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/InlineFlowBoxPainter.h" | 6 #include "core/paint/InlineFlowBoxPainter.h" |
7 | 7 |
8 #include "core/layout/LayoutBlock.h" | 8 #include "core/layout/LayoutBlock.h" |
9 #include "core/layout/LayoutInline.h" | 9 #include "core/layout/LayoutInline.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 110 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
111 // TODO(chrishtr): this should be pixel-snapped. | 111 // TODO(chrishtr): this should be pixel-snapped. |
112 paintInfo.context->clip(FloatRect(LayoutRect(rect.x(), rect.y(), m_inlin
eFlowBox.width(), m_inlineFlowBox.height()))); | 112 paintInfo.context->clip(FloatRect(LayoutRect(rect.x(), rect.y(), m_inlin
eFlowBox.width(), m_inlineFlowBox.height()))); |
113 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.deprecatedBoxModelOb
ject(), paintInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, re
ct.size(), op); | 113 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.deprecatedBoxModelOb
ject(), paintInfo, c, fillLayer, rect, BackgroundBleedNone, &m_inlineFlowBox, re
ct.size(), op); |
114 } else { | 114 } else { |
115 // We have a fill image that spans multiple lines. | 115 // We have a fill image that spans multiple lines. |
116 // FIXME: frameSize ought to be the same as rect.size(). | 116 // FIXME: frameSize ought to be the same as rect.size(). |
117 LayoutSize frameSize(m_inlineFlowBox.width(), m_inlineFlowBox.height()); | 117 LayoutSize frameSize(m_inlineFlowBox.width(), m_inlineFlowBox.height()); |
118 LayoutRect imageStripPaintRect = paintRectForImageStrip(rect.location(),
frameSize, m_inlineFlowBox.layoutObject().style()->direction()); | 118 LayoutRect imageStripPaintRect = paintRectForImageStrip(rect.location(),
frameSize, m_inlineFlowBox.layoutObject().style()->direction()); |
119 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 119 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
120 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), m_inlineFlowBox.w
idth(), m_inlineFlowBox.height())); | 120 // TODO(chrishtr): this should likely be pixel-snapped. |
| 121 paintInfo.context->clip(FloatRect(LayoutRect(rect.x(), rect.y(), m_inlin
eFlowBox.width(), m_inlineFlowBox.height()))); |
121 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.deprecatedBoxModelOb
ject(), paintInfo, c, fillLayer, imageStripPaintRect, BackgroundBleedNone, &m_in
lineFlowBox, rect.size(), op); | 122 BoxPainter::paintFillLayerExtended(*m_inlineFlowBox.deprecatedBoxModelOb
ject(), paintInfo, c, fillLayer, imageStripPaintRect, BackgroundBleedNone, &m_in
lineFlowBox, rect.size(), op); |
122 } | 123 } |
123 } | 124 } |
124 | 125 |
125 void InlineFlowBoxPainter::paintBoxShadow(const PaintInfo& info, const ComputedS
tyle& s, ShadowStyle shadowStyle, const LayoutRect& paintRect) | 126 void InlineFlowBoxPainter::paintBoxShadow(const PaintInfo& info, const ComputedS
tyle& s, ShadowStyle shadowStyle, const LayoutRect& paintRect) |
126 { | 127 { |
127 if ((!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m
_inlineFlowBox.parent()) { | 128 if ((!m_inlineFlowBox.prevLineBox() && !m_inlineFlowBox.nextLineBox()) || !m
_inlineFlowBox.parent()) { |
128 BoxPainter::paintBoxShadow(info, paintRect, s, shadowStyle); | 129 BoxPainter::paintBoxShadow(info, paintRect, s, shadowStyle); |
129 } else { | 130 } else { |
130 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't | 131 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't |
131 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines | 132 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines |
132 BoxPainter::paintBoxShadow(info, paintRect, s, shadowStyle, m_inlineFlow
Box.includeLogicalLeftEdge(), m_inlineFlowBox.includeLogicalRightEdge()); | 133 BoxPainter::paintBoxShadow(info, paintRect, s, shadowStyle, m_inlineFlow
Box.includeLogicalLeftEdge(), m_inlineFlowBox.includeLogicalRightEdge()); |
133 } | 134 } |
134 } | 135 } |
135 | 136 |
136 | |
137 static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NineP
ieceImage& image, const LayoutRect& paintRect) | 137 static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NineP
ieceImage& image, const LayoutRect& paintRect) |
138 { | 138 { |
139 LayoutRect clipRect(paintRect); | 139 LayoutRect clipRect(paintRect); |
140 const ComputedStyle& style = box->layoutObject().styleRef(); | 140 const ComputedStyle& style = box->layoutObject().styleRef(); |
141 LayoutRectOutsets outsets = style.imageOutsets(image); | 141 LayoutRectOutsets outsets = style.imageOutsets(image); |
142 if (box->isHorizontal()) { | 142 if (box->isHorizontal()) { |
143 clipRect.setY(paintRect.y() - outsets.top()); | 143 clipRect.setY(paintRect.y() - outsets.top()); |
144 clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom()
); | 144 clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom()
); |
145 if (box->includeLogicalLeftEdge()) { | 145 if (box->includeLogicalLeftEdge()) { |
146 clipRect.setX(paintRect.x() - outsets.left()); | 146 clipRect.setX(paintRect.x() - outsets.left()); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 rect.setHeight(logicalHeight); | 359 rect.setHeight(logicalHeight); |
360 } else { | 360 } else { |
361 rect.setX(logicalTop); | 361 rect.setX(logicalTop); |
362 rect.setWidth(logicalHeight); | 362 rect.setWidth(logicalHeight); |
363 } | 363 } |
364 } | 364 } |
365 return rect; | 365 return rect; |
366 } | 366 } |
367 | 367 |
368 } // namespace blink | 368 } // namespace blink |
OLD | NEW |