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

Side by Side 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: minor decrufting. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. 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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 { 55 {
56 ASSERT(input->layoutObject()); 56 ASSERT(input->layoutObject());
57 const ComputedStyle& sliderStyle = input->layoutObject()->styleRef(); 57 const ComputedStyle& sliderStyle = input->layoutObject()->styleRef();
58 58
59 return sliderStyle.appearance() == SliderVerticalPart; 59 return sliderStyle.appearance() == SliderVerticalPart;
60 } 60 }
61 61
62 inline SliderThumbElement::SliderThumbElement(Document& document) 62 inline SliderThumbElement::SliderThumbElement(Document& document)
63 : HTMLDivElement(document) 63 : HTMLDivElement(document)
64 , m_inDragMode(false) 64 , m_inDragMode(false)
65 , m_didDragAnywhere(false)
65 { 66 {
66 } 67 }
67 68
68 PassRefPtrWillBeRawPtr<SliderThumbElement> SliderThumbElement::create(Document& document) 69 PassRefPtrWillBeRawPtr<SliderThumbElement> SliderThumbElement::create(Document& document)
69 { 70 {
70 RefPtrWillBeRawPtr<SliderThumbElement> element = adoptRefWillBeNoop(new Slid erThumbElement(document)); 71 RefPtrWillBeRawPtr<SliderThumbElement> element = adoptRefWillBeNoop(new Slid erThumbElement(document));
71 element->setAttribute(idAttr, ShadowElementNames::sliderThumb()); 72 element->setAttribute(idAttr, ShadowElementNames::sliderThumb());
72 return element.release(); 73 return element.release();
73 } 74 }
74 75
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 163 }
163 164
164 String valueString = serializeForNumberType(value); 165 String valueString = serializeForNumberType(value);
165 if (valueString == input->value()) 166 if (valueString == input->value())
166 return; 167 return;
167 168
168 // FIXME: This is no longer being set from renderer. Consider updating the m ethod name. 169 // FIXME: This is no longer being set from renderer. Consider updating the m ethod name.
169 input->setValueFromRenderer(valueString); 170 input->setValueFromRenderer(valueString);
170 if (layoutObject()) 171 if (layoutObject())
171 layoutObject()->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidatio nReason::SliderValueChanged); 172 layoutObject()->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidatio nReason::SliderValueChanged);
173
174 // We actually changed the value as part of a drag.
175 if (m_inDragMode)
176 m_didDragAnywhere = true;
172 } 177 }
173 178
174 void SliderThumbElement::startDragging() 179 void SliderThumbElement::startDragging()
175 { 180 {
176 if (LocalFrame* frame = document().frame()) { 181 if (LocalFrame* frame = document().frame()) {
177 frame->eventHandler().setCapturingMouseEventsNode(this); 182 frame->eventHandler().setCapturingMouseEventsNode(this);
178 m_inDragMode = true; 183 m_inDragMode = true;
184 m_didDragAnywhere = false;
179 } 185 }
180 } 186 }
181 187
182 void SliderThumbElement::stopDragging() 188 void SliderThumbElement::stopDragging()
183 { 189 {
184 if (!m_inDragMode) 190 if (!m_inDragMode)
185 return; 191 return;
186 192
187 if (LocalFrame* frame = document().frame()) 193 if (LocalFrame* frame = document().frame())
188 frame->eventHandler().setCapturingMouseEventsNode(nullptr); 194 frame->eventHandler().setCapturingMouseEventsNode(nullptr);
(...skipping 21 matching lines...) Expand all
210 } 216 }
211 217
212 MouseEvent* mouseEvent = toMouseEvent(event); 218 MouseEvent* mouseEvent = toMouseEvent(event);
213 bool isLeftButton = mouseEvent->button() == LeftButton; 219 bool isLeftButton = mouseEvent->button() == LeftButton;
214 const AtomicString& eventType = event->type(); 220 const AtomicString& eventType = event->type();
215 221
216 // We intentionally do not call event->setDefaultHandled() here because 222 // We intentionally do not call event->setDefaultHandled() here because
217 // MediaControlTimelineElement::defaultEventHandler() wants to handle these 223 // MediaControlTimelineElement::defaultEventHandler() wants to handle these
218 // mouse events. 224 // mouse events.
219 if (eventType == EventTypeNames::mousedown && isLeftButton) { 225 if (eventType == EventTypeNames::mousedown && isLeftButton) {
226
227 m_mouseDownLocation = mouseEvent->absoluteLocation();
220 startDragging(); 228 startDragging();
221 return; 229 return;
222 } else if (eventType == EventTypeNames::mouseup && isLeftButton) { 230 } else if (eventType == EventTypeNames::mouseup && isLeftButton) {
231 if (m_inDragMode && !m_didDragAnywhere && isMediaSlider()) {
232 // We got a down / up with no drag in between, and we're a media
philipj_slow 2015/07/21 12:02:21 I don't think this is quite right. When you click
liberato (no reviews please) 2015/07/27 20:26:09 i agree in principle, but i don't have enough expe
philipj_slow 2015/07/28 15:23:49 It definitely is possible that the change will res
liberato (no reviews please) 2015/07/30 05:54:23 i've reverted all of this, since we're now shippin
233 // slider. Jump to the touch down.
234 setPositionFromPoint(m_mouseDownLocation);
235 }
236
223 stopDragging(); 237 stopDragging();
238
224 return; 239 return;
225 } else if (eventType == EventTypeNames::mousemove) { 240 } else if (eventType == EventTypeNames::mousemove) {
226 if (m_inDragMode) 241 if (m_inDragMode)
227 setPositionFromPoint(mouseEvent->absoluteLocation()); 242 setPositionFromPoint(mouseEvent->absoluteLocation());
228 return; 243 return;
229 } 244 }
230 245
231 HTMLDivElement::defaultEventHandler(event); 246 HTMLDivElement::defaultEventHandler(event);
232 } 247 }
233 248
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 DEFINE_STATIC_LOCAL(const AtomicString, sliderThumb, ("-webkit-slider-thumb" , AtomicString::ConstructFromLiteral)); 285 DEFINE_STATIC_LOCAL(const AtomicString, sliderThumb, ("-webkit-slider-thumb" , AtomicString::ConstructFromLiteral));
271 return sliderThumb; 286 return sliderThumb;
272 } 287 }
273 288
274 static const AtomicString& mediaSliderThumbShadowPartId() 289 static const AtomicString& mediaSliderThumbShadowPartId()
275 { 290 {
276 DEFINE_STATIC_LOCAL(const AtomicString, mediaSliderThumb, ("-webkit-media-sl ider-thumb", AtomicString::ConstructFromLiteral)); 291 DEFINE_STATIC_LOCAL(const AtomicString, mediaSliderThumb, ("-webkit-media-sl ider-thumb", AtomicString::ConstructFromLiteral));
277 return mediaSliderThumb; 292 return mediaSliderThumb;
278 } 293 }
279 294
280 const AtomicString& SliderThumbElement::shadowPseudoId() const 295 bool SliderThumbElement::isMediaSlider() const
281 { 296 {
282 HTMLInputElement* input = hostInput(); 297 HTMLInputElement* input = hostInput();
283 if (!input || !input->layoutObject()) 298 if (!input || !input->layoutObject())
284 return sliderThumbShadowPartId(); 299 return false;
285 300
286 const ComputedStyle& sliderStyle = input->layoutObject()->styleRef(); 301 const ComputedStyle& sliderStyle = input->layoutObject()->styleRef();
287 switch (sliderStyle.appearance()) { 302 switch (sliderStyle.appearance()) {
288 case MediaSliderPart: 303 case MediaSliderPart:
289 case MediaSliderThumbPart: 304 case MediaSliderThumbPart:
290 case MediaVolumeSliderPart: 305 case MediaVolumeSliderPart:
291 case MediaVolumeSliderThumbPart: 306 case MediaVolumeSliderThumbPart:
292 case MediaFullScreenVolumeSliderPart: 307 case MediaFullScreenVolumeSliderPart:
293 case MediaFullScreenVolumeSliderThumbPart: 308 case MediaFullScreenVolumeSliderThumbPart:
309 return true;
310 default:
311 return false;
312 }
313 }
314
315 const AtomicString& SliderThumbElement::shadowPseudoId() const
316 {
317 if (isMediaSlider())
294 return mediaSliderThumbShadowPartId(); 318 return mediaSliderThumbShadowPartId();
295 default: 319 return sliderThumbShadowPartId();
296 return sliderThumbShadowPartId();
297 }
298 } 320 }
299 321
300 // -------------------------------- 322 // --------------------------------
301 323
302 inline SliderContainerElement::SliderContainerElement(Document& document) 324 inline SliderContainerElement::SliderContainerElement(Document& document)
303 : HTMLDivElement(document) 325 : HTMLDivElement(document)
304 { 326 {
305 } 327 }
306 328
307 DEFINE_NODE_FACTORY(SliderContainerElement) 329 DEFINE_NODE_FACTORY(SliderContainerElement)
(...skipping 19 matching lines...) Expand all
327 case MediaVolumeSliderThumbPart: 349 case MediaVolumeSliderThumbPart:
328 case MediaFullScreenVolumeSliderPart: 350 case MediaFullScreenVolumeSliderPart:
329 case MediaFullScreenVolumeSliderThumbPart: 351 case MediaFullScreenVolumeSliderThumbPart:
330 return mediaSliderContainer; 352 return mediaSliderContainer;
331 default: 353 default:
332 return sliderContainer; 354 return sliderContainer;
333 } 355 }
334 } 356 }
335 357
336 } 358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698