| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView) | 106 void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView) |
| 107 { | 107 { |
| 108 ASSERT(m_page); | 108 ASSERT(m_page); |
| 109 | 109 |
| 110 // Compute the region of the page that we can't do fast scrolling for. This
currently includes | 110 // Compute the region of the page that we can't do fast scrolling for. This
currently includes |
| 111 // all scrollable areas, such as subframes, overflow divs and list boxes, wh
ose composited | 111 // all scrollable areas, such as subframes, overflow divs and list boxes, wh
ose composited |
| 112 // scrolling are not enabled. We need to do this even if the frame view whos
e layout was updated | 112 // 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. | 113 // is not the main frame. |
| 114 Region nonFastScrollableRegion = computeNonFastScrollableRegion(m_page->main
Frame(), IntPoint()); | 114 Region nonFastScrollableRegion = computeNonFastScrollableRegion(m_page->main
Frame(), IntPoint()); |
| 115 setNonFastScrollableRegion(nonFastScrollableRegion); | 115 setNonFastScrollableRegion(nonFastScrollableRegion); |
| 116 #if ENABLE(TOUCH_EVENT_TRACKING) |
| 116 Vector<IntRect> touchEventTargetRects; | 117 Vector<IntRect> touchEventTargetRects; |
| 117 computeAbsoluteTouchEventTargetRects(m_page->mainFrame()->document(), touchE
ventTargetRects); | 118 computeAbsoluteTouchEventTargetRects(m_page->mainFrame()->document(), touchE
ventTargetRects); |
| 118 setTouchEventTargetRects(touchEventTargetRects); | 119 setTouchEventTargetRects(touchEventTargetRects); |
| 120 #endif |
| 119 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(frameView)) | 121 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(frameView)) |
| 120 scrollLayer->setBounds(frameView->contentsSize()); | 122 scrollLayer->setBounds(frameView->contentsSize()); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay
er* layer, bool enable) | 125 void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay
er* layer, bool enable) |
| 124 { | 126 { |
| 125 if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer)) | 127 if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer)) |
| 126 scrollableLayer->setIsContainerForFixedPositionLayers(enable); | 128 scrollableLayer->setIsContainerForFixedPositionLayers(enable); |
| 127 } | 129 } |
| 128 | 130 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF
rame()->view())) { | 291 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF
rame()->view())) { |
| 290 WebVector<WebRect> webRects(absoluteHitTestRects.size()); | 292 WebVector<WebRect> webRects(absoluteHitTestRects.size()); |
| 291 for (size_t i = 0; i < absoluteHitTestRects.size(); ++i) | 293 for (size_t i = 0; i < absoluteHitTestRects.size(); ++i) |
| 292 webRects[i] = absoluteHitTestRects[i]; | 294 webRects[i] = absoluteHitTestRects[i]; |
| 293 scrollLayer->setTouchEventHandlerRegion(webRects); | 295 scrollLayer->setTouchEventHandlerRegion(webRects); |
| 294 } | 296 } |
| 295 } | 297 } |
| 296 | 298 |
| 297 void ScrollingCoordinator::touchEventTargetRectsDidChange(const Document*) | 299 void ScrollingCoordinator::touchEventTargetRectsDidChange(const Document*) |
| 298 { | 300 { |
| 301 #if ENABLE(TOUCH_EVENT_TRACKING) |
| 299 // The rects are always evaluated and used in the main frame coordinates. | 302 // The rects are always evaluated and used in the main frame coordinates. |
| 300 FrameView* frameView = m_page->mainFrame()->view(); | 303 FrameView* frameView = m_page->mainFrame()->view(); |
| 301 Document* document = m_page->mainFrame()->document(); | 304 Document* document = m_page->mainFrame()->document(); |
| 302 | 305 |
| 303 // Wait until after layout to update. | 306 // Wait until after layout to update. |
| 304 if (frameView->needsLayout() || !document) | 307 if (frameView->needsLayout() || !document) |
| 305 return; | 308 return; |
| 306 | 309 |
| 307 Vector<IntRect> touchEventTargetRects; | 310 Vector<IntRect> touchEventTargetRects; |
| 308 computeAbsoluteTouchEventTargetRects(document, touchEventTargetRects); | 311 computeAbsoluteTouchEventTargetRects(document, touchEventTargetRects); |
| 309 setTouchEventTargetRects(touchEventTargetRects); | 312 setTouchEventTargetRects(touchEventTargetRects); |
| 313 #endif |
| 310 } | 314 } |
| 311 | 315 |
| 312 void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count) | 316 void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count) |
| 313 { | 317 { |
| 314 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF
rame()->view())) | 318 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF
rame()->view())) |
| 315 scrollLayer->setHaveWheelEventHandlers(count > 0); | 319 scrollLayer->setHaveWheelEventHandlers(count > 0); |
| 316 } | 320 } |
| 317 | 321 |
| 318 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView
* frameView) | 322 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView
* frameView) |
| 319 { | 323 { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 } | 386 } |
| 383 } | 387 } |
| 384 | 388 |
| 385 FrameTree* tree = frame->tree(); | 389 FrameTree* tree = frame->tree(); |
| 386 for (Frame* subFrame = tree->firstChild(); subFrame; subFrame = subFrame->tr
ee()->nextSibling()) | 390 for (Frame* subFrame = tree->firstChild(); subFrame; subFrame = subFrame->tr
ee()->nextSibling()) |
| 387 nonFastScrollableRegion.unite(computeNonFastScrollableRegion(subFrame, o
ffset)); | 391 nonFastScrollableRegion.unite(computeNonFastScrollableRegion(subFrame, o
ffset)); |
| 388 | 392 |
| 389 return nonFastScrollableRegion; | 393 return nonFastScrollableRegion; |
| 390 } | 394 } |
| 391 | 395 |
| 396 #if ENABLE(TOUCH_EVENT_TRACKING) |
| 392 static void accumulateRendererTouchEventTargetRects(Vector<IntRect>& rects, cons
t RenderObject* renderer, const IntRect& parentRect = IntRect()) | 397 static void accumulateRendererTouchEventTargetRects(Vector<IntRect>& rects, cons
t RenderObject* renderer, const IntRect& parentRect = IntRect()) |
| 393 { | 398 { |
| 394 IntRect adjustedParentRect = parentRect; | 399 IntRect adjustedParentRect = parentRect; |
| 395 if (parentRect.isEmpty() || renderer->isFloating() || renderer->isPositioned
() || renderer->hasTransform()) { | 400 if (parentRect.isEmpty() || renderer->isFloating() || renderer->isPositioned
() || renderer->hasTransform()) { |
| 396 // FIXME: This method is O(N^2) as it walks the tree to the root for eve
ry renderer. RenderGeometryMap would fix this. | 401 // FIXME: This method is O(N^2) as it walks the tree to the root for eve
ry renderer. RenderGeometryMap would fix this. |
| 397 IntRect r = enclosingIntRect(renderer->clippedOverflowRectForRepaint(0))
; | 402 IntRect r = enclosingIntRect(renderer->clippedOverflowRectForRepaint(0))
; |
| 398 if (!r.isEmpty()) { | 403 if (!r.isEmpty()) { |
| 399 // Convert to the top-level view's coordinates. | 404 // Convert to the top-level view's coordinates. |
| 400 ASSERT(renderer->document()->view()); | 405 ASSERT(renderer->document()->view()); |
| 401 r = renderer->document()->view()->convertToRootView(r); | 406 r = renderer->document()->view()->convertToRootView(r); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 457 |
| 453 void ScrollingCoordinator::computeAbsoluteTouchEventTargetRects(const Document*
document, Vector<IntRect>& rects) | 458 void ScrollingCoordinator::computeAbsoluteTouchEventTargetRects(const Document*
document, Vector<IntRect>& rects) |
| 454 { | 459 { |
| 455 ASSERT(document); | 460 ASSERT(document); |
| 456 if (!document->view()) | 461 if (!document->view()) |
| 457 return; | 462 return; |
| 458 | 463 |
| 459 // FIXME: These rects won't be properly updated if the renderers are in a su
b-tree that scrolls. | 464 // FIXME: These rects won't be properly updated if the renderers are in a su
b-tree that scrolls. |
| 460 accumulateDocumentEventTargetRects(rects, document); | 465 accumulateDocumentEventTargetRects(rects, document); |
| 461 } | 466 } |
| 467 #endif |
| 462 | 468 |
| 463 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount() | 469 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount() |
| 464 { | 470 { |
| 465 unsigned wheelEventHandlerCount = 0; | 471 unsigned wheelEventHandlerCount = 0; |
| 466 | 472 |
| 467 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->trave
rseNext()) { | 473 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->trave
rseNext()) { |
| 468 if (frame->document()) | 474 if (frame->document()) |
| 469 wheelEventHandlerCount += frame->document()->wheelEventHandlerCount(
); | 475 wheelEventHandlerCount += frame->document()->wheelEventHandlerCount(
); |
| 470 } | 476 } |
| 471 | 477 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 stringBuilder.resize(stringBuilder.length() - 2); | 625 stringBuilder.resize(stringBuilder.length() - 2); |
| 620 return stringBuilder.toString(); | 626 return stringBuilder.toString(); |
| 621 } | 627 } |
| 622 | 628 |
| 623 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 629 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
| 624 { | 630 { |
| 625 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); | 631 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); |
| 626 } | 632 } |
| 627 | 633 |
| 628 } // namespace WebCore | 634 } // namespace WebCore |
| OLD | NEW |