Bug 1343695 Part 1: Retrieve text content with GetRenderedText. r=mats

MozReview-Commit-ID: 4VLoaTlDELG

--HG--
extra : rebase_source : d48bc3f175cc88d76087e4371e2b9efead517613
This commit is contained in:
Brad Werth 2017-03-01 16:15:22 -08:00
Родитель 8f1654d5da
Коммит d2ed12d9e6
2 изменённых файлов: 13 добавлений и 21 удалений

Просмотреть файл

@ -2973,13 +2973,6 @@ 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<nsTextFrame*>(f->GetNextContinuation())) {
int32_t fstart = f->GetContentOffset(), fend = f->GetContentEnd();
@ -3010,11 +3003,13 @@ static nsresult GetPartialTextRect(nsLayoutUtils::RectCallback* aCallback,
// Finally capture the text, if requested.
if (aTextList) {
const nsAString& textSubstring =
Substring(textContent,
textContentStart,
(textContentEnd - textContentStart));
aTextList->AppendElement(textSubstring, fallible);
nsIFrame::RenderedText renderedText = f->GetRenderedText(
textContentStart,
textContentEnd,
nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE);
aTextList->AppendElement(renderedText.mString, fallible);
}
}
}

Просмотреть файл

@ -4018,16 +4018,13 @@ struct MOZ_RAII BoxToRectAndText : public BoxToRect {
if (aFrame->GetType() == nsGkAtoms::textFrame) {
nsTextFrame* textFrame = static_cast<nsTextFrame*>(aFrame);
nsIContent* content = textFrame->GetContent();
nsAutoString textContent;
mozilla::ErrorResult err; // ignored
content->GetTextContent(textContent, err);
nsIFrame::RenderedText renderedText = textFrame->GetRenderedText(
textFrame->GetContentOffset(),
textFrame->GetContentOffset() + textFrame->GetContentLength(),
nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE);
const nsAString& textSubstring =
Substring(textContent,
textFrame->GetContentOffset(),
textFrame->GetContentLength());
aResult.Append(textSubstring);
aResult.Append(renderedText.mString);
}
for (nsIFrame* child = aFrame->PrincipalChildList().FirstChild();