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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/BlockPainter.h" | 6 #include "core/paint/BlockPainter.h" |
7 | 7 |
8 #include "core/editing/Caret.h" | 8 #include "core/editing/Caret.h" |
9 #include "core/editing/FrameSelection.h" | 9 #include "core/editing/FrameSelection.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (!child->hasSelfPaintingLayer() && !child->isFloating()) | 102 if (!child->hasSelfPaintingLayer() && !child->isFloating()) |
103 paintAsInlineBlock(child, paintInfo, childPoint); | 103 paintAsInlineBlock(child, paintInfo, childPoint); |
104 } | 104 } |
105 | 105 |
106 void BlockPainter::paintInlineBox(InlineBox& inlineBox, PaintInfo& paintInfo, co
nst LayoutPoint& paintOffset) | 106 void BlockPainter::paintInlineBox(InlineBox& inlineBox, PaintInfo& paintInfo, co
nst LayoutPoint& paintOffset) |
107 { | 107 { |
108 if (!paintInfo.shouldPaintWithinRoot(&inlineBox.renderer()) || (paintInfo.ph
ase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)) | 108 if (!paintInfo.shouldPaintWithinRoot(&inlineBox.renderer()) || (paintInfo.ph
ase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)) |
109 return; | 109 return; |
110 | 110 |
111 LayoutPoint childPoint = paintOffset; | 111 LayoutPoint childPoint = paintOffset; |
112 if (inlineBox.parent()->renderer().style()->isFlippedBlocksWritingMode()) //
Faster than calling containingBlock(). | 112 if (inlineBox.parent()->renderer().style()->slowIsFlippedBlocksWritingMode()
) // Faster than calling containingBlock(). |
113 childPoint = inlineBox.renderer().containingBlock()->flipForWritingModeF
orChild(&toRenderBox(inlineBox.renderer()), childPoint); | 113 childPoint = inlineBox.renderer().containingBlock()->flipForWritingModeF
orChild(&toRenderBox(inlineBox.renderer()), childPoint); |
114 | 114 |
115 paintAsInlineBlock(&inlineBox.renderer(), paintInfo, childPoint); | 115 paintAsInlineBlock(&inlineBox.renderer(), paintInfo, childPoint); |
116 } | 116 } |
117 | 117 |
118 void BlockPainter::paintAsInlineBlock(RenderObject* renderer, PaintInfo& paintIn
fo, const LayoutPoint& childPoint) | 118 void BlockPainter::paintAsInlineBlock(RenderObject* renderer, PaintInfo& paintIn
fo, const LayoutPoint& childPoint) |
119 { | 119 { |
120 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection) | 120 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase
Selection) |
121 return; | 121 return; |
122 | 122 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 LayoutUnit ruleRight = m_renderBlock.isHorizontalWritingMode() ?
ruleLeft + ruleThickness : ruleLeft + m_renderBlock.contentWidth(); | 324 LayoutUnit ruleRight = m_renderBlock.isHorizontalWritingMode() ?
ruleLeft + ruleThickness : ruleLeft + m_renderBlock.contentWidth(); |
325 LayoutUnit ruleTop = m_renderBlock.isHorizontalWritingMode() ? p
aintOffset.y() + m_renderBlock.borderTop() + m_renderBlock.paddingTop() : paintO
ffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd; | 325 LayoutUnit ruleTop = m_renderBlock.isHorizontalWritingMode() ? p
aintOffset.y() + m_renderBlock.borderTop() + m_renderBlock.paddingTop() : paintO
ffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd; |
326 LayoutUnit ruleBottom = m_renderBlock.isHorizontalWritingMode()
? ruleTop + m_renderBlock.contentHeight() : ruleTop + ruleThickness; | 326 LayoutUnit ruleBottom = m_renderBlock.isHorizontalWritingMode()
? ruleTop + m_renderBlock.contentHeight() : ruleTop + ruleThickness; |
327 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule
Left, ruleTop, ruleRight, ruleBottom); | 327 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule
Left, ruleTop, ruleRight, ruleBottom); |
328 ObjectPainter::drawLineForBoxSide(paintInfo.context, pixelSnappe
dRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnapp
edRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); | 328 ObjectPainter::drawLineForBoxSide(paintInfo.context, pixelSnappe
dRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnapp
edRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); |
329 } | 329 } |
330 | 330 |
331 ruleLogicalLeft = currLogicalLeftOffset; | 331 ruleLogicalLeft = currLogicalLeftOffset; |
332 } | 332 } |
333 } else { | 333 } else { |
334 bool topToBottom = !m_renderBlock.style()->isFlippedBlocksWritingMode(); | 334 bool topToBottom = !m_renderBlock.style()->slowIsFlippedBlocksWritingMod
e(); |
335 LayoutUnit ruleLeft = m_renderBlock.isHorizontalWritingMode() | 335 LayoutUnit ruleLeft = m_renderBlock.isHorizontalWritingMode() |
336 ? m_renderBlock.borderLeft() + m_renderBlock.paddingLeft() | 336 ? m_renderBlock.borderLeft() + m_renderBlock.paddingLeft() |
337 : colGap / 2 - colGap - ruleThickness / 2 + m_renderBlock.borderBefo
re() + m_renderBlock.paddingBefore(); | 337 : colGap / 2 - colGap - ruleThickness / 2 + m_renderBlock.borderBefo
re() + m_renderBlock.paddingBefore(); |
338 LayoutUnit ruleWidth = m_renderBlock.isHorizontalWritingMode() ? m_rende
rBlock.contentWidth() : ruleThickness; | 338 LayoutUnit ruleWidth = m_renderBlock.isHorizontalWritingMode() ? m_rende
rBlock.contentWidth() : ruleThickness; |
339 LayoutUnit ruleTop = m_renderBlock.isHorizontalWritingMode() | 339 LayoutUnit ruleTop = m_renderBlock.isHorizontalWritingMode() |
340 ? colGap / 2 - colGap - ruleThickness / 2 + m_renderBlock.borderBefo
re() + m_renderBlock.paddingBefore() | 340 ? colGap / 2 - colGap - ruleThickness / 2 + m_renderBlock.borderBefo
re() + m_renderBlock.paddingBefore() |
341 : m_renderBlock.borderStart() + m_renderBlock.paddingStart(); | 341 : m_renderBlock.borderStart() + m_renderBlock.paddingStart(); |
342 LayoutUnit ruleHeight = m_renderBlock.isHorizontalWritingMode() ? ruleTh
ickness : m_renderBlock.contentHeight(); | 342 LayoutUnit ruleHeight = m_renderBlock.isHorizontalWritingMode() ? ruleTh
ickness : m_renderBlock.contentHeight(); |
343 LayoutRect ruleRect(ruleLeft, ruleTop, ruleWidth, ruleHeight); | 343 LayoutRect ruleRect(ruleLeft, ruleTop, ruleWidth, ruleHeight); |
344 | 344 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 411 |
412 // Adjust our x and y when painting. | 412 // Adjust our x and y when painting. |
413 LayoutPoint adjustedPaintOffset = paintOffset + offset; | 413 LayoutPoint adjustedPaintOffset = paintOffset + offset; |
414 if (paintingFloats) | 414 if (paintingFloats) |
415 m_renderBlock.paintFloats(info, adjustedPaintOffset, paintInfo.p
hase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip); | 415 m_renderBlock.paintFloats(info, adjustedPaintOffset, paintInfo.p
hase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip); |
416 else | 416 else |
417 paintContents(info, adjustedPaintOffset); | 417 paintContents(info, adjustedPaintOffset); |
418 } | 418 } |
419 | 419 |
420 LayoutUnit blockDelta = (m_renderBlock.isHorizontalWritingMode() ? colRe
ct.height() : colRect.width()); | 420 LayoutUnit blockDelta = (m_renderBlock.isHorizontalWritingMode() ? colRe
ct.height() : colRect.width()); |
421 if (m_renderBlock.style()->isFlippedBlocksWritingMode()) | 421 if (m_renderBlock.style()->slowIsFlippedBlocksWritingMode()) |
422 currLogicalTopOffset += blockDelta; | 422 currLogicalTopOffset += blockDelta; |
423 else | 423 else |
424 currLogicalTopOffset -= blockDelta; | 424 currLogicalTopOffset -= blockDelta; |
425 } | 425 } |
426 } | 426 } |
427 | 427 |
428 void BlockPainter::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 428 void BlockPainter::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
429 { | 429 { |
430 // Avoid painting descendants of the root element when stylesheets haven't l
oaded. This eliminates FOUC. | 430 // Avoid painting descendants of the root element when stylesheets haven't l
oaded. This eliminates FOUC. |
431 // It's ok not to draw, because later on, when all the stylesheets do load,
styleResolverChanged() on the Document | 431 // It's ok not to draw, because later on, when all the stylesheets do load,
styleResolverChanged() on the Document |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 RenderBlock* block = flow->containingBlock(); | 512 RenderBlock* block = flow->containingBlock(); |
513 for ( ; block && block != &m_renderBlock; block = block->containingBlock
()) | 513 for ( ; block && block != &m_renderBlock; block = block->containingBlock
()) |
514 accumulatedPaintOffset.moveBy(block->location()); | 514 accumulatedPaintOffset.moveBy(block->location()); |
515 ASSERT(block); | 515 ASSERT(block); |
516 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); | 516 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 | 520 |
521 } // namespace blink | 521 } // namespace blink |
OLD | NEW |