Bug 1521604 Part 1: Hoist the flushing version of GetPrimaryFrame from Element to nsIContent. r=bzbarsky
authorBrad Werth <bwerth@mozilla.com>
Fri, 01 Feb 2019 22:28:54 +0000
changeset 514377 6d3b8198f3995d6400433eddd85ae040ecdba310
parent 514376 bcb403c04f1c869e7a64636077deb8f6a9ef2aff
child 514378 e23801bb3b78d664fac0726a0609a2996e3f0cfe
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1521604
milestone67.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 1521604 Part 1: Hoist the flushing version of GetPrimaryFrame from Element to nsIContent. r=bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D17713
dom/base/Element.cpp
dom/base/Element.h
dom/base/nsIContent.h
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -210,16 +210,30 @@ ASSERT_NODE_SIZE(Text, 120, 64);
 
 nsAtom* nsIContent::DoGetID() const {
   MOZ_ASSERT(HasID(), "Unexpected call");
   MOZ_ASSERT(IsElement(), "Only elements can have IDs");
 
   return AsElement()->GetParsedAttr(nsGkAtoms::id)->GetAtomValue();
 }
 
+nsIFrame* nsIContent::GetPrimaryFrame(mozilla::FlushType aType) {
+  Document* doc = GetComposedDoc();
+  if (!doc) {
+    return nullptr;
+  }
+
+  // Cause a flush, so we get up-to-date frame information.
+  if (aType != mozilla::FlushType::None) {
+    doc->FlushPendingNotifications(aType);
+  }
+
+  return GetPrimaryFrame();
+}
+
 namespace mozilla {
 namespace dom {
 
 const nsAttrValue* Element::GetSVGAnimatedClass() const {
   MOZ_ASSERT(MayHaveClass() && IsSVGElement(), "Unexpected call");
   return static_cast<const SVGElement*>(this)->GetAnimatedClassName();
 }
 
@@ -2175,31 +2189,16 @@ nsresult Element::DispatchClickEvent(nsP
   if (aExtraEventFlags) {
     // Be careful not to overwrite existing flags!
     event.mFlags.Union(*aExtraEventFlags);
   }
 
   return DispatchEvent(aPresContext, &event, aTarget, aFullDispatch, aStatus);
 }
 
-nsIFrame* Element::GetPrimaryFrame(FlushType aType) {
-  Document* doc = GetComposedDoc();
-  if (!doc) {
-    return nullptr;
-  }
-
-  // Cause a flush, so we get up-to-date frame
-  // information
-  if (aType != FlushType::None) {
-    doc->FlushPendingNotifications(aType);
-  }
-
-  return GetPrimaryFrame();
-}
-
 //----------------------------------------------------------------------
 nsresult Element::LeaveLink(nsPresContext* aPresContext) {
   nsILinkHandler* handler = aPresContext->GetLinkHandler();
   if (!handler) {
     return NS_OK;
   }
 
   return handler->OnLeaveLink();
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1380,27 +1380,16 @@ class Element : public FragmentOrElement
    * event.
    * If aPresContext is nullptr, this does nothing.
    */
   using nsIContent::DispatchEvent;
   static nsresult DispatchEvent(nsPresContext* aPresContext,
                                 WidgetEvent* aEvent, nsIContent* aTarget,
                                 bool aFullDispatch, nsEventStatus* aStatus);
 
-  /**
-   * Get the primary frame for this content with flushing
-   *
-   * @param aType the kind of flush to do, typically FlushType::Frames or
-   *              FlushType::Layout
-   * @return the primary frame
-   */
-  nsIFrame* GetPrimaryFrame(FlushType aType);
-  // Work around silly C++ name hiding stuff
-  nsIFrame* GetPrimaryFrame() const { return nsIContent::GetPrimaryFrame(); }
-
   bool IsDisplayContents() const {
     return HasServoData() && Servo_Element_IsDisplayContents(this);
   }
 
   const nsAttrValue* GetParsedAttr(const nsAtom* aAttr) const {
     return mAttrs.GetAttr(aAttr);
   }
 
--- a/dom/base/nsIContent.h
+++ b/dom/base/nsIContent.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef nsIContent_h___
 #define nsIContent_h___
 
 #include "mozilla/Attributes.h"
+#include "mozilla/FlushType.h"
 #include "mozilla/dom/BorrowedAttrInfo.h"
 #include "nsCaseTreatment.h"  // for enum, cannot be forward-declared
 #include "nsINode.h"
 #include "nsStringFwd.h"
 #include "nsISupportsImpl.h"
 
 // Forward declarations
 class nsAtom;
@@ -632,16 +633,25 @@ class nsIContent : public nsINode {
    *
    * In the case of absolutely positioned elements and floated elements, this
    * frame is the out of flow frame, not the placeholder.
    */
   nsIFrame* GetPrimaryFrame() const {
     return (IsInUncomposedDoc() || IsInShadowTree()) ? mPrimaryFrame : nullptr;
   }
 
+  /**
+   * Get the primary frame for this content with flushing
+   *
+   * @param aType the kind of flush to do, typically FlushType::Frames or
+   *              FlushType::Layout
+   * @return the primary frame
+   */
+  nsIFrame* GetPrimaryFrame(mozilla::FlushType aType);
+
   // Defined in nsIContentInlines.h because it needs nsIFrame.
   inline void SetPrimaryFrame(nsIFrame* aFrame);
 
   nsresult LookupNamespaceURIInternal(const nsAString& aNamespacePrefix,
                                       nsAString& aNamespaceURI) const;
 
   /**
    * If this content has independent selection, e.g., if this is input field