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 "ScrollingCoordinator.h" | 28 #include "ScrollingCoordinator.h" |
29 | 29 |
30 #include "Document.h" | |
31 #include "Frame.h" | 30 #include "Frame.h" |
32 #include "FrameView.h" | 31 #include "FrameView.h" |
33 #include "GraphicsLayer.h" | 32 #include "GraphicsLayer.h" |
34 #include "IntRect.h" | 33 #include "IntRect.h" |
35 #include "Page.h" | 34 #include "Page.h" |
36 #include "PlatformWheelEvent.h" | 35 #include "PlatformWheelEvent.h" |
37 #include "PluginViewBase.h" | 36 #include "PluginViewBase.h" |
38 #include "Region.h" | 37 #include "Region.h" |
39 #include "RenderView.h" | 38 #include "RenderView.h" |
40 #include "ScrollAnimator.h" | 39 #include "ScrollAnimator.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 170 } |
172 } | 171 } |
173 | 172 |
174 FrameTree* tree = frame->tree(); | 173 FrameTree* tree = frame->tree(); |
175 for (Frame* subFrame = tree->firstChild(); subFrame; subFrame = subFrame->tr
ee()->nextSibling()) | 174 for (Frame* subFrame = tree->firstChild(); subFrame; subFrame = subFrame->tr
ee()->nextSibling()) |
176 nonFastScrollableRegion.unite(computeNonFastScrollableRegion(subFrame, o
ffset)); | 175 nonFastScrollableRegion.unite(computeNonFastScrollableRegion(subFrame, o
ffset)); |
177 | 176 |
178 return nonFastScrollableRegion; | 177 return nonFastScrollableRegion; |
179 } | 178 } |
180 | 179 |
181 #if ENABLE(TOUCH_EVENT_TRACKING) | |
182 static void accumulateRendererTouchEventTargetRects(Vector<IntRect>& rects, cons
t RenderObject* renderer) | |
183 { | |
184 // FIXME: This method is O(N^2) as it walks the tree to the root for every r
enderer. RenderGeometryMap would fix this. | |
185 rects.append(enclosingIntRect(renderer->clippedOverflowRectForRepaint(0))); | |
186 if (renderer->isRenderBlock()) { | |
187 const RenderBlock* block = toRenderBlock(renderer); | |
188 for (RenderObject* child = block->firstChild(); child; child = child->ne
xtSibling()) | |
189 accumulateRendererTouchEventTargetRects(rects, child); | |
190 } | |
191 } | |
192 | |
193 static void accumulateDocumentEventTargetRects(Vector<IntRect>& rects, const Doc
ument* document) | |
194 { | |
195 ASSERT(document); | |
196 if (!document->touchEventTargets()) | |
197 return; | |
198 | |
199 const TouchEventTargetSet* targets = document->touchEventTargets(); | |
200 for (TouchEventTargetSet::const_iterator iter = targets->begin(); iter != ta
rgets->end(); ++iter) { | |
201 const Node* touchTarget = iter->key; | |
202 if (!touchTarget->inDocument()) | |
203 continue; | |
204 | |
205 if (touchTarget == document) { | |
206 if (RenderView* view = document->renderView()) | |
207 rects.append(enclosingIntRect(view->clippedOverflowRectForRepain
t(0))); | |
208 return; | |
209 } | |
210 | |
211 if (touchTarget->isDocumentNode() && touchTarget != document) { | |
212 accumulateDocumentEventTargetRects(rects, static_cast<const Document
*>(touchTarget)); | |
213 continue; | |
214 } | |
215 | |
216 if (RenderObject* renderer = touchTarget->renderer()) | |
217 accumulateRendererTouchEventTargetRects(rects, renderer); | |
218 } | |
219 } | |
220 | |
221 void ScrollingCoordinator::computeAbsoluteTouchEventTargetRects(const Document*
document, Vector<IntRect>& rects) | |
222 { | |
223 ASSERT(document); | |
224 if (!document->view()) | |
225 return; | |
226 | |
227 // FIXME: These rects won't be properly updated if the renderers are in a su
b-tree that scrolls. | |
228 accumulateDocumentEventTargetRects(rects, document); | |
229 } | |
230 #endif | |
231 | |
232 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount() | 180 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount() |
233 { | 181 { |
234 unsigned wheelEventHandlerCount = 0; | 182 unsigned wheelEventHandlerCount = 0; |
235 | 183 |
236 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->trave
rseNext()) { | 184 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->trave
rseNext()) { |
237 if (frame->document()) | 185 if (frame->document()) |
238 wheelEventHandlerCount += frame->document()->wheelEventHandlerCount(
); | 186 wheelEventHandlerCount += frame->document()->wheelEventHandlerCount(
); |
239 } | 187 } |
240 | 188 |
241 return wheelEventHandlerCount; | 189 return wheelEventHandlerCount; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 stringBuilder.resize(stringBuilder.length() - 2); | 414 stringBuilder.resize(stringBuilder.length() - 2); |
467 return stringBuilder.toString(); | 415 return stringBuilder.toString(); |
468 } | 416 } |
469 | 417 |
470 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 418 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
471 { | 419 { |
472 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); | 420 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); |
473 } | 421 } |
474 | 422 |
475 } // namespace WebCore | 423 } // namespace WebCore |
OLD | NEW |