LEFT | RIGHT |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 } | 1110 } |
1111 | 1111 |
1112 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); | 1112 bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset); |
1113 paintObject(paintInfo, adjustedPaintOffset); | 1113 paintObject(paintInfo, adjustedPaintOffset); |
1114 if (pushedClip) | 1114 if (pushedClip) |
1115 popContentsClip(paintInfo, phase, adjustedPaintOffset); | 1115 popContentsClip(paintInfo, phase, adjustedPaintOffset); |
1116 | 1116 |
1117 // Our scrollbar widgets paint exactly when we tell them to, so that they wo
rk properly with | 1117 // Our scrollbar widgets paint exactly when we tell them to, so that they wo
rk properly with |
1118 // z-index. We paint after we painted the background/border, so that the scr
ollbars will | 1118 // z-index. We paint after we painted the background/border, so that the scr
ollbars will |
1119 // sit above the background/border. | 1119 // sit above the background/border. |
1120 if ((phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBlockBack
ground) && hasOverflowClip() && layer() | 1120 if ((phase == PaintPhase::BlockBackground || phase == PaintPhase::ChildBlock
Background) && hasOverflowClip() && layer() |
1121 && style().visibility() == Visibility::Visible && paintInfo.shouldPaintW
ithinRoot(*this) && !paintInfo.paintRootBackgroundOnly()) | 1121 && style().visibility() == Visibility::Visible && paintInfo.shouldPaintW
ithinRoot(*this) && !paintInfo.paintRootBackgroundOnly()) |
1122 layer()->paintOverflowControls(paintInfo.context(), roundedIntPoint(adju
stedPaintOffset), snappedIntRect(paintInfo.rect)); | 1122 layer()->paintOverflowControls(paintInfo.context(), roundedIntPoint(adju
stedPaintOffset), snappedIntRect(paintInfo.rect)); |
1123 } | 1123 } |
1124 | 1124 |
1125 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) | 1125 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) |
1126 { | 1126 { |
1127 // Style is non-final if the element has a pending stylesheet before it. We
end up with renderers with such styles if a script | 1127 // Style is non-final if the element has a pending stylesheet before it. We
end up with renderers with such styles if a script |
1128 // forces renderer construction by querying something layout dependent. | 1128 // forces renderer construction by querying something layout dependent. |
1129 // Avoid FOUC by not painting. Switching to final style triggers repaint. | 1129 // Avoid FOUC by not painting. Switching to final style triggers repaint. |
1130 if (style().isNotFinal()) | 1130 if (style().isNotFinal()) |
1131 return; | 1131 return; |
1132 | 1132 |
1133 if (childrenInline()) | 1133 if (childrenInline()) |
1134 paintInlineChildren(paintInfo, paintOffset); | 1134 paintInlineChildren(paintInfo, paintOffset); |
1135 else { | 1135 else { |
1136 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai
ntPhaseOutline : paintInfo.phase; | 1136 PaintPhase newPhase = (paintInfo.phase == PaintPhase::ChildOutlines) ? P
aintPhase::Outline : paintInfo.phase; |
1137 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi
ldBlockBackground : newPhase; | 1137 newPhase = (newPhase == PaintPhase::ChildBlockBackgrounds) ? PaintPhase:
:ChildBlockBackground : newPhase; |
1138 | 1138 |
1139 // We don't paint our own background, but we do let the kids paint their
backgrounds. | 1139 // We don't paint our own background, but we do let the kids paint their
backgrounds. |
1140 PaintInfo paintInfoForChild(paintInfo); | 1140 PaintInfo paintInfoForChild(paintInfo); |
1141 paintInfoForChild.phase = newPhase; | 1141 paintInfoForChild.phase = newPhase; |
1142 paintInfoForChild.updateSubtreePaintRootForChildren(this); | 1142 paintInfoForChild.updateSubtreePaintRootForChildren(this); |
1143 | 1143 |
1144 // FIXME: Paint-time pagination is obsolete and is now only used by embe
dded WebViews inside AppKit | 1144 // FIXME: Paint-time pagination is obsolete and is now only used by embe
dded WebViews inside AppKit |
1145 // NSViews. Do not add any more code for this. | 1145 // NSViews. Do not add any more code for this. |
1146 bool usePrintRect = !view().printRect().isEmpty(); | 1146 bool usePrintRect = !view().printRect().isEmpty(); |
1147 paintChildren(paintInfo, paintOffset, paintInfoForChild, usePrintRect); | 1147 paintChildren(paintInfo, paintOffset, paintInfoForChild, usePrintRect); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 else | 1221 else |
1222 page().dragCaretController().paintDragCaret(&frame(), paintInfo.cont
ext(), paintOffset, paintInfo.rect); | 1222 page().dragCaretController().paintDragCaret(&frame(), paintInfo.cont
ext(), paintOffset, paintInfo.rect); |
1223 } | 1223 } |
1224 } | 1224 } |
1225 | 1225 |
1226 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) | 1226 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
et) |
1227 { | 1227 { |
1228 PaintPhase paintPhase = paintInfo.phase; | 1228 PaintPhase paintPhase = paintInfo.phase; |
1229 | 1229 |
1230 // 1. paint background, borders etc | 1230 // 1. paint background, borders etc |
1231 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil
dBlockBackground) && style().visibility() == Visibility::Visible) { | 1231 if ((paintPhase == PaintPhase::BlockBackground || paintPhase == PaintPhase::
ChildBlockBackground) && style().visibility() == Visibility::Visible) { |
1232 if (hasVisibleBoxDecorations()) | 1232 if (hasVisibleBoxDecorations()) |
1233 paintBoxDecorations(paintInfo, paintOffset); | 1233 paintBoxDecorations(paintInfo, paintOffset); |
1234 } | 1234 } |
1235 ···· | 1235 ···· |
1236 // Paint legends just above the border before we scroll or clip. | 1236 // Paint legends just above the border before we scroll or clip. |
1237 if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChild
BlockBackground || paintPhase == PaintPhaseSelection) | 1237 if (paintPhase == PaintPhase::BlockBackground || paintPhase == PaintPhase::C
hildBlockBackground || paintPhase == PaintPhase::Selection) |
1238 paintExcludedChildrenInBorder(paintInfo, paintOffset); | 1238 paintExcludedChildrenInBorder(paintInfo, paintOffset); |
1239 ···· | 1239 ···· |
1240 if (paintPhase == PaintPhaseMask && style().visibility() == Visibility::Visi
ble) { | 1240 if (paintPhase == PaintPhase::Mask && style().visibility() == Visibility::Vi
sible) { |
1241 paintMask(paintInfo, paintOffset); | 1241 paintMask(paintInfo, paintOffset); |
1242 return; | 1242 return; |
1243 } | 1243 } |
1244 | 1244 |
1245 if (paintPhase == PaintPhaseClippingMask && style().visibility() == Visibili
ty::Visible) { | 1245 if (paintPhase == PaintPhase::ClippingMask && style().visibility() == Visibi
lity::Visible) { |
1246 paintClippingMask(paintInfo, paintOffset); | 1246 paintClippingMask(paintInfo, paintOffset); |
1247 return; | 1247 return; |
1248 } | 1248 } |
1249 | 1249 |
1250 // If just painting the root background, then return. | 1250 // If just painting the root background, then return. |
1251 if (paintInfo.paintRootBackgroundOnly()) | 1251 if (paintInfo.paintRootBackgroundOnly()) |
1252 return; | 1252 return; |
1253 | 1253 |
1254 // Adjust our painting position if we're inside a scrolled layer (e.g., an o
verflow:auto div). | 1254 // Adjust our painting position if we're inside a scrolled layer (e.g., an o
verflow:auto div). |
1255 LayoutPoint scrolledOffset = paintOffset; | 1255 LayoutPoint scrolledOffset = paintOffset; |
1256 scrolledOffset.moveBy(-scrollPosition()); | 1256 scrolledOffset.moveBy(-scrollPosition()); |
1257 | 1257 |
1258 // Column rules need to account for scrolling and clipping. | 1258 // Column rules need to account for scrolling and clipping. |
1259 // FIXME: Clipping of column rules does not work. We will need a separate pa
int phase for column rules I suspect in order to get | 1259 // FIXME: Clipping of column rules does not work. We will need a separate pa
int phase for column rules I suspect in order to get |
1260 // clipping correct (since it has to paint as background but is still consid
ered "contents"). | 1260 // clipping correct (since it has to paint as background but is still consid
ered "contents"). |
1261 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil
dBlockBackground) && style().visibility() == Visibility::Visible) | 1261 if ((paintPhase == PaintPhase::BlockBackground || paintPhase == PaintPhase::
ChildBlockBackground) && style().visibility() == Visibility::Visible) |
1262 paintColumnRules(paintInfo, scrolledOffset); | 1262 paintColumnRules(paintInfo, scrolledOffset); |
1263 | 1263 |
1264 // Done with backgrounds, borders and column rules. | 1264 // Done with backgrounds, borders and column rules. |
1265 if (paintPhase == PaintPhaseBlockBackground) | 1265 if (paintPhase == PaintPhase::BlockBackground) |
1266 return; | 1266 return; |
1267 ···· | 1267 ···· |
1268 // 2. paint contents | 1268 // 2. paint contents |
1269 if (paintPhase != PaintPhaseSelfOutline) | 1269 if (paintPhase != PaintPhase::SelfOutline) |
1270 paintContents(paintInfo, scrolledOffset); | 1270 paintContents(paintInfo, scrolledOffset); |
1271 | 1271 |
1272 // 3. paint selection | 1272 // 3. paint selection |
1273 // FIXME: Make this work with multi column layouts. For now don't fill gaps
. | 1273 // FIXME: Make this work with multi column layouts. For now don't fill gaps
. |
1274 bool isPrinting = document().printing(); | 1274 bool isPrinting = document().printing(); |
1275 if (!isPrinting) | 1275 if (!isPrinting) |
1276 paintSelection(paintInfo, scrolledOffset); // Fill in gaps in selection
on lines and between blocks. | 1276 paintSelection(paintInfo, scrolledOffset); // Fill in gaps in selection
on lines and between blocks. |
1277 | 1277 |
1278 // 4. paint floats. | 1278 // 4. paint floats. |
1279 if (paintPhase == PaintPhaseFloat || paintPhase == PaintPhaseSelection || pa
intPhase == PaintPhaseTextClip) | 1279 if (paintPhase == PaintPhase::Float || paintPhase == PaintPhase::Selection |
| paintPhase == PaintPhase::TextClip) |
1280 paintFloats(paintInfo, scrolledOffset, paintPhase == PaintPhaseSelection
|| paintPhase == PaintPhaseTextClip); | 1280 paintFloats(paintInfo, scrolledOffset, paintPhase == PaintPhase::Selecti
on || paintPhase == PaintPhase::TextClip); |
1281 | 1281 |
1282 // 5. paint outline. | 1282 // 5. paint outline. |
1283 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline)
&& hasOutline() && style().visibility() == Visibility::Visible) | 1283 if ((paintPhase == PaintPhase::Outline || paintPhase == PaintPhase::SelfOutl
ine) && hasOutline() && style().visibility() == Visibility::Visible) |
1284 paintOutline(paintInfo, LayoutRect(paintOffset, size())); | 1284 paintOutline(paintInfo, LayoutRect(paintOffset, size())); |
1285 | 1285 |
1286 // 6. paint continuation outlines. | 1286 // 6. paint continuation outlines. |
1287 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseChildOutline
s)) { | 1287 if ((paintPhase == PaintPhase::Outline || paintPhase == PaintPhase::ChildOut
lines)) { |
1288 RenderInline* inlineCont = inlineContinuation(); | 1288 RenderInline* inlineCont = inlineContinuation(); |
1289 if (inlineCont && inlineCont->hasOutline() && inlineCont->style().visibi
lity() == Visibility::Visible) { | 1289 if (inlineCont && inlineCont->hasOutline() && inlineCont->style().visibi
lity() == Visibility::Visible) { |
1290 RenderInline* inlineRenderer = downcast<RenderInline>(inlineCont->el
ement()->renderer()); | 1290 RenderInline* inlineRenderer = downcast<RenderInline>(inlineCont->el
ement()->renderer()); |
1291 RenderBlock* containingBlock = this->containingBlock(); | 1291 RenderBlock* containingBlock = this->containingBlock(); |
1292 | 1292 |
1293 bool inlineEnclosedInSelfPaintingLayer = false; | 1293 bool inlineEnclosedInSelfPaintingLayer = false; |
1294 for (RenderBoxModelObject* box = inlineRenderer; box != containingBl
ock; box = &box->parent()->enclosingBoxModelObject()) { | 1294 for (RenderBoxModelObject* box = inlineRenderer; box != containingBl
ock; box = &box->parent()->enclosingBoxModelObject()) { |
1295 if (box->hasSelfPaintingLayer()) { | 1295 if (box->hasSelfPaintingLayer()) { |
1296 inlineEnclosedInSelfPaintingLayer = true; | 1296 inlineEnclosedInSelfPaintingLayer = true; |
1297 break; | 1297 break; |
1298 } | 1298 } |
1299 } | 1299 } |
1300 | 1300 |
1301 // Do not add continuations for outline painting by our containing b
lock if we are a relative positioned | 1301 // Do not add continuations for outline painting by our containing b
lock if we are a relative positioned |
1302 // anonymous block (i.e. have our own layer), paint them straightawa
y instead. This is because a block depends on renderers in its continuation tabl
e being | 1302 // anonymous block (i.e. have our own layer), paint them straightawa
y instead. This is because a block depends on renderers in its continuation tabl
e being |
1303 // in the same layer.· | 1303 // in the same layer.· |
1304 if (!inlineEnclosedInSelfPaintingLayer && !hasLayer()) | 1304 if (!inlineEnclosedInSelfPaintingLayer && !hasLayer()) |
1305 containingBlock->addContinuationWithOutline(inlineRenderer); | 1305 containingBlock->addContinuationWithOutline(inlineRenderer); |
1306 else if (!inlineRenderer->firstLineBox() || (!inlineEnclosedInSelfPa
intingLayer && hasLayer())) | 1306 else if (!inlineRenderer->firstLineBox() || (!inlineEnclosedInSelfPa
intingLayer && hasLayer())) |
1307 inlineRenderer->paintOutline(paintInfo, paintOffset - locationOf
fset() + inlineRenderer->containingBlock()->location()); | 1307 inlineRenderer->paintOutline(paintInfo, paintOffset - locationOf
fset() + inlineRenderer->containingBlock()->location()); |
1308 } | 1308 } |
1309 paintContinuationOutlines(paintInfo, paintOffset); | 1309 paintContinuationOutlines(paintInfo, paintOffset); |
1310 } | 1310 } |
1311 | 1311 |
1312 // 7. paint caret. | 1312 // 7. paint caret. |
1313 // If the caret's node's render object's containing block is this block, and
the paint action is PaintPhaseForeground, | 1313 // If the caret's node's render object's containing block is this block, and
the paint action is PaintPhase::Foreground, |
1314 // then paint the caret. | 1314 // then paint the caret. |
1315 if (paintPhase == PaintPhaseForeground) { | 1315 if (paintPhase == PaintPhase::Foreground) { |
1316 paintCaret(paintInfo, paintOffset, CursorCaret); | 1316 paintCaret(paintInfo, paintOffset, CursorCaret); |
1317 paintCaret(paintInfo, paintOffset, DragCaret); | 1317 paintCaret(paintInfo, paintOffset, DragCaret); |
1318 } | 1318 } |
1319 } | 1319 } |
1320 | 1320 |
1321 static ContinuationOutlineTableMap* continuationOutlineTable() | 1321 static ContinuationOutlineTableMap* continuationOutlineTable() |
1322 { | 1322 { |
1323 static NeverDestroyed<ContinuationOutlineTableMap> table; | 1323 static NeverDestroyed<ContinuationOutlineTableMap> table; |
1324 return &table.get(); | 1324 return &table.get(); |
1325 } | 1325 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 LayoutUnit lastTop = 0; | 1425 LayoutUnit lastTop = 0; |
1426 LayoutUnit lastLeft = logicalLeftSelectionOffset(*this, lastTop, cache); | 1426 LayoutUnit lastLeft = logicalLeftSelectionOffset(*this, lastTop, cache); |
1427 LayoutUnit lastRight = logicalRightSelectionOffset(*this, lastTop, cache); | 1427 LayoutUnit lastRight = logicalRightSelectionOffset(*this, lastTop, cache); |
1428 ···· | 1428 ···· |
1429 return selectionGaps(*this, offsetFromRepaintContainer, IntSize(), lastTop,
lastLeft, lastRight, cache); | 1429 return selectionGaps(*this, offsetFromRepaintContainer, IntSize(), lastTop,
lastLeft, lastRight, cache); |
1430 } | 1430 } |
1431 | 1431 |
1432 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) | 1432 void RenderBlock::paintSelection(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset) |
1433 { | 1433 { |
1434 #if ENABLE(TEXT_SELECTION) | 1434 #if ENABLE(TEXT_SELECTION) |
1435 if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhaseForeground) { | 1435 if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhase::Foreground)
{ |
1436 LogicalSelectionOffsetCaches cache(*this); | 1436 LogicalSelectionOffsetCaches cache(*this); |
1437 LayoutUnit lastTop = 0; | 1437 LayoutUnit lastTop = 0; |
1438 LayoutUnit lastLeft = logicalLeftSelectionOffset(*this, lastTop, cache); | 1438 LayoutUnit lastLeft = logicalLeftSelectionOffset(*this, lastTop, cache); |
1439 LayoutUnit lastRight = logicalRightSelectionOffset(*this, lastTop, cache
); | 1439 LayoutUnit lastRight = logicalRightSelectionOffset(*this, lastTop, cache
); |
1440 GraphicsContextStateSaver stateSaver(paintInfo.context()); | 1440 GraphicsContextStateSaver stateSaver(paintInfo.context()); |
1441 | 1441 |
1442 LayoutRect gapRectsBounds = selectionGaps(*this, paintOffset, LayoutSize
(), lastTop, lastLeft, lastRight, cache, &paintInfo); | 1442 LayoutRect gapRectsBounds = selectionGaps(*this, paintOffset, LayoutSize
(), lastTop, lastLeft, lastRight, cache, &paintInfo); |
1443 if (!gapRectsBounds.isEmpty()) { | 1443 if (!gapRectsBounds.isEmpty()) { |
1444 if (RenderLayer* layer = enclosingLayer()) { | 1444 if (RenderLayer* layer = enclosingLayer()) { |
1445 gapRectsBounds.moveBy(-paintOffset); | 1445 gapRectsBounds.moveBy(-paintOffset); |
(...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3486 return false; | 3486 return false; |
3487 | 3487 |
3488 HitTestAction childHitTest = hitTestAction; | 3488 HitTestAction childHitTest = hitTestAction; |
3489 if (hitTestAction == HitTestChildBlockBackgrounds) | 3489 if (hitTestAction == HitTestChildBlockBackgrounds) |
3490 childHitTest = HitTestChildBlockBackground; | 3490 childHitTest = HitTestChildBlockBackground; |
3491 LayoutPoint childPoint = flipForWritingModeForChild(legend, accumulatedOffse
t); | 3491 LayoutPoint childPoint = flipForWritingModeForChild(legend, accumulatedOffse
t); |
3492 return legend->nodeAtPoint(request, result, locationInContainer, childPoint,
childHitTest); | 3492 return legend->nodeAtPoint(request, result, locationInContainer, childPoint,
childHitTest); |
3493 } | 3493 } |
3494 ···· | 3494 ···· |
3495 } // namespace WebCore | 3495 } // namespace WebCore |
LEFT | RIGHT |