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

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

Issue 1156993013: New media playback UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed some tests from previous CL. Created 5 years, 5 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: Source/core/html/shadow/SliderThumbElement.cpp
diff --git a/Source/core/html/shadow/SliderThumbElement.cpp b/Source/core/html/shadow/SliderThumbElement.cpp
index 39043fdfaee819c22262c81b6e86d99c67c3ac6c..d5071c2917bd75bc3acf827c3caf371f5e8038b1 100644
--- a/Source/core/html/shadow/SliderThumbElement.cpp
+++ b/Source/core/html/shadow/SliderThumbElement.cpp
@@ -62,6 +62,7 @@ inline static bool hasVerticalAppearance(HTMLInputElement* input)
inline SliderThumbElement::SliderThumbElement(Document& document)
: HTMLDivElement(document)
, m_inDragMode(false)
+ , m_didDragAnywhere(false)
{
}
@@ -169,6 +170,10 @@ void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point)
input->setValueFromRenderer(valueString);
if (layoutObject())
layoutObject()->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::SliderValueChanged);
+
+ // We actually changed the value as part of a drag.
+ if (m_inDragMode)
+ m_didDragAnywhere = true;
}
void SliderThumbElement::startDragging()
@@ -176,6 +181,7 @@ void SliderThumbElement::startDragging()
if (LocalFrame* frame = document().frame()) {
frame->eventHandler().setCapturingMouseEventsNode(this);
m_inDragMode = true;
+ m_didDragAnywhere = false;
}
}
@@ -217,10 +223,19 @@ void SliderThumbElement::defaultEventHandler(Event* event)
// MediaControlTimelineElement::defaultEventHandler() wants to handle these
// mouse events.
if (eventType == EventTypeNames::mousedown && isLeftButton) {
+
+ m_mouseDownLocation = mouseEvent->absoluteLocation();
startDragging();
return;
} else if (eventType == EventTypeNames::mouseup && isLeftButton) {
+ if (m_inDragMode && !m_didDragAnywhere && isMediaSlider()) {
philipj_slow 2015/07/09 13:40:56 I think what I would expect is that mousedown actu
liberato (no reviews please) 2015/07/09 22:35:35 mousedown move: i considered that, but having the
philipj_slow 2015/07/09 23:18:37 You're right, <input type=range> with a mouse woul
liberato (no reviews please) 2015/07/14 22:10:36 i'll open a discussion, but i'd prefer not to conn
+ // We got a down / up with no drag in between, and we're a media
+ // slider. Jump to the touch down.
+ setPositionFromPoint(m_mouseDownLocation);
+ }
+
stopDragging();
+
return;
} else if (eventType == EventTypeNames::mousemove) {
if (m_inDragMode)
@@ -277,11 +292,11 @@ static const AtomicString& mediaSliderThumbShadowPartId()
return mediaSliderThumb;
}
-const AtomicString& SliderThumbElement::shadowPseudoId() const
+bool SliderThumbElement::isMediaSlider() const
{
HTMLInputElement* input = hostInput();
if (!input || !input->layoutObject())
- return sliderThumbShadowPartId();
+ return false;
const ComputedStyle& sliderStyle = input->layoutObject()->styleRef();
switch (sliderStyle.appearance()) {
@@ -291,12 +306,19 @@ const AtomicString& SliderThumbElement::shadowPseudoId() const
case MediaVolumeSliderThumbPart:
case MediaFullScreenVolumeSliderPart:
case MediaFullScreenVolumeSliderThumbPart:
- return mediaSliderThumbShadowPartId();
+ return true;
default:
- return sliderThumbShadowPartId();
+ return false;
}
}
+const AtomicString& SliderThumbElement::shadowPseudoId() const
+{
+ if (isMediaSlider())
+ return mediaSliderThumbShadowPartId();
+ return sliderThumbShadowPartId();
+}
+
// --------------------------------
inline SliderContainerElement::SliderContainerElement(Document& document)

Powered by Google App Engine
This is Rietveld 408576698