Web Inspector: REGRESSION: Overlay: highlighting a ::before/::after shows the node...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2019 00:52:10 +0000 (00:52 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jul 2019 00:52:10 +0000 (00:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200051

Reviewed by Joseph Pecoraro.

When highlighting a pseudo-element, only use the parent node for selector information. All
rendering data should still come from the pseudo-element itself.

* inspector/InspectorOverlay.cpp:
(WebCore::drawShapeHighlight):
(WebCore::InspectorOverlay::drawElementTitle):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247805 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorOverlay.cpp

index 0304816..b89b57c 100644 (file)
@@ -1,5 +1,19 @@
 2019-07-24  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: REGRESSION: Overlay: highlighting a ::before/::after shows the node info of the parent instead
+        https://bugs.webkit.org/show_bug.cgi?id=200051
+
+        Reviewed by Joseph Pecoraro.
+
+        When highlighting a pseudo-element, only use the parent node for selector information. All
+        rendering data should still come from the pseudo-element itself.
+
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::drawShapeHighlight):
+        (WebCore::InspectorOverlay::drawElementTitle):
+
+2019-07-24  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: support `console.screenshot` with subclasses of CanvasRenderingContext
         https://bugs.webkit.org/show_bug.cgi?id=199305
 
index 09cbf65..4ec5262 100644 (file)
@@ -277,11 +277,7 @@ static void drawFragmentHighlight(GraphicsContext& context, Node& node, const Hi
 
 static void drawShapeHighlight(GraphicsContext& context, Node& node, Highlight::Bounds& bounds)
 {
-    Element* element = effectiveElementForNode(node);
-    if (!element)
-        return;
-
-    RenderObject* renderer = element->renderer();
+    RenderObject* renderer = node.renderer();
     if (!renderer || !is<RenderBox>(renderer))
         return;
 
@@ -289,12 +285,15 @@ static void drawShapeHighlight(GraphicsContext& context, Node& node, Highlight::
     if (!shapeOutsideInfo)
         return;
 
-    const Color shapeHighlightColor(96, 82, 127, 204);
+    Frame* containingFrame = node.document().frame();
+    if (!containingFrame)
+        return;
 
-    Frame* containingFrame = element->document().frame();
     FrameView* containingView = containingFrame->view();
     FrameView* mainView = containingFrame->page()->mainFrame().view();
 
+    const Color shapeHighlightColor(96, 82, 127, 204);
+
     Shape::DisplayPaths paths;
     shapeOutsideInfo->computedShape().buildDisplayPaths(paths);
 
@@ -843,7 +842,7 @@ void InspectorOverlay::drawElementTitle(GraphicsContext& context, Node& node, co
     if (!element)
         return;
 
-    RenderObject* renderer = element->renderer();
+    RenderObject* renderer = node.renderer();
     if (!renderer)
         return;
 
@@ -871,9 +870,9 @@ void InspectorOverlay::drawElementTitle(GraphicsContext& context, Node& node, co
     }
 
     String elementPseudoType;
-    if (element->isBeforePseudoElement())
+    if (node.isBeforePseudoElement())
         elementPseudoType = "::before"_s;
-    else if (element->isAfterPseudoElement())
+    else if (node.isAfterPseudoElement())
         elementPseudoType = "::after"_s;
 
     String elementWidth;
@@ -883,7 +882,7 @@ void InspectorOverlay::drawElementTitle(GraphicsContext& context, Node& node, co
         elementWidth = String::number(adjustForAbsoluteZoom(roundToInt(modelObject->offsetWidth()), *modelObject));
         elementHeight = String::number(adjustForAbsoluteZoom(roundToInt(modelObject->offsetHeight()), *modelObject));
     } else {
-        FrameView* containingView = element->document().frame()->view();
+        FrameView* containingView = node.document().frame()->view();
         IntRect boundingBox = snappedIntRect(containingView->contentsToRootView(renderer->absoluteBoundingBoxRect()));
         elementWidth = String::number(boundingBox.width());
         elementHeight = String::number(boundingBox.height());
@@ -894,8 +893,8 @@ void InspectorOverlay::drawElementTitle(GraphicsContext& context, Node& node, co
         WebCore::AXObjectCache::enableAccessibility();
 
     String elementRole;
-    if (AXObjectCache* axObjectCache = element->document().axObjectCache()) {
-        if (AccessibilityObject* axObject = axObjectCache->getOrCreate(element))
+    if (AXObjectCache* axObjectCache = node.document().axObjectCache()) {
+        if (AccessibilityObject* axObject = axObjectCache->getOrCreate(&node))
             elementRole = axObject->computedRoleString();
     }