Bug 1367306 part 1 - Add an attribute in nsIDOMWindowUtils to check whether the document is styled by stylo. r?bholley draft
authorXidorn Quan <me@upsuper.org>
Wed, 21 Jun 2017 15:24:55 +1000
changeset 597888 128b864d4e43e9f57f110a780cdb015ca3598054
parent 597887 a22c4c79321e3c540bab29edf9c8d5b01f29449d
child 597889 3143631f66a5a8e66692c18ef85e08d42bc7a4d3
push id65074
push userxquan@mozilla.com
push dateWed, 21 Jun 2017 05:26:15 +0000
reviewersbholley
bugs1367306
milestone56.0a1
Bug 1367306 part 1 - Add an attribute in nsIDOMWindowUtils to check whether the document is styled by stylo. r?bholley MozReview-Commit-ID: 6ed78DkzmT8
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -4337,16 +4337,24 @@ nsDOMWindowUtils::GetDirectionFromText(c
       break;
     case eDir_Auto:
       MOZ_ASSERT_UNREACHABLE("GetDirectionFromText should never return this value");
       return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
+NS_IMETHODIMP
+nsDOMWindowUtils::GetIsStyledByServo(bool* aStyledByServo)
+{
+  nsIDocument* doc = GetDocument();
+  *aStyledByServo = doc && doc->IsStyledByServo();
+  return NS_OK;
+}
+
 NS_INTERFACE_MAP_BEGIN(nsTranslationNodeList)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY(nsITranslationNodeList)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(nsTranslationNodeList)
 NS_IMPL_RELEASE(nsTranslationNodeList)
 
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -2021,16 +2021,23 @@ interface nsIDOMWindowUtils : nsISupport
    * algorithm defined in http://unicode.org/reports/tr9/#P2.
    *
    * @param aString the string to retrieve the direction for.
    * @return one of DIRECTION_LTR, DIRECTION_RTL or DIRECTION_NOT_SET depending
    *         on the first-strong character found in the string.
    */
   long getDirectionFromText(in AString aString);
 
+  /**
+   * Whether the current document is styled by Servo's style engine.
+   *
+   * This calls nsIDocument::IsStyledByServo().
+   */
+  readonly attribute boolean isStyledByServo;
+
   // These consts are only for testing purposes.
   const long DEFAULT_MOUSE_POINTER_ID = 0;
   const long DEFAULT_PEN_POINTER_ID   = 1;
   const long DEFAULT_TOUCH_POINTER_ID = 2;
 
   // Match WidgetMouseEventBase::buttonType.
   const long MOUSE_BUTTON_LEFT_BUTTON   = 0;
   const long MOUSE_BUTTON_MIDDLE_BUTTON = 1;