Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: Source/core/rendering/InlineFlowBox.cpp

Issue 559733005: Move painting code from RenderBoxModelObject into BoxPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/BoxPainter.cpp ('k') | Source/core/rendering/RenderBox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
1186 if ((!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLineB ox() && !nextLineBox()) || !parent()) { 1187 if ((!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLineB ox() && !nextLineBox()) || !parent()) {
1187 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect, BackgroundBleedNone, this, rect.size(), op); 1188 BoxPainter::paintFillLayerExtended(*boxModelObject(), paintInfo, c, fill Layer, rect, BackgroundBleedNone, this, rect.size(), op);
1188 } else if (renderer().style()->boxDecorationBreak() == DCLONE) { 1189 } else if (renderer().style()->boxDecorationBreak() == DCLONE) {
1189 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1190 GraphicsContextStateSaver stateSaver(*paintInfo.context);
1190 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height() )); 1191 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height() ));
1191 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect, BackgroundBleedNone, this, rect.size(), op); 1192 BoxPainter::paintFillLayerExtended(*boxModelObject(), paintInfo, c, fill Layer, rect, BackgroundBleedNone, this, rect.size(), op);
1192 } else { 1193 } else {
1193 // We have a fill image that spans multiple lines. 1194 // We have a fill image that spans multiple lines.
1194 // We need to adjust tx and ty by the width of all previous lines. 1195 // 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 1196 // 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 1197 // 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 1198 // as though you had one single line. This means each line has to pick up the background where
1198 // the previous line left off. 1199 // the previous line left off.
1199 LayoutUnit logicalOffsetOnLine = 0; 1200 LayoutUnit logicalOffsetOnLine = 0;
1200 LayoutUnit totalLogicalWidth; 1201 LayoutUnit totalLogicalWidth;
1201 if (renderer().style()->direction() == LTR) { 1202 if (renderer().style()->direction() == LTR) {
1202 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin eBox()) 1203 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin eBox())
1203 logicalOffsetOnLine += curr->logicalWidth(); 1204 logicalOffsetOnLine += curr->logicalWidth();
1204 totalLogicalWidth = logicalOffsetOnLine; 1205 totalLogicalWidth = logicalOffsetOnLine;
1205 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) 1206 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
1206 totalLogicalWidth += curr->logicalWidth(); 1207 totalLogicalWidth += curr->logicalWidth();
1207 } else { 1208 } else {
1208 for (InlineFlowBox* curr = nextLineBox(); curr; curr = curr->nextLin eBox()) 1209 for (InlineFlowBox* curr = nextLineBox(); curr; curr = curr->nextLin eBox())
1209 logicalOffsetOnLine += curr->logicalWidth(); 1210 logicalOffsetOnLine += curr->logicalWidth();
1210 totalLogicalWidth = logicalOffsetOnLine; 1211 totalLogicalWidth = logicalOffsetOnLine;
1211 for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox()) 1212 for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox())
1212 totalLogicalWidth += curr->logicalWidth(); 1213 totalLogicalWidth += curr->logicalWidth();
1213 } 1214 }
1214 LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : L ayoutUnit()); 1215 LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : L ayoutUnit());
1215 LayoutUnit stripY = rect.y() - (isHorizontal() ? LayoutUnit() : logicalO ffsetOnLine); 1216 LayoutUnit stripY = rect.y() - (isHorizontal() ? LayoutUnit() : logicalO ffsetOnLine);
1216 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast <LayoutUnit>(width()); 1217 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast <LayoutUnit>(width());
1217 LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height ()) : totalLogicalWidth; 1218 LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height ()) : totalLogicalWidth;
1218 1219
1219 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1220 GraphicsContextStateSaver stateSaver(*paintInfo.context);
1220 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height() )); 1221 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); 1222 BoxPainter::paintFillLayerExtended(*boxModelObject(), paintInfo, c, fill Layer, LayoutRect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.size(), op);
1222 } 1223 }
1223 } 1224 }
1224 1225
1225 void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow Style shadowStyle, const LayoutRect& paintRect) 1226 void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow Style shadowStyle, const LayoutRect& paintRect)
1226 { 1227 {
1227 if ((!prevLineBox() && !nextLineBox()) || !parent()) 1228 if ((!prevLineBox() && !nextLineBox()) || !parent())
1228 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); 1229 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle);
1229 else { 1230 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 1231 // 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 1232 // 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
1672 ASSERT(child->prevOnLine() == prev); 1673 ASSERT(child->prevOnLine() == prev);
1673 prev = child; 1674 prev = child;
1674 } 1675 }
1675 ASSERT(prev == m_lastChild); 1676 ASSERT(prev == m_lastChild);
1676 #endif 1677 #endif
1677 } 1678 }
1678 1679
1679 #endif 1680 #endif
1680 1681
1681 } // namespace blink 1682 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/BoxPainter.cpp ('k') | Source/core/rendering/RenderBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698