Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 16 matching lines...) Expand all Loading... | |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 | 32 |
| 33 #include "config.h" | 33 #include "config.h" |
| 34 #include "core/html/shadow/SliderThumbElement.h" | 34 #include "core/html/shadow/SliderThumbElement.h" |
| 35 | 35 |
| 36 #include "core/events/Event.h" | 36 #include "core/events/Event.h" |
| 37 #include "core/events/KeyboardEvent.h" | |
| 37 #include "core/events/MouseEvent.h" | 38 #include "core/events/MouseEvent.h" |
| 38 #include "core/dom/shadow/ShadowRoot.h" | 39 #include "core/dom/shadow/ShadowRoot.h" |
| 39 #include "core/html/HTMLInputElement.h" | 40 #include "core/html/HTMLInputElement.h" |
| 40 #include "core/html/forms/StepRange.h" | 41 #include "core/html/forms/StepRange.h" |
| 41 #include "core/html/parser/HTMLParserIdioms.h" | 42 #include "core/html/parser/HTMLParserIdioms.h" |
| 42 #include "core/html/shadow/ShadowElementNames.h" | 43 #include "core/html/shadow/ShadowElementNames.h" |
| 43 #include "core/page/EventHandler.h" | 44 #include "core/page/EventHandler.h" |
| 44 #include "core/frame/Frame.h" | 45 #include "core/frame/Frame.h" |
| 45 #include "core/rendering/RenderFlexibleBox.h" | 46 #include "core/rendering/RenderFlexibleBox.h" |
| 46 #include "core/rendering/RenderSlider.h" | 47 #include "core/rendering/RenderSlider.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 } | 299 } |
| 299 | 300 |
| 300 String valueString = serializeForNumberType(value); | 301 String valueString = serializeForNumberType(value); |
| 301 if (valueString == input->value()) | 302 if (valueString == input->value()) |
| 302 return; | 303 return; |
| 303 | 304 |
| 304 // FIXME: This is no longer being set from renderer. Consider updating the m ethod name. | 305 // FIXME: This is no longer being set from renderer. Consider updating the m ethod name. |
| 305 input->setValueFromRenderer(valueString); | 306 input->setValueFromRenderer(valueString); |
| 306 if (renderer()) | 307 if (renderer()) |
| 307 renderer()->setNeedsLayout(); | 308 renderer()->setNeedsLayout(); |
| 308 input->dispatchFormControlChangeEvent(); | |
| 309 } | 309 } |
| 310 | 310 |
| 311 void SliderThumbElement::startDragging() | 311 void SliderThumbElement::startDragging() |
| 312 { | 312 { |
| 313 if (Frame* frame = document().frame()) { | 313 if (Frame* frame = document().frame()) { |
| 314 frame->eventHandler().setCapturingMouseEventsNode(this); | 314 frame->eventHandler().setCapturingMouseEventsNode(this); |
| 315 m_inDragMode = true; | 315 m_inDragMode = true; |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 void SliderThumbElement::stopDragging() | 319 void SliderThumbElement::stopDragging() |
| 320 { | 320 { |
| 321 if (!m_inDragMode) | 321 if (!m_inDragMode) |
| 322 return; | 322 return; |
| 323 | 323 |
| 324 if (Frame* frame = document().frame()) | 324 if (Frame* frame = document().frame()) |
| 325 frame->eventHandler().setCapturingMouseEventsNode(0); | 325 frame->eventHandler().setCapturingMouseEventsNode(0); |
| 326 m_inDragMode = false; | 326 m_inDragMode = false; |
| 327 if (renderer()) | 327 if (renderer()) |
| 328 renderer()->setNeedsLayout(); | 328 renderer()->setNeedsLayout(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 void SliderThumbElement::defaultEventHandler(Event* event) | 331 void SliderThumbElement::defaultEventHandler(Event* event) |
| 332 { | 332 { |
| 333 HTMLInputElement* input = hostInput(); | |
| 334 if (event->isKeyboardEvent()) { | |
| 335 input->dispatchFormControlChangeEvent(); | |
|
tkent
2014/01/14 01:00:51
I don't think this is necessary. RangeInputType::h
Habib Virji
2014/01/14 10:23:42
Done.
| |
| 336 } | |
| 337 | |
| 333 if (!event->isMouseEvent()) { | 338 if (!event->isMouseEvent()) { |
| 334 HTMLDivElement::defaultEventHandler(event); | 339 HTMLDivElement::defaultEventHandler(event); |
| 335 return; | 340 return; |
| 336 } | 341 } |
| 337 | 342 |
| 338 // FIXME: Should handle this readonly/disabled check in more general way. | 343 // FIXME: Should handle this readonly/disabled check in more general way. |
| 339 // Missing this kind of check is likely to occur elsewhere if adding it in e ach shadow element. | 344 // Missing this kind of check is likely to occur elsewhere if adding it in e ach shadow element. |
| 340 HTMLInputElement* input = hostInput(); | |
| 341 if (!input || input->isDisabledOrReadOnly()) { | 345 if (!input || input->isDisabledOrReadOnly()) { |
| 342 stopDragging(); | 346 stopDragging(); |
| 343 HTMLDivElement::defaultEventHandler(event); | 347 HTMLDivElement::defaultEventHandler(event); |
| 344 return; | 348 return; |
| 345 } | 349 } |
| 346 | 350 |
| 347 MouseEvent* mouseEvent = toMouseEvent(event); | 351 MouseEvent* mouseEvent = toMouseEvent(event); |
| 348 bool isLeftButton = mouseEvent->button() == LeftButton; | 352 bool isLeftButton = mouseEvent->button() == LeftButton; |
| 349 const AtomicString& eventType = event->type(); | 353 const AtomicString& eventType = event->type(); |
| 350 | 354 |
| 351 // We intentionally do not call event->setDefaultHandled() here because | 355 // We intentionally do not call event->setDefaultHandled() here because |
| 352 // MediaControlTimelineElement::defaultEventHandler() wants to handle these | 356 // MediaControlTimelineElement::defaultEventHandler() wants to handle these |
| 353 // mouse events. | 357 // mouse events. |
| 354 if (eventType == EventTypeNames::mousedown && isLeftButton) { | 358 if (eventType == EventTypeNames::mousedown && isLeftButton) { |
| 355 startDragging(); | 359 startDragging(); |
| 356 return; | 360 return; |
| 357 } else if (eventType == EventTypeNames::mouseup && isLeftButton) { | 361 } else if (eventType == EventTypeNames::mouseup && isLeftButton) { |
| 362 input->dispatchFormControlChangeEvent(); | |
|
tkent
2014/01/14 01:00:51
This should be *in* stopDragging() because we need
Habib Virji
2014/01/14 10:23:42
Done. Moved dispatchFormControlChangeEvent to stop
| |
| 358 stopDragging(); | 363 stopDragging(); |
| 359 return; | 364 return; |
| 360 } else if (eventType == EventTypeNames::mousemove) { | 365 } else if (eventType == EventTypeNames::mousemove) { |
| 361 if (m_inDragMode) | 366 if (m_inDragMode) |
| 362 setPositionFromPoint(mouseEvent->absoluteLocation()); | 367 setPositionFromPoint(mouseEvent->absoluteLocation()); |
| 363 return; | 368 return; |
| 364 } | 369 } |
| 365 | 370 |
| 366 HTMLDivElement::defaultEventHandler(event); | 371 HTMLDivElement::defaultEventHandler(event); |
| 367 } | 372 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 case MediaVolumeSliderThumbPart: | 470 case MediaVolumeSliderThumbPart: |
| 466 case MediaFullScreenVolumeSliderPart: | 471 case MediaFullScreenVolumeSliderPart: |
| 467 case MediaFullScreenVolumeSliderThumbPart: | 472 case MediaFullScreenVolumeSliderThumbPart: |
| 468 return mediaSliderContainer; | 473 return mediaSliderContainer; |
| 469 default: | 474 default: |
| 470 return sliderContainer; | 475 return sliderContainer; |
| 471 } | 476 } |
| 472 } | 477 } |
| 473 | 478 |
| 474 } | 479 } |
| OLD | NEW |