accessible/src/windows/ia2/ia2AccessibleTable.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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 "ia2AccessibleTable.h"
michael@0 9
michael@0 10 #include "Accessible2.h"
michael@0 11 #include "AccessibleTable_i.c"
michael@0 12 #include "AccessibleTable2_i.c"
michael@0 13
michael@0 14 #include "AccessibleWrap.h"
michael@0 15 #include "IUnknownImpl.h"
michael@0 16 #include "Statistics.h"
michael@0 17 #include "TableAccessible.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 ia2AccessibleTable::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_IAccessibleTable == iid) {
michael@0 35 statistics::IAccessibleTableUsed();
michael@0 36 *ppv = static_cast<IAccessibleTable*>(this);
michael@0 37 (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
michael@0 38 return S_OK;
michael@0 39 }
michael@0 40
michael@0 41 if (IID_IAccessibleTable2 == iid) {
michael@0 42 *ppv = static_cast<IAccessibleTable2*>(this);
michael@0 43 (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
michael@0 44 return S_OK;
michael@0 45 }
michael@0 46
michael@0 47 return E_NOINTERFACE;
michael@0 48 }
michael@0 49
michael@0 50 ////////////////////////////////////////////////////////////////////////////////
michael@0 51 // IAccessibleTable
michael@0 52
michael@0 53 STDMETHODIMP
michael@0 54 ia2AccessibleTable::get_accessibleAt(long aRowIdx, long aColIdx,
michael@0 55 IUnknown** aAccessible)
michael@0 56 {
michael@0 57 return get_cellAt(aRowIdx, aColIdx, aAccessible);
michael@0 58 }
michael@0 59
michael@0 60 STDMETHODIMP
michael@0 61 ia2AccessibleTable::get_caption(IUnknown** aAccessible)
michael@0 62 {
michael@0 63 A11Y_TRYBLOCK_BEGIN
michael@0 64
michael@0 65 if (!aAccessible)
michael@0 66 return E_INVALIDARG;
michael@0 67
michael@0 68 *aAccessible = nullptr;
michael@0 69 if (!mTable)
michael@0 70 return CO_E_OBJNOTCONNECTED;
michael@0 71
michael@0 72 AccessibleWrap* caption = static_cast<AccessibleWrap*>(mTable->Caption());
michael@0 73 if (!caption)
michael@0 74 return S_FALSE;
michael@0 75
michael@0 76 (*aAccessible = static_cast<IAccessible*>(caption))->AddRef();
michael@0 77 return S_OK;
michael@0 78
michael@0 79 A11Y_TRYBLOCK_END
michael@0 80 }
michael@0 81
michael@0 82 STDMETHODIMP
michael@0 83 ia2AccessibleTable::get_childIndex(long aRowIdx, long aColIdx,
michael@0 84 long* aChildIdx)
michael@0 85 {
michael@0 86 A11Y_TRYBLOCK_BEGIN
michael@0 87
michael@0 88 if (!aChildIdx)
michael@0 89 return E_INVALIDARG;
michael@0 90
michael@0 91 *aChildIdx = 0;
michael@0 92 if (!mTable)
michael@0 93 return CO_E_OBJNOTCONNECTED;
michael@0 94
michael@0 95 if (aRowIdx < 0 || aColIdx < 0 ||
michael@0 96 static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
michael@0 97 static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
michael@0 98 return E_INVALIDARG;
michael@0 99
michael@0 100 *aChildIdx = mTable->CellIndexAt(aRowIdx, aColIdx);
michael@0 101 return S_OK;
michael@0 102
michael@0 103 A11Y_TRYBLOCK_END
michael@0 104 }
michael@0 105
michael@0 106 STDMETHODIMP
michael@0 107 ia2AccessibleTable::get_columnDescription(long aColIdx, BSTR* aDescription)
michael@0 108 {
michael@0 109 A11Y_TRYBLOCK_BEGIN
michael@0 110
michael@0 111 if (!aDescription)
michael@0 112 return E_INVALIDARG;
michael@0 113
michael@0 114 *aDescription = nullptr;
michael@0 115 if (!mTable)
michael@0 116 return CO_E_OBJNOTCONNECTED;
michael@0 117
michael@0 118 if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
michael@0 119 return E_INVALIDARG;
michael@0 120
michael@0 121 nsAutoString descr;
michael@0 122 mTable->ColDescription(aColIdx, descr);
michael@0 123 if (descr.IsEmpty())
michael@0 124 return S_FALSE;
michael@0 125
michael@0 126 *aDescription = ::SysAllocStringLen(descr.get(), descr.Length());
michael@0 127 return *aDescription ? S_OK : E_OUTOFMEMORY;
michael@0 128
michael@0 129 A11Y_TRYBLOCK_END
michael@0 130 }
michael@0 131
michael@0 132 STDMETHODIMP
michael@0 133 ia2AccessibleTable::get_columnExtentAt(long aRowIdx, long aColIdx,
michael@0 134 long* aSpan)
michael@0 135 {
michael@0 136 A11Y_TRYBLOCK_BEGIN
michael@0 137
michael@0 138 if (!aSpan)
michael@0 139 return E_INVALIDARG;
michael@0 140
michael@0 141 *aSpan = 0;
michael@0 142 if (!mTable)
michael@0 143 return CO_E_OBJNOTCONNECTED;
michael@0 144
michael@0 145 if (aRowIdx < 0 || aColIdx < 0 ||
michael@0 146 static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
michael@0 147 static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
michael@0 148 return E_INVALIDARG;
michael@0 149
michael@0 150 *aSpan = mTable->ColExtentAt(aRowIdx, aColIdx);
michael@0 151 return S_OK;
michael@0 152
michael@0 153 A11Y_TRYBLOCK_END
michael@0 154 }
michael@0 155
michael@0 156 STDMETHODIMP
michael@0 157 ia2AccessibleTable::get_columnHeader(IAccessibleTable** aAccessibleTable,
michael@0 158 long* aStartingRowIndex)
michael@0 159 {
michael@0 160 A11Y_TRYBLOCK_BEGIN
michael@0 161
michael@0 162 if (!aAccessibleTable || !aStartingRowIndex)
michael@0 163 return E_INVALIDARG;
michael@0 164
michael@0 165 *aAccessibleTable = nullptr;
michael@0 166 *aStartingRowIndex = -1;
michael@0 167 return E_NOTIMPL;
michael@0 168
michael@0 169 A11Y_TRYBLOCK_END
michael@0 170 }
michael@0 171
michael@0 172 STDMETHODIMP
michael@0 173 ia2AccessibleTable::get_columnIndex(long aCellIdx, long* aColIdx)
michael@0 174 {
michael@0 175 A11Y_TRYBLOCK_BEGIN
michael@0 176
michael@0 177 if (!aColIdx)
michael@0 178 return E_INVALIDARG;
michael@0 179
michael@0 180 *aColIdx = 0;
michael@0 181 if (!mTable)
michael@0 182 return CO_E_OBJNOTCONNECTED;
michael@0 183
michael@0 184 if (aCellIdx < 0 ||
michael@0 185 static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
michael@0 186 return E_INVALIDARG;
michael@0 187
michael@0 188 *aColIdx = mTable->ColIndexAt(aCellIdx);
michael@0 189 return S_OK;
michael@0 190
michael@0 191 A11Y_TRYBLOCK_END
michael@0 192 }
michael@0 193
michael@0 194 STDMETHODIMP
michael@0 195 ia2AccessibleTable::get_nColumns(long* aColCount)
michael@0 196 {
michael@0 197 A11Y_TRYBLOCK_BEGIN
michael@0 198
michael@0 199 if (!aColCount)
michael@0 200 return E_INVALIDARG;
michael@0 201
michael@0 202 *aColCount = 0;
michael@0 203 if (!mTable)
michael@0 204 return CO_E_OBJNOTCONNECTED;
michael@0 205
michael@0 206 *aColCount = mTable->ColCount();
michael@0 207 return S_OK;
michael@0 208
michael@0 209 A11Y_TRYBLOCK_END
michael@0 210 }
michael@0 211
michael@0 212 STDMETHODIMP
michael@0 213 ia2AccessibleTable::get_nRows(long* aRowCount)
michael@0 214 {
michael@0 215 A11Y_TRYBLOCK_BEGIN
michael@0 216
michael@0 217 if (!aRowCount)
michael@0 218 return E_INVALIDARG;
michael@0 219
michael@0 220 *aRowCount = 0;
michael@0 221 if (!mTable)
michael@0 222 return CO_E_OBJNOTCONNECTED;
michael@0 223
michael@0 224 *aRowCount = mTable->RowCount();
michael@0 225 return S_OK;
michael@0 226
michael@0 227 A11Y_TRYBLOCK_END
michael@0 228 }
michael@0 229
michael@0 230 STDMETHODIMP
michael@0 231 ia2AccessibleTable::get_nSelectedChildren(long* aChildCount)
michael@0 232 {
michael@0 233 return get_nSelectedCells(aChildCount);
michael@0 234 }
michael@0 235
michael@0 236 STDMETHODIMP
michael@0 237 ia2AccessibleTable::get_nSelectedColumns(long* aColCount)
michael@0 238 {
michael@0 239 A11Y_TRYBLOCK_BEGIN
michael@0 240
michael@0 241 if (!aColCount)
michael@0 242 return E_INVALIDARG;
michael@0 243
michael@0 244 *aColCount = 0;
michael@0 245 if (!mTable)
michael@0 246 return CO_E_OBJNOTCONNECTED;
michael@0 247
michael@0 248 *aColCount = mTable->SelectedColCount();
michael@0 249 return S_OK;
michael@0 250
michael@0 251 A11Y_TRYBLOCK_END
michael@0 252 }
michael@0 253
michael@0 254 STDMETHODIMP
michael@0 255 ia2AccessibleTable::get_nSelectedRows(long* aRowCount)
michael@0 256 {
michael@0 257 A11Y_TRYBLOCK_BEGIN
michael@0 258
michael@0 259 if (!aRowCount)
michael@0 260 return E_INVALIDARG;
michael@0 261
michael@0 262 *aRowCount = 0;
michael@0 263 if (!mTable)
michael@0 264 return CO_E_OBJNOTCONNECTED;
michael@0 265
michael@0 266 *aRowCount = mTable->SelectedRowCount();
michael@0 267
michael@0 268 return S_OK;
michael@0 269
michael@0 270 A11Y_TRYBLOCK_END
michael@0 271 }
michael@0 272
michael@0 273 STDMETHODIMP
michael@0 274 ia2AccessibleTable::get_rowDescription(long aRowIdx, BSTR* aDescription)
michael@0 275 {
michael@0 276 A11Y_TRYBLOCK_BEGIN
michael@0 277
michael@0 278 if (!aDescription)
michael@0 279 return E_INVALIDARG;
michael@0 280
michael@0 281 *aDescription = nullptr;
michael@0 282 if (!mTable)
michael@0 283 return CO_E_OBJNOTCONNECTED;
michael@0 284
michael@0 285 if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
michael@0 286 return E_INVALIDARG;
michael@0 287
michael@0 288 nsAutoString descr;
michael@0 289 mTable->RowDescription(aRowIdx, descr);
michael@0 290 if (descr.IsEmpty())
michael@0 291 return S_FALSE;
michael@0 292
michael@0 293 *aDescription = ::SysAllocStringLen(descr.get(), descr.Length());
michael@0 294 return *aDescription ? S_OK : E_OUTOFMEMORY;
michael@0 295
michael@0 296 A11Y_TRYBLOCK_END
michael@0 297 }
michael@0 298
michael@0 299 STDMETHODIMP
michael@0 300 ia2AccessibleTable::get_rowExtentAt(long aRowIdx, long aColIdx, long* aSpan)
michael@0 301 {
michael@0 302 A11Y_TRYBLOCK_BEGIN
michael@0 303
michael@0 304 if (!aSpan)
michael@0 305 return E_INVALIDARG;
michael@0 306
michael@0 307 *aSpan = 0;
michael@0 308 if (!mTable)
michael@0 309 return CO_E_OBJNOTCONNECTED;
michael@0 310
michael@0 311 if (aRowIdx < 0 || aColIdx < 0 ||
michael@0 312 static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
michael@0 313 static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
michael@0 314 return E_INVALIDARG;
michael@0 315
michael@0 316 *aSpan = mTable->RowExtentAt(aRowIdx, aColIdx);
michael@0 317 return S_OK;
michael@0 318
michael@0 319 A11Y_TRYBLOCK_END
michael@0 320 }
michael@0 321
michael@0 322 STDMETHODIMP
michael@0 323 ia2AccessibleTable::get_rowHeader(IAccessibleTable** aAccessibleTable,
michael@0 324 long* aStartingColumnIndex)
michael@0 325 {
michael@0 326 A11Y_TRYBLOCK_BEGIN
michael@0 327
michael@0 328 if (!aAccessibleTable || !aStartingColumnIndex)
michael@0 329 return E_INVALIDARG;
michael@0 330
michael@0 331 *aAccessibleTable = nullptr;
michael@0 332 *aStartingColumnIndex = -1;
michael@0 333 return E_NOTIMPL;
michael@0 334
michael@0 335 A11Y_TRYBLOCK_END
michael@0 336 }
michael@0 337
michael@0 338 STDMETHODIMP
michael@0 339 ia2AccessibleTable::get_rowIndex(long aCellIdx, long* aRowIdx)
michael@0 340 {
michael@0 341 A11Y_TRYBLOCK_BEGIN
michael@0 342
michael@0 343 if (!aRowIdx)
michael@0 344 return E_INVALIDARG;
michael@0 345
michael@0 346 *aRowIdx = 0;
michael@0 347 if (!mTable)
michael@0 348 return CO_E_OBJNOTCONNECTED;
michael@0 349
michael@0 350 if (aCellIdx < 0 ||
michael@0 351 static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
michael@0 352 return E_INVALIDARG;
michael@0 353
michael@0 354 *aRowIdx = mTable->RowIndexAt(aCellIdx);
michael@0 355 return S_OK;
michael@0 356
michael@0 357 A11Y_TRYBLOCK_END
michael@0 358 }
michael@0 359
michael@0 360 STDMETHODIMP
michael@0 361 ia2AccessibleTable::get_selectedChildren(long aMaxChildren, long** aChildren,
michael@0 362 long* aNChildren)
michael@0 363 {
michael@0 364 A11Y_TRYBLOCK_BEGIN
michael@0 365
michael@0 366 if (!aChildren || !aNChildren)
michael@0 367 return E_INVALIDARG;
michael@0 368
michael@0 369 *aChildren = nullptr;
michael@0 370 *aNChildren = 0;
michael@0 371 if (!mTable)
michael@0 372 return CO_E_OBJNOTCONNECTED;
michael@0 373
michael@0 374 nsAutoTArray<uint32_t, 30> cellIndices;
michael@0 375 mTable->SelectedCellIndices(&cellIndices);
michael@0 376
michael@0 377 uint32_t maxCells = cellIndices.Length();
michael@0 378 if (maxCells == 0)
michael@0 379 return S_FALSE;
michael@0 380
michael@0 381 *aChildren = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxCells));
michael@0 382 *aNChildren = maxCells;
michael@0 383 for (uint32_t i = 0; i < maxCells; i++)
michael@0 384 (*aChildren)[i] = cellIndices[i];
michael@0 385
michael@0 386 return S_OK;
michael@0 387
michael@0 388 A11Y_TRYBLOCK_END
michael@0 389 }
michael@0 390
michael@0 391 STDMETHODIMP
michael@0 392 ia2AccessibleTable::get_selectedColumns(long aMaxColumns, long** aColumns,
michael@0 393 long* aNColumns)
michael@0 394 {
michael@0 395 A11Y_TRYBLOCK_BEGIN
michael@0 396
michael@0 397 return get_selectedColumns(aColumns, aNColumns);
michael@0 398
michael@0 399 A11Y_TRYBLOCK_END
michael@0 400 }
michael@0 401
michael@0 402 STDMETHODIMP
michael@0 403 ia2AccessibleTable::get_selectedRows(long aMaxRows, long** aRows, long* aNRows)
michael@0 404 {
michael@0 405 A11Y_TRYBLOCK_BEGIN
michael@0 406
michael@0 407 return get_selectedRows(aRows, aNRows);
michael@0 408
michael@0 409 A11Y_TRYBLOCK_END
michael@0 410 }
michael@0 411
michael@0 412 STDMETHODIMP
michael@0 413 ia2AccessibleTable::get_summary(IUnknown** aAccessible)
michael@0 414 {
michael@0 415 A11Y_TRYBLOCK_BEGIN
michael@0 416
michael@0 417 if (!aAccessible)
michael@0 418 return E_INVALIDARG;
michael@0 419
michael@0 420 // Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
michael@0 421 // link an accessible object to specify a summary. There is closes method
michael@0 422 // in nsIAccessibleTable::summary to get a summary as a string which is not
michael@0 423 // mapped directly to IAccessible2.
michael@0 424
michael@0 425 *aAccessible = nullptr;
michael@0 426 return S_FALSE;
michael@0 427
michael@0 428 A11Y_TRYBLOCK_END
michael@0 429 }
michael@0 430
michael@0 431 STDMETHODIMP
michael@0 432 ia2AccessibleTable::get_isColumnSelected(long aColIdx, boolean* aIsSelected)
michael@0 433 {
michael@0 434 A11Y_TRYBLOCK_BEGIN
michael@0 435
michael@0 436 if (!aIsSelected)
michael@0 437 return E_INVALIDARG;
michael@0 438
michael@0 439 *aIsSelected = false;
michael@0 440 if (!mTable)
michael@0 441 return CO_E_OBJNOTCONNECTED;
michael@0 442
michael@0 443 if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
michael@0 444 return E_INVALIDARG;
michael@0 445
michael@0 446 *aIsSelected = mTable->IsColSelected(aColIdx);
michael@0 447 return S_OK;
michael@0 448
michael@0 449 A11Y_TRYBLOCK_END
michael@0 450 }
michael@0 451
michael@0 452 STDMETHODIMP
michael@0 453 ia2AccessibleTable::get_isRowSelected(long aRowIdx, boolean* aIsSelected)
michael@0 454 {
michael@0 455 A11Y_TRYBLOCK_BEGIN
michael@0 456
michael@0 457 if (!aIsSelected)
michael@0 458 return E_INVALIDARG;
michael@0 459
michael@0 460 *aIsSelected = false;
michael@0 461 if (!mTable)
michael@0 462 return CO_E_OBJNOTCONNECTED;
michael@0 463
michael@0 464 if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
michael@0 465 return E_INVALIDARG;
michael@0 466
michael@0 467 *aIsSelected = mTable->IsRowSelected(aRowIdx);
michael@0 468 return S_OK;
michael@0 469
michael@0 470 A11Y_TRYBLOCK_END
michael@0 471 }
michael@0 472
michael@0 473 STDMETHODIMP
michael@0 474 ia2AccessibleTable::get_isSelected(long aRowIdx, long aColIdx,
michael@0 475 boolean* aIsSelected)
michael@0 476 {
michael@0 477 A11Y_TRYBLOCK_BEGIN
michael@0 478
michael@0 479 if (!aIsSelected)
michael@0 480 return E_INVALIDARG;
michael@0 481
michael@0 482 *aIsSelected = false;
michael@0 483 if (!mTable)
michael@0 484 return CO_E_OBJNOTCONNECTED;
michael@0 485
michael@0 486 if (aRowIdx < 0 || aColIdx < 0 ||
michael@0 487 static_cast<uint32_t>(aColIdx) >= mTable->ColCount() ||
michael@0 488 static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
michael@0 489 return E_INVALIDARG;
michael@0 490
michael@0 491 *aIsSelected = mTable->IsCellSelected(aRowIdx, aColIdx);
michael@0 492 return S_OK;
michael@0 493
michael@0 494 A11Y_TRYBLOCK_END
michael@0 495 }
michael@0 496
michael@0 497 STDMETHODIMP
michael@0 498 ia2AccessibleTable::selectRow(long aRowIdx)
michael@0 499 {
michael@0 500 A11Y_TRYBLOCK_BEGIN
michael@0 501
michael@0 502 if (!mTable)
michael@0 503 return CO_E_OBJNOTCONNECTED;
michael@0 504
michael@0 505 if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
michael@0 506 return E_INVALIDARG;
michael@0 507
michael@0 508 mTable->SelectRow(aRowIdx);
michael@0 509 return S_OK;
michael@0 510
michael@0 511 A11Y_TRYBLOCK_END
michael@0 512 }
michael@0 513
michael@0 514 STDMETHODIMP
michael@0 515 ia2AccessibleTable::selectColumn(long aColIdx)
michael@0 516 {
michael@0 517 A11Y_TRYBLOCK_BEGIN
michael@0 518
michael@0 519 if (!mTable)
michael@0 520 return CO_E_OBJNOTCONNECTED;
michael@0 521
michael@0 522 if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
michael@0 523 return E_INVALIDARG;
michael@0 524
michael@0 525 mTable->SelectCol(aColIdx);
michael@0 526 return S_OK;
michael@0 527
michael@0 528 A11Y_TRYBLOCK_END
michael@0 529 }
michael@0 530
michael@0 531 STDMETHODIMP
michael@0 532 ia2AccessibleTable::unselectRow(long aRowIdx)
michael@0 533 {
michael@0 534 A11Y_TRYBLOCK_BEGIN
michael@0 535
michael@0 536 if (!mTable)
michael@0 537 return CO_E_OBJNOTCONNECTED;
michael@0 538
michael@0 539 if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
michael@0 540 return E_INVALIDARG;
michael@0 541
michael@0 542 mTable->UnselectRow(aRowIdx);
michael@0 543 return S_OK;
michael@0 544
michael@0 545 A11Y_TRYBLOCK_END
michael@0 546 }
michael@0 547
michael@0 548 STDMETHODIMP
michael@0 549 ia2AccessibleTable::unselectColumn(long aColIdx)
michael@0 550 {
michael@0 551 A11Y_TRYBLOCK_BEGIN
michael@0 552
michael@0 553 if (!mTable)
michael@0 554 return CO_E_OBJNOTCONNECTED;
michael@0 555
michael@0 556 if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
michael@0 557 return E_INVALIDARG;
michael@0 558
michael@0 559 mTable->UnselectCol(aColIdx);
michael@0 560 return S_OK;
michael@0 561
michael@0 562 A11Y_TRYBLOCK_END
michael@0 563 }
michael@0 564
michael@0 565 STDMETHODIMP
michael@0 566 ia2AccessibleTable::get_rowColumnExtentsAtIndex(long aCellIdx, long* aRowIdx,
michael@0 567 long* aColIdx,
michael@0 568 long* aRowExtents,
michael@0 569 long* aColExtents,
michael@0 570 boolean* aIsSelected)
michael@0 571 {
michael@0 572 A11Y_TRYBLOCK_BEGIN
michael@0 573
michael@0 574 if (!aRowIdx || !aColIdx || !aRowExtents || !aColExtents || !aIsSelected)
michael@0 575 return E_INVALIDARG;
michael@0 576
michael@0 577 *aRowIdx = 0;
michael@0 578 *aColIdx = 0;
michael@0 579 *aRowExtents = 0;
michael@0 580 *aColExtents = 0;
michael@0 581 *aIsSelected = false;
michael@0 582 if (!mTable)
michael@0 583 return CO_E_OBJNOTCONNECTED;
michael@0 584
michael@0 585 if (aCellIdx < 0 ||
michael@0 586 static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
michael@0 587 return E_INVALIDARG;
michael@0 588
michael@0 589 int32_t colIdx = 0, rowIdx = 0;
michael@0 590 mTable->RowAndColIndicesAt(aCellIdx, &rowIdx, &colIdx);
michael@0 591 *aRowIdx = rowIdx;
michael@0 592 *aColIdx = colIdx;
michael@0 593 *aRowExtents = mTable->RowExtentAt(rowIdx, colIdx);
michael@0 594 *aColExtents = mTable->ColExtentAt(rowIdx, colIdx);
michael@0 595 *aIsSelected = mTable->IsCellSelected(rowIdx, colIdx);
michael@0 596
michael@0 597 return S_OK;
michael@0 598
michael@0 599 A11Y_TRYBLOCK_END
michael@0 600 }
michael@0 601
michael@0 602 STDMETHODIMP
michael@0 603 ia2AccessibleTable::get_modelChange(IA2TableModelChange* aModelChange)
michael@0 604 {
michael@0 605 return E_NOTIMPL;
michael@0 606 }
michael@0 607
michael@0 608 ////////////////////////////////////////////////////////////////////////////////
michael@0 609 // IAccessibleTable2
michael@0 610
michael@0 611 STDMETHODIMP
michael@0 612 ia2AccessibleTable::get_cellAt(long aRowIdx, long aColIdx, IUnknown** aCell)
michael@0 613 {
michael@0 614 A11Y_TRYBLOCK_BEGIN
michael@0 615
michael@0 616 if (!aCell)
michael@0 617 return E_INVALIDARG;
michael@0 618
michael@0 619 *aCell = nullptr;
michael@0 620
michael@0 621 if (!mTable)
michael@0 622 return CO_E_OBJNOTCONNECTED;
michael@0 623
michael@0 624 AccessibleWrap* cell =
michael@0 625 static_cast<AccessibleWrap*>(mTable->CellAt(aRowIdx, aColIdx));
michael@0 626 if (!cell)
michael@0 627 return E_INVALIDARG;
michael@0 628
michael@0 629 (*aCell = static_cast<IAccessible*>(cell))->AddRef();
michael@0 630 return S_OK;
michael@0 631
michael@0 632 A11Y_TRYBLOCK_END
michael@0 633 }
michael@0 634
michael@0 635 STDMETHODIMP
michael@0 636 ia2AccessibleTable::get_nSelectedCells(long* aCellCount)
michael@0 637 {
michael@0 638 A11Y_TRYBLOCK_BEGIN
michael@0 639
michael@0 640 if (!aCellCount)
michael@0 641 return E_INVALIDARG;
michael@0 642
michael@0 643 *aCellCount = 0;
michael@0 644 if (!mTable)
michael@0 645 return CO_E_OBJNOTCONNECTED;
michael@0 646
michael@0 647 *aCellCount = mTable->SelectedCellCount();
michael@0 648 return S_OK;
michael@0 649
michael@0 650 A11Y_TRYBLOCK_END
michael@0 651 }
michael@0 652
michael@0 653 STDMETHODIMP
michael@0 654 ia2AccessibleTable::get_selectedCells(IUnknown*** aCells, long* aNSelectedCells)
michael@0 655 {
michael@0 656 A11Y_TRYBLOCK_BEGIN
michael@0 657
michael@0 658 if (!aCells || !aNSelectedCells)
michael@0 659 return E_INVALIDARG;
michael@0 660
michael@0 661 *aCells = nullptr;
michael@0 662 *aNSelectedCells = 0;
michael@0 663 if (!mTable)
michael@0 664 return CO_E_OBJNOTCONNECTED;
michael@0 665
michael@0 666 nsAutoTArray<Accessible*, 30> cells;
michael@0 667 mTable->SelectedCells(&cells);
michael@0 668 if (cells.IsEmpty())
michael@0 669 return S_FALSE;
michael@0 670
michael@0 671 *aCells =
michael@0 672 static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) *
michael@0 673 cells.Length()));
michael@0 674 if (!*aCells)
michael@0 675 return E_OUTOFMEMORY;
michael@0 676
michael@0 677 for (uint32_t i = 0; i < cells.Length(); i++) {
michael@0 678 (*aCells)[i] =
michael@0 679 static_cast<IAccessible*>(static_cast<AccessibleWrap*>(cells[i]));
michael@0 680 ((*aCells)[i])->AddRef();
michael@0 681 }
michael@0 682
michael@0 683 *aNSelectedCells = cells.Length();
michael@0 684 return S_OK;
michael@0 685
michael@0 686 A11Y_TRYBLOCK_END
michael@0 687 }
michael@0 688
michael@0 689 STDMETHODIMP
michael@0 690 ia2AccessibleTable::get_selectedColumns(long** aColumns, long* aNColumns)
michael@0 691 {
michael@0 692 A11Y_TRYBLOCK_BEGIN
michael@0 693
michael@0 694 if (!aColumns || !aNColumns)
michael@0 695 return E_INVALIDARG;
michael@0 696
michael@0 697 *aColumns = nullptr;
michael@0 698 *aNColumns = 0;
michael@0 699 if (!mTable)
michael@0 700 return CO_E_OBJNOTCONNECTED;
michael@0 701
michael@0 702 nsAutoTArray<uint32_t, 30> colIndices;
michael@0 703 mTable->SelectedColIndices(&colIndices);
michael@0 704
michael@0 705 uint32_t maxCols = colIndices.Length();
michael@0 706 if (maxCols == 0)
michael@0 707 return S_FALSE;
michael@0 708
michael@0 709 *aColumns = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxCols));
michael@0 710 *aNColumns = maxCols;
michael@0 711 for (uint32_t i = 0; i < maxCols; i++)
michael@0 712 (*aColumns)[i] = colIndices[i];
michael@0 713
michael@0 714 return S_OK;
michael@0 715
michael@0 716 A11Y_TRYBLOCK_END
michael@0 717 }
michael@0 718
michael@0 719 STDMETHODIMP
michael@0 720 ia2AccessibleTable::get_selectedRows(long** aRows, long* aNRows)
michael@0 721 {
michael@0 722 A11Y_TRYBLOCK_BEGIN
michael@0 723
michael@0 724 if (!aRows || !aNRows)
michael@0 725 return E_INVALIDARG;
michael@0 726
michael@0 727 *aRows = nullptr;
michael@0 728 *aNRows = 0;
michael@0 729 if (!mTable)
michael@0 730 return CO_E_OBJNOTCONNECTED;
michael@0 731
michael@0 732 nsAutoTArray<uint32_t, 30> rowIndices;
michael@0 733 mTable->SelectedRowIndices(&rowIndices);
michael@0 734
michael@0 735 uint32_t maxRows = rowIndices.Length();
michael@0 736 if (maxRows == 0)
michael@0 737 return S_FALSE;
michael@0 738
michael@0 739 *aRows = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxRows));
michael@0 740 *aNRows = maxRows;
michael@0 741 for (uint32_t i = 0; i < maxRows; i++)
michael@0 742 (*aRows)[i] = rowIndices[i];
michael@0 743
michael@0 744 return S_OK;
michael@0 745
michael@0 746 A11Y_TRYBLOCK_END
michael@0 747 }

mercurial