From bd590c7b0525ad90a53b5c6a34d731f9b7bcaeba Mon Sep 17 00:00:00 2001 From: Ojan Vafai Date: Sun, 1 Feb 2015 20:37:32 -0800 Subject: [PATCH] Remove mask painting. Now that we don't have -webkit-mask-*, this is dead code. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/886263003 --- engine/core/rendering/InlineBox.cpp | 3 -- engine/core/rendering/InlineFlowBox.cpp | 50 ------------------------ engine/core/rendering/InlineFlowBox.h | 1 - engine/core/rendering/PaintPhase.h | 1 - engine/core/rendering/RenderBlock.cpp | 9 +---- engine/core/rendering/RenderBox.cpp | 10 ----- engine/core/rendering/RenderBox.h | 1 - engine/core/rendering/RenderLayer.cpp | 18 --------- engine/core/rendering/RenderLayer.h | 2 - engine/core/rendering/RenderReplaced.cpp | 5 --- 10 files changed, 1 insertion(+), 99 deletions(-) diff --git a/engine/core/rendering/InlineBox.cpp b/engine/core/rendering/InlineBox.cpp index e2ab8dc3e..585ef5e86 100644 --- a/engine/core/rendering/InlineBox.cpp +++ b/engine/core/rendering/InlineBox.cpp @@ -193,9 +193,6 @@ void InlineBox::adjustPosition(float dx, float dy) void InlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/) { - if (paintInfo.phase == PaintPhaseMask) - return; - LayoutPoint childPoint = paintOffset; RenderBlock::paintAsInlineBlock(&renderer(), paintInfo, childPoint); } diff --git a/engine/core/rendering/InlineFlowBox.cpp b/engine/core/rendering/InlineFlowBox.cpp index 0f713dee0..f4d9a5e22 100644 --- a/engine/core/rendering/InlineFlowBox.cpp +++ b/engine/core/rendering/InlineFlowBox.cpp @@ -997,11 +997,6 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) return; - if (paintInfo.phase == PaintPhaseMask) { - paintMask(paintInfo, paintOffset); - return; - } - paintBoxDecorationBackground(paintInfo, paintOffset); for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { @@ -1168,51 +1163,6 @@ void InlineFlowBox::paintBoxDecorationBackground(PaintInfo& paintInfo, const Lay } } -void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffset) -{ - // Pixel snap mask painting. - LayoutRect frameRect = roundedFrameRect(); - - // Move x/y to our coordinates. - LayoutRect localRect(frameRect); - LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); - - const NinePieceImage& maskNinePieceImage = renderer().style()->maskBoxImage(); - StyleImage* maskBoxImage = renderer().style()->maskBoxImage().image(); - - LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); - paintFillLayers(paintInfo, Color::transparent, renderer().style()->maskLayers(), paintRect); - - bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer()); - if (!hasBoxImage || !maskBoxImage->isLoaded()) { - return; // Don't paint anything while we wait for the image to load. - } - - // The simple case is where we are the only box for this object. In those - // cases only a single call to draw is required. - if (!prevLineBox() && !nextLineBox()) { - boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(adjustedPaintOffset, frameRect.size()), renderer().style(), maskNinePieceImage); - } else { - // We have a mask image that spans multiple lines. - // We need to adjust _tx and _ty by the width of all previous lines. - LayoutUnit logicalOffsetOnLine = 0; - for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox()) - logicalOffsetOnLine += curr->logicalWidth(); - LayoutUnit totalLogicalWidth = logicalOffsetOnLine; - for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) - totalLogicalWidth += curr->logicalWidth(); - LayoutUnit stripX = adjustedPaintOffset.x() - logicalOffsetOnLine; - LayoutUnit stripY = adjustedPaintOffset.y(); - LayoutUnit stripWidth = totalLogicalWidth; - LayoutUnit stripHeight = frameRect.height(); - - LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePieceImage, paintRect); - GraphicsContextStateSaver stateSaver(*paintInfo.context); - paintInfo.context->clip(clipRect); - boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer().style(), maskNinePieceImage); - } -} - InlineBox* InlineFlowBox::firstLeafChild() const { InlineBox* leaf = 0; diff --git a/engine/core/rendering/InlineFlowBox.h b/engine/core/rendering/InlineFlowBox.h index b4e44de07..81cf85381 100644 --- a/engine/core/rendering/InlineFlowBox.h +++ b/engine/core/rendering/InlineFlowBox.h @@ -291,7 +291,6 @@ public: private: void paintBoxDecorationBackground(PaintInfo&, const LayoutPoint&); - void paintMask(PaintInfo&, const LayoutPoint&); void paintFillLayers(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&); void paintFillLayer(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&); void paintBoxShadow(const PaintInfo&, RenderStyle*, ShadowStyle, const LayoutRect&); diff --git a/engine/core/rendering/PaintPhase.h b/engine/core/rendering/PaintPhase.h index f83237680..590504900 100644 --- a/engine/core/rendering/PaintPhase.h +++ b/engine/core/rendering/PaintPhase.h @@ -39,7 +39,6 @@ namespace blink { enum PaintPhase { PaintPhaseForeground, - PaintPhaseMask, }; } // namespace blink diff --git a/engine/core/rendering/RenderBlock.cpp b/engine/core/rendering/RenderBlock.cpp index 34711bfaf..2da944eae 100644 --- a/engine/core/rendering/RenderBlock.cpp +++ b/engine/core/rendering/RenderBlock.cpp @@ -501,9 +501,7 @@ void RenderBlock::paintChildAsInlineBlock(RenderBox* child, PaintInfo& paintInfo void RenderBlock::paintAsInlineBlock(RenderObject* renderer, PaintInfo& paintInfo, const LayoutPoint& childPoint) { - // FIXME(sky): Why don't masks go down this path? - if (paintInfo.phase == PaintPhaseMask) - return; + // FIXME(sky): Remove this function. renderer->paint(paintInfo, childPoint); } @@ -538,11 +536,6 @@ void RenderBlock::paintCarets(PaintInfo& paintInfo, const LayoutPoint& paintOffs void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) { - if (paintInfo.phase == PaintPhaseMask) { - paintMask(paintInfo, paintOffset); - return; - } - if (hasBoxDecorationBackground()) paintBoxDecorationBackground(paintInfo, paintOffset); diff --git a/engine/core/rendering/RenderBox.cpp b/engine/core/rendering/RenderBox.cpp index e25356e32..a7649a5bd 100644 --- a/engine/core/rendering/RenderBox.cpp +++ b/engine/core/rendering/RenderBox.cpp @@ -499,13 +499,6 @@ bool RenderBox::backgroundHasOpaqueTopLayer() const return false; } -void RenderBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffset) -{ - LayoutRect paintRect = LayoutRect(paintOffset, size()); - paintFillLayers(paintInfo, Color::transparent, style()->maskLayers(), paintRect, BackgroundBleedNone); - paintNinePieceImage(paintInfo.context, paintRect, style(), style()->maskBoxImage()); -} - void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer& fillLayer, const LayoutRect& rect, BackgroundBleedAvoidance bleedAvoidance, RenderObject* backgroundObject) { @@ -568,9 +561,6 @@ void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const bool RenderBox::pushContentsClip(PaintInfo& paintInfo, const LayoutPoint& accumulatedOffset, ContentsClipBehavior contentsClipBehavior) { - if (paintInfo.phase == PaintPhaseMask) - return false; - bool isOverflowClip = hasOverflowClip() && !layer()->isSelfPaintingLayer(); if (!isOverflowClip) return false; diff --git a/engine/core/rendering/RenderBox.h b/engine/core/rendering/RenderBox.h index 7f82d6390..19f73b793 100644 --- a/engine/core/rendering/RenderBox.h +++ b/engine/core/rendering/RenderBox.h @@ -381,7 +381,6 @@ public: virtual void paintObject(PaintInfo&, const LayoutPoint&) { ASSERT_NOT_REACHED(); } virtual void paintBoxDecorationBackground(PaintInfo&, const LayoutPoint&); - virtual void paintMask(PaintInfo&, const LayoutPoint&); // Called when a positioned object moves but doesn't necessarily change size. A simplified layout is attempted // that just updates the object's position. If the size does change, the object remains dirty. diff --git a/engine/core/rendering/RenderLayer.cpp b/engine/core/rendering/RenderLayer.cpp index 4c3996eb5..bb03e92a2 100644 --- a/engine/core/rendering/RenderLayer.cpp +++ b/engine/core/rendering/RenderLayer.cpp @@ -950,9 +950,6 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti // Make sure that we now use the original transparency context. ASSERT(transparencyLayerContext == context); - if (shouldPaintContent && renderer()->hasMask()) - paintMask(context, localPaintingInfo, layerLocation, backgroundRect); - // End our transparency layer if (haveTransparency && m_usedTransparency) { context->endLayer(); @@ -1027,21 +1024,6 @@ void RenderLayer::paintForeground(GraphicsContext* context, GraphicsContext* tra restoreClip(context, localPaintingInfo.paintDirtyRect, layerForegroundRect); } -void RenderLayer::paintMask(GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, - LayoutPoint& layerLocation, ClipRect& layerBackgroundRect) -{ - if (localPaintingInfo.clipToDirtyRect) - clipToRect(localPaintingInfo, context, layerBackgroundRect, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self. - - // Paint the mask. - // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. - PaintInfo paintInfo(context, pixelSnappedIntRect(layerBackgroundRect.rect()), PaintPhaseMask, localPaintingInfo.rootLayer->renderer()); - renderer()->paint(paintInfo, layerLocation); - - if (localPaintingInfo.clipToDirtyRect) - restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRect); -} - static inline LayoutRect frameVisibleRect(RenderObject* renderer) { FrameView* frameView = renderer->document().view(); diff --git a/engine/core/rendering/RenderLayer.h b/engine/core/rendering/RenderLayer.h index 45f35b6a5..ef2719274 100644 --- a/engine/core/rendering/RenderLayer.h +++ b/engine/core/rendering/RenderLayer.h @@ -289,8 +289,6 @@ private: void paintForeground(GraphicsContext*, GraphicsContext* transparencyLayerContext, const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo&, LayoutPoint& layerLocation, ClipRect& layerForegroundRect); - void paintMask(GraphicsContext*, const LayerPaintingInfo&, - LayoutPoint& layerLocation, ClipRect& layerBackgroundRect); RenderLayer* hitTestLayer(RenderLayer* rootLayer, RenderLayer* containerLayer, const HitTestRequest& request, HitTestResult& result, const LayoutRect& hitTestRect, const HitTestLocation&, bool appliedTransform, diff --git a/engine/core/rendering/RenderReplaced.cpp b/engine/core/rendering/RenderReplaced.cpp index 2643155cd..2a60b8f56 100644 --- a/engine/core/rendering/RenderReplaced.cpp +++ b/engine/core/rendering/RenderReplaced.cpp @@ -93,11 +93,6 @@ void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) LayoutPoint adjustedPaintOffset = paintOffset + location(); - if (paintInfo.phase == PaintPhaseMask) { - paintMask(paintInfo, adjustedPaintOffset); - return; - } - if (hasBoxDecorationBackground()) paintBoxDecorationBackground(paintInfo, adjustedPaintOffset); -- GitLab