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

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

Issue 1813383002: Move all fast-path paint invalidation mapping into PaintInvalidationState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 } 1185 }
1186 1186
1187 static PassOwnPtr<TracedValue> jsonObjectForPaintInvalidationInfo(const LayoutRe ct& rect, const String& invalidationReason) 1187 static PassOwnPtr<TracedValue> jsonObjectForPaintInvalidationInfo(const LayoutRe ct& rect, const String& invalidationReason)
1188 { 1188 {
1189 OwnPtr<TracedValue> value = TracedValue::create(); 1189 OwnPtr<TracedValue> value = TracedValue::create();
1190 addJsonObjectForRect(value.get(), "rect", rect); 1190 addJsonObjectForRect(value.get(), "rect", rect);
1191 value->setString("invalidation_reason", invalidationReason); 1191 value->setString("invalidation_reason", invalidationReason);
1192 return value.release(); 1192 return value.release();
1193 } 1193 }
1194 1194
1195 LayoutRect LayoutObject::computePaintInvalidationRect(const LayoutBoxModelObject & paintInvalidationContainer, const PaintInvalidationState* paintInvalidationSta te) const
1196 {
1197 return clippedOverflowRectForPaintInvalidation(&paintInvalidationContainer, paintInvalidationState);
1198 }
1199
1200
1201 static void invalidatePaintRectangleOnWindow(const LayoutBoxModelObject& paintIn validationContainer, const IntRect& dirtyRect) 1195 static void invalidatePaintRectangleOnWindow(const LayoutBoxModelObject& paintIn validationContainer, const IntRect& dirtyRect)
1202 { 1196 {
1203 FrameView* frameView = paintInvalidationContainer.frameView(); 1197 FrameView* frameView = paintInvalidationContainer.frameView();
1204 ASSERT(paintInvalidationContainer.isLayoutView() && paintInvalidationContain er.layer()->compositingState() == NotComposited); 1198 ASSERT(paintInvalidationContainer.isLayoutView() && paintInvalidationContain er.layer()->compositingState() == NotComposited);
1205 if (!frameView || paintInvalidationContainer.document().printing()) 1199 if (!frameView || paintInvalidationContainer.document().printing())
1206 return; 1200 return;
1207 1201
1208 ASSERT(!frameView->frame().ownerLayoutObject()); 1202 ASSERT(!frameView->frame().ownerLayoutObject());
1209 1203
1210 IntRect paintRect = dirtyRect; 1204 IntRect paintRect = dirtyRect;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 #endif 1282 #endif
1289 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*this, inval idationReason); 1283 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*this, inval idationReason);
1290 } 1284 }
1291 1285
1292 void LayoutObject::invalidateDisplayItemClientsWithPaintInvalidationState(const LayoutBoxModelObject& paintInvalidationContainer, const PaintInvalidationState& paintInvalidationState, PaintInvalidationReason invalidationReason) const 1286 void LayoutObject::invalidateDisplayItemClientsWithPaintInvalidationState(const LayoutBoxModelObject& paintInvalidationContainer, const PaintInvalidationState& paintInvalidationState, PaintInvalidationReason invalidationReason) const
1293 { 1287 {
1294 paintInvalidationState.enclosingSelfPaintingLayer(*this).setNeedsRepaint(); 1288 paintInvalidationState.enclosingSelfPaintingLayer(*this).setNeedsRepaint();
1295 invalidateDisplayItemClients(paintInvalidationContainer, invalidationReason) ; 1289 invalidateDisplayItemClients(paintInvalidationContainer, invalidationReason) ;
1296 } 1290 }
1297 1291
1298 LayoutRect LayoutObject::boundsRectForPaintInvalidation(const LayoutBoxModelObje ct& paintInvalidationContainer, const PaintInvalidationState* paintInvalidationS tate) const
1299 {
1300 return PaintLayer::computePaintInvalidationRect(*this, paintInvalidationCont ainer.layer(), paintInvalidationState);
1301 }
1302
1303 const LayoutBoxModelObject* LayoutObject::invalidatePaintRectangleInternal(const LayoutRect& dirtyRect) const 1292 const LayoutBoxModelObject* LayoutObject::invalidatePaintRectangleInternal(const LayoutRect& dirtyRect) const
1304 { 1293 {
1305 RELEASE_ASSERT(isRooted()); 1294 RELEASE_ASSERT(isRooted());
1306 1295
1307 if (dirtyRect.isEmpty()) 1296 if (dirtyRect.isEmpty())
1308 return nullptr; 1297 return nullptr;
1309 1298
1310 if (view()->document().printing()) 1299 if (view()->document().printing())
1311 return nullptr; // Don't invalidate paints if we're printing. 1300 return nullptr; // Don't invalidate paints if we're printing.
1312 1301
1313 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation(); 1302 const LayoutBoxModelObject& paintInvalidationContainer = containerForPaintIn validation();
1314 LayoutRect dirtyRectOnBacking = dirtyRect; 1303 LayoutRect dirtyRectOnBacking = dirtyRect;
1315 PaintLayer::mapRectToPaintInvalidationBacking(this, &paintInvalidationContai ner, dirtyRectOnBacking); 1304 PaintLayer::mapRectToPaintInvalidationBacking(*this, paintInvalidationContai ner, dirtyRectOnBacking);
1316 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRectOnBacking , PaintInvalidationRectangle); 1305 invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRectOnBacking , PaintInvalidationRectangle);
1317 return &paintInvalidationContainer; 1306 return &paintInvalidationContainer;
1318 } 1307 }
1319 1308
1320 void LayoutObject::invalidatePaintRectangle(const LayoutRect& rect) const 1309 void LayoutObject::invalidatePaintRectangle(const LayoutRect& rect) const
1321 { 1310 {
1322 if (PaintLayer* enclosingLayer = this->enclosingLayer()) 1311 if (PaintLayer* enclosingLayer = this->enclosingLayer())
1323 enclosingLayer->setNeedsRepaint(); 1312 enclosingLayer->setNeedsRepaint();
1324 const LayoutBoxModelObject* paintInvalidationContainer = invalidatePaintRect angleInternal(rect); 1313 const LayoutBoxModelObject* paintInvalidationContainer = invalidatePaintRect angleInternal(rect);
1325 if (paintInvalidationContainer) 1314 if (paintInvalidationContainer)
1326 invalidateDisplayItemClients(*paintInvalidationContainer, PaintInvalidat ionRectangle); 1315 invalidateDisplayItemClients(*paintInvalidationContainer, PaintInvalidat ionRectangle);
1327 } 1316 }
1328 1317
1329 void LayoutObject::invalidatePaintRectangleNotInvalidatingDisplayItemClients(con st LayoutRect& r) const 1318 void LayoutObject::invalidatePaintRectangleNotInvalidatingDisplayItemClients(con st LayoutRect& r) const
1330 { 1319 {
1331 invalidatePaintRectangleInternal(r); 1320 invalidatePaintRectangleInternal(r);
1332 } 1321 }
1333 1322
1334 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState) 1323 void LayoutObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv alidationState)
1335 { 1324 {
1336 ASSERT(!needsLayout()); 1325 ASSERT(!needsLayout());
1337 1326
1338 // If we didn't need paint invalidation then our children don't need as well . 1327 // If we didn't need paint invalidation then our children don't need as well .
1339 // Skip walking down the tree as everything should be fine below us. 1328 // Skip walking down the tree as everything should be fine below us.
1340 if (!shouldCheckForPaintInvalidation(paintInvalidationState)) 1329 if (!shouldCheckForPaintInvalidation(paintInvalidationState))
1341 return; 1330 return;
1342 1331
1343 PaintInvalidationReason reason = invalidatePaintIfNeeded(paintInvalidationSt ate); 1332 PaintInvalidationState newPaintInvalidationState(paintInvalidationState, *th is);
1344 clearPaintInvalidationFlags(paintInvalidationState); 1333 PaintInvalidationReason reason = invalidatePaintIfNeeded(newPaintInvalidatio nState);
1334 clearPaintInvalidationFlags(newPaintInvalidationState);
1345 1335
1346 if (reason == PaintInvalidationDelayedFull) 1336 if (reason == PaintInvalidationDelayedFull)
1347 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this); 1337 newPaintInvalidationState.pushDelayedPaintInvalidationTarget(*this);
1348 1338
1339 newPaintInvalidationState.updateForChildren();
1349 invalidatePaintOfSubtreesIfNeeded(paintInvalidationState); 1340 invalidatePaintOfSubtreesIfNeeded(paintInvalidationState);
pdr. 2016/03/25 01:51:46 should this be newPaintInvalidationState?
Xianzhu 2016/03/25 16:35:55 Yes. Fixed.
1350 } 1341 }
1351 1342
1352 void LayoutObject::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationStat e& childPaintInvalidationState) 1343 void LayoutObject::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationStat e& childPaintInvalidationState)
1353 { 1344 {
1354 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli ng()) { 1345 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli ng()) {
1355 if (!child->isOutOfFlowPositioned()) 1346 if (!child->isOutOfFlowPositioned())
1356 child->invalidateTreeIfNeeded(childPaintInvalidationState); 1347 child->invalidateTreeIfNeeded(childPaintInvalidationState);
1357 } 1348 }
1358 } 1349 }
1359 1350
1360 static PassOwnPtr<TracedValue> jsonObjectForOldAndNewRects(const LayoutRect& old Rect, const LayoutPoint& oldLocation, const LayoutRect& newRect, const LayoutPoi nt& newLocation) 1351 static PassOwnPtr<TracedValue> jsonObjectForOldAndNewRects(const LayoutRect& old Rect, const LayoutPoint& oldLocation, const LayoutRect& newRect, const LayoutPoi nt& newLocation)
1361 { 1352 {
1362 OwnPtr<TracedValue> value = TracedValue::create(); 1353 OwnPtr<TracedValue> value = TracedValue::create();
1363 addJsonObjectForRect(value.get(), "oldRect", oldRect); 1354 addJsonObjectForRect(value.get(), "oldRect", oldRect);
1364 addJsonObjectForPoint(value.get(), "oldLocation", oldLocation); 1355 addJsonObjectForPoint(value.get(), "oldLocation", oldLocation);
1365 addJsonObjectForRect(value.get(), "newRect", newRect); 1356 addJsonObjectForRect(value.get(), "newRect", newRect);
1366 addJsonObjectForPoint(value.get(), "newLocation", newLocation); 1357 addJsonObjectForPoint(value.get(), "newLocation", newLocation);
1367 return value.release(); 1358 return value.release();
1368 } 1359 }
1369 1360
1370 LayoutRect LayoutObject::selectionRectInViewCoordinates() const 1361 LayoutRect LayoutObject::selectionRectInViewCoordinates() const
1371 { 1362 {
1372 return selectionRectForPaintInvalidation(view()); 1363 LayoutRect selectionRect = localSelectionRect();
1364 if (!selectionRect.isEmpty())
1365 mapToVisibleRectInAncestorSpace(view(), selectionRect);
1366 return selectionRect;
1373 } 1367 }
1374 1368
1375 LayoutRect LayoutObject::previousSelectionRectForPaintInvalidation() const 1369 LayoutRect LayoutObject::previousSelectionRectForPaintInvalidation() const
1376 { 1370 {
1377 if (!selectionPaintInvalidationMap) 1371 if (!selectionPaintInvalidationMap)
1378 return LayoutRect(); 1372 return LayoutRect();
1379 1373
1380 return selectionPaintInvalidationMap->get(this); 1374 return selectionPaintInvalidationMap->get(this);
1381 } 1375 }
1382 1376
(...skipping 14 matching lines...) Expand all
1397 // TODO(wangxianzhu): Remove this for slimming paint v2 because we won't care ab out paint invalidation rects. 1391 // TODO(wangxianzhu): Remove this for slimming paint v2 because we won't care ab out paint invalidation rects.
1398 inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject & paintInvalidationContainer, const PaintInvalidationState& paintInvalidationSta te, PaintInvalidationReason invalidationReason) 1392 inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject & paintInvalidationContainer, const PaintInvalidationState& paintInvalidationSta te, PaintInvalidationReason invalidationReason)
1399 { 1393 {
1400 // Update selection rect when we are doing full invalidation (in case that t he object is moved, composite status changed, etc.) 1394 // Update selection rect when we are doing full invalidation (in case that t he object is moved, composite status changed, etc.)
1401 // or shouldInvalidationSelection is set (in case that the selection itself changed). 1395 // or shouldInvalidationSelection is set (in case that the selection itself changed).
1402 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI nvalidationReason(invalidationReason); 1396 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI nvalidationReason(invalidationReason);
1403 if (!fullInvalidation && !shouldInvalidateSelection()) 1397 if (!fullInvalidation && !shouldInvalidateSelection())
1404 return; 1398 return;
1405 1399
1406 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); 1400 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation();
1407 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali dationContainer); 1401 LayoutRect newSelectionRect = localSelectionRect();
1402 if (!newSelectionRect.isEmpty()) {
1403 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(newSelecti onRect);
1408 1404
1409 // Composited scrolling should not be included in the bounds and position tr acking, because the graphics layer backing the scroller 1405 // Composited scrolling should not be included in the bounds and positio n tracking, because the graphics layer backing the scroller
1410 // does not move on scroll. 1406 // does not move on scroll.
1411 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) { 1407 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvali dationContainer != this) {
1412 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset()); 1408 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->s crolledContentOffset());
1413 newSelectionRect.move(inverseOffset); 1409 newSelectionRect.move(inverseOffset);
1410 }
1414 } 1411 }
1415 1412
1416 setPreviousSelectionRectForPaintInvalidation(newSelectionRect); 1413 setPreviousSelectionRectForPaintInvalidation(newSelectionRect);
1417 1414
1418 if (shouldInvalidateSelection()) 1415 if (shouldInvalidateSelection())
1419 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation Container, paintInvalidationState, PaintInvalidationSelection); 1416 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation Container, paintInvalidationState, PaintInvalidationSelection);
1420 1417
1421 if (fullInvalidation) 1418 if (fullInvalidation)
1422 return; 1419 return;
1423 1420
1424 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect); 1421 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect);
1425 } 1422 }
1426 1423
1427 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid ationState& paintInvalidationState) 1424 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid ationState& paintInvalidationState)
1428 { 1425 {
1426 ASSERT(&paintInvalidationState.currentObject() == this);
1427
1429 if (styleRef().hasOutline()) { 1428 if (styleRef().hasOutline()) {
1430 PaintLayer& layer = paintInvalidationState.enclosingSelfPaintingLayer(*t his); 1429 PaintLayer& layer = paintInvalidationState.enclosingSelfPaintingLayer(*t his);
1431 if (layer.layoutObject() != this) 1430 if (layer.layoutObject() != this)
1432 layer.setNeedsPaintPhaseDescendantOutlines(); 1431 layer.setNeedsPaintPhaseDescendantOutlines();
1433 } 1432 }
1434 1433
1435 LayoutView* v = view(); 1434 LayoutView* v = view();
1436 if (v->document().printing()) 1435 if (v->document().printing())
1437 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng. 1436 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng.
1438 1437
1439 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt ate.paintInvalidationContainer(); 1438 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt ate.paintInvalidationContainer();
1440 // TODO(wangxianzhu): Enable this assert after we fix all paintInvalidationC ontainer mismatch issues. crbug.com/360286 1439 // TODO(wangxianzhu): Enable this assert after we fix all paintInvalidationC ontainer mismatch issues. crbug.com/360286
1441 // ASSERT(paintInvalidationContainer == containerForPaintInvalidation()); 1440 // ASSERT(paintInvalidationContainer == containerForPaintInvalidation());
1442 1441
1443 const LayoutRect oldBounds = previousPaintInvalidationRect(); 1442 const LayoutRect oldBounds = previousPaintInvalidationRect();
1444 const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintInvalid ationEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking(); 1443 const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintInvalid ationEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking();
1445 LayoutRect newBounds = boundsRectForPaintInvalidation(paintInvalidationConta iner, &paintInvalidationState); 1444 LayoutRect newBounds = paintInvalidationState.computePaintInvalidationRectIn Backing();
1446 LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintInvalidationE nabled() ? LayoutPoint() : PaintLayer::positionFromPaintInvalidationBacking(this , &paintInvalidationContainer, &paintInvalidationState); 1445 LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintInvalidationE nabled() ? LayoutPoint() : paintInvalidationState.computePositionFromPaintInvali dationBacking();
1447 1446
1448 // Composited scrolling should not be included in the bounds and position tr acking, because the graphics layer backing the scroller 1447 // Composited scrolling should not be included in the bounds and position tr acking, because the graphics layer backing the scroller
1449 // does not move on scroll. 1448 // does not move on scroll.
1450 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) { 1449 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) {
1451 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset()); 1450 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset());
1452 newLocation.move(inverseOffset); 1451 newLocation.move(inverseOffset);
1453 newBounds.move(inverseOffset); 1452 newBounds.move(inverseOffset);
1454 } 1453 }
1455 1454
1456 setPreviousPaintInvalidationRect(newBounds); 1455 setPreviousPaintInvalidationRect(newBounds);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 } 1621 }
1623 1622
1624 void LayoutObject::invalidatePaintForOverflowIfNeeded() 1623 void LayoutObject::invalidatePaintForOverflowIfNeeded()
1625 { 1624 {
1626 if (shouldInvalidateOverflowForPaint()) 1625 if (shouldInvalidateOverflowForPaint())
1627 invalidatePaintForOverflow(); 1626 invalidatePaintForOverflow();
1628 } 1627 }
1629 1628
1630 LayoutRect LayoutObject::absoluteClippedOverflowRect() const 1629 LayoutRect LayoutObject::absoluteClippedOverflowRect() const
1631 { 1630 {
1632 return clippedOverflowRectForPaintInvalidation(view()); 1631 LayoutRect rect = localOverflowRectForPaintInvalidation();
1632 mapToVisibleRectInAncestorSpace(view(), rect);
1633 return rect;
1633 } 1634 }
1634 1635
1635 LayoutRect LayoutObject::clippedOverflowRectForPaintInvalidation(const LayoutBox ModelObject*, const PaintInvalidationState*) const 1636 LayoutRect LayoutObject::localOverflowRectForPaintInvalidation() const
1636 { 1637 {
1637 ASSERT_NOT_REACHED(); 1638 ASSERT_NOT_REACHED();
1638 return LayoutRect(); 1639 return LayoutRect();
1639 } 1640 }
1640 1641
1641 void LayoutObject::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* a ncestor, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState) const 1642 void LayoutObject::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* a ncestor, LayoutRect& rect) const
1642 { 1643 {
1643 if (ancestor == this) 1644 if (ancestor == this)
1644 return; 1645 return;
1645 1646
1646 if (paintInvalidationState && paintInvalidationState->canMapToAncestor(ances tor)) {
1647 paintInvalidationState->mapObjectRectToAncestor(*this, ancestor, rect);
1648 return;
1649 }
1650
1651 if (LayoutObject* parent = this->parent()) { 1647 if (LayoutObject* parent = this->parent()) {
1652 if (parent->hasOverflowClip()) { 1648 if (parent->hasOverflowClip()) {
1653 LayoutBox* parentBox = toLayoutBox(parent); 1649 LayoutBox* parentBox = toLayoutBox(parent);
1654 parentBox->mapScrollingContentsRectToBoxSpace(rect); 1650 parentBox->mapScrollingContentsRectToBoxSpace(rect);
1655 if (parent != ancestor) 1651 if (parent != ancestor)
1656 parentBox->applyOverflowClip(rect); 1652 parentBox->applyOverflowClip(rect);
1657 if (rect.isEmpty()) 1653 if (rect.isEmpty())
1658 return; 1654 return;
1659 } 1655 }
1660 1656
1661 parent->mapToVisibleRectInAncestorSpace(ancestor, rect, nullptr); 1657 parent->mapToVisibleRectInAncestorSpace(ancestor, rect);
1662 } 1658 }
1663 } 1659 }
1664 1660
1665 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*) 1661 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*)
1666 { 1662 {
1667 } 1663 }
1668 1664
1669 #ifndef NDEBUG 1665 #ifndef NDEBUG
1670 1666
1671 void LayoutObject::showTreeForThis() const 1667 void LayoutObject::showTreeForThis() const
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 } 2232 }
2237 2233
2238 FloatQuad LayoutObject::ancestorToLocalQuad(LayoutBoxModelObject* ancestor, cons t FloatQuad& quad, MapCoordinatesFlags mode) const 2234 FloatQuad LayoutObject::ancestorToLocalQuad(LayoutBoxModelObject* ancestor, cons t FloatQuad& quad, MapCoordinatesFlags mode) const
2239 { 2235 {
2240 TransformState transformState(TransformState::UnapplyInverseTransformDirecti on, quad.boundingBox().center(), quad); 2236 TransformState transformState(TransformState::UnapplyInverseTransformDirecti on, quad.boundingBox().center(), quad);
2241 mapAncestorToLocal(ancestor, transformState, mode); 2237 mapAncestorToLocal(ancestor, transformState, mode);
2242 transformState.flatten(); 2238 transformState.flatten();
2243 return transformState.lastPlanarQuad(); 2239 return transformState.lastPlanarQuad();
2244 } 2240 }
2245 2241
2246 void LayoutObject::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Tran sformState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const Pain tInvalidationState* paintInvalidationState) const 2242 void LayoutObject::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Tran sformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const
2247 { 2243 {
2248 if (ancestor == this) 2244 if (ancestor == this)
2249 return; 2245 return;
2250 2246
2251 if (paintInvalidationState && paintInvalidationState->canMapToAncestor(ances tor)) {
2252 LayoutSize offset = paintInvalidationState->paintOffset();
2253 if (const LayoutBox* layoutBox = isBox() ? toLayoutBox(this) : nullptr)
2254 offset += layoutBox->locationOffset();
2255 if (const PaintLayer* layer = style()->hasInFlowPosition() && hasLayer() ? toLayoutBoxModelObject(this)->layer() : nullptr)
2256 offset += layer->offsetForInFlowPosition();
2257 transformState.move(offset);
2258 return;
2259 }
2260
2261 if (wasFixed) 2247 if (wasFixed)
2262 *wasFixed = mode & IsFixed; 2248 *wasFixed = mode & IsFixed;
2263 2249
2264 bool containerSkipped; 2250 bool containerSkipped;
2265 const LayoutObject* o = container(ancestor, &containerSkipped); 2251 const LayoutObject* o = container(ancestor, &containerSkipped);
2266 if (!o) 2252 if (!o)
2267 return; 2253 return;
2268 2254
2269 if (mode & ApplyContainerFlip) { 2255 if (mode & ApplyContainerFlip) {
2270 if (isBox()) { 2256 if (isBox()) {
(...skipping 26 matching lines...) Expand all
2297 } 2283 }
2298 2284
2299 if (containerSkipped) { 2285 if (containerSkipped) {
2300 // There can't be a transform between |ancestor| and |o|, because transf orms create 2286 // There can't be a transform between |ancestor| and |o|, because transf orms create
2301 // containers, so it should be safe to just subtract the delta between t he ancestor and |o|. 2287 // containers, so it should be safe to just subtract the delta between t he ancestor and |o|.
2302 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(o); 2288 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(o);
2303 transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans form); 2289 transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans form);
2304 return; 2290 return;
2305 } 2291 }
2306 2292
2307 o->mapLocalToAncestor(ancestor, transformState, mode, wasFixed, paintInvalid ationState); 2293 o->mapLocalToAncestor(ancestor, transformState, mode, wasFixed);
2308 } 2294 }
2309 2295
2310 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 2296 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
2311 { 2297 {
2312 ASSERT_NOT_REACHED(); 2298 ASSERT_NOT_REACHED();
2313 return nullptr; 2299 return nullptr;
2314 } 2300 }
2315 2301
2316 void LayoutObject::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Tran sformState& transformState, MapCoordinatesFlags mode) const 2302 void LayoutObject::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Tran sformState& transformState, MapCoordinatesFlags mode) const
2317 { 2303 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 { 2382 {
2397 // Track the point at the center of the quad's bounding box. As mapLocalToAn cestor() calls offsetFromContainer(), 2383 // Track the point at the center of the quad's bounding box. As mapLocalToAn cestor() calls offsetFromContainer(),
2398 // it will use that point as the reference point to decide which column's tr ansform to apply in multiple-column blocks. 2384 // it will use that point as the reference point to decide which column's tr ansform to apply in multiple-column blocks.
2399 TransformState transformState(TransformState::ApplyTransformDirection, local Quad.boundingBox().center(), localQuad); 2385 TransformState transformState(TransformState::ApplyTransformDirection, local Quad.boundingBox().center(), localQuad);
2400 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip | Use Transforms, wasFixed); 2386 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip | Use Transforms, wasFixed);
2401 transformState.flatten(); 2387 transformState.flatten();
2402 2388
2403 return transformState.lastPlanarQuad(); 2389 return transformState.lastPlanarQuad();
2404 } 2390 }
2405 2391
2406 FloatPoint LayoutObject::localToAncestorPoint(const FloatPoint& localPoint, cons t LayoutBoxModelObject* ancestor, MapCoordinatesFlags mode, bool* wasFixed, cons t PaintInvalidationState* paintInvalidationState) const 2392 FloatPoint LayoutObject::localToAncestorPoint(const FloatPoint& localPoint, cons t LayoutBoxModelObject* ancestor, MapCoordinatesFlags mode, bool* wasFixed) cons t
2407 { 2393 {
2408 TransformState transformState(TransformState::ApplyTransformDirection, local Point); 2394 TransformState transformState(TransformState::ApplyTransformDirection, local Point);
2409 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip | Use Transforms, wasFixed, paintInvalidationState); 2395 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip | Use Transforms, wasFixed);
2410 transformState.flatten(); 2396 transformState.flatten();
2411 2397
2412 return transformState.lastPlanarPoint(); 2398 return transformState.lastPlanarPoint();
2413 } 2399 }
2414 2400
2415 void LayoutObject::localToAncestorRects(Vector<LayoutRect>& rects, const LayoutB oxModelObject* ancestor, const LayoutPoint& preOffset, const LayoutPoint& postOf fset) const 2401 void LayoutObject::localToAncestorRects(Vector<LayoutRect>& rects, const LayoutB oxModelObject* ancestor, const LayoutPoint& preOffset, const LayoutPoint& postOf fset) const
2416 { 2402 {
2417 for (size_t i = 0; i < rects.size(); ++i) { 2403 for (size_t i = 0; i < rects.size(); ++i) {
2418 LayoutRect& rect = rects[i]; 2404 LayoutRect& rect = rects[i];
2419 rect.moveBy(preOffset); 2405 rect.moveBy(preOffset);
(...skipping 22 matching lines...) Expand all
2442 2428
2443 if (backingLayer) 2429 if (backingLayer)
2444 *backingLayer = paintInvalidationContainer.layer(); 2430 *backingLayer = paintInvalidationContainer.layer();
2445 FloatPoint containerPoint = localToAncestorPoint(FloatPoint(localPoint), &pa intInvalidationContainer, TraverseDocumentBoundaries); 2431 FloatPoint containerPoint = localToAncestorPoint(FloatPoint(localPoint), &pa intInvalidationContainer, TraverseDocumentBoundaries);
2446 2432
2447 // A layoutObject can have no invalidation backing if it is from a detached frame, 2433 // A layoutObject can have no invalidation backing if it is from a detached frame,
2448 // or when forced compositing is disabled. 2434 // or when forced compositing is disabled.
2449 if (paintInvalidationContainer.layer()->compositingState() == NotComposited) 2435 if (paintInvalidationContainer.layer()->compositingState() == NotComposited)
2450 return containerPoint; 2436 return containerPoint;
2451 2437
2452 PaintLayer::mapPointToPaintBackingCoordinates(&paintInvalidationContainer, c ontainerPoint); 2438 PaintLayer::mapPointInPaintInvalidationContainerToBacking(paintInvalidationC ontainer, containerPoint);
2453 return containerPoint; 2439 return containerPoint;
2454 } 2440 }
2455 2441
2456 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o) const 2442 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o) const
2457 { 2443 {
2458 ASSERT(o == container()); 2444 ASSERT(o == container());
2459 return o->hasOverflowClip() ? LayoutSize(-toLayoutBox(o)->scrolledContentOff set()) : LayoutSize(); 2445 return o->hasOverflowClip() ? LayoutSize(-toLayoutBox(o)->scrolledContentOff set()) : LayoutSize();
2460 } 2446 }
2461 2447
2462 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* ancesto rContainer) const 2448 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* ancesto rContainer) const
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
3737 const blink::LayoutObject* root = object1; 3723 const blink::LayoutObject* root = object1;
3738 while (root->parent()) 3724 while (root->parent())
3739 root = root->parent(); 3725 root = root->parent();
3740 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3726 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3741 } else { 3727 } else {
3742 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3728 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3743 } 3729 }
3744 } 3730 }
3745 3731
3746 #endif 3732 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698