Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:expandtab:shiftwidth=2:tabstop=2: |
michael@0 | 3 | */ |
michael@0 | 4 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #include "ia2AccessibleEditableText.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "AccessibleEditableText_i.c" |
michael@0 | 11 | #include "HyperTextAccessible-inl.h" |
michael@0 | 12 | #include "HyperTextAccessibleWrap.h" |
michael@0 | 13 | |
michael@0 | 14 | #include "nsCOMPtr.h" |
michael@0 | 15 | #include "nsString.h" |
michael@0 | 16 | |
michael@0 | 17 | using namespace mozilla::a11y; |
michael@0 | 18 | |
michael@0 | 19 | // IAccessibleEditableText |
michael@0 | 20 | |
michael@0 | 21 | STDMETHODIMP |
michael@0 | 22 | ia2AccessibleEditableText::copyText(long aStartOffset, long aEndOffset) |
michael@0 | 23 | { |
michael@0 | 24 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 25 | |
michael@0 | 26 | HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); |
michael@0 | 27 | if (textAcc->IsDefunct()) |
michael@0 | 28 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 29 | |
michael@0 | 30 | if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) |
michael@0 | 31 | return E_INVALIDARG; |
michael@0 | 32 | |
michael@0 | 33 | textAcc->CopyText(aStartOffset, aEndOffset); |
michael@0 | 34 | return S_OK; |
michael@0 | 35 | |
michael@0 | 36 | A11Y_TRYBLOCK_END |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | STDMETHODIMP |
michael@0 | 40 | ia2AccessibleEditableText::deleteText(long aStartOffset, long aEndOffset) |
michael@0 | 41 | { |
michael@0 | 42 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 43 | |
michael@0 | 44 | HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); |
michael@0 | 45 | if (textAcc->IsDefunct()) |
michael@0 | 46 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 47 | |
michael@0 | 48 | if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) |
michael@0 | 49 | return E_INVALIDARG; |
michael@0 | 50 | |
michael@0 | 51 | textAcc->DeleteText(aStartOffset, aEndOffset); |
michael@0 | 52 | return S_OK; |
michael@0 | 53 | |
michael@0 | 54 | A11Y_TRYBLOCK_END |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | STDMETHODIMP |
michael@0 | 58 | ia2AccessibleEditableText::insertText(long aOffset, BSTR *aText) |
michael@0 | 59 | { |
michael@0 | 60 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 61 | |
michael@0 | 62 | HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); |
michael@0 | 63 | if (textAcc->IsDefunct()) |
michael@0 | 64 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 65 | |
michael@0 | 66 | if (!textAcc->IsValidOffset(aOffset)) |
michael@0 | 67 | return E_INVALIDARG; |
michael@0 | 68 | |
michael@0 | 69 | uint32_t length = ::SysStringLen(*aText); |
michael@0 | 70 | nsAutoString text(*aText, length); |
michael@0 | 71 | |
michael@0 | 72 | textAcc->InsertText(text, aOffset); |
michael@0 | 73 | return S_OK; |
michael@0 | 74 | |
michael@0 | 75 | A11Y_TRYBLOCK_END |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | STDMETHODIMP |
michael@0 | 79 | ia2AccessibleEditableText::cutText(long aStartOffset, long aEndOffset) |
michael@0 | 80 | { |
michael@0 | 81 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 82 | |
michael@0 | 83 | HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); |
michael@0 | 84 | if (textAcc->IsDefunct()) |
michael@0 | 85 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 86 | |
michael@0 | 87 | if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) |
michael@0 | 88 | return E_INVALIDARG; |
michael@0 | 89 | |
michael@0 | 90 | textAcc->CutText(aStartOffset, aEndOffset); |
michael@0 | 91 | return S_OK; |
michael@0 | 92 | |
michael@0 | 93 | A11Y_TRYBLOCK_END |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | STDMETHODIMP |
michael@0 | 97 | ia2AccessibleEditableText::pasteText(long aOffset) |
michael@0 | 98 | { |
michael@0 | 99 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 100 | |
michael@0 | 101 | HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); |
michael@0 | 102 | if (textAcc->IsDefunct()) |
michael@0 | 103 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 104 | |
michael@0 | 105 | if (!textAcc->IsValidOffset(aOffset)) |
michael@0 | 106 | return E_INVALIDARG; |
michael@0 | 107 | |
michael@0 | 108 | textAcc->PasteText(aOffset); |
michael@0 | 109 | return S_OK; |
michael@0 | 110 | |
michael@0 | 111 | A11Y_TRYBLOCK_END |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | STDMETHODIMP |
michael@0 | 115 | ia2AccessibleEditableText::replaceText(long aStartOffset, long aEndOffset, |
michael@0 | 116 | BSTR *aText) |
michael@0 | 117 | { |
michael@0 | 118 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 119 | |
michael@0 | 120 | HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this); |
michael@0 | 121 | if (textAcc->IsDefunct()) |
michael@0 | 122 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 123 | |
michael@0 | 124 | if (!textAcc->IsValidRange(aStartOffset, aEndOffset)) |
michael@0 | 125 | return E_INVALIDARG; |
michael@0 | 126 | |
michael@0 | 127 | textAcc->DeleteText(aStartOffset, aEndOffset); |
michael@0 | 128 | |
michael@0 | 129 | uint32_t length = ::SysStringLen(*aText); |
michael@0 | 130 | nsAutoString text(*aText, length); |
michael@0 | 131 | textAcc->InsertText(text, aStartOffset); |
michael@0 | 132 | |
michael@0 | 133 | return S_OK; |
michael@0 | 134 | |
michael@0 | 135 | A11Y_TRYBLOCK_END |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | STDMETHODIMP |
michael@0 | 139 | ia2AccessibleEditableText::setAttributes(long aStartOffset, long aEndOffset, |
michael@0 | 140 | BSTR *aAttributes) |
michael@0 | 141 | { |
michael@0 | 142 | return E_NOTIMPL; |
michael@0 | 143 | } |