| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "config.h" | 20 #include "config.h" |
| 21 #include "core/rendering/InlineFlowBox.h" | 21 #include "core/rendering/InlineFlowBox.h" |
| 22 | 22 |
| 23 #include "core/CSSPropertyNames.h" | 23 #include "core/CSSPropertyNames.h" |
| 24 #include "core/dom/Document.h" | 24 #include "core/dom/Document.h" |
| 25 #include "core/paint/BoxPainter.h" |
| 25 #include "core/rendering/HitTestResult.h" | 26 #include "core/rendering/HitTestResult.h" |
| 26 #include "core/rendering/InlineTextBox.h" | 27 #include "core/rendering/InlineTextBox.h" |
| 27 #include "core/rendering/RenderBlock.h" | 28 #include "core/rendering/RenderBlock.h" |
| 28 #include "core/rendering/RenderInline.h" | 29 #include "core/rendering/RenderInline.h" |
| 29 #include "core/rendering/RenderLayer.h" | 30 #include "core/rendering/RenderLayer.h" |
| 30 #include "core/rendering/RenderListMarker.h" | 31 #include "core/rendering/RenderListMarker.h" |
| 31 #include "core/rendering/RenderObjectInlines.h" | 32 #include "core/rendering/RenderObjectInlines.h" |
| 32 #include "core/rendering/RenderRubyBase.h" | 33 #include "core/rendering/RenderRubyBase.h" |
| 33 #include "core/rendering/RenderRubyRun.h" | 34 #include "core/rendering/RenderRubyRun.h" |
| 34 #include "core/rendering/RenderRubyText.h" | 35 #include "core/rendering/RenderRubyText.h" |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 // would be clipped out, so it has to be drawn separately). | 1177 // would be clipped out, so it has to be drawn separately). |
| 1177 StyleImage* image = lastBackgroundLayer.image(); | 1178 StyleImage* image = lastBackgroundLayer.image(); |
| 1178 bool hasFillImage = image && image->canRender(renderer(), renderer().style()
->effectiveZoom()); | 1179 bool hasFillImage = image && image->canRender(renderer(), renderer().style()
->effectiveZoom()); |
| 1179 return (!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLi
neBox() && !nextLineBox()) || !parent(); | 1180 return (!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLi
neBox() && !nextLineBox()) || !parent(); |
| 1180 } | 1181 } |
| 1181 | 1182 |
| 1182 void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c
onst FillLayer& fillLayer, const LayoutRect& rect, CompositeOperator op) | 1183 void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c
onst FillLayer& fillLayer, const LayoutRect& rect, CompositeOperator op) |
| 1183 { | 1184 { |
| 1184 StyleImage* img = fillLayer.image(); | 1185 StyleImage* img = fillLayer.image(); |
| 1185 bool hasFillImage = img && img->canRender(renderer(), renderer().style()->ef
fectiveZoom()); | 1186 bool hasFillImage = img && img->canRender(renderer(), renderer().style()->ef
fectiveZoom()); |
| 1187 ASSERT(!renderer().isText()); |
| 1188 RenderBox* box = toRenderBox(&renderer()); |
| 1189 BoxPainter boxPainter(*box); |
| 1186 if ((!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLineB
ox() && !nextLineBox()) || !parent()) { | 1190 if ((!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLineB
ox() && !nextLineBox()) || !parent()) { |
| 1187 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); | 1191 boxPainter.paintFillLayerExtended(paintInfo, c, fillLayer, rect, Backgro
undBleedNone, this, rect.size(), op); |
| 1188 } else if (renderer().style()->boxDecorationBreak() == DCLONE) { | 1192 } else if (renderer().style()->boxDecorationBreak() == DCLONE) { |
| 1189 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1193 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 1190 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()
)); | 1194 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()
)); |
| 1191 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); | 1195 boxPainter.paintFillLayerExtended(paintInfo, c, fillLayer, rect, Backgro
undBleedNone, this, rect.size(), op); |
| 1192 } else { | 1196 } else { |
| 1193 // We have a fill image that spans multiple lines. | 1197 // We have a fill image that spans multiple lines. |
| 1194 // We need to adjust tx and ty by the width of all previous lines. | 1198 // We need to adjust tx and ty by the width of all previous lines. |
| 1195 // Think of background painting on inlines as though you had one long li
ne, a single continuous | 1199 // Think of background painting on inlines as though you had one long li
ne, a single continuous |
| 1196 // strip. Even though that strip has been broken up across multiple lin
es, you still paint it | 1200 // strip. Even though that strip has been broken up across multiple lin
es, you still paint it |
| 1197 // as though you had one single line. This means each line has to pick
up the background where | 1201 // as though you had one single line. This means each line has to pick
up the background where |
| 1198 // the previous line left off. | 1202 // the previous line left off. |
| 1199 LayoutUnit logicalOffsetOnLine = 0; | 1203 LayoutUnit logicalOffsetOnLine = 0; |
| 1200 LayoutUnit totalLogicalWidth; | 1204 LayoutUnit totalLogicalWidth; |
| 1201 if (renderer().style()->direction() == LTR) { | 1205 if (renderer().style()->direction() == LTR) { |
| 1202 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin
eBox()) | 1206 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin
eBox()) |
| 1203 logicalOffsetOnLine += curr->logicalWidth(); | 1207 logicalOffsetOnLine += curr->logicalWidth(); |
| 1204 totalLogicalWidth = logicalOffsetOnLine; | 1208 totalLogicalWidth = logicalOffsetOnLine; |
| 1205 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) | 1209 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) |
| 1206 totalLogicalWidth += curr->logicalWidth(); | 1210 totalLogicalWidth += curr->logicalWidth(); |
| 1207 } else { | 1211 } else { |
| 1208 for (InlineFlowBox* curr = nextLineBox(); curr; curr = curr->nextLin
eBox()) | 1212 for (InlineFlowBox* curr = nextLineBox(); curr; curr = curr->nextLin
eBox()) |
| 1209 logicalOffsetOnLine += curr->logicalWidth(); | 1213 logicalOffsetOnLine += curr->logicalWidth(); |
| 1210 totalLogicalWidth = logicalOffsetOnLine; | 1214 totalLogicalWidth = logicalOffsetOnLine; |
| 1211 for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox()) | 1215 for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox()) |
| 1212 totalLogicalWidth += curr->logicalWidth(); | 1216 totalLogicalWidth += curr->logicalWidth(); |
| 1213 } | 1217 } |
| 1214 LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : L
ayoutUnit()); | 1218 LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : L
ayoutUnit()); |
| 1215 LayoutUnit stripY = rect.y() - (isHorizontal() ? LayoutUnit() : logicalO
ffsetOnLine); | 1219 LayoutUnit stripY = rect.y() - (isHorizontal() ? LayoutUnit() : logicalO
ffsetOnLine); |
| 1216 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast
<LayoutUnit>(width()); | 1220 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast
<LayoutUnit>(width()); |
| 1217 LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height
()) : totalLogicalWidth; | 1221 LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height
()) : totalLogicalWidth; |
| 1218 | 1222 |
| 1219 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1223 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 1220 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()
)); | 1224 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()
)); |
| 1221 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, Layout
Rect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.s
ize(), op); | 1225 boxPainter.paintFillLayerExtended(paintInfo, c, fillLayer, LayoutRect(st
ripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.size(),
op); |
| 1222 } | 1226 } |
| 1223 } | 1227 } |
| 1224 | 1228 |
| 1225 void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow
Style shadowStyle, const LayoutRect& paintRect) | 1229 void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow
Style shadowStyle, const LayoutRect& paintRect) |
| 1226 { | 1230 { |
| 1227 if ((!prevLineBox() && !nextLineBox()) || !parent()) | 1231 if ((!prevLineBox() && !nextLineBox()) || !parent()) |
| 1228 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); | 1232 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); |
| 1229 else { | 1233 else { |
| 1230 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't | 1234 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't |
| 1231 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines | 1235 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 ASSERT(child->prevOnLine() == prev); | 1676 ASSERT(child->prevOnLine() == prev); |
| 1673 prev = child; | 1677 prev = child; |
| 1674 } | 1678 } |
| 1675 ASSERT(prev == m_lastChild); | 1679 ASSERT(prev == m_lastChild); |
| 1676 #endif | 1680 #endif |
| 1677 } | 1681 } |
| 1678 | 1682 |
| 1679 #endif | 1683 #endif |
| 1680 | 1684 |
| 1681 } // namespace blink | 1685 } // namespace blink |
| OLD | NEW |