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