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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, rect)) | 1060 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, rect)) |
1061 return true; | 1061 return true; |
1062 } | 1062 } |
1063 | 1063 |
1064 return false; | 1064 return false; |
1065 } | 1065 } |
1066 | 1066 |
1067 void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
LayoutUnit lineTop, LayoutUnit lineBottom) | 1067 void InlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
LayoutUnit lineTop, LayoutUnit lineBottom) |
1068 { | 1068 { |
1069 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); | 1069 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); |
1070 overflowRect.inflate(renderer()->maximalOutlineSize(paintInfo.phase)); | 1070 overflowRect.inflate(renderer()->maximalOutlineSize(paintInfo.getPhase())); |
1071 flipForWritingMode(overflowRect); | 1071 flipForWritingMode(overflowRect); |
1072 overflowRect.moveBy(paintOffset); | 1072 overflowRect.moveBy(paintOffset); |
1073 | 1073 |
1074 if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect))) | 1074 if (!paintInfo.getRect().intersects(pixelSnappedIntRect(overflowRect))) |
1075 return; | 1075 return; |
1076 | 1076 |
1077 if (paintInfo.phase != PaintPhaseChildOutlines) { | 1077 if (paintInfo.getPhase() != PaintPhaseChildOutlines) { |
1078 if (paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhas
eSelfOutline) { | 1078 if (paintInfo.getPhase() == PaintPhaseOutline || paintInfo.getPhase() ==
PaintPhaseSelfOutline) { |
1079 // Add ourselves to the paint info struct's list of inlines that nee
d to paint their | 1079 // Add ourselves to the paint info struct's list of inlines that nee
d to paint their |
1080 // outlines. | 1080 // outlines. |
1081 if (renderer()->style()->visibility() == VISIBLE && renderer()->hasO
utline() && !isRootInlineBox()) { | 1081 if (renderer()->style()->visibility() == VISIBLE && renderer()->hasO
utline() && !isRootInlineBox()) { |
1082 RenderInline* inlineFlow = toRenderInline(renderer()); | 1082 RenderInline* inlineFlow = toRenderInline(renderer()); |
1083 | 1083 |
1084 RenderBlock* cb = 0; | 1084 RenderBlock* cb = 0; |
1085 bool containingBlockPaintsContinuationOutline = inlineFlow->cont
inuation() || inlineFlow->isInlineElementContinuation(); | 1085 bool containingBlockPaintsContinuationOutline = inlineFlow->cont
inuation() || inlineFlow->isInlineElementContinuation(); |
1086 if (containingBlockPaintsContinuationOutline) { | 1086 if (containingBlockPaintsContinuationOutline) { |
1087 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690.
We currently don't reconnect inline continuations | 1087 // FIXME: See https://bugs.webkit.org/show_bug.cgi?id=54690.
We currently don't reconnect inline continuations |
1088 // after a child removal. As a result, those merged inlines
do not get seperated and hence not get enclosed by | 1088 // after a child removal. As a result, those merged inlines
do not get seperated and hence not get enclosed by |
1089 // anonymous blocks. In this case, it is better to bail out
and paint it ourself. | 1089 // anonymous blocks. In this case, it is better to bail out
and paint it ourself. |
1090 RenderBlock* enclosingAnonymousBlock = renderer()->containin
gBlock(); | 1090 RenderBlock* enclosingAnonymousBlock = renderer()->containin
gBlock(); |
1091 if (!enclosingAnonymousBlock->isAnonymousBlock()) | 1091 if (!enclosingAnonymousBlock->isAnonymousBlock()) |
1092 containingBlockPaintsContinuationOutline = false; | 1092 containingBlockPaintsContinuationOutline = false; |
1093 else { | 1093 else { |
1094 cb = enclosingAnonymousBlock->containingBlock(); | 1094 cb = enclosingAnonymousBlock->containingBlock(); |
1095 for (RenderBoxModelObject* box = boxModelObject(); box !
= cb; box = box->parent()->enclosingBoxModelObject()) { | 1095 for (RenderBoxModelObject* box = boxModelObject(); box !
= cb; box = box->parent()->enclosingBoxModelObject()) { |
1096 if (box->hasSelfPaintingLayer()) { | 1096 if (box->hasSelfPaintingLayer()) { |
1097 containingBlockPaintsContinuationOutline = false
; | 1097 containingBlockPaintsContinuationOutline = false
; |
1098 break; | 1098 break; |
1099 } | 1099 } |
1100 } | 1100 } |
1101 } | 1101 } |
1102 } | 1102 } |
1103 | 1103 |
1104 if (containingBlockPaintsContinuationOutline) { | 1104 if (containingBlockPaintsContinuationOutline) { |
1105 // Add ourselves to the containing block of the entire conti
nuation so that it can | 1105 // Add ourselves to the containing block of the entire conti
nuation so that it can |
1106 // paint us atomically. | 1106 // paint us atomically. |
1107 cb->addContinuationWithOutline(toRenderInline(renderer()->no
de()->renderer())); | 1107 cb->addContinuationWithOutline(toRenderInline(renderer()->no
de()->renderer())); |
1108 } else if (!inlineFlow->isInlineElementContinuation()) | 1108 } else if (!inlineFlow->isInlineElementContinuation()) { |
1109 paintInfo.outlineObjects->add(inlineFlow); | 1109 paintInfo.getOutlineObjects()->add(inlineFlow); |
| 1110 } |
1110 } | 1111 } |
1111 } else if (paintInfo.phase == PaintPhaseMask) { | 1112 } else if (paintInfo.getPhase() == PaintPhaseMask) { |
1112 paintMask(paintInfo, paintOffset); | 1113 paintMask(paintInfo, paintOffset); |
1113 return; | 1114 return; |
1114 } else { | 1115 } else { |
1115 // Paint our background, border and box-shadow. | 1116 // Paint our background, border and box-shadow. |
1116 paintBoxDecorations(paintInfo, paintOffset); | 1117 paintBoxDecorations(paintInfo, paintOffset); |
1117 } | 1118 } |
1118 } | 1119 } |
1119 | 1120 |
1120 if (paintInfo.phase == PaintPhaseMask) | 1121 if (paintInfo.getPhase() == PaintPhaseMask) |
1121 return; | 1122 return; |
1122 | 1123 |
1123 PaintPhase paintPhase = paintInfo.phase == PaintPhaseChildOutlines ? PaintPh
aseOutline : paintInfo.phase; | 1124 PaintPhase paintPhase = paintInfo.getPhase() == PaintPhaseChildOutlines ? Pa
intPhaseOutline : paintInfo.getPhase(); |
1124 PaintInfo childInfo(paintInfo); | 1125 PaintInfo childInfo(paintInfo); |
1125 childInfo.phase = paintPhase; | 1126 childInfo.setPhase(paintPhase); |
1126 childInfo.updatePaintingRootForChildren(renderer()); | 1127 childInfo.updatePaintingRootForChildren(renderer()); |
1127 | 1128 |
1128 // Paint our children. | 1129 // Paint our children. |
1129 if (paintPhase != PaintPhaseSelfOutline) { | 1130 if (paintPhase != PaintPhaseSelfOutline) { |
1130 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { | 1131 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { |
1131 if (curr->renderer()->isText() || !curr->boxModelObject()->hasSelfPa
intingLayer()) | 1132 if (curr->renderer()->isText() || !curr->boxModelObject()->hasSelfPa
intingLayer()) |
1132 curr->paint(childInfo, paintOffset, lineTop, lineBottom); | 1133 curr->paint(childInfo, paintOffset, lineTop, lineBottom); |
1133 } | 1134 } |
1134 } | 1135 } |
1135 } | 1136 } |
1136 | 1137 |
1137 void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c,
const FillLayer* fillLayer, const LayoutRect& rect, CompositeOperator op) | 1138 void InlineFlowBox::paintFillLayers(PaintInfo& paintInfo, const Color& c, const
FillLayer* fillLayer, const LayoutRect& rect, CompositeOperator op) |
1138 { | 1139 { |
1139 if (!fillLayer) | 1140 if (!fillLayer) |
1140 return; | 1141 return; |
1141 paintFillLayers(paintInfo, c, fillLayer->next(), rect, op); | 1142 paintFillLayers(paintInfo, c, fillLayer->next(), rect, op); |
1142 paintFillLayer(paintInfo, c, fillLayer, rect, op); | 1143 paintFillLayer(paintInfo, c, fillLayer, rect, op); |
1143 } | 1144 } |
1144 | 1145 |
1145 bool InlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackg
roundLayer) const | 1146 bool InlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackg
roundLayer) const |
1146 { | 1147 { |
1147 // The checks here match how paintFillLayer() decides whether to clip (if it
does, the shadow | 1148 // The checks here match how paintFillLayer() decides whether to clip (if it
does, the shadow |
1148 // would be clipped out, so it has to be drawn separately). | 1149 // would be clipped out, so it has to be drawn separately). |
1149 StyleImage* image = lastBackgroundLayer.image(); | 1150 StyleImage* image = lastBackgroundLayer.image(); |
1150 bool hasFillImage = image && image->canRender(renderer(), renderer()->style(
)->effectiveZoom()); | 1151 bool hasFillImage = image && image->canRender(renderer(), renderer()->style(
)->effectiveZoom()); |
1151 return (!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevL
ineBox() && !nextLineBox()) || !parent(); | 1152 return (!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevL
ineBox() && !nextLineBox()) || !parent(); |
1152 } | 1153 } |
1153 | 1154 |
1154 void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c
onst FillLayer* fillLayer, const LayoutRect& rect, CompositeOperator op) | 1155 void InlineFlowBox::paintFillLayer(PaintInfo& paintInfo, const Color& c, const F
illLayer* fillLayer, const LayoutRect& rect, CompositeOperator op) |
1155 { | 1156 { |
1156 StyleImage* img = fillLayer->image(); | 1157 StyleImage* img = fillLayer->image(); |
1157 bool hasFillImage = img && img->canRender(renderer(), renderer()->style()->e
ffectiveZoom()); | 1158 bool hasFillImage = img && img->canRender(renderer(), renderer()->style()->e
ffectiveZoom()); |
1158 if ((!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevLine
Box() && !nextLineBox()) || !parent()) | 1159 if ((!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevLine
Box() && !nextLineBox()) || !parent()) |
1159 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); | 1160 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); |
1160 else if (renderer()->style()->boxDecorationBreak() == DCLONE) { | 1161 else if (renderer()->style()->boxDecorationBreak() == DCLONE) { |
1161 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1162 GraphicsContextStateSaver stateSaver(*(paintInfo.getContext())); |
1162 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()
)); | 1163 paintInfo.getContext()->clip(LayoutRect(rect.x(), rect.y(), width(), hei
ght())); |
1163 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); | 1164 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect,
BackgroundBleedNone, this, rect.size(), op); |
1164 } else { | 1165 } else { |
1165 // We have a fill image that spans multiple lines. | 1166 // We have a fill image that spans multiple lines. |
1166 // We need to adjust tx and ty by the width of all previous lines. | 1167 // We need to adjust tx and ty by the width of all previous lines. |
1167 // Think of background painting on inlines as though you had one long li
ne, a single continuous | 1168 // Think of background painting on inlines as though you had one long li
ne, a single continuous |
1168 // strip. Even though that strip has been broken up across multiple lin
es, you still paint it | 1169 // strip. Even though that strip has been broken up across multiple lin
es, you still paint it |
1169 // as though you had one single line. This means each line has to pick
up the background where | 1170 // as though you had one single line. This means each line has to pick
up the background where |
1170 // the previous line left off. | 1171 // the previous line left off. |
1171 LayoutUnit logicalOffsetOnLine = 0; | 1172 LayoutUnit logicalOffsetOnLine = 0; |
1172 LayoutUnit totalLogicalWidth; | 1173 LayoutUnit totalLogicalWidth; |
1173 if (renderer()->style()->direction() == LTR) { | 1174 if (renderer()->style()->direction() == LTR) { |
1174 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin
eBox()) | 1175 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLin
eBox()) |
1175 logicalOffsetOnLine += curr->logicalWidth(); | 1176 logicalOffsetOnLine += curr->logicalWidth(); |
1176 totalLogicalWidth = logicalOffsetOnLine; | 1177 totalLogicalWidth = logicalOffsetOnLine; |
1177 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) | 1178 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) |
1178 totalLogicalWidth += curr->logicalWidth(); | 1179 totalLogicalWidth += curr->logicalWidth(); |
1179 } else { | 1180 } else { |
1180 for (InlineFlowBox* curr = nextLineBox(); curr; curr = curr->nextLin
eBox()) | 1181 for (InlineFlowBox* curr = nextLineBox(); curr; curr = curr->nextLin
eBox()) |
1181 logicalOffsetOnLine += curr->logicalWidth(); | 1182 logicalOffsetOnLine += curr->logicalWidth(); |
1182 totalLogicalWidth = logicalOffsetOnLine; | 1183 totalLogicalWidth = logicalOffsetOnLine; |
1183 for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox()) | 1184 for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox()) |
1184 totalLogicalWidth += curr->logicalWidth(); | 1185 totalLogicalWidth += curr->logicalWidth(); |
1185 } | 1186 } |
1186 LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : L
ayoutUnit()); | 1187 LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : L
ayoutUnit()); |
1187 LayoutUnit stripY = rect.y() - (isHorizontal() ? LayoutUnit() : logicalO
ffsetOnLine); | 1188 LayoutUnit stripY = rect.y() - (isHorizontal() ? LayoutUnit() : logicalO
ffsetOnLine); |
1188 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast
<LayoutUnit>(width()); | 1189 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : static_cast
<LayoutUnit>(width()); |
1189 LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height
()) : totalLogicalWidth; | 1190 LayoutUnit stripHeight = isHorizontal() ? static_cast<LayoutUnit>(height
()) : totalLogicalWidth; |
1190 | 1191 |
1191 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1192 GraphicsContextStateSaver stateSaver(*paintInfo.getContext()); |
1192 paintInfo.context->clip(LayoutRect(rect.x(), rect.y(), width(), height()
)); | 1193 paintInfo.getContext()->clip(LayoutRect(rect.x(), rect.y(), width(), hei
ght())); |
1193 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, Layout
Rect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.s
ize(), op); | 1194 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, Layout
Rect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.s
ize(), op); |
1194 } | 1195 } |
1195 } | 1196 } |
1196 | 1197 |
1197 void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, Shadow
Style shadowStyle, const LayoutRect& paintRect) | 1198 void InlineFlowBox::paintBoxShadow(PaintInfo& info, RenderStyle* s, ShadowStyle
shadowStyle, const LayoutRect& paintRect) |
1198 { | 1199 { |
1199 if ((!prevLineBox() && !nextLineBox()) || !parent()) | 1200 if ((!prevLineBox() && !nextLineBox()) || !parent()) |
1200 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); | 1201 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); |
1201 else { | 1202 else { |
1202 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't | 1203 // FIXME: We can do better here in the multi-line case. We want to push
a clip so that the shadow doesn't |
1203 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines | 1204 // protrude incorrectly at the edges, and we want to possibly include sh
adows cast from the previous/following lines |
1204 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle, includ
eLogicalLeftEdge(), includeLogicalRightEdge()); | 1205 boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle, includ
eLogicalLeftEdge(), includeLogicalRightEdge()); |
1205 } | 1206 } |
1206 } | 1207 } |
1207 | 1208 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 clipRect.setHeight(paintRect.height() + outsets.top()); | 1248 clipRect.setHeight(paintRect.height() + outsets.top()); |
1248 } | 1249 } |
1249 if (box->includeLogicalRightEdge()) | 1250 if (box->includeLogicalRightEdge()) |
1250 clipRect.setHeight(clipRect.height() + outsets.bottom()); | 1251 clipRect.setHeight(clipRect.height() + outsets.bottom()); |
1251 } | 1252 } |
1252 return clipRect; | 1253 return clipRect; |
1253 } | 1254 } |
1254 | 1255 |
1255 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 1256 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
1256 { | 1257 { |
1257 if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->vis
ibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground) | 1258 if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->vis
ibility() != VISIBLE || paintInfo.getPhase() != PaintPhaseForeground) |
1258 return; | 1259 return; |
1259 | 1260 |
1260 // Pixel snap background/border painting. | 1261 // Pixel snap background/border painting. |
1261 LayoutRect frameRect = roundedFrameRect(); | 1262 LayoutRect frameRect = roundedFrameRect(); |
1262 | 1263 |
1263 constrainToLineTopAndBottomIfNeeded(frameRect); | 1264 constrainToLineTopAndBottomIfNeeded(frameRect); |
1264 | 1265 |
1265 // Move x/y to our coordinates. | 1266 // Move x/y to our coordinates. |
1266 LayoutRect localRect(frameRect); | 1267 LayoutRect localRect(frameRect); |
1267 flipForWritingMode(localRect); | 1268 flipForWritingMode(localRect); |
1268 LayoutPoint adjustedPaintoffset = paintOffset + localRect.location(); | 1269 LayoutPoint adjustedPaintoffset = paintOffset + localRect.location(); |
1269 | 1270 |
1270 GraphicsContext* context = paintInfo.context; | 1271 GraphicsContext* context = paintInfo.getContext(); |
1271 | 1272 |
1272 // You can use p::first-line to specify a background. If so, the root line b
oxes for | 1273 // You can use p::first-line to specify a background. If so, the root line b
oxes for |
1273 // a line may actually have to paint a background. | 1274 // a line may actually have to paint a background. |
1274 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); | 1275 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); |
1275 if ((!parent() && isFirstLineStyle() && styleToUse != renderer()->style()) |
| (parent() && renderer()->hasBoxDecorations())) { | 1276 if ((!parent() && isFirstLineStyle() && styleToUse != renderer()->style()) |
| (parent() && renderer()->hasBoxDecorations())) { |
1276 LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size())
; | 1277 LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size())
; |
1277 // Shadow comes first and is behind the background and border. | 1278 // Shadow comes first and is behind the background and border. |
1278 if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBl
eedNone, this)) | 1279 if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBl
eedNone, this)) |
1279 paintBoxShadow(paintInfo, styleToUse, Normal, paintRect); | 1280 paintBoxShadow(paintInfo, styleToUse, Normal, paintRect); |
1280 | 1281 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 GraphicsContextStateSaver stateSaver(*context); | 1320 GraphicsContextStateSaver stateSaver(*context); |
1320 context->clip(clipRect); | 1321 context->clip(clipRect); |
1321 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stri
pY, stripWidth, stripHeight), renderer()->style(isFirstLineStyle())); | 1322 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stri
pY, stripWidth, stripHeight), renderer()->style(isFirstLineStyle())); |
1322 } | 1323 } |
1323 } | 1324 } |
1324 } | 1325 } |
1325 } | 1326 } |
1326 | 1327 |
1327 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) | 1328 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) |
1328 { | 1329 { |
1329 if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->vis
ibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) | 1330 if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->vis
ibility() != VISIBLE || paintInfo.getPhase() != PaintPhaseMask) |
1330 return; | 1331 return; |
1331 | 1332 |
1332 // Pixel snap mask painting. | 1333 // Pixel snap mask painting. |
1333 LayoutRect frameRect = roundedFrameRect(); | 1334 LayoutRect frameRect = roundedFrameRect(); |
1334 | 1335 |
1335 constrainToLineTopAndBottomIfNeeded(frameRect); | 1336 constrainToLineTopAndBottomIfNeeded(frameRect); |
1336 | 1337 |
1337 // Move x/y to our coordinates. | 1338 // Move x/y to our coordinates. |
1338 LayoutRect localRect(frameRect); | 1339 LayoutRect localRect(frameRect); |
1339 flipForWritingMode(localRect); | 1340 flipForWritingMode(localRect); |
1340 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); | 1341 LayoutPoint adjustedPaintOffset = paintOffset + localRect.location(); |
1341 | 1342 |
1342 const NinePieceImage& maskNinePieceImage = renderer()->style()->maskBoxImage
(); | 1343 const NinePieceImage& maskNinePieceImage = renderer()->style()->maskBoxImage
(); |
1343 StyleImage* maskBoxImage = renderer()->style()->maskBoxImage().image(); | 1344 StyleImage* maskBoxImage = renderer()->style()->maskBoxImage().image(); |
1344 | 1345 |
1345 // Figure out if we need to push a transparency layer to render our mask. | 1346 // Figure out if we need to push a transparency layer to render our mask. |
1346 bool pushTransparencyLayer = false; | 1347 bool pushTransparencyLayer = false; |
1347 bool compositedMask = renderer()->hasLayer() && boxModelObject()->layer()->h
asCompositedMask(); | 1348 bool compositedMask = renderer()->hasLayer() && boxModelObject()->layer()->h
asCompositedMask(); |
1348 bool flattenCompositingLayers = renderer()->view()->frameView() && renderer(
)->view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; | 1349 bool flattenCompositingLayers = renderer()->view()->frameView() && renderer(
)->view()->frameView()->paintBehavior() & PaintBehaviorFlattenCompositingLayers; |
1349 CompositeOperator compositeOp = CompositeSourceOver; | 1350 CompositeOperator compositeOp = CompositeSourceOver; |
1350 if (!compositedMask || flattenCompositingLayers) { | 1351 if (!compositedMask || flattenCompositingLayers) { |
1351 if ((maskBoxImage && renderer()->style()->maskLayers()->hasImage()) || r
enderer()->style()->maskLayers()->next()) | 1352 if ((maskBoxImage && renderer()->style()->maskLayers()->hasImage()) || r
enderer()->style()->maskLayers()->next()) |
1352 pushTransparencyLayer = true; | 1353 pushTransparencyLayer = true; |
1353 | 1354 |
1354 compositeOp = CompositeDestinationIn; | 1355 compositeOp = CompositeDestinationIn; |
1355 if (pushTransparencyLayer) { | 1356 if (pushTransparencyLayer) { |
1356 paintInfo.context->setCompositeOperation(CompositeDestinationIn); | 1357 paintInfo.getContext()->setCompositeOperation(CompositeDestinationIn
); |
1357 paintInfo.context->beginTransparencyLayer(1.0f); | 1358 paintInfo.getContext()->beginTransparencyLayer(1.0f); |
1358 compositeOp = CompositeSourceOver; | 1359 compositeOp = CompositeSourceOver; |
1359 } | 1360 } |
1360 } | 1361 } |
1361 | 1362 |
1362 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); | 1363 LayoutRect paintRect = LayoutRect(adjustedPaintOffset, frameRect.size()); |
1363 paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), paint
Rect, compositeOp); | 1364 paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), paint
Rect, compositeOp); |
1364 | 1365 |
1365 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer(), rende
rer()->style()->effectiveZoom()); | 1366 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer(), rende
rer()->style()->effectiveZoom()); |
1366 if (!hasBoxImage || !maskBoxImage->isLoaded()) { | 1367 if (!hasBoxImage || !maskBoxImage->isLoaded()) { |
1367 if (pushTransparencyLayer) | 1368 if (pushTransparencyLayer) |
1368 paintInfo.context->endTransparencyLayer(); | 1369 paintInfo.getContext()->endTransparencyLayer(); |
1369 return; // Don't paint anything while we wait for the image to load. | 1370 return; // Don't paint anything while we wait for the image to load. |
1370 } | 1371 } |
1371 | 1372 |
1372 // The simple case is where we are the only box for this object. In those | 1373 // The simple case is where we are the only box for this object. In those |
1373 // cases only a single call to draw is required. | 1374 // cases only a single call to draw is required. |
1374 if (!prevLineBox() && !nextLineBox()) { | 1375 if (!prevLineBox() && !nextLineBox()) { |
1375 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(adju
stedPaintOffset, frameRect.size()), renderer()->style(), maskNinePieceImage, com
positeOp); | 1376 boxModelObject()->paintNinePieceImage(paintInfo.getContext(), LayoutRect
(adjustedPaintOffset, frameRect.size()), renderer()->style(), maskNinePieceImage
, compositeOp); |
1376 } else { | 1377 } else { |
1377 // We have a mask image that spans multiple lines. | 1378 // We have a mask image that spans multiple lines. |
1378 // We need to adjust _tx and _ty by the width of all previous lines. | 1379 // We need to adjust _tx and _ty by the width of all previous lines. |
1379 LayoutUnit logicalOffsetOnLine = 0; | 1380 LayoutUnit logicalOffsetOnLine = 0; |
1380 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox
()) | 1381 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->prevLineBox
()) |
1381 logicalOffsetOnLine += curr->logicalWidth(); | 1382 logicalOffsetOnLine += curr->logicalWidth(); |
1382 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; | 1383 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; |
1383 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) | 1384 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) |
1384 totalLogicalWidth += curr->logicalWidth(); | 1385 totalLogicalWidth += curr->logicalWidth(); |
1385 LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logicalO
ffsetOnLine : LayoutUnit()); | 1386 LayoutUnit stripX = adjustedPaintOffset.x() - (isHorizontal() ? logicalO
ffsetOnLine : LayoutUnit()); |
1386 LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? LayoutUn
it() : logicalOffsetOnLine); | 1387 LayoutUnit stripY = adjustedPaintOffset.y() - (isHorizontal() ? LayoutUn
it() : logicalOffsetOnLine); |
1387 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.w
idth(); | 1388 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.w
idth(); |
1388 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogi
calWidth; | 1389 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : totalLogi
calWidth; |
1389 | 1390 |
1390 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePiece
Image, paintRect); | 1391 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, maskNinePiece
Image, paintRect); |
1391 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 1392 GraphicsContextStateSaver stateSaver(*paintInfo.getContext()); |
1392 paintInfo.context->clip(clipRect); | 1393 paintInfo.getContext()->clip(clipRect); |
1393 boxModelObject()->paintNinePieceImage(paintInfo.context, LayoutRect(stri
pX, stripY, stripWidth, stripHeight), renderer()->style(), maskNinePieceImage, c
ompositeOp); | 1394 boxModelObject()->paintNinePieceImage(paintInfo.getContext(), LayoutRect
(stripX, stripY, stripWidth, stripHeight), renderer()->style(), maskNinePieceIma
ge, compositeOp); |
1394 } | 1395 } |
1395 | 1396 |
1396 if (pushTransparencyLayer) | 1397 if (pushTransparencyLayer) |
1397 paintInfo.context->endTransparencyLayer(); | 1398 paintInfo.getContext()->endTransparencyLayer(); |
1398 } | 1399 } |
1399 | 1400 |
1400 InlineBox* InlineFlowBox::firstLeafChild() const | 1401 InlineBox* InlineFlowBox::firstLeafChild() const |
1401 { | 1402 { |
1402 InlineBox* leaf = 0; | 1403 InlineBox* leaf = 0; |
1403 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL
ine()) | 1404 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL
ine()) |
1404 leaf = child->isLeaf() ? child : toInlineFlowBox(child)->firstLeafChild(
); | 1405 leaf = child->isLeaf() ? child : toInlineFlowBox(child)->firstLeafChild(
); |
1405 return leaf; | 1406 return leaf; |
1406 } | 1407 } |
1407 | 1408 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 ASSERT(child->prevOnLine() == prev); | 1636 ASSERT(child->prevOnLine() == prev); |
1636 prev = child; | 1637 prev = child; |
1637 } | 1638 } |
1638 ASSERT(prev == m_lastChild); | 1639 ASSERT(prev == m_lastChild); |
1639 #endif | 1640 #endif |
1640 } | 1641 } |
1641 | 1642 |
1642 #endif | 1643 #endif |
1643 | 1644 |
1644 } // namespace WebCore | 1645 } // namespace WebCore |
OLD | NEW |