Changeset 84517 in webkit


Ignore:
Timestamp:
Apr 21, 2011 10:37:47 AM (13 years ago)
Author:
Dimitri Glazkov
Message:

2011-04-20 Dimitri Glazkov <Dimitri Glazkov>

Reviewed by Kent Tamura.

REGRESSION (r75543): Styles bleed into new shadow DOM (like slider and video)
https://bugs.webkit.org/show_bug.cgi?id=52917

  • fast/css/shadow-dom-scope-expected.txt: Added.
  • fast/css/shadow-dom-scope.html: Added.

2011-04-20 Dimitri Glazkov <Dimitri Glazkov>

Reviewed by Kent Tamura.

REGRESSION (r75543): Styles bleed into new shadow DOM (like slider and video)
https://bugs.webkit.org/show_bug.cgi?id=52917

In order to determine whether a rule should apply inside of a shadow DOM subtree,
we collect three pieces of information:

1) Are we parsing UA sheets?
2) Does the current tree scope allows applying author sheets?
3) Does the rule explicitly reach into shadow DOM (using pseudo-elements, for example)?

If the answer to all of these is no, we ignore the rule.

Test: fast/css/shadow-dom-scope.html

  • css/CSSStyleSelector.cpp: (WebCore::MatchingUARulesScope::MatchingUARulesScope): Added a scope helper to

track whether we are currently matching UA rules.

(WebCore::CSSStyleSelector::matchRulesForList): Added the check for three

conditions mentioned above.

(WebCore::CSSStyleSelector::SelectorChecker::SelectorChecker): Added

initializer for the flag, which helps us determine whether the rule
explicitly reaches into shadow DOM.

(WebCore::CSSStyleSelector::matchUARules): Started using the scope helper.
(WebCore::CSSStyleSelector::checkSelector): Added initializing of the

flag.

(WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): Added setting

of the flag when we encounter unknown pseudo-elements.

  • css/CSSStyleSelector.h: Adjusted decls.
  • dom/ShadowRoot.cpp: (WebCore::ShadowRoot::applyAuthorSheets): Added.
  • dom/ShadowRoot.h: Adjusted decls.
  • dom/TreeScope.cpp: (WebCore::TreeScope::applyAuthorSheets): Added.
  • dom/TreeScope.h: Adjusted decls.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r84516 r84517  
     12011-04-20  Dimitri Glazkov  <dglazkov@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        REGRESSION (r75543): Styles bleed into new shadow DOM (like slider and video)
     6        https://bugs.webkit.org/show_bug.cgi?id=52917
     7
     8        * fast/css/shadow-dom-scope-expected.txt: Added.
     9        * fast/css/shadow-dom-scope.html: Added.
     10
    1112011-04-21  Levi Weintraub  <leviw@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r84516 r84517  
     12011-04-20  Dimitri Glazkov  <dglazkov@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        REGRESSION (r75543): Styles bleed into new shadow DOM (like slider and video)
     6        https://bugs.webkit.org/show_bug.cgi?id=52917
     7
     8        In order to determine whether a rule should apply inside of a shadow DOM subtree,
     9        we collect three pieces of information:
     10
     11        1) Are we parsing UA sheets?
     12        2) Does the current tree scope allows applying author sheets?
     13        3) Does the rule explicitly reach into shadow DOM (using pseudo-elements, for example)?
     14
     15        If the answer to all of these is no, we ignore the rule.
     16
     17        Test: fast/css/shadow-dom-scope.html
     18
     19        * css/CSSStyleSelector.cpp:
     20        (WebCore::MatchingUARulesScope::MatchingUARulesScope): Added a scope helper to
     21            track whether we are currently matching UA rules.
     22        (WebCore::CSSStyleSelector::matchRulesForList): Added the check for three
     23            conditions mentioned above.
     24        (WebCore::CSSStyleSelector::SelectorChecker::SelectorChecker): Added
     25            initializer for the flag, which helps us determine whether the rule
     26            explicitly reaches into shadow DOM.
     27        (WebCore::CSSStyleSelector::matchUARules): Started using the scope helper.
     28        (WebCore::CSSStyleSelector::checkSelector): Added initializing of the
     29            flag.
     30        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): Added setting
     31            of the flag when we encounter unknown pseudo-elements.
     32        * css/CSSStyleSelector.h: Adjusted decls.
     33        * dom/ShadowRoot.cpp:
     34        (WebCore::ShadowRoot::applyAuthorSheets): Added.
     35        * dom/ShadowRoot.h: Adjusted decls.
     36        * dom/TreeScope.cpp:
     37        (WebCore::TreeScope::applyAuthorSheets): Added.
     38        * dom/TreeScope.h: Adjusted decls.
     39
    1402011-04-21  Levi Weintraub  <leviw@chromium.org>
    241
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r84380 r84517  
    747747}
    748748
     749class MatchingUARulesScope {
     750public:
     751    MatchingUARulesScope();
     752    ~MatchingUARulesScope();
     753
     754    static bool isMatchingUARules();
     755
     756private:
     757    static bool m_matchingUARules;
     758};
     759
     760MatchingUARulesScope::MatchingUARulesScope()
     761{
     762    ASSERT(!m_matchingUARules);
     763    m_matchingUARules = true;
     764}
     765
     766MatchingUARulesScope::~MatchingUARulesScope()
     767{
     768    m_matchingUARules = false;
     769}
     770
     771inline bool MatchingUARulesScope::isMatchingUARules()
     772{
     773    return m_matchingUARules;
     774}
     775
     776bool MatchingUARulesScope::m_matchingUARules = false;
     777
     778inline static bool matchesInTreeScope(TreeScope* treeScope, bool ruleReachesIntoShadowDOM)
     779{
     780    return MatchingUARulesScope::isMatchingUARules() || treeScope->applyAuthorSheets() || ruleReachesIntoShadowDOM;
     781}
     782
    749783void CSSStyleSelector::matchRulesForList(const Vector<RuleData>* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)
    750784{
     
    761795            continue;
    762796        if (checkSelector(ruleData)) {
     797            if (!matchesInTreeScope(m_element->treeScope(), m_checker.m_hasUnknownPseudoElements))
     798                continue;
    763799            // If the rule has no properties to apply, then ignore it in the non-debug mode.
    764800            CSSStyleRule* rule = ruleData.rule();
     
    882918    , m_pseudoStyle(NOPSEUDO)
    883919    , m_documentIsHTML(document->isHTMLDocument())
     920    , m_hasUnknownPseudoElements(false)
    884921    , m_matchVisitedPseudoClass(false)
    885922{
     
    11691206void CSSStyleSelector::matchUARules(int& firstUARule, int& lastUARule)
    11701207{
     1208    MatchingUARulesScope scope;
     1209
    11711210    // First we match rules from the user agent sheet.
    11721211    RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print")
     
    20422081{
    20432082    m_dynamicPseudo = NOPSEUDO;
     2083    m_checker.m_hasUnknownPseudoElements = false;
    20442084
    20452085    // Let the slow path handle SVG as it has some additional rules regarding shadow trees.
     
    29392979        if (!elementStyle && !m_collectRulesOnly)
    29402980            return false;
     2981
     2982        if (sel->isUnknownPseudoElement())
     2983            m_hasUnknownPseudoElements = true;
    29412984
    29422985        PseudoId pseudoId = CSSSelector::pseudoId(sel->pseudoType());
  • trunk/Source/WebCore/css/CSSStyleSelector.h

    r83241 r84517  
    276276            PseudoId m_pseudoStyle;
    277277            bool m_documentIsHTML;
     278            mutable bool m_hasUnknownPseudoElements;
    278279            mutable bool m_matchVisitedPseudoClass;
    279280            mutable HashSet<LinkHash, LinkHashHash> m_linksCheckedForVisitedState;
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r84511 r84517  
    122122}
    123123
     124bool ShadowRoot::applyAuthorSheets() const
     125{
     126    return false;
    124127}
     128
     129}
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r84511 r84517  
    5252    virtual PassRefPtr<Node> cloneNode(bool deep);
    5353    virtual bool childTypeAllowed(NodeType) const;
     54    virtual bool applyAuthorSheets() const;
    5455
    5556    ContainerNode* firstContentElement() const;
  • trunk/Source/WebCore/dom/TreeScope.cpp

    r84394 r84517  
    159159}
    160160
     161bool TreeScope::applyAuthorSheets() const
     162{
     163    return true;
     164}
     165
    161166} // namespace WebCore
    162167
  • trunk/Source/WebCore/dom/TreeScope.h

    r84394 r84517  
    6666    Element* findAnchor(const String& name);
    6767
     68    virtual bool applyAuthorSheets() const;
     69
    6870protected:
    6971    TreeScope(Document*);
Note: See TracChangeset for help on using the changeset viewer.