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: Disable fast-path/slow-path comparison because of saturated operations of LayoutUnit 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
1349 invalidatePaintOfSubtreesIfNeeded(paintInvalidationState); 1339 newPaintInvalidationState.updateForChildren();
1340 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState);
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 LayoutRect selectionRect = localSelectionRect(); 1363 LayoutRect selectionRect = localSelectionRect();
1373 if (!selectionRect.isEmpty()) 1364 if (!selectionRect.isEmpty())
1374 mapToVisibleRectInAncestorSpace(view(), selectionRect, nullptr); 1365 mapToVisibleRectInAncestorSpace(view(), selectionRect);
1375 return selectionRect; 1366 return selectionRect;
1376 } 1367 }
1377 1368
1378 LayoutRect LayoutObject::previousSelectionRectForPaintInvalidation() const 1369 LayoutRect LayoutObject::previousSelectionRectForPaintInvalidation() const
1379 { 1370 {
1380 if (!selectionPaintInvalidationMap) 1371 if (!selectionPaintInvalidationMap)
1381 return LayoutRect(); 1372 return LayoutRect();
1382 1373
1383 return selectionPaintInvalidationMap->get(this); 1374 return selectionPaintInvalidationMap->get(this);
1384 } 1375 }
(...skipping 17 matching lines...) Expand all
1402 { 1393 {
1403 // 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.)
1404 // or shouldInvalidationSelection is set (in case that the selection itself changed). 1395 // or shouldInvalidationSelection is set (in case that the selection itself changed).
1405 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI nvalidationReason(invalidationReason); 1396 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI nvalidationReason(invalidationReason);
1406 if (!fullInvalidation && !shouldInvalidateSelection()) 1397 if (!fullInvalidation && !shouldInvalidateSelection())
1407 return; 1398 return;
1408 1399
1409 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); 1400 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation();
1410 LayoutRect newSelectionRect = localSelectionRect(); 1401 LayoutRect newSelectionRect = localSelectionRect();
1411 if (!newSelectionRect.isEmpty()) { 1402 if (!newSelectionRect.isEmpty()) {
1412 PaintLayer::mapRectToPaintInvalidationBacking(this, &paintInvalidationCo ntainer, newSelectionRect, &paintInvalidationState); 1403 paintInvalidationState.mapLocalRectToPaintInvalidationBacking(newSelecti onRect);
1413 1404
1414 // Composited scrolling should not be included in the bounds and positio n tracking, 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
1415 // does not move on scroll. 1406 // does not move on scroll.
1416 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvali dationContainer != this) { 1407 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvali dationContainer != this) {
1417 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->s crolledContentOffset()); 1408 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->s crolledContentOffset());
1418 newSelectionRect.move(inverseOffset); 1409 newSelectionRect.move(inverseOffset);
1419 } 1410 }
1420 } 1411 }
1421 1412
1422 setPreviousSelectionRectForPaintInvalidation(newSelectionRect); 1413 setPreviousSelectionRectForPaintInvalidation(newSelectionRect);
1423 1414
1424 if (shouldInvalidateSelection()) 1415 if (shouldInvalidateSelection())
1425 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation Container, paintInvalidationState, PaintInvalidationSelection); 1416 invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidation Container, paintInvalidationState, PaintInvalidationSelection);
1426 1417
1427 if (fullInvalidation) 1418 if (fullInvalidation)
1428 return; 1419 return;
1429 1420
1430 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect); 1421 fullyInvalidatePaint(paintInvalidationContainer, PaintInvalidationSelection, oldSelectionRect, newSelectionRect);
1431 } 1422 }
1432 1423
1433 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid ationState& paintInvalidationState) 1424 PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(const PaintInvalid ationState& paintInvalidationState)
1434 { 1425 {
1426 ASSERT(&paintInvalidationState.currentObject() == this);
1427
1435 if (styleRef().hasOutline()) { 1428 if (styleRef().hasOutline()) {
1436 PaintLayer& layer = paintInvalidationState.enclosingSelfPaintingLayer(*t his); 1429 PaintLayer& layer = paintInvalidationState.enclosingSelfPaintingLayer(*t his);
1437 if (layer.layoutObject() != this) 1430 if (layer.layoutObject() != this)
1438 layer.setNeedsPaintPhaseDescendantOutlines(); 1431 layer.setNeedsPaintPhaseDescendantOutlines();
1439 } 1432 }
1440 1433
1441 LayoutView* v = view(); 1434 LayoutView* v = view();
1442 if (v->document().printing()) 1435 if (v->document().printing())
1443 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng. 1436 return PaintInvalidationNone; // Don't invalidate paints if we're printi ng.
1444 1437
1445 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt ate.paintInvalidationContainer(); 1438 const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationSt ate.paintInvalidationContainer();
1446 // 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
1447 // ASSERT(paintInvalidationContainer == containerForPaintInvalidation()); 1440 // ASSERT(paintInvalidationContainer == containerForPaintInvalidation());
1448 1441
1449 const LayoutRect oldBounds = previousPaintInvalidationRect(); 1442 const LayoutRect oldBounds = previousPaintInvalidationRect();
1450 const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintInvalid ationEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking(); 1443 const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintInvalid ationEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking();
1451 LayoutRect newBounds = boundsRectForPaintInvalidation(paintInvalidationConta iner, &paintInvalidationState); 1444 LayoutRect newBounds = paintInvalidationState.computePaintInvalidationRectIn Backing();
1452 LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintInvalidationE nabled() ? LayoutPoint() : PaintLayer::positionFromPaintInvalidationBacking(this , &paintInvalidationContainer, &paintInvalidationState); 1445 LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintInvalidationE nabled() ? LayoutPoint() : paintInvalidationState.computePositionFromPaintInvali dationBacking();
1453 1446
1454 // 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
1455 // does not move on scroll. 1448 // does not move on scroll.
1456 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) { 1449 if (paintInvalidationContainer.usesCompositedScrolling() && &paintInvalidati onContainer != this) {
1457 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset()); 1450 LayoutSize inverseOffset(toLayoutBox(&paintInvalidationContainer)->scrol ledContentOffset());
1458 newLocation.move(inverseOffset); 1451 newLocation.move(inverseOffset);
1459 newBounds.move(inverseOffset); 1452 newBounds.move(inverseOffset);
1460 } 1453 }
1461 1454
1462 setPreviousPaintInvalidationRect(newBounds); 1455 setPreviousPaintInvalidationRect(newBounds);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 } 1621 }
1629 1622
1630 void LayoutObject::invalidatePaintForOverflowIfNeeded() 1623 void LayoutObject::invalidatePaintForOverflowIfNeeded()
1631 { 1624 {
1632 if (shouldInvalidateOverflowForPaint()) 1625 if (shouldInvalidateOverflowForPaint())
1633 invalidatePaintForOverflow(); 1626 invalidatePaintForOverflow();
1634 } 1627 }
1635 1628
1636 LayoutRect LayoutObject::absoluteClippedOverflowRect() const 1629 LayoutRect LayoutObject::absoluteClippedOverflowRect() const
1637 { 1630 {
1638 return clippedOverflowRectForPaintInvalidation(view());
1639 }
1640
1641 LayoutRect LayoutObject::clippedOverflowRectForPaintInvalidation(const LayoutBox ModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInva lidationState) const
1642 {
1643 LayoutRect rect = localOverflowRectForPaintInvalidation(); 1631 LayoutRect rect = localOverflowRectForPaintInvalidation();
1644 mapToVisibleRectInAncestorSpace(paintInvalidationContainer, rect, paintInval idationState); 1632 mapToVisibleRectInAncestorSpace(view(), rect);
1645 return rect; 1633 return rect;
1646 } 1634 }
1647 1635
1648 LayoutRect LayoutObject::localOverflowRectForPaintInvalidation() const 1636 LayoutRect LayoutObject::localOverflowRectForPaintInvalidation() const
1649 { 1637 {
1650 ASSERT_NOT_REACHED(); 1638 ASSERT_NOT_REACHED();
1651 return LayoutRect(); 1639 return LayoutRect();
1652 } 1640 }
1653 1641
1654 bool LayoutObject::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* a ncestor, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState, VisibleRectFlags visibleRectFlags) const 1642 bool LayoutObject::mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* a ncestor, LayoutRect& rect, VisibleRectFlags visibleRectFlags) const
1655 { 1643 {
1656 // For any layout object that doesn't override this method (the main example is LayoutText), 1644 // For any layout object that doesn't override this method (the main example is LayoutText),
1657 // the rect is assumed to be in the coordinate space of the object's parent. 1645 // the rect is assumed to be in the coordinate space of the object's parent.
1658 1646
1659 if (ancestor == this) 1647 if (ancestor == this)
1660 return true; 1648 return true;
1661 1649
1662 if (paintInvalidationState && paintInvalidationState->canMapToAncestor(ances tor))
1663 return paintInvalidationState->mapObjectRectToAncestor(*this, ancestor, rect, visibleRectFlags);
1664
1665 if (LayoutObject* parent = this->parent()) { 1650 if (LayoutObject* parent = this->parent()) {
1666 if (parent->hasOverflowClip()) { 1651 if (parent->hasOverflowClip()) {
1667 LayoutBox* parentBox = toLayoutBox(parent); 1652 LayoutBox* parentBox = toLayoutBox(parent);
1668 parentBox->mapScrollingContentsRectToBoxSpace(rect); 1653 parentBox->mapScrollingContentsRectToBoxSpace(rect);
1669 if (parent != ancestor && !parentBox->applyOverflowClip(rect, visibl eRectFlags)) 1654 if (parent != ancestor && !parentBox->applyOverflowClip(rect, visibl eRectFlags))
1670 return false; 1655 return false;
1671 } 1656 }
1672 1657
1673 return parent->mapToVisibleRectInAncestorSpace(ancestor, rect, nullptr, visibleRectFlags); 1658 return parent->mapToVisibleRectInAncestorSpace(ancestor, rect, visibleRe ctFlags);
1674 } 1659 }
1675 return true; 1660 return true;
1676 } 1661 }
1677 1662
1678 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*) 1663 void LayoutObject::dirtyLinesFromChangedChild(LayoutObject*)
1679 { 1664 {
1680 } 1665 }
1681 1666
1682 #ifndef NDEBUG 1667 #ifndef NDEBUG
1683 1668
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 } 2234 }
2250 2235
2251 FloatQuad LayoutObject::ancestorToLocalQuad(LayoutBoxModelObject* ancestor, cons t FloatQuad& quad, MapCoordinatesFlags mode) const 2236 FloatQuad LayoutObject::ancestorToLocalQuad(LayoutBoxModelObject* ancestor, cons t FloatQuad& quad, MapCoordinatesFlags mode) const
2252 { 2237 {
2253 TransformState transformState(TransformState::UnapplyInverseTransformDirecti on, quad.boundingBox().center(), quad); 2238 TransformState transformState(TransformState::UnapplyInverseTransformDirecti on, quad.boundingBox().center(), quad);
2254 mapAncestorToLocal(ancestor, transformState, mode); 2239 mapAncestorToLocal(ancestor, transformState, mode);
2255 transformState.flatten(); 2240 transformState.flatten();
2256 return transformState.lastPlanarQuad(); 2241 return transformState.lastPlanarQuad();
2257 } 2242 }
2258 2243
2259 void LayoutObject::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Tran sformState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const Pain tInvalidationState* paintInvalidationState) const 2244 void LayoutObject::mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Tran sformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const
2260 { 2245 {
2261 if (ancestor == this) 2246 if (ancestor == this)
2262 return; 2247 return;
2263 2248
2264 if (paintInvalidationState && paintInvalidationState->canMapToAncestor(ances tor)) {
2265 LayoutSize offset = paintInvalidationState->paintOffset();
2266 if (const LayoutBox* layoutBox = isBox() ? toLayoutBox(this) : nullptr)
2267 offset += layoutBox->locationOffset();
2268 if (const PaintLayer* layer = style()->hasInFlowPosition() && hasLayer() ? toLayoutBoxModelObject(this)->layer() : nullptr)
2269 offset += layer->offsetForInFlowPosition();
2270 transformState.move(offset);
2271 return;
2272 }
2273
2274 if (wasFixed) 2249 if (wasFixed)
2275 *wasFixed = mode & IsFixed; 2250 *wasFixed = mode & IsFixed;
2276 2251
2277 bool containerSkipped; 2252 bool containerSkipped;
2278 const LayoutObject* o = container(ancestor, &containerSkipped); 2253 const LayoutObject* o = container(ancestor, &containerSkipped);
2279 if (!o) 2254 if (!o)
2280 return; 2255 return;
2281 2256
2282 if (mode & ApplyContainerFlip) { 2257 if (mode & ApplyContainerFlip) {
2283 if (isBox()) { 2258 if (isBox()) {
(...skipping 26 matching lines...) Expand all
2310 } 2285 }
2311 2286
2312 if (containerSkipped) { 2287 if (containerSkipped) {
2313 // There can't be a transform between |ancestor| and |o|, because transf orms create 2288 // There can't be a transform between |ancestor| and |o|, because transf orms create
2314 // containers, so it should be safe to just subtract the delta between t he ancestor and |o|. 2289 // containers, so it should be safe to just subtract the delta between t he ancestor and |o|.
2315 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(o); 2290 LayoutSize containerOffset = ancestor->offsetFromAncestorContainer(o);
2316 transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans form); 2291 transformState.move(-containerOffset.width(), -containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans form);
2317 return; 2292 return;
2318 } 2293 }
2319 2294
2320 o->mapLocalToAncestor(ancestor, transformState, mode, wasFixed, paintInvalid ationState); 2295 o->mapLocalToAncestor(ancestor, transformState, mode, wasFixed);
2321 } 2296 }
2322 2297
2323 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const 2298 const LayoutObject* LayoutObject::pushMappingToContainer(const LayoutBoxModelObj ect* ancestorToStopAt, LayoutGeometryMap& geometryMap) const
2324 { 2299 {
2325 ASSERT_NOT_REACHED(); 2300 ASSERT_NOT_REACHED();
2326 return nullptr; 2301 return nullptr;
2327 } 2302 }
2328 2303
2329 void LayoutObject::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Tran sformState& transformState, MapCoordinatesFlags mode) const 2304 void LayoutObject::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, Tran sformState& transformState, MapCoordinatesFlags mode) const
2330 { 2305 {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 { 2384 {
2410 // Track the point at the center of the quad's bounding box. As mapLocalToAn cestor() calls offsetFromContainer(), 2385 // Track the point at the center of the quad's bounding box. As mapLocalToAn cestor() calls offsetFromContainer(),
2411 // it will use that point as the reference point to decide which column's tr ansform to apply in multiple-column blocks. 2386 // it will use that point as the reference point to decide which column's tr ansform to apply in multiple-column blocks.
2412 TransformState transformState(TransformState::ApplyTransformDirection, local Quad.boundingBox().center(), localQuad); 2387 TransformState transformState(TransformState::ApplyTransformDirection, local Quad.boundingBox().center(), localQuad);
2413 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip | Use Transforms, wasFixed); 2388 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip | Use Transforms, wasFixed);
2414 transformState.flatten(); 2389 transformState.flatten();
2415 2390
2416 return transformState.lastPlanarQuad(); 2391 return transformState.lastPlanarQuad();
2417 } 2392 }
2418 2393
2419 FloatPoint LayoutObject::localToAncestorPoint(const FloatPoint& localPoint, cons t LayoutBoxModelObject* ancestor, MapCoordinatesFlags mode, bool* wasFixed, cons t PaintInvalidationState* paintInvalidationState) const 2394 FloatPoint LayoutObject::localToAncestorPoint(const FloatPoint& localPoint, cons t LayoutBoxModelObject* ancestor, MapCoordinatesFlags mode, bool* wasFixed) cons t
2420 { 2395 {
2421 TransformState transformState(TransformState::ApplyTransformDirection, local Point); 2396 TransformState transformState(TransformState::ApplyTransformDirection, local Point);
2422 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip | Use Transforms, wasFixed, paintInvalidationState); 2397 mapLocalToAncestor(ancestor, transformState, mode | ApplyContainerFlip | Use Transforms, wasFixed);
2423 transformState.flatten(); 2398 transformState.flatten();
2424 2399
2425 return transformState.lastPlanarPoint(); 2400 return transformState.lastPlanarPoint();
2426 } 2401 }
2427 2402
2428 void LayoutObject::localToAncestorRects(Vector<LayoutRect>& rects, const LayoutB oxModelObject* ancestor, const LayoutPoint& preOffset, const LayoutPoint& postOf fset) const 2403 void LayoutObject::localToAncestorRects(Vector<LayoutRect>& rects, const LayoutB oxModelObject* ancestor, const LayoutPoint& preOffset, const LayoutPoint& postOf fset) const
2429 { 2404 {
2430 for (size_t i = 0; i < rects.size(); ++i) { 2405 for (size_t i = 0; i < rects.size(); ++i) {
2431 LayoutRect& rect = rects[i]; 2406 LayoutRect& rect = rects[i];
2432 rect.moveBy(preOffset); 2407 rect.moveBy(preOffset);
(...skipping 22 matching lines...) Expand all
2455 2430
2456 if (backingLayer) 2431 if (backingLayer)
2457 *backingLayer = paintInvalidationContainer.layer(); 2432 *backingLayer = paintInvalidationContainer.layer();
2458 FloatPoint containerPoint = localToAncestorPoint(FloatPoint(localPoint), &pa intInvalidationContainer, TraverseDocumentBoundaries); 2433 FloatPoint containerPoint = localToAncestorPoint(FloatPoint(localPoint), &pa intInvalidationContainer, TraverseDocumentBoundaries);
2459 2434
2460 // A layoutObject can have no invalidation backing if it is from a detached frame, 2435 // A layoutObject can have no invalidation backing if it is from a detached frame,
2461 // or when forced compositing is disabled. 2436 // or when forced compositing is disabled.
2462 if (paintInvalidationContainer.layer()->compositingState() == NotComposited) 2437 if (paintInvalidationContainer.layer()->compositingState() == NotComposited)
2463 return containerPoint; 2438 return containerPoint;
2464 2439
2465 PaintLayer::mapPointInPaintInvalidationContainerToBacking(&paintInvalidation Container, containerPoint); 2440 PaintLayer::mapPointInPaintInvalidationContainerToBacking(paintInvalidationC ontainer, containerPoint);
2466 return containerPoint; 2441 return containerPoint;
2467 } 2442 }
2468 2443
2469 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o) const 2444 LayoutSize LayoutObject::offsetFromContainer(const LayoutObject* o) const
2470 { 2445 {
2471 ASSERT(o == container()); 2446 ASSERT(o == container());
2472 return o->hasOverflowClip() ? LayoutSize(-toLayoutBox(o)->scrolledContentOff set()) : LayoutSize(); 2447 return o->hasOverflowClip() ? LayoutSize(-toLayoutBox(o)->scrolledContentOff set()) : LayoutSize();
2473 } 2448 }
2474 2449
2475 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* ancesto rContainer) const 2450 LayoutSize LayoutObject::offsetFromAncestorContainer(const LayoutObject* ancesto rContainer) const
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after
3740 const blink::LayoutObject* root = object1; 3715 const blink::LayoutObject* root = object1;
3741 while (root->parent()) 3716 while (root->parent())
3742 root = root->parent(); 3717 root = root->parent();
3743 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); 3718 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0);
3744 } else { 3719 } else {
3745 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); 3720 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n");
3746 } 3721 }
3747 } 3722 }
3748 3723
3749 #endif 3724 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698