Changeset 153494 in webkit


Ignore:
Timestamp:
Jul 30, 2013 2:32:54 PM (11 years ago)
Author:
akling@apple.com
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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r153493 r153494  
     12013-07-30  Andreas Kling  <akling@apple.com>
     2
     3        Inactive style sheets should not trigger style recalc when loaded.
     4        <http://webkit.org/b/119236>
     5        <rdar://problem/14588132>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Style sheets that are either alternate sheets or are excluded by their media query should not trigger
     10        a full style recalc when they finish loading, since the end result will not be observably different.
     11
     12        The sheets are still inspectable through document.styleSheets.
     13
     14        Changed enums from Blocking/NonBlocking to ActiveSheet/InactiveSheet to clarify what's going on.
     15
     16        * html/HTMLLinkElement.h:
     17        * html/HTMLLinkElement.cpp:
     18        (WebCore::HTMLLinkElement::HTMLLinkElement):
     19        (WebCore::HTMLLinkElement::setDisabledState):
     20        (WebCore::HTMLLinkElement::process):
     21        (WebCore::HTMLLinkElement::startLoadingDynamicSheet):
     22        (WebCore::HTMLLinkElement::addPendingSheet):
     23        (WebCore::HTMLLinkElement::removePendingSheet):
     24
    1252013-07-30  Tim Horton  <timothy_horton@apple.com>
    226
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r150356 r153494  
    7272    , m_firedLoad(false)
    7373    , m_loadedSheet(false)
    74     , m_pendingSheetType(None)
     74    , m_pendingSheetType(Unknown)
    7575{
    7676    ASSERT(hasTagName(linkTag));
     
    110110            // Check #2: An alternate sheet becomes enabled while it is still loading.
    111111            if (m_relAttribute.m_isAlternate && m_disabledState == EnabledViaScript)
    112                 addPendingSheet(Blocking);
     112                addPendingSheet(ActiveSheet);
    113113
    114114            // Check #3: A main sheet becomes enabled while it was still loading and
     
    118118            // sheets. :)
    119119            if (!m_relAttribute.m_isAlternate && m_disabledState == EnabledViaScript && oldDisabledState == Disabled)
    120                 addPendingSheet(Blocking);
     120                addPendingSheet(ActiveSheet);
    121121
    122122            // If the sheet is already loading just bail.
     
    213213        // Don't hold up render tree construction and script execution on stylesheets
    214214        // that are not needed for the rendering at the moment.
    215         bool blocking = mediaQueryMatches && !isAlternate();
    216         addPendingSheet(blocking ? Blocking : NonBlocking);
     215        bool isActive = mediaQueryMatches && !isAlternate();
     216        addPendingSheet(isActive ? ActiveSheet : InactiveSheet);
    217217
    218218        // Load stylesheets that are not needed for the rendering immediately with low priority.
    219         ResourceLoadPriority priority = blocking ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
     219        ResourceLoadPriority priority = isActive ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
    220220        CachedResourceRequest request(ResourceRequest(document()->completeURL(url)), charset, priority);
    221221        request.setInitiator(this);
     
    384384void HTMLLinkElement::startLoadingDynamicSheet()
    385385{
    386     // We don't support multiple blocking sheets.
    387     ASSERT(m_pendingSheetType < Blocking);
    388     addPendingSheet(Blocking);
     386    // We don't support multiple active sheets.
     387    ASSERT(m_pendingSheetType < ActiveSheet);
     388    addPendingSheet(ActiveSheet);
    389389}
    390390
     
    449449    m_pendingSheetType = type;
    450450
    451     if (m_pendingSheetType == NonBlocking)
     451    if (m_pendingSheetType == InactiveSheet)
    452452        return;
    453453    document()->styleSheetCollection()->addPendingSheet();
     
    457457{
    458458    PendingSheetType type = m_pendingSheetType;
    459     m_pendingSheetType = None;
    460 
    461     if (type == None)
    462         return;
    463     if (type == NonBlocking) {
    464         // Document::removePendingSheet() triggers the style selector recalc for blocking sheets.
    465         document()->styleResolverChanged(RecalcStyleImmediately);
     459    m_pendingSheetType = Unknown;
     460
     461    if (type == Unknown)
     462        return;
     463
     464    if (type == InactiveSheet) {
     465        // Document just needs to know about the sheet for exposure through document.styleSheets
     466        document()->styleSheetCollection()->updateActiveStyleSheets(DocumentStyleSheetCollection::OptimizedUpdate);
    466467        return;
    467468    }
  • trunk/Source/WebCore/html/HTMLLinkElement.h

    r151947 r153494  
    102102
    103103    virtual void finishParsingChildren();
    104    
    105     enum PendingSheetType { None, NonBlocking, Blocking };
     104
     105    enum PendingSheetType { Unknown, ActiveSheet, InactiveSheet };
    106106    void addPendingSheet(PendingSheetType);
    107107
Note: See TracChangeset for help on using the changeset viewer.