Title: [261703] trunk
Revision
261703
Author
nvasil...@apple.com
Date
2020-05-14 12:28:41 -0700 (Thu, 14 May 2020)

Log Message

Web Inspector: front-end shouldn't change the order of User Style Sheet rules
https://bugs.webkit.org/show_bug.cgi?id=210893
<rdar://problem/61937118>

Reviewed by Devin Rousso.

Source/WebCore:

Previously, some style sheets were falsly detected as Inspector::Protocol::CSS::StyleSheetOrigin::User
causing incorrect order of style rules in Web Inspector.

Test: inspector/css/getMatchedStylesForNode.html

* inspector/agents/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::detectOrigin):

LayoutTests:

Test that AuthorCSS and UserCSS are correctly arranged.

* inspector/css/getMatchedStylesForNode-expected.txt:
* inspector/css/getMatchedStylesForNode.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261702 => 261703)


--- trunk/LayoutTests/ChangeLog	2020-05-14 19:04:30 UTC (rev 261702)
+++ trunk/LayoutTests/ChangeLog	2020-05-14 19:28:41 UTC (rev 261703)
@@ -1,3 +1,16 @@
+2020-05-14  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: front-end shouldn't change the order of User Style Sheet rules
+        https://bugs.webkit.org/show_bug.cgi?id=210893
+        <rdar://problem/61937118>
+
+        Reviewed by Devin Rousso.
+
+        Test that AuthorCSS and UserCSS are correctly arranged.
+
+        * inspector/css/getMatchedStylesForNode-expected.txt:
+        * inspector/css/getMatchedStylesForNode.html:
+
 2020-05-14  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed test gardening, remove expectations for tests that are no longer failing.

Modified: trunk/LayoutTests/inspector/css/getMatchedStylesForNode-expected.txt (261702 => 261703)


--- trunk/LayoutTests/inspector/css/getMatchedStylesForNode-expected.txt	2020-05-14 19:04:30 UTC (rev 261702)
+++ trunk/LayoutTests/inspector/css/getMatchedStylesForNode-expected.txt	2020-05-14 19:28:41 UTC (rev 261703)
@@ -20,6 +20,148 @@
             ]
           }
         ],
+        "text": "div"
+      },
+      "sourceLine": "<filtered>",
+      "origin": "user",
+      "style": {
+        "cssProperties": [
+          {
+            "name": "z-index",
+            "value": "600"
+          }
+        ],
+        "shorthandEntries": [],
+        "styleId": "<filtered>",
+        "width": "",
+        "height": ""
+      },
+      "sourceURL": "<filtered>"
+    },
+    "matchingSelectors": [
+      0
+    ]
+  },
+  {
+    "rule": {
+      "selectorList": {
+        "selectors": [
+          {
+            "text": "div",
+            "specificity": [
+              0,
+              0,
+              1
+            ]
+          }
+        ],
+        "text": "div"
+      },
+      "sourceLine": "<filtered>",
+      "origin": "user",
+      "style": {
+        "cssProperties": [
+          {
+            "name": "z-index",
+            "value": "500"
+          }
+        ],
+        "shorthandEntries": [],
+        "styleId": "<filtered>",
+        "width": "",
+        "height": ""
+      },
+      "sourceURL": "<filtered>"
+    },
+    "matchingSelectors": [
+      0
+    ]
+  },
+  {
+    "rule": {
+      "selectorList": {
+        "selectors": [
+          {
+            "text": "div",
+            "specificity": [
+              0,
+              0,
+              1
+            ]
+          }
+        ],
+        "text": "div"
+      },
+      "sourceLine": "<filtered>",
+      "origin": "regular",
+      "style": {
+        "cssProperties": [
+          {
+            "name": "z-index",
+            "value": "400"
+          }
+        ],
+        "shorthandEntries": [],
+        "styleId": "<filtered>",
+        "width": "",
+        "height": ""
+      },
+      "sourceURL": "<filtered>",
+      "ruleId": "<filtered>"
+    },
+    "matchingSelectors": [
+      0
+    ]
+  },
+  {
+    "rule": {
+      "selectorList": {
+        "selectors": [
+          {
+            "text": "div",
+            "specificity": [
+              0,
+              0,
+              1
+            ]
+          }
+        ],
+        "text": "div"
+      },
+      "sourceLine": "<filtered>",
+      "origin": "regular",
+      "style": {
+        "cssProperties": [
+          {
+            "name": "z-index",
+            "value": "300"
+          }
+        ],
+        "shorthandEntries": [],
+        "styleId": "<filtered>",
+        "width": "",
+        "height": ""
+      },
+      "sourceURL": "<filtered>",
+      "ruleId": "<filtered>"
+    },
+    "matchingSelectors": [
+      0
+    ]
+  },
+  {
+    "rule": {
+      "selectorList": {
+        "selectors": [
+          {
+            "text": "div",
+            "specificity": [
+              0,
+              0,
+              1
+            ]
+          }
+        ],
         "text": "div",
         "range": "<filtered>"
       },

Modified: trunk/LayoutTests/inspector/css/getMatchedStylesForNode.html (261702 => 261703)


--- trunk/LayoutTests/inspector/css/getMatchedStylesForNode.html	2020-05-14 19:04:30 UTC (rev 261702)
+++ trunk/LayoutTests/inspector/css/getMatchedStylesForNode.html	2020-05-14 19:28:41 UTC (rev 261703)
@@ -1,6 +1,12 @@
 <html>
 <head>
 <script src=""
+<script>
+window.internals.insertAuthorCSS("div { z-index: 400; }");
+window.internals.insertUserCSS("div { z-index: 600; }");
+window.internals.insertAuthorCSS("div { z-index: 300; }");
+window.internals.insertUserCSS("div { z-index: 500; }");
+</script>
 <style>
     @import url(resources/external.css?1) (min-width: 0px);
 

Modified: trunk/Source/WebCore/ChangeLog (261702 => 261703)


--- trunk/Source/WebCore/ChangeLog	2020-05-14 19:04:30 UTC (rev 261702)
+++ trunk/Source/WebCore/ChangeLog	2020-05-14 19:28:41 UTC (rev 261703)
@@ -1,3 +1,19 @@
+2020-05-14  Nikita Vasilyev  <nvasil...@apple.com>
+
+        Web Inspector: front-end shouldn't change the order of User Style Sheet rules
+        https://bugs.webkit.org/show_bug.cgi?id=210893
+        <rdar://problem/61937118>
+
+        Reviewed by Devin Rousso.
+
+        Previously, some style sheets were falsly detected as Inspector::Protocol::CSS::StyleSheetOrigin::User
+        causing incorrect order of style rules in Web Inspector.
+
+        Test: inspector/css/getMatchedStylesForNode.html
+
+        * inspector/agents/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::detectOrigin):
+
 2020-05-14  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [macOS] Update the placeholder icon image for attachment elements with progress="0"

Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp (261702 => 261703)


--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2020-05-14 19:04:30 UTC (rev 261702)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2020-05-14 19:28:41 UTC (rev 261703)
@@ -931,7 +931,7 @@
     if (pageStyleSheet && !pageStyleSheet->ownerNode() && pageStyleSheet->href().isEmpty())
         return Inspector::Protocol::CSS::StyleSheetOrigin::UserAgent;
 
-    if (pageStyleSheet && pageStyleSheet->ownerNode() && pageStyleSheet->ownerNode()->nodeName() == "#document")
+    if (pageStyleSheet && pageStyleSheet->contents().isUserStyleSheet())
         return Inspector::Protocol::CSS::StyleSheetOrigin::User;
 
     auto iterator = m_documentToInspectorStyleSheet.find(ownerDocument);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to