Title: [196575] trunk
Revision
196575
Author
[email protected]
Date
2016-02-15 02:30:36 -0800 (Mon, 15 Feb 2016)

Log Message

Add test for class change style invalidation optimization
https://bugs.webkit.org/show_bug.cgi?id=154226

Reviewed by Myles Maxfield.

Test for https://trac.webkit.org/r196383

Source/WebCore:

Add internals.styleChangeType function.

Test: fast/css/style-invalidation-class-change-descendants.html

* testing/Internals.cpp:
(WebCore::Internals::nodeNeedsStyleRecalc):
(WebCore::asString):
(WebCore::Internals::styleChangeType):
(WebCore::Internals::description):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* fast/css/style-invalidation-class-change-descendants-expected.txt: Added.
* fast/css/style-invalidation-class-change-descendants.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (196574 => 196575)


--- trunk/LayoutTests/ChangeLog	2016-02-15 09:50:29 UTC (rev 196574)
+++ trunk/LayoutTests/ChangeLog	2016-02-15 10:30:36 UTC (rev 196575)
@@ -1,3 +1,15 @@
+2016-02-14  Antti Koivisto  <[email protected]>
+
+        Add test for class change style invalidation optimization
+        https://bugs.webkit.org/show_bug.cgi?id=154226
+
+        Reviewed by Myles Maxfield.
+
+        Test for https://trac.webkit.org/r196383
+
+        * fast/css/style-invalidation-class-change-descendants-expected.txt: Added.
+        * fast/css/style-invalidation-class-change-descendants.html: Added.
+
 2016-02-15  Hunseop Jeong  <[email protected]>
 
         Unreviewed. EFL gardening. Mark more video tests to failure.

Added: trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants-expected.txt (0 => 196575)


--- trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants-expected.txt	2016-02-15 10:30:36 UTC (rev 196575)
@@ -0,0 +1,57 @@
+Test that we invalidate the element subtree minimally on class attribute change
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS hasExpectedStyle is true
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "NoStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+PASS hasExpectedStyle is true
+Adding class NotThere
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "NoStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+Adding class style1
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "InlineStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+PASS hasExpectedStyle is true
+Adding class style2
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "InlineStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+PASS hasExpectedStyle is true
+Removing class style2
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "InlineStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+PASS hasExpectedStyle is true
+Adding class style3
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "InlineStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+PASS hasExpectedStyle is true
+Removing class style3
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "InlineStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+PASS hasExpectedStyle is true
+Adding class style4
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "NoStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+PASS hasExpectedStyle is true
+Removing class NotThere
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "NoStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+Removing class style1
+PASS testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange") is true
+PASS testStyleChangeType("target", "InlineStyleChange") is true
+PASS testStyleChangeType("inert", "NoStyleChange") is true
+PASS hasExpectedStyle is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants.html (0 => 196575)


--- trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/style-invalidation-class-change-descendants.html	2016-02-15 10:30:36 UTC (rev 196575)
@@ -0,0 +1,148 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+* {
+    color: black;
+}
+root.style1 target {
+    color: rgb(1, 1, 1);
+}
+
+root.style2 > inert target {
+    color: rgb(2, 2, 2);
+}
+
+root.style3 inert + target {
+    color: rgb(3, 3, 3);
+}
+
+root.style4 > target inert {
+    color: rgb(4, 4, 4);
+}
+
+</style>
+</head>
+<body>
+    <root>
+        <!-- With renderer -->
+        <inert>
+            <inert>
+                <inert></inert>
+                <target>
+                    <inert></inert>
+                    <target></target>
+                </target>
+            </inert>
+            <target></target>
+            <inert></inert>
+        </inert>
+    </root>
+    <root style="display:none;">
+        <!-- Without renderer -->
+        <inert>
+            <inert>
+                <inert></inert>
+                <target>
+                    <inert></inert>
+                    <target></target>
+                </target>
+            </inert>
+            <target></target>
+            <inert></inert>
+        </inert>
+    </root>
+</body>
+<script>
+
+description('Test that we invalidate the element subtree minimally on class attribute change');
+
+function testStyleChangeType(tag, type)
+{
+    var elements = document.querySelectorAll(tag);
+    for (var i = 0; i < elements.length; ++i) {
+        if (window.internals.styleChangeType(elements[i]) != type)
+            return false;
+    }
+    return true;
+}
+
+function testStyleInvalidation(expectedDescendantStyleChange) {
+    // Ideally we would't invalidate the root at all.
+    shouldBeTrue('testStyleChangeType("root", "NoStyleChange") || testStyleChangeType("root", "InlineStyleChange")');
+
+    shouldBeTrue('testStyleChangeType("target", "' + expectedDescendantStyleChange +'")');
+
+    shouldBeTrue('testStyleChangeType("inert", "NoStyleChange")');
+}
+
+function addClass(name) {
+    debug("Adding class " + name);
+    var allRoots = document.querySelectorAll("root");
+    allRoots[0].classList.add(name);
+    allRoots[1].classList.add(name);
+}
+
+function removeClass(name) {
+    debug("Removing class " + name);
+    var allRoots = document.querySelectorAll("root");
+    allRoots[0].classList.remove(name);
+    allRoots[1].classList.remove(name);
+}
+
+function checkStyle(n) {
+    document.documentElement.offsetTop;
+
+    hasExpectedStyle = true;
+    expectedColor = 'rgb('+n+', '+n+', '+n+')';
+    var targets = document.querySelectorAll("target");
+    for (var i = 0; i < targets.length; ++i) {
+        hasExpectedStyle = getComputedStyle(targets[i]).color == expectedColor;
+        if (!hasExpectedStyle)
+            break;
+    }
+    shouldBeTrue("hasExpectedStyle");
+}
+
+checkStyle(0);
+testStyleInvalidation("NoStyleChange");
+checkStyle(0);
+
+addClass('NotThere');
+testStyleInvalidation("NoStyleChange");
+
+addClass('style1');
+testStyleInvalidation("InlineStyleChange");
+checkStyle(1);
+
+addClass('style2');
+testStyleInvalidation("InlineStyleChange");
+checkStyle(2);
+
+removeClass('style2');
+testStyleInvalidation("InlineStyleChange");
+checkStyle(1);
+
+addClass('style3');
+testStyleInvalidation("InlineStyleChange");
+checkStyle(3);
+
+removeClass('style3');
+testStyleInvalidation("InlineStyleChange");
+checkStyle(1);
+
+addClass('style4');
+testStyleInvalidation("NoStyleChange");
+checkStyle(1);
+
+removeClass('NotThere');
+testStyleInvalidation("NoStyleChange");
+
+removeClass('style1');
+testStyleInvalidation("InlineStyleChange");
+checkStyle(0);
+
+</script>
+<script src=""
+</html>

Modified: trunk/Source/WebCore/ChangeLog (196574 => 196575)


--- trunk/Source/WebCore/ChangeLog	2016-02-15 09:50:29 UTC (rev 196574)
+++ trunk/Source/WebCore/ChangeLog	2016-02-15 10:30:36 UTC (rev 196575)
@@ -1,3 +1,24 @@
+2016-02-14  Antti Koivisto  <[email protected]>
+
+        Add test for class change style invalidation optimization
+        https://bugs.webkit.org/show_bug.cgi?id=154226
+
+        Reviewed by Myles Maxfield.
+
+        Test for https://trac.webkit.org/r196383
+
+        Add internals.styleChangeType function.
+
+        Test: fast/css/style-invalidation-class-change-descendants.html
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::nodeNeedsStyleRecalc):
+        (WebCore::asString):
+        (WebCore::Internals::styleChangeType):
+        (WebCore::Internals::description):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2016-02-14  Simon Fraser  <[email protected]>
 
         [CSS Filters] When applying an SVG filter on a composited image using CSS the image is rendered without the filter

Modified: trunk/Source/WebCore/testing/Internals.cpp (196574 => 196575)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-02-15 09:50:29 UTC (rev 196574)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-02-15 10:30:36 UTC (rev 196575)
@@ -464,6 +464,34 @@
     return node->needsStyleRecalc();
 }
 
+static String styleChangeTypeToString(StyleChangeType type)
+{
+    switch (type) {
+    case NoStyleChange:
+        return "NoStyleChange";
+    case InlineStyleChange:
+        return "InlineStyleChange";
+    case FullStyleChange:
+        return "FullStyleChange";
+    case SyntheticStyleChange:
+        return "SyntheticStyleChange";
+    case ReconstructRenderTree:
+        return "ReconstructRenderTree";
+    }
+    ASSERT_NOT_REACHED();
+    return "";
+}
+
+String Internals::styleChangeType(Node* node, ExceptionCode& exception)
+{
+    if (!node) {
+        exception = INVALID_ACCESS_ERR;
+        return { };
+    }
+
+    return styleChangeTypeToString(node->styleChangeType());
+}
+
 String Internals::description(Deprecated::ScriptValue value)
 {
     return toString(value.jsValue());

Modified: trunk/Source/WebCore/testing/Internals.h (196574 => 196575)


--- trunk/Source/WebCore/testing/Internals.h	2016-02-15 09:50:29 UTC (rev 196574)
+++ trunk/Source/WebCore/testing/Internals.h	2016-02-15 10:30:36 UTC (rev 196575)
@@ -89,6 +89,7 @@
 
     String address(Node*);
     bool nodeNeedsStyleRecalc(Node*, ExceptionCode&);
+    String styleChangeType(Node*, ExceptionCode&);
     String description(Deprecated::ScriptValue);
 
     bool isPreloaded(const String& url);

Modified: trunk/Source/WebCore/testing/Internals.idl (196574 => 196575)


--- trunk/Source/WebCore/testing/Internals.idl	2016-02-15 09:50:29 UTC (rev 196574)
+++ trunk/Source/WebCore/testing/Internals.idl	2016-02-15 10:30:36 UTC (rev 196575)
@@ -68,6 +68,7 @@
 ] interface Internals {
     DOMString address(Node node);
     [RaisesException] boolean nodeNeedsStyleRecalc(Node node);
+    [RaisesException] DOMString styleChangeType(Node node);
     DOMString description(any value);
 
     // Animated image pausing testing.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to