2011-06-25 Joseph Pecoraro <joepeck@webkit.org>
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jun 2011 23:01:15 +0000 (23:01 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jun 2011 23:01:15 +0000 (23:01 +0000)
        Reviewed by Simon Fraser.

        Inspector highlight rect is wrong for contents of transformed iframes
        https://bugs.webkit.org/show_bug.cgi?id=53627

        Part 1: Provide FloatQuad versions of convertFromRenderer,
        convertToContainingView, and convertChildToSelf, so that we
        can get the fully transformed quad of a renderer all the
        way up to the root widget.

        * page/FrameView.cpp:
        (WebCore::FrameView::convertFromRenderer):
        (WebCore::FrameView::convertToContainingView):
        * page/FrameView.h:
        * platform/ScrollView.h:
        (WebCore::ScrollView::convertChildToSelf):
        * platform/Widget.h:
        * platform/Widget.cpp:
        (WebCore::Widget::convertToContainingView):
        Provide FloatQuad versions of these already existing functions.

        (WebCore::Widget::convertToRootContainingView):
        Provide a helper conversion function to recursively
        convert a given FloatQuad up to the root widget.

        * inspector/DOMNodeHighlighter.cpp:
        (WebCore::DOMNodeHighlighter::DrawNodeHighlight):
        Use the new methods to convert the FloatQuad for the highlighted
        node to the root container, without losing transformation
        information. Add a FIXME for SVG, which is still broken.

        * WebCore.exp.in:
        Export the new Widget functions so WebKit can link properly.

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/inspector/DOMNodeHighlighter.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/Widget.cpp
Source/WebCore/platform/Widget.h

index f83caeb..6d0ec1a 100644 (file)
@@ -1,3 +1,39 @@
+2011-06-25  Joseph Pecoraro  <joepeck@webkit.org>
+
+        Reviewed by Simon Fraser.
+
+        Inspector highlight rect is wrong for contents of transformed iframes
+        https://bugs.webkit.org/show_bug.cgi?id=53627
+
+        Part 1: Provide FloatQuad versions of convertFromRenderer,
+        convertToContainingView, and convertChildToSelf, so that we
+        can get the fully transformed quad of a renderer all the
+        way up to the root widget.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::convertFromRenderer):
+        (WebCore::FrameView::convertToContainingView):
+        * page/FrameView.h:
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::convertChildToSelf):
+        * platform/Widget.h:
+        * platform/Widget.cpp:
+        (WebCore::Widget::convertToContainingView):
+        Provide FloatQuad versions of these already existing functions.
+
+        (WebCore::Widget::convertToRootContainingView):
+        Provide a helper conversion function to recursively
+        convert a given FloatQuad up to the root widget.
+
+        * inspector/DOMNodeHighlighter.cpp:
+        (WebCore::DOMNodeHighlighter::DrawNodeHighlight):
+        Use the new methods to convert the FloatQuad for the highlighted
+        node to the root container, without losing transformation
+        information. Add a FIXME for SVG, which is still broken.
+
+        * WebCore.exp.in:
+        Export the new Widget functions so WebKit can link properly.
+
 2011-06-25  Dirk Schulze  <krit@webkit.org>
 
         Unreviewed build fix.
index 91ed84d..ccd8384 100644 (file)
@@ -1274,10 +1274,12 @@ __ZNK7WebCore6JSNode21pushEventHandlerScopeEPN3JSC9ExecStateEPNS1_14ScopeChainNo
 __ZNK7WebCore6Widget14platformWidgetEv
 __ZNK7WebCore6Widget23convertToContainingViewERKNS_7IntRectE
 __ZNK7WebCore6Widget23convertToContainingViewERKNS_8IntPointE
+__ZNK7WebCore6Widget23convertToContainingViewERKNS_9FloatQuadE
 __ZNK7WebCore6Widget25convertFromContainingViewERKNS_7IntRectE
 __ZNK7WebCore6Widget25convertFromContainingViewERKNS_8IntPointE
 __ZNK7WebCore6Widget25convertToContainingWindowERKNS_7IntRectE
 __ZNK7WebCore6Widget25convertToContainingWindowERKNS_8IntPointE
+__ZNK7WebCore6Widget27convertToRootContainingViewERKNS_9FloatQuadE
 __ZNK7WebCore6Widget9frameRectEv
 __ZNK7WebCore7Element10screenRectEv
 __ZNK7WebCore7Element10shadowRootEv
index 9aa69ef..3d4d4d2 100644 (file)
@@ -267,21 +267,22 @@ void DrawNodeHighlight(GraphicsContext& context, Node* node, HighlightMode mode)
         IntRect marginBox(borderBox.x() - renderBox->marginLeft(), borderBox.y() - renderBox->marginTop(),
                           borderBox.width() + renderBox->marginLeft() + renderBox->marginRight(), borderBox.height() + renderBox->marginTop() + renderBox->marginBottom());
 
+        FrameView* containingView = containingFrame->view();
+        FloatQuad absContentQuad = containingView->convertFromRenderer(renderer, FloatRect(contentBox));
+        FloatQuad absPaddingQuad = containingView->convertFromRenderer(renderer, FloatRect(paddingBox));
+        FloatQuad absBorderQuad = containingView->convertFromRenderer(renderer, FloatRect(borderBox));
+        FloatQuad absMarginQuad = containingView->convertFromRenderer(renderer, FloatRect(marginBox));
 
-        FloatQuad absContentQuad = renderBox->localToAbsoluteQuad(FloatRect(contentBox));
-        FloatQuad absPaddingQuad = renderBox->localToAbsoluteQuad(FloatRect(paddingBox));
-        FloatQuad absBorderQuad = renderBox->localToAbsoluteQuad(FloatRect(borderBox));
-        FloatQuad absMarginQuad = renderBox->localToAbsoluteQuad(FloatRect(marginBox));
-
-        absContentQuad.move(mainFrameOffset);
-        absPaddingQuad.move(mainFrameOffset);
-        absBorderQuad.move(mainFrameOffset);
-        absMarginQuad.move(mainFrameOffset);
+        absContentQuad = containingView->convertToRootContainingView(absContentQuad);
+        absPaddingQuad = containingView->convertToRootContainingView(absPaddingQuad);
+        absBorderQuad = containingView->convertToRootContainingView(absBorderQuad);
+        absMarginQuad = containingView->convertToRootContainingView(absMarginQuad);
 
         titleAnchorBox = absMarginQuad.enclosingBoundingBox();
 
         drawHighlightForBox(context, absContentQuad, absPaddingQuad, absBorderQuad, absMarginQuad, mode);
     } else if (renderer->isRenderInline() || isSVGRenderer) {
+        // FIXME: Does not handle transformed content correctly.
         // FIXME: We should show margins/padding/border for inlines.
         Vector<FloatQuad> lineBoxQuads;
         renderer->absoluteQuads(lineBoxQuads);
index e7cd839..3ff5c3c 100644 (file)
@@ -2806,6 +2806,42 @@ IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const
     return parentPoint;
 }
 
+FloatQuad FrameView::convertFromRenderer(const RenderObject* renderer, const FloatQuad& rendererQuad) const
+{
+    FloatQuad quad = renderer->localToAbsoluteQuad(rendererQuad);
+
+    IntPoint scroll = scrollPosition();
+    quad.move(-scroll.x(), -scroll.y());
+
+    return quad;
+}
+
+FloatQuad FrameView::convertToContainingView(const FloatQuad& localQuad) const
+{
+    if (const ScrollView* parentScrollView = parent()) {
+        if (parentScrollView->isFrameView()) {
+            const FrameView* parentView = static_cast<const FrameView*>(parentScrollView);
+
+            // Get our renderer in the parent view.
+            RenderPart* renderer = m_frame->ownerRenderer();
+            if (!renderer)
+                return localQuad;
+
+            // Add borders and padding.
+            FloatQuad quad(localQuad);
+            quad.move(renderer->borderLeft() + renderer->paddingLeft(),
+                      renderer->borderTop() + renderer->paddingTop());
+
+            // Apply the parent's transforms and scroll offset.
+            return parentView->convertFromRenderer(renderer, quad);
+        }
+
+        return Widget::convertToContainingView(localQuad);
+    }
+
+    return localQuad;
+}
+
 // Normal delay
 void FrameView::setRepaintThrottlingDeferredRepaintDelay(double p)
 {
index 40d9e42..2ebb9ca 100644 (file)
@@ -260,6 +260,10 @@ public:
     virtual IntPoint convertFromRenderer(const RenderObject*, const IntPoint&) const;
     virtual IntPoint convertToRenderer(const RenderObject*, const IntPoint&) const;
 
+    // Conversion with FloatQuads, to keep transformed coordinates.
+    virtual FloatQuad convertFromRenderer(const RenderObject*, const FloatQuad&) const;
+    virtual FloatQuad convertToContainingView(const FloatQuad&) const;
+
     bool isFrameViewScrollCorner(RenderScrollbarPart* scrollCorner) const { return m_scrollCorner == scrollCorner; }
 
     void calculateScrollbarModesForLayout(ScrollbarMode& hMode, ScrollbarMode& vMode);
index 1d90836..ce24d86 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef ScrollView_h
 #define ScrollView_h
 
+#include "FloatQuad.h"
 #include "IntRect.h"
 #include "Scrollbar.h"
 #include "ScrollableArea.h"
@@ -256,6 +257,16 @@ public:
         return newPoint;
     }
 
+    FloatQuad convertChildToSelf(const Widget* child, const FloatQuad& quad) const
+    {
+        IntPoint point = quad.enclosingBoundingBox().location();
+        IntPoint newPoint = convertChildToSelf(child, point);
+
+        FloatQuad newQuad = quad;
+        newQuad.move(newPoint.x(), newPoint.y());
+        return newQuad;
+    }
+
     // Widget override. Handles painting of the contents of the view as well as the scrollbars.
     virtual void paint(GraphicsContext*, const IntRect&);
     void paintScrollbars(GraphicsContext*, const IntRect&);
index 9a980c0..5ac642c 100644 (file)
@@ -168,6 +168,23 @@ IntPoint Widget::convertFromContainingView(const IntPoint& parentPoint) const
     return parentPoint;
 }
 
+FloatQuad Widget::convertToContainingView(const FloatQuad& localQuad) const
+{
+    if (const ScrollView* parentScrollView = parent())
+        return parentScrollView->convertChildToSelf(this, localQuad);
+
+    return localQuad;
+}
+
+FloatQuad Widget::convertToRootContainingView(const FloatQuad& localQuad) const
+{
+    if (!parent())
+        return localQuad;
+
+    FloatQuad containingQuad = convertToContainingView(localQuad);
+    return parent()->convertToRootContainingView(containingQuad);
+}
+
 #if !PLATFORM(EFL)
 void Widget::frameRectsChanged()
 {
index 3af50e4..26aaa1a 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef Widget_h
 #define Widget_h
 
+#include "FloatQuad.h"
 #include "IntRect.h"
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
@@ -253,6 +254,10 @@ public:
     virtual IntPoint convertToContainingView(const IntPoint&) const;
     virtual IntPoint convertFromContainingView(const IntPoint&) const;
 
+    // Conversion with FloatQuads, to keep transformed coordinates.
+    virtual FloatQuad convertToContainingView(const FloatQuad&) const;
+    virtual FloatQuad convertToRootContainingView(const FloatQuad&) const;
+
     // A means to access the AX cache when this object can get a pointer to it.
     virtual AXObjectCache* axObjectCache() const { return 0; }