OLD | NEW |
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/api/LineLayoutAPIShim.h" | 7 #include "core/layout/api/LineLayoutAPIShim.h" |
8 #include "core/layout/line/RootInlineBox.h" | 8 #include "core/layout/line/RootInlineBox.h" |
9 #include "core/paint/BoxPainter.h" | 9 #include "core/paint/BoxPainter.h" |
10 #include "core/paint/PaintInfo.h" | 10 #include "core/paint/PaintInfo.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 TextDirection direction) const { | 174 TextDirection direction) const { |
175 // We have a fill/border/mask image that spans multiple lines. | 175 // We have a fill/border/mask image that spans multiple lines. |
176 // We need to adjust the offset by the width of all previous lines. | 176 // We need to adjust the offset by the width of all previous lines. |
177 // Think of background painting on inlines as though you had one long line, a | 177 // Think of background painting on inlines as though you had one long line, a |
178 // single continuous strip. Even though that strip has been broken up across | 178 // single continuous strip. Even though that strip has been broken up across |
179 // multiple lines, you still paint it as though you had one single line. This | 179 // multiple lines, you still paint it as though you had one single line. This |
180 // means each line has to pick up the background where the previous line left | 180 // means each line has to pick up the background where the previous line left |
181 // off. | 181 // off. |
182 LayoutUnit logicalOffsetOnLine; | 182 LayoutUnit logicalOffsetOnLine; |
183 LayoutUnit totalLogicalWidth; | 183 LayoutUnit totalLogicalWidth; |
184 if (direction == LTR) { | 184 if (direction == TextDirection::Ltr) { |
185 for (const InlineFlowBox* curr = m_inlineFlowBox.prevLineBox(); curr; | 185 for (const InlineFlowBox* curr = m_inlineFlowBox.prevLineBox(); curr; |
186 curr = curr->prevLineBox()) | 186 curr = curr->prevLineBox()) |
187 logicalOffsetOnLine += curr->logicalWidth(); | 187 logicalOffsetOnLine += curr->logicalWidth(); |
188 totalLogicalWidth = logicalOffsetOnLine; | 188 totalLogicalWidth = logicalOffsetOnLine; |
189 for (const InlineFlowBox* curr = &m_inlineFlowBox; curr; | 189 for (const InlineFlowBox* curr = &m_inlineFlowBox; curr; |
190 curr = curr->nextLineBox()) | 190 curr = curr->nextLineBox()) |
191 totalLogicalWidth += curr->logicalWidth(); | 191 totalLogicalWidth += curr->logicalWidth(); |
192 } else { | 192 } else { |
193 for (const InlineFlowBox* curr = m_inlineFlowBox.nextLineBox(); curr; | 193 for (const InlineFlowBox* curr = m_inlineFlowBox.nextLineBox(); curr; |
194 curr = curr->nextLineBox()) | 194 curr = curr->nextLineBox()) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 paintInfo, adjustedFrameRect, | 308 paintInfo, adjustedFrameRect, |
309 m_inlineFlowBox.getLineLayoutItem().styleRef( | 309 m_inlineFlowBox.getLineLayoutItem().styleRef( |
310 m_inlineFlowBox.isFirstLineStyle()), | 310 m_inlineFlowBox.isFirstLineStyle()), |
311 BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), | 311 BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), |
312 m_inlineFlowBox.includeLogicalRightEdge()); | 312 m_inlineFlowBox.includeLogicalRightEdge()); |
313 break; | 313 break; |
314 case PaintBordersWithClip: | 314 case PaintBordersWithClip: |
315 // FIXME: What the heck do we do with RTL here? The math we're using is | 315 // FIXME: What the heck do we do with RTL here? The math we're using is |
316 // obviously not right, but it isn't even clear how this should work at | 316 // obviously not right, but it isn't even clear how this should work at |
317 // all. | 317 // all. |
318 LayoutRect imageStripPaintRect = | 318 LayoutRect imageStripPaintRect = paintRectForImageStrip( |
319 paintRectForImageStrip(adjustedPaintOffset, frameRect.size(), LTR); | 319 adjustedPaintOffset, frameRect.size(), TextDirection::Ltr); |
320 GraphicsContextStateSaver stateSaver(paintInfo.context); | 320 GraphicsContextStateSaver stateSaver(paintInfo.context); |
321 paintInfo.context.clip(adjustedClipRect); | 321 paintInfo.context.clip(adjustedClipRect); |
322 BoxPainter::paintBorder( | 322 BoxPainter::paintBorder( |
323 *toLayoutBoxModelObject(LineLayoutAPIShim::layoutObjectFrom( | 323 *toLayoutBoxModelObject(LineLayoutAPIShim::layoutObjectFrom( |
324 m_inlineFlowBox.boxModelObject())), | 324 m_inlineFlowBox.boxModelObject())), |
325 paintInfo, imageStripPaintRect, | 325 paintInfo, imageStripPaintRect, |
326 m_inlineFlowBox.getLineLayoutItem().styleRef( | 326 m_inlineFlowBox.getLineLayoutItem().styleRef( |
327 m_inlineFlowBox.isFirstLineStyle())); | 327 m_inlineFlowBox.isFirstLineStyle())); |
328 break; | 328 break; |
329 } | 329 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // cases only a single call to draw is required. | 394 // cases only a single call to draw is required. |
395 if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) { | 395 if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) { |
396 BoxPainter::paintNinePieceImage( | 396 BoxPainter::paintNinePieceImage( |
397 *boxModel, paintInfo.context, paintRect, | 397 *boxModel, paintInfo.context, paintRect, |
398 m_inlineFlowBox.getLineLayoutItem().styleRef(), maskNinePieceImage, | 398 m_inlineFlowBox.getLineLayoutItem().styleRef(), maskNinePieceImage, |
399 compositeOp); | 399 compositeOp); |
400 } else { | 400 } else { |
401 // We have a mask image that spans multiple lines. | 401 // We have a mask image that spans multiple lines. |
402 // FIXME: What the heck do we do with RTL here? The math we're using is | 402 // FIXME: What the heck do we do with RTL here? The math we're using is |
403 // obviously not right, but it isn't even clear how this should work at all. | 403 // obviously not right, but it isn't even clear how this should work at all. |
404 LayoutRect imageStripPaintRect = | 404 LayoutRect imageStripPaintRect = paintRectForImageStrip( |
405 paintRectForImageStrip(adjustedPaintOffset, frameRect.size(), LTR); | 405 adjustedPaintOffset, frameRect.size(), TextDirection::Ltr); |
406 FloatRect clipRect(clipRectForNinePieceImageStrip( | 406 FloatRect clipRect(clipRectForNinePieceImageStrip( |
407 m_inlineFlowBox, maskNinePieceImage, paintRect)); | 407 m_inlineFlowBox, maskNinePieceImage, paintRect)); |
408 GraphicsContextStateSaver stateSaver(paintInfo.context); | 408 GraphicsContextStateSaver stateSaver(paintInfo.context); |
409 // TODO(chrishtr): this should be pixel-snapped. | 409 // TODO(chrishtr): this should be pixel-snapped. |
410 paintInfo.context.clip(clipRect); | 410 paintInfo.context.clip(clipRect); |
411 BoxPainter::paintNinePieceImage( | 411 BoxPainter::paintNinePieceImage( |
412 *boxModel, paintInfo.context, imageStripPaintRect, | 412 *boxModel, paintInfo.context, imageStripPaintRect, |
413 m_inlineFlowBox.getLineLayoutItem().styleRef(), maskNinePieceImage, | 413 m_inlineFlowBox.getLineLayoutItem().styleRef(), maskNinePieceImage, |
414 compositeOp); | 414 compositeOp); |
415 } | 415 } |
(...skipping 26 matching lines...) Expand all Loading... |
442 rect.setHeight(logicalHeight); | 442 rect.setHeight(logicalHeight); |
443 } else { | 443 } else { |
444 rect.setX(logicalTop); | 444 rect.setX(logicalTop); |
445 rect.setWidth(logicalHeight); | 445 rect.setWidth(logicalHeight); |
446 } | 446 } |
447 } | 447 } |
448 return rect; | 448 return rect; |
449 } | 449 } |
450 | 450 |
451 } // namespace blink | 451 } // namespace blink |
OLD | NEW |