| 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 == TextDirection::Ltr) { | 184 if (direction == TextDirection::kLtr) { |
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 238 } |
| 239 return DontPaintBorders; | 239 return DontPaintBorders; |
| 240 } | 240 } |
| 241 | 241 |
| 242 void InlineFlowBoxPainter::paintBoxDecorationBackground( | 242 void InlineFlowBoxPainter::paintBoxDecorationBackground( |
| 243 const PaintInfo& paintInfo, | 243 const PaintInfo& paintInfo, |
| 244 const LayoutPoint& paintOffset, | 244 const LayoutPoint& paintOffset, |
| 245 const LayoutRect& cullRect) { | 245 const LayoutRect& cullRect) { |
| 246 DCHECK(paintInfo.phase == PaintPhaseForeground); | 246 DCHECK(paintInfo.phase == PaintPhaseForeground); |
| 247 if (m_inlineFlowBox.getLineLayoutItem().style()->visibility() != | 247 if (m_inlineFlowBox.getLineLayoutItem().style()->visibility() != |
| 248 EVisibility::Visible) | 248 EVisibility::kVisible) |
| 249 return; | 249 return; |
| 250 | 250 |
| 251 // You can use p::first-line to specify a background. If so, the root line | 251 // You can use p::first-line to specify a background. If so, the root line |
| 252 // boxes for a line may actually have to paint a background. | 252 // boxes for a line may actually have to paint a background. |
| 253 LayoutObject* inlineFlowBoxLayoutObject = | 253 LayoutObject* inlineFlowBoxLayoutObject = |
| 254 LineLayoutAPIShim::layoutObjectFrom(m_inlineFlowBox.getLineLayoutItem()); | 254 LineLayoutAPIShim::layoutObjectFrom(m_inlineFlowBox.getLineLayoutItem()); |
| 255 const ComputedStyle* styleToUse = m_inlineFlowBox.getLineLayoutItem().style( | 255 const ComputedStyle* styleToUse = m_inlineFlowBox.getLineLayoutItem().style( |
| 256 m_inlineFlowBox.isFirstLineStyle()); | 256 m_inlineFlowBox.isFirstLineStyle()); |
| 257 bool shouldPaintBoxDecorationBackground; | 257 bool shouldPaintBoxDecorationBackground; |
| 258 if (m_inlineFlowBox.parent()) | 258 if (m_inlineFlowBox.parent()) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = paintRectForImageStrip( | 318 LayoutRect imageStripPaintRect = paintRectForImageStrip( |
| 319 adjustedPaintOffset, frameRect.size(), TextDirection::Ltr); | 319 adjustedPaintOffset, frameRect.size(), TextDirection::kLtr); |
| 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 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, | 332 void InlineFlowBoxPainter::paintMask(const PaintInfo& paintInfo, |
| 333 const LayoutPoint& paintOffset) { | 333 const LayoutPoint& paintOffset) { |
| 334 if (m_inlineFlowBox.getLineLayoutItem().style()->visibility() != | 334 if (m_inlineFlowBox.getLineLayoutItem().style()->visibility() != |
| 335 EVisibility::Visible || | 335 EVisibility::kVisible || |
| 336 paintInfo.phase != PaintPhaseMask) | 336 paintInfo.phase != PaintPhaseMask) |
| 337 return; | 337 return; |
| 338 | 338 |
| 339 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); | 339 LayoutRect frameRect = frameRectClampedToLineTopAndBottomIfNeeded(); |
| 340 | 340 |
| 341 // Move x/y to our coordinates. | 341 // Move x/y to our coordinates. |
| 342 LayoutRect localRect(frameRect); | 342 LayoutRect localRect(frameRect); |
| 343 m_inlineFlowBox.flipForWritingMode(localRect); | 343 m_inlineFlowBox.flipForWritingMode(localRect); |
| 344 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 344 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
| 345 | 345 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = paintRectForImageStrip( | 404 LayoutRect imageStripPaintRect = paintRectForImageStrip( |
| 405 adjustedPaintOffset, frameRect.size(), TextDirection::Ltr); | 405 adjustedPaintOffset, frameRect.size(), TextDirection::kLtr); |
| 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 |