diff --git a/accessible/base/NotificationController.cpp b/accessible/base/NotificationController.cpp index 83d3062ef07e..854b364fb58b 100644 --- a/accessible/base/NotificationController.cpp +++ b/accessible/base/NotificationController.cpp @@ -228,11 +228,12 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime) nsIContent* containerElm = containerNode->IsElement() ? containerNode->AsElement() : nullptr; - nsIFrame::RenderedText text = textFrame->GetRenderedText(); + nsAutoString text; + textFrame->GetRenderedText(&text); // Remove text accessible if rendered text is empty. if (textAcc) { - if (text.mString.IsEmpty()) { + if (text.IsEmpty()) { #ifdef A11Y_LOG if (logging::IsEnabled(logging::eTree | logging::eText)) { logging::MsgBegin("TREE", "text node lost its content"); @@ -255,17 +256,17 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime) logging::MsgEntry("old text '%s'", NS_ConvertUTF16toUTF8(textAcc->AsTextLeaf()->Text()).get()); logging::MsgEntry("new text: '%s'", - NS_ConvertUTF16toUTF8(text.mString).get()); + NS_ConvertUTF16toUTF8(text).get()); logging::MsgEnd(); } #endif - TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text.mString); + TextUpdater::Run(mDocument, textAcc->AsTextLeaf(), text); continue; } // Append an accessible if rendered text is not empty. - if (!text.mString.IsEmpty()) { + if (!text.IsEmpty()) { #ifdef A11Y_LOG if (logging::IsEnabled(logging::eTree | logging::eText)) { logging::MsgBegin("TREE", "text node gains new content"); diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index 95cf3f6fb720..ff822c93172d 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -1091,11 +1091,12 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode, // Create accessible for visible text frames. if (content->IsNodeOfType(nsINode::eTEXT)) { - nsIFrame::RenderedText text = frame->GetRenderedText(); + nsAutoString text; + frame->GetRenderedText(&text, nullptr, nullptr, 0, UINT32_MAX); // Ignore not rendered text nodes and whitespace text nodes between table // cells. - if (text.mString.IsEmpty() || - (aContext->IsTableRow() && nsCoreUtils::IsWhitespaceString(text.mString))) { + if (text.IsEmpty() || + (aContext->IsTableRow() && nsCoreUtils::IsWhitespaceString(text))) { if (aIsSubtreeHidden) *aIsSubtreeHidden = true; @@ -1107,7 +1108,7 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode, return nullptr; document->BindToDocument(newAcc, nullptr); - newAcc->AsTextLeaf()->SetText(text.mString); + newAcc->AsTextLeaf()->SetText(text); return newAcc; } diff --git a/accessible/base/nsTextEquivUtils.cpp b/accessible/base/nsTextEquivUtils.cpp index bb7b3d918de4..d8dcd2ae0727 100644 --- a/accessible/base/nsTextEquivUtils.cpp +++ b/accessible/base/nsTextEquivUtils.cpp @@ -139,8 +139,8 @@ nsTextEquivUtils::AppendTextEquivFromTextContent(nsIContent *aContent, if (aContent->TextLength() > 0) { nsIFrame *frame = aContent->GetPrimaryFrame(); if (frame) { - nsIFrame::RenderedText text = frame->GetRenderedText(); - aString->Append(text.mString); + nsresult rv = frame->GetRenderedText(aString); + NS_ENSURE_SUCCESS(rv, rv); } else { // If aContent is an object that is display: none, we have no a frame. aContent->AppendTextTo(*aString); diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index 6f97835bb9b3..89fc66e63545 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -394,10 +394,10 @@ Accessible::VisibilityState() if (frame->GetType() == nsGkAtoms::textFrame && !(frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) && frame->GetRect().IsEmpty()) { - nsIFrame::RenderedText text = frame->GetRenderedText(); - if (text.mString.IsEmpty()) { + nsAutoString renderedText; + frame->GetRenderedText(&renderedText, nullptr, nullptr, 0, 1); + if (renderedText.IsEmpty()) return states::INVISIBLE; - } } return 0; diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index 2fcce652ce21..38c22afa8e3a 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -1984,9 +1984,17 @@ HyperTextAccessible::ContentToRenderedOffset(nsIFrame* aFrame, int32_t aContentO NS_ASSERTION(aFrame->GetPrevContinuation() == nullptr, "Call on primary frame only"); - nsIFrame::RenderedText text = aFrame->GetRenderedText(aContentOffset, - aContentOffset + 1); - *aRenderedOffset = text.mOffsetWithinNodeRenderedText; + gfxSkipChars skipChars; + gfxSkipCharsIterator iter; + // Only get info up to original offset, we know that will be larger than skipped offset + nsresult rv = aFrame->GetRenderedText(nullptr, &skipChars, &iter, 0, aContentOffset); + NS_ENSURE_SUCCESS(rv, rv); + + uint32_t ourRenderedStart = iter.GetSkippedOffset(); + int32_t ourContentStart = iter.GetOriginalOffset(); + + *aRenderedOffset = iter.ConvertOriginalToSkipped(aContentOffset + ourContentStart) - + ourRenderedStart; return NS_OK; } @@ -2008,9 +2016,16 @@ HyperTextAccessible::RenderedToContentOffset(nsIFrame* aFrame, uint32_t aRendere NS_ASSERTION(aFrame->GetPrevContinuation() == nullptr, "Call on primary frame only"); - nsIFrame::RenderedText text = aFrame->GetRenderedText(aRenderedOffset, - aRenderedOffset + 1, nsIFrame::TextOffsetType::OFFSETS_IN_RENDERED_TEXT); - *aContentOffset = text.mOffsetWithinNodeText; + gfxSkipChars skipChars; + gfxSkipCharsIterator iter; + // We only need info up to skipped offset -- that is what we're converting to original offset + nsresult rv = aFrame->GetRenderedText(nullptr, &skipChars, &iter, 0, aRenderedOffset); + NS_ENSURE_SUCCESS(rv, rv); + + uint32_t ourRenderedStart = iter.GetSkippedOffset(); + int32_t ourContentStart = iter.GetOriginalOffset(); + + *aContentOffset = iter.ConvertSkippedToOriginal(aRenderedOffset + ourRenderedStart) - ourContentStart; return NS_OK; } diff --git a/accessible/tests/mochitest/jsat/test_traversal.html b/accessible/tests/mochitest/jsat/test_traversal.html index 12316034aea6..533e9d89ff90 100644 --- a/accessible/tests/mochitest/jsat/test_traversal.html +++ b/accessible/tests/mochitest/jsat/test_traversal.html @@ -113,7 +113,7 @@ 'A esoteric weapon wielded by only the most ' + 'formidable warriors, for its unrelenting strict' + ' power is unfathomable.', - '• Lists of Programming Languages', 'Lisp', + '• Lists of Programming Languages', 'Lisp ', '1. Scheme', '2. Racket', '3. Clojure', '4. Standard Lisp', 'link-0', ' Lisp', 'checkbox-1-5', ' LeLisp', '• JavaScript', @@ -124,7 +124,7 @@ '5 8', 'gridcell4', 'Just an innocuous separator', 'Dirty Words', 'Meaning', 'Mud', 'Wet Dirt', 'Dirt', 'Messy Stuff', 'statusbar-1', 'statusbar-2', - 'switch-1', 'This is a MathML formula', 'math-1', + 'switch-1', 'This is a MathML formula ', 'math-1', 'with some text after.']); queueTraversalSequence(gQueue, docAcc, TraversalRules.Landmark, null, diff --git a/accessible/tests/mochitest/pivot/test_virtualcursor.html b/accessible/tests/mochitest/pivot/test_virtualcursor.html index 9bb17348434c..2fb339964afb 100644 --- a/accessible/tests/mochitest/pivot/test_virtualcursor.html +++ b/accessible/tests/mochitest/pivot/test_virtualcursor.html @@ -52,7 +52,7 @@ gQueue, docAcc, ObjectTraversalRule, null, ['Main Title', 'Lorem ipsum ', 'dolor', ' sit amet. Integer vitae urna leo, id ', - 'semper', ' nulla.', 'Second Section Title', + 'semper', ' nulla. ', 'Second Section Title', 'Sed accumsan luctus lacus, vitae mollis arcu tristique vulputate.', 'An ', 'embedded', ' document.', 'Hide me', 'Link 1', 'Link 2', 'Link 3', 'Hello', 'World']); @@ -90,7 +90,7 @@ gQueue, docAcc, ObjectTraversalRule, getAccessible(doc.getElementById('paragraph-1')), ['Lorem ipsum ', 'dolor', ' sit amet. Integer vitae urna leo, id ', - 'semper', ' nulla.']); + 'semper', ' nulla. ']); gQueue.push(new setModalRootInvoker(docAcc, docAcc.parent, NS_ERROR_INVALID_ARG)); diff --git a/accessible/tests/mochitest/text/test_doc.html b/accessible/tests/mochitest/text/test_doc.html index 76b801c277f0..9c6788275a0d 100644 --- a/accessible/tests/mochitest/text/test_doc.html +++ b/accessible/tests/mochitest/text/test_doc.html @@ -16,8 +16,8 @@ function doTest() { var iframeDoc = [ getNode("iframe").contentDocument ]; - testCharacterCount(iframeDoc, 13); - testText(iframeDoc, 0, 13, "outbodyinbody"); + testCharacterCount(iframeDoc, 15); + testText(iframeDoc, 0, 15, "outbody inbody "); SimpleTest.finish(); } diff --git a/accessible/tests/mochitest/text/test_hypertext.html b/accessible/tests/mochitest/text/test_hypertext.html index 6df2419aa6fc..5640dc186509 100644 --- a/accessible/tests/mochitest/text/test_hypertext.html +++ b/accessible/tests/mochitest/text/test_hypertext.html @@ -58,7 +58,7 @@ //////////////////////////////////////////////////////////////////////// // getTextAtOffset line boundary - testTextAtOffset(0, BOUNDARY_LINE_START, "line", 0, 4, + testTextAtOffset(0, BOUNDARY_LINE_START, "line ", 0, 5, "hypertext3", kOk, kOk, kOk); // XXX: see bug 634202. @@ -122,7 +122,7 @@
--hello
****/ - -testText("abc", " abc", "Leading whitespace preserved"); -testText("abc ", "abc ", "Trailing whitespace preserved"); -testText("abc def", "abc def", "Internal whitespace preserved"); -testText("abc\ndef", "abc\ndef", "\\n preserved"); -testText("abc\rdef", "abc\ndef", "\\r converted to newline"); -testText("abc\tdef", "abc\tdef", "\\t preserved"); - -/********/ - -testText("abc", " abc", "Leading whitespace preserved"); -testText("abc ", "abc ", "Trailing whitespace preserved"); -testText("abc def", "abc def", "Internal whitespace preserved"); -testText("abc\ndef", "abc\ndef", "\\n preserved"); -testText("abc\rdef", "abc\ndef", "\\r converted to newline"); -testText("abc\tdef", "abc\tdef", "\\t preserved"); - -/**** ****/ - -testText(" abc", " abc", "Leading whitespace preserved"); -testText("abc ", "abc ", "Trailing whitespace preserved"); -testText("abc def", "abc def", "Internal whitespace preserved"); -testText("abc\ndef", "abc\ndef", "\\n preserved"); -testText("abc\rdef", "abc\ndef", "\\r converted to newline"); -testText("abc\tdef", "abc\tdef", "\\t preserved"); - -/********/ - -testText("abc", "abc", "Leading whitespace removed"); -testText("abc ", "abc", "Trailing whitespace removed"); -testText("abc def", "abc def", "Internal whitespace collapsed"); -testText("abc\ndef", "abc\ndef", "\\n preserved"); -testText("abc\rdef", "abc\ndef", "\\r converted to newline"); -testText("abc\tdef", "abc def", "\\t converted to space"); - -/**** Collapsing whitespace across element boundaries ****/ - -testText("abc def", "abc def", "Whitespace collapses across element boundaries"); -testText("abc def", "abc def", "Whitespace collapses across element boundaries"); -testText("abc def", "abc def", "Whitespace collapses across element boundaries"); - -/**** Soft line breaks ****/ - -testText("abc def", "abc def", "Soft line breaks ignored"); - -/**** first-line/first-letter ****/ - -testText("abc def", "ABC def", "::first-line styles applied"); -testText("abc def", "Abc def", "::first-letter styles applied"); -testText("abc def", "abc def", "::first-letter float ignored"); - -/**** ****/ - -testText("", "\xA0", " preserved"); - -/**** display:none ****/ - -testText("