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