Skip to content

Commit

Permalink
imported/w3c/web-platform-tests/css/css-nesting/cssom.html is failing…
Browse files Browse the repository at this point in the history
… in WebKit

https://bugs.webkit.org/show_bug.cgi?id=262459

Reviewed by Ryosuke Niwa.

We have an optimization in CharacterData::setData() that avoids doing some work
when the JS cannot observe it. This optimization was breaking the test.

The test sets the innerHTML of a <style> element, which ends up calling setData()
on the child Text node (as an optimization) and then takes the optimized code
path in CharacterData::setData(). The optimized code path fails to notify the
ancestors that the text has changed. However, HTMLStyleElement::childrenChanged()
has code that needs to run in such case.

As a result, I am now disabling the optimization in CharacterData::setData() if
the parent node is an HTMLStyleElement.

* LayoutTests/imported/w3c/web-platform-tests/css/css-nesting/cssom-expected.txt:
* Source/WebCore/dom/CharacterData.cpp:
(WebCore::canUseSetDataOptimization):

Canonical link: https://commits.webkit.org/268707@main
  • Loading branch information
cdumez committed Oct 1, 2023
1 parent 52d5e29 commit 060f71c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PASS Simple CSSOM manipulation of subrules 5
PASS Simple CSSOM manipulation of subrules 6
PASS Simple CSSOM manipulation of subrules 7
PASS Simple CSSOM manipulation of subrules 8
FAIL Simple CSSOM manipulation of subrules 9 assert_equals: selectorText and insertRule expected ".a {\n color: red;\n div & { }\n div.b .c & { color: green; }\n .c div.b &, div & { color: blue; }\n}" but got ".a {\n color: olivedrab;\n div & { }\n div.b .c & { color: green; }\n .c div.b &, div & { color: blue; }\n}"
PASS Simple CSSOM manipulation of subrules 9
PASS Simple CSSOM manipulation of subrules 10
PASS Mutating the selectorText of outer rule invalidates inner rules

3 changes: 2 additions & 1 deletion Source/WebCore/dom/CharacterData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ElementTraversal.h"
#include "EventNames.h"
#include "FrameSelection.h"
#include "HTMLStyleElement.h"
#include "InspectorInstrumentation.h"
#include "MutationEvent.h"
#include "MutationObserverInterestGroup.h"
Expand All @@ -50,7 +51,7 @@ static bool canUseSetDataOptimization(const CharacterData& node)
{
auto& document = node.document();
return !document.hasListenerType(Document::ListenerType::DOMCharacterDataModified) && !document.hasMutationObserversOfType(MutationObserverOptionType::CharacterData)
&& !document.hasListenerType(Document::ListenerType::DOMSubtreeModified);
&& !document.hasListenerType(Document::ListenerType::DOMSubtreeModified) && !is<HTMLStyleElement>(node.parentNode());
}

void CharacterData::setData(const String& data)
Expand Down

0 comments on commit 060f71c

Please sign in to comment.