summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderWidget.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-13 12:51:20 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-19 20:50:05 +0200
commitd441d6f39bb846989d95bcf5caf387b42414718d (patch)
treee367e64a75991c554930278175d403c072de6bb8 /Source/WebCore/rendering/RenderWidget.cpp
parent0060b2994c07842f4c59de64b5e3e430525c4b90 (diff)
downloadqtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/WebCore/rendering/RenderWidget.cpp')
-rw-r--r--Source/WebCore/rendering/RenderWidget.cpp102
1 files changed, 58 insertions, 44 deletions
diff --git a/Source/WebCore/rendering/RenderWidget.cpp b/Source/WebCore/rendering/RenderWidget.cpp
index 977751a73..271b8cfe3 100644
--- a/Source/WebCore/rendering/RenderWidget.cpp
+++ b/Source/WebCore/rendering/RenderWidget.cpp
@@ -32,6 +32,7 @@
#include "RenderLayer.h"
#include "RenderView.h"
#include "RenderWidgetProtector.h"
+#include <wtf/StackStats.h>
#if USE(ACCELERATED_COMPOSITING)
#include "RenderLayerBacking.h"
@@ -57,8 +58,8 @@ WidgetHierarchyUpdatesSuspensionScope::WidgetToParentMap& WidgetHierarchyUpdates
void WidgetHierarchyUpdatesSuspensionScope::moveWidgets()
{
- WidgetToParentMap map = widgetNewParentMap();
- widgetNewParentMap().clear();
+ WidgetToParentMap map;
+ widgetNewParentMap().swap(map);
WidgetToParentMap::iterator end = map.end();
for (WidgetToParentMap::iterator it = map.begin(); it != end; ++it) {
Widget* child = it->key.get();
@@ -85,10 +86,10 @@ static void moveWidgetToParentSoon(Widget* child, FrameView* parent)
WidgetHierarchyUpdatesSuspensionScope::scheduleWidgetToMove(child, parent);
}
-RenderWidget::RenderWidget(Node* node)
- : RenderReplaced(node)
+RenderWidget::RenderWidget(Element* element)
+ : RenderReplaced(element)
, m_widget(0)
- , m_frameView(node->document()->view())
+ , m_frameView(element->document()->view())
// Reference counting is used to prevent the widget from being
// destroyed while inside the Widget code, which might not be
// able to handle that.
@@ -102,9 +103,9 @@ void RenderWidget::willBeDestroyed()
if (RenderView* v = view())
v->removeWidget(this);
- if (AXObjectCache::accessibilityEnabled()) {
- document()->axObjectCache()->childrenChanged(this->parent());
- document()->axObjectCache()->remove(this);
+ if (AXObjectCache* cache = document()->existingAXObjectCache()) {
+ cache->childrenChanged(this->parent());
+ cache->remove(this);
}
setWidget(0);
@@ -119,7 +120,7 @@ void RenderWidget::destroy()
// Grab the arena from node()->document()->renderArena() before clearing the node pointer.
// Clear the node before deref-ing, as this may be deleted when deref is called.
RenderArena* arena = renderArena();
- setNode(0);
+ clearNode();
deref(arena);
}
@@ -143,8 +144,9 @@ bool RenderWidget::setWidgetGeometry(const LayoutRect& frame)
return false;
IntRect clipRect = roundedIntRect(enclosingLayer()->childrenClipRect());
+ IntRect newFrame = roundedIntRect(frame);
bool clipChanged = m_clipRect != clipRect;
- bool boundsChanged = m_widget->frameRect() != frame;
+ bool boundsChanged = m_widget->frameRect() != newFrame;
if (!boundsChanged && !clipChanged)
return false;
@@ -153,7 +155,10 @@ bool RenderWidget::setWidgetGeometry(const LayoutRect& frame)
RenderWidgetProtector protector(this);
RefPtr<Node> protectedNode(node());
- m_widget->setFrameRect(roundedIntRect(frame));
+ m_widget->setFrameRect(newFrame);
+
+ if (clipChanged && !boundsChanged)
+ m_widget->clipRectChanged();
#if USE(ACCELERATED_COMPOSITING)
if (hasLayer() && layer()->isComposited())
@@ -169,7 +174,7 @@ bool RenderWidget::updateWidgetGeometry()
if (!m_widget->transformsAffectFrameRect())
return setWidgetGeometry(absoluteContentBox());
- LayoutRect absoluteContentBox(localToAbsoluteQuad(FloatQuad(contentBox), SnapOffsetForTransforms).boundingBox());
+ LayoutRect absoluteContentBox(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox());
if (m_widget->isFrameView()) {
contentBox.setLocation(absoluteContentBox.location());
return setWidgetGeometry(contentBox);
@@ -234,6 +239,39 @@ void RenderWidget::notifyWidget(WidgetNotification notification)
m_widget->notifyWidget(notification);
}
+void RenderWidget::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ LayoutPoint adjustedPaintOffset = paintOffset + location();
+
+ // Tell the widget to paint now. This is the only time the widget is allowed
+ // to paint itself. That way it will composite properly with z-indexed layers.
+ IntPoint widgetLocation = m_widget->frameRect().location();
+ IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + paddingLeft()),
+ roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop()));
+ IntRect paintRect = paintInfo.rect;
+
+ IntSize widgetPaintOffset = paintLocation - widgetLocation;
+ // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
+ // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
+ if (!widgetPaintOffset.isZero()) {
+ paintInfo.context->translate(widgetPaintOffset);
+ paintRect.move(-widgetPaintOffset);
+ }
+ m_widget->paint(paintInfo.context, paintRect);
+
+ if (!widgetPaintOffset.isZero())
+ paintInfo.context->translate(-widgetPaintOffset);
+
+ if (m_widget->isFrameView()) {
+ FrameView* frameView = toFrameView(m_widget.get());
+ bool runOverlapTests = !frameView->useSlowRepaintsIfNotOverlapped() || frameView->hasCompositedContentIncludingDescendants();
+ if (paintInfo.overlapTestRequests && runOverlapTests) {
+ ASSERT(!paintInfo.overlapTestRequests->contains(this));
+ paintInfo.overlapTestRequests->set(this, m_widget->frameRect());
+ }
+ }
+}
+
void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (!shouldPaint(paintInfo, paintOffset))
@@ -250,7 +288,7 @@ void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
}
if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && hasOutline())
- paintOutline(paintInfo.context, LayoutRect(adjustedPaintOffset, size()));
+ paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size()));
if (!m_frameView || paintInfo.phase != PaintPhaseForeground)
return;
@@ -273,35 +311,8 @@ void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
clipRoundedInnerRect(paintInfo.context, borderRect, roundedInnerRect);
}
- if (m_widget) {
- // Tell the widget to paint now. This is the only time the widget is allowed
- // to paint itself. That way it will composite properly with z-indexed layers.
- IntPoint widgetLocation = m_widget->frameRect().location();
- IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + paddingLeft()),
- roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop()));
- IntRect paintRect = paintInfo.rect;
-
- IntSize widgetPaintOffset = paintLocation - widgetLocation;
- // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
- // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
- if (!widgetPaintOffset.isZero()) {
- paintInfo.context->translate(widgetPaintOffset);
- paintRect.move(-widgetPaintOffset);
- }
- m_widget->paint(paintInfo.context, paintRect);
-
- if (!widgetPaintOffset.isZero())
- paintInfo.context->translate(-widgetPaintOffset);
-
- if (m_widget->isFrameView()) {
- FrameView* frameView = static_cast<FrameView*>(m_widget.get());
- bool runOverlapTests = !frameView->useSlowRepaintsIfNotOverlapped() || frameView->hasCompositedContentIncludingDescendants();
- if (paintInfo.overlapTestRequests && runOverlapTests) {
- ASSERT(!paintInfo.overlapTestRequests->contains(this));
- paintInfo.overlapTestRequests->set(this, m_widget->frameRect());
- }
- }
- }
+ if (m_widget)
+ paintContents(paintInfo, paintOffset);
if (style()->hasBorderRadius())
paintInfo.context->restore();
@@ -311,13 +322,16 @@ void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
// FIXME: selectionRect() is in absolute, not painting coordinates.
paintInfo.context->fillRect(pixelSnappedIntRect(selectionRect()), selectionBackgroundColor(), style()->colorSpace());
}
+
+ if (hasLayer() && layer()->canResize())
+ layer()->paintResizer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect);
}
void RenderWidget::setOverlapTestResult(bool isOverlapped)
{
ASSERT(m_widget);
ASSERT(m_widget->isFrameView());
- static_cast<FrameView*>(m_widget.get())->setIsOverlapped(isOverlapped);
+ toFrameView(m_widget.get())->setIsOverlapped(isOverlapped);
}
void RenderWidget::deref(RenderArena *arena)
@@ -336,7 +350,7 @@ void RenderWidget::updateWidgetPosition()
// if the frame bounds got changed, or if view needs layout (possibly indicating
// content size is wrong) we have to do a layout to set the right widget size
if (m_widget && m_widget->isFrameView()) {
- FrameView* frameView = static_cast<FrameView*>(m_widget.get());
+ FrameView* frameView = toFrameView(m_widget.get());
// Check the frame's page to make sure that the frame isn't in the process of being destroyed.
if ((boundsChanged || frameView->needsLayout()) && frameView->frame()->page())
frameView->layout();