removeAttribute('style') not working in certain circumstances
authortasak@google.com <tasak@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2012 11:33:07 +0000 (11:33 +0000)
committertasak@google.com <tasak@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2012 11:33:07 +0000 (11:33 +0000)
commit5d471855947719b1ba29f06263c71792ab6a1330
treecfdbde99d3c610f60f6bf47e8bceed4d575dff00
parent0bcefaa42afe73612a08f5525049d85e3bfa2f9b
removeAttribute('style') not working in certain circumstances
https://bugs.webkit.org/show_bug.cgi?id=99295

Reviewed by Ryosuke Niwa.

Source/WebCore:

After web developers did style.XXXX=YYYY for some element, the inline
style should be always removable by using "removeAttribute('style')".
Currently it depends on whether web developers invokes
getAttribute('style'), setAttribute('style), and so on. E.g. once they
invoke getAttribute('style'), removeAttribute('style') works. This is
very confusing behavior.
Looking at Firefox browser, removeAttribute('style') always removes
all inline styles.

Test: fast/css/remove-attribute-style.html

* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::clear):
Added a new method to remove all style properties.
(WebCore):
* css/StylePropertySet.h:
(StylePropertySet):
* dom/Element.cpp:
(WebCore::Element::removeAttribute):
If 'style' is given but the element has no style attribute, the old
code did nothing. However, if the element is styled element and has any
inline styles, the inline styles should be removed. So invoke
StyledElement::removeAllInlineStyleProperties and if any inline styles
are removed, invoke style recalc, too.
* dom/StyledElement.cpp:
(WebCore::StyledElement::removeAllInlineStyleProperties):
Added a new method to remove all inline style propeties. If any inline
style is removed, invoke inlineStyleChanged() to force style recalc.
(WebCore):
* dom/StyledElement.h:
(StyledElement):

LayoutTests:

* fast/css/remove-attribute-style-expected.txt: Added.
* fast/css/remove-attribute-style.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@133581 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css/remove-attribute-style-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/remove-attribute-style.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/StylePropertySet.cpp
Source/WebCore/css/StylePropertySet.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/StyledElement.cpp
Source/WebCore/dom/StyledElement.h