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

Unified Diff: third_party/WebKit/Source/core/html/shadow/SliderThumbElement.cpp

Issue 2209773002: Remove the blocking touch handlers for the input[type=range] and add touch-action instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move the touch event handlers to the container in the shadow dom Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/shadow/SliderThumbElement.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/SliderThumbElement.cpp b/third_party/WebKit/Source/core/html/shadow/SliderThumbElement.cpp
index 8d9d3f157686106527291c1d3c1f15c6a4c3c210..93c892b9c3fe8c41f824cea7cc1395555968a926 100644
--- a/third_party/WebKit/Source/core/html/shadow/SliderThumbElement.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/SliderThumbElement.cpp
@@ -31,9 +31,10 @@
#include "core/html/shadow/SliderThumbElement.h"
+#include "core/dom/shadow/ShadowRoot.h"
#include "core/events/Event.h"
#include "core/events/MouseEvent.h"
-#include "core/dom/shadow/ShadowRoot.h"
+#include "core/events/TouchEvent.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/forms/StepRange.h"
@@ -307,6 +308,33 @@ LayoutObject* SliderContainerElement::createLayoutObject(const ComputedStyle&)
return new LayoutSliderContainer(this);
}
+void SliderContainerElement::defaultEventHandler(Event* event)
+{
+ if (event->isTouchEvent()) {
+ handleTouchEvent(toTouchEvent(event));
+ return;
+ }
+}
+
+void SliderContainerElement::handleTouchEvent(TouchEvent* event)
+{
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost());
majidvp 2016/08/12 03:35:43 s/static_cast<HTMLInputElement*>/toHTMLInputElemen
+ if (input->isDisabledOrReadOnly())
+ return;
+
+ if (event->type() == EventTypeNames::touchend) {
+ input->dispatchFormControlChangeEvent();
+ event->setDefaultHandled();
+ return;
+ }
+
+ TouchList* touches = event->targetTouches();
+ SliderThumbElement* thumb = toSliderThumbElement(input->userAgentShadowRoot()->getElementById(ShadowElementNames::sliderThumb()));
+ if (touches->length() == 1) {
+ thumb->setPositionFromPoint(touches->item(0)->absoluteLocation());
+ }
+}
+
const AtomicString& SliderContainerElement::shadowPseudoId() const
{
DEFINE_STATIC_LOCAL(const AtomicString, mediaSliderContainer, ("-webkit-media-slider-container"));

Powered by Google App Engine
This is Rietveld 408576698