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

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp

Issue 2692853016: Change PaintLayer::m_layoutObject to a reference. (Closed)
Patch Set: Added TODO Created 3 years, 10 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) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 static void clearPositionConstraintExceptForLayer(GraphicsLayer* layer, 277 static void clearPositionConstraintExceptForLayer(GraphicsLayer* layer,
278 GraphicsLayer* except) { 278 GraphicsLayer* except) {
279 if (layer && layer != except && toWebLayer(layer)) 279 if (layer && layer != except && toWebLayer(layer))
280 toWebLayer(layer)->setPositionConstraint(WebLayerPositionConstraint()); 280 toWebLayer(layer)->setPositionConstraint(WebLayerPositionConstraint());
281 } 281 }
282 282
283 static WebLayerPositionConstraint computePositionConstraint( 283 static WebLayerPositionConstraint computePositionConstraint(
284 const PaintLayer* layer) { 284 const PaintLayer* layer) {
285 DCHECK(layer->hasCompositedLayerMapping()); 285 DCHECK(layer->hasCompositedLayerMapping());
286 do { 286 do {
287 if (layer->layoutObject()->style()->position() == EPosition::kFixed) { 287 if (layer->layoutObject().style()->position() == EPosition::kFixed) {
288 const LayoutObject* fixedPositionObject = layer->layoutObject(); 288 const LayoutObject& fixedPositionObject = layer->layoutObject();
289 bool fixedToRight = !fixedPositionObject->style()->right().isAuto(); 289 bool fixedToRight = !fixedPositionObject.style()->right().isAuto();
290 bool fixedToBottom = !fixedPositionObject->style()->bottom().isAuto(); 290 bool fixedToBottom = !fixedPositionObject.style()->bottom().isAuto();
291 return WebLayerPositionConstraint::fixedPosition(fixedToRight, 291 return WebLayerPositionConstraint::fixedPosition(fixedToRight,
292 fixedToBottom); 292 fixedToBottom);
293 } 293 }
294 294
295 layer = layer->parent(); 295 layer = layer->parent();
296 296
297 // Composited layers that inherit a fixed position state will be positioned 297 // Composited layers that inherit a fixed position state will be positioned
298 // with respect to the nearest compositedLayerMapping's GraphicsLayer. 298 // with respect to the nearest compositedLayerMapping's GraphicsLayer.
299 // So, once we find a layer that has its own compositedLayerMapping, we can 299 // So, once we find a layer that has its own compositedLayerMapping, we can
300 // stop searching for a fixed position LayoutObject. 300 // stop searching for a fixed position LayoutObject.
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 566 }
567 567
568 static void projectRectsToGraphicsLayerSpaceRecursive( 568 static void projectRectsToGraphicsLayerSpaceRecursive(
569 const PaintLayer* curLayer, 569 const PaintLayer* curLayer,
570 const LayerHitTestRects& layerRects, 570 const LayerHitTestRects& layerRects,
571 GraphicsLayerHitTestRects& graphicsRects, 571 GraphicsLayerHitTestRects& graphicsRects,
572 LayoutGeometryMap& geometryMap, 572 LayoutGeometryMap& geometryMap,
573 HashSet<const PaintLayer*>& layersWithRects, 573 HashSet<const PaintLayer*>& layersWithRects,
574 LayerFrameMap& layerChildFrameMap) { 574 LayerFrameMap& layerChildFrameMap) {
575 // If this layer is throttled, ignore it. 575 // If this layer is throttled, ignore it.
576 if (curLayer->layoutObject()->frameView() && 576 if (curLayer->layoutObject().frameView() &&
577 curLayer->layoutObject()->frameView()->shouldThrottleRendering()) 577 curLayer->layoutObject().frameView()->shouldThrottleRendering())
578 return; 578 return;
579 // Project any rects for the current layer 579 // Project any rects for the current layer
580 LayerHitTestRects::const_iterator layerIter = layerRects.find(curLayer); 580 LayerHitTestRects::const_iterator layerIter = layerRects.find(curLayer);
581 if (layerIter != layerRects.end()) { 581 if (layerIter != layerRects.end()) {
582 // Find the enclosing composited layer when it's in another document (for 582 // Find the enclosing composited layer when it's in another document (for
583 // non-composited iframes). 583 // non-composited iframes).
584 const PaintLayer* compositedLayer = 584 const PaintLayer* compositedLayer =
585 layerIter->key 585 layerIter->key
586 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries(); 586 ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries();
587 DCHECK(compositedLayer); 587 DCHECK(compositedLayer);
588 588
589 // Find the appropriate GraphicsLayer for the composited Layer. 589 // Find the appropriate GraphicsLayer for the composited Layer.
590 GraphicsLayer* graphicsLayer = 590 GraphicsLayer* graphicsLayer =
591 compositedLayer->graphicsLayerBacking(curLayer->layoutObject()); 591 compositedLayer->graphicsLayerBacking(&curLayer->layoutObject());
592 592
593 GraphicsLayerHitTestRects::iterator glIter = 593 GraphicsLayerHitTestRects::iterator glIter =
594 graphicsRects.find(graphicsLayer); 594 graphicsRects.find(graphicsLayer);
595 Vector<LayoutRect>* glRects; 595 Vector<LayoutRect>* glRects;
596 if (glIter == graphicsRects.end()) 596 if (glIter == graphicsRects.end())
597 glRects = &graphicsRects.insert(graphicsLayer, Vector<LayoutRect>()) 597 glRects = &graphicsRects.insert(graphicsLayer, Vector<LayoutRect>())
598 .storedValue->value; 598 .storedValue->value;
599 else 599 else
600 glRects = &glIter->value; 600 glRects = &glIter->value;
601 601
602 // Transform each rect to the co-ordinate space of the graphicsLayer. 602 // Transform each rect to the co-ordinate space of the graphicsLayer.
603 for (size_t i = 0; i < layerIter->value.size(); ++i) { 603 for (size_t i = 0; i < layerIter->value.size(); ++i) {
604 LayoutRect rect = layerIter->value[i]; 604 LayoutRect rect = layerIter->value[i];
605 if (compositedLayer != curLayer) { 605 if (compositedLayer != curLayer) {
606 FloatQuad compositorQuad = geometryMap.mapToAncestor( 606 FloatQuad compositorQuad = geometryMap.mapToAncestor(
607 FloatRect(rect), compositedLayer->layoutObject()); 607 FloatRect(rect), &compositedLayer->layoutObject());
608 rect = LayoutRect(compositorQuad.boundingBox()); 608 rect = LayoutRect(compositorQuad.boundingBox());
609 // If the enclosing composited layer itself is scrolled, we have to undo 609 // If the enclosing composited layer itself is scrolled, we have to undo
610 // the subtraction of its scroll offset since we want the offset 610 // the subtraction of its scroll offset since we want the offset
611 // relative to the scrolling content, not the element itself. 611 // relative to the scrolling content, not the element itself.
612 if (compositedLayer->layoutObject()->hasOverflowClip()) 612 if (compositedLayer->layoutObject().hasOverflowClip())
613 rect.move(compositedLayer->layoutBox()->scrolledContentOffset()); 613 rect.move(compositedLayer->layoutBox()->scrolledContentOffset());
614 } 614 }
615 PaintLayer::mapRectInPaintInvalidationContainerToBacking( 615 PaintLayer::mapRectInPaintInvalidationContainerToBacking(
616 *compositedLayer->layoutObject(), rect); 616 compositedLayer->layoutObject(), rect);
617 rect.move(-graphicsLayer->offsetFromLayoutObject()); 617 rect.move(-graphicsLayer->offsetFromLayoutObject());
618 618
619 glRects->push_back(rect); 619 glRects->push_back(rect);
620 } 620 }
621 } 621 }
622 622
623 // Walk child layers of interest 623 // Walk child layers of interest
624 for (const PaintLayer* childLayer = curLayer->firstChild(); childLayer; 624 for (const PaintLayer* childLayer = curLayer->firstChild(); childLayer;
625 childLayer = childLayer->nextSibling()) { 625 childLayer = childLayer->nextSibling()) {
626 if (layersWithRects.contains(childLayer)) { 626 if (layersWithRects.contains(childLayer)) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 for (const auto& layerRect : layerRects) { 670 for (const auto& layerRect : layerRects) {
671 const PaintLayer* layer = layerRect.key; 671 const PaintLayer* layer = layerRect.key;
672 do { 672 do {
673 if (!layersWithRects.insert(layer).isNewEntry) 673 if (!layersWithRects.insert(layer).isNewEntry)
674 break; 674 break;
675 675
676 if (layer->parent()) { 676 if (layer->parent()) {
677 layer = layer->parent(); 677 layer = layer->parent();
678 } else { 678 } else {
679 LayoutItem parentDocLayoutItem = 679 LayoutItem parentDocLayoutItem =
680 layer->layoutObject()->frame()->ownerLayoutItem(); 680 layer->layoutObject().frame()->ownerLayoutItem();
681 if (!parentDocLayoutItem.isNull()) { 681 if (!parentDocLayoutItem.isNull()) {
682 layer = parentDocLayoutItem.enclosingLayer(); 682 layer = parentDocLayoutItem.enclosingLayer();
683 touchHandlerInChildFrame = true; 683 touchHandlerInChildFrame = true;
684 } 684 }
685 } 685 }
686 } while (layer); 686 } while (layer);
687 } 687 }
688 688
689 // Now walk the layer projecting rects while maintaining a LayoutGeometryMap 689 // Now walk the layer projecting rects while maintaining a LayoutGeometryMap
690 MapCoordinatesFlags flags = UseTransforms; 690 MapCoordinatesFlags flags = UseTransforms;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 void ScrollingCoordinator::setTouchEventTargetRects( 735 void ScrollingCoordinator::setTouchEventTargetRects(
736 LayerHitTestRects& layerRects) { 736 LayerHitTestRects& layerRects) {
737 TRACE_EVENT0("input", "ScrollingCoordinator::setTouchEventTargetRects"); 737 TRACE_EVENT0("input", "ScrollingCoordinator::setTouchEventTargetRects");
738 738
739 // Ensure we have an entry for each composited layer that previously had rects 739 // Ensure we have an entry for each composited layer that previously had rects
740 // (so that old ones will get cleared out). Note that ideally we'd track this 740 // (so that old ones will get cleared out). Note that ideally we'd track this
741 // on GraphicsLayer instead of Layer, but we have no good hook into the 741 // on GraphicsLayer instead of Layer, but we have no good hook into the
742 // lifetime of a GraphicsLayer. 742 // lifetime of a GraphicsLayer.
743 GraphicsLayerHitTestRects graphicsLayerRects; 743 GraphicsLayerHitTestRects graphicsLayerRects;
744 for (const PaintLayer* layer : m_layersWithTouchRects) { 744 for (const PaintLayer* layer : m_layersWithTouchRects) {
745 if (layer->layoutObject()->frameView() && 745 if (layer->layoutObject().frameView() &&
746 layer->layoutObject()->frameView()->shouldThrottleRendering()) { 746 layer->layoutObject().frameView()->shouldThrottleRendering()) {
747 continue; 747 continue;
748 } 748 }
749 GraphicsLayer* mainGraphicsLayer = 749 GraphicsLayer* mainGraphicsLayer =
750 layer->graphicsLayerBacking(layer->layoutObject()); 750 layer->graphicsLayerBacking(&layer->layoutObject());
751 if (mainGraphicsLayer) 751 if (mainGraphicsLayer)
752 graphicsLayerRects.insert(mainGraphicsLayer, Vector<LayoutRect>()); 752 graphicsLayerRects.insert(mainGraphicsLayer, Vector<LayoutRect>());
753 GraphicsLayer* scrollingContentsLayer = layer->graphicsLayerBacking(); 753 GraphicsLayer* scrollingContentsLayer = layer->graphicsLayerBacking();
754 if (scrollingContentsLayer && scrollingContentsLayer != mainGraphicsLayer) 754 if (scrollingContentsLayer && scrollingContentsLayer != mainGraphicsLayer)
755 graphicsLayerRects.insert(scrollingContentsLayer, Vector<LayoutRect>()); 755 graphicsLayerRects.insert(scrollingContentsLayer, Vector<LayoutRect>());
756 } 756 }
757 757
758 m_layersWithTouchRects.clear(); 758 m_layersWithTouchRects.clear();
759 for (const auto& layerRect : layerRects) { 759 for (const auto& layerRect : layerRects) {
760 if (!layerRect.value.isEmpty()) { 760 if (!layerRect.value.isEmpty()) {
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 frameView ? toWebLayer(frameView->layoutViewportScrollableArea() 1188 frameView ? toWebLayer(frameView->layoutViewportScrollableArea()
1189 ->layerForScrolling()) 1189 ->layerForScrolling())
1190 : nullptr) { 1190 : nullptr) {
1191 return WebSize(frameView->layoutViewportScrollableArea()->contentsSize()) != 1191 return WebSize(frameView->layoutViewportScrollableArea()->contentsSize()) !=
1192 scrollLayer->bounds(); 1192 scrollLayer->bounds();
1193 } 1193 }
1194 return false; 1194 return false;
1195 } 1195 }
1196 1196
1197 } // namespace blink 1197 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698