diff options
author | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2012-10-11 12:52:34 +0000 |
---|---|---|
committer | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2012-10-11 12:52:34 +0000 |
commit | df53e96c81594b2123ca83848d4a388b1af7aa46 (patch) | |
tree | 9cb627c55ceaee9e4b96df3a3d00b7ea7160b81c /third_party/WebKit | |
parent | 0e91e0f56eccb3dc31a71688a7c22c260c450c88 (diff) | |
download | chromium_src-df53e96c81594b2123ca83848d4a388b1af7aa46.zip chromium_src-df53e96c81594b2123ca83848d4a388b1af7aa46.tar.gz chromium_src-df53e96c81594b2123ca83848d4a388b1af7aa46.tar.bz2 |
REGRESSION (r96393): In some cases, generated content is never shown
https://bugs.webkit.org/show_bug.cgi?id=88196
Patch by Arpita Bahuguna <arpitabahuguna@gmail.com> on 2012-10-11
Reviewed by Antti Koivisto.
Source/WebCore:
Elements with style specified from an attribute selector in conjunction
with a pseudo-element should not take on the shared style of their
previous matching sibling (if any).
The problem here is that an attribute selector appended by a pseudo-element
does not return any matched rules for the call (matchesRuleSet(m_uncommonAttributeRuleSet.get()))
in StyleResolver::locateSharedStyle().
This is because of the way pseudo-elements are handled in
SelectorChecker::checkSelector(). For a pseudo-element selector we check
for the condition (!context.elementStyle && m_mode == ResolvingStyle) and
since for this particular flow the SelectorChecker mode is set to ResolvingStyle
and since the current element's style is still not available we fail this
initial check and return SelectorFailsLocally from checkSelector(). This is
incorrect behavior since the element does have an attribute selector specified
for it.
Have thus introduced another enum value: SharingRules for SelectorChecker's Mode.
SelectorChecker's mode should be set to SharingRules before making the
call to collectMatchingRules() and then reset (back to ResolvingStyle) thereafter.
Existing Mode value: CollectingRules although appropriate cannot be used in this
scenario because we also don't want to set any value to dynamicPseudo for this flow.
Test: fast/selectors/style-sharing-attribute-selector-with-pseudo-element.html
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkSelector):
Added additional check for SelectorChecker's mode: SharingRules when
trying to match for the pseudo-element selector.
* css/SelectorChecker.h:
Added SharingRules to Mode enum.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet):
(WebCore::StyleResolver::locateSharedStyle):
* css/StyleResolver.h:
(StyleResolver):
Renamed matchesRuleSet() to a more descriptive styleSharingCandidateMatchesRuleSet().
Also, setting the SelectorChecker's mode to SharingRules before calling
on collectMatchingRules() from styleSharingCandidateMatchesRuleSet().
LayoutTests:
* fast/selectors/style-sharing-attribute-selector-with-pseudo-element-expected.html: Added.
* fast/selectors/style-sharing-attribute-selector-with-pseudo-element.html: Added.
Ref test added for verifying that the attribute selector style, when specified
in conjucntion with pseudo-elements, is applied to the corresponding element.
git-svn-id: svn://svn.chromium.org/blink/trunk@131047 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit')
8 files changed, 100 insertions, 7 deletions
diff --git a/third_party/WebKit/LayoutTests/ChangeLog b/third_party/WebKit/LayoutTests/ChangeLog index 8c07128..04e96b6 100644 --- a/third_party/WebKit/LayoutTests/ChangeLog +++ b/third_party/WebKit/LayoutTests/ChangeLog @@ -1,3 +1,15 @@ +2012-10-11 Arpita Bahuguna <arpitabahuguna@gmail.com> + + REGRESSION (r96393): In some cases, generated content is never shown + https://bugs.webkit.org/show_bug.cgi?id=88196 + + Reviewed by Antti Koivisto. + + * fast/selectors/style-sharing-attribute-selector-with-pseudo-element-expected.html: Added. + * fast/selectors/style-sharing-attribute-selector-with-pseudo-element.html: Added. + Ref test added for verifying that the attribute selector style, when specified + in conjucntion with pseudo-elements, is applied to the corresponding element. + 2012-10-11 Shinya Kawanaka <shinyak@chromium.org> Some shadow roots are not showing up in Inspector. diff --git a/third_party/WebKit/LayoutTests/fast/selectors/style-sharing-attribute-selector-with-pseudo-element-expected.html b/third_party/WebKit/LayoutTests/fast/selectors/style-sharing-attribute-selector-with-pseudo-element-expected.html new file mode 100644 index 0000000..34794c3 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/selectors/style-sharing-attribute-selector-with-pseudo-element-expected.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html> +<body> +<div>Test for Bugzilla <a href="https://bugs.webkit.org/show_bug.cgi?id=88196">Bug 88196</a>: REGRESSION (r96393): In some cases, generated content is never shown</div> +<div>Elements with style specified from attribute selectors in conjunction with pseudo-elements should not take on the shared style of their previous matching sibling (if any).</div> +<p>First paragraph.</p> +<p>Second paragraph with :before and :after content.</p> +</body> +</html> + diff --git a/third_party/WebKit/LayoutTests/fast/selectors/style-sharing-attribute-selector-with-pseudo-element.html b/third_party/WebKit/LayoutTests/fast/selectors/style-sharing-attribute-selector-with-pseudo-element.html new file mode 100644 index 0000000..556005a --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/selectors/style-sharing-attribute-selector-with-pseudo-element.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<head> +<style> +[myatt]:after { + content: attr(myatt); +} +[myatt]:before { + content: 'Second paragraph'; +} +</style> +</head> +<body> +<div>Test for Bugzilla <a href="https://bugs.webkit.org/show_bug.cgi?id=88196">Bug 88196</a>: REGRESSION (r96393): In some cases, generated content is never shown</div> +<div>Elements with style specified from attribute selectors in conjunction with pseudo-elements should not take on the shared style of their previous matching sibling (if any).</div> +<p>First paragraph.</p> +<p myatt=":before and :after content."> with </p> +</body> +</html> + diff --git a/third_party/WebKit/Source/WebCore/ChangeLog b/third_party/WebKit/Source/WebCore/ChangeLog index c1414cb..22b60ba 100644 --- a/third_party/WebKit/Source/WebCore/ChangeLog +++ b/third_party/WebKit/Source/WebCore/ChangeLog @@ -1,3 +1,53 @@ +2012-10-11 Arpita Bahuguna <arpitabahuguna@gmail.com> + + REGRESSION (r96393): In some cases, generated content is never shown + https://bugs.webkit.org/show_bug.cgi?id=88196 + + Reviewed by Antti Koivisto. + + Elements with style specified from an attribute selector in conjunction + with a pseudo-element should not take on the shared style of their + previous matching sibling (if any). + + The problem here is that an attribute selector appended by a pseudo-element + does not return any matched rules for the call (matchesRuleSet(m_uncommonAttributeRuleSet.get())) + in StyleResolver::locateSharedStyle(). + + This is because of the way pseudo-elements are handled in + SelectorChecker::checkSelector(). For a pseudo-element selector we check + for the condition (!context.elementStyle && m_mode == ResolvingStyle) and + since for this particular flow the SelectorChecker mode is set to ResolvingStyle + and since the current element's style is still not available we fail this + initial check and return SelectorFailsLocally from checkSelector(). This is + incorrect behavior since the element does have an attribute selector specified + for it. + + Have thus introduced another enum value: SharingRules for SelectorChecker's Mode. + SelectorChecker's mode should be set to SharingRules before making the + call to collectMatchingRules() and then reset (back to ResolvingStyle) thereafter. + + Existing Mode value: CollectingRules although appropriate cannot be used in this + scenario because we also don't want to set any value to dynamicPseudo for this flow. + + Test: fast/selectors/style-sharing-attribute-selector-with-pseudo-element.html + + * css/SelectorChecker.cpp: + (WebCore::SelectorChecker::checkSelector): + Added additional check for SelectorChecker's mode: SharingRules when + trying to match for the pseudo-element selector. + + * css/SelectorChecker.h: + Added SharingRules to Mode enum. + + * css/StyleResolver.cpp: + (WebCore::StyleResolver::styleSharingCandidateMatchesRuleSet): + (WebCore::StyleResolver::locateSharedStyle): + * css/StyleResolver.h: + (StyleResolver): + Renamed matchesRuleSet() to a more descriptive styleSharingCandidateMatchesRuleSet(). + Also, setting the SelectorChecker's mode to SharingRules before calling + on collectMatchingRules() from styleSharingCandidateMatchesRuleSet(). + 2012-10-11 Shinya Kawanaka <shinyak@chromium.org> Some shadow roots are not showing up in Inspector. diff --git a/third_party/WebKit/Source/WebCore/css/SelectorChecker.cpp b/third_party/WebKit/Source/WebCore/css/SelectorChecker.cpp index acd4b0a..d1b9c98 100644 --- a/third_party/WebKit/Source/WebCore/css/SelectorChecker.cpp +++ b/third_party/WebKit/Source/WebCore/css/SelectorChecker.cpp @@ -459,7 +459,7 @@ SelectorChecker::SelectorMatch SelectorChecker::checkSelector(const SelectorChec if (Document* document = context.element->document()) document->styleSheetCollection()->setUsesFirstLetterRules(true); } - if (pseudoId != NOPSEUDO) + if (pseudoId != NOPSEUDO && m_mode != SharingRules) dynamicPseudo = pseudoId; } } diff --git a/third_party/WebKit/Source/WebCore/css/SelectorChecker.h b/third_party/WebKit/Source/WebCore/css/SelectorChecker.h index cd2cb4c..ef140f3 100644 --- a/third_party/WebKit/Source/WebCore/css/SelectorChecker.h +++ b/third_party/WebKit/Source/WebCore/css/SelectorChecker.h @@ -52,7 +52,7 @@ public: enum SelectorMatch { SelectorMatches, SelectorFailsLocally, SelectorFailsAllSiblings, SelectorFailsCompletely }; enum VisitedMatchType { VisitedMatchDisabled, VisitedMatchEnabled }; - enum Mode { ResolvingStyle = 0, CollectingRules, QueryingRules }; + enum Mode { ResolvingStyle = 0, CollectingRules, QueryingRules, SharingRules }; struct SelectorCheckingContext { // Initial selector constructor diff --git a/third_party/WebKit/Source/WebCore/css/StyleResolver.cpp b/third_party/WebKit/Source/WebCore/css/StyleResolver.cpp index 669681c..656d5b5 100644 --- a/third_party/WebKit/Source/WebCore/css/StyleResolver.cpp +++ b/third_party/WebKit/Source/WebCore/css/StyleResolver.cpp @@ -1035,15 +1035,16 @@ Node* StyleResolver::locateCousinList(Element* parent, unsigned& visitedNodeCoun return 0; } -bool StyleResolver::matchesRuleSet(RuleSet* ruleSet) +bool StyleResolver::styleSharingCandidateMatchesRuleSet(RuleSet* ruleSet) { if (!ruleSet) return false; m_matchedRules.clear(); int firstRuleIndex = -1, lastRuleIndex = -1; + m_checker.setMode(SelectorChecker::SharingRules); collectMatchingRules(ruleSet, firstRuleIndex, lastRuleIndex, false); - + m_checker.setMode(SelectorChecker::ResolvingStyle); if (m_matchedRules.isEmpty()) return false; m_matchedRules.clear(); @@ -1307,10 +1308,10 @@ RenderStyle* StyleResolver::locateSharedStyle() return 0; // Can't share if sibling rules apply. This is checked at the end as it should rarely fail. - if (matchesRuleSet(m_siblingRuleSet.get())) + if (styleSharingCandidateMatchesRuleSet(m_siblingRuleSet.get())) return 0; // Can't share if attribute rules apply. - if (matchesRuleSet(m_uncommonAttributeRuleSet.get())) + if (styleSharingCandidateMatchesRuleSet(m_uncommonAttributeRuleSet.get())) return 0; // Tracking child index requires unique style for each node. This may get set by the sibling rule match above. if (parentStylePreventsSharing(m_parentStyle)) diff --git a/third_party/WebKit/Source/WebCore/css/StyleResolver.h b/third_party/WebKit/Source/WebCore/css/StyleResolver.h index 6b13623..12098aa 100644 --- a/third_party/WebKit/Source/WebCore/css/StyleResolver.h +++ b/third_party/WebKit/Source/WebCore/css/StyleResolver.h @@ -173,7 +173,7 @@ private: void initElement(Element*); void collectFeatures(); RenderStyle* locateSharedStyle(); - bool matchesRuleSet(RuleSet*); + bool styleSharingCandidateMatchesRuleSet(RuleSet*); Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const; StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const; bool canShareStyleWithElement(StyledElement*) const; |