Bug 1359341 part 4 - Optimize initializing a nsBlockInFlowLineIterator for single-line blocks by skipping the search for aFindFrame. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Tue, 23 May 2017 19:09:27 +0200
changeset 360204 3cc5123e91476e84629230ede146c67ec60ecb6d
parent 360203 08e64a7a749562b2b857c51930d666e5bdda87e1
child 360205 e1f4657102382a13c3ff18d4313397771fbf8b1a
push id90599
push usermpalmgren@mozilla.com
push dateTue, 23 May 2017 17:09:38 +0000
treeherdermozilla-inbound@3cc5123e9147 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1359341
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1359341 part 4 - Optimize initializing a nsBlockInFlowLineIterator for single-line blocks by skipping the search for aFindFrame. r=jfkthame MozReview-Commit-ID: GpiNAzFhZeJ
layout/generic/nsBlockFrame.cpp
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -5659,16 +5659,24 @@ nsBlockInFlowLineIterator::nsBlockInFlow
 {
   *aFoundValidLine = false;
 
   nsIFrame* child = FindChildContaining(aFrame, aFindFrame);
   if (!child)
     return;
 
   LineIterator line_end = aFrame->LinesEnd();
+  mLine = aFrame->LinesBegin();
+  if (mLine != line_end && mLine.next() == line_end &&
+      !aFrame->HasOverflowLines()) {
+    // The block has a single line - that must be it!
+    *aFoundValidLine = true;
+    return;
+  }
+
   // Try to use the cursor if it exists, otherwise fall back to the first line
   if (nsLineBox* const cursor = aFrame->GetLineCursor()) {
     mLine = line_end;
     // Perform a simultaneous forward and reverse search starting from the
     // line cursor.
     nsBlockFrame::LineIterator line = aFrame->LinesBeginFrom(cursor);
     nsBlockFrame::ReverseLineIterator rline = aFrame->LinesRBeginFrom(cursor);
     nsBlockFrame::ReverseLineIterator rline_end = aFrame->LinesREnd();