Bug 1363640 Part 2 - Move the logic in SupportsServoStyleBackend() to UpdateStyleBackendType(). draft
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 09 May 2017 18:33:57 -0700
changeset 583791 aea94616d571fa3726c52bf026d222b4ef7ea6ac
parent 583790 09f034b8b9b9cc8647c322c9866691cf0dbc5ed9
child 583792 1c06b80333984576a92f32289a68160ca54f0cea
push id60548
push userbmo:tlin@mozilla.com
push dateWed, 24 May 2017 17:00:28 +0000
bugs1363640
milestone55.0a1
Bug 1363640 Part 2 - Move the logic in SupportsServoStyleBackend() to UpdateStyleBackendType(). SupportsServoStyleBackend() uses methods in nsIDocument, so it would be more straightforward to do that in UpdateStyleBackendType(). Also, call StyloEnabled() before doing other logic so that the warning about "no docshell" won't show up when stylo is built but disabled. MozReview-Commit-ID: 9ZUYatPBv1r
dom/base/nsDocument.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -13139,27 +13139,23 @@ nsIDocument::UpdateStyleBackendType()
 {
   MOZ_ASSERT(mStyleBackendType == StyleBackendType::None,
              "no need to call UpdateStyleBackendType now");
 
   // Assume Gecko by default.
   mStyleBackendType = StyleBackendType::Gecko;
 
 #ifdef MOZ_STYLO
-  // XXX For now we use a Servo-backed style set only for (X)HTML documents
-  // in content docshells.  This should let us avoid implementing XUL-specific
-  // CSS features.  And apart from not supporting SVG properties in Servo
-  // yet, the root SVG element likes to create a style sheet for an SVG
-  // document before we have a pres shell (i.e. before we make the decision
-  // here about whether to use a Gecko- or Servo-backed style system), so
-  // we avoid Servo-backed style sets for SVG documents.
-  if (!mDocumentContainer) {
-    NS_WARNING("stylo: No docshell yet, assuming Gecko style system");
-  } else if (nsLayoutUtils::SupportsServoStyleBackend(this)) {
-    mStyleBackendType = StyleBackendType::Servo;
+  if (nsLayoutUtils::StyloEnabled()) {
+    if (!mDocumentContainer) {
+      NS_WARNING("stylo: No docshell yet, assuming Gecko style system");
+    } else if ((IsHTMLOrXHTML() || IsSVGDocument()) &&
+               IsContentDocument()) {
+      mStyleBackendType = StyleBackendType::Servo;
+    }
   }
 #endif
 }
 
 /**
  * Helper function for |nsDocument::PrincipalFlashClassification|
  *
  * Adds a table name string to a table list (a comma separated string). The
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -9336,25 +9336,16 @@ nsLayoutUtils::ComputePartialPrerenderAr
   // redistributing from one axis to another, or from one side to another.
   nscoord xExcess = aPrerenderSize.width - aDirtyRect.width;
   nscoord yExcess = aPrerenderSize.height - aDirtyRect.height;
   nsRect result = aDirtyRect;
   result.Inflate(xExcess / 2, yExcess / 2);
   return result.MoveInsideAndClamp(aOverflow);
 }
 
-
-/* static */ bool
-nsLayoutUtils::SupportsServoStyleBackend(nsIDocument* aDocument)
-{
-  return StyloEnabled() &&
-         (aDocument->IsHTMLOrXHTML() || aDocument->IsSVGDocument()) &&
-         aDocument->IsContentDocument();
-}
-
 static
 bool
 LineHasNonEmptyContentWorker(nsIFrame* aFrame)
 {
   // Look for non-empty frames, but ignore inline and br frames.
   // For inline frames, descend into the children, if any.
   if (aFrame->IsInlineFrame()) {
     for (nsIFrame* child : aFrame->PrincipalChildList()) {
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2908,24 +2908,16 @@ public:
    * @return A rectangle that includes |aDirtyRect|, is clamped to |aOverflow|,
    *         and is no larger than |aPrerenderSize|.
    */
   static nsRect ComputePartialPrerenderArea(const nsRect& aDirtyRect,
                                             const nsRect& aOverflow,
                                             const nsSize& aPrerenderSize);
 
   /*
-   * Returns whether the given document supports being rendered with a
-   * Servo-backed style system.  This checks whether Stylo is enabled
-   * globally, that the document is an HTML document, and that it is
-   * being presented in a content docshell.
-   */
-  static bool SupportsServoStyleBackend(nsIDocument* aDocument);
-
-  /*
    * Checks whether a node is an invisible break.
    * If not, returns the first frame on the next line if such a next line exists.
    *
    * @return  true if the node is an invisible break.
    *          aNextLineFrame is returned null in this case.
    *          false if the node causes a visible break or if the node is no break.
    *
    * @param   aNextLineFrame  assigned to first frame on the next line if such a