Title: [153494] trunk/Source/WebCore
Revision
153494
Author
[email protected]
Date
2013-07-30 14:32:54 -0700 (Tue, 30 Jul 2013)

Log Message

Inactive style sheets should not trigger style recalc when loaded.
<http://webkit.org/b/119236>
<rdar://problem/14588132>

Reviewed by Antti Koivisto.

Style sheets that are either alternate sheets or are excluded by their media query should not trigger
a full style recalc when they finish loading, since the end result will not be observably different.

The sheets are still inspectable through document.styleSheets.

Changed enums from Blocking/NonBlocking to ActiveSheet/InactiveSheet to clarify what's going on.

* html/HTMLLinkElement.h:
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::HTMLLinkElement):
(WebCore::HTMLLinkElement::setDisabledState):
(WebCore::HTMLLinkElement::process):
(WebCore::HTMLLinkElement::startLoadingDynamicSheet):
(WebCore::HTMLLinkElement::addPendingSheet):
(WebCore::HTMLLinkElement::removePendingSheet):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (153493 => 153494)


--- trunk/Source/WebCore/ChangeLog	2013-07-30 21:27:09 UTC (rev 153493)
+++ trunk/Source/WebCore/ChangeLog	2013-07-30 21:32:54 UTC (rev 153494)
@@ -1,3 +1,27 @@
+2013-07-30  Andreas Kling  <[email protected]>
+
+        Inactive style sheets should not trigger style recalc when loaded.
+        <http://webkit.org/b/119236>
+        <rdar://problem/14588132>
+
+        Reviewed by Antti Koivisto.
+
+        Style sheets that are either alternate sheets or are excluded by their media query should not trigger
+        a full style recalc when they finish loading, since the end result will not be observably different.
+
+        The sheets are still inspectable through document.styleSheets.
+
+        Changed enums from Blocking/NonBlocking to ActiveSheet/InactiveSheet to clarify what's going on.
+
+        * html/HTMLLinkElement.h:
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::HTMLLinkElement):
+        (WebCore::HTMLLinkElement::setDisabledState):
+        (WebCore::HTMLLinkElement::process):
+        (WebCore::HTMLLinkElement::startLoadingDynamicSheet):
+        (WebCore::HTMLLinkElement::addPendingSheet):
+        (WebCore::HTMLLinkElement::removePendingSheet):
+
 2013-07-30  Tim Horton  <[email protected]>
 
         Fix typo in enum name ("SelectionInSnaphot" -> "SelectionInSnapshot")

Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (153493 => 153494)


--- trunk/Source/WebCore/html/HTMLLinkElement.cpp	2013-07-30 21:27:09 UTC (rev 153493)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp	2013-07-30 21:32:54 UTC (rev 153494)
@@ -71,7 +71,7 @@
     , m_isInShadowTree(false)
     , m_firedLoad(false)
     , m_loadedSheet(false)
-    , m_pendingSheetType(None)
+    , m_pendingSheetType(Unknown)
 {
     ASSERT(hasTagName(linkTag));
 }
@@ -109,7 +109,7 @@
 
             // Check #2: An alternate sheet becomes enabled while it is still loading.
             if (m_relAttribute.m_isAlternate && m_disabledState == EnabledViaScript)
-                addPendingSheet(Blocking);
+                addPendingSheet(ActiveSheet);
 
             // Check #3: A main sheet becomes enabled while it was still loading and
             // after it was disabled via script. It takes really terrible code to make this
@@ -117,7 +117,7 @@
             // virtualplastic.net, which manages to do about 12 enable/disables on only 3
             // sheets. :)
             if (!m_relAttribute.m_isAlternate && m_disabledState == EnabledViaScript && oldDisabledState == Disabled)
-                addPendingSheet(Blocking);
+                addPendingSheet(ActiveSheet);
 
             // If the sheet is already loading just bail.
             return;
@@ -212,11 +212,11 @@
 
         // Don't hold up render tree construction and script execution on stylesheets
         // that are not needed for the rendering at the moment.
-        bool blocking = mediaQueryMatches && !isAlternate();
-        addPendingSheet(blocking ? Blocking : NonBlocking);
+        bool isActive = mediaQueryMatches && !isAlternate();
+        addPendingSheet(isActive ? ActiveSheet : InactiveSheet);
 
         // Load stylesheets that are not needed for the rendering immediately with low priority.
-        ResourceLoadPriority priority = blocking ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
+        ResourceLoadPriority priority = isActive ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
         CachedResourceRequest request(ResourceRequest(document()->completeURL(url)), charset, priority);
         request.setInitiator(this);
         m_cachedSheet = document()->cachedResourceLoader()->requestCSSStyleSheet(request);
@@ -383,9 +383,9 @@
 
 void HTMLLinkElement::startLoadingDynamicSheet()
 {
-    // We don't support multiple blocking sheets.
-    ASSERT(m_pendingSheetType < Blocking);
-    addPendingSheet(Blocking);
+    // We don't support multiple active sheets.
+    ASSERT(m_pendingSheetType < ActiveSheet);
+    addPendingSheet(ActiveSheet);
 }
 
 bool HTMLLinkElement::isURLAttribute(const Attribute& attribute) const
@@ -448,7 +448,7 @@
         return;
     m_pendingSheetType = type;
 
-    if (m_pendingSheetType == NonBlocking)
+    if (m_pendingSheetType == InactiveSheet)
         return;
     document()->styleSheetCollection()->addPendingSheet();
 }
@@ -456,13 +456,14 @@
 void HTMLLinkElement::removePendingSheet(RemovePendingSheetNotificationType notification)
 {
     PendingSheetType type = m_pendingSheetType;
-    m_pendingSheetType = None;
+    m_pendingSheetType = Unknown;
 
-    if (type == None)
+    if (type == Unknown)
         return;
-    if (type == NonBlocking) {
-        // Document::removePendingSheet() triggers the style selector recalc for blocking sheets.
-        document()->styleResolverChanged(RecalcStyleImmediately);
+
+    if (type == InactiveSheet) {
+        // Document just needs to know about the sheet for exposure through document.styleSheets
+        document()->styleSheetCollection()->updateActiveStyleSheets(DocumentStyleSheetCollection::OptimizedUpdate);
         return;
     }
 

Modified: trunk/Source/WebCore/html/HTMLLinkElement.h (153493 => 153494)


--- trunk/Source/WebCore/html/HTMLLinkElement.h	2013-07-30 21:27:09 UTC (rev 153493)
+++ trunk/Source/WebCore/html/HTMLLinkElement.h	2013-07-30 21:32:54 UTC (rev 153494)
@@ -101,8 +101,8 @@
     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
 
     virtual void finishParsingChildren();
-    
-    enum PendingSheetType { None, NonBlocking, Blocking };
+
+    enum PendingSheetType { Unknown, ActiveSheet, InactiveSheet };
     void addPendingSheet(PendingSheetType);
 
     enum RemovePendingSheetNotificationType {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to