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 13 matching lines...) Expand all Loading... | |
| 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 #include "core/html/shadow/SliderThumbElement.h" | 32 #include "core/html/shadow/SliderThumbElement.h" |
| 33 | 33 |
| 34 #include "core/dom/shadow/ShadowRoot.h" | |
| 34 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
| 35 #include "core/events/MouseEvent.h" | 36 #include "core/events/MouseEvent.h" |
| 36 #include "core/dom/shadow/ShadowRoot.h" | 37 #include "core/events/TouchEvent.h" |
| 37 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
| 38 #include "core/html/HTMLInputElement.h" | 39 #include "core/html/HTMLInputElement.h" |
| 39 #include "core/html/forms/StepRange.h" | 40 #include "core/html/forms/StepRange.h" |
| 40 #include "core/html/parser/HTMLParserIdioms.h" | 41 #include "core/html/parser/HTMLParserIdioms.h" |
| 41 #include "core/html/shadow/ShadowElementNames.h" | 42 #include "core/html/shadow/ShadowElementNames.h" |
| 42 #include "core/input/EventHandler.h" | 43 #include "core/input/EventHandler.h" |
| 43 #include "core/layout/LayoutSliderContainer.h" | 44 #include "core/layout/LayoutSliderContainer.h" |
| 44 #include "core/layout/LayoutSliderThumb.h" | 45 #include "core/layout/LayoutSliderThumb.h" |
| 45 #include "core/layout/LayoutTheme.h" | 46 #include "core/layout/LayoutTheme.h" |
| 46 | 47 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 { | 301 { |
| 301 } | 302 } |
| 302 | 303 |
| 303 DEFINE_NODE_FACTORY(SliderContainerElement) | 304 DEFINE_NODE_FACTORY(SliderContainerElement) |
| 304 | 305 |
| 305 LayoutObject* SliderContainerElement::createLayoutObject(const ComputedStyle&) | 306 LayoutObject* SliderContainerElement::createLayoutObject(const ComputedStyle&) |
| 306 { | 307 { |
| 307 return new LayoutSliderContainer(this); | 308 return new LayoutSliderContainer(this); |
| 308 } | 309 } |
| 309 | 310 |
| 311 void SliderContainerElement::defaultEventHandler(Event* event) | |
| 312 { | |
| 313 if (event->isTouchEvent()) { | |
| 314 handleTouchEvent(toTouchEvent(event)); | |
| 315 return; | |
| 316 } | |
| 317 } | |
| 318 | |
| 319 void SliderContainerElement::handleTouchEvent(TouchEvent* event) | |
| 320 { | |
| 321 HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowHost()); | |
|
majidvp
2016/08/12 03:35:43
s/static_cast<HTMLInputElement*>/toHTMLInputElemen
| |
| 322 if (input->isDisabledOrReadOnly()) | |
| 323 return; | |
| 324 | |
| 325 if (event->type() == EventTypeNames::touchend) { | |
| 326 input->dispatchFormControlChangeEvent(); | |
| 327 event->setDefaultHandled(); | |
| 328 return; | |
| 329 } | |
| 330 | |
| 331 TouchList* touches = event->targetTouches(); | |
| 332 SliderThumbElement* thumb = toSliderThumbElement(input->userAgentShadowRoot( )->getElementById(ShadowElementNames::sliderThumb())); | |
| 333 if (touches->length() == 1) { | |
| 334 thumb->setPositionFromPoint(touches->item(0)->absoluteLocation()); | |
| 335 } | |
| 336 } | |
| 337 | |
| 310 const AtomicString& SliderContainerElement::shadowPseudoId() const | 338 const AtomicString& SliderContainerElement::shadowPseudoId() const |
| 311 { | 339 { |
| 312 DEFINE_STATIC_LOCAL(const AtomicString, mediaSliderContainer, ("-webkit-medi a-slider-container")); | 340 DEFINE_STATIC_LOCAL(const AtomicString, mediaSliderContainer, ("-webkit-medi a-slider-container")); |
| 313 DEFINE_STATIC_LOCAL(const AtomicString, sliderContainer, ("-webkit-slider-co ntainer")); | 341 DEFINE_STATIC_LOCAL(const AtomicString, sliderContainer, ("-webkit-slider-co ntainer")); |
| 314 | 342 |
| 315 if (!shadowHost() || !shadowHost()->layoutObject()) | 343 if (!shadowHost() || !shadowHost()->layoutObject()) |
| 316 return sliderContainer; | 344 return sliderContainer; |
| 317 | 345 |
| 318 const ComputedStyle& sliderStyle = shadowHost()->layoutObject()->styleRef(); | 346 const ComputedStyle& sliderStyle = shadowHost()->layoutObject()->styleRef(); |
| 319 switch (sliderStyle.appearance()) { | 347 switch (sliderStyle.appearance()) { |
| 320 case MediaSliderPart: | 348 case MediaSliderPart: |
| 321 case MediaSliderThumbPart: | 349 case MediaSliderThumbPart: |
| 322 case MediaVolumeSliderPart: | 350 case MediaVolumeSliderPart: |
| 323 case MediaVolumeSliderThumbPart: | 351 case MediaVolumeSliderThumbPart: |
| 324 case MediaFullScreenVolumeSliderPart: | 352 case MediaFullScreenVolumeSliderPart: |
| 325 case MediaFullScreenVolumeSliderThumbPart: | 353 case MediaFullScreenVolumeSliderThumbPart: |
| 326 return mediaSliderContainer; | 354 return mediaSliderContainer; |
| 327 default: | 355 default: |
| 328 return sliderContainer; | 356 return sliderContainer; |
| 329 } | 357 } |
| 330 } | 358 } |
| 331 | 359 |
| 332 } // namespace blink | 360 } // namespace blink |
| OLD | NEW |