OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 { | 46 { |
47 Page* page = frame->page(); | 47 Page* page = frame->page(); |
48 return page ? page->mainFrame() : 0; | 48 return page ? page->mainFrame() : 0; |
49 } | 49 } |
50 #endif | 50 #endif |
51 | 51 |
52 AutoscrollController::AutoscrollController() | 52 AutoscrollController::AutoscrollController() |
53 : m_autoscrollTimer(this, &AutoscrollController::autoscrollTimerFired) | 53 : m_autoscrollTimer(this, &AutoscrollController::autoscrollTimerFired) |
54 , m_autoscrollRenderer(0) | 54 , m_autoscrollRenderer(0) |
55 , m_autoscrollType(NoAutoscroll) | 55 , m_autoscrollType(NoAutoscroll) |
56 #if ENABLE(PAN_SCROLLING) | |
57 , m_panScrollButtonPressed(false) | |
58 , m_springLoadedPanScrollInProgress(false) | |
59 #endif | |
60 { | 56 { |
61 } | 57 } |
62 | 58 |
63 RenderBox* AutoscrollController::autoscrollRenderer() const | 59 RenderBox* AutoscrollController::autoscrollRenderer() const |
64 { | 60 { |
65 return m_autoscrollRenderer; | 61 return m_autoscrollRenderer; |
66 } | 62 } |
67 | 63 |
68 bool AutoscrollController::autoscrollInProgress() const | 64 bool AutoscrollController::autoscrollInProgress() const |
69 { | 65 { |
(...skipping 12 matching lines...) Expand all Loading... |
82 m_autoscrollRenderer = scrollable; | 78 m_autoscrollRenderer = scrollable; |
83 startAutoscrollTimer(); | 79 startAutoscrollTimer(); |
84 } | 80 } |
85 | 81 |
86 void AutoscrollController::stopAutoscrollTimer(bool rendererIsBeingDestroyed) | 82 void AutoscrollController::stopAutoscrollTimer(bool rendererIsBeingDestroyed) |
87 { | 83 { |
88 RenderBox* scrollable = m_autoscrollRenderer; | 84 RenderBox* scrollable = m_autoscrollRenderer; |
89 m_autoscrollTimer.stop(); | 85 m_autoscrollTimer.stop(); |
90 m_autoscrollType = NoAutoscroll; | 86 m_autoscrollType = NoAutoscroll; |
91 m_autoscrollRenderer = 0; | 87 m_autoscrollRenderer = 0; |
92 #if ENABLE(PAN_SCROLLING) | |
93 m_panScrollButtonPressed = false; | |
94 m_springLoadedPanScrollInProgress = false; | |
95 #endif | |
96 | 88 |
97 if (!scrollable) | 89 if (!scrollable) |
98 return; | 90 return; |
99 | 91 |
100 Frame* frame = scrollable->frame(); | 92 Frame* frame = scrollable->frame(); |
101 EventHandler* eventHandler = frame->eventHandler(); | 93 EventHandler* eventHandler = frame->eventHandler(); |
102 if (autoscrollInProgress() && eventHandler->mouseDownWasInSubframe()) { | 94 if (autoscrollInProgress() && eventHandler->mouseDownWasInSubframe()) { |
103 if (Frame* subframe = eventHandler->subframeForTargetNode(eventHandler->
mousePressNode())) | 95 if (Frame* subframe = eventHandler->subframeForTargetNode(eventHandler->
mousePressNode())) |
104 subframe->eventHandler()->stopAutoscrollTimer(rendererIsBeingDestroy
ed); | 96 subframe->eventHandler()->stopAutoscrollTimer(rendererIsBeingDestroy
ed); |
105 return; | 97 return; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 m_autoscrollType = AutoscrollForPan; | 142 m_autoscrollType = AutoscrollForPan; |
151 } | 143 } |
152 | 144 |
153 void AutoscrollController::didPanScrollStop() | 145 void AutoscrollController::didPanScrollStop() |
154 { | 146 { |
155 m_autoscrollType = NoAutoscroll; | 147 m_autoscrollType = NoAutoscroll; |
156 } | 148 } |
157 | 149 |
158 void AutoscrollController::handleMouseReleaseEvent(const PlatformMouseEvent& mou
seEvent) | 150 void AutoscrollController::handleMouseReleaseEvent(const PlatformMouseEvent& mou
seEvent) |
159 { | 151 { |
160 if (mouseEvent.button() == MiddleButton) | 152 switch (m_autoscrollType) { |
161 m_panScrollButtonPressed = false; | 153 case AutoscrollForPan: |
162 if (m_springLoadedPanScrollInProgress) | 154 if (mouseEvent.button() == MiddleButton) |
| 155 m_autoscrollType = AutoscrollForPanCanStop; |
| 156 break; |
| 157 case AutoscrollForPanCanStop: |
163 stopAutoscrollTimer(); | 158 stopAutoscrollTimer(); |
| 159 break; |
| 160 } |
164 } | 161 } |
165 | 162 |
166 bool AutoscrollController::panScrollInProgress() const | 163 bool AutoscrollController::panScrollInProgress() const |
167 { | 164 { |
168 return m_autoscrollType == AutoscrollForPan; | 165 return m_autoscrollType == AutoscrollForPan || m_autoscrollType == Autoscrol
lForPanCanStop; |
169 } | 166 } |
170 | 167 |
171 void AutoscrollController::startPanScrolling(RenderBox* scrollable, const IntPoi
nt& lastKnownMousePosition) | 168 void AutoscrollController::startPanScrolling(RenderBox* scrollable, const IntPoi
nt& lastKnownMousePosition) |
172 { | 169 { |
173 // We don't want to trigger the autoscroll or the panScroll if it's already
active | 170 // We don't want to trigger the autoscroll or the panScroll if it's already
active |
174 if (m_autoscrollTimer.isActive()) | 171 if (m_autoscrollTimer.isActive()) |
175 return; | 172 return; |
176 | 173 |
177 m_autoscrollType = AutoscrollForPan; | 174 m_autoscrollType = AutoscrollForPan; |
178 m_autoscrollRenderer = scrollable; | 175 m_autoscrollRenderer = scrollable; |
179 m_panScrollStartPos = lastKnownMousePosition; | 176 m_panScrollStartPos = lastKnownMousePosition; |
180 m_springLoadedPanScrollInProgress = false; | |
181 | 177 |
182 if (FrameView* view = scrollable->frame()->view()) | 178 if (FrameView* view = scrollable->frame()->view()) |
183 view->addPanScrollIcon(lastKnownMousePosition); | 179 view->addPanScrollIcon(lastKnownMousePosition); |
184 scrollable->frame()->eventHandler()->didPanScrollStart(); | 180 scrollable->frame()->eventHandler()->didPanScrollStart(); |
185 startAutoscrollTimer(); | 181 startAutoscrollTimer(); |
186 } | 182 } |
187 #else | 183 #else |
188 bool AutoscrollController::panScrollInProgress() const | 184 bool AutoscrollController::panScrollInProgress() const |
189 { | 185 { |
190 return false; | 186 return false; |
(...skipping 12 matching lines...) Expand all Loading... |
203 case AutoscrollForSelection: | 199 case AutoscrollForSelection: |
204 if (!frame->eventHandler()->mousePressed()) { | 200 if (!frame->eventHandler()->mousePressed()) { |
205 stopAutoscrollTimer(); | 201 stopAutoscrollTimer(); |
206 return; | 202 return; |
207 } | 203 } |
208 m_autoscrollRenderer->autoscroll(); | 204 m_autoscrollRenderer->autoscroll(); |
209 break; | 205 break; |
210 case NoAutoscroll: | 206 case NoAutoscroll: |
211 break; | 207 break; |
212 #if ENABLE(PAN_SCROLLING) | 208 #if ENABLE(PAN_SCROLLING) |
| 209 case AutoscrollForPanCanStop: |
213 case AutoscrollForPan: | 210 case AutoscrollForPan: |
214 // we verify that the main frame hasn't received the order to stop the p
anScroll | 211 // we verify that the main frame hasn't received the order to stop the p
anScroll |
215 if (Frame* mainFrame = getMainFrame(frame)) { | 212 if (Frame* mainFrame = getMainFrame(frame)) { |
216 if (!mainFrame->eventHandler()->panScrollInProgress()) { | 213 if (!mainFrame->eventHandler()->panScrollInProgress()) { |
217 stopAutoscrollTimer(); | 214 stopAutoscrollTimer(); |
218 return; | 215 return; |
219 } | 216 } |
220 } | 217 } |
221 if (FrameView* view = frame->view()) | 218 if (FrameView* view = frame->view()) |
222 updatePanScrollState(view, frame->eventHandler()->lastKnownMousePosi
tion()); | 219 updatePanScrollState(view, frame->eventHandler()->lastKnownMousePosi
tion()); |
(...skipping 11 matching lines...) Expand all Loading... |
234 #if ENABLE(PAN_SCROLLING) | 231 #if ENABLE(PAN_SCROLLING) |
235 void AutoscrollController::updatePanScrollState(FrameView* view, const IntPoint&
lastKnownMousePosition) | 232 void AutoscrollController::updatePanScrollState(FrameView* view, const IntPoint&
lastKnownMousePosition) |
236 { | 233 { |
237 // At the original click location we draw a 4 arrowed icon. Over this icon t
here won't be any scroll | 234 // At the original click location we draw a 4 arrowed icon. Over this icon t
here won't be any scroll |
238 // So we don't want to change the cursor over this area | 235 // So we don't want to change the cursor over this area |
239 bool east = m_panScrollStartPos.x() < (lastKnownMousePosition.x() - ScrollVi
ew::noPanScrollRadius); | 236 bool east = m_panScrollStartPos.x() < (lastKnownMousePosition.x() - ScrollVi
ew::noPanScrollRadius); |
240 bool west = m_panScrollStartPos.x() > (lastKnownMousePosition.x() + ScrollVi
ew::noPanScrollRadius); | 237 bool west = m_panScrollStartPos.x() > (lastKnownMousePosition.x() + ScrollVi
ew::noPanScrollRadius); |
241 bool north = m_panScrollStartPos.y() > (lastKnownMousePosition.y() + ScrollV
iew::noPanScrollRadius); | 238 bool north = m_panScrollStartPos.y() > (lastKnownMousePosition.y() + ScrollV
iew::noPanScrollRadius); |
242 bool south = m_panScrollStartPos.y() < (lastKnownMousePosition.y() - ScrollV
iew::noPanScrollRadius); | 239 bool south = m_panScrollStartPos.y() < (lastKnownMousePosition.y() - ScrollV
iew::noPanScrollRadius); |
243 | 240 |
244 if ((east || west || north || south) && m_panScrollButtonPressed) | 241 if (m_autoscrollType == AutoscrollForPan && (east || west || north || south)
) |
245 m_springLoadedPanScrollInProgress = true; | 242 m_autoscrollType = AutoscrollForPanCanStop; |
246 | 243 |
247 if (north) { | 244 if (north) { |
248 if (east) | 245 if (east) |
249 view->setCursor(northEastPanningCursor()); | 246 view->setCursor(northEastPanningCursor()); |
250 else if (west) | 247 else if (west) |
251 view->setCursor(northWestPanningCursor()); | 248 view->setCursor(northWestPanningCursor()); |
252 else | 249 else |
253 view->setCursor(northPanningCursor()); | 250 view->setCursor(northPanningCursor()); |
254 } else if (south) { | 251 } else if (south) { |
255 if (east) | 252 if (east) |
256 view->setCursor(southEastPanningCursor()); | 253 view->setCursor(southEastPanningCursor()); |
257 else if (west) | 254 else if (west) |
258 view->setCursor(southWestPanningCursor()); | 255 view->setCursor(southWestPanningCursor()); |
259 else | 256 else |
260 view->setCursor(southPanningCursor()); | 257 view->setCursor(southPanningCursor()); |
261 } else if (east) | 258 } else if (east) |
262 view->setCursor(eastPanningCursor()); | 259 view->setCursor(eastPanningCursor()); |
263 else if (west) | 260 else if (west) |
264 view->setCursor(westPanningCursor()); | 261 view->setCursor(westPanningCursor()); |
265 else | 262 else |
266 view->setCursor(middlePanningCursor()); | 263 view->setCursor(middlePanningCursor()); |
267 } | 264 } |
268 #endif | 265 #endif |
269 | 266 |
270 } // namespace WebCore | 267 } // namespace WebCore |
OLD | NEW |