Copy and paste can strip !important CSS rules due to a bug in mergeStyleFromRules
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Apr 2013 04:51:28 +0000 (04:51 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Apr 2013 04:51:28 +0000 (04:51 +0000)
commit6fb472bb57d68a1dff81ae77d7694daf496f4a83
treefa5d500a8d9f1e1a5286bd3c2e739667e5c2b810
parent87d1c481ef71ef99861e721292094bf0d23d1b04
Copy and paste can strip !important CSS rules due to a bug in mergeStyleFromRules
https://bugs.webkit.org/show_bug.cgi?id=115217

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by mergeStyleFromRules overriding "important" style rules with "unimportant" inline styles.
Fixed the bug by using addParsedProperty, which respects !important, in MutableStylePropertySet's
mergeAndOverrideOnConflict, which was only used in editing code. Now that we've fixed this function, we can use
it in ViewportStyleResolver::addViewportRule as well.

Test: editing/pasteboard/copy-paste-with-important-rules.html

* css/StylePropertySet.cpp:
(WebCore::MutableStylePropertySet::mergeAndOverrideOnConflict): Fixed to respect !important.
* css/ViewportStyleResolver.cpp:
(WebCore::ViewportStyleResolver::addViewportRule): Use mergeAndOverrideOnConflict now that the code is identical.

LayoutTests:

Added a regression test.

* editing/pasteboard/copy-paste-with-important-rules-expected.txt: Added.
* editing/pasteboard/copy-paste-with-important-rules.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149167 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/copy-paste-with-important-rules-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/copy-paste-with-important-rules.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/StylePropertySet.cpp
Source/WebCore/css/ViewportStyleResolver.cpp