Bug 1253476 - Move IsRendered to Element; r=emilio
authorBrian Birtles <birtles@gmail.com>
Mon, 20 May 2019 05:22:27 +0000
changeset 474492 b74b84baf7176ceb375f0f891511e5687470493b
parent 474491 16dbeeceab3854e49afa681ddffa0bfe8b943986
child 474493 180d65431190005d9607ae4ca4725226e1c8568c
push id36040
push userrgurzau@mozilla.com
push dateMon, 20 May 2019 13:43:21 +0000
treeherdermozilla-central@319a369ccde4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1253476
milestone68.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 1253476 - Move IsRendered to Element; r=emilio And update the GitHub issue link at the same time since #3947 was duped to #1837. Differential Revision: https://phabricator.services.mozilla.com/D30326
dom/base/Element.h
dom/html/nsGenericHTMLElement.cpp
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1402,16 +1402,24 @@ class Element : public FragmentOrElement
   static nsresult DispatchEvent(nsPresContext* aPresContext,
                                 WidgetEvent* aEvent, nsIContent* aTarget,
                                 bool aFullDispatch, nsEventStatus* aStatus);
 
   bool IsDisplayContents() const {
     return HasServoData() && Servo_Element_IsDisplayContents(this);
   }
 
+  /*
+   * https://html.spec.whatwg.org/#being-rendered
+   *
+   * With a gotcha for display contents:
+   *   https://github.com/whatwg/html/issues/1837
+   */
+  bool IsRendered() const { return GetPrimaryFrame() || IsDisplayContents(); }
+
   const nsAttrValue* GetParsedAttr(const nsAtom* aAttr) const {
     return mAttrs.GetAttr(aAttr);
   }
 
   const nsAttrValue* GetParsedAttr(const nsAtom* aAttr,
                                    int32_t aNameSpaceID) const {
     return mAttrs.GetAttr(aAttr, aNameSpaceID);
   }
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2648,24 +2648,16 @@ nsresult nsGenericHTMLElement::NewURIFro
     // and waiting for the subsequent load to fail.
     NS_RELEASE(*aURI);
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   }
 
   return NS_OK;
 }
 
-// https://html.spec.whatwg.org/#being-rendered
-//
-// With a gotcha for display contents:
-//   https://github.com/whatwg/html/issues/3947
-static bool IsRendered(const Element& aElement) {
-  return aElement.GetPrimaryFrame() || aElement.IsDisplayContents();
-}
-
 void nsGenericHTMLElement::GetInnerText(mozilla::dom::DOMString& aValue,
                                         mozilla::ErrorResult& aError) {
   // innerText depends on layout. For example, white space processing is
   // something that happens during reflow and which must be reflected by
   // innerText.  So for:
   //
   //   <div style="white-space:normal"> A     B C </div>
   //
@@ -2710,17 +2702,17 @@ void nsGenericHTMLElement::GetInnerText(
     frame = frame->GetInFlowParent();
   }
 
   // Flush layout if we determined a reflow is required.
   if (dirty && doc) {
     doc->FlushPendingNotifications(FlushType::Layout);
   }
 
-  if (!IsRendered(*this)) {
+  if (!IsRendered()) {
     GetTextContentInternal(aValue, aError);
   } else {
     nsRange::GetInnerTextNoFlush(aValue, aError, this);
   }
 }
 
 void nsGenericHTMLElement::SetInnerText(const nsAString& aValue) {
   // Batch possible DOMSubtreeModified events.