Bug 1368802 - nsFrameIterator::GetPlaceholderFrame should only try to get the placeholder for out-of-flow frames, because in-flow frames never have a placeholder. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Wed, 31 May 2017 21:29:49 +0200
changeset 412137 422e3c006cf2b56d94f969d4b8e29b0982103437
parent 412136 fc6012cad03e870b46ce4ddc2077762c31f8f9b7
child 412138 ddcdb354143a9018a9bc94cef7a395ef46873f8b
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1368802
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 1368802 - nsFrameIterator::GetPlaceholderFrame should only try to get the placeholder for out-of-flow frames, because in-flow frames never have a placeholder. r=jfkthame MozReview-Commit-ID: CcAlCWMHQQX
layout/base/nsFrameTraversal.cpp
--- a/layout/base/nsFrameTraversal.cpp
+++ b/layout/base/nsFrameTraversal.cpp
@@ -77,16 +77,20 @@ protected:
   */
   
   virtual nsIFrame* GetFirstChildInner(nsIFrame* aFrame);
   virtual nsIFrame* GetLastChildInner(nsIFrame* aFrame);  
 
   virtual nsIFrame* GetNextSiblingInner(nsIFrame* aFrame);
   virtual nsIFrame* GetPrevSiblingInner(nsIFrame* aFrame);
 
+  /**
+   * Return the placeholder frame for aFrame if it has one, otherwise return
+   * aFrame itself.
+   */
   nsIFrame* GetPlaceholderFrame(nsIFrame* aFrame);
   bool      IsPopupFrame(nsIFrame* aFrame);
 
   nsPresContext* const mPresContext;
   const bool mLockScroll;
   const bool mFollowOOFs;
   const bool mSkipPopupChecks;
   const nsIteratorType mType;
@@ -479,28 +483,22 @@ nsIFrame*
 nsFrameIterator::GetPrevSiblingInner(nsIFrame* aFrame) {
   return aFrame->GetPrevSibling();
 }
 
 
 nsIFrame*
 nsFrameIterator::GetPlaceholderFrame(nsIFrame* aFrame)
 {
-  nsIFrame* result = aFrame;
-  nsIPresShell *presShell = mPresContext->GetPresShell();
-  if (presShell) {
-    nsIFrame* placeholder = presShell->GetPlaceholderFrameFor(aFrame);
-    if (placeholder)
-      result = placeholder;
+  if (MOZ_LIKELY(!aFrame || !aFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW))) {
+    return aFrame;
   }
-
-  if (result != aFrame)
-    result = GetPlaceholderFrame(result);
-
-  return result;
+  nsIFrame* placeholder =
+    aFrame->PresContext()->PresShell()->GetPlaceholderFrameFor(aFrame);
+  return placeholder ? placeholder : aFrame;
 }
 
 bool
 nsFrameIterator::IsPopupFrame(nsIFrame* aFrame)
 {
   // If skipping popup checks, pretend this isn't one.
   if (mSkipPopupChecks) {
     return false;