accessible/src/windows/ia2/ia2AccessibleText.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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 "ia2AccessibleText.h"
michael@0 9
michael@0 10 #include "Accessible2.h"
michael@0 11 #include "AccessibleText_i.c"
michael@0 12
michael@0 13 #include "HyperTextAccessibleWrap.h"
michael@0 14 #include "HyperTextAccessible-inl.h"
michael@0 15
michael@0 16 using namespace mozilla::a11y;
michael@0 17
michael@0 18 // IAccessibleText
michael@0 19
michael@0 20 STDMETHODIMP
michael@0 21 ia2AccessibleText::addSelection(long aStartOffset, long aEndOffset)
michael@0 22 {
michael@0 23 A11Y_TRYBLOCK_BEGIN
michael@0 24
michael@0 25 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 26 if (textAcc->IsDefunct())
michael@0 27 return CO_E_OBJNOTCONNECTED;
michael@0 28
michael@0 29 return textAcc->AddToSelection(aStartOffset, aEndOffset) ?
michael@0 30 S_OK : E_INVALIDARG;
michael@0 31
michael@0 32 A11Y_TRYBLOCK_END
michael@0 33 }
michael@0 34
michael@0 35 STDMETHODIMP
michael@0 36 ia2AccessibleText::get_attributes(long aOffset, long *aStartOffset,
michael@0 37 long *aEndOffset, BSTR *aTextAttributes)
michael@0 38 {
michael@0 39 A11Y_TRYBLOCK_BEGIN
michael@0 40
michael@0 41 if (!aStartOffset || !aEndOffset || !aTextAttributes)
michael@0 42 return E_INVALIDARG;
michael@0 43
michael@0 44 *aStartOffset = 0;
michael@0 45 *aEndOffset = 0;
michael@0 46 *aTextAttributes = nullptr;
michael@0 47
michael@0 48 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 49 if (textAcc->IsDefunct())
michael@0 50 return CO_E_OBJNOTCONNECTED;
michael@0 51
michael@0 52 int32_t startOffset = 0, endOffset = 0;
michael@0 53 nsCOMPtr<nsIPersistentProperties> attributes =
michael@0 54 textAcc->TextAttributes(true, aOffset, &startOffset, &endOffset);
michael@0 55
michael@0 56 HRESULT hr = AccessibleWrap::ConvertToIA2Attributes(attributes,
michael@0 57 aTextAttributes);
michael@0 58 if (FAILED(hr))
michael@0 59 return hr;
michael@0 60
michael@0 61 *aStartOffset = startOffset;
michael@0 62 *aEndOffset = endOffset;
michael@0 63
michael@0 64 return S_OK;
michael@0 65
michael@0 66 A11Y_TRYBLOCK_END
michael@0 67 }
michael@0 68
michael@0 69 STDMETHODIMP
michael@0 70 ia2AccessibleText::get_caretOffset(long *aOffset)
michael@0 71 {
michael@0 72 A11Y_TRYBLOCK_BEGIN
michael@0 73
michael@0 74 if (!aOffset)
michael@0 75 return E_INVALIDARG;
michael@0 76
michael@0 77 *aOffset = -1;
michael@0 78
michael@0 79 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 80 if (textAcc->IsDefunct())
michael@0 81 return CO_E_OBJNOTCONNECTED;
michael@0 82
michael@0 83 *aOffset = textAcc->CaretOffset();
michael@0 84 return *aOffset != -1 ? S_OK : S_FALSE;
michael@0 85
michael@0 86 A11Y_TRYBLOCK_END
michael@0 87 }
michael@0 88
michael@0 89 STDMETHODIMP
michael@0 90 ia2AccessibleText::get_characterExtents(long aOffset,
michael@0 91 enum IA2CoordinateType aCoordType,
michael@0 92 long* aX, long* aY,
michael@0 93 long* aWidth, long* aHeight)
michael@0 94 {
michael@0 95 A11Y_TRYBLOCK_BEGIN
michael@0 96
michael@0 97 if (!aX || !aY || !aWidth || !aHeight)
michael@0 98 return E_INVALIDARG;
michael@0 99 *aX = *aY = *aWidth = *aHeight = 0;
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 uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
michael@0 106 nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
michael@0 107 nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
michael@0 108
michael@0 109 nsIntRect rect = textAcc->CharBounds(aOffset, geckoCoordType);
michael@0 110
michael@0 111 *aX = rect.x;
michael@0 112 *aY = rect.y;
michael@0 113 *aWidth = rect.width;
michael@0 114 *aHeight = rect.height;
michael@0 115 return S_OK;
michael@0 116
michael@0 117 A11Y_TRYBLOCK_END
michael@0 118 }
michael@0 119
michael@0 120 STDMETHODIMP
michael@0 121 ia2AccessibleText::get_nSelections(long* aNSelections)
michael@0 122 {
michael@0 123 A11Y_TRYBLOCK_BEGIN
michael@0 124
michael@0 125 if (!aNSelections)
michael@0 126 return E_INVALIDARG;
michael@0 127 *aNSelections = 0;
michael@0 128
michael@0 129 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 130 if (textAcc->IsDefunct())
michael@0 131 return CO_E_OBJNOTCONNECTED;
michael@0 132
michael@0 133 *aNSelections = textAcc->SelectionCount();
michael@0 134 return S_OK;
michael@0 135
michael@0 136 A11Y_TRYBLOCK_END
michael@0 137 }
michael@0 138
michael@0 139 STDMETHODIMP
michael@0 140 ia2AccessibleText::get_offsetAtPoint(long aX, long aY,
michael@0 141 enum IA2CoordinateType aCoordType,
michael@0 142 long* aOffset)
michael@0 143 {
michael@0 144 A11Y_TRYBLOCK_BEGIN
michael@0 145
michael@0 146 if (!aOffset)
michael@0 147 return E_INVALIDARG;
michael@0 148 *aOffset = 0;
michael@0 149
michael@0 150 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 151 if (textAcc->IsDefunct())
michael@0 152 return CO_E_OBJNOTCONNECTED;
michael@0 153
michael@0 154 uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
michael@0 155 nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
michael@0 156 nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
michael@0 157
michael@0 158 *aOffset = textAcc->OffsetAtPoint(aX, aY, geckoCoordType);
michael@0 159 return *aOffset == -1 ? S_FALSE : S_OK;
michael@0 160
michael@0 161 A11Y_TRYBLOCK_END
michael@0 162 }
michael@0 163
michael@0 164 STDMETHODIMP
michael@0 165 ia2AccessibleText::get_selection(long aSelectionIndex, long* aStartOffset,
michael@0 166 long* aEndOffset)
michael@0 167 {
michael@0 168 A11Y_TRYBLOCK_BEGIN
michael@0 169
michael@0 170 if (!aStartOffset || !aEndOffset)
michael@0 171 return E_INVALIDARG;
michael@0 172 *aStartOffset = *aEndOffset = 0;
michael@0 173
michael@0 174 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 175 if (textAcc->IsDefunct())
michael@0 176 return CO_E_OBJNOTCONNECTED;
michael@0 177
michael@0 178 int32_t startOffset = 0, endOffset = 0;
michael@0 179 if (!textAcc->SelectionBoundsAt(aSelectionIndex, &startOffset, &endOffset))
michael@0 180 return E_INVALIDARG;
michael@0 181
michael@0 182 *aStartOffset = startOffset;
michael@0 183 *aEndOffset = endOffset;
michael@0 184 return S_OK;
michael@0 185
michael@0 186 A11Y_TRYBLOCK_END
michael@0 187 }
michael@0 188
michael@0 189 STDMETHODIMP
michael@0 190 ia2AccessibleText::get_text(long aStartOffset, long aEndOffset, BSTR* aText)
michael@0 191 {
michael@0 192 A11Y_TRYBLOCK_BEGIN
michael@0 193
michael@0 194 if (!aText)
michael@0 195 return E_INVALIDARG;
michael@0 196
michael@0 197 *aText = nullptr;
michael@0 198
michael@0 199 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 200 if (textAcc->IsDefunct())
michael@0 201 return CO_E_OBJNOTCONNECTED;
michael@0 202
michael@0 203 if (!textAcc->IsValidRange(aStartOffset, aEndOffset))
michael@0 204 return E_INVALIDARG;
michael@0 205
michael@0 206 nsAutoString text;
michael@0 207 textAcc->TextSubstring(aStartOffset, aEndOffset, text);
michael@0 208 if (text.IsEmpty())
michael@0 209 return S_FALSE;
michael@0 210
michael@0 211 *aText = ::SysAllocStringLen(text.get(), text.Length());
michael@0 212 return *aText ? S_OK : E_OUTOFMEMORY;
michael@0 213
michael@0 214 A11Y_TRYBLOCK_END
michael@0 215 }
michael@0 216
michael@0 217 STDMETHODIMP
michael@0 218 ia2AccessibleText::get_textBeforeOffset(long aOffset,
michael@0 219 enum IA2TextBoundaryType aBoundaryType,
michael@0 220 long* aStartOffset, long* aEndOffset,
michael@0 221 BSTR* aText)
michael@0 222 {
michael@0 223 A11Y_TRYBLOCK_BEGIN
michael@0 224
michael@0 225 if (!aStartOffset || !aEndOffset || !aText)
michael@0 226 return E_INVALIDARG;
michael@0 227
michael@0 228 *aStartOffset = *aEndOffset = 0;
michael@0 229 *aText = nullptr;
michael@0 230
michael@0 231 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 232 if (textAcc->IsDefunct())
michael@0 233 return CO_E_OBJNOTCONNECTED;
michael@0 234
michael@0 235 if (!textAcc->IsValidOffset(aOffset))
michael@0 236 return E_INVALIDARG;
michael@0 237
michael@0 238 nsAutoString text;
michael@0 239 int32_t startOffset = 0, endOffset = 0;
michael@0 240
michael@0 241 if (aBoundaryType == IA2_TEXT_BOUNDARY_ALL) {
michael@0 242 startOffset = 0;
michael@0 243 endOffset = textAcc->CharacterCount();
michael@0 244 textAcc->TextSubstring(startOffset, endOffset, text);
michael@0 245 } else {
michael@0 246 AccessibleTextBoundary boundaryType = GetGeckoTextBoundary(aBoundaryType);
michael@0 247 if (boundaryType == -1)
michael@0 248 return S_FALSE;
michael@0 249
michael@0 250 textAcc->TextBeforeOffset(aOffset, boundaryType, &startOffset, &endOffset, text);
michael@0 251 }
michael@0 252
michael@0 253 *aStartOffset = startOffset;
michael@0 254 *aEndOffset = endOffset;
michael@0 255
michael@0 256 if (text.IsEmpty())
michael@0 257 return S_FALSE;
michael@0 258
michael@0 259 *aText = ::SysAllocStringLen(text.get(), text.Length());
michael@0 260 return *aText ? S_OK : E_OUTOFMEMORY;
michael@0 261
michael@0 262 A11Y_TRYBLOCK_END
michael@0 263 }
michael@0 264
michael@0 265 STDMETHODIMP
michael@0 266 ia2AccessibleText::get_textAfterOffset(long aOffset,
michael@0 267 enum IA2TextBoundaryType aBoundaryType,
michael@0 268 long* aStartOffset, long* aEndOffset,
michael@0 269 BSTR* aText)
michael@0 270 {
michael@0 271 A11Y_TRYBLOCK_BEGIN
michael@0 272
michael@0 273 if (!aStartOffset || !aEndOffset || !aText)
michael@0 274 return E_INVALIDARG;
michael@0 275
michael@0 276 *aStartOffset = 0;
michael@0 277 *aEndOffset = 0;
michael@0 278 *aText = nullptr;
michael@0 279
michael@0 280 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 281 if (textAcc->IsDefunct())
michael@0 282 return CO_E_OBJNOTCONNECTED;
michael@0 283
michael@0 284 if (!textAcc->IsValidOffset(aOffset))
michael@0 285 return E_INVALIDARG;
michael@0 286
michael@0 287 nsAutoString text;
michael@0 288 int32_t startOffset = 0, endOffset = 0;
michael@0 289
michael@0 290 if (aBoundaryType == IA2_TEXT_BOUNDARY_ALL) {
michael@0 291 startOffset = 0;
michael@0 292 endOffset = textAcc->CharacterCount();
michael@0 293 textAcc->TextSubstring(startOffset, endOffset, text);
michael@0 294 } else {
michael@0 295 AccessibleTextBoundary boundaryType = GetGeckoTextBoundary(aBoundaryType);
michael@0 296 if (boundaryType == -1)
michael@0 297 return S_FALSE;
michael@0 298 textAcc->TextAfterOffset(aOffset, boundaryType, &startOffset, &endOffset, text);
michael@0 299 }
michael@0 300
michael@0 301 *aStartOffset = startOffset;
michael@0 302 *aEndOffset = endOffset;
michael@0 303
michael@0 304 if (text.IsEmpty())
michael@0 305 return S_FALSE;
michael@0 306
michael@0 307 *aText = ::SysAllocStringLen(text.get(), text.Length());
michael@0 308 return *aText ? S_OK : E_OUTOFMEMORY;
michael@0 309
michael@0 310 A11Y_TRYBLOCK_END
michael@0 311 }
michael@0 312
michael@0 313 STDMETHODIMP
michael@0 314 ia2AccessibleText::get_textAtOffset(long aOffset,
michael@0 315 enum IA2TextBoundaryType aBoundaryType,
michael@0 316 long* aStartOffset, long* aEndOffset,
michael@0 317 BSTR* aText)
michael@0 318 {
michael@0 319 A11Y_TRYBLOCK_BEGIN
michael@0 320
michael@0 321 if (!aStartOffset || !aEndOffset || !aText)
michael@0 322 return E_INVALIDARG;
michael@0 323
michael@0 324 *aStartOffset = *aEndOffset = 0;
michael@0 325 *aText = nullptr;
michael@0 326
michael@0 327 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 328 if (textAcc->IsDefunct())
michael@0 329 return CO_E_OBJNOTCONNECTED;
michael@0 330
michael@0 331 if (!textAcc->IsValidOffset(aOffset))
michael@0 332 return E_INVALIDARG;
michael@0 333
michael@0 334 nsAutoString text;
michael@0 335 int32_t startOffset = 0, endOffset = 0;
michael@0 336 if (aBoundaryType == IA2_TEXT_BOUNDARY_ALL) {
michael@0 337 startOffset = 0;
michael@0 338 endOffset = textAcc->CharacterCount();
michael@0 339 textAcc->TextSubstring(startOffset, endOffset, text);
michael@0 340 } else {
michael@0 341 AccessibleTextBoundary boundaryType = GetGeckoTextBoundary(aBoundaryType);
michael@0 342 if (boundaryType == -1)
michael@0 343 return S_FALSE;
michael@0 344 textAcc->TextAtOffset(aOffset, boundaryType, &startOffset, &endOffset, text);
michael@0 345 }
michael@0 346
michael@0 347 *aStartOffset = startOffset;
michael@0 348 *aEndOffset = endOffset;
michael@0 349
michael@0 350 if (text.IsEmpty())
michael@0 351 return S_FALSE;
michael@0 352
michael@0 353 *aText = ::SysAllocStringLen(text.get(), text.Length());
michael@0 354 return *aText ? S_OK : E_OUTOFMEMORY;
michael@0 355
michael@0 356 A11Y_TRYBLOCK_END
michael@0 357 }
michael@0 358
michael@0 359 STDMETHODIMP
michael@0 360 ia2AccessibleText::removeSelection(long aSelectionIndex)
michael@0 361 {
michael@0 362 A11Y_TRYBLOCK_BEGIN
michael@0 363
michael@0 364 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 365 if (textAcc->IsDefunct())
michael@0 366 return CO_E_OBJNOTCONNECTED;
michael@0 367
michael@0 368 return textAcc->RemoveFromSelection(aSelectionIndex) ?
michael@0 369 S_OK : E_INVALIDARG;
michael@0 370
michael@0 371 A11Y_TRYBLOCK_END
michael@0 372 }
michael@0 373
michael@0 374 STDMETHODIMP
michael@0 375 ia2AccessibleText::setCaretOffset(long aOffset)
michael@0 376 {
michael@0 377 A11Y_TRYBLOCK_BEGIN
michael@0 378
michael@0 379 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 380 if (textAcc->IsDefunct())
michael@0 381 return CO_E_OBJNOTCONNECTED;
michael@0 382
michael@0 383 if (!textAcc->IsValidOffset(aOffset))
michael@0 384 return E_INVALIDARG;
michael@0 385
michael@0 386 textAcc->SetCaretOffset(aOffset);
michael@0 387 return S_OK;
michael@0 388
michael@0 389 A11Y_TRYBLOCK_END
michael@0 390 }
michael@0 391
michael@0 392 STDMETHODIMP
michael@0 393 ia2AccessibleText::setSelection(long aSelectionIndex, long aStartOffset,
michael@0 394 long aEndOffset)
michael@0 395 {
michael@0 396 A11Y_TRYBLOCK_BEGIN
michael@0 397
michael@0 398 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 399 if (textAcc->IsDefunct())
michael@0 400 return CO_E_OBJNOTCONNECTED;
michael@0 401
michael@0 402 return textAcc->SetSelectionBoundsAt(aSelectionIndex, aStartOffset, aEndOffset) ?
michael@0 403 S_OK : E_INVALIDARG;
michael@0 404
michael@0 405 A11Y_TRYBLOCK_END
michael@0 406 }
michael@0 407
michael@0 408 STDMETHODIMP
michael@0 409 ia2AccessibleText::get_nCharacters(long* aNCharacters)
michael@0 410 {
michael@0 411 A11Y_TRYBLOCK_BEGIN
michael@0 412
michael@0 413 if (!aNCharacters)
michael@0 414 return E_INVALIDARG;
michael@0 415 *aNCharacters = 0;
michael@0 416
michael@0 417 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 418 if (textAcc->IsDefunct())
michael@0 419 return CO_E_OBJNOTCONNECTED;
michael@0 420
michael@0 421 *aNCharacters = textAcc->CharacterCount();
michael@0 422 return S_OK;
michael@0 423
michael@0 424 A11Y_TRYBLOCK_END
michael@0 425 }
michael@0 426
michael@0 427 STDMETHODIMP
michael@0 428 ia2AccessibleText::scrollSubstringTo(long aStartIndex, long aEndIndex,
michael@0 429 enum IA2ScrollType aScrollType)
michael@0 430 {
michael@0 431 A11Y_TRYBLOCK_BEGIN
michael@0 432
michael@0 433 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 434 if (textAcc->IsDefunct())
michael@0 435 return CO_E_OBJNOTCONNECTED;
michael@0 436
michael@0 437 if (!textAcc->IsValidRange(aStartIndex, aEndIndex))
michael@0 438 return E_INVALIDARG;
michael@0 439
michael@0 440 textAcc->ScrollSubstringTo(aStartIndex, aEndIndex, aScrollType);
michael@0 441 return S_OK;
michael@0 442
michael@0 443 A11Y_TRYBLOCK_END
michael@0 444 }
michael@0 445
michael@0 446 STDMETHODIMP
michael@0 447 ia2AccessibleText::scrollSubstringToPoint(long aStartIndex, long aEndIndex,
michael@0 448 enum IA2CoordinateType aCoordType,
michael@0 449 long aX, long aY)
michael@0 450 {
michael@0 451 A11Y_TRYBLOCK_BEGIN
michael@0 452
michael@0 453 HyperTextAccessible* textAcc = static_cast<HyperTextAccessibleWrap*>(this);
michael@0 454 if (textAcc->IsDefunct())
michael@0 455 return CO_E_OBJNOTCONNECTED;
michael@0 456
michael@0 457 if (!textAcc->IsValidRange(aStartIndex, aEndIndex))
michael@0 458 return E_INVALIDARG;
michael@0 459
michael@0 460 uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
michael@0 461 nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
michael@0 462 nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
michael@0 463
michael@0 464 textAcc->ScrollSubstringToPoint(aStartIndex, aEndIndex,
michael@0 465 geckoCoordType, aX, aY);
michael@0 466 return S_OK;
michael@0 467
michael@0 468 A11Y_TRYBLOCK_END
michael@0 469 }
michael@0 470
michael@0 471 STDMETHODIMP
michael@0 472 ia2AccessibleText::get_newText(IA2TextSegment *aNewText)
michael@0 473 {
michael@0 474 A11Y_TRYBLOCK_BEGIN
michael@0 475
michael@0 476 return GetModifiedText(true, aNewText);
michael@0 477
michael@0 478 A11Y_TRYBLOCK_END
michael@0 479 }
michael@0 480
michael@0 481 STDMETHODIMP
michael@0 482 ia2AccessibleText::get_oldText(IA2TextSegment *aOldText)
michael@0 483 {
michael@0 484 A11Y_TRYBLOCK_BEGIN
michael@0 485
michael@0 486 return GetModifiedText(false, aOldText);
michael@0 487
michael@0 488 A11Y_TRYBLOCK_END
michael@0 489 }
michael@0 490
michael@0 491 // ia2AccessibleText
michael@0 492
michael@0 493 HRESULT
michael@0 494 ia2AccessibleText::GetModifiedText(bool aGetInsertedText,
michael@0 495 IA2TextSegment *aText)
michael@0 496 {
michael@0 497 if (!aText)
michael@0 498 return E_INVALIDARG;
michael@0 499
michael@0 500 uint32_t startOffset = 0, endOffset = 0;
michael@0 501 nsAutoString text;
michael@0 502
michael@0 503 nsresult rv = GetModifiedText(aGetInsertedText, text,
michael@0 504 &startOffset, &endOffset);
michael@0 505 if (NS_FAILED(rv))
michael@0 506 return GetHRESULT(rv);
michael@0 507
michael@0 508 aText->start = startOffset;
michael@0 509 aText->end = endOffset;
michael@0 510
michael@0 511 if (text.IsEmpty())
michael@0 512 return S_FALSE;
michael@0 513
michael@0 514 aText->text = ::SysAllocStringLen(text.get(), text.Length());
michael@0 515 return aText->text ? S_OK : E_OUTOFMEMORY;
michael@0 516 }
michael@0 517
michael@0 518 AccessibleTextBoundary
michael@0 519 ia2AccessibleText::GetGeckoTextBoundary(enum IA2TextBoundaryType aBoundaryType)
michael@0 520 {
michael@0 521 switch (aBoundaryType) {
michael@0 522 case IA2_TEXT_BOUNDARY_CHAR:
michael@0 523 return nsIAccessibleText::BOUNDARY_CHAR;
michael@0 524 case IA2_TEXT_BOUNDARY_WORD:
michael@0 525 return nsIAccessibleText::BOUNDARY_WORD_START;
michael@0 526 case IA2_TEXT_BOUNDARY_LINE:
michael@0 527 return nsIAccessibleText::BOUNDARY_LINE_START;
michael@0 528 //case IA2_TEXT_BOUNDARY_SENTENCE:
michael@0 529 //case IA2_TEXT_BOUNDARY_PARAGRAPH:
michael@0 530 // XXX: not implemented
michael@0 531 default:
michael@0 532 return -1;
michael@0 533 }
michael@0 534 }
michael@0 535

mercurial