Updating attributes on HTML elements do not invalidate the style correctly unless...
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Aug 2014 19:16:51 +0000 (19:16 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Aug 2014 19:16:51 +0000 (19:16 +0000)
commit72bc397d46f602d079746f976dfdf1f8b218af27
tree8b0f8b93246d83a723b5db43459de4bf870b3e84
parentf4ca29e7e5de51d7ade768cc367a90b0eacfcb68
Updating attributes on HTML elements do not invalidate the style correctly unless the attribute name is lowercase in the stylesheet
https://bugs.webkit.org/show_bug.cgi?id=136270
Source/WebCore:

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-08-27
Reviewed by Andreas Kling.

In HTML, WebKit treats every attribute name lowercase to implement case-insensitive matching.
When invalidating style, the StyleResolver was ignoring HTML and always using the XML names.

This patch split the names on RuleFeatureSet in two sets: one for XML, one for HTML.
In StyleResolver, the name used depends on the type of the element being updated.

This patch also adds nodeNeedsStyleRecalc() to Internals to test the optimization and various cases
of style update.

Tests: fast/css/attribute-for-content-property-style-update-html.html
       fast/css/attribute-for-content-property-style-update-xhtml.xhtml
       fast/css/attribute-style-invalidation-optimization-html.html
       fast/css/attribute-style-invalidation-optimization-xhtml.xhtml
       fast/css/attribute-style-update-html.html
       fast/selectors/attribute-style-update-html.html
       fast/selectors/attribute-style-update-svg-in-html.html
       fast/selectors/attribute-style-update-xhtml.xhtml

* css/RuleFeature.cpp:
(WebCore::RuleFeatureSet::collectFeaturesFromSelector):
(WebCore::RuleFeatureSet::add):
(WebCore::RuleFeatureSet::clear):
* css/RuleFeature.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
* css/StyleResolver.h:
(WebCore::StyleResolver::hasSelectorForAttribute):
* dom/Element.cpp:
(WebCore::Element::willModifyAttribute):
* testing/Internals.cpp:
(WebCore::Internals::address):
(WebCore::Internals::nodeNeedsStyleRecalc):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

rdar://problem/16190617

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-08-27
Reviewed by Andreas Kling.

The test coverage for attribute update was abysmal. This adds the basic cases for HTML and XML.

* fast/css/attribute-for-content-property-style-update-html-expected.html: Added.
* fast/css/attribute-for-content-property-style-update-html.html: Added.
* fast/css/attribute-for-content-property-style-update-xhtml-expected.html: Added.
* fast/css/attribute-for-content-property-style-update-xhtml.xhtml: Added.
* fast/css/attribute-style-invalidation-optimization-html-expected.txt: Added.
* fast/css/attribute-style-invalidation-optimization-html.html: Added.
* fast/css/attribute-style-invalidation-optimization-xhtml-expected.txt: Added.
* fast/css/attribute-style-invalidation-optimization-xhtml.xhtml: Added.
* fast/css/attribute-style-update-html-expected.html: Added.
* fast/css/attribute-style-update-html.html: Added.
* fast/selectors/attribute-style-update-html-expected.txt: Added.
* fast/selectors/attribute-style-update-html.html: Added.
* fast/selectors/attribute-style-update-svg-in-html-expected.txt: Added.
* fast/selectors/attribute-style-update-svg-in-html.html: Added.
* fast/selectors/attribute-style-update-xhtml-expected.txt: Added.
* fast/selectors/attribute-style-update-xhtml.xhtml: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173012 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/attribute-for-content-property-style-update-html-expected.html [new file with mode: 0644]
LayoutTests/fast/css/attribute-for-content-property-style-update-html.html [new file with mode: 0644]
LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml-expected.html [new file with mode: 0644]
LayoutTests/fast/css/attribute-for-content-property-style-update-xhtml.xhtml [new file with mode: 0644]
LayoutTests/fast/css/attribute-style-invalidation-optimization-html-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/attribute-style-invalidation-optimization-html.html [new file with mode: 0644]
LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/attribute-style-invalidation-optimization-xhtml.xhtml [new file with mode: 0644]
LayoutTests/fast/css/attribute-style-update-html-expected.html [new file with mode: 0644]
LayoutTests/fast/css/attribute-style-update-html.html [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-style-update-html-expected.txt [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-style-update-html.html [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-style-update-svg-in-html-expected.txt [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-style-update-svg-in-html.html [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-style-update-xhtml-expected.txt [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-style-update-xhtml.xhtml [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/RuleFeature.cpp
Source/WebCore/css/RuleFeature.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/dom/Element.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl