Commit 3a4eb7f6 authored by pilgrim@chromium.org's avatar pilgrim@chromium.org

[Line Layout API] Add shim for Paint objects to access underlying LayoutObject

This CL allows us to remove another shim, InlineBox::deprecatedBoxModelObject,
and clears the way for removing all direct LayoutObject access in core/line/.

BUG=499321

Review URL: https://codereview.chromium.org/1310473003

git-svn-id: svn://svn.chromium.org/blink/trunk@201274 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 894692a4
...@@ -1928,6 +1928,7 @@ ...@@ -1928,6 +1928,7 @@
'paint/LayoutObjectDrawingRecorder.h', 'paint/LayoutObjectDrawingRecorder.h',
'paint/LineBoxListPainter.cpp', 'paint/LineBoxListPainter.cpp',
'paint/LineBoxListPainter.h', 'paint/LineBoxListPainter.h',
'paint/LineLayoutPaintShim.h',
'paint/ListItemPainter.cpp', 'paint/ListItemPainter.cpp',
'paint/ListItemPainter.h', 'paint/ListItemPainter.h',
'paint/ListMarkerPainter.cpp', 'paint/ListMarkerPainter.cpp',
......
...@@ -19,6 +19,7 @@ class HitTestLocation; ...@@ -19,6 +19,7 @@ class HitTestLocation;
class LayoutObject; class LayoutObject;
class LineLayoutBox; class LineLayoutBox;
class LineLayoutBoxModel; class LineLayoutBoxModel;
class LineLayoutPaintShim;
enum HitTestFilter; enum HitTestFilter;
...@@ -323,6 +324,8 @@ protected: ...@@ -323,6 +324,8 @@ protected:
private: private:
LayoutObject* m_layoutObject; LayoutObject* m_layoutObject;
friend class LineLayoutPaintShim;
}; };
} // namespace blink } // namespace blink
......
...@@ -271,14 +271,6 @@ public: ...@@ -271,14 +271,6 @@ public:
EVerticalAlign verticalAlign() const { return lineLayoutItem().isText() ? ComputedStyle::initialVerticalAlign() : lineLayoutItem().style(m_bitfields.firstLine())->verticalAlign(); } EVerticalAlign verticalAlign() const { return lineLayoutItem().isText() ? ComputedStyle::initialVerticalAlign() : lineLayoutItem().style(m_bitfields.firstLine())->verticalAlign(); }
// TODO(pilgrim) remove this
LayoutBoxModelObject* deprecatedBoxModelObject() const
{
if (!lineLayoutItem().isText())
return toLayoutBoxModelObject(&layoutObject());
return 0;
}
// Use with caution! The type is not checked! // Use with caution! The type is not checked!
LineLayoutBoxModel boxModelObject() const LineLayoutBoxModel boxModelObject() const
{ {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "core/layout/line/InlineFlowBox.h" #include "core/layout/line/InlineFlowBox.h"
#include "core/paint/BoxPainter.h" #include "core/paint/BoxPainter.h"
#include "core/paint/DeprecatedPaintLayer.h" #include "core/paint/DeprecatedPaintLayer.h"
#include "core/paint/LineLayoutPaintShim.h"
#include "core/paint/PaintInfo.h" #include "core/paint/PaintInfo.h"
#include "platform/graphics/GraphicsContextStateSaver.h" #include "platform/graphics/GraphicsContextStateSaver.h"
#include "platform/graphics/paint/DrawingRecorder.h" #include "platform/graphics/paint/DrawingRecorder.h"
...@@ -102,15 +103,16 @@ void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col ...@@ -102,15 +103,16 @@ void InlineFlowBoxPainter::paintFillLayers(const PaintInfo& paintInfo, const Col
void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op)
{ {
LayoutBoxModelObject* boxModel = toLayoutBoxModelObject(LineLayoutPaintShim::layoutObjectFrom(m_inlineFlowBox.boxModelObject()));
StyleImage* img = fillLayer.image(); StyleImage* img = fillLayer.image();
bool hasFillImage = img && img->canRender(m_inlineFlowBox.layoutObject(), m_inlineFlowBox.layoutObject().style()->effectiveZoom()); bool hasFillImage = img && img->canRender(m_inlineFlowBox.layoutObject(), m_inlineFlowBox.layoutObject().style()->effectiveZoom());
if ((!hasFillImage && !m_inlineFlowBox.layoutObject().style()->hasBorderRadius()) || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m_inlineFlowBox.parent()) { if ((!hasFillImage && !m_inlineFlowBox.layoutObject().style()->hasBorderRadius()) || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m_inlineFlowBox.parent()) {
BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.deprecatedBoxModelObject(), paintInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(), op); BoxPainter::paintFillLayerExtended(*boxModel, paintInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(), op);
} else if (m_inlineFlowBox.layoutObject().style()->boxDecorationBreak() == DCLONE) { } else if (m_inlineFlowBox.layoutObject().style()->boxDecorationBreak() == DCLONE) {
GraphicsContextStateSaver stateSaver(*paintInfo.context); GraphicsContextStateSaver stateSaver(*paintInfo.context);
// TODO(chrishtr): this should be pixel-snapped. // TODO(chrishtr): this should be pixel-snapped.
paintInfo.context->clip(FloatRect(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.width(), m_inlineFlowBox.height()))); paintInfo.context->clip(FloatRect(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.width(), m_inlineFlowBox.height())));
BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.deprecatedBoxModelObject(), paintInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(), op); BoxPainter::paintFillLayerExtended(*boxModel, paintInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(), op);
} else { } else {
// We have a fill image that spans multiple lines. // We have a fill image that spans multiple lines.
// FIXME: frameSize ought to be the same as rect.size(). // FIXME: frameSize ought to be the same as rect.size().
...@@ -118,7 +120,7 @@ void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Colo ...@@ -118,7 +120,7 @@ void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Colo
LayoutRect imageStripPaintRect = paintRectForImageStrip(rect.location(), frameSize, m_inlineFlowBox.layoutObject().style()->direction()); LayoutRect imageStripPaintRect = paintRectForImageStrip(rect.location(), frameSize, m_inlineFlowBox.layoutObject().style()->direction());
GraphicsContextStateSaver stateSaver(*paintInfo.context); GraphicsContextStateSaver stateSaver(*paintInfo.context);
paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.width(), m_inlineFlowBox.height())); paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.width(), m_inlineFlowBox.height()));
BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.deprecatedBoxModelObject(), paintInfo, c, fillLayer, imageStripPaintRect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(), op); BoxPainter::paintFillLayerExtended(*boxModel, paintInfo, c, fillLayer, imageStripPaintRect, BackgroundBleedNone, &m_inlineFlowBox, rect.size(), op);
} }
} }
...@@ -262,8 +264,7 @@ void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn ...@@ -262,8 +264,7 @@ void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn
case DontPaintBorders: case DontPaintBorders:
break; break;
case PaintBordersWithoutClip: case PaintBordersWithoutClip:
BoxPainter::paintBorder(*m_inlineFlowBox.deprecatedBoxModelObject(), paintInfo, adjustedFrameRect, m_inlineFlowBox.layoutObject().styleRef(m_inlineFlowBox.isFirstLineStyle()), BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutPaintShim::layoutObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, adjustedFrameRect, m_inlineFlowBox.layoutObject().styleRef(m_inlineFlowBox.isFirstLineStyle()), BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), m_inlineFlowBox.includeLogicalRightEdge());
BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), m_inlineFlowBox.includeLogicalRightEdge());
break; break;
case PaintBordersWithClip: case PaintBordersWithClip:
// FIXME: What the heck do we do with RTL here? The math we're using is obviously not right, // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
...@@ -272,7 +273,7 @@ void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn ...@@ -272,7 +273,7 @@ void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn
GraphicsContextStateSaver stateSaver(*paintInfo.context); GraphicsContextStateSaver stateSaver(*paintInfo.context);
// TODO(chrishtr): this should be pixel-snapped. // TODO(chrishtr): this should be pixel-snapped.
paintInfo.context->clip(FloatRect(adjustedClipRect)); paintInfo.context->clip(FloatRect(adjustedClipRect));
BoxPainter::paintBorder(*m_inlineFlowBox.deprecatedBoxModelObject(), paintInfo, imageStripPaintRect, m_inlineFlowBox.layoutObject().styleRef(m_inlineFlowBox.isFirstLineStyle())); BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutPaintShim::layoutObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, imageStripPaintRect, m_inlineFlowBox.layoutObject().styleRef(m_inlineFlowBox.isFirstLineStyle()));
break; break;
} }
} }
...@@ -321,10 +322,11 @@ void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi ...@@ -321,10 +322,11 @@ void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi
return; // Don't paint anything while we wait for the image to load. return; // Don't paint anything while we wait for the image to load.
} }
LayoutBoxModelObject* boxModel = toLayoutBoxModelObject(LineLayoutPaintShim::layoutObjectFrom(m_inlineFlowBox.boxModelObject()));
// The simple case is where we are the only box for this object. In those // The simple case is where we are the only box for this object. In those
// cases only a single call to draw is required. // cases only a single call to draw is required.
if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) { if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) {
BoxPainter::paintNinePieceImage(*m_inlineFlowBox.deprecatedBoxModelObject(), paintInfo.context, paintRect, m_inlineFlowBox.layoutObject().styleRef(), maskNinePieceImage, compositeOp); BoxPainter::paintNinePieceImage(*boxModel, paintInfo.context, paintRect, m_inlineFlowBox.layoutObject().styleRef(), maskNinePieceImage, compositeOp);
} else { } else {
// We have a mask image that spans multiple lines. // We have a mask image that spans multiple lines.
// FIXME: What the heck do we do with RTL here? The math we're using is obviously not right, // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
...@@ -334,7 +336,7 @@ void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi ...@@ -334,7 +336,7 @@ void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi
GraphicsContextStateSaver stateSaver(*paintInfo.context); GraphicsContextStateSaver stateSaver(*paintInfo.context);
// TODO(chrishtr): this should be pixel-snapped. // TODO(chrishtr): this should be pixel-snapped.
paintInfo.context->clip(clipRect); paintInfo.context->clip(clipRect);
BoxPainter::paintNinePieceImage(*m_inlineFlowBox.deprecatedBoxModelObject(), paintInfo.context, imageStripPaintRect, m_inlineFlowBox.layoutObject().styleRef(), maskNinePieceImage, compositeOp); BoxPainter::paintNinePieceImage(*boxModel, paintInfo.context, imageStripPaintRect, m_inlineFlowBox.layoutObject().styleRef(), maskNinePieceImage, compositeOp);
} }
if (pushTransparencyLayer) if (pushTransparencyLayer)
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LineLayoutPaintShim_h
#define LineLayoutPaintShim_h
#include "core/layout/api/LineLayoutItem.h"
namespace blink {
class LayoutObject;
// TODO(pilgrim): Remove this kludge once Paint objects have a real API and no longer need access to the underlying LayoutObject.
class LineLayoutPaintShim {
public:
static LayoutObject* layoutObjectFrom(LineLayoutItem item)
{
return item.layoutObject();
}
};
} // namespace blink
#endif // LineLayoutPaintShim_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment