OLD | NEW |
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 { | 208 { |
209 if (layer && layer != except && toWebLayer(layer)) | 209 if (layer && layer != except && toWebLayer(layer)) |
210 toWebLayer(layer)->setPositionConstraint(WebLayerPositionConstraint()); | 210 toWebLayer(layer)->setPositionConstraint(WebLayerPositionConstraint()); |
211 } | 211 } |
212 | 212 |
213 static WebLayerPositionConstraint computePositionConstraint(const Layer* layer) | 213 static WebLayerPositionConstraint computePositionConstraint(const Layer* layer) |
214 { | 214 { |
215 ASSERT(layer->hasCompositedLayerMapping()); | 215 ASSERT(layer->hasCompositedLayerMapping()); |
216 do { | 216 do { |
217 if (layer->renderer()->style()->position() == FixedPosition) { | 217 if (layer->renderer()->style()->position() == FixedPosition) { |
218 const RenderObject* fixedPositionObject = layer->renderer(); | 218 const LayoutObject* fixedPositionObject = layer->renderer(); |
219 bool fixedToRight = !fixedPositionObject->style()->right().isAuto(); | 219 bool fixedToRight = !fixedPositionObject->style()->right().isAuto(); |
220 bool fixedToBottom = !fixedPositionObject->style()->bottom().isAuto(
); | 220 bool fixedToBottom = !fixedPositionObject->style()->bottom().isAuto(
); |
221 return WebLayerPositionConstraint::fixedPosition(fixedToRight, fixed
ToBottom); | 221 return WebLayerPositionConstraint::fixedPosition(fixedToRight, fixed
ToBottom); |
222 } | 222 } |
223 | 223 |
224 layer = layer->parent(); | 224 layer = layer->parent(); |
225 | 225 |
226 // Composited layers that inherit a fixed position state will be positio
ned with respect to the nearest compositedLayerMapping's GraphicsLayer. | 226 // Composited layers that inherit a fixed position state will be positio
ned with respect to the nearest compositedLayerMapping's GraphicsLayer. |
227 // So, once we find a layer that has its own compositedLayerMapping, we
can stop searching for a fixed position RenderObject. | 227 // So, once we find a layer that has its own compositedLayerMapping, we
can stop searching for a fixed position LayoutObject. |
228 } while (layer && !layer->hasCompositedLayerMapping()); | 228 } while (layer && !layer->hasCompositedLayerMapping()); |
229 return WebLayerPositionConstraint(); | 229 return WebLayerPositionConstraint(); |
230 } | 230 } |
231 | 231 |
232 void ScrollingCoordinator::updateLayerPositionConstraint(Layer* layer) | 232 void ScrollingCoordinator::updateLayerPositionConstraint(Layer* layer) |
233 { | 233 { |
234 ASSERT(layer->hasCompositedLayerMapping()); | 234 ASSERT(layer->hasCompositedLayerMapping()); |
235 CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMappi
ng(); | 235 CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMappi
ng(); |
236 GraphicsLayer* mainLayer = compositedLayerMapping->childForSuperlayers(); | 236 GraphicsLayer* mainLayer = compositedLayerMapping->childForSuperlayers(); |
237 | 237 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 // current frame which we can consult while walking the layers of that frame. | 435 // current frame which we can consult while walking the layers of that frame. |
436 // Whenever we descend into a new frame, a new map will be created. | 436 // Whenever we descend into a new frame, a new map will be created. |
437 using LayerFrameMap = HashMap<const Layer*, Vector<const LocalFrame*>>; | 437 using LayerFrameMap = HashMap<const Layer*, Vector<const LocalFrame*>>; |
438 static void makeLayerChildFrameMap(const LocalFrame* currentFrame, LayerFrameMap
* map) | 438 static void makeLayerChildFrameMap(const LocalFrame* currentFrame, LayerFrameMap
* map) |
439 { | 439 { |
440 map->clear(); | 440 map->clear(); |
441 const FrameTree& tree = currentFrame->tree(); | 441 const FrameTree& tree = currentFrame->tree(); |
442 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne
xtSibling()) { | 442 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne
xtSibling()) { |
443 if (!child->isLocalFrame()) | 443 if (!child->isLocalFrame()) |
444 continue; | 444 continue; |
445 const RenderObject* ownerRenderer = toLocalFrame(child)->ownerRenderer()
; | 445 const LayoutObject* ownerRenderer = toLocalFrame(child)->ownerRenderer()
; |
446 if (!ownerRenderer) | 446 if (!ownerRenderer) |
447 continue; | 447 continue; |
448 const Layer* containingLayer = ownerRenderer->enclosingLayer(); | 448 const Layer* containingLayer = ownerRenderer->enclosingLayer(); |
449 LayerFrameMap::iterator iter = map->find(containingLayer); | 449 LayerFrameMap::iterator iter = map->find(containingLayer); |
450 if (iter == map->end()) | 450 if (iter == map->end()) |
451 map->add(containingLayer, Vector<const LocalFrame*>()).storedValue->
value.append(toLocalFrame(child)); | 451 map->add(containingLayer, Vector<const LocalFrame*>()).storedValue->
value.append(toLocalFrame(child)); |
452 else | 452 else |
453 iter->value.append(toLocalFrame(child)); | 453 iter->value.append(toLocalFrame(child)); |
454 } | 454 } |
455 } | 455 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // all documents on the page). | 533 // all documents on the page). |
534 HashSet<const Layer*> layersWithRects; | 534 HashSet<const Layer*> layersWithRects; |
535 for (const auto& layerRect : layerRects) { | 535 for (const auto& layerRect : layerRects) { |
536 const Layer* layer = layerRect.key; | 536 const Layer* layer = layerRect.key; |
537 do { | 537 do { |
538 if (!layersWithRects.add(layer).isNewEntry) | 538 if (!layersWithRects.add(layer).isNewEntry) |
539 break; | 539 break; |
540 | 540 |
541 if (layer->parent()) { | 541 if (layer->parent()) { |
542 layer = layer->parent(); | 542 layer = layer->parent(); |
543 } else if (RenderObject* parentDocRenderer = layer->renderer()->fram
e()->ownerRenderer()) { | 543 } else if (LayoutObject* parentDocRenderer = layer->renderer()->fram
e()->ownerRenderer()) { |
544 layer = parentDocRenderer->enclosingLayer(); | 544 layer = parentDocRenderer->enclosingLayer(); |
545 touchHandlerInChildFrame = true; | 545 touchHandlerInChildFrame = true; |
546 } | 546 } |
547 } while (layer); | 547 } while (layer); |
548 } | 548 } |
549 | 549 |
550 // Now walk the layer projecting rects while maintaining a RenderGeometryMap | 550 // Now walk the layer projecting rects while maintaining a RenderGeometryMap |
551 MapCoordinatesFlags flags = UseTransforms; | 551 MapCoordinatesFlags flags = UseTransforms; |
552 if (touchHandlerInChildFrame) | 552 if (touchHandlerInChildFrame) |
553 flags |= TraverseDocumentBoundaries; | 553 flags |= TraverseDocumentBoundaries; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 if (!node || !node->inDocument()) | 824 if (!node || !node->inDocument()) |
825 continue; | 825 continue; |
826 | 826 |
827 // If the document belongs to an invisible subframe it does not have a c
omposited layer | 827 // If the document belongs to an invisible subframe it does not have a c
omposited layer |
828 // and should be skipped. | 828 // and should be skipped. |
829 if (node->document().isInInvisibleSubframe()) | 829 if (node->document().isInInvisibleSubframe()) |
830 continue; | 830 continue; |
831 | 831 |
832 if (node->isDocumentNode() && node != document) { | 832 if (node->isDocumentNode() && node != document) { |
833 accumulateDocumentTouchEventTargetRects(rects, toDocument(node)); | 833 accumulateDocumentTouchEventTargetRects(rects, toDocument(node)); |
834 } else if (RenderObject* renderer = node->renderer()) { | 834 } else if (LayoutObject* renderer = node->renderer()) { |
835 // If the set also contains one of our ancestor nodes then processin
g | 835 // If the set also contains one of our ancestor nodes then processin
g |
836 // this node would be redundant. | 836 // this node would be redundant. |
837 bool hasTouchEventTargetAncestor = false; | 837 bool hasTouchEventTargetAncestor = false; |
838 for (Node* ancestor = node->parentNode(); ancestor && !hasTouchEvent
TargetAncestor; ancestor = ancestor->parentNode()) { | 838 for (Node* ancestor = node->parentNode(); ancestor && !hasTouchEvent
TargetAncestor; ancestor = ancestor->parentNode()) { |
839 if (targets->contains(ancestor)) | 839 if (targets->contains(ancestor)) |
840 hasTouchEventTargetAncestor = true; | 840 hasTouchEventTargetAncestor = true; |
841 } | 841 } |
842 if (!hasTouchEventTargetAncestor) { | 842 if (!hasTouchEventTargetAncestor) { |
843 // Walk up the tree to the outermost non-composited scrollable l
ayer. | 843 // Walk up the tree to the outermost non-composited scrollable l
ayer. |
844 Layer* enclosingNonCompositedScrollLayer = nullptr; | 844 Layer* enclosingNonCompositedScrollLayer = nullptr; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 frameView->scrollAnimator()->handleWheelEventPhase(phase); | 951 frameView->scrollAnimator()->handleWheelEventPhase(phase); |
952 } | 952 } |
953 #endif | 953 #endif |
954 | 954 |
955 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
View* frameView) const | 955 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
View* frameView) const |
956 { | 956 { |
957 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects =
frameView->viewportConstrainedObjects(); | 957 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects =
frameView->viewportConstrainedObjects(); |
958 if (!viewportConstrainedObjects) | 958 if (!viewportConstrainedObjects) |
959 return false; | 959 return false; |
960 | 960 |
961 for (const RenderObject* renderer : *viewportConstrainedObjects) { | 961 for (const LayoutObject* renderer : *viewportConstrainedObjects) { |
962 ASSERT(renderer->isBoxModelObject() && renderer->hasLayer()); | 962 ASSERT(renderer->isBoxModelObject() && renderer->hasLayer()); |
963 ASSERT(renderer->style()->position() == FixedPosition); | 963 ASSERT(renderer->style()->position() == FixedPosition); |
964 Layer* layer = toRenderBoxModelObject(renderer)->layer(); | 964 Layer* layer = toRenderBoxModelObject(renderer)->layer(); |
965 | 965 |
966 // Whether the Layer scrolls with the viewport is a tree-depenent | 966 // Whether the Layer scrolls with the viewport is a tree-depenent |
967 // property and our viewportConstrainedObjects collection is maintained | 967 // property and our viewportConstrainedObjects collection is maintained |
968 // with only RenderObject-level information. | 968 // with only LayoutObject-level information. |
969 if (!layer->scrollsWithViewport()) | 969 if (!layer->scrollsWithViewport()) |
970 continue; | 970 continue; |
971 | 971 |
972 // If the whole subtree is invisible, there's no reason to scroll on | 972 // If the whole subtree is invisible, there's no reason to scroll on |
973 // the main thread because we don't need to generate invalidations | 973 // the main thread because we don't need to generate invalidations |
974 // for invisible content. | 974 // for invisible content. |
975 if (layer->subtreeIsInvisible()) | 975 if (layer->subtreeIsInvisible()) |
976 continue; | 976 continue; |
977 | 977 |
978 // We're only smart enough to scroll viewport-constrainted objects | 978 // We're only smart enough to scroll viewport-constrainted objects |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 bool frameIsScrollable = frameView && frameView->isScrollable(); | 1045 bool frameIsScrollable = frameView && frameView->isScrollable(); |
1046 if (frameIsScrollable != m_wasFrameScrollable) | 1046 if (frameIsScrollable != m_wasFrameScrollable) |
1047 return true; | 1047 return true; |
1048 | 1048 |
1049 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : nullptr) | 1049 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : nullptr) |
1050 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds(
); | 1050 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds(
); |
1051 return false; | 1051 return false; |
1052 } | 1052 } |
1053 | 1053 |
1054 } // namespace blink | 1054 } // namespace blink |
OLD | NEW |