Changeset 208356 in webkit


Ignore:
Timestamp:
Nov 3, 2016 4:18:01 PM (8 years ago)
Author:
Ryan Haddad
Message:

Unreviewed, rolling out r208302.

This change causes LayoutTest crashes under GuardMalloc.

Reverted changeset:

"Load stylesheets in link elements inside a connected shadow
tree"
https://bugs.webkit.org/show_bug.cgi?id=160683
http://trac.webkit.org/changeset/208302

Location:
trunk
Files:
5 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r208351 r208356  
     12016-11-03  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r208302.
     4
     5        This change causes LayoutTest crashes under GuardMalloc.
     6
     7        Reverted changeset:
     8
     9        "Load stylesheets in link elements inside a connected shadow
     10        tree"
     11        https://bugs.webkit.org/show_bug.cgi?id=160683
     12        http://trac.webkit.org/changeset/208302
     13
    1142016-11-03  Yusuke Suzuki  <utatane.tea@gmail.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r208355 r208356  
     12016-11-03  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r208302.
     4
     5        This change causes LayoutTest crashes under GuardMalloc.
     6
     7        Reverted changeset:
     8
     9        "Load stylesheets in link elements inside a connected shadow
     10        tree"
     11        https://bugs.webkit.org/show_bug.cgi?id=160683
     12        http://trac.webkit.org/changeset/208302
     13
    1142016-11-03  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebCore/dom/Document.cpp

    r208302 r208356  
    69816981{
    69826982    ASSERT(shadowRoot.inDocument());
    6983     ASSERT(!m_inDocumentShadowRoots.contains(&shadowRoot));
    69846983    m_inDocumentShadowRoots.add(&shadowRoot);
    69856984}
     
    69876986void Document::didRemoveInDocumentShadowRoot(ShadowRoot& shadowRoot)
    69886987{
    6989     ASSERT(!shadowRoot.inDocument());
    69906988    ASSERT(m_inDocumentShadowRoots.contains(&shadowRoot));
    69916989    m_inDocumentShadowRoots.remove(&shadowRoot);
  • trunk/Source/WebCore/dom/Element.cpp

    r208347 r208356  
    17851785    oldRoot->setHost(nullptr);
    17861786    oldRoot->setParentTreeScope(&document());
     1787
     1788    notifyChildNodeRemoved(*this, *oldRoot);
    17871789}
    17881790
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r208302 r208356  
    8585Node::InsertionNotificationRequest ShadowRoot::insertedInto(ContainerNode& insertionPoint)
    8686{
    87     bool wasInDocument = inDocument();
    88     DocumentFragment::insertedInto(insertionPoint);
    89     if (insertionPoint.inDocument() && !wasInDocument)
     87    auto result = DocumentFragment::insertedInto(insertionPoint);
     88    if (inDocument())
    9089        document().didInsertInDocumentShadowRoot(*this);
    91     return InsertionDone;
     90    return result;
    9291}
    9392
    9493void ShadowRoot::removedFrom(ContainerNode& insertionPoint)
    9594{
     95    if (inDocument())
     96        document().didRemoveInDocumentShadowRoot(*this);
    9697    DocumentFragment::removedFrom(insertionPoint);
    97     if (insertionPoint.inDocument() && !inDocument())
    98         document().didRemoveInDocumentShadowRoot(*this);
    9998}
    10099
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r208302 r208356  
    8181    , m_loading(false)
    8282    , m_createdByParser(createdByParser)
     83    , m_isInShadowTree(false)
    8384    , m_firedLoad(false)
    8485    , m_loadedResource(false)
     
    101102        m_cachedSheet->removeClient(*this);
    102103
    103     if (m_styleScope)
    104         m_styleScope->removeStyleSheetCandidateNode(*this);
     104    if (inDocument())
     105        document().styleScope().removeStyleSheetCandidateNode(*this);
    105106
    106107    linkLoadEventSender().cancelEvent(*this);
     
    112113    DisabledState oldDisabledState = m_disabledState;
    113114    m_disabledState = disabled ? Disabled : EnabledViaScript;
    114     if (oldDisabledState == m_disabledState)
    115         return;
    116 
    117     ASSERT(inDocument() || !styleSheetIsLoading());
    118     if (!inDocument())
    119         return;
    120 
    121     // If we change the disabled state while the sheet is still loading, then we have to
    122     // perform three checks:
    123     if (styleSheetIsLoading()) {
    124         // Check #1: The sheet becomes disabled while loading.
    125         if (m_disabledState == Disabled)
    126             removePendingSheet();
    127 
    128         // Check #2: An alternate sheet becomes enabled while it is still loading.
    129         if (m_relAttribute.isAlternate && m_disabledState == EnabledViaScript)
    130             addPendingSheet(ActiveSheet);
    131 
    132         // Check #3: A main sheet becomes enabled while it was still loading and
    133         // after it was disabled via script. It takes really terrible code to make this
    134         // happen (a double toggle for no reason essentially). This happens on
    135         // virtualplastic.net, which manages to do about 12 enable/disables on only 3
    136         // sheets. :)
    137         if (!m_relAttribute.isAlternate && m_disabledState == EnabledViaScript && oldDisabledState == Disabled)
    138             addPendingSheet(ActiveSheet);
    139 
    140         // If the sheet is already loading just bail.
    141         return;
    142     }
    143 
    144     // Load the sheet, since it's never been loaded before.
    145     if (!m_sheet && m_disabledState == EnabledViaScript)
    146         process();
    147     else {
    148         ASSERT(m_styleScope);
    149         m_styleScope->didChangeActiveStyleSheetCandidates();
     115    if (oldDisabledState != m_disabledState) {
     116        // If we change the disabled state while the sheet is still loading, then we have to
     117        // perform three checks:
     118        if (styleSheetIsLoading()) {
     119            // Check #1: The sheet becomes disabled while loading.
     120            if (m_disabledState == Disabled)
     121                removePendingSheet();
     122
     123            // Check #2: An alternate sheet becomes enabled while it is still loading.
     124            if (m_relAttribute.isAlternate && m_disabledState == EnabledViaScript)
     125                addPendingSheet(ActiveSheet);
     126
     127            // Check #3: A main sheet becomes enabled while it was still loading and
     128            // after it was disabled via script. It takes really terrible code to make this
     129            // happen (a double toggle for no reason essentially). This happens on
     130            // virtualplastic.net, which manages to do about 12 enable/disables on only 3
     131            // sheets. :)
     132            if (!m_relAttribute.isAlternate && m_disabledState == EnabledViaScript && oldDisabledState == Disabled)
     133                addPendingSheet(ActiveSheet);
     134
     135            // If the sheet is already loading just bail.
     136            return;
     137        }
     138
     139        // Load the sheet, since it's never been loaded before.
     140        if (!m_sheet && m_disabledState == EnabledViaScript)
     141            process();
     142        else
     143            document().styleScope().didChangeActiveStyleSheetCandidates();
    150144    }
    151145}
     
    183177        process();
    184178        if (m_sheet && !isDisabled())
    185             m_styleScope->didChangeActiveStyleSheetCandidates();
     179            document().styleScope().didChangeActiveStyleSheetCandidates();
    186180        return;
    187181    }
     
    221215void HTMLLinkElement::process()
    222216{
    223     if (!inDocument()) {
     217    if (!inDocument() || m_isInShadowTree) {
    224218        ASSERT(!m_sheet);
    225219        return;
     
    290284        // we no longer contain a stylesheet, e.g. perhaps rel or type was changed
    291285        clearSheet();
    292         m_styleScope->didChangeActiveStyleSheetCandidates();
     286        document().styleScope().didChangeActiveStyleSheetCandidates();
    293287    }
    294288}
     
    304298Node::InsertionNotificationRequest HTMLLinkElement::insertedInto(ContainerNode& insertionPoint)
    305299{
    306     bool wasInDocument = inDocument();
    307300    HTMLElement::insertedInto(insertionPoint);
    308     if (!insertionPoint.inDocument() || wasInDocument)
     301    if (!insertionPoint.inDocument())
    309302        return InsertionDone;
    310303
    311     m_styleScope = &Style::Scope::forNode(*this);
    312     m_styleScope->addStyleSheetCandidateNode(*this, m_createdByParser);
     304    m_isInShadowTree = isInShadowTree();
     305    if (m_isInShadowTree)
     306        return InsertionDone;
     307
     308    document().styleScope().addStyleSheetCandidateNode(*this, m_createdByParser);
    313309
    314310    process();
     
    319315{
    320316    HTMLElement::removedFrom(insertionPoint);
    321     if (!insertionPoint.inDocument() || inDocument())
    322         return;
     317    if (!insertionPoint.inDocument())
     318        return;
     319
     320    if (m_isInShadowTree) {
     321        ASSERT(!m_sheet);
     322        return;
     323    }
     324    document().styleScope().removeStyleSheetCandidateNode(*this);
    323325
    324326    if (m_sheet)
     
    327329    if (styleSheetIsLoading())
    328330        removePendingSheet(RemovePendingSheetNotifyLater);
    329    
    330     if (m_styleScope) {
    331         m_styleScope->removeStyleSheetCandidateNode(*this);
    332         m_styleScope = nullptr;
    333     }
    334 
    335331}
    336332
     
    549545    if (m_pendingSheetType == InactiveSheet)
    550546        return;
    551     ASSERT(m_styleScope);
    552     m_styleScope->addPendingSheet();
     547    document().styleScope().addPendingSheet();
    553548}
    554549
     
    561556        return;
    562557
    563     ASSERT(m_styleScope);
    564558    if (type == InactiveSheet) {
    565559        // Document just needs to know about the sheet for exposure through document.styleSheets
    566         m_styleScope->didChangeActiveStyleSheetCandidates();
    567         return;
    568     }
    569 
    570     m_styleScope->removePendingSheet(
     560        document().styleScope().didChangeActiveStyleSheetCandidates();
     561        return;
     562    }
     563
     564    document().styleScope().removePendingSheet(
    571565        notification == RemovePendingSheetNotifyImmediately
    572566        ? Style::Scope::RemovePendingSheetNotifyImmediately
  • trunk/Source/WebCore/html/HTMLLinkElement.h

    r208302 r208356  
    120120
    121121    LinkLoader m_linkLoader;
    122     Style::Scope* m_styleScope { nullptr };
    123122    CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
    124123    RefPtr<CSSStyleSheet> m_sheet;
     
    136135    bool m_loading;
    137136    bool m_createdByParser;
     137    bool m_isInShadowTree;
    138138    bool m_firedLoad;
    139139    bool m_loadedResource;
  • trunk/Source/WebCore/html/HTMLStyleElement.cpp

    r208302 r208356  
    9595Node::InsertionNotificationRequest HTMLStyleElement::insertedInto(ContainerNode& insertionPoint)
    9696{
    97     bool wasInDocument = inDocument();
    98     auto result = HTMLElement::insertedInto(insertionPoint);
    99     if (insertionPoint.inDocument() && !wasInDocument)
     97    HTMLElement::insertedInto(insertionPoint);
     98    if (insertionPoint.inDocument())
    10099        m_styleSheetOwner.insertedIntoDocument(*this);
    101     return result;
     100
     101    return InsertionDone;
    102102}
    103103
     
    105105{
    106106    HTMLElement::removedFrom(insertionPoint);
    107     if (insertionPoint.inDocument() && !inDocument())
     107
     108    if (insertionPoint.inDocument())
    108109        m_styleSheetOwner.removedFromDocument(*this);
    109110}
  • trunk/Source/WebCore/svg/SVGStyleElement.cpp

    r208302 r208356  
    117117Node::InsertionNotificationRequest SVGStyleElement::insertedInto(ContainerNode& rootParent)
    118118{
    119     bool wasInDocument = inDocument();
    120     auto result = SVGElement::insertedInto(rootParent);
    121     if (rootParent.inDocument() && !wasInDocument)
     119    SVGElement::insertedInto(rootParent);
     120    if (rootParent.inDocument())
    122121        m_styleSheetOwner.insertedIntoDocument(*this);
    123     return result;
     122    return InsertionDone;
    124123}
    125124
     
    127126{
    128127    SVGElement::removedFrom(rootParent);
    129     if (rootParent.inDocument() && !inDocument())
     128    if (rootParent.inDocument())
    130129        m_styleSheetOwner.removedFromDocument(*this);
    131130}
Note: See TracChangeset for help on using the changeset viewer.