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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 2037713002: Adjust for composited scrolling when invalidating paint rectangles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 ASSERT(!paintingLayer() || paintingLayer()->needsRepaint()); 1261 ASSERT(!paintingLayer() || paintingLayer()->needsRepaint());
1262 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*this, inval idationReason, this); 1262 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*this, inval idationReason, this);
1263 } 1263 }
1264 1264
1265 void LayoutObject::invalidateDisplayItemClientsWithPaintInvalidationState(const LayoutBoxModelObject& paintInvalidationContainer, const PaintInvalidationState& paintInvalidationState, PaintInvalidationReason invalidationReason) const 1265 void LayoutObject::invalidateDisplayItemClientsWithPaintInvalidationState(const LayoutBoxModelObject& paintInvalidationContainer, const PaintInvalidationState& paintInvalidationState, PaintInvalidationReason invalidationReason) const
1266 { 1266 {
1267 paintInvalidationState.paintingLayer().setNeedsRepaint(); 1267 paintInvalidationState.paintingLayer().setNeedsRepaint();
1268 invalidateDisplayItemClients(paintInvalidationContainer, invalidationReason) ; 1268 invalidateDisplayItemClients(paintInvalidationContainer, invalidationReason) ;
1269 } 1269 }
1270 1270
1271
1272 bool LayoutObject::compositedScrollsWithRespectTo(const LayoutBoxModelObject& pa intInvalidationContainer) const
1273 {
1274 return paintInvalidationContainer.usesCompositedScrolling() && this != &pain tInvalidationContainer;
1275 }
1276
1271 const LayoutBoxModelObject* LayoutObject::invalidatePaintRectangleInternal(const LayoutRect& dirtyRect) const 1277 const LayoutBoxModelObject* LayoutObject::invalidatePaintRectangleInternal(const LayoutRect& dirtyRect) const
1272 { 1278 {
1273 RELEASE_ASSERT(isRooted()); 1279 RELEASE_ASSERT(isRooted());
1274 1280
1275 if (dirtyRect.isEmpty()) 1281 if (dirtyRect.isEmpty())
1276 return nullptr; 1282 return nullptr;
1277 1283
1278 if (view()->document().printing()) 1284 if (view()->document().printing())
1279 return nullptr; // Don't invalidate paints if we're printing. 1285 return nullptr; // Don't invalidate paints if we're printing.
1280 1286
1281 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation(); 1287 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation();
1282 LayoutRect dirtyRectOnBacking = dirtyRect; 1288 LayoutRect dirtyRectOnBacking = dirtyRect;
1283 PaintLayer::mapRectToPaintInvalidationBacking(*this, paintInvalidationContai ner, dirtyRectOnBacking); 1289 PaintLayer::mapRectToPaintInvalidationBacking(*this, paintInvalidationContai ner, dirtyRectOnBacking);
1290
1291 // Composited scrolling should not be included in the bounds of composited-s crolled items.
1292 if (compositedScrollsWithRespectTo(paintInvalidationContainer)) {
1293 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset());
1294 dirtyRectOnBacking.move(inverseOffset);
1295 }
1296
1284 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRectOnBacking , PaintInvalidationRectangle); 1297 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRectOnBacking , PaintInvalidationRectangle);
1285 return &paintInvalidationContainer; 1298 return &paintInvalidationContainer;
1286 } 1299 }
1287 1300
1288 void LayoutObject::invalidatePaintRectangle(const LayoutRect& rect) const 1301 void LayoutObject::invalidatePaintRectangle(const LayoutRect& rect) const
1289 { 1302 {
1290 setPaintingLayerNeedsRepaint(); 1303 setPaintingLayerNeedsRepaint();
1291 const LayoutBoxModelObject* paintInvalidationContainer = invalidatePaintRect angleInternal(rect); 1304 const LayoutBoxModelObject* paintInvalidationContainer = invalidatePaintRect angleInternal(rect);
1292 if (paintInvalidationContainer) 1305 if (paintInvalidationContainer)
1293 invalidateDisplayItemClients(*paintInvalidationContainer, PaintInvalidat ionRectangle); 1306 invalidateDisplayItemClients(*paintInvalidationContainer, PaintInvalidat ionRectangle);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 if (!fullInvalidation && !shouldInvalidateSelection()) 1392 if (!fullInvalidation && !shouldInvalidateSelection())
1380 return; 1393 return;
1381 1394
1382 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); 1395 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation();
1383 LayoutRect newSelectionRect = localSelectionRect(); 1396 LayoutRect newSelectionRect = localSelectionRect();
1384 if (!newSelectionRect.isEmpty()) { 1397 if (!newSelectionRect.isEmpty()) {
1385 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(newSelecti onRect); 1398 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(newSelecti onRect);
1386 1399
1387 // Composited scrolling should not be included in the bounds and positio n tracking, because the graphics layer backing the scroller 1400 // Composited scrolling should not be included in the bounds and positio n tracking, because the graphics layer backing the scroller
1388 // does not move on scroll. 1401 // does not move on scroll.
1389 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvali dationContainer != this) { 1402 if (compositedScrollsWithRespectTo(paintInvalidationContainer)) {
1390 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->s crolledContentOffset()); 1403 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->s crolledContentOffset());
1391 newSelectionRect.move(inverseOffset); 1404 newSelectionRect.move(inverseOffset);
1392 } 1405 }
1393 } 1406 }
1394 1407
1395 setPreviousSelectionRectForPaintInvalidation(newSelectionRect); 1408 setPreviousSelectionRectForPaintInvalidation(newSelectionRect);
1396 1409
1397 // TODO(wangxianzhu): Combine the following two conditions when removing Lay outView::doingFullPaintInvalidation(). 1410 // TODO(wangxianzhu): Combine the following two conditions when removing Lay outView::doingFullPaintInvalidation().
1398 if (!fullInvalidation) 1411 if (!fullInvalidation)
1399 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelect ion, oldSelectionRect, newSelectionRect); 1412 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelect ion, oldSelectionRect, newSelectionRect);
(...skipping 18 matching lines...) Expand all
1418 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt ate.paintInvalidationContainer(); 1431 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt ate.paintInvalidationContainer();
1419 ASSERT(paintInvalidationContainer == containerForPaintInvalidation()); 1432 ASSERT(paintInvalidationContainer == containerForPaintInvalidation());
1420 1433
1421 const LayoutRect oldBounds = previousPaintInvalidationRect(); 1434 const LayoutRect oldBounds = previousPaintInvalidationRect();
1422 const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintInvalid ationEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking(); 1435 const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintInvalid ationEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking();
1423 LayoutRect newBounds = paintInvalidationState.computePaintInvalidationRectIn Backing(); 1436 LayoutRect newBounds = paintInvalidationState.computePaintInvalidationRectIn Backing();
1424 LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintInvalidationE nabled() ? LayoutPoint() : paintInvalidationState.computePositionFromPaintInvali dationBacking(); 1437 LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintInvalidationE nabled() ? LayoutPoint() : paintInvalidationState.computePositionFromPaintInvali dationBacking();
1425 1438
1426 // Composited scrolling should not be included in the bounds and position tr acking, because the graphics layer backing the scroller 1439 // Composited scrolling should not be included in the bounds and position tr acking, because the graphics layer backing the scroller
1427 // does not move on scroll. 1440 // does not move on scroll.
1428 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) { 1441 if (compositedScrollsWithRespectTo(paintInvalidationContainer)) {
1429 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset()); 1442 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset());
1430 newLocation.move(inverseOffset); 1443 newLocation.move(inverseOffset);
1431 newBounds.move(inverseOffset); 1444 newBounds.move(inverseOffset);
1432 } 1445 }
1433 1446
1434 setPreviousPaintInvalidationRect(newBounds); 1447 setPreviousPaintInvalidationRect(newBounds);
1435 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 1448 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
1436 setPreviousPositionFromPaintInvalidationBacking(newLocation); 1449 setPreviousPositionFromPaintInvalidationBacking(newLocation);
1437 1450
1438 if (!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() && paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinContainerOnly()) { 1451 if (!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() && paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinContainerOnly()) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 return PaintInvalidationBecameInvisible; 1534 return PaintInvalidationBecameInvisible;
1522 1535
1523 if (locationChanged) 1536 if (locationChanged)
1524 return PaintInvalidationLocationChange; 1537 return PaintInvalidationLocationChange;
1525 1538
1526 return PaintInvalidationIncremental; 1539 return PaintInvalidationIncremental;
1527 } 1540 }
1528 1541
1529 void LayoutObject::adjustInvalidationRectForCompositedScrolling(LayoutRect& rect , const LayoutBoxModelObject& paintInvalidationContainer) const 1542 void LayoutObject::adjustInvalidationRectForCompositedScrolling(LayoutRect& rect , const LayoutBoxModelObject& paintInvalidationContainer) const
1530 { 1543 {
1531 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) { 1544 if (compositedScrollsWithRespectTo(paintInvalidationContainer)) {
1532 LayoutSize offset(-toLayoutBox(&paintInvalidationContainer)->scrolledCon tentOffset()); 1545 LayoutSize offset(-toLayoutBox(&paintInvalidationContainer)->scrolledCon tentOffset());
1533 rect.move(offset); 1546 rect.move(offset);
1534 } 1547 }
1535 } 1548 }
1536 1549
1537 LayoutRect LayoutObject::previousPaintInvalidationRectIncludingCompositedScrolli ng(const LayoutBoxModelObject& paintInvalidationContainer) const 1550 LayoutRect LayoutObject::previousPaintInvalidationRectIncludingCompositedScrolli ng(const LayoutBoxModelObject& paintInvalidationContainer) const
1538 { 1551 {
1539 LayoutRect invalidationRect = previousPaintInvalidationRect(); 1552 LayoutRect invalidationRect = previousPaintInvalidationRect();
1540 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInvalida tionContainer); 1553 adjustInvalidationRectForCompositedScrolling(invalidationRect, paintInvalida tionContainer);
1541 return invalidationRect; 1554 return invalidationRect;
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3687 const blink::LayoutObject* root = object1; 3700 const blink::LayoutObject* root = object1;
3688 while (root->parent()) 3701 while (root->parent())
3689 root = root->parent(); 3702 root = root->parent();
3690 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3703 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3691 } else { 3704 } else {
3692 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3705 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3693 } 3706 }
3694 } 3707 }
3695 3708
3696 #endif 3709 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698