Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: third_party/WebKit/Source/core/events/TouchEvent.cpp

Issue 2680973010: Log when PreventDefaulting event forced uncancellable. (Closed)
Patch Set: Fix silly bug, Win build still fails. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2008, The Android Open Source Project 2 * Copyright 2008, The Android Open Source Project
3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright 10 * * Redistributions in binary form must reproduce the above copyright
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 bool TouchEvent::isTouchEvent() const { 246 bool TouchEvent::isTouchEvent() const {
247 return true; 247 return true;
248 } 248 }
249 249
250 void TouchEvent::preventDefault() { 250 void TouchEvent::preventDefault() {
251 UIEventWithKeyState::preventDefault(); 251 UIEventWithKeyState::preventDefault();
252 252
253 // A common developer error is to wait too long before attempting to stop 253 // A common developer error is to wait too long before attempting to stop
254 // scrolling by consuming a touchmove event. Generate a warning if this 254 // scrolling by consuming a touchmove event. Generate a warning if this
255 // event is uncancelable. 255 // event is uncancelable.
256 MessageSource messageSource = JSMessageSource;
256 String warningMessage; 257 String warningMessage;
257 switch (handlingPassive()) { 258 switch (handlingPassive()) {
258 case PassiveMode::NotPassive: 259 case PassiveMode::NotPassive:
259 case PassiveMode::NotPassiveDefault: 260 case PassiveMode::NotPassiveDefault:
260 if (!cancelable()) { 261 if (!cancelable()) {
261 warningMessage = "Ignored attempt to cancel a " + type() + 262 UseCounter::count(view()->frame(),
262 " event with cancelable=false, for example " 263 UseCounter::UncancellableTouchEventPreventDefaulted);
263 "because scrolling is in progress and " 264
264 "cannot be interrupted."; 265 if (m_nativeEvent &&
266 m_nativeEvent->dispatchType ==
267 WebInputEvent::
268 ListenersForcedNonBlockingDueToMainThreadResponsiveness) {
269 // Non blocking due to main thread responsiveness.
270 UseCounter::count(
271 view()->frame(),
272 UseCounter::
273 UncancellableTouchEventDueToMainThreadResponsivenessPreventDef aulted);
274 messageSource = InterventionMessageSource;
275 warningMessage =
276 "Ignored attempt to cancel a " + type() +
277 " event with cancelable=false. This event was forced to be "
278 "non-cancellable because the page was too busy to handle the "
279 "event promptly.";
280 } else {
281 // Non blocking for any other reason.
282 warningMessage = "Ignored attempt to cancel a " + type() +
bokan 2017/02/10 00:24:06 Just checking - you intend for the ForcedNonBlocki
tdresser 2017/02/10 13:24:57 We consider the "due to fling case" to be equivale
bokan 2017/02/10 15:36:16 Acknowledged.
283 " event with cancelable=false, for example "
284 "because scrolling is in progress and "
285 "cannot be interrupted.";
286 }
265 } 287 }
266 break; 288 break;
267 case PassiveMode::PassiveForcedDocumentLevel: 289 case PassiveMode::PassiveForcedDocumentLevel:
268 // Only enable the warning when the current touch action is auto because 290 // Only enable the warning when the current touch action is auto because
269 // an author may use touch action but call preventDefault for interop with 291 // an author may use touch action but call preventDefault for interop with
270 // browsers that don't support touch-action. 292 // browsers that don't support touch-action.
271 if (m_currentTouchAction == TouchActionAuto) { 293 if (m_currentTouchAction == TouchActionAuto) {
294 messageSource = InterventionMessageSource;
272 warningMessage = 295 warningMessage =
273 "Unable to preventDefault inside passive event listener due to " 296 "Unable to preventDefault inside passive event listener due to "
274 "target being treated as passive. See " 297 "target being treated as passive. See "
275 "https://www.chromestatus.com/features/5093566007214080"; 298 "https://www.chromestatus.com/features/5093566007214080";
276 } 299 }
277 break; 300 break;
278 default: 301 default:
279 break; 302 break;
280 } 303 }
281 304
282 if (!warningMessage.isEmpty() && view() && view()->isLocalDOMWindow() && 305 if (!warningMessage.isEmpty() && view() && view()->isLocalDOMWindow() &&
283 view()->frame()) { 306 view()->frame()) {
284 toLocalDOMWindow(view())->frame()->console().addMessage( 307 toLocalDOMWindow(view())->frame()->console().addMessage(
285 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, 308 ConsoleMessage::create(messageSource, WarningMessageLevel,
286 warningMessage)); 309 warningMessage));
287 } 310 }
288 311
289 if ((type() == EventTypeNames::touchstart || 312 if ((type() == EventTypeNames::touchstart ||
290 type() == EventTypeNames::touchmove) && 313 type() == EventTypeNames::touchmove) &&
291 view() && view()->frame() && m_currentTouchAction == TouchActionAuto) { 314 view() && view()->frame() && m_currentTouchAction == TouchActionAuto) {
292 switch (handlingPassive()) { 315 switch (handlingPassive()) {
293 case PassiveMode::NotPassiveDefault: 316 case PassiveMode::NotPassiveDefault:
294 UseCounter::count(view()->frame(), 317 UseCounter::count(view()->frame(),
295 UseCounter::TouchEventPreventedNoTouchAction); 318 UseCounter::TouchEventPreventedNoTouchAction);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 return toTouchEvent(EventDispatchMediator::event()); 371 return toTouchEvent(EventDispatchMediator::event());
349 } 372 }
350 373
351 DispatchEventResult TouchEventDispatchMediator::dispatchEvent( 374 DispatchEventResult TouchEventDispatchMediator::dispatchEvent(
352 EventDispatcher& dispatcher) const { 375 EventDispatcher& dispatcher) const {
353 event().eventPath().adjustForTouchEvent(event()); 376 event().eventPath().adjustForTouchEvent(event());
354 return dispatcher.dispatch(); 377 return dispatcher.dispatch();
355 } 378 }
356 379
357 } // namespace blink 380 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698