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

Unified Diff: third_party/WebKit/Source/core/events/TouchEvent.cpp

Issue 2539183003: Don't log a console warning when touch-action is used. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/events/TouchEvent.cpp
diff --git a/third_party/WebKit/Source/core/events/TouchEvent.cpp b/third_party/WebKit/Source/core/events/TouchEvent.cpp
index b4df51359f30b24c0c8c5e6142b2c2a341dee3ec..7a0a36f0f9d5068e153ba1e9eb01c5446c70df0d 100644
--- a/third_party/WebKit/Source/core/events/TouchEvent.cpp
+++ b/third_party/WebKit/Source/core/events/TouchEvent.cpp
@@ -199,7 +199,8 @@ void logTouchTargetHistogram(EventTarget* eventTarget,
TouchEvent::TouchEvent()
: m_causesScrollingIfUncanceled(false),
m_firstTouchMoveOrStart(false),
- m_defaultPreventedBeforeCurrentTarget(false) {}
+ m_defaultPreventedBeforeCurrentTarget(false),
+ m_currentTouchAction(TouchActionAuto) {}
TouchEvent::TouchEvent(TouchList* touches,
TouchList* targetTouches,
@@ -240,7 +241,8 @@ TouchEvent::TouchEvent(const AtomicString& type,
m_changedTouches(TouchList::create(initializer.changedTouches())),
m_causesScrollingIfUncanceled(false),
m_firstTouchMoveOrStart(false),
- m_defaultPreventedBeforeCurrentTarget(false) {}
+ m_defaultPreventedBeforeCurrentTarget(false),
+ m_currentTouchAction(TouchActionAuto) {}
TouchEvent::~TouchEvent() {}
@@ -258,14 +260,36 @@ void TouchEvent::preventDefault() {
// A common developer error is to wait too long before attempting to stop
// scrolling by consuming a touchmove event. Generate a warning if this
// event is uncancelable.
- if (!cancelable() && handlingPassive() == PassiveMode::NotPassive && view() &&
- view()->isLocalDOMWindow() && view()->frame()) {
+ String warningMessage;
+ switch (handlingPassive()) {
+ case PassiveMode::NotPassive:
+ if (!cancelable()) {
+ warningMessage = "Ignored attempt to cancel a " + type() +
+ " event with cancelable=false, for example "
+ "because scrolling is in progress and "
+ "cannot be interrupted.";
+ }
+ break;
+ case PassiveMode::PassiveForcedDocumentLevel:
+ // Only enable the warning when the current touch action is auto because
+ // an author may use touch action but call preventDefault for interop with
+ // browsers that don't support touch-action.
+ if (m_currentTouchAction == TouchActionAuto) {
+ warningMessage =
+ "Unable to preventDefault inside passive event listener due to "
+ "target being treated as passive. See "
+ "https://www.chromestatus.com/features/5093566007214080";
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (!warningMessage.isEmpty() && view() && view()->isLocalDOMWindow() &&
+ view()->frame()) {
toLocalDOMWindow(view())->frame()->console().addMessage(
ConsoleMessage::create(JSMessageSource, WarningMessageLevel,
- "Ignored attempt to cancel a " + type() +
- " event with cancelable=false, for example "
- "because scrolling is in progress and "
- "cannot be interrupted."));
+ warningMessage));
}
if ((type() == EventTypeNames::touchstart ||
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698