Title: [291824] trunk/Source/WebCore
Revision
291824
Author
pan...@apple.com
Date
2022-03-24 16:29:30 -0700 (Thu, 24 Mar 2022)

Log Message

Web Inspector: Blank inspector in a page with container queries
https://bugs.webkit.org/show_bug.cgi?id=238338

Reviewed by Devin Rousso.

Because there is no CSSOM implementation for container queries, we are unable to inspect them currently.
However, we should be resilient to the absence of that implementation and expect that not all rules have a
matching CSSOM implementation, instead of just crashing when it happens. This patch only resolves crashes as the
result of the presence of container queries, and followup work will be done to actually plumb the correct
information to Web Inspector to show these rules.

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::collectFlatRules):
* inspector/agents/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::collectStyleSheets):
* style/InspectorCSSOMWrappers.cpp:
(WebCore::Style::InspectorCSSOMWrappers::collect):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291823 => 291824)


--- trunk/Source/WebCore/ChangeLog	2022-03-24 23:23:53 UTC (rev 291823)
+++ trunk/Source/WebCore/ChangeLog	2022-03-24 23:29:30 UTC (rev 291824)
@@ -1,3 +1,23 @@
+2022-03-24  Patrick Angle  <pan...@apple.com>
+
+        Web Inspector: Blank inspector in a page with container queries
+        https://bugs.webkit.org/show_bug.cgi?id=238338
+
+        Reviewed by Devin Rousso.
+
+        Because there is no CSSOM implementation for container queries, we are unable to inspect them currently.
+        However, we should be resilient to the absence of that implementation and expect that not all rules have a
+        matching CSSOM implementation, instead of just crashing when it happens. This patch only resolves crashes as the
+        result of the presence of container queries, and followup work will be done to actually plumb the correct
+        information to Web Inspector to show these rules.
+
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheet::collectFlatRules):
+        * inspector/agents/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::collectStyleSheets):
+        * style/InspectorCSSOMWrappers.cpp:
+        (WebCore::Style::InspectorCSSOMWrappers::collect):
+
 2022-03-24  Antoine Quint  <grao...@webkit.org>
 
         DOM GPUP: paintSystemPreviewBadge (AR QuickLook element badge)

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (291823 => 291824)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2022-03-24 23:23:53 UTC (rev 291823)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2022-03-24 23:29:30 UTC (rev 291824)
@@ -1526,6 +1526,9 @@
 
     for (unsigned i = 0, size = ruleList->length(); i < size; ++i) {
         CSSRule* rule = ruleList->item(i);
+        if (!rule)
+            continue;
+        
         CSSStyleRule* styleRule = InspectorCSSAgent::asCSSStyleRule(*rule);
         if (styleRule)
             result->append(styleRule);

Modified: trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp (291823 => 291824)


--- trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2022-03-24 23:23:53 UTC (rev 291823)
+++ trunk/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp	2022-03-24 23:29:30 UTC (rev 291824)
@@ -648,9 +648,8 @@
     result.append(styleSheet);
 
     for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) {
-        CSSRule* rule = styleSheet->item(i);
-        if (is<CSSImportRule>(*rule)) {
-            if (CSSStyleSheet* importedStyleSheet = downcast<CSSImportRule>(*rule).styleSheet())
+        if (auto* rule = dynamicDowncast<CSSImportRule>(styleSheet->item(i))) {
+            if (CSSStyleSheet* importedStyleSheet = rule->styleSheet())
                 collectStyleSheets(importedStyleSheet, result);
         }
     }

Modified: trunk/Source/WebCore/style/InspectorCSSOMWrappers.cpp (291823 => 291824)


--- trunk/Source/WebCore/style/InspectorCSSOMWrappers.cpp	2022-03-24 23:23:53 UTC (rev 291823)
+++ trunk/Source/WebCore/style/InspectorCSSOMWrappers.cpp	2022-03-24 23:29:30 UTC (rev 291824)
@@ -59,6 +59,9 @@
     unsigned size = listType->length();
     for (unsigned i = 0; i < size; ++i) {
         CSSRule* cssRule = listType->item(i);
+        if (!cssRule)
+            continue;
+        
         switch (cssRule->styleRuleType()) {
         case StyleRuleType::Import:
             collect(downcast<CSSImportRule>(*cssRule).styleSheet());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to