Title: [241701] releases/WebKitGTK/webkit-2.24
Revision
241701
Author
carlo...@webkit.org
Date
2019-02-18 08:15:55 -0800 (Mon, 18 Feb 2019)

Log Message

Merge r241623 - Web Inspector: Styles: valid values in style attributes are reported as unsupported property values
https://bugs.webkit.org/show_bug.cgi?id=194619
<rdar://problem/47917373>

Source/WebInspectorUI:

Reviewed by Devin Rousso.

Payload of inline styles may contain `range` that doesn't match
the actual text of the payload - it has an extra empty line at the end.
Mismatching ranges caused data corruption.

* UserInterface/Models/DOMNodeStyles.js:
(WI.DOMNodeStyles.prototype._parseStylePropertyPayload):

LayoutTests:

Reviewed by Devin Rousso and Joseph Pecoraro.

* inspector/css/modify-inline-style-expected.txt: Added.
* inspector/css/modify-inline-style.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/LayoutTests/ChangeLog (241700 => 241701)


--- releases/WebKitGTK/webkit-2.24/LayoutTests/ChangeLog	2019-02-18 16:15:49 UTC (rev 241700)
+++ releases/WebKitGTK/webkit-2.24/LayoutTests/ChangeLog	2019-02-18 16:15:55 UTC (rev 241701)
@@ -1,3 +1,14 @@
+2019-02-15  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: Styles: valid values in style attributes are reported as unsupported property values
+        https://bugs.webkit.org/show_bug.cgi?id=194619
+        <rdar://problem/47917373>
+
+        Reviewed by Devin Rousso and Joseph Pecoraro.
+
+        * inspector/css/modify-inline-style-expected.txt: Added.
+        * inspector/css/modify-inline-style.html: Added.
+
 2019-02-15  Per Arne Vollan  <pvol...@apple.com>
 
         [WebVTT] Inline WebVTT styles should start with '::cue'

Added: releases/WebKitGTK/webkit-2.24/LayoutTests/inspector/css/modify-inline-style-expected.txt (0 => 241701)


--- releases/WebKitGTK/webkit-2.24/LayoutTests/inspector/css/modify-inline-style-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.24/LayoutTests/inspector/css/modify-inline-style-expected.txt	2019-02-18 16:15:55 UTC (rev 241701)
@@ -0,0 +1,18 @@
+Testing that adding and editing CSS properties of inline styles works.
+
+
+== Running test suite: ModifyInlineStyle
+-- Running test case: ModifyInlineStyle.AddPropertyAndEdit
+CSSProperty changed to "font: 12px normal sans-serif!important;".
+font: 12px normal sans-serif!important;
+
+CSSProperty changed to "color: red;".
+font: 12px normal sans-serif!important;color: red;
+
+CSSProperty changed to "font: 12px sans-serif;".
+font: 12px sans-serif;color: red;
+
+CSSProperty changed to "color: invalid_c010r;".
+font: 12px sans-serif;color: invalid_c010r;
+
+

Added: releases/WebKitGTK/webkit-2.24/LayoutTests/inspector/css/modify-inline-style.html (0 => 241701)


--- releases/WebKitGTK/webkit-2.24/LayoutTests/inspector/css/modify-inline-style.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.24/LayoutTests/inspector/css/modify-inline-style.html	2019-02-18 16:15:55 UTC (rev 241701)
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test() {
+    let nodeStyles = null;
+
+    WI.DOMNodeStyles.addEventListener(WI.DOMNodeStyles.Event.NeedsRefresh, function(event) {
+        // Normally, this would get called from views if the styles sidebar is visible.
+        // This doesn't work in tests.
+        event.target.refresh();
+    });
+
+    let suite = InspectorTest.createAsyncSuite("ModifyInlineStyle");
+
+    suite.addTestCase({
+        name: "ModifyInlineStyle.AddPropertyAndEdit",
+        test(resolve, reject) {
+            let getInlineStyleDeclaration = () => {
+                for (let styleDeclaration of nodeStyles.orderedStyles) {
+                    if (styleDeclaration.type === styleDeclaration.constructor.Type.Inline)
+                        return styleDeclaration;
+                }
+                InspectorTest.fail("No declaration found.");
+                resolve();
+            };
+
+            let style = getInlineStyleDeclaration();
+
+            const fontPropertyIndex = 0;
+            let fontProperty = style.newBlankProperty(fontPropertyIndex);
+            fontProperty.name = "font";
+            fontProperty.rawValue = "12px normal sans-serif!important";
+
+            let colorProperty = null;
+
+            let cssPropertyChanged = (event) => {
+                if (event.target.ownerStyle && event.target.ownerStyle.type === WI.CSSStyleDeclaration.Type.Computed)
+                    return;
+
+                if (!event.target.text)
+                    return;
+
+                InspectorTest.log(`CSSProperty changed to "${event.target.text}".`);
+                InspectorTest.log(style.text + "\n");
+            };
+
+            WI.CSSProperty.addEventListener(WI.CSSProperty.Event.Changed, cssPropertyChanged);
+
+            fontProperty.awaitEvent(WI.CSSProperty.Event.Changed).then((event) => {
+                const colorPropertyIndex = 1;
+                colorProperty = style.newBlankProperty(colorPropertyIndex);
+                let promise = colorProperty.awaitEvent(WI.CSSProperty.Event.Changed);
+                colorProperty.name = "color";
+                colorProperty.rawValue = "red";
+                return promise;
+            }).then(() => {
+                let promise = fontProperty.awaitEvent(WI.CSSProperty.Event.Changed);
+                fontProperty.rawValue = "12px sans-serif";
+                return promise;
+            }).then(() => {
+                let promise = colorProperty.awaitEvent(WI.CSSProperty.Event.Changed);
+                colorProperty.rawValue = "invalid_c010r";
+                return promise;
+            }).then(() => {
+                WI.CSSProperty.removeEventListener(WI.CSSProperty.Event.Changed, cssPropertyChanged);
+                resolve();
+                return true;
+            });
+        }
+    });
+
+    WI.domManager.requestDocument((documentNode) => {
+        WI.domManager.querySelector(documentNode.id, "#x", (contentNodeId) => {
+            if (contentNodeId) {
+                let domNode = WI.domManager.nodeForId(contentNodeId);
+                nodeStyles = WI.cssManager.stylesForNode(domNode);
+
+                if (nodeStyles.needsRefresh) {
+                    nodeStyles.singleFireEventListener(WI.DOMNodeStyles.Event.Refreshed, (event) => {
+                        suite.runTestCasesAndFinish()
+                    });
+                } else
+                    suite.runTestCasesAndFinish();
+            } else {
+                InspectorTest.fail("DOM node not found.");
+                InspectorTest.completeTest();
+            }
+        });
+    });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <p>Testing that adding and editing CSS properties of inline styles works.</p>
+    <div id="x"></div>
+</body>
+</html>

Modified: releases/WebKitGTK/webkit-2.24/Source/WebInspectorUI/ChangeLog (241700 => 241701)


--- releases/WebKitGTK/webkit-2.24/Source/WebInspectorUI/ChangeLog	2019-02-18 16:15:49 UTC (rev 241700)
+++ releases/WebKitGTK/webkit-2.24/Source/WebInspectorUI/ChangeLog	2019-02-18 16:15:55 UTC (rev 241701)
@@ -1,3 +1,18 @@
+2019-02-15  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: Styles: valid values in style attributes are reported as unsupported property values
+        https://bugs.webkit.org/show_bug.cgi?id=194619
+        <rdar://problem/47917373>
+
+        Reviewed by Devin Rousso.
+
+        Payload of inline styles may contain `range` that doesn't match
+        the actual text of the payload - it has an extra empty line at the end.
+        Mismatching ranges caused data corruption.
+
+        * UserInterface/Models/DOMNodeStyles.js:
+        (WI.DOMNodeStyles.prototype._parseStylePropertyPayload):
+
 2019-02-14  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r241497.

Modified: releases/WebKitGTK/webkit-2.24/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js (241700 => 241701)


--- releases/WebKitGTK/webkit-2.24/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js	2019-02-18 16:15:49 UTC (rev 241700)
+++ releases/WebKitGTK/webkit-2.24/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js	2019-02-18 16:15:55 UTC (rev 241701)
@@ -512,6 +512,7 @@
         var name = payload.name;
         var value = payload.value || "";
         var priority = payload.priority || "";
+        let range = payload.range || null;
 
         var enabled = true;
         var overridden = false;
@@ -536,6 +537,19 @@
             break;
         }
 
+        if (range) {
+            // Last property of inline style has mismatching range.
+            // The actual text has one line, but the range spans two lines.
+            let rangeLineCount = 1 + range.endLine - range.startLine;
+            if (rangeLineCount > 1) {
+                let textLineCount = text.lineCount;
+                if (textLineCount === rangeLineCount - 1) {
+                    range.endLine = range.startLine + (textLineCount - 1);
+                    range.endColumn = range.startColumn + text.lastLine.length;
+                }
+            }
+        }
+
         var styleSheetTextRange = this._parseSourceRangePayload(payload.range);
 
         if (styleDeclaration) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to