| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 3 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 4 * reserved. | 4 * reserved. |
| 5 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 6 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 const int x_signum = (distance.Width() < 0) ? -1 : (distance.Width() > 0); | 231 const int x_signum = (distance.Width() < 0) ? -1 : (distance.Width() > 0); |
| 232 const int y_signum = (distance.Height() < 0) ? -1 : (distance.Height() > 0); | 232 const int y_signum = (distance.Height() < 0) ? -1 : (distance.Height() > 0); |
| 233 FloatSize velocity( | 233 FloatSize velocity( |
| 234 pow(fabs(distance.Width()), kExponent) * kMultiplier * x_signum, | 234 pow(fabs(distance.Width()), kExponent) * kMultiplier * x_signum, |
| 235 pow(fabs(distance.Height()), kExponent) * kMultiplier * y_signum); | 235 pow(fabs(distance.Height()), kExponent) * kMultiplier * y_signum); |
| 236 | 236 |
| 237 if (velocity != last_velocity_) { | 237 if (velocity != last_velocity_) { |
| 238 last_velocity_ = velocity; | 238 last_velocity_ = velocity; |
| 239 if (middle_click_mode_ == kMiddleClickInitial) | 239 if (middle_click_mode_ == kMiddleClickInitial) |
| 240 middle_click_mode_ = kMiddleClickHolding; | 240 middle_click_mode_ = kMiddleClickHolding; |
| 241 page_->GetChromeClient().SetCursorOverridden(false); |
| 241 view->SetCursor(MiddleClickAutoscrollCursor(velocity)); | 242 view->SetCursor(MiddleClickAutoscrollCursor(velocity)); |
| 243 page_->GetChromeClient().SetCursorOverridden(true); |
| 242 page_->GetChromeClient().AutoscrollFling(velocity, frame); | 244 page_->GetChromeClient().AutoscrollFling(velocity, frame); |
| 243 } | 245 } |
| 244 } | 246 } |
| 245 | 247 |
| 246 void AutoscrollController::HandleMouseReleaseForMiddleClickAutoscroll( | 248 void AutoscrollController::HandleMouseReleaseForMiddleClickAutoscroll( |
| 247 LocalFrame* frame, | 249 LocalFrame* frame, |
| 248 bool is_middle_button) { | 250 bool is_middle_button) { |
| 249 DCHECK(RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()); | 251 DCHECK(RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()); |
| 250 if (!MiddleClickAutoscrollInProgress()) | 252 if (!MiddleClickAutoscrollInProgress()) |
| 251 return; | 253 return; |
| 252 | 254 |
| 253 if (!frame->IsMainFrame()) | 255 if (!frame->IsMainFrame()) |
| 254 return; | 256 return; |
| 255 | 257 |
| 256 if (middle_click_mode_ == kMiddleClickInitial && is_middle_button) | 258 if (middle_click_mode_ == kMiddleClickInitial && is_middle_button) |
| 257 middle_click_mode_ = kMiddleClickToggled; | 259 middle_click_mode_ = kMiddleClickToggled; |
| 258 else if (middle_click_mode_ == kMiddleClickHolding) | 260 else if (middle_click_mode_ == kMiddleClickHolding) |
| 259 StopMiddleClickAutoscroll(frame); | 261 StopMiddleClickAutoscroll(frame); |
| 260 } | 262 } |
| 261 | 263 |
| 262 void AutoscrollController::StopMiddleClickAutoscroll(LocalFrame* frame) { | 264 void AutoscrollController::StopMiddleClickAutoscroll(LocalFrame* frame) { |
| 263 if (!MiddleClickAutoscrollInProgress()) | 265 if (!MiddleClickAutoscrollInProgress()) |
| 264 return; | 266 return; |
| 265 | 267 |
| 266 page_->GetChromeClient().AutoscrollEnd(frame); | 268 page_->GetChromeClient().AutoscrollEnd(frame); |
| 267 autoscroll_type_ = kNoAutoscroll; | 269 autoscroll_type_ = kNoAutoscroll; |
| 270 page_->GetChromeClient().SetCursorOverridden(false); |
| 268 frame->LocalFrameRoot().GetEventHandler().ScheduleCursorUpdate(); | 271 frame->LocalFrameRoot().GetEventHandler().ScheduleCursorUpdate(); |
| 269 } | 272 } |
| 270 | 273 |
| 271 bool AutoscrollController::MiddleClickAutoscrollInProgress() const { | 274 bool AutoscrollController::MiddleClickAutoscrollInProgress() const { |
| 272 return autoscroll_type_ == kAutoscrollForMiddleClick; | 275 return autoscroll_type_ == kAutoscrollForMiddleClick; |
| 273 } | 276 } |
| 274 | 277 |
| 275 void AutoscrollController::StartMiddleClickAutoscroll( | 278 void AutoscrollController::StartMiddleClickAutoscroll( |
| 276 LocalFrame* frame, | 279 LocalFrame* frame, |
| 277 const FloatPoint& position, | 280 const FloatPoint& position, |
| 278 const FloatPoint& position_global) { | 281 const FloatPoint& position_global) { |
| 279 DCHECK(RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()); | 282 DCHECK(RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled()); |
| 280 // We don't want to trigger the autoscroll or the middleClickAutoscroll if | 283 // We don't want to trigger the autoscroll or the middleClickAutoscroll if |
| 281 // it's already active. | 284 // it's already active. |
| 282 if (autoscroll_type_ != kNoAutoscroll) | 285 if (autoscroll_type_ != kNoAutoscroll) |
| 283 return; | 286 return; |
| 284 | 287 |
| 285 autoscroll_type_ = kAutoscrollForMiddleClick; | 288 autoscroll_type_ = kAutoscrollForMiddleClick; |
| 286 middle_click_mode_ = kMiddleClickInitial; | 289 middle_click_mode_ = kMiddleClickInitial; |
| 287 middle_click_autoscroll_start_pos_global_ = position_global; | 290 middle_click_autoscroll_start_pos_global_ = position_global; |
| 288 | 291 |
| 289 UseCounter::Count(frame, WebFeature::kMiddleClickAutoscrollStart); | 292 UseCounter::Count(frame, WebFeature::kMiddleClickAutoscrollStart); |
| 290 | 293 |
| 291 last_velocity_ = FloatSize(); | 294 last_velocity_ = FloatSize(); |
| 295 |
| 292 if (LocalFrameView* view = frame->View()) | 296 if (LocalFrameView* view = frame->View()) |
| 293 view->SetCursor(MiddleClickAutoscrollCursor(last_velocity_)); | 297 view->SetCursor(MiddleClickAutoscrollCursor(last_velocity_)); |
| 298 page_->GetChromeClient().SetCursorOverridden(true); |
| 294 page_->GetChromeClient().AutoscrollStart( | 299 page_->GetChromeClient().AutoscrollStart( |
| 295 position.ScaledBy(1 / frame->DevicePixelRatio()), frame); | 300 position.ScaledBy(1 / frame->DevicePixelRatio()), frame); |
| 296 } | 301 } |
| 297 | 302 |
| 298 void AutoscrollController::Animate(double) { | 303 void AutoscrollController::Animate(double) { |
| 299 // Middle-click autoscroll isn't handled on the main thread. | 304 // Middle-click autoscroll isn't handled on the main thread. |
| 300 if (MiddleClickAutoscrollInProgress()) | 305 if (MiddleClickAutoscrollInProgress()) |
| 301 return; | 306 return; |
| 302 | 307 |
| 303 if (!autoscroll_layout_object_ || !autoscroll_layout_object_->GetFrame()) { | 308 if (!autoscroll_layout_object_ || !autoscroll_layout_object_->GetFrame()) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 332 break; | 337 break; |
| 333 } | 338 } |
| 334 } | 339 } |
| 335 | 340 |
| 336 void AutoscrollController::ScheduleMainThreadAnimation() { | 341 void AutoscrollController::ScheduleMainThreadAnimation() { |
| 337 page_->GetChromeClient().ScheduleAnimation( | 342 page_->GetChromeClient().ScheduleAnimation( |
| 338 autoscroll_layout_object_->GetFrame()->View()); | 343 autoscroll_layout_object_->GetFrame()->View()); |
| 339 } | 344 } |
| 340 | 345 |
| 341 } // namespace blink | 346 } // namespace blink |
| OLD | NEW |