mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Bug 1343695 Part 1: Retrieve text content with GetRenderedText. r=mats
MozReview-Commit-ID: 4VLoaTlDELG --HG-- extra : rebase_source : 4cc21c8d0de752ef927982e9d451bf46d3ca9877
This commit is contained in:
parent
c6017076fc
commit
1a39a40cd5
@ -2906,13 +2906,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();
|
||||
@ -2943,11 +2936,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();
|
||||
|
Loading…
Reference in New Issue
Block a user