| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 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 | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 { | 230 { |
| 231 RefPtr<MediaControlPlayButtonElement> button = adoptRef(new MediaControlPlay
ButtonElement(mediaControls)); | 231 RefPtr<MediaControlPlayButtonElement> button = adoptRef(new MediaControlPlay
ButtonElement(mediaControls)); |
| 232 button->ensureUserAgentShadowRoot(); | 232 button->ensureUserAgentShadowRoot(); |
| 233 button->setType("button"); | 233 button->setType("button"); |
| 234 return button.release(); | 234 return button.release(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void MediaControlPlayButtonElement::defaultEventHandler(Event* event) | 237 void MediaControlPlayButtonElement::defaultEventHandler(Event* event) |
| 238 { | 238 { |
| 239 if (event->type() == EventTypeNames::click) { | 239 if (event->type() == EventTypeNames::click) { |
| 240 if (mediaControllerInterface().canPlay()) | 240 mediaElement().togglePlayState(); |
| 241 mediaControllerInterface().play(); | |
| 242 else | |
| 243 mediaControllerInterface().pause(); | |
| 244 updateDisplayType(); | 241 updateDisplayType(); |
| 245 event->setDefaultHandled(); | 242 event->setDefaultHandled(); |
| 246 } | 243 } |
| 247 HTMLInputElement::defaultEventHandler(event); | 244 HTMLInputElement::defaultEventHandler(event); |
| 248 } | 245 } |
| 249 | 246 |
| 250 void MediaControlPlayButtonElement::updateDisplayType() | 247 void MediaControlPlayButtonElement::updateDisplayType() |
| 251 { | 248 { |
| 252 setDisplayType(mediaControllerInterface().canPlay() ? MediaPlayButton : Medi
aPauseButton); | 249 setDisplayType(mediaElement().togglePlayStateWillPlay() ? MediaPlayButton :
MediaPauseButton); |
| 253 } | 250 } |
| 254 | 251 |
| 255 const AtomicString& MediaControlPlayButtonElement::shadowPseudoId() const | 252 const AtomicString& MediaControlPlayButtonElement::shadowPseudoId() const |
| 256 { | 253 { |
| 257 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-play-button",
AtomicString::ConstructFromLiteral)); | 254 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-play-button",
AtomicString::ConstructFromLiteral)); |
| 258 return id; | 255 return id; |
| 259 } | 256 } |
| 260 | 257 |
| 261 // ---------------------------- | 258 // ---------------------------- |
| 262 | 259 |
| 263 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Media
Controls& mediaControls) | 260 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Media
Controls& mediaControls) |
| 264 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton) | 261 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton) |
| 265 { | 262 { |
| 266 } | 263 } |
| 267 | 264 |
| 268 PassRefPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlayPlayButtonEl
ement::create(MediaControls& mediaControls) | 265 PassRefPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlayPlayButtonEl
ement::create(MediaControls& mediaControls) |
| 269 { | 266 { |
| 270 RefPtr<MediaControlOverlayPlayButtonElement> button = adoptRef(new MediaCont
rolOverlayPlayButtonElement(mediaControls)); | 267 RefPtr<MediaControlOverlayPlayButtonElement> button = adoptRef(new MediaCont
rolOverlayPlayButtonElement(mediaControls)); |
| 271 button->ensureUserAgentShadowRoot(); | 268 button->ensureUserAgentShadowRoot(); |
| 272 button->setType("button"); | 269 button->setType("button"); |
| 273 return button.release(); | 270 return button.release(); |
| 274 } | 271 } |
| 275 | 272 |
| 276 void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event) | 273 void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event) |
| 277 { | 274 { |
| 278 if (event->type() == EventTypeNames::click && mediaControllerInterface().can
Play()) { | 275 if (event->type() == EventTypeNames::click && mediaElement().togglePlayState
WillPlay()) { |
| 279 mediaControllerInterface().play(); | 276 mediaElement().togglePlayState(); |
| 280 updateDisplayType(); | 277 updateDisplayType(); |
| 281 event->setDefaultHandled(); | 278 event->setDefaultHandled(); |
| 282 } | 279 } |
| 283 HTMLInputElement::defaultEventHandler(event); | 280 HTMLInputElement::defaultEventHandler(event); |
| 284 } | 281 } |
| 285 | 282 |
| 286 void MediaControlOverlayPlayButtonElement::updateDisplayType() | 283 void MediaControlOverlayPlayButtonElement::updateDisplayType() |
| 287 { | 284 { |
| 288 if (mediaControllerInterface().canPlay()) { | 285 if (mediaElement().togglePlayStateWillPlay()) { |
| 289 show(); | 286 show(); |
| 290 } else | 287 } else |
| 291 hide(); | 288 hide(); |
| 292 } | 289 } |
| 293 | 290 |
| 294 const AtomicString& MediaControlOverlayPlayButtonElement::shadowPseudoId() const | 291 const AtomicString& MediaControlOverlayPlayButtonElement::shadowPseudoId() const |
| 295 { | 292 { |
| 296 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-overlay-play-
button", AtomicString::ConstructFromLiteral)); | 293 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-overlay-play-
button", AtomicString::ConstructFromLiteral)); |
| 297 return id; | 294 return id; |
| 298 } | 295 } |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 float fontSize = smallestDimension * 0.05f; | 669 float fontSize = smallestDimension * 0.05f; |
| 673 if (fontSize != m_fontSize) { | 670 if (fontSize != m_fontSize) { |
| 674 m_fontSize = fontSize; | 671 m_fontSize = fontSize; |
| 675 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue:
:CSS_PX); | 672 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue:
:CSS_PX); |
| 676 } | 673 } |
| 677 } | 674 } |
| 678 | 675 |
| 679 // ---------------------------- | 676 // ---------------------------- |
| 680 | 677 |
| 681 } // namespace WebCore | 678 } // namespace WebCore |
| OLD | NEW |