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 "ia2AccessibleTableCell.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "Accessible2.h" |
michael@0 | 11 | #include "AccessibleTable2_i.c" |
michael@0 | 12 | #include "AccessibleTableCell_i.c" |
michael@0 | 13 | |
michael@0 | 14 | #include "AccessibleWrap.h" |
michael@0 | 15 | #include "TableAccessible.h" |
michael@0 | 16 | #include "TableCellAccessible.h" |
michael@0 | 17 | #include "IUnknownImpl.h" |
michael@0 | 18 | |
michael@0 | 19 | #include "nsCOMPtr.h" |
michael@0 | 20 | #include "nsString.h" |
michael@0 | 21 | |
michael@0 | 22 | using namespace mozilla::a11y; |
michael@0 | 23 | |
michael@0 | 24 | // IUnknown |
michael@0 | 25 | |
michael@0 | 26 | STDMETHODIMP |
michael@0 | 27 | ia2AccessibleTableCell::QueryInterface(REFIID iid, void** ppv) |
michael@0 | 28 | { |
michael@0 | 29 | if (!ppv) |
michael@0 | 30 | return E_INVALIDARG; |
michael@0 | 31 | |
michael@0 | 32 | *ppv = nullptr; |
michael@0 | 33 | |
michael@0 | 34 | if (IID_IAccessibleTableCell == iid) { |
michael@0 | 35 | *ppv = static_cast<IAccessibleTableCell*>(this); |
michael@0 | 36 | (reinterpret_cast<IUnknown*>(*ppv))->AddRef(); |
michael@0 | 37 | return S_OK; |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | return E_NOINTERFACE; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 44 | // IAccessibleTableCell |
michael@0 | 45 | |
michael@0 | 46 | STDMETHODIMP |
michael@0 | 47 | ia2AccessibleTableCell::get_table(IUnknown** aTable) |
michael@0 | 48 | { |
michael@0 | 49 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 50 | |
michael@0 | 51 | if (!aTable) |
michael@0 | 52 | return E_INVALIDARG; |
michael@0 | 53 | |
michael@0 | 54 | *aTable = nullptr; |
michael@0 | 55 | if (!mTableCell) |
michael@0 | 56 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 57 | |
michael@0 | 58 | TableAccessible* table = mTableCell->Table(); |
michael@0 | 59 | if (!table) |
michael@0 | 60 | return E_FAIL; |
michael@0 | 61 | |
michael@0 | 62 | AccessibleWrap* wrap = static_cast<AccessibleWrap*>(table->AsAccessible()); |
michael@0 | 63 | *aTable = static_cast<IAccessible*>(wrap); |
michael@0 | 64 | (*aTable)->AddRef(); |
michael@0 | 65 | return S_OK; |
michael@0 | 66 | |
michael@0 | 67 | A11Y_TRYBLOCK_END |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | STDMETHODIMP |
michael@0 | 71 | ia2AccessibleTableCell::get_columnExtent(long* aSpan) |
michael@0 | 72 | { |
michael@0 | 73 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 74 | |
michael@0 | 75 | if (!aSpan) |
michael@0 | 76 | return E_INVALIDARG; |
michael@0 | 77 | |
michael@0 | 78 | *aSpan = 0; |
michael@0 | 79 | if (!mTableCell) |
michael@0 | 80 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 81 | |
michael@0 | 82 | *aSpan = mTableCell->ColExtent(); |
michael@0 | 83 | |
michael@0 | 84 | return S_OK; |
michael@0 | 85 | |
michael@0 | 86 | A11Y_TRYBLOCK_END |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | STDMETHODIMP |
michael@0 | 90 | ia2AccessibleTableCell::get_columnHeaderCells(IUnknown*** aCellAccessibles, |
michael@0 | 91 | long* aNColumnHeaderCells) |
michael@0 | 92 | { |
michael@0 | 93 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 94 | |
michael@0 | 95 | if (!aCellAccessibles || !aNColumnHeaderCells) |
michael@0 | 96 | return E_INVALIDARG; |
michael@0 | 97 | |
michael@0 | 98 | *aCellAccessibles = nullptr; |
michael@0 | 99 | *aNColumnHeaderCells = 0; |
michael@0 | 100 | if (!mTableCell) |
michael@0 | 101 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 102 | |
michael@0 | 103 | nsAutoTArray<Accessible*, 10> cells; |
michael@0 | 104 | mTableCell->ColHeaderCells(&cells); |
michael@0 | 105 | |
michael@0 | 106 | *aNColumnHeaderCells = cells.Length(); |
michael@0 | 107 | *aCellAccessibles = |
michael@0 | 108 | static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) * |
michael@0 | 109 | cells.Length())); |
michael@0 | 110 | |
michael@0 | 111 | if (!*aCellAccessibles) |
michael@0 | 112 | return E_OUTOFMEMORY; |
michael@0 | 113 | |
michael@0 | 114 | for (uint32_t i = 0; i < cells.Length(); i++) { |
michael@0 | 115 | AccessibleWrap* cell = static_cast<AccessibleWrap*>(cells[i]); |
michael@0 | 116 | (*aCellAccessibles)[i] = static_cast<IAccessible*>(cell); |
michael@0 | 117 | (*aCellAccessibles)[i]->AddRef(); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | return S_OK; |
michael@0 | 121 | |
michael@0 | 122 | A11Y_TRYBLOCK_END |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | STDMETHODIMP |
michael@0 | 126 | ia2AccessibleTableCell::get_columnIndex(long* aColIdx) |
michael@0 | 127 | { |
michael@0 | 128 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 129 | |
michael@0 | 130 | if (!aColIdx) |
michael@0 | 131 | return E_INVALIDARG; |
michael@0 | 132 | |
michael@0 | 133 | *aColIdx = -1; |
michael@0 | 134 | if (!mTableCell) |
michael@0 | 135 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 136 | |
michael@0 | 137 | *aColIdx = mTableCell->ColIdx(); |
michael@0 | 138 | return S_OK; |
michael@0 | 139 | |
michael@0 | 140 | A11Y_TRYBLOCK_END |
michael@0 | 141 | } |
michael@0 | 142 | |
michael@0 | 143 | STDMETHODIMP |
michael@0 | 144 | ia2AccessibleTableCell::get_rowExtent(long* aSpan) |
michael@0 | 145 | { |
michael@0 | 146 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 147 | |
michael@0 | 148 | if (!aSpan) |
michael@0 | 149 | return E_INVALIDARG; |
michael@0 | 150 | |
michael@0 | 151 | *aSpan = 0; |
michael@0 | 152 | if (!mTableCell) |
michael@0 | 153 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 154 | |
michael@0 | 155 | *aSpan = mTableCell->RowExtent(); |
michael@0 | 156 | return S_OK; |
michael@0 | 157 | |
michael@0 | 158 | A11Y_TRYBLOCK_END |
michael@0 | 159 | } |
michael@0 | 160 | |
michael@0 | 161 | STDMETHODIMP |
michael@0 | 162 | ia2AccessibleTableCell::get_rowHeaderCells(IUnknown*** aCellAccessibles, |
michael@0 | 163 | long* aNRowHeaderCells) |
michael@0 | 164 | { |
michael@0 | 165 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 166 | |
michael@0 | 167 | if (!aCellAccessibles || !aNRowHeaderCells) |
michael@0 | 168 | return E_INVALIDARG; |
michael@0 | 169 | |
michael@0 | 170 | *aCellAccessibles = nullptr; |
michael@0 | 171 | *aNRowHeaderCells = 0; |
michael@0 | 172 | if (!mTableCell) |
michael@0 | 173 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 174 | |
michael@0 | 175 | nsAutoTArray<Accessible*, 10> cells; |
michael@0 | 176 | mTableCell->RowHeaderCells(&cells); |
michael@0 | 177 | |
michael@0 | 178 | *aNRowHeaderCells = cells.Length(); |
michael@0 | 179 | *aCellAccessibles = |
michael@0 | 180 | static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) * |
michael@0 | 181 | cells.Length())); |
michael@0 | 182 | if (!*aCellAccessibles) |
michael@0 | 183 | return E_OUTOFMEMORY; |
michael@0 | 184 | |
michael@0 | 185 | for (uint32_t i = 0; i < cells.Length(); i++) { |
michael@0 | 186 | AccessibleWrap* cell = static_cast<AccessibleWrap*>(cells[i]); |
michael@0 | 187 | (*aCellAccessibles)[i] = static_cast<IAccessible*>(cell); |
michael@0 | 188 | (*aCellAccessibles)[i]->AddRef(); |
michael@0 | 189 | } |
michael@0 | 190 | |
michael@0 | 191 | return S_OK; |
michael@0 | 192 | |
michael@0 | 193 | A11Y_TRYBLOCK_END |
michael@0 | 194 | } |
michael@0 | 195 | |
michael@0 | 196 | STDMETHODIMP |
michael@0 | 197 | ia2AccessibleTableCell::get_rowIndex(long* aRowIdx) |
michael@0 | 198 | { |
michael@0 | 199 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 200 | |
michael@0 | 201 | if (!aRowIdx) |
michael@0 | 202 | return E_INVALIDARG; |
michael@0 | 203 | |
michael@0 | 204 | *aRowIdx = -1; |
michael@0 | 205 | if (!mTableCell) |
michael@0 | 206 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 207 | |
michael@0 | 208 | *aRowIdx = mTableCell->RowIdx(); |
michael@0 | 209 | return S_OK; |
michael@0 | 210 | |
michael@0 | 211 | A11Y_TRYBLOCK_END |
michael@0 | 212 | } |
michael@0 | 213 | |
michael@0 | 214 | STDMETHODIMP |
michael@0 | 215 | ia2AccessibleTableCell::get_rowColumnExtents(long* aRowIdx, long* aColIdx, |
michael@0 | 216 | long* aRowExtents, |
michael@0 | 217 | long* aColExtents, |
michael@0 | 218 | boolean* aIsSelected) |
michael@0 | 219 | { |
michael@0 | 220 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 221 | |
michael@0 | 222 | if (!aRowIdx || !aColIdx || !aRowExtents || !aColExtents || !aIsSelected) |
michael@0 | 223 | return E_INVALIDARG; |
michael@0 | 224 | |
michael@0 | 225 | *aRowIdx = *aColIdx = *aRowExtents = *aColExtents = 0; |
michael@0 | 226 | *aIsSelected = false; |
michael@0 | 227 | if (!mTableCell) |
michael@0 | 228 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 229 | |
michael@0 | 230 | *aRowIdx = mTableCell->RowIdx(); |
michael@0 | 231 | *aColIdx = mTableCell->ColIdx(); |
michael@0 | 232 | *aRowExtents = mTableCell->RowExtent(); |
michael@0 | 233 | *aColExtents = mTableCell->ColExtent(); |
michael@0 | 234 | *aIsSelected = mTableCell->Selected(); |
michael@0 | 235 | |
michael@0 | 236 | return S_OK; |
michael@0 | 237 | |
michael@0 | 238 | A11Y_TRYBLOCK_END |
michael@0 | 239 | } |
michael@0 | 240 | |
michael@0 | 241 | STDMETHODIMP |
michael@0 | 242 | ia2AccessibleTableCell::get_isSelected(boolean* aIsSelected) |
michael@0 | 243 | { |
michael@0 | 244 | A11Y_TRYBLOCK_BEGIN |
michael@0 | 245 | |
michael@0 | 246 | if (!aIsSelected) |
michael@0 | 247 | return E_INVALIDARG; |
michael@0 | 248 | |
michael@0 | 249 | *aIsSelected = false; |
michael@0 | 250 | if (!mTableCell) |
michael@0 | 251 | return CO_E_OBJNOTCONNECTED; |
michael@0 | 252 | |
michael@0 | 253 | *aIsSelected = mTableCell->Selected(); |
michael@0 | 254 | return S_OK; |
michael@0 | 255 | |
michael@0 | 256 | A11Y_TRYBLOCK_END |
michael@0 | 257 | } |