| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (is_displayed_ && opaque_) | 234 if (is_displayed_ && opaque_) |
| 235 DidBecomeVisible(); | 235 DidBecomeVisible(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 bool MediaControlPanelElement::KeepEventInNode(Event* event) { | 238 bool MediaControlPanelElement::KeepEventInNode(Event* event) { |
| 239 return IsUserInteractionEvent(event); | 239 return IsUserInteractionEvent(event); |
| 240 } | 240 } |
| 241 | 241 |
| 242 // ---------------------------- | 242 // ---------------------------- |
| 243 | 243 |
| 244 MediaControlPanelEnclosureElement::MediaControlPanelEnclosureElement( | |
| 245 MediaControls& media_controls) | |
| 246 // Mapping onto same MediaControlElementType as panel element, since it has | |
| 247 // similar properties. | |
| 248 : MediaControlDivElement(media_controls, kMediaControlsPanel) {} | |
| 249 | |
| 250 MediaControlPanelEnclosureElement* MediaControlPanelEnclosureElement::Create( | |
| 251 MediaControls& media_controls) { | |
| 252 MediaControlPanelEnclosureElement* enclosure = | |
| 253 new MediaControlPanelEnclosureElement(media_controls); | |
| 254 enclosure->SetShadowPseudoId( | |
| 255 AtomicString("-webkit-media-controls-enclosure")); | |
| 256 return enclosure; | |
| 257 } | |
| 258 | |
| 259 // ---------------------------- | |
| 260 | |
| 261 MediaControlOverlayEnclosureElement::MediaControlOverlayEnclosureElement( | |
| 262 MediaControls& media_controls) | |
| 263 // Mapping onto same MediaControlElementType as panel element, since it has | |
| 264 // similar properties. | |
| 265 : MediaControlDivElement(media_controls, kMediaControlsPanel) {} | |
| 266 | |
| 267 MediaControlOverlayEnclosureElement* | |
| 268 MediaControlOverlayEnclosureElement::Create(MediaControls& media_controls) { | |
| 269 MediaControlOverlayEnclosureElement* enclosure = | |
| 270 new MediaControlOverlayEnclosureElement(media_controls); | |
| 271 enclosure->SetShadowPseudoId( | |
| 272 AtomicString("-webkit-media-controls-overlay-enclosure")); | |
| 273 return enclosure; | |
| 274 } | |
| 275 | |
| 276 EventDispatchHandlingState* | |
| 277 MediaControlOverlayEnclosureElement::PreDispatchEventHandler(Event* event) { | |
| 278 // When the media element is clicked or touched we want to make the overlay | |
| 279 // cast button visible (if the other requirements are right) even if | |
| 280 // JavaScript is doing its own handling of the event. Doing it in | |
| 281 // preDispatchEventHandler prevents any interference from JavaScript. | |
| 282 // Note that we can't simply test for click, since JS handling of touch events | |
| 283 // can prevent their translation to click events. | |
| 284 if (event && (event->type() == EventTypeNames::click || | |
| 285 event->type() == EventTypeNames::touchstart)) | |
| 286 GetMediaControls().ShowOverlayCastButtonIfNeeded(); | |
| 287 return MediaControlDivElement::PreDispatchEventHandler(event); | |
| 288 } | |
| 289 | |
| 290 // ---------------------------- | |
| 291 | |
| 292 MediaControlMuteButtonElement::MediaControlMuteButtonElement( | |
| 293 MediaControls& media_controls) | |
| 294 : MediaControlInputElement(media_controls, kMediaMuteButton) {} | |
| 295 | |
| 296 MediaControlMuteButtonElement* MediaControlMuteButtonElement::Create( | |
| 297 MediaControls& media_controls) { | |
| 298 MediaControlMuteButtonElement* button = | |
| 299 new MediaControlMuteButtonElement(media_controls); | |
| 300 button->EnsureUserAgentShadowRoot(); | |
| 301 button->setType(InputTypeNames::button); | |
| 302 button->SetShadowPseudoId(AtomicString("-webkit-media-controls-mute-button")); | |
| 303 return button; | |
| 304 } | |
| 305 | |
| 306 void MediaControlMuteButtonElement::DefaultEventHandler(Event* event) { | |
| 307 if (event->type() == EventTypeNames::click) { | |
| 308 if (MediaElement().muted()) | |
| 309 Platform::Current()->RecordAction( | |
| 310 UserMetricsAction("Media.Controls.Unmute")); | |
| 311 else | |
| 312 Platform::Current()->RecordAction( | |
| 313 UserMetricsAction("Media.Controls.Mute")); | |
| 314 | |
| 315 MediaElement().setMuted(!MediaElement().muted()); | |
| 316 event->SetDefaultHandled(); | |
| 317 } | |
| 318 | |
| 319 MediaControlInputElement::DefaultEventHandler(event); | |
| 320 } | |
| 321 | |
| 322 void MediaControlMuteButtonElement::UpdateDisplayType() { | |
| 323 // TODO(mlamouri): checking for volume == 0 because the mute button will look | |
| 324 // 'muted' when the volume is 0 even if the element is not muted. This allows | |
| 325 // the painting and the display type to actually match. | |
| 326 SetDisplayType((MediaElement().muted() || MediaElement().volume() == 0) | |
| 327 ? kMediaUnMuteButton | |
| 328 : kMediaMuteButton); | |
| 329 UpdateOverflowString(); | |
| 330 } | |
| 331 | |
| 332 WebLocalizedString::Name | |
| 333 MediaControlMuteButtonElement::GetOverflowStringName() { | |
| 334 if (MediaElement().muted()) | |
| 335 return WebLocalizedString::kOverflowMenuUnmute; | |
| 336 return WebLocalizedString::kOverflowMenuMute; | |
| 337 } | |
| 338 | |
| 339 // ---------------------------- | |
| 340 | |
| 341 MediaControlPlayButtonElement::MediaControlPlayButtonElement( | 244 MediaControlPlayButtonElement::MediaControlPlayButtonElement( |
| 342 MediaControls& media_controls) | 245 MediaControls& media_controls) |
| 343 : MediaControlInputElement(media_controls, kMediaPlayButton) {} | 246 : MediaControlInputElement(media_controls, kMediaPlayButton) {} |
| 344 | 247 |
| 345 MediaControlPlayButtonElement* MediaControlPlayButtonElement::Create( | 248 MediaControlPlayButtonElement* MediaControlPlayButtonElement::Create( |
| 346 MediaControls& media_controls) { | 249 MediaControls& media_controls) { |
| 347 MediaControlPlayButtonElement* button = | 250 MediaControlPlayButtonElement* button = |
| 348 new MediaControlPlayButtonElement(media_controls); | 251 new MediaControlPlayButtonElement(media_controls); |
| 349 button->EnsureUserAgentShadowRoot(); | 252 button->EnsureUserAgentShadowRoot(); |
| 350 button->setType(InputTypeNames::button); | 253 button->setType(InputTypeNames::button); |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 MediaControlCurrentTimeDisplayElement* | 1059 MediaControlCurrentTimeDisplayElement* |
| 1157 MediaControlCurrentTimeDisplayElement::Create(MediaControls& media_controls) { | 1060 MediaControlCurrentTimeDisplayElement::Create(MediaControls& media_controls) { |
| 1158 MediaControlCurrentTimeDisplayElement* element = | 1061 MediaControlCurrentTimeDisplayElement* element = |
| 1159 new MediaControlCurrentTimeDisplayElement(media_controls); | 1062 new MediaControlCurrentTimeDisplayElement(media_controls); |
| 1160 element->SetShadowPseudoId( | 1063 element->SetShadowPseudoId( |
| 1161 AtomicString("-webkit-media-controls-current-time-display")); | 1064 AtomicString("-webkit-media-controls-current-time-display")); |
| 1162 return element; | 1065 return element; |
| 1163 } | 1066 } |
| 1164 | 1067 |
| 1165 } // namespace blink | 1068 } // namespace blink |
| OLD | NEW |