- Revision
- 89753
- Author
- [email protected]
- Date
- 2011-06-25 16:01:15 -0700 (Sat, 25 Jun 2011)
Log Message
2011-06-25 Joseph Pecoraro <[email protected]>
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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (89752 => 89753)
--- trunk/Source/WebCore/ChangeLog 2011-06-25 22:16:57 UTC (rev 89752)
+++ trunk/Source/WebCore/ChangeLog 2011-06-25 23:01:15 UTC (rev 89753)
@@ -1,3 +1,39 @@
+2011-06-25 Joseph Pecoraro <[email protected]>
+
+ 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 <[email protected]>
Unreviewed build fix.
Modified: trunk/Source/WebCore/WebCore.exp.in (89752 => 89753)
--- trunk/Source/WebCore/WebCore.exp.in 2011-06-25 22:16:57 UTC (rev 89752)
+++ trunk/Source/WebCore/WebCore.exp.in 2011-06-25 23:01:15 UTC (rev 89753)
@@ -1274,10 +1274,12 @@
__ZNK7WebCore6Widget14platformWidgetEv
__ZNK7WebCore6Widget23convertToContainingViewERKNS_7IntRectE
__ZNK7WebCore6Widget23convertToContainingViewERKNS_8IntPointE
+__ZNK7WebCore6Widget23convertToContainingViewERKNS_9FloatQuadE
__ZNK7WebCore6Widget25convertFromContainingViewERKNS_7IntRectE
__ZNK7WebCore6Widget25convertFromContainingViewERKNS_8IntPointE
__ZNK7WebCore6Widget25convertToContainingWindowERKNS_7IntRectE
__ZNK7WebCore6Widget25convertToContainingWindowERKNS_8IntPointE
+__ZNK7WebCore6Widget27convertToRootContainingViewERKNS_9FloatQuadE
__ZNK7WebCore6Widget9frameRectEv
__ZNK7WebCore7Element10screenRectEv
__ZNK7WebCore7Element10shadowRootEv
Modified: trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp (89752 => 89753)
--- trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp 2011-06-25 22:16:57 UTC (rev 89752)
+++ trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp 2011-06-25 23:01:15 UTC (rev 89753)
@@ -267,21 +267,22 @@
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 = containingView->convertToRootContainingView(absContentQuad);
+ absPaddingQuad = containingView->convertToRootContainingView(absPaddingQuad);
+ absBorderQuad = containingView->convertToRootContainingView(absBorderQuad);
+ absMarginQuad = containingView->convertToRootContainingView(absMarginQuad);
- absContentQuad.move(mainFrameOffset);
- absPaddingQuad.move(mainFrameOffset);
- absBorderQuad.move(mainFrameOffset);
- absMarginQuad.move(mainFrameOffset);
-
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);
Modified: trunk/Source/WebCore/page/FrameView.cpp (89752 => 89753)
--- trunk/Source/WebCore/page/FrameView.cpp 2011-06-25 22:16:57 UTC (rev 89752)
+++ trunk/Source/WebCore/page/FrameView.cpp 2011-06-25 23:01:15 UTC (rev 89753)
@@ -2806,6 +2806,42 @@
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)
{
Modified: trunk/Source/WebCore/page/FrameView.h (89752 => 89753)
--- trunk/Source/WebCore/page/FrameView.h 2011-06-25 22:16:57 UTC (rev 89752)
+++ trunk/Source/WebCore/page/FrameView.h 2011-06-25 23:01:15 UTC (rev 89753)
@@ -260,6 +260,10 @@
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);
Modified: trunk/Source/WebCore/platform/ScrollView.h (89752 => 89753)
--- trunk/Source/WebCore/platform/ScrollView.h 2011-06-25 22:16:57 UTC (rev 89752)
+++ trunk/Source/WebCore/platform/ScrollView.h 2011-06-25 23:01:15 UTC (rev 89753)
@@ -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 @@
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&);
Modified: trunk/Source/WebCore/platform/Widget.cpp (89752 => 89753)
--- trunk/Source/WebCore/platform/Widget.cpp 2011-06-25 22:16:57 UTC (rev 89752)
+++ trunk/Source/WebCore/platform/Widget.cpp 2011-06-25 23:01:15 UTC (rev 89753)
@@ -168,6 +168,23 @@
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()
{
Modified: trunk/Source/WebCore/platform/Widget.h (89752 => 89753)
--- trunk/Source/WebCore/platform/Widget.h 2011-06-25 22:16:57 UTC (rev 89752)
+++ trunk/Source/WebCore/platform/Widget.h 2011-06-25 23:01:15 UTC (rev 89753)
@@ -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 @@
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; }