Bug 1343695 Part 2: Narrow an overly restrictive assert in GetRenderedText. draft
authorBrad Werth <bwerth@mozilla.com>
Tue, 14 Mar 2017 14:27:30 -0700
changeset 498502 8871b8a6c46eb8af87e3f5cd5cb43b23991baf24
parent 498501 6f57521c9a2f11b9ee6cd7af723b53096f044dfa
child 498503 39f6e3cec76d9603029ef7eca53e84853be0b125
push id49216
push userbwerth@mozilla.com
push dateTue, 14 Mar 2017 21:42:09 +0000
bugs1343695
milestone55.0a1
Bug 1343695 Part 2: Narrow an overly restrictive assert in GetRenderedText. MozReview-Commit-ID: EuxNJmKPxok
layout/generic/nsTextFrame.cpp
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -9833,17 +9833,23 @@ LineEndsInHardLineBreak(nsTextFrame* aFr
 }
 
 nsIFrame::RenderedText
 nsTextFrame::GetRenderedText(uint32_t aStartOffset,
                              uint32_t aEndOffset,
                              TextOffsetType aOffsetType,
                              TrailingWhitespace aTrimTrailingWhitespace)
 {
-  NS_ASSERTION(!GetPrevContinuation(), "Must be called on first-in-flow");
+  MOZ_ASSERT(aStartOffset <= aEndOffset, "bogus offsets");
+  MOZ_ASSERT(!GetPrevContinuation() ||
+             (aOffsetType == TextOffsetType::OFFSETS_IN_CONTENT_TEXT &&
+              aStartOffset >= (uint32_t)GetContentOffset() &&
+              aEndOffset <= (uint32_t)GetContentEnd()),
+             "Must be called on first-in-flow, or content offsets must be "
+             "given and be within this frame.");
 
   // The handling of offsets could be more efficient...
   RenderedText result;
   nsBlockFrame* lineContainer = nullptr;
   nsTextFrame* textFrame;
   const nsTextFragment* textFrag = mContent->GetText();
   uint32_t offsetInRenderedString = 0;
   bool haveOffsets = false;