Changeset 202227 in webkit


Ignore:
Timestamp:
Jun 20, 2016 1:52:10 AM (8 years ago)
Author:
Antti Koivisto
Message:

Updating class name of a shadow host does not update the style applied by :host()
https://bugs.webkit.org/show_bug.cgi?id=158900
<rdar://problem/26883707>

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/shadow-dom/shadow-host-style-update.html

Teach style invalidation optimization code about :host.

  • style/AttributeChangeInvalidation.cpp:

(WebCore::Style::mayBeAffectedByHostStyle):
(WebCore::Style::AttributeChangeInvalidation::invalidateStyle):

  • style/ClassChangeInvalidation.cpp:

(WebCore::Style::computeClassChange):
(WebCore::Style::mayBeAffectedByHostStyle):
(WebCore::Style::ClassChangeInvalidation::invalidateStyle):

  • style/IdChangeInvalidation.cpp:

(WebCore::Style::mayBeAffectedByHostStyle):
(WebCore::Style::IdChangeInvalidation::invalidateStyle):

LayoutTests:

  • fast/shadow-dom/shadow-host-style-update-expected.html: Added.
  • fast/shadow-dom/shadow-host-style-update.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202223 r202227  
     12016-06-19  Antti Koivisto  <antti@apple.com>
     2
     3        Updating class name of a shadow host does not update the style applied by :host()
     4        https://bugs.webkit.org/show_bug.cgi?id=158900
     5        <rdar://problem/26883707>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * fast/shadow-dom/shadow-host-style-update-expected.html: Added.
     10        * fast/shadow-dom/shadow-host-style-update.html: Added.
     11
    1122016-06-19  Alexey Proskuryakov  <ap@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r202218 r202227  
     12016-06-19  Antti Koivisto  <antti@apple.com>
     2
     3        Updating class name of a shadow host does not update the style applied by :host()
     4        https://bugs.webkit.org/show_bug.cgi?id=158900
     5        <rdar://problem/26883707>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Test: fast/shadow-dom/shadow-host-style-update.html
     10
     11        Teach style invalidation optimization code about :host.
     12
     13        * style/AttributeChangeInvalidation.cpp:
     14        (WebCore::Style::mayBeAffectedByHostStyle):
     15        (WebCore::Style::AttributeChangeInvalidation::invalidateStyle):
     16        * style/ClassChangeInvalidation.cpp:
     17        (WebCore::Style::computeClassChange):
     18        (WebCore::Style::mayBeAffectedByHostStyle):
     19        (WebCore::Style::ClassChangeInvalidation::invalidateStyle):
     20        * style/IdChangeInvalidation.cpp:
     21        (WebCore::Style::mayBeAffectedByHostStyle):
     22        (WebCore::Style::IdChangeInvalidation::invalidateStyle):
     23
    1242016-06-19  Gavin & Ellie Barraclough  <barraclough@apple.com>
    225
  • trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp

    r196629 r202227  
    2929#include "DocumentRuleSets.h"
    3030#include "ElementIterator.h"
     31#include "ShadowRoot.h"
    3132#include "StyleInvalidationAnalysis.h"
    3233#include "StyleResolver.h"
     
    3435namespace WebCore {
    3536namespace Style {
     37
     38static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, bool isHTML, const QualifiedName& attributeName)
     39{
     40    auto& shadowRuleSets = shadowRoot.styleResolver().ruleSets();
     41    if (shadowRuleSets.authorStyle()->hostPseudoClassRules().isEmpty())
     42        return false;
     43
     44    auto& nameSet = isHTML ? shadowRuleSets.features().attributeCanonicalLocalNamesInRules : shadowRuleSets.features().attributeLocalNamesInRules;
     45    return nameSet.contains(attributeName.localName().impl());
     46}
    3647
    3748void AttributeChangeInvalidation::invalidateStyle(const QualifiedName& attributeName, const AtomicString& oldValue, const AtomicString& newValue)
     
    4455
    4556    auto& nameSet = isHTML ? ruleSets.features().attributeCanonicalLocalNamesInRules : ruleSets.features().attributeLocalNamesInRules;
    46     bool shouldInvalidate = nameSet.contains(attributeName.localName().impl());
    47     if (!shouldInvalidate)
     57    bool mayAffectStyle = nameSet.contains(attributeName.localName().impl());
     58
     59    auto* shadowRoot = m_element.shadowRoot();
     60    if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, isHTML, attributeName))
     61        mayAffectStyle = true;
     62
     63    if (!mayAffectStyle)
    4864        return;
    4965
  • trunk/Source/WebCore/style/ClassChangeInvalidation.cpp

    r202167 r202227  
    2929#include "DocumentRuleSets.h"
    3030#include "ElementChildIterator.h"
     31#include "ShadowRoot.h"
    3132#include "SpaceSplitString.h"
    3233#include "StyleInvalidationAnalysis.h"
     
    8586}
    8687
     88static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, AtomicStringImpl* changedClass)
     89{
     90    auto& shadowRuleSets = shadowRoot.styleResolver().ruleSets();
     91    if (shadowRuleSets.authorStyle()->hostPseudoClassRules().isEmpty())
     92        return false;
     93    return shadowRuleSets.features().classesInRules.contains(changedClass);
     94}
     95
    8796void ClassChangeInvalidation::invalidateStyle(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses)
    8897{
     
    9099
    91100    auto& ruleSets = m_element.styleResolver().ruleSets();
     101    auto* shadowRoot = m_element.shadowRoot();
    92102
    93103    ClassChangeVector changedClassesAffectingStyle;
    94104    for (auto* changedClass : changedClasses) {
    95         if (ruleSets.features().classesInRules.contains(changedClass))
     105        bool mayAffectStyle = ruleSets.features().classesInRules.contains(changedClass);
     106
     107        if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, changedClass))
     108            mayAffectStyle = true;
     109
     110        if (mayAffectStyle)
    96111            changedClassesAffectingStyle.append(changedClass);
    97112    };
     
    100115        return;
    101116
    102     if (m_element.shadowRoot() && ruleSets.authorStyle()->hasShadowPseudoElementRules()) {
     117    if (shadowRoot && ruleSets.authorStyle()->hasShadowPseudoElementRules()) {
    103118        m_element.setNeedsStyleRecalc(FullStyleChange);
    104119        return;
  • trunk/Source/WebCore/style/IdChangeInvalidation.cpp

    r196636 r202227  
    2929#include "DocumentRuleSets.h"
    3030#include "ElementChildIterator.h"
     31#include "ShadowRoot.h"
    3132#include "StyleResolver.h"
    3233
    3334namespace WebCore {
    3435namespace Style {
     36
     37static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, const AtomicString& changedId)
     38{
     39    auto& shadowRuleSets = shadowRoot.styleResolver().ruleSets();
     40    if (shadowRuleSets.authorStyle()->hostPseudoClassRules().isEmpty())
     41        return false;
     42
     43    return shadowRuleSets.features().idsInRules.contains(changedId.impl());
     44}
    3545
    3646void IdChangeInvalidation::invalidateStyle(const AtomicString& changedId)
     
    4252
    4353    bool mayAffectStyle = ruleSets.features().idsInRules.contains(changedId.impl());
     54
     55    auto* shadowRoot = m_element.shadowRoot();
     56    if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, changedId))
     57        mayAffectStyle = true;
     58
    4459    if (!mayAffectStyle)
    4560        return;
Note: See TracChangeset for help on using the changeset viewer.