diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/rendering/RenderWidget.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/rendering/RenderWidget.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderWidget.cpp | 101 |
1 files changed, 56 insertions, 45 deletions
diff --git a/Source/WebCore/rendering/RenderWidget.cpp b/Source/WebCore/rendering/RenderWidget.cpp index 924ea33ef..ef804b2be 100644 --- a/Source/WebCore/rendering/RenderWidget.cpp +++ b/Source/WebCore/rendering/RenderWidget.cpp @@ -24,16 +24,18 @@ #include "RenderWidget.h" #include "AXObjectCache.h" -#include "FloatRoundedRect.h" #include "Frame.h" #include "HTMLFrameOwnerElement.h" #include "HitTestResult.h" #include "RenderLayer.h" -#include "RenderLayerBacking.h" #include "RenderView.h" #include <wtf/StackStats.h> #include <wtf/Ref.h> +#if USE(ACCELERATED_COMPOSITING) +#include "RenderLayerBacking.h" +#endif + namespace WebCore { static HashMap<const Widget*, RenderWidget*>& widgetRendererMap() @@ -46,7 +48,7 @@ unsigned WidgetHierarchyUpdatesSuspensionScope::s_widgetHierarchyUpdateSuspendCo WidgetHierarchyUpdatesSuspensionScope::WidgetToParentMap& WidgetHierarchyUpdatesSuspensionScope::widgetNewParentMap() { - static NeverDestroyed<WidgetToParentMap> map; + DEFINE_STATIC_LOCAL(WidgetToParentMap, map, ()); return map; } @@ -61,7 +63,7 @@ void WidgetHierarchyUpdatesSuspensionScope::moveWidgets() FrameView* newParent = it->value; if (newParent != currentParent) { if (currentParent) - currentParent->removeChild(*child); + currentParent->removeChild(child); if (newParent) newParent->addChild(child); } @@ -80,8 +82,8 @@ static void moveWidgetToParentSoon(Widget* child, FrameView* parent) WidgetHierarchyUpdatesSuspensionScope::scheduleWidgetToMove(child, parent); } -RenderWidget::RenderWidget(HTMLFrameOwnerElement& element, Ref<RenderStyle>&& style) - : RenderReplaced(element, WTFMove(style)) +RenderWidget::RenderWidget(HTMLFrameOwnerElement& element, PassRef<RenderStyle> style) + : RenderReplaced(element, std::move(style)) , m_weakPtrFactory(this) { setInline(false); @@ -99,14 +101,13 @@ void RenderWidget::willBeDestroyed() cache->remove(this); } - setWidget(nullptr); + setWidget(0); RenderReplaced::willBeDestroyed(); } RenderWidget::~RenderWidget() { - ASSERT(!m_refCount); } // Widgets are always placed on integer boundaries, so rounding the size is actually @@ -140,9 +141,10 @@ bool RenderWidget::setWidgetGeometry(const LayoutRect& frame) if (!weakThis) return true; - if (boundsChanged && isComposited()) +#if USE(ACCELERATED_COMPOSITING) + if (boundsChanged && hasLayer() && layer()->isComposited()) layer()->backing()->updateAfterWidgetResize(); - +#endif return oldFrameRect.size() != newFrameRect.size(); } @@ -218,28 +220,30 @@ void RenderWidget::styleDidChange(StyleDifference diff, const RenderStyle* oldSt void RenderWidget::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOffset) { - IntPoint contentPaintOffset = roundedIntPoint(paintOffset + location() + contentBoxRect().location()); + 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())); LayoutRect paintRect = paintInfo.rect; - IntPoint widgetLocation = m_widget->frameRect().location(); - IntSize widgetPaintOffset = contentPaintOffset - widgetLocation; + LayoutSize 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); + paintInfo.context->translate(widgetPaintOffset); paintRect.move(-widgetPaintOffset); } - // FIXME: Remove repaintrect encolsing/integral snapping when RenderWidget becomes device pixel snapped. - m_widget->paint(paintInfo.context(), snappedIntRect(paintRect)); + m_widget->paint(paintInfo.context, pixelSnappedIntRect(paintRect)); if (!widgetPaintOffset.isZero()) - paintInfo.context().translate(-widgetPaintOffset); + paintInfo.context->translate(-widgetPaintOffset); - if (is<FrameView>(*m_widget)) { - FrameView& frameView = downcast<FrameView>(*m_widget); - bool runOverlapTests = !frameView.useSlowRepaintsIfNotOverlapped(); + 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()); @@ -268,6 +272,11 @@ void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) if (paintInfo.phase != PaintPhaseForeground) return; +#if PLATFORM(MAC) + if (style().highlight() != nullAtom && !paintInfo.context->paintingDisabled()) + paintCustomHighlight(paintOffset, style().highlight(), true); +#endif + if (style().hasBorderRadius()) { LayoutRect borderRect = LayoutRect(adjustedPaintOffset, size()); @@ -275,53 +284,53 @@ void RenderWidget::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) return; // Push a clip if we have a border radius, since we want to round the foreground content that gets painted. - paintInfo.context().save(); - FloatRoundedRect roundedInnerRect = FloatRoundedRect(style().getRoundedInnerBorderFor(borderRect, - paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true)); - clipRoundedInnerRect(paintInfo.context(), borderRect, roundedInnerRect); + paintInfo.context->save(); + RoundedRect roundedInnerRect = style().getRoundedInnerBorderFor(borderRect, + paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true); + clipRoundedInnerRect(paintInfo.context, borderRect, roundedInnerRect); } if (m_widget) paintContents(paintInfo, paintOffset); if (style().hasBorderRadius()) - paintInfo.context().restore(); + paintInfo.context->restore(); // Paint a partially transparent wash over selected widgets. if (isSelected() && !document().printing()) { // FIXME: selectionRect() is in absolute, not painting coordinates. - paintInfo.context().fillRect(snappedIntRect(selectionRect()), selectionBackgroundColor()); + paintInfo.context->fillRect(pixelSnappedIntRect(selectionRect()), selectionBackgroundColor(), style().colorSpace()); } if (hasLayer() && layer()->canResize()) - layer()->paintResizer(paintInfo.context(), roundedIntPoint(adjustedPaintOffset), paintInfo.rect); + layer()->paintResizer(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect); } void RenderWidget::setOverlapTestResult(bool isOverlapped) { ASSERT(m_widget); - downcast<FrameView>(*m_widget).setIsOverlapped(isOverlapped); + ASSERT(m_widget->isFrameView()); + toFrameView(m_widget.get())->setIsOverlapped(isOverlapped); } -RenderWidget::ChildWidgetState RenderWidget::updateWidgetPosition() +void RenderWidget::updateWidgetPosition() { if (!m_widget) - return ChildWidgetState::Destroyed; + return; WeakPtr<RenderWidget> weakThis = createWeakPtr(); bool widgetSizeChanged = updateWidgetGeometry(); - if (!weakThis || !m_widget) - return ChildWidgetState::Destroyed; + if (!weakThis) + return; // if the frame size 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 (is<FrameView>(*m_widget)) { - FrameView& frameView = downcast<FrameView>(*m_widget); + if (m_widget->isFrameView()) { + 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 ((widgetSizeChanged || frameView.needsLayout()) && frameView.frame().page()) - frameView.layout(); + if ((widgetSizeChanged || frameView->needsLayout()) && frameView->frame().page()) + frameView->layout(); } - return ChildWidgetState::Valid; } IntRect RenderWidget::windowClipRect() const @@ -345,17 +354,17 @@ RenderWidget* RenderWidget::find(const Widget* widget) bool RenderWidget::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action) { - if (request.allowsChildFrameContent() && is<FrameView>(widget()) && downcast<FrameView>(*widget()).renderView()) { - FrameView& childFrameView = downcast<FrameView>(*widget()); - RenderView& childRoot = *childFrameView.renderView(); + if (request.allowsChildFrameContent() && widget() && widget()->isFrameView() && toFrameView(widget())->renderView()) { + FrameView* childFrameView = toFrameView(widget()); + RenderView* childRoot = childFrameView->renderView(); LayoutPoint adjustedLocation = accumulatedOffset + location(); - LayoutPoint contentOffset = LayoutPoint(borderLeft() + paddingLeft(), borderTop() + paddingTop()) - toIntSize(childFrameView.scrollPosition()); + LayoutPoint contentOffset = LayoutPoint(borderLeft() + paddingLeft(), borderTop() + paddingTop()) - childFrameView->scrollOffset(); HitTestLocation newHitTestLocation(locationInContainer, -adjustedLocation - contentOffset); HitTestRequest newHitTestRequest(request.type() | HitTestRequest::ChildFrameHitTest); HitTestResult childFrameResult(newHitTestLocation); - bool isInsideChildFrame = childRoot.hitTest(newHitTestRequest, newHitTestLocation, childFrameResult); + bool isInsideChildFrame = childRoot->hitTest(newHitTestRequest, newHitTestLocation, childFrameResult); if (newHitTestLocation.isRectBasedTest()) result.append(childFrameResult); @@ -375,6 +384,7 @@ bool RenderWidget::nodeAtPoint(const HitTestRequest& request, HitTestResult& res return inside; } +#if USE(ACCELERATED_COMPOSITING) bool RenderWidget::requiresLayer() const { return RenderReplaced::requiresLayer() || requiresAcceleratedCompositing(); @@ -390,6 +400,7 @@ bool RenderWidget::requiresAcceleratedCompositing() const return false; } +#endif bool RenderWidget::needsPreferredWidthsRecalculation() const { @@ -400,9 +411,9 @@ bool RenderWidget::needsPreferredWidthsRecalculation() const RenderBox* RenderWidget::embeddedContentBox() const { - if (!is<FrameView>(widget())) - return nullptr; - return downcast<FrameView>(*widget()).embeddedContentBox(); + if (!widget() || !widget()->isFrameView()) + return 0; + return toFrameView(widget())->embeddedContentBox(); } } // namespace WebCore |