Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: third_party/WebKit/Source/core/paint/InlineFlowBoxPainter.cpp

Issue 1616643002: Rename LineLayoutPaintShim -> LineLayoutAPIShim (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/InlineFlowBoxPainter.h" 5 #include "core/paint/InlineFlowBoxPainter.h"
6 6
7 #include "core/layout/LayoutBlock.h" 7 #include "core/layout/LayoutBlock.h"
8 #include "core/layout/LayoutInline.h" 8 #include "core/layout/LayoutInline.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/layout/api/LineLayoutAPIShim.h"
10 #include "core/layout/api/LineLayoutBoxModel.h" 11 #include "core/layout/api/LineLayoutBoxModel.h"
11 #include "core/layout/api/SelectionState.h" 12 #include "core/layout/api/SelectionState.h"
12 #include "core/layout/line/InlineFlowBox.h" 13 #include "core/layout/line/InlineFlowBox.h"
13 #include "core/paint/BoxPainter.h" 14 #include "core/paint/BoxPainter.h"
14 #include "core/paint/LineLayoutPaintShim.h"
15 #include "core/paint/PaintInfo.h" 15 #include "core/paint/PaintInfo.h"
16 #include "core/paint/PaintLayer.h" 16 #include "core/paint/PaintLayer.h"
17 #include "platform/graphics/GraphicsContextStateSaver.h" 17 #include "platform/graphics/GraphicsContextStateSaver.h"
18 #include "platform/graphics/paint/DrawingRecorder.h" 18 #include "platform/graphics/paint/DrawingRecorder.h"
19 19
20 namespace blink { 20 namespace blink {
21 21
22 void InlineFlowBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const LayoutUnit lineTop, const LayoutUnit lineBottom) 22 void InlineFlowBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const LayoutUnit lineTop, const LayoutUnit lineBottom)
23 { 23 {
24 ASSERT(!shouldPaintSelfOutline(paintInfo.phase) && !shouldPaintDescendantOut lines(paintInfo.phase)); 24 ASSERT(!shouldPaintSelfOutline(paintInfo.phase) && !shouldPaintDescendantOut lines(paintInfo.phase));
(...skipping 30 matching lines...) Expand all
55 { 55 {
56 // FIXME: This should be a for loop or similar. It's a little non-trivial to do so, however, since the layers need to be 56 // FIXME: This should be a for loop or similar. It's a little non-trivial to do so, however, since the layers need to be
57 // painted in reverse order. 57 // painted in reverse order.
58 if (fillLayer.next()) 58 if (fillLayer.next())
59 paintFillLayers(paintInfo, c, *fillLayer.next(), rect, op); 59 paintFillLayers(paintInfo, c, *fillLayer.next(), rect, op);
60 paintFillLayer(paintInfo, c, fillLayer, rect, op); 60 paintFillLayer(paintInfo, c, fillLayer, rect, op);
61 } 61 }
62 62
63 void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Colo r& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op) 63 void InlineFlowBoxPainter::paintFillLayer(const PaintInfo& paintInfo, const Colo r& c, const FillLayer& fillLayer, const LayoutRect& rect, SkXfermode::Mode op)
64 { 64 {
65 LayoutBoxModelObject* boxModel = toLayoutBoxModelObject(LineLayoutPaintShim: :layoutObjectFrom(m_inlineFlowBox.boxModelObject())); 65 LayoutBoxModelObject* boxModel = toLayoutBoxModelObject(LineLayoutAPIShim::l ayoutObjectFrom(m_inlineFlowBox.boxModelObject()));
66 StyleImage* img = fillLayer.image(); 66 StyleImage* img = fillLayer.image();
67 bool hasFillImage = img && img->canRender(); 67 bool hasFillImage = img && img->canRender();
68 if ((!hasFillImage && !m_inlineFlowBox.lineLayoutItem().style()->hasBorderRa dius()) || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m_inlineFlowBox.parent()) { 68 if ((!hasFillImage && !m_inlineFlowBox.lineLayoutItem().style()->hasBorderRa dius()) || (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m_inlineFlowBox.parent()) {
69 BoxPainter::paintFillLayer(*boxModel, paintInfo, c, fillLayer, rect, Bac kgroundBleedNone, &m_inlineFlowBox, rect.size(), op); 69 BoxPainter::paintFillLayer(*boxModel, paintInfo, c, fillLayer, rect, Bac kgroundBleedNone, &m_inlineFlowBox, rect.size(), op);
70 } else if (m_inlineFlowBox.lineLayoutItem().style()->boxDecorationBreak() == DCLONE) { 70 } else if (m_inlineFlowBox.lineLayoutItem().style()->boxDecorationBreak() == DCLONE) {
71 GraphicsContextStateSaver stateSaver(paintInfo.context); 71 GraphicsContextStateSaver stateSaver(paintInfo.context);
72 paintInfo.context.clip(pixelSnappedIntRect(rect)); 72 paintInfo.context.clip(pixelSnappedIntRect(rect));
73 BoxPainter::paintFillLayer(*boxModel, paintInfo, c, fillLayer, rect, Bac kgroundBleedNone, &m_inlineFlowBox, rect.size(), op); 73 BoxPainter::paintFillLayer(*boxModel, paintInfo, c, fillLayer, rect, Bac kgroundBleedNone, &m_inlineFlowBox, rect.size(), op);
74 } else { 74 } else {
75 // We have a fill image that spans multiple lines. 75 // We have a fill image that spans multiple lines.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 176
177 void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn fo, const LayoutPoint& paintOffset, const LayoutRect& cullRect) 177 void InlineFlowBoxPainter::paintBoxDecorationBackground(const PaintInfo& paintIn fo, const LayoutPoint& paintOffset, const LayoutRect& cullRect)
178 { 178 {
179 ASSERT(paintInfo.phase == PaintPhaseForeground); 179 ASSERT(paintInfo.phase == PaintPhaseForeground);
180 if (m_inlineFlowBox.lineLayoutItem().style()->visibility() != VISIBLE) 180 if (m_inlineFlowBox.lineLayoutItem().style()->visibility() != VISIBLE)
181 return; 181 return;
182 182
183 // You can use p::first-line to specify a background. If so, the root line b oxes for 183 // You can use p::first-line to specify a background. If so, the root line b oxes for
184 // a line may actually have to paint a background. 184 // a line may actually have to paint a background.
185 LayoutObject* inlineFlowBoxLayoutObject = LineLayoutPaintShim::layoutObjectF rom(m_inlineFlowBox.lineLayoutItem()); 185 LayoutObject* inlineFlowBoxLayoutObject = LineLayoutAPIShim::layoutObjectFro m(m_inlineFlowBox.lineLayoutItem());
186 const ComputedStyle* styleToUse = m_inlineFlowBox.lineLayoutItem().style(m_i nlineFlowBox.isFirstLineStyle()); 186 const ComputedStyle* styleToUse = m_inlineFlowBox.lineLayoutItem().style(m_i nlineFlowBox.isFirstLineStyle());
187 bool shouldPaintBoxDecorationBackground; 187 bool shouldPaintBoxDecorationBackground;
188 if (m_inlineFlowBox.parent()) 188 if (m_inlineFlowBox.parent())
189 shouldPaintBoxDecorationBackground = inlineFlowBoxLayoutObject->hasBoxDe corationBackground(); 189 shouldPaintBoxDecorationBackground = inlineFlowBoxLayoutObject->hasBoxDe corationBackground();
190 else 190 else
191 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle() && styleToUse != m_inlineFlowBox.lineLayoutItem().style(); 191 shouldPaintBoxDecorationBackground = m_inlineFlowBox.isFirstLineStyle() && styleToUse != m_inlineFlowBox.lineLayoutItem().style();
192 192
193 if (!shouldPaintBoxDecorationBackground) 193 if (!shouldPaintBoxDecorationBackground)
194 return; 194 return;
195 195
(...skipping 19 matching lines...) Expand all
215 paintBoxShadow(paintInfo, *styleToUse, Normal, adjustedFrameRect); 215 paintBoxShadow(paintInfo, *styleToUse, Normal, adjustedFrameRect);
216 216
217 Color backgroundColor = inlineFlowBoxLayoutObject->resolveColor(*styleToUse, CSSPropertyBackgroundColor); 217 Color backgroundColor = inlineFlowBoxLayoutObject->resolveColor(*styleToUse, CSSPropertyBackgroundColor);
218 paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(), adjustedFrameRect); 218 paintFillLayers(paintInfo, backgroundColor, styleToUse->backgroundLayers(), adjustedFrameRect);
219 paintBoxShadow(paintInfo, *styleToUse, Inset, adjustedFrameRect); 219 paintBoxShadow(paintInfo, *styleToUse, Inset, adjustedFrameRect);
220 220
221 switch (borderPaintingType) { 221 switch (borderPaintingType) {
222 case DontPaintBorders: 222 case DontPaintBorders:
223 break; 223 break;
224 case PaintBordersWithoutClip: 224 case PaintBordersWithoutClip:
225 BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutPaintShim::lay outObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, adjustedFrameRect, m_inlineFlowBox.lineLayoutItem().styleRef(m_inlineFlowBox.isFirstLineStyle()), B ackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), m_inlineFlowBox.in cludeLogicalRightEdge()); 225 BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutAPIShim::layou tObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, adjustedFrameRect, m_ inlineFlowBox.lineLayoutItem().styleRef(m_inlineFlowBox.isFirstLineStyle()), Bac kgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), m_inlineFlowBox.incl udeLogicalRightEdge());
226 break; 226 break;
227 case PaintBordersWithClip: 227 case PaintBordersWithClip:
228 // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right, 228 // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
229 // but it isn't even clear how this should work at all. 229 // but it isn't even clear how this should work at all.
230 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOff set, frameRect.size(), LTR); 230 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOff set, frameRect.size(), LTR);
231 GraphicsContextStateSaver stateSaver(paintInfo.context); 231 GraphicsContextStateSaver stateSaver(paintInfo.context);
232 paintInfo.context.clip(adjustedClipRect); 232 paintInfo.context.clip(adjustedClipRect);
233 BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutPaintShim::lay outObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, imageStripPaintRect , m_inlineFlowBox.lineLayoutItem().styleRef(m_inlineFlowBox.isFirstLineStyle())) ; 233 BoxPainter::paintBorder(*toLayoutBoxModelObject(LineLayoutAPIShim::layou tObjectFrom(m_inlineFlowBox.boxModelObject())), paintInfo, imageStripPaintRect, m_inlineFlowBox.lineLayoutItem().styleRef(m_inlineFlowBox.isFirstLineStyle()));
234 break; 234 break;
235 } 235 }
236 } 236 }
237 237
238 void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi nt& paintOffset) 238 void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoi nt& paintOffset)
239 { 239 {
240 if (m_inlineFlowBox.lineLayoutItem().style()->visibility() != VISIBLE || pai ntInfo.phase != PaintPhaseMask) 240 if (m_inlineFlowBox.lineLayoutItem().style()->visibility() != VISIBLE || pai ntInfo.phase != PaintPhaseMask)
241 return; 241 return;
242 242
243 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); 243 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded();
(...skipping 28 matching lines...) Expand all
272 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); 272 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size());
273 paintFillLayers(paintInfo, Color::transparent, m_inlineFlowBox.lineLayoutIte m().style()->maskLayers(), paintRect, compositeOp); 273 paintFillLayers(paintInfo, Color::transparent, m_inlineFlowBox.lineLayoutIte m().style()->maskLayers(), paintRect, compositeOp);
274 274
275 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(); 275 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender();
276 if (!hasBoxImage || !maskBoxImage->isLoaded()) { 276 if (!hasBoxImage || !maskBoxImage->isLoaded()) {
277 if (pushTransparencyLayer) 277 if (pushTransparencyLayer)
278 paintInfo.context.endLayer(); 278 paintInfo.context.endLayer();
279 return; // Don't paint anything while we wait for the image to load. 279 return; // Don't paint anything while we wait for the image to load.
280 } 280 }
281 281
282 LayoutBoxModelObject* boxModel = toLayoutBoxModelObject(LineLayoutPaintShim: :layoutObjectFrom(m_inlineFlowBox.boxModelObject())); 282 LayoutBoxModelObject* boxModel = toLayoutBoxModelObject(LineLayoutAPIShim::l ayoutObjectFrom(m_inlineFlowBox.boxModelObject()));
283 // The simple case is where we are the only box for this object. In those 283 // The simple case is where we are the only box for this object. In those
284 // cases only a single call to draw is required. 284 // cases only a single call to draw is required.
285 if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) { 285 if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) {
286 BoxPainter::paintNinePieceImage(*boxModel, paintInfo.context, paintRect, m_inlineFlowBox.lineLayoutItem().styleRef(), maskNinePieceImage, compositeOp); 286 BoxPainter::paintNinePieceImage(*boxModel, paintInfo.context, paintRect, m_inlineFlowBox.lineLayoutItem().styleRef(), maskNinePieceImage, compositeOp);
287 } else { 287 } else {
288 // We have a mask image that spans multiple lines. 288 // We have a mask image that spans multiple lines.
289 // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right, 289 // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
290 // but it isn't even clear how this should work at all. 290 // but it isn't even clear how this should work at all.
291 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOff set, frameRect.size(), LTR); 291 LayoutRect imageStripPaintRect = paintRectForImageStrip(adjustedPaintOff set, frameRect.size(), LTR);
292 FloatRect clipRect(clipRectForNinePieceImageStrip(m_inlineFlowBox, maskN inePieceImage, paintRect)); 292 FloatRect clipRect(clipRectForNinePieceImageStrip(m_inlineFlowBox, maskN inePieceImage, paintRect));
(...skipping 25 matching lines...) Expand all
318 rect.setHeight(logicalHeight); 318 rect.setHeight(logicalHeight);
319 } else { 319 } else {
320 rect.setX(logicalTop); 320 rect.setX(logicalTop);
321 rect.setWidth(logicalHeight); 321 rect.setWidth(logicalHeight);
322 } 322 }
323 } 323 }
324 return rect; 324 return rect;
325 } 325 }
326 326
327 } // namespace blink 327 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698