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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 | 27 |
28 #include "core/page/scrolling/ScrollingCoordinator.h" | 28 #include "core/page/scrolling/ScrollingCoordinator.h" |
29 | 29 |
30 #include "RuntimeEnabledFeatures.h" | |
30 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
32 #include "core/dom/Node.h" | |
33 #include "core/html/HTMLElement.h" | |
31 #include "core/page/Frame.h" | 34 #include "core/page/Frame.h" |
32 #include "core/page/FrameView.h" | 35 #include "core/page/FrameView.h" |
33 #include "core/page/Page.h" | 36 #include "core/page/Page.h" |
34 #include "core/platform/PlatformWheelEvent.h" | 37 #include "core/platform/PlatformWheelEvent.h" |
35 #include "core/platform/ScrollAnimator.h" | 38 #include "core/platform/ScrollAnimator.h" |
36 #include "core/platform/ScrollbarThemeComposite.h" | 39 #include "core/platform/ScrollbarThemeComposite.h" |
40 #include "core/platform/chromium/TraceEvent.h" | |
37 #include "core/platform/chromium/support/WebScrollbarImpl.h" | 41 #include "core/platform/chromium/support/WebScrollbarImpl.h" |
38 #include "core/platform/chromium/support/WebScrollbarThemeGeometryNative.h" | 42 #include "core/platform/chromium/support/WebScrollbarThemeGeometryNative.h" |
39 #include "core/platform/graphics/GraphicsLayer.h" | 43 #include "core/platform/graphics/GraphicsLayer.h" |
40 #include "core/platform/graphics/IntRect.h" | 44 #include "core/platform/graphics/IntRect.h" |
41 #include "core/platform/graphics/Region.h" | 45 #include "core/platform/graphics/Region.h" |
46 #include "core/platform/graphics/transforms/TransformState.h" | |
42 #include "core/plugins/PluginView.h" | 47 #include "core/plugins/PluginView.h" |
43 #include "core/rendering/RenderLayerBacking.h" | 48 #include "core/rendering/RenderLayerBacking.h" |
44 #include "core/rendering/RenderLayerCompositor.h" | 49 #include "core/rendering/RenderLayerCompositor.h" |
45 #include "core/rendering/RenderView.h" | 50 #include "core/rendering/RenderView.h" |
46 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
47 #include "public/platform/WebCompositorSupport.h" | 52 #include "public/platform/WebCompositorSupport.h" |
48 #include "public/platform/WebLayerPositionConstraint.h" | 53 #include "public/platform/WebLayerPositionConstraint.h" |
49 #include "public/platform/WebScrollbarLayer.h" | 54 #include "public/platform/WebScrollbarLayer.h" |
50 #include "public/platform/WebScrollbarThemeGeometry.h" | 55 #include "public/platform/WebScrollbarThemeGeometry.h" |
51 #include "public/platform/WebScrollbarThemePainter.h" | 56 #include "public/platform/WebScrollbarThemePainter.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 WebVector<WebRect> webRects(rects.size()); | 103 WebVector<WebRect> webRects(rects.size()); |
99 for (size_t i = 0; i < rects.size(); ++i) | 104 for (size_t i = 0; i < rects.size(); ++i) |
100 webRects[i] = rects[i]; | 105 webRects[i] = rects[i]; |
101 scrollLayer->setNonFastScrollableRegion(webRects); | 106 scrollLayer->setNonFastScrollableRegion(webRects); |
102 } | 107 } |
103 } | 108 } |
104 | 109 |
105 void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView) | 110 void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView) |
106 { | 111 { |
107 ASSERT(m_page); | 112 ASSERT(m_page); |
113 if (!RuntimeEnabledFeatures::touchEnabled()) | |
114 return; | |
115 | |
116 TRACE_EVENT0("input", "ScrollingCoordinator::frameViewLayoutUpdated"); | |
108 | 117 |
109 // Compute the region of the page that we can't handle scroll gestures on im pl thread: | 118 // Compute the region of the page that we can't handle scroll gestures on im pl thread: |
110 // This currently includes: | 119 // This currently includes: |
111 // 1. All scrollable areas, such as subframes, overflow divs and list boxes, whose composited | 120 // 1. All scrollable areas, such as subframes, overflow divs and list boxes, whose composited |
112 // scrolling are not enabled. We need to do this even if the frame view whos e layout was updated | 121 // scrolling are not enabled. We need to do this even if the frame view whos e layout was updated |
113 // is not the main frame. | 122 // is not the main frame. |
114 // 2. Resize control areas, e.g. the small rect at the right bottom of div/t extarea/iframe when | 123 // 2. Resize control areas, e.g. the small rect at the right bottom of div/t extarea/iframe when |
115 // CSS property "resize" is enabled. | 124 // CSS property "resize" is enabled. |
116 // 3. Plugin areas. | 125 // 3. Plugin areas. |
117 Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScro llGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint()); | 126 Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScro llGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint()); |
118 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMa inThreadRegion); | 127 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMa inThreadRegion); |
119 Vector<IntRect> touchEventTargetRects; | 128 LayerHitTestRects touchEventTargetRects; |
120 computeAbsoluteTouchEventTargetRects(m_page->mainFrame()->document(), touchE ventTargetRects); | 129 computeTouchEventTargetRects(touchEventTargetRects); |
121 setTouchEventTargetRects(touchEventTargetRects); | 130 setTouchEventTargetRects(touchEventTargetRects); |
122 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(frameView)) | 131 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(frameView)) |
123 scrollLayer->setBounds(frameView->contentsSize()); | 132 scrollLayer->setBounds(frameView->contentsSize()); |
124 } | 133 } |
125 | 134 |
126 void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay er* layer, bool enable) | 135 void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay er* layer, bool enable) |
127 { | 136 { |
128 if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer)) | 137 if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer)) |
129 scrollableLayer->setIsContainerForFixedPositionLayers(enable); | 138 scrollableLayer->setIsContainerForFixedPositionLayers(enable); |
130 } | 139 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 } | 298 } |
290 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, VerticalScrollbar)) { | 299 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, VerticalScrollbar)) { |
291 GraphicsLayer* verticalScrollbarLayer = verticalScrollbarLayerForScrolla bleArea(scrollableArea); | 300 GraphicsLayer* verticalScrollbarLayer = verticalScrollbarLayerForScrolla bleArea(scrollableArea); |
292 if (verticalScrollbarLayer) | 301 if (verticalScrollbarLayer) |
293 setupScrollbarLayer(verticalScrollbarLayer, scrollbarLayer, webLayer ); | 302 setupScrollbarLayer(verticalScrollbarLayer, scrollbarLayer, webLayer ); |
294 } | 303 } |
295 | 304 |
296 return !!webLayer; | 305 return !!webLayer; |
297 } | 306 } |
298 | 307 |
299 void ScrollingCoordinator::setTouchEventTargetRects(const Vector<IntRect>& absol uteHitTestRects) | 308 static void convertLayerRectsToEnclosingCompositedLayer(const LayerHitTestRects& layerRects, LayerHitTestRects& compositorRects) |
300 { | 309 { |
301 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF rame()->view())) { | 310 // We have a set of rects per RenderLayer, we need to map them to their boun ding boxes in their |
302 WebVector<WebRect> webRects(absoluteHitTestRects.size()); | 311 // enclosing composited layer. |
303 for (size_t i = 0; i < absoluteHitTestRects.size(); ++i) | 312 for (LayerHitTestRects::const_iterator layerIter = layerRects.begin(); layer Iter != layerRects.end(); ++layerIter) { |
304 webRects[i] = absoluteHitTestRects[i]; | 313 // Find the enclosing composited layer when it's in another document (fo r non-composited iframes). |
305 scrollLayer->setTouchEventHandlerRegion(webRects); | 314 RenderLayer* compositedLayer = 0; |
315 for (const RenderLayer* layer = layerIter->key; !compositedLayer;) { | |
316 compositedLayer = layer->enclosingCompositingLayerForRepaint(); | |
317 if (!compositedLayer) { | |
318 RenderObject* owner = layer->renderer()->frame()->ownerRenderer( ); | |
319 if (!owner) | |
320 break; | |
321 layer = owner->enclosingLayer(); | |
322 } | |
323 } | |
324 if (!compositedLayer) | |
325 continue; | |
leviw_travelin_and_unemployed
2013/07/18 18:08:39
Does this happen? When?
| |
326 | |
327 LayerHitTestRects::iterator compIter = compositorRects.find(compositedLa yer); | |
328 if (compIter == compositorRects.end()) | |
329 compIter = compositorRects.add(compositedLayer, Vector<IntRect>()).i terator; | |
330 | |
331 // Transform each rect to the co-ordinate space of it's enclosing compos ited layer. | |
332 // Ideally we'd compute a transformation matrix once and re-use it for e ach rect, but | |
333 // there doesn't appear to be any easy way to do it (mapLocalToContainer will flatten | |
334 // the TransformState, so we can't use setQuad/mappedQuad over and over again). Perhaps | |
335 // RenderGeometryMap? | |
336 for (size_t i = 0; i < layerIter->value.size(); ++i) { | |
337 FloatQuad localQuad(layerIter->value[i]); | |
338 TransformState transformState(TransformState::ApplyTransformDirectio n, localQuad); | |
339 MapCoordinatesFlags flags = ApplyContainerFlip | UseTransforms | Tra verseDocumentBoundaries; | |
340 layerIter->key->renderer()->mapLocalToContainer(compositedLayer->ren derer(), transformState, flags); | |
341 transformState.flatten(); | |
342 IntRect compositorRect = enclosingIntRect(transformState.lastPlanarQ uad().boundingBox()); | |
343 compIter->value.append(compositorRect); | |
344 } | |
345 } | |
346 } | |
347 | |
348 void ScrollingCoordinator::setTouchEventTargetRects(const LayerHitTestRects& lay erRects) | |
349 { | |
350 TRACE_EVENT0("input", "ScrollingCoordinator::setTouchEventTargetRects"); | |
351 | |
352 LayerHitTestRects compositorRects; | |
353 convertLayerRectsToEnclosingCompositedLayer(layerRects, compositorRects); | |
354 | |
355 // Inform any observers (i.e. for testing) of these new rects. | |
356 HashSet<TouchEventTargetRectsObserver*>::iterator stop = m_touchEventTargetR ectsObservers.end(); | |
357 for (HashSet<TouchEventTargetRectsObserver*>::iterator it = m_touchEventTarg etRectsObservers.begin(); it != stop; ++it) | |
358 (*it)->touchEventTargetRectsChanged(compositorRects); | |
359 | |
360 // Note that ideally we'd clear the touch event handler region on all layers first, | |
361 // in case there are others that no longer have any handlers. But it's unlik ely to | |
362 // matter much in practice (just makes us more conservative). | |
363 for (LayerHitTestRects::const_iterator iter = compositorRects.begin(); iter != compositorRects.end(); ++iter) { | |
364 WebVector<WebRect> webRects(iter->value.size()); | |
365 for (size_t i = 0; i < iter->value.size(); ++i) | |
366 webRects[i] = iter->value[i]; | |
367 RenderLayerBacking* backing = iter->key->backing(); | |
368 // If the layer is using composited scrolling, then it's the contents th at these | |
369 // rects apply to. | |
370 GraphicsLayer* graphicsLayer = backing->scrollingContentsLayer(); | |
371 if (!graphicsLayer) | |
372 graphicsLayer = backing->graphicsLayer(); | |
373 graphicsLayer->platformLayer()->setTouchEventHandlerRegion(webRects); | |
306 } | 374 } |
307 } | 375 } |
308 | 376 |
309 void ScrollingCoordinator::touchEventTargetRectsDidChange(const Document*) | 377 void ScrollingCoordinator::touchEventTargetRectsDidChange(const Document*) |
310 { | 378 { |
311 // The rects are always evaluated and used in the main frame coordinates. | 379 if (!RuntimeEnabledFeatures::touchEnabled()) |
312 FrameView* frameView = m_page->mainFrame()->view(); | 380 return; |
313 Document* document = m_page->mainFrame()->document(); | |
314 | 381 |
315 // Wait until after layout to update. | 382 // Wait until after layout to update. |
316 if (frameView->needsLayout() || !document) | 383 if (m_page->mainFrame()->view()->needsLayout()) |
317 return; | 384 return; |
318 | 385 |
319 Vector<IntRect> touchEventTargetRects; | 386 TRACE_EVENT0("input", "ScrollingCoordinator::touchEventTargetRectsDidChange" ); |
320 computeAbsoluteTouchEventTargetRects(document, touchEventTargetRects); | 387 |
388 LayerHitTestRects touchEventTargetRects; | |
389 computeTouchEventTargetRects(touchEventTargetRects); | |
321 setTouchEventTargetRects(touchEventTargetRects); | 390 setTouchEventTargetRects(touchEventTargetRects); |
322 } | 391 } |
323 | 392 |
324 void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count) | 393 void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count) |
325 { | 394 { |
326 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF rame()->view())) | 395 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF rame()->view())) |
327 scrollLayer->setHaveWheelEventHandlers(count > 0); | 396 scrollLayer->setHaveWheelEventHandlers(count > 0); |
328 } | 397 } |
329 | 398 |
330 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView * frameView) | 399 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView * frameView) |
(...skipping 25 matching lines...) Expand all Loading... | |
356 | 425 |
357 // We currently only support composited mode. | 426 // We currently only support composited mode. |
358 RenderView* renderView = m_page->mainFrame()->contentRenderer(); | 427 RenderView* renderView = m_page->mainFrame()->contentRenderer(); |
359 if (!renderView) | 428 if (!renderView) |
360 return false; | 429 return false; |
361 return renderView->usesCompositing(); | 430 return renderView->usesCompositing(); |
362 } | 431 } |
363 | 432 |
364 Region ScrollingCoordinator::computeShouldHandleScrollGestureOnMainThreadRegion( const Frame* frame, const IntPoint& frameLocation) const | 433 Region ScrollingCoordinator::computeShouldHandleScrollGestureOnMainThreadRegion( const Frame* frame, const IntPoint& frameLocation) const |
365 { | 434 { |
435 TRACE_EVENT0("input", "ScrollingCoordinator::computeShouldHandleScrollGestur eOnMainThreadRegion"); | |
366 Region shouldHandleScrollGestureOnMainThreadRegion; | 436 Region shouldHandleScrollGestureOnMainThreadRegion; |
367 FrameView* frameView = frame->view(); | 437 FrameView* frameView = frame->view(); |
368 if (!frameView) | 438 if (!frameView) |
369 return shouldHandleScrollGestureOnMainThreadRegion; | 439 return shouldHandleScrollGestureOnMainThreadRegion; |
370 | 440 |
371 IntPoint offset = frameLocation; | 441 IntPoint offset = frameLocation; |
372 offset.moveBy(frameView->frameRect().location()); | 442 offset.moveBy(frameView->frameRect().location()); |
373 | 443 |
374 if (const FrameView::ScrollableAreaSet* scrollableAreas = frameView->scrolla bleAreas()) { | 444 if (const FrameView::ScrollableAreaSet* scrollableAreas = frameView->scrolla bleAreas()) { |
375 for (FrameView::ScrollableAreaSet::const_iterator it = scrollableAreas-> begin(), end = scrollableAreas->end(); it != end; ++it) { | 445 for (FrameView::ScrollableAreaSet::const_iterator it = scrollableAreas-> begin(), end = scrollableAreas->end(); it != end; ++it) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 } | 478 } |
409 } | 479 } |
410 | 480 |
411 FrameTree* tree = frame->tree(); | 481 FrameTree* tree = frame->tree(); |
412 for (Frame* subFrame = tree->firstChild(); subFrame; subFrame = subFrame->tr ee()->nextSibling()) | 482 for (Frame* subFrame = tree->firstChild(); subFrame; subFrame = subFrame->tr ee()->nextSibling()) |
413 shouldHandleScrollGestureOnMainThreadRegion.unite(computeShouldHandleScr ollGestureOnMainThreadRegion(subFrame, offset)); | 483 shouldHandleScrollGestureOnMainThreadRegion.unite(computeShouldHandleScr ollGestureOnMainThreadRegion(subFrame, offset)); |
414 | 484 |
415 return shouldHandleScrollGestureOnMainThreadRegion; | 485 return shouldHandleScrollGestureOnMainThreadRegion; |
416 } | 486 } |
417 | 487 |
418 static void accumulateRendererTouchEventTargetRects(Vector<IntRect>& rects, cons t RenderObject* renderer, const IntRect& parentRect = IntRect()) | 488 void ScrollingCoordinator::addTouchEventTargetRectsObserver(TouchEventTargetRect sObserver* observer) |
419 { | 489 { |
420 IntRect adjustedParentRect = parentRect; | 490 m_touchEventTargetRectsObservers.add(observer); |
421 if (parentRect.isEmpty() || renderer->isFloating() || renderer->isPositioned () || renderer->hasTransform()) { | |
422 // FIXME: This method is O(N^2) as it walks the tree to the root for eve ry renderer. RenderGeometryMap would fix this. | |
423 IntRect r = enclosingIntRect(renderer->clippedOverflowRectForRepaint(0)) ; | |
424 if (!r.isEmpty()) { | |
425 // Convert to the top-level view's coordinates. | |
426 ASSERT(renderer->document()->view()); | |
427 r = renderer->document()->view()->convertToRootView(r); | |
428 | |
429 if (!parentRect.contains(r)) { | |
430 rects.append(r); | |
431 adjustedParentRect = r; | |
432 } | |
433 } | |
434 } | |
435 | |
436 for (RenderObject* child = renderer->firstChild(); child; child = child->nex tSibling()) | |
437 accumulateRendererTouchEventTargetRects(rects, child, adjustedParentRect ); | |
438 } | 491 } |
439 | 492 |
440 static void accumulateDocumentEventTargetRects(Vector<IntRect>& rects, const Doc ument* document) | 493 void ScrollingCoordinator::removeTouchEventTargetRectsObserver(TouchEventTargetR ectsObserver* observer) |
494 { | |
495 m_touchEventTargetRectsObservers.remove(observer); | |
496 } | |
497 | |
498 static void accumulateDocumentTouchEventTargetRects(LayerHitTestRects& rects, co nst Document* document) | |
441 { | 499 { |
442 ASSERT(document); | 500 ASSERT(document); |
443 if (!document->touchEventTargets()) | 501 if (!document->touchEventTargets()) |
444 return; | 502 return; |
445 | 503 |
446 const TouchEventTargetSet* targets = document->touchEventTargets(); | 504 const TouchEventTargetSet* targets = document->touchEventTargets(); |
505 | |
506 // If there's a handler on the document, html or body element (fairly common in practice), | |
507 // then we can quickly mark the entire document and skip looking at any othe r handlers. | |
508 // Note that technically a handler on the body doesn't cover the whole docum ent, but it's | |
509 // reasonable to be conservative and report the whole document anyway. | |
447 for (TouchEventTargetSet::const_iterator iter = targets->begin(); iter != ta rgets->end(); ++iter) { | 510 for (TouchEventTargetSet::const_iterator iter = targets->begin(); iter != ta rgets->end(); ++iter) { |
448 const Node* touchTarget = iter->key; | 511 Node* target = iter->key; |
449 if (!touchTarget->inDocument()) | 512 if (target == document || target == document->documentElement() || targe t == document->body()) { |
450 continue; | 513 if (RenderObject* renderer = document->renderer()) { |
451 | 514 renderer->computeLayerHitTestRects(rects); |
452 if (touchTarget == document) { | |
453 if (RenderView* view = document->renderView()) { | |
454 IntRect r; | |
455 if (touchTarget == document->topDocument()) | |
456 r = view->documentRect(); | |
457 else | |
458 r = enclosingIntRect(view->clippedOverflowRectForRepaint(0)) ; | |
459 | |
460 if (!r.isEmpty()) { | |
461 ASSERT(view->document()->view()); | |
462 r = view->document()->view()->convertToRootView(r); | |
463 rects.append(r); | |
464 } | |
465 } | 515 } |
466 return; | 516 return; |
467 } | 517 } |
518 } | |
468 | 519 |
469 if (touchTarget->isDocumentNode() && touchTarget != document) { | 520 // Examine every target in detail. |
leviw_travelin_and_unemployed
2013/07/18 18:08:39
This comment doesn't really help.
Rick Byers
2013/07/18 19:58:52
Removed
| |
470 accumulateDocumentEventTargetRects(rects, toDocument(touchTarget)); | 521 for (TouchEventTargetSet::const_iterator iter = targets->begin(); iter != ta rgets->end(); ++iter) { |
522 const Node* target = iter->key; | |
523 if (!target->inDocument()) | |
471 continue; | 524 continue; |
525 | |
526 if (target->isDocumentNode()) { | |
527 ASSERT(target != document); | |
528 accumulateDocumentTouchEventTargetRects(rects, toDocument(target)); | |
529 } else if (RenderObject* renderer = target->renderer()) { | |
530 renderer->computeLayerHitTestRects(rects); | |
472 } | 531 } |
532 } | |
473 | 533 |
474 if (RenderObject* renderer = touchTarget->renderer()) | |
475 accumulateRendererTouchEventTargetRects(rects, renderer); | |
476 } | |
477 } | 534 } |
478 | 535 |
479 void ScrollingCoordinator::computeAbsoluteTouchEventTargetRects(const Document* document, Vector<IntRect>& rects) | 536 void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects ) |
480 { | 537 { |
481 ASSERT(document); | 538 TRACE_EVENT0("input", "ScrollingCoordinator::computeTouchEventTargetRects"); |
482 if (!document->view()) | 539 |
540 Document* document = m_page->mainFrame()->document(); | |
541 if (!document || !document->view()) | |
483 return; | 542 return; |
484 | 543 |
485 // FIXME: These rects won't be properly updated if the renderers are in a su b-tree that scrolls. | 544 accumulateDocumentTouchEventTargetRects(rects, document); |
486 accumulateDocumentEventTargetRects(rects, document); | |
487 } | 545 } |
488 | 546 |
489 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount() | 547 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount() |
490 { | 548 { |
491 unsigned wheelEventHandlerCount = 0; | 549 unsigned wheelEventHandlerCount = 0; |
492 | 550 |
493 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->trave rseNext()) { | 551 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->trave rseNext()) { |
494 if (frame->document()) | 552 if (frame->document()) |
495 wheelEventHandlerCount += frame->document()->wheelEventHandlerCount( ); | 553 wheelEventHandlerCount += frame->document()->wheelEventHandlerCount( ); |
496 } | 554 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 stringBuilder.resize(stringBuilder.length() - 2); | 706 stringBuilder.resize(stringBuilder.length() - 2); |
649 return stringBuilder.toString(); | 707 return stringBuilder.toString(); |
650 } | 708 } |
651 | 709 |
652 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 710 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
653 { | 711 { |
654 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); | 712 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); |
655 } | 713 } |
656 | 714 |
657 } // namespace WebCore | 715 } // namespace WebCore |
OLD | NEW |