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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/dom/Fullscreen.h" | 31 #include "core/dom/Fullscreen.h" |
32 #include "core/dom/Node.h" | 32 #include "core/dom/Node.h" |
33 #include "core/frame/EventHandlerRegistry.h" | 33 #include "core/frame/EventHandlerRegistry.h" |
34 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
36 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
37 #include "core/html/HTMLElement.h" | 37 #include "core/html/HTMLElement.h" |
38 #include "core/layout/compositing/CompositedLayerMapping.h" | 38 #include "core/layout/compositing/CompositedLayerMapping.h" |
39 #include "core/layout/compositing/RenderLayerCompositor.h" | 39 #include "core/layout/compositing/LayerCompositor.h" |
40 #include "core/page/Chrome.h" | 40 #include "core/page/Chrome.h" |
41 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
42 #include "core/plugins/PluginView.h" | 42 #include "core/plugins/PluginView.h" |
43 #include "core/rendering/RenderGeometryMap.h" | 43 #include "core/rendering/RenderGeometryMap.h" |
44 #include "core/rendering/RenderPart.h" | 44 #include "core/rendering/RenderPart.h" |
45 #include "core/rendering/RenderView.h" | 45 #include "core/rendering/RenderView.h" |
46 #include "platform/RuntimeEnabledFeatures.h" | 46 #include "platform/RuntimeEnabledFeatures.h" |
47 #include "platform/TraceEvent.h" | 47 #include "platform/TraceEvent.h" |
48 #include "platform/exported/WebScrollbarImpl.h" | 48 #include "platform/exported/WebScrollbarImpl.h" |
49 #include "platform/exported/WebScrollbarThemeGeometryNative.h" | 49 #include "platform/exported/WebScrollbarThemeGeometryNative.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (WebLayer* scrollableLayer = toWebLayer(layer)) | 203 if (WebLayer* scrollableLayer = toWebLayer(layer)) |
204 scrollableLayer->setIsContainerForFixedPositionLayers(enable); | 204 scrollableLayer->setIsContainerForFixedPositionLayers(enable); |
205 } | 205 } |
206 | 206 |
207 static void clearPositionConstraintExceptForLayer(GraphicsLayer* layer, Graphics
Layer* except) | 207 static void clearPositionConstraintExceptForLayer(GraphicsLayer* layer, Graphics
Layer* except) |
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 RenderLayer* l
ayer) | 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 RenderObject* 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 RenderObject. |
228 } while (layer && !layer->hasCompositedLayerMapping()); | 228 } while (layer && !layer->hasCompositedLayerMapping()); |
229 return WebLayerPositionConstraint(); | 229 return WebLayerPositionConstraint(); |
230 } | 230 } |
231 | 231 |
232 void ScrollingCoordinator::updateLayerPositionConstraint(RenderLayer* 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 |
238 // Avoid unnecessary commits | 238 // Avoid unnecessary commits |
239 clearPositionConstraintExceptForLayer(compositedLayerMapping->squashingConta
inmentLayer(), mainLayer); | 239 clearPositionConstraintExceptForLayer(compositedLayerMapping->squashingConta
inmentLayer(), mainLayer); |
240 clearPositionConstraintExceptForLayer(compositedLayerMapping->ancestorClippi
ngLayer(), mainLayer); | 240 clearPositionConstraintExceptForLayer(compositedLayerMapping->ancestorClippi
ngLayer(), mainLayer); |
241 clearPositionConstraintExceptForLayer(compositedLayerMapping->mainGraphicsLa
yer(), mainLayer); | 241 clearPositionConstraintExceptForLayer(compositedLayerMapping->mainGraphicsLa
yer(), mainLayer); |
242 | 242 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if (m_page->settings().rootLayerScrolls() && isForRootLayer(scrollableArea)) | 423 if (m_page->settings().rootLayerScrolls() && isForRootLayer(scrollableArea)) |
424 m_page->chrome().registerViewportLayers(); | 424 m_page->chrome().registerViewportLayers(); |
425 | 425 |
426 scrollableArea->layerForScrollingDidChange(); | 426 scrollableArea->layerForScrollingDidChange(); |
427 | 427 |
428 return !!webLayer; | 428 return !!webLayer; |
429 } | 429 } |
430 | 430 |
431 using GraphicsLayerHitTestRects = WTF::HashMap<const GraphicsLayer*, Vector<Layo
utRect>>; | 431 using GraphicsLayerHitTestRects = WTF::HashMap<const GraphicsLayer*, Vector<Layo
utRect>>; |
432 | 432 |
433 // In order to do a DFS cross-frame walk of the RenderLayer tree, we need to kno
w which | 433 // In order to do a DFS cross-frame walk of the Layer tree, we need to know whic
h |
434 // RenderLayers have child frames inside of them. This computes a mapping for th
e | 434 // Layers have child frames inside of them. This computes a mapping for the |
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 RenderLayer*, 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 RenderObject* ownerRenderer = toLocalFrame(child)->ownerRenderer()
; |
446 if (!ownerRenderer) | 446 if (!ownerRenderer) |
447 continue; | 447 continue; |
448 const RenderLayer* 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 } |
456 | 456 |
457 static void projectRectsToGraphicsLayerSpaceRecursive( | 457 static void projectRectsToGraphicsLayerSpaceRecursive( |
458 const RenderLayer* curLayer, | 458 const Layer* curLayer, |
459 const LayerHitTestRects& layerRects, | 459 const LayerHitTestRects& layerRects, |
460 GraphicsLayerHitTestRects& graphicsRects, | 460 GraphicsLayerHitTestRects& graphicsRects, |
461 RenderGeometryMap& geometryMap, | 461 RenderGeometryMap& geometryMap, |
462 HashSet<const RenderLayer*>& layersWithRects, | 462 HashSet<const Layer*>& layersWithRects, |
463 LayerFrameMap& layerChildFrameMap) | 463 LayerFrameMap& layerChildFrameMap) |
464 { | 464 { |
465 // Project any rects for the current layer | 465 // Project any rects for the current layer |
466 LayerHitTestRects::const_iterator layerIter = layerRects.find(curLayer); | 466 LayerHitTestRects::const_iterator layerIter = layerRects.find(curLayer); |
467 if (layerIter != layerRects.end()) { | 467 if (layerIter != layerRects.end()) { |
468 // Find the enclosing composited layer when it's in another document (fo
r non-composited iframes). | 468 // Find the enclosing composited layer when it's in another document (fo
r non-composited iframes). |
469 const RenderLayer* compositedLayer = layerIter->key->enclosingLayerForPa
intInvalidationCrossingFrameBoundaries(); | 469 const Layer* compositedLayer = layerIter->key->enclosingLayerForPaintInv
alidationCrossingFrameBoundaries(); |
470 ASSERT(compositedLayer); | 470 ASSERT(compositedLayer); |
471 | 471 |
472 // Find the appropriate GraphicsLayer for the composited RenderLayer. | 472 // Find the appropriate GraphicsLayer for the composited Layer. |
473 GraphicsLayer* graphicsLayer = compositedLayer->graphicsLayerBackingForS
crolling(); | 473 GraphicsLayer* graphicsLayer = compositedLayer->graphicsLayerBackingForS
crolling(); |
474 | 474 |
475 GraphicsLayerHitTestRects::iterator glIter = graphicsRects.find(graphics
Layer); | 475 GraphicsLayerHitTestRects::iterator glIter = graphicsRects.find(graphics
Layer); |
476 Vector<LayoutRect>* glRects; | 476 Vector<LayoutRect>* glRects; |
477 if (glIter == graphicsRects.end()) | 477 if (glIter == graphicsRects.end()) |
478 glRects = &graphicsRects.add(graphicsLayer, Vector<LayoutRect>()).st
oredValue->value; | 478 glRects = &graphicsRects.add(graphicsLayer, Vector<LayoutRect>()).st
oredValue->value; |
479 else | 479 else |
480 glRects = &glIter->value; | 480 glRects = &glIter->value; |
481 | 481 |
482 // Transform each rect to the co-ordinate space of the graphicsLayer. | 482 // Transform each rect to the co-ordinate space of the graphicsLayer. |
483 for (size_t i = 0; i < layerIter->value.size(); ++i) { | 483 for (size_t i = 0; i < layerIter->value.size(); ++i) { |
484 LayoutRect rect = layerIter->value[i]; | 484 LayoutRect rect = layerIter->value[i]; |
485 if (compositedLayer != curLayer) { | 485 if (compositedLayer != curLayer) { |
486 FloatQuad compositorQuad = geometryMap.mapToContainer(rect, comp
ositedLayer->renderer()); | 486 FloatQuad compositorQuad = geometryMap.mapToContainer(rect, comp
ositedLayer->renderer()); |
487 rect = LayoutRect(compositorQuad.boundingBox()); | 487 rect = LayoutRect(compositorQuad.boundingBox()); |
488 // If the enclosing composited layer itself is scrolled, we have
to undo the subtraction | 488 // If the enclosing composited layer itself is scrolled, we have
to undo the subtraction |
489 // of its scroll offset since we want the offset relative to the
scrolling content, not | 489 // of its scroll offset since we want the offset relative to the
scrolling content, not |
490 // the element itself. | 490 // the element itself. |
491 if (compositedLayer->renderer()->hasOverflowClip()) | 491 if (compositedLayer->renderer()->hasOverflowClip()) |
492 rect.move(compositedLayer->renderBox()->scrolledContentOffse
t()); | 492 rect.move(compositedLayer->renderBox()->scrolledContentOffse
t()); |
493 } | 493 } |
494 RenderLayer::mapRectToPaintBackingCoordinates(compositedLayer->rende
rer(), rect); | 494 Layer::mapRectToPaintBackingCoordinates(compositedLayer->renderer(),
rect); |
495 glRects->append(rect); | 495 glRects->append(rect); |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 // Walk child layers of interest | 499 // Walk child layers of interest |
500 for (const RenderLayer* childLayer = curLayer->firstChild(); childLayer; chi
ldLayer = childLayer->nextSibling()) { | 500 for (const Layer* childLayer = curLayer->firstChild(); childLayer; childLaye
r = childLayer->nextSibling()) { |
501 if (layersWithRects.contains(childLayer)) { | 501 if (layersWithRects.contains(childLayer)) { |
502 geometryMap.pushMappingsToAncestor(childLayer, curLayer); | 502 geometryMap.pushMappingsToAncestor(childLayer, curLayer); |
503 projectRectsToGraphicsLayerSpaceRecursive(childLayer, layerRects, gr
aphicsRects, geometryMap, layersWithRects, layerChildFrameMap); | 503 projectRectsToGraphicsLayerSpaceRecursive(childLayer, layerRects, gr
aphicsRects, geometryMap, layersWithRects, layerChildFrameMap); |
504 geometryMap.popMappingsToAncestor(curLayer); | 504 geometryMap.popMappingsToAncestor(curLayer); |
505 } | 505 } |
506 } | 506 } |
507 | 507 |
508 // If this layer has any frames of interest as a child of it, walk those (wi
th an updated frame map). | 508 // If this layer has any frames of interest as a child of it, walk those (wi
th an updated frame map). |
509 LayerFrameMap::iterator mapIter = layerChildFrameMap.find(curLayer); | 509 LayerFrameMap::iterator mapIter = layerChildFrameMap.find(curLayer); |
510 if (mapIter != layerChildFrameMap.end()) { | 510 if (mapIter != layerChildFrameMap.end()) { |
511 for (size_t i = 0; i < mapIter->value.size(); i++) { | 511 for (size_t i = 0; i < mapIter->value.size(); i++) { |
512 const LocalFrame* childFrame = mapIter->value[i]; | 512 const LocalFrame* childFrame = mapIter->value[i]; |
513 const RenderLayer* childLayer = childFrame->view()->renderView()->la
yer(); | 513 const Layer* childLayer = childFrame->view()->renderView()->layer(); |
514 if (layersWithRects.contains(childLayer)) { | 514 if (layersWithRects.contains(childLayer)) { |
515 LayerFrameMap newLayerChildFrameMap; | 515 LayerFrameMap newLayerChildFrameMap; |
516 makeLayerChildFrameMap(childFrame, &newLayerChildFrameMap); | 516 makeLayerChildFrameMap(childFrame, &newLayerChildFrameMap); |
517 geometryMap.pushMappingsToAncestor(childLayer, curLayer); | 517 geometryMap.pushMappingsToAncestor(childLayer, curLayer); |
518 projectRectsToGraphicsLayerSpaceRecursive(childLayer, layerRects
, graphicsRects, geometryMap, layersWithRects, newLayerChildFrameMap); | 518 projectRectsToGraphicsLayerSpaceRecursive(childLayer, layerRects
, graphicsRects, geometryMap, layersWithRects, newLayerChildFrameMap); |
519 geometryMap.popMappingsToAncestor(curLayer); | 519 geometryMap.popMappingsToAncestor(curLayer); |
520 } | 520 } |
521 } | 521 } |
522 } | 522 } |
523 } | 523 } |
524 | 524 |
525 static void projectRectsToGraphicsLayerSpace(LocalFrame* mainFrame, const LayerH
itTestRects& layerRects, GraphicsLayerHitTestRects& graphicsRects) | 525 static void projectRectsToGraphicsLayerSpace(LocalFrame* mainFrame, const LayerH
itTestRects& layerRects, GraphicsLayerHitTestRects& graphicsRects) |
526 { | 526 { |
527 TRACE_EVENT0("input", "ScrollingCoordinator::projectRectsToGraphicsLayerSpac
e"); | 527 TRACE_EVENT0("input", "ScrollingCoordinator::projectRectsToGraphicsLayerSpac
e"); |
528 bool touchHandlerInChildFrame = false; | 528 bool touchHandlerInChildFrame = false; |
529 | 529 |
530 // We have a set of rects per RenderLayer, we need to map them to their boun
ding boxes in their | 530 // We have a set of rects per Layer, we need to map them to their bounding b
oxes in their |
531 // enclosing composited layer. To do this most efficiently we'll walk the Re
nderLayer tree using | 531 // enclosing composited layer. To do this most efficiently we'll walk the La
yer tree using |
532 // RenderGeometryMap. First record all the branches we should traverse in th
e tree (including | 532 // RenderGeometryMap. First record all the branches we should traverse in th
e tree (including |
533 // all documents on the page). | 533 // all documents on the page). |
534 HashSet<const RenderLayer*> layersWithRects; | 534 HashSet<const Layer*> layersWithRects; |
535 for (const auto& layerRect : layerRects) { | 535 for (const auto& layerRect : layerRects) { |
536 const RenderLayer* 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 (RenderObject* 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; |
554 RenderLayer* rootLayer = mainFrame->contentRenderer()->layer(); | 554 Layer* rootLayer = mainFrame->contentRenderer()->layer(); |
555 RenderGeometryMap geometryMap(flags); | 555 RenderGeometryMap geometryMap(flags); |
556 geometryMap.pushMappingsToAncestor(rootLayer, 0); | 556 geometryMap.pushMappingsToAncestor(rootLayer, 0); |
557 LayerFrameMap layerChildFrameMap; | 557 LayerFrameMap layerChildFrameMap; |
558 makeLayerChildFrameMap(mainFrame, &layerChildFrameMap); | 558 makeLayerChildFrameMap(mainFrame, &layerChildFrameMap); |
559 projectRectsToGraphicsLayerSpaceRecursive(rootLayer, layerRects, graphicsRec
ts, geometryMap, layersWithRects, layerChildFrameMap); | 559 projectRectsToGraphicsLayerSpaceRecursive(rootLayer, layerRects, graphicsRec
ts, geometryMap, layersWithRects, layerChildFrameMap); |
560 } | 560 } |
561 | 561 |
562 void ScrollingCoordinator::updateTouchEventTargetRectsIfNeeded() | 562 void ScrollingCoordinator::updateTouchEventTargetRectsIfNeeded() |
563 { | 563 { |
564 TRACE_EVENT0("input", "ScrollingCoordinator::updateTouchEventTargetRectsIfNe
eded"); | 564 TRACE_EVENT0("input", "ScrollingCoordinator::updateTouchEventTargetRectsIfNe
eded"); |
(...skipping 22 matching lines...) Expand all Loading... |
587 setShouldUpdateScrollLayerPositionOnMainThread(m_lastMainThreadScrollingReas
ons); | 587 setShouldUpdateScrollLayerPositionOnMainThread(m_lastMainThreadScrollingReas
ons); |
588 } | 588 } |
589 | 589 |
590 // Note that in principle this could be called more often than computeTouchEvent
TargetRects, for | 590 // Note that in principle this could be called more often than computeTouchEvent
TargetRects, for |
591 // example during a non-composited scroll (although that's not yet implemented -
crbug.com/261307). | 591 // example during a non-composited scroll (although that's not yet implemented -
crbug.com/261307). |
592 void ScrollingCoordinator::setTouchEventTargetRects(LayerHitTestRects& layerRect
s) | 592 void ScrollingCoordinator::setTouchEventTargetRects(LayerHitTestRects& layerRect
s) |
593 { | 593 { |
594 TRACE_EVENT0("input", "ScrollingCoordinator::setTouchEventTargetRects"); | 594 TRACE_EVENT0("input", "ScrollingCoordinator::setTouchEventTargetRects"); |
595 | 595 |
596 // Update the list of layers with touch hit rects. | 596 // Update the list of layers with touch hit rects. |
597 HashSet<const RenderLayer*> oldLayersWithTouchRects; | 597 HashSet<const Layer*> oldLayersWithTouchRects; |
598 m_layersWithTouchRects.swap(oldLayersWithTouchRects); | 598 m_layersWithTouchRects.swap(oldLayersWithTouchRects); |
599 for (const auto& layerRect : layerRects) { | 599 for (const auto& layerRect : layerRects) { |
600 if (!layerRect.value.isEmpty()) { | 600 if (!layerRect.value.isEmpty()) { |
601 const RenderLayer* compositedLayer = layerRect.key->enclosingLayerFo
rPaintInvalidationCrossingFrameBoundaries(); | 601 const Layer* compositedLayer = layerRect.key->enclosingLayerForPaint
InvalidationCrossingFrameBoundaries(); |
602 ASSERT(compositedLayer); | 602 ASSERT(compositedLayer); |
603 m_layersWithTouchRects.add(compositedLayer); | 603 m_layersWithTouchRects.add(compositedLayer); |
604 } | 604 } |
605 } | 605 } |
606 | 606 |
607 // Ensure we have an entry for each composited layer that previously had rec
ts (so that old | 607 // Ensure we have an entry for each composited layer that previously had rec
ts (so that old |
608 // ones will get cleared out). Note that ideally we'd track this on Graphics
Layer instead of | 608 // ones will get cleared out). Note that ideally we'd track this on Graphics
Layer instead of |
609 // RenderLayer, but we have no good hook into the lifetime of a GraphicsLaye
r. | 609 // Layer, but we have no good hook into the lifetime of a GraphicsLayer. |
610 for (const RenderLayer* layer : oldLayersWithTouchRects) { | 610 for (const Layer* layer : oldLayersWithTouchRects) { |
611 if (!layerRects.contains(layer)) | 611 if (!layerRects.contains(layer)) |
612 layerRects.add(layer, Vector<LayoutRect>()); | 612 layerRects.add(layer, Vector<LayoutRect>()); |
613 } | 613 } |
614 | 614 |
615 GraphicsLayerHitTestRects graphicsLayerRects; | 615 GraphicsLayerHitTestRects graphicsLayerRects; |
616 projectRectsToGraphicsLayerSpace(m_page->deprecatedLocalMainFrame(), layerRe
cts, graphicsLayerRects); | 616 projectRectsToGraphicsLayerSpace(m_page->deprecatedLocalMainFrame(), layerRe
cts, graphicsLayerRects); |
617 | 617 |
618 for (const auto& layerRect : graphicsLayerRects) { | 618 for (const auto& layerRect : graphicsLayerRects) { |
619 const GraphicsLayer* graphicsLayer = layerRect.key; | 619 const GraphicsLayer* graphicsLayer = layerRect.key; |
620 WebVector<WebRect> webRects(layerRect.value.size()); | 620 WebVector<WebRect> webRects(layerRect.value.size()); |
(...skipping 14 matching lines...) Expand all Loading... |
635 | 635 |
636 // FIXME: scheduleAnimation() is just a method of forcing the compositor to
realize that it | 636 // FIXME: scheduleAnimation() is just a method of forcing the compositor to
realize that it |
637 // needs to commit here. We should expose a cleaner API for this. | 637 // needs to commit here. We should expose a cleaner API for this. |
638 RenderView* renderView = m_page->deprecatedLocalMainFrame()->contentRenderer
(); | 638 RenderView* renderView = m_page->deprecatedLocalMainFrame()->contentRenderer
(); |
639 if (renderView && renderView->compositor() && renderView->compositor()->stal
eInCompositingMode()) | 639 if (renderView && renderView->compositor() && renderView->compositor()->stal
eInCompositingMode()) |
640 m_page->deprecatedLocalMainFrame()->view()->scheduleAnimation(); | 640 m_page->deprecatedLocalMainFrame()->view()->scheduleAnimation(); |
641 | 641 |
642 m_touchEventTargetRectsAreDirty = true; | 642 m_touchEventTargetRectsAreDirty = true; |
643 } | 643 } |
644 | 644 |
645 void ScrollingCoordinator::updateScrollParentForGraphicsLayer(GraphicsLayer* chi
ld, RenderLayer* parent) | 645 void ScrollingCoordinator::updateScrollParentForGraphicsLayer(GraphicsLayer* chi
ld, Layer* parent) |
646 { | 646 { |
647 WebLayer* scrollParentWebLayer = nullptr; | 647 WebLayer* scrollParentWebLayer = nullptr; |
648 if (parent && parent->hasCompositedLayerMapping()) | 648 if (parent && parent->hasCompositedLayerMapping()) |
649 scrollParentWebLayer = toWebLayer(parent->compositedLayerMapping()->scro
llingContentsLayer()); | 649 scrollParentWebLayer = toWebLayer(parent->compositedLayerMapping()->scro
llingContentsLayer()); |
650 | 650 |
651 child->setScrollParent(scrollParentWebLayer); | 651 child->setScrollParent(scrollParentWebLayer); |
652 } | 652 } |
653 | 653 |
654 void ScrollingCoordinator::updateClipParentForGraphicsLayer(GraphicsLayer* child
, RenderLayer* parent) | 654 void ScrollingCoordinator::updateClipParentForGraphicsLayer(GraphicsLayer* child
, Layer* parent) |
655 { | 655 { |
656 WebLayer* clipParentWebLayer = nullptr; | 656 WebLayer* clipParentWebLayer = nullptr; |
657 if (parent && parent->hasCompositedLayerMapping()) | 657 if (parent && parent->hasCompositedLayerMapping()) |
658 clipParentWebLayer = toWebLayer(parent->compositedLayerMapping()->parent
ForSublayers()); | 658 clipParentWebLayer = toWebLayer(parent->compositedLayerMapping()->parent
ForSublayers()); |
659 | 659 |
660 child->setClipParent(clipParentWebLayer); | 660 child->setClipParent(clipParentWebLayer); |
661 } | 661 } |
662 | 662 |
663 void ScrollingCoordinator::willDestroyRenderLayer(RenderLayer* layer) | 663 void ScrollingCoordinator::willDestroyLayer(Layer* layer) |
664 { | 664 { |
665 m_layersWithTouchRects.remove(layer); | 665 m_layersWithTouchRects.remove(layer); |
666 } | 666 } |
667 | 667 |
668 void ScrollingCoordinator::updateHaveWheelEventHandlers() | 668 void ScrollingCoordinator::updateHaveWheelEventHandlers() |
669 { | 669 { |
670 ASSERT(isMainThread()); | 670 ASSERT(isMainThread()); |
671 ASSERT(m_page); | 671 ASSERT(m_page); |
672 if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFram
e()->view()) | 672 if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFram
e()->view()) |
673 return; | 673 return; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 } else if (RenderObject* renderer = node->renderer()) { | 834 } else if (RenderObject* 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 RenderLayer* enclosingNonCompositedScrollLayer = nullptr; | 844 Layer* enclosingNonCompositedScrollLayer = nullptr; |
845 for (RenderLayer* parent = renderer->enclosingLayer(); parent &&
parent->compositingState() == NotComposited; parent = parent->parent()) { | 845 for (Layer* parent = renderer->enclosingLayer(); parent && paren
t->compositingState() == NotComposited; parent = parent->parent()) { |
846 if (parent->scrollsOverflow()) | 846 if (parent->scrollsOverflow()) |
847 enclosingNonCompositedScrollLayer = parent; | 847 enclosingNonCompositedScrollLayer = parent; |
848 } | 848 } |
849 | 849 |
850 // Report the whole non-composited scroll layer as a touch hit r
ect because any | 850 // Report the whole non-composited scroll layer as a touch hit r
ect because any |
851 // rects inside of it may move around relative to their enclosin
g composited layer | 851 // rects inside of it may move around relative to their enclosin
g composited layer |
852 // without causing the rects to be recomputed. Non-composited sc
rolling occurs on | 852 // without causing the rects to be recomputed. Non-composited sc
rolling occurs on |
853 // the main thread, so we're not getting much benefit from compo
sitor touch hit | 853 // the main thread, so we're not getting much benefit from compo
sitor touch hit |
854 // testing in this case anyway. | 854 // testing in this case anyway. |
855 if (enclosingNonCompositedScrollLayer) | 855 if (enclosingNonCompositedScrollLayer) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 RenderObject* 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 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | 964 Layer* layer = toRenderBoxModelObject(renderer)->layer(); |
965 | 965 |
966 // Whether the RenderLayer 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 RenderObject-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; |
(...skipping 68 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 |