From 33cca3c72a5cb9603bb20f2a774af19296e38e2d Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Mon, 13 Mar 2017 16:44:23 -0700 Subject: [PATCH] Backed out 2 changesets (bug 1343695) for osx chrome mochitest assertions a=backout Backed out changeset e5db40a036fe (bug 1343695) Backed out changeset 687ffd715113 (bug 1343695) MozReview-Commit-ID: 2CN1gipg3ia --- dom/base/nsRange.cpp | 19 ++++++++++++------- .../test_range_getClientRectsAndTexts.html | 17 +---------------- layout/base/nsLayoutUtils.cpp | 15 +++++++++------ 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index 17ad9e78a423..1635ce49e88e 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -2906,6 +2906,13 @@ static nsresult GetPartialTextRect(nsLayoutUtils::RectCallback* aCallback, { nsTextFrame* textFrame = GetTextFrameForContent(aContent, aFlushLayout); if (textFrame) { + // If we'll need it later, collect the full content text now. + nsAutoString textContent; + if (aTextList) { + mozilla::ErrorResult err; // ignored + aContent->GetTextContent(textContent, err); + } + nsIFrame* relativeTo = nsLayoutUtils::GetContainingBlockForClientRect(textFrame); for (nsTextFrame* f = textFrame; f; f = static_cast(f->GetNextContinuation())) { int32_t fstart = f->GetContentOffset(), fend = f->GetContentEnd(); @@ -2936,13 +2943,11 @@ static nsresult GetPartialTextRect(nsLayoutUtils::RectCallback* aCallback, // Finally capture the text, if requested. if (aTextList) { - nsIFrame::RenderedText renderedText = f->GetRenderedText( - textContentStart, - textContentEnd, - nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT, - nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE); - - aTextList->AppendElement(renderedText.mString, fallible); + const nsAString& textSubstring = + Substring(textContent, + textContentStart, + (textContentEnd - textContentStart)); + aTextList->AppendElement(textSubstring, fallible); } } } diff --git a/dom/base/test/chrome/test_range_getClientRectsAndTexts.html b/dom/base/test/chrome/test_range_getClientRectsAndTexts.html index 8539c3355a65..5d8dc5a6e52d 100644 --- a/dom/base/test/chrome/test_range_getClientRectsAndTexts.html +++ b/dom/base/test/chrome/test_range_getClientRectsAndTexts.html @@ -15,17 +15,11 @@ function runTests() let attempts = [ {startNode: "one", start:0, endNode:"one", end:0, textList:[], message:"Empty rect"}, {startNode: "one", start:2, endNode:"one", end:6, textList:["l on"], message:"Single line"}, - {startNode: "implicit", start:6, endNode:"implicit", end:12, textList:["it bre"], message:"Implicit break"}, + {startNode: "implicit", start:6, endNode:"implicit", end:12, textList:["it\nbre"], message:"Implicit break"}, {startNode: "two.a", start:1, endNode:"two.b", end:2, textList:["wo", "", "li"], message:"Two lines"}, {startNode: "embed.a", start:7, endNode:"embed.b", end:2, textList:["th ", "simple nested", " ", "te"], message:"Simple nested"}, {startNode: "deep.a", start:2, endNode:"deep.b", end:2, textList:["ne with ", "complex, more deeply nested", " ", "te"], message:"Complex nested"}, {startNode: "image.a", start:7, endNode:"image.b", end:2, textList:["th inline ", "", " ", "im"], message:"Inline image"}, - {startNode: "hyphen1", start:0, endNode:"hyphen1", end:3, textList:["a\u00AD", "b"], message:"Shy hyphen (active)"}, - {startNode: "hyphen2", start:0, endNode:"hyphen2", end:3, textList:["c\u00ADd"], message:"Shy hyphen (inactive)"}, - {startNode: "hyphen2", start:0, endNode:"hyphen2", end:2, textList:["c\u00AD"], message:"Shy hyphen (inactive, trailing)"}, - {startNode: "hyphen2", start:1, endNode:"hyphen2", end:3, textList:["\u00ADd"], message:"Shy hyphen (inactive, leading)"}, - {startNode: "uc", start:0, endNode:"uc", end:2, textList:["EF"], message:"UC transform"}, - {startNode: "pre", start:0, endNode:"pre", end:3, textList:["g\n", "h"], message:"pre with break"}, ]; for (let attempt of attempts) { @@ -62,14 +56,5 @@ break in one line
Line with inline image
-
a­b
- -
c­d
- -
ef
- -
g
-h
- \ No newline at end of file diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index e4dcc4669bcd..2c8f4349d74c 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4018,13 +4018,16 @@ struct MOZ_RAII BoxToRectAndText : public BoxToRect { if (aFrame->GetType() == nsGkAtoms::textFrame) { nsTextFrame* textFrame = static_cast(aFrame); - nsIFrame::RenderedText renderedText = textFrame->GetRenderedText( - textFrame->GetContentOffset(), - textFrame->GetContentOffset() + textFrame->GetContentLength(), - nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT, - nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE); + nsIContent* content = textFrame->GetContent(); + nsAutoString textContent; + mozilla::ErrorResult err; // ignored + content->GetTextContent(textContent, err); - aResult.Append(renderedText.mString); + const nsAString& textSubstring = + Substring(textContent, + textFrame->GetContentOffset(), + textFrame->GetContentLength()); + aResult.Append(textSubstring); } for (nsIFrame* child = aFrame->PrincipalChildList().FirstChild();