| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 TextDirection direction) const { | 160 TextDirection direction) const { |
| 161 // We have a fill/border/mask image that spans multiple lines. | 161 // We have a fill/border/mask image that spans multiple lines. |
| 162 // We need to adjust the offset by the width of all previous lines. | 162 // We need to adjust the offset by the width of all previous lines. |
| 163 // Think of background painting on inlines as though you had one long line, a | 163 // Think of background painting on inlines as though you had one long line, a |
| 164 // single continuous strip. Even though that strip has been broken up across | 164 // single continuous strip. Even though that strip has been broken up across |
| 165 // multiple lines, you still paint it as though you had one single line. This | 165 // multiple lines, you still paint it as though you had one single line. This |
| 166 // means each line has to pick up the background where the previous line left | 166 // means each line has to pick up the background where the previous line left |
| 167 // off. | 167 // off. |
| 168 LayoutUnit logicalOffsetOnLine; | 168 LayoutUnit logicalOffsetOnLine; |
| 169 LayoutUnit totalLogicalWidth; | 169 LayoutUnit totalLogicalWidth; |
| 170 if (direction == LTR) { | 170 if (direction == TextDirection::Ltr) { |
| 171 for (const InlineFlowBox* curr = m_inlineFlowBox.prevLineBox(); curr; | 171 for (const InlineFlowBox* curr = m_inlineFlowBox.prevLineBox(); curr; |
| 172 curr = curr->prevLineBox()) | 172 curr = curr->prevLineBox()) |
| 173 logicalOffsetOnLine += curr->logicalWidth(); | 173 logicalOffsetOnLine += curr->logicalWidth(); |
| 174 totalLogicalWidth = logicalOffsetOnLine; | 174 totalLogicalWidth = logicalOffsetOnLine; |
| 175 for (const InlineFlowBox* curr = &m_inlineFlowBox; curr; | 175 for (const InlineFlowBox* curr = &m_inlineFlowBox; curr; |
| 176 curr = curr->nextLineBox()) | 176 curr = curr->nextLineBox()) |
| 177 totalLogicalWidth += curr->logicalWidth(); | 177 totalLogicalWidth += curr->logicalWidth(); |
| 178 } else { | 178 } else { |
| 179 for (const InlineFlowBox* curr = m_inlineFlowBox.nextLineBox(); curr; | 179 for (const InlineFlowBox* curr = m_inlineFlowBox.nextLineBox(); curr; |
| 180 curr = curr->nextLineBox()) | 180 curr = curr->nextLineBox()) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 paintInfo, adjustedFrameRect, | 294 paintInfo, adjustedFrameRect, |
| 295 m_inlineFlowBox.getLineLayoutItem().styleRef( | 295 m_inlineFlowBox.getLineLayoutItem().styleRef( |
| 296 m_inlineFlowBox.isFirstLineStyle()), | 296 m_inlineFlowBox.isFirstLineStyle()), |
| 297 BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), | 297 BackgroundBleedNone, m_inlineFlowBox.includeLogicalLeftEdge(), |
| 298 m_inlineFlowBox.includeLogicalRightEdge()); | 298 m_inlineFlowBox.includeLogicalRightEdge()); |
| 299 break; | 299 break; |
| 300 case PaintBordersWithClip: | 300 case PaintBordersWithClip: |
| 301 // FIXME: What the heck do we do with RTL here? The math we're using is | 301 // FIXME: What the heck do we do with RTL here? The math we're using is |
| 302 // obviously not right, but it isn't even clear how this should work at | 302 // obviously not right, but it isn't even clear how this should work at |
| 303 // all. | 303 // all. |
| 304 LayoutRect imageStripPaintRect = | 304 LayoutRect imageStripPaintRect = paintRectForImageStrip( |
| 305 paintRectForImageStrip(adjustedPaintOffset, frameRect.size(), LTR); | 305 adjustedPaintOffset, frameRect.size(), TextDirection::Ltr); |
| 306 GraphicsContextStateSaver stateSaver(paintInfo.context); | 306 GraphicsContextStateSaver stateSaver(paintInfo.context); |
| 307 paintInfo.context.clip(adjustedClipRect); | 307 paintInfo.context.clip(adjustedClipRect); |
| 308 BoxPainter::paintBorder( | 308 BoxPainter::paintBorder( |
| 309 *toLayoutBoxModelObject(LineLayoutAPIShim::layoutObjectFrom( | 309 *toLayoutBoxModelObject(LineLayoutAPIShim::layoutObjectFrom( |
| 310 m_inlineFlowBox.boxModelObject())), | 310 m_inlineFlowBox.boxModelObject())), |
| 311 paintInfo, imageStripPaintRect, | 311 paintInfo, imageStripPaintRect, |
| 312 m_inlineFlowBox.getLineLayoutItem().styleRef( | 312 m_inlineFlowBox.getLineLayoutItem().styleRef( |
| 313 m_inlineFlowBox.isFirstLineStyle())); | 313 m_inlineFlowBox.isFirstLineStyle())); |
| 314 break; | 314 break; |
| 315 } | 315 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 // cases only a single call to draw is required. | 380 // cases only a single call to draw is required. |
| 381 if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) { | 381 if (!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) { |
| 382 BoxPainter::paintNinePieceImage( | 382 BoxPainter::paintNinePieceImage( |
| 383 *boxModel, paintInfo.context, paintRect, | 383 *boxModel, paintInfo.context, paintRect, |
| 384 m_inlineFlowBox.getLineLayoutItem().styleRef(), maskNinePieceImage, | 384 m_inlineFlowBox.getLineLayoutItem().styleRef(), maskNinePieceImage, |
| 385 compositeOp); | 385 compositeOp); |
| 386 } else { | 386 } else { |
| 387 // We have a mask image that spans multiple lines. | 387 // We have a mask image that spans multiple lines. |
| 388 // FIXME: What the heck do we do with RTL here? The math we're using is | 388 // FIXME: What the heck do we do with RTL here? The math we're using is |
| 389 // obviously not right, but it isn't even clear how this should work at all. | 389 // obviously not right, but it isn't even clear how this should work at all. |
| 390 LayoutRect imageStripPaintRect = | 390 LayoutRect imageStripPaintRect = paintRectForImageStrip( |
| 391 paintRectForImageStrip(adjustedPaintOffset, frameRect.size(), LTR); | 391 adjustedPaintOffset, frameRect.size(), TextDirection::Ltr); |
| 392 FloatRect clipRect(clipRectForNinePieceImageStrip( | 392 FloatRect clipRect(clipRectForNinePieceImageStrip( |
| 393 m_inlineFlowBox, maskNinePieceImage, paintRect)); | 393 m_inlineFlowBox, maskNinePieceImage, paintRect)); |
| 394 GraphicsContextStateSaver stateSaver(paintInfo.context); | 394 GraphicsContextStateSaver stateSaver(paintInfo.context); |
| 395 // TODO(chrishtr): this should be pixel-snapped. | 395 // TODO(chrishtr): this should be pixel-snapped. |
| 396 paintInfo.context.clip(clipRect); | 396 paintInfo.context.clip(clipRect); |
| 397 BoxPainter::paintNinePieceImage( | 397 BoxPainter::paintNinePieceImage( |
| 398 *boxModel, paintInfo.context, imageStripPaintRect, | 398 *boxModel, paintInfo.context, imageStripPaintRect, |
| 399 m_inlineFlowBox.getLineLayoutItem().styleRef(), maskNinePieceImage, | 399 m_inlineFlowBox.getLineLayoutItem().styleRef(), maskNinePieceImage, |
| 400 compositeOp); | 400 compositeOp); |
| 401 } | 401 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 428 rect.setHeight(logicalHeight); | 428 rect.setHeight(logicalHeight); |
| 429 } else { | 429 } else { |
| 430 rect.setX(logicalTop); | 430 rect.setX(logicalTop); |
| 431 rect.setWidth(logicalHeight); | 431 rect.setWidth(logicalHeight); |
| 432 } | 432 } |
| 433 } | 433 } |
| 434 return rect; | 434 return rect; |
| 435 } | 435 } |
| 436 | 436 |
| 437 } // namespace blink | 437 } // namespace blink |
| OLD | NEW |