OLD | NEW |
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) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 } | 1302 } |
1303 | 1303 |
1304 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS
tate& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationConta
iner) | 1304 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS
tate& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationConta
iner) |
1305 { | 1305 { |
1306 LayoutView* v = view(); | 1306 LayoutView* v = view(); |
1307 if (v->document().printing()) | 1307 if (v->document().printing()) |
1308 return PaintInvalidationNone; // Don't invalidate paints if we're printi
ng. | 1308 return PaintInvalidationNone; // Don't invalidate paints if we're printi
ng. |
1309 | 1309 |
1310 const LayoutRect oldBounds = previousPaintInvalidationRect(); | 1310 const LayoutRect oldBounds = previousPaintInvalidationRect(); |
1311 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking
(); | 1311 const LayoutPoint oldLocation = previousPositionFromPaintInvalidationBacking
(); |
1312 const LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidati
onContainer, &paintInvalidationState); | 1312 LayoutRect newBounds = boundsRectForPaintInvalidation(&paintInvalidationCont
ainer, &paintInvalidationState); |
1313 const LayoutPoint newLocation = DeprecatedPaintLayer::positionFromPaintInval
idationBacking(this, &paintInvalidationContainer, &paintInvalidationState); | 1313 LayoutPoint newLocation = DeprecatedPaintLayer::positionFromPaintInvalidatio
nBacking(this, &paintInvalidationContainer, &paintInvalidationState); |
| 1314 |
| 1315 // Composited scrolling should not be included in the bounds and position tr
acking, because the graphics layer backing the scroller |
| 1316 // does not move on scroll. |
| 1317 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati
onContainer != this) { |
| 1318 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol
ledContentOffset()); |
| 1319 newLocation.move(inverseOffset); |
| 1320 newBounds.move(inverseOffset); |
| 1321 } |
| 1322 |
1314 setPreviousPaintInvalidationRect(newBounds); | 1323 setPreviousPaintInvalidationRect(newBounds); |
1315 setPreviousPositionFromPaintInvalidationBacking(newLocation); | 1324 setPreviousPositionFromPaintInvalidationBacking(newLocation); |
1316 | 1325 |
1317 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn
validationContainer, oldBounds, oldLocation, newBounds, newLocation); | 1326 PaintInvalidationReason invalidationReason = paintInvalidationReason(paintIn
validationContainer, oldBounds, oldLocation, newBounds, newLocation); |
1318 | 1327 |
1319 // We need to invalidate the selection before checking for whether we are do
ing a full invalidation. | 1328 // We need to invalidate the selection before checking for whether we are do
ing a full invalidation. |
1320 // This is because we need to update the old rect regardless. | 1329 // This is because we need to update the old rect regardless. |
1321 invalidateSelectionIfNeeded(paintInvalidationContainer, invalidationReason); | 1330 invalidateSelectionIfNeeded(paintInvalidationContainer, invalidationReason); |
1322 | 1331 |
1323 // If we are set to do a full paint invalidation that means the LayoutView w
ill issue | 1332 // If we are set to do a full paint invalidation that means the LayoutView w
ill issue |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 // into the incremental invalidation we'll issue two invalidations instead | 1414 // into the incremental invalidation we'll issue two invalidations instead |
1406 // of one. | 1415 // of one. |
1407 if (oldBounds.isEmpty()) | 1416 if (oldBounds.isEmpty()) |
1408 return PaintInvalidationBecameVisible; | 1417 return PaintInvalidationBecameVisible; |
1409 if (newBounds.isEmpty()) | 1418 if (newBounds.isEmpty()) |
1410 return PaintInvalidationBecameInvisible; | 1419 return PaintInvalidationBecameInvisible; |
1411 | 1420 |
1412 return PaintInvalidationIncremental; | 1421 return PaintInvalidationIncremental; |
1413 } | 1422 } |
1414 | 1423 |
| 1424 void LayoutObject::adjustInvalidationRectForCompositedScrolling(LayoutRect& rect
, const LayoutBoxModelObject& paintInvalidationContainer) const |
| 1425 { |
| 1426 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati
onContainer != this) { |
| 1427 LayoutSize offset(-toLayoutBox(&paintInvalidationContainer)->scrolledCon
tentOffset()); |
| 1428 rect.move(offset); |
| 1429 } |
| 1430 } |
| 1431 |
| 1432 LayoutRect LayoutObject::previousPaintInvalidationRectIncludingCompositedScrolli
ng(const LayoutBoxModelObject& paintInvalidationContainer) const |
| 1433 { |
| 1434 LayoutRect invalidationRect = previousPaintInvalidationRect(); |
| 1435 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInvalida
tionContainer); |
| 1436 return invalidationRect; |
| 1437 } |
| 1438 |
| 1439 void LayoutObject::adjustPreviousPaintInvalidationForScrollIfNeeded(const Double
Size& scrollDelta) |
| 1440 { |
| 1441 if (containerForPaintInvalidation()->usesCompositedScrolling()) |
| 1442 return; |
| 1443 m_previousPaintInvalidationRect.move(LayoutSize(scrollDelta)); |
| 1444 } |
| 1445 |
1415 void LayoutObject::incrementallyInvalidatePaint(const LayoutBoxModelObject& pain
tInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds
, const LayoutPoint& positionFromPaintInvalidationBacking) | 1446 void LayoutObject::incrementallyInvalidatePaint(const LayoutBoxModelObject& pain
tInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds
, const LayoutPoint& positionFromPaintInvalidationBacking) |
1416 { | 1447 { |
1417 ASSERT(oldBounds.location() == newBounds.location()); | 1448 ASSERT(oldBounds.location() == newBounds.location()); |
1418 | 1449 |
1419 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); | 1450 LayoutUnit deltaRight = newBounds.maxX() - oldBounds.maxX(); |
1420 if (deltaRight > 0) | 1451 if (deltaRight > 0) { |
1421 invalidatePaintUsingContainer(paintInvalidationContainer, LayoutRect(old
Bounds.maxX(), newBounds.y(), deltaRight, newBounds.height()), PaintInvalidation
Incremental); | 1452 LayoutRect invalidationRect(oldBounds.maxX(), newBounds.y(), deltaRight,
newBounds.height()); |
1422 else if (deltaRight < 0) | 1453 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva
lidationContainer); |
1423 invalidatePaintUsingContainer(paintInvalidationContainer, LayoutRect(new
Bounds.maxX(), oldBounds.y(), -deltaRight, oldBounds.height()), PaintInvalidatio
nIncremental); | 1454 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe
ct, PaintInvalidationIncremental); |
| 1455 } else if (deltaRight < 0) { |
| 1456 LayoutRect invalidationRect(newBounds.maxX(), oldBounds.y(), -deltaRight
, oldBounds.height()); |
| 1457 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva
lidationContainer); |
| 1458 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe
ct, PaintInvalidationIncremental); |
| 1459 } |
1424 | 1460 |
1425 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY(); | 1461 LayoutUnit deltaBottom = newBounds.maxY() - oldBounds.maxY(); |
1426 if (deltaBottom > 0) | 1462 if (deltaBottom > 0) { |
1427 invalidatePaintUsingContainer(paintInvalidationContainer, LayoutRect(new
Bounds.x(), oldBounds.maxY(), newBounds.width(), deltaBottom), PaintInvalidation
Incremental); | 1463 LayoutRect invalidationRect(newBounds.x(), oldBounds.maxY(), newBounds.w
idth(), deltaBottom); |
1428 else if (deltaBottom < 0) | 1464 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva
lidationContainer); |
1429 invalidatePaintUsingContainer(paintInvalidationContainer, LayoutRect(old
Bounds.x(), newBounds.maxY(), oldBounds.width(), -deltaBottom), PaintInvalidatio
nIncremental); | 1465 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe
ct, PaintInvalidationIncremental); |
| 1466 } else if (deltaBottom < 0) { |
| 1467 LayoutRect invalidationRect(oldBounds.x(), newBounds.maxY(), oldBounds.w
idth(), -deltaBottom); |
| 1468 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva
lidationContainer); |
| 1469 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe
ct, PaintInvalidationIncremental); |
| 1470 } |
1430 } | 1471 } |
1431 | 1472 |
1432 void LayoutObject::fullyInvalidatePaint(const LayoutBoxModelObject& paintInvalid
ationContainer, PaintInvalidationReason invalidationReason, const LayoutRect& ol
dBounds, const LayoutRect& newBounds) | 1473 void LayoutObject::fullyInvalidatePaint(const LayoutBoxModelObject& paintInvalid
ationContainer, PaintInvalidationReason invalidationReason, const LayoutRect& ol
dBounds, const LayoutRect& newBounds) |
1433 { | 1474 { |
1434 // Otherwise do full paint invalidation. | 1475 // Otherwise do full paint invalidation. |
1435 invalidatePaintUsingContainer(paintInvalidationContainer, oldBounds, invalid
ationReason); | 1476 LayoutRect invalidationRect = oldBounds; |
1436 if (newBounds != oldBounds) | 1477 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInvalida
tionContainer); |
1437 invalidatePaintUsingContainer(paintInvalidationContainer, newBounds, inv
alidationReason); | 1478 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRect,
invalidationReason); |
| 1479 if (newBounds != oldBounds) { |
| 1480 invalidationRect = newBounds; |
| 1481 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInva
lidationContainer); |
| 1482 invalidatePaintUsingContainer(paintInvalidationContainer, invalidationRe
ct, invalidationReason); |
| 1483 } |
1438 } | 1484 } |
1439 | 1485 |
1440 void LayoutObject::invalidatePaintForOverflow() | 1486 void LayoutObject::invalidatePaintForOverflow() |
1441 { | 1487 { |
1442 } | 1488 } |
1443 | 1489 |
1444 void LayoutObject::invalidatePaintForOverflowIfNeeded() | 1490 void LayoutObject::invalidatePaintForOverflowIfNeeded() |
1445 { | 1491 { |
1446 if (shouldInvalidateOverflowForPaint()) | 1492 if (shouldInvalidateOverflowForPaint()) |
1447 invalidatePaintForOverflow(); | 1493 invalidatePaintForOverflow(); |
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3270 traverseNonCompositingDescendants(const_cast<LayoutObject&>(object), Functor
(paintInvalidationContainer)); | 3316 traverseNonCompositingDescendants(const_cast<LayoutObject&>(object), Functor
(paintInvalidationContainer)); |
3271 } | 3317 } |
3272 | 3318 |
3273 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() | 3319 void LayoutObject::invalidatePaintIncludingNonCompositingDescendants() |
3274 { | 3320 { |
3275 class Functor : public LayoutObjectTraversalFunctor { | 3321 class Functor : public LayoutObjectTraversalFunctor { |
3276 public: | 3322 public: |
3277 explicit Functor(const LayoutBoxModelObject& paintInvalidationContainer)
: m_paintInvalidationContainer(paintInvalidationContainer) { } | 3323 explicit Functor(const LayoutBoxModelObject& paintInvalidationContainer)
: m_paintInvalidationContainer(paintInvalidationContainer) { } |
3278 void operator()(LayoutObject& object) const override | 3324 void operator()(LayoutObject& object) const override |
3279 { | 3325 { |
3280 object.invalidatePaintUsingContainer(m_paintInvalidationContainer, o
bject.previousPaintInvalidationRect(), PaintInvalidationLayer); | 3326 LayoutRect invalidationRect = object.previousPaintInvalidationRect()
; |
| 3327 object.adjustInvalidationRectForCompositedScrolling(invalidationRect
, m_paintInvalidationContainer); |
| 3328 object.invalidatePaintUsingContainer(m_paintInvalidationContainer, i
nvalidationRect, PaintInvalidationLayer); |
3281 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | 3329 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
3282 object.invalidateDisplayItemClients(m_paintInvalidationContainer
); | 3330 object.invalidateDisplayItemClients(m_paintInvalidationContainer
); |
3283 } | 3331 } |
3284 private: | 3332 private: |
3285 const LayoutBoxModelObject& m_paintInvalidationContainer; | 3333 const LayoutBoxModelObject& m_paintInvalidationContainer; |
3286 }; | 3334 }; |
3287 | 3335 |
3288 // Since we're only painting non-composited layers, we know that they all sh
are the same paintInvalidationContainer. | 3336 // Since we're only painting non-composited layers, we know that they all sh
are the same paintInvalidationContainer. |
3289 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn
validationOnRootedTree(); | 3337 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn
validationOnRootedTree(); |
3290 traverseNonCompositingDescendants(*this, Functor(paintInvalidationContainer)
); | 3338 traverseNonCompositingDescendants(*this, Functor(paintInvalidationContainer)
); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3349 const blink::LayoutObject* root = object1; | 3397 const blink::LayoutObject* root = object1; |
3350 while (root->parent()) | 3398 while (root->parent()) |
3351 root = root->parent(); | 3399 root = root->parent(); |
3352 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3400 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
3353 } else { | 3401 } else { |
3354 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); | 3402 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); |
3355 } | 3403 } |
3356 } | 3404 } |
3357 | 3405 |
3358 #endif | 3406 #endif |
OLD | NEW |