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

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

Issue 2203123004: Don't adjust for scrolling of the ancestor, rather than un-adjusting for it later. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 4 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
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 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 { 1225 {
1226 paintInvalidationState.paintingLayer().setNeedsRepaint(); 1226 paintInvalidationState.paintingLayer().setNeedsRepaint();
1227 invalidateDisplayItemClients(reason); 1227 invalidateDisplayItemClients(reason);
1228 } 1228 }
1229 1229
1230 bool LayoutObject::compositedScrollsWithRespectTo(const LayoutBoxModelObject& pa intInvalidationContainer) const 1230 bool LayoutObject::compositedScrollsWithRespectTo(const LayoutBoxModelObject& pa intInvalidationContainer) const
1231 { 1231 {
1232 return paintInvalidationContainer.usesCompositedScrolling() && this != &pain tInvalidationContainer; 1232 return paintInvalidationContainer.usesCompositedScrolling() && this != &pain tInvalidationContainer;
1233 } 1233 }
1234 1234
1235 IntSize LayoutObject::scrollAdjustmentForPaintInvalidation(const LayoutBoxModelO bject& paintInvalidationContainer) const
1236 {
1237 // Non-composited scrolling should be included in the bounds of scrolled ite ms. Since mapToVisualRectInAncestorSpace does not include
1238 // scrolling of the ancestor, we need to add it back in after.
1239 if (paintInvalidationContainer.isBox() && !paintInvalidationContainer.usesCo mpositedScrolling() && this != &paintInvalidationContainer) {
1240 const LayoutBox* box = toLayoutBox(&paintInvalidationContainer);
1241 if (box->hasOverflowClip())
1242 return -box->scrolledContentOffset();
1243 }
1244 return IntSize();
1245 }
1246
1235 void LayoutObject::invalidatePaintRectangle(const LayoutRect& dirtyRect) const 1247 void LayoutObject::invalidatePaintRectangle(const LayoutRect& dirtyRect) const
1236 { 1248 {
1237 RELEASE_ASSERT(isRooted()); 1249 RELEASE_ASSERT(isRooted());
1238 1250
1239 if (dirtyRect.isEmpty()) 1251 if (dirtyRect.isEmpty())
1240 return; 1252 return;
1241 1253
1242 if (view()->document().printing()) 1254 if (view()->document().printing())
1243 return; // Don't invalidate paints if we're printing. 1255 return; // Don't invalidate paints if we're printing.
1244 1256
1245 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation(); 1257 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation();
1246 LayoutRect dirtyRectOnBacking = dirtyRect; 1258 LayoutRect dirtyRectOnBacking = dirtyRect;
1247 PaintLayer::mapRectToPaintInvalidationBacking(*this, paintInvalidationContai ner, dirtyRectOnBacking); 1259 PaintLayer::mapRectToPaintInvalidationBacking(*this, paintInvalidationContai ner, dirtyRectOnBacking);
1248 1260 dirtyRectOnBacking.move(scrollAdjustmentForPaintInvalidation(paintInvalidati onContainer));
1249 // Composited scrolling should not be included in the bounds of composited-s crolled items.
1250 if (compositedScrollsWithRespectTo(paintInvalidationContainer)) {
1251 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset());
1252 dirtyRectOnBacking.move(inverseOffset);
1253 }
1254 1261
1255 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRectOnBacking , PaintInvalidationRectangle); 1262 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRectOnBacking , PaintInvalidationRectangle);
1256 1263
1257 slowSetPaintingLayerNeedsRepaint(); 1264 slowSetPaintingLayerNeedsRepaint();
1258 invalidateDisplayItemClients(PaintInvalidationRectangle); 1265 invalidateDisplayItemClients(PaintInvalidationRectangle);
1259 } 1266 }
1260 1267
1261 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState) 1268 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState)
1262 { 1269 {
1263 ASSERT(!needsLayout()); 1270 ASSERT(!needsLayout());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject & paintInvalidationContainer, const PaintInvalidationState& paintInvalidationSta te, PaintInvalidationReason invalidationReason) 1341 inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject & paintInvalidationContainer, const PaintInvalidationState& paintInvalidationSta te, PaintInvalidationReason invalidationReason)
1335 { 1342 {
1336 // Update selection rect when we are doing full invalidation (in case that t he object is moved, composite status changed, etc.) 1343 // Update selection rect when we are doing full invalidation (in case that t he object is moved, composite status changed, etc.)
1337 // or shouldInvalidationSelection is set (in case that the selection itself changed). 1344 // or shouldInvalidationSelection is set (in case that the selection itself changed).
1338 bool fullInvalidation = isFullPaintInvalidationReason(invalidationReason); 1345 bool fullInvalidation = isFullPaintInvalidationReason(invalidationReason);
1339 if (!fullInvalidation && !shouldInvalidateSelection()) 1346 if (!fullInvalidation && !shouldInvalidateSelection())
1340 return; 1347 return;
1341 1348
1342 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); 1349 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation();
1343 LayoutRect newSelectionRect = localSelectionRect(); 1350 LayoutRect newSelectionRect = localSelectionRect();
1344 if (!newSelectionRect.isEmpty()) { 1351 if (!newSelectionRect.isEmpty())
1345 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(newSelecti onRect); 1352 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(newSelecti onRect);
1346 1353
1347 // Composited scrolling should not be included in the bounds and positio n tracking, because the graphics layer backing the scroller 1354 newSelectionRect.move(scrollAdjustmentForPaintInvalidation(paintInvalidation Container));
1348 // does not move on scroll.
1349 if (compositedScrollsWithRespectTo(paintInvalidationContainer)) {
1350 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->s crolledContentOffset());
1351 newSelectionRect.move(inverseOffset);
1352 }
1353 }
1354 1355
1355 setPreviousSelectionRectForPaintInvalidation(newSelectionRect); 1356 setPreviousSelectionRectForPaintInvalidation(newSelectionRect);
1356 1357
1357 // TODO(wangxianzhu): Combine the following two conditions when removing Lay outView::doingFullPaintInvalidation(). 1358 // TODO(wangxianzhu): Combine the following two conditions when removing Lay outView::doingFullPaintInvalidation().
1358 if (!fullInvalidation) 1359 if (!fullInvalidation)
1359 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelect ion, oldSelectionRect, newSelectionRect); 1360 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelect ion, oldSelectionRect, newSelectionRect);
1360 if (shouldInvalidateSelection()) 1361 if (shouldInvalidateSelection())
1361 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation State, PaintInvalidationSelection); 1362 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation State, PaintInvalidationSelection);
1362 } 1363 }
1363 1364
(...skipping 12 matching lines...) Expand all
1376 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng. 1377 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng.
1377 1378
1378 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt ate.paintInvalidationContainer(); 1379 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt ate.paintInvalidationContainer();
1379 ASSERT(paintInvalidationContainer == containerForPaintInvalidation()); 1380 ASSERT(paintInvalidationContainer == containerForPaintInvalidation());
1380 1381
1381 const LayoutRect oldBounds = previousPaintInvalidationRect(); 1382 const LayoutRect oldBounds = previousPaintInvalidationRect();
1382 const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintInvalid ationEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking(); 1383 const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintInvalid ationEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking();
1383 LayoutRect newBounds = paintInvalidationState.computePaintInvalidationRectIn Backing(); 1384 LayoutRect newBounds = paintInvalidationState.computePaintInvalidationRectIn Backing();
1384 LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintInvalidationE nabled() ? LayoutPoint() : paintInvalidationState.computePositionFromPaintInvali dationBacking(); 1385 LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintInvalidationE nabled() ? LayoutPoint() : paintInvalidationState.computePositionFromPaintInvali dationBacking();
1385 1386
1386 // Composited scrolling should not be included in the bounds and position tr acking, because the graphics layer backing the scroller 1387 IntSize adjustment = scrollAdjustmentForPaintInvalidation(paintInvalidationC ontainer);
1387 // does not move on scroll. 1388 newLocation.move(adjustment);
1388 // TODO(chrishtr): can we just avoid adding in the scroll in the first place in LayoutBox::mapScrollingContentsRectToBoxSpace? 1389 newBounds.move(adjustment);
1389 if (compositedScrollsWithRespectTo(paintInvalidationContainer)) {
1390 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset());
1391 newLocation.move(inverseOffset);
1392 newBounds.move(inverseOffset);
1393 }
1394 1390
1395 setPreviousPaintInvalidationRect(newBounds); 1391 setPreviousPaintInvalidationRect(newBounds);
1396 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) 1392 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled())
1397 setPreviousPositionFromPaintInvalidationBacking(newLocation); 1393 setPreviousPositionFromPaintInvalidationBacking(newLocation);
1398 1394
1399 if (!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() && paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinContainerOnly()) { 1395 if (!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() && paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinContainerOnly()) {
1400 // We are done updating the paint invalidation rect. No other paint inva lidation work to do for this object. 1396 // We are done updating the paint invalidation rect. No other paint inva lidation work to do for this object.
1401 return PaintInvalidationNone; 1397 return PaintInvalidationNone;
1402 } 1398 }
1403 1399
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after
3674 const blink::LayoutObject* root = object1; 3670 const blink::LayoutObject* root = object1;
3675 while (root->parent()) 3671 while (root->parent())
3676 root = root->parent(); 3672 root = root->parent();
3677 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3673 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3678 } else { 3674 } else {
3679 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)"); 3675 WTFLogAlways("%s", "Cannot showLayoutTree. Root is (nil)");
3680 } 3676 }
3681 } 3677 }
3682 3678
3683 #endif 3679 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698