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

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

Issue 564973002: Move a bunch more painting code out of RenderBoxModelObject and into BoxPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove unnecessary include. 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
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
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height ()) : totalLogicalWidth; 1222 LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height ()) : totalLogicalWidth;
1223 1223
1224 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1224 GraphicsContextStateSaver stateSaver(*paintInfo.context);
1225 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height() )); 1225 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height() ));
1226 boxPainter.paintFillLayerExtended(paintInfo, c, fillLayer, LayoutRect(st ripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.size(), op); 1226 boxPainter.paintFillLayerExtended(paintInfo, c, fillLayer, LayoutRect(st ripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.size(), op);
1227 } 1227 }
1228 } 1228 }
1229 1229
1230 void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow Style shadowStyle, const LayoutRect& paintRect) 1230 void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow Style shadowStyle, const LayoutRect& paintRect)
1231 { 1231 {
1232 ASSERT(!renderer()->isText);
1233 BoxPainter boxPainter(toRenderBox(renderer()));
1232 if ((!prevLineBox() && !nextLineBox()) || !parent()) 1234 if ((!prevLineBox() && !nextLineBox()) || !parent())
1233 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); 1235 boxPainter.paintBoxShadow(info, paintRect, s, shadowStyle);
1234 else { 1236 else {
1235 // FIXME: We can do better here in the multi-line case. We want to push a clip so that the shadow doesn't 1237 // FIXME: We can do better here in the multi-line case. We want to push a clip so that the shadow doesn't
1236 // protrude incorrectly at the edges, and we want to possibly include sh adows cast from the previous/following lines 1238 // protrude incorrectly at the edges, and we want to possibly include sh adows cast from the previous/following lines
1237 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle, includ eLogicalLeftEdge(), includeLogicalRightEdge()); 1239 boxPainter.paintBoxShadow(info, paintRect, s, shadowStyle, includeLogica lLeftEdge(), includeLogicalRightEdge());
1238 } 1240 }
1239 } 1241 }
1240 1242
1241 void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(LayoutRect& rect) const 1243 void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(LayoutRect& rect) const
1242 { 1244 {
1243 bool noQuirksMode = renderer().document().inNoQuirksMode(); 1245 bool noQuirksMode = renderer().document().inNoQuirksMode();
1244 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAn dBaseline() && hasTextDescendants())) { 1246 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAn dBaseline() && hasTextDescendants())) {
1245 const RootInlineBox& rootBox = root(); 1247 const RootInlineBox& rootBox = root();
1246 LayoutUnit logicalTop = isHorizontal() ? rect.y() : rect.x(); 1248 LayoutUnit logicalTop = isHorizontal() ? rect.y() : rect.x();
1247 LayoutUnit logicalHeight = isHorizontal() ? rect.height() : rect.width() ; 1249 LayoutUnit logicalHeight = isHorizontal() ? rect.height() : rect.width() ;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 // non-first-line style. 1328 // non-first-line style.
1327 if (parent() && renderer().style()->hasBorder()) { 1329 if (parent() && renderer().style()->hasBorder()) {
1328 const NinePieceImage& borderImage = renderer().style()->borderImage(); 1330 const NinePieceImage& borderImage = renderer().style()->borderImage();
1329 StyleImage* borderImageSource = borderImage.image(); 1331 StyleImage* borderImageSource = borderImage.image();
1330 bool hasBorderImage = borderImageSource && borderImageSource->canRender( renderer(), styleToUse->effectiveZoom()); 1332 bool hasBorderImage = borderImageSource && borderImageSource->canRender( renderer(), styleToUse->effectiveZoom());
1331 if (hasBorderImage && !borderImageSource->isLoaded()) 1333 if (hasBorderImage && !borderImageSource->isLoaded())
1332 return; // Don't paint anything while we wait for the image to load. 1334 return; // Don't paint anything while we wait for the image to load.
1333 1335
1334 // The simple case is where we either have no border image or we are the only box for this object. 1336 // The simple case is where we either have no border image or we are the only box for this object.
1335 // In those cases only a single call to draw is required. 1337 // In those cases only a single call to draw is required.
1338 ASSERT(!renderer().isText());
1339 BoxPainter boxPainter(toRenderBox(renderer()));
1336 if (!hasBorderImage || (!prevLineBox() && !nextLineBox())) { 1340 if (!hasBorderImage || (!prevLineBox() && !nextLineBox())) {
1337 boxModelObject()->paintBorder(paintInfo, paintRect, renderer().style (isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogi calRightEdge()); 1341
1342 boxPainter.paintBorder(paintInfo, paintRect, renderer().style(isFirs tLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRigh tEdge());
1338 } else { 1343 } else {
1339 // We have a border image that spans multiple lines. 1344 // We have a border image that spans multiple lines.
1340 // We need to adjust tx and ty by the width of all previous lines. 1345 // We need to adjust tx and ty by the width of all previous lines.
1341 // Think of border image painting on inlines as though you had one l ong line, a single continuous 1346 // Think of border image painting on inlines as though you had one l ong line, a single continuous
1342 // strip. Even though that strip has been broken up across multiple lines, you still paint it 1347 // strip. Even though that strip has been broken up across multiple lines, you still paint it
1343 // as though you had one single line. This means each line has to pi ck up the image where 1348 // as though you had one single line. This means each line has to pi ck up the image where
1344 // the previous line left off. 1349 // the previous line left off.
1345 // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right, 1350 // FIXME: What the heck do we do with RTL here? The math we're using is obviously not right,
1346 // but it isn't even clear how this should work at all. 1351 // but it isn't even clear how this should work at all.
1347 LayoutUnit logicalOffsetOnLine = 0; 1352 LayoutUnit logicalOffsetOnLine = 0;
1348 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin eBox()) 1353 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin eBox())
1349 logicalOffsetOnLine += curr->logicalWidth(); 1354 logicalOffsetOnLine += curr->logicalWidth();
1350 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; 1355 LayoutUnit totalLogicalWidth = logicalOffsetOnLine;
1351 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) 1356 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
1352 totalLogicalWidth += curr->logicalWidth(); 1357 totalLogicalWidth += curr->logicalWidth();
1353 LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logi calOffsetOnLine : LayoutUnit()); 1358 LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logi calOffsetOnLine : LayoutUnit());
1354 LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? Layo utUnit() : logicalOffsetOnLine); 1359 LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? Layo utUnit() : logicalOffsetOnLine);
1355 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRe ct.width(); 1360 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRe ct.width();
1356 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : total LogicalWidth; 1361 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : total LogicalWidth;
1357 1362
1358 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borderIma ge, paintRect); 1363 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borderIma ge, paintRect);
1359 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1364 GraphicsContextStateSaver stateSaver(*paintInfo.context);
1360 paintInfo.context->clip(clipRect); 1365 paintInfo.context->clip(clipRect);
1361 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWidth, stripHeight), renderer().style(isFirstLineStyle())); 1366 boxPainter.paintBorder(paintInfo, LayoutRect(stripX, stripY, stripWi dth, stripHeight), renderer().style(isFirstLineStyle()));
1362 } 1367 }
1363 } 1368 }
1364 } 1369 }
1365 1370
1366 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs et) 1371 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs et)
1367 { 1372 {
1368 if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->vis ibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 1373 if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->vis ibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
1369 return; 1374 return;
1370 1375
1371 // Pixel snap mask painting. 1376 // Pixel snap mask painting.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 1408
1404 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer(), rende rer().style()->effectiveZoom()); 1409 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer(), rende rer().style()->effectiveZoom());
1405 if (!hasBoxImage || !maskBoxImage->isLoaded()) { 1410 if (!hasBoxImage || !maskBoxImage->isLoaded()) {
1406 if (pushTransparencyLayer) 1411 if (pushTransparencyLayer)
1407 paintInfo.context->endLayer(); 1412 paintInfo.context->endLayer();
1408 return; // Don't paint anything while we wait for the image to load. 1413 return; // Don't paint anything while we wait for the image to load.
1409 } 1414 }
1410 1415
1411 // The simple case is where we are the only box for this object. In those 1416 // The simple case is where we are the only box for this object. In those
1412 // cases only a single call to draw is required. 1417 // cases only a single call to draw is required.
1418 ASSERT(!renderer().isText());
1419 BoxPainter boxPainter(toRenderBox(renderer()));
1413 if (!prevLineBox() && !nextLineBox()) { 1420 if (!prevLineBox() && !nextLineBox()) {
1414 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(adju stedPaintOffset, frameRect.size()), renderer().style(), maskNinePieceImage, comp ositeOp); 1421 boxPainter.paintNinePieceImage(paintInfo.context, LayoutRect(adjustedPai ntOffset, frameRect.size()), renderer().style(), maskNinePieceImage, compositeOp );
1415 } else { 1422 } else {
1416 // We have a mask image that spans multiple lines. 1423 // We have a mask image that spans multiple lines.
1417 // We need to adjust _tx and _ty by the width of all previous lines. 1424 // We need to adjust _tx and _ty by the width of all previous lines.
1418 LayoutUnit logicalOffsetOnLine = 0; 1425 LayoutUnit logicalOffsetOnLine = 0;
1419 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox ()) 1426 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox ())
1420 logicalOffsetOnLine += curr->logicalWidth(); 1427 logicalOffsetOnLine += curr->logicalWidth();
1421 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; 1428 LayoutUnit totalLogicalWidth = logicalOffsetOnLine;
1422 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) 1429 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox())
1423 totalLogicalWidth += curr->logicalWidth(); 1430 totalLogicalWidth += curr->logicalWidth();
1424 LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logicalO ffsetOnLine : LayoutUnit()); 1431 LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logicalO ffsetOnLine : LayoutUnit());
1425 LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? LayoutUn it() : logicalOffsetOnLine); 1432 LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? LayoutUn it() : logicalOffsetOnLine);
1426 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.w idth(); 1433 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.w idth();
1427 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogi calWidth; 1434 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogi calWidth;
1428 1435
1429 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePiece Image, paintRect); 1436 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePiece Image, paintRect);
1430 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1437 GraphicsContextStateSaver stateSaver(*paintInfo.context);
1431 paintInfo.context->clip(clipRect); 1438 paintInfo.context->clip(clipRect);
1432 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(stri pX, stripY, stripWidth, stripHeight), renderer().style(), maskNinePieceImage, co mpositeOp); 1439 boxPainter.paintNinePieceImage(paintInfo.context, LayoutRect(stripX, str ipY, stripWidth, stripHeight), renderer().style(), maskNinePieceImage, composite Op);
1433 } 1440 }
1434 1441
1435 if (pushTransparencyLayer) 1442 if (pushTransparencyLayer)
1436 paintInfo.context->endLayer(); 1443 paintInfo.context->endLayer();
1437 } 1444 }
1438 1445
1439 InlineBox* InlineFlowBox::firstLeafChild() const 1446 InlineBox* InlineFlowBox::firstLeafChild() const
1440 { 1447 {
1441 InlineBox* leaf = 0; 1448 InlineBox* leaf = 0;
1442 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL ine()) 1449 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL ine())
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 ASSERT(child->prevOnLine() == prev); 1684 ASSERT(child->prevOnLine() == prev);
1678 prev = child; 1685 prev = child;
1679 } 1686 }
1680 ASSERT(prev == m_lastChild); 1687 ASSERT(prev == m_lastChild);
1681 #endif 1688 #endif
1682 } 1689 }
1683 1690
1684 #endif 1691 #endif
1685 1692
1686 } // namespace blink 1693 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698