1/* 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of Apple Inc. ("Apple") nor the names of 15 * its contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30#ifndef MediaControlElements_h 31#define MediaControlElements_h 32 33#if ENABLE(VIDEO) 34#include "MediaControlElementTypes.h" 35#include "TextTrackRepresentation.h" 36 37namespace WebCore { 38 39// ---------------------------- 40 41class MediaControlPanelElement final : public MediaControlDivElement { 42public: 43 static PassRefPtr<MediaControlPanelElement> create(Document&); 44 45 void setCanBeDragged(bool); 46 void setIsDisplayed(bool); 47 48 void resetPosition(); 49 void makeOpaque(); 50 void makeTransparent(); 51 52#if !PLATFORM(IOS) 53 virtual bool willRespondToMouseMoveEvents() override { return true; } 54 virtual bool willRespondToMouseClickEvents() override { return true; } 55#endif 56 57private: 58 explicit MediaControlPanelElement(Document&); 59 60 virtual const AtomicString& shadowPseudoId() const override; 61 virtual void defaultEventHandler(Event*) override; 62 63 void startDrag(const LayoutPoint& eventLocation); 64 void continueDrag(const LayoutPoint& eventLocation); 65 void endDrag(); 66 67 void startTimer(); 68 void stopTimer(); 69 void transitionTimerFired(Timer<MediaControlPanelElement>&); 70 71 void setPosition(const LayoutPoint&); 72 73 bool m_canBeDragged; 74 bool m_isBeingDragged; 75 bool m_isDisplayed; 76 bool m_opaque; 77 LayoutPoint m_lastDragEventLocation; 78 LayoutPoint m_cumulativeDragOffset; 79 80 Timer<MediaControlPanelElement> m_transitionTimer; 81}; 82 83// ---------------------------- 84 85class MediaControlPanelEnclosureElement final : public MediaControlDivElement { 86public: 87 static PassRefPtr<MediaControlPanelEnclosureElement> create(Document&); 88 89private: 90 explicit MediaControlPanelEnclosureElement(Document&); 91 virtual const AtomicString& shadowPseudoId() const override; 92}; 93 94// ---------------------------- 95 96class MediaControlOverlayEnclosureElement final : public MediaControlDivElement { 97public: 98 static PassRefPtr<MediaControlOverlayEnclosureElement> create(Document&); 99 100private: 101 explicit MediaControlOverlayEnclosureElement(Document&); 102 virtual const AtomicString& shadowPseudoId() const override; 103}; 104 105// ---------------------------- 106 107class MediaControlTimelineContainerElement : public MediaControlDivElement { 108public: 109 static PassRefPtr<MediaControlTimelineContainerElement> create(Document&); 110 111 void setTimeDisplaysHidden(bool); 112 113private: 114 explicit MediaControlTimelineContainerElement(Document&); 115 virtual const AtomicString& shadowPseudoId() const override; 116 117 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 118}; 119 120// ---------------------------- 121 122class MediaControlVolumeSliderContainerElement : public MediaControlDivElement { 123public: 124 static PassRefPtr<MediaControlVolumeSliderContainerElement> create(Document&); 125 126#if !PLATFORM(IOS) 127 virtual bool willRespondToMouseMoveEvents() override { return true; } 128#endif 129 130private: 131 explicit MediaControlVolumeSliderContainerElement(Document&); 132 133 virtual const AtomicString& shadowPseudoId() const override; 134 virtual void defaultEventHandler(Event*) override; 135 136 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 137}; 138 139// ---------------------------- 140 141class MediaControlStatusDisplayElement : public MediaControlDivElement { 142public: 143 static PassRefPtr<MediaControlStatusDisplayElement> create(Document&); 144 145 void update(); 146 147private: 148 explicit MediaControlStatusDisplayElement(Document&); 149 virtual const AtomicString& shadowPseudoId() const override; 150 151 enum StateBeingDisplayed { Nothing, Loading, LiveBroadcast }; 152 StateBeingDisplayed m_stateBeingDisplayed; 153}; 154 155// ---------------------------- 156 157class MediaControlPanelMuteButtonElement final : public MediaControlMuteButtonElement { 158public: 159 static PassRefPtr<MediaControlPanelMuteButtonElement> create(Document&, MediaControls*); 160 161#if !PLATFORM(IOS) 162 virtual bool willRespondToMouseMoveEvents() override { return true; } 163#endif 164 165private: 166 explicit MediaControlPanelMuteButtonElement(Document&, MediaControls*); 167 168 virtual const AtomicString& shadowPseudoId() const override; 169 virtual void defaultEventHandler(Event*) override; 170 171 MediaControls* m_controls; 172}; 173 174// ---------------------------- 175 176class MediaControlVolumeSliderMuteButtonElement final : public MediaControlMuteButtonElement { 177public: 178 static PassRefPtr<MediaControlVolumeSliderMuteButtonElement> create(Document&); 179 180private: 181 explicit MediaControlVolumeSliderMuteButtonElement(Document&); 182 virtual const AtomicString& shadowPseudoId() const override; 183}; 184 185 186// ---------------------------- 187 188class MediaControlPlayButtonElement final : public MediaControlInputElement { 189public: 190 static PassRefPtr<MediaControlPlayButtonElement> create(Document&); 191 192#if !PLATFORM(IOS) 193 virtual bool willRespondToMouseClickEvents() override { return true; } 194#endif 195 196 virtual void updateDisplayType() override; 197 198private: 199 explicit MediaControlPlayButtonElement(Document&); 200 201 virtual const AtomicString& shadowPseudoId() const override; 202 virtual void defaultEventHandler(Event*) override; 203}; 204 205// ---------------------------- 206 207class MediaControlOverlayPlayButtonElement final : public MediaControlInputElement { 208public: 209 static PassRefPtr<MediaControlOverlayPlayButtonElement> create(Document&); 210 211 virtual void updateDisplayType() override; 212 213private: 214 explicit MediaControlOverlayPlayButtonElement(Document&); 215 216 virtual const AtomicString& shadowPseudoId() const override; 217 virtual void defaultEventHandler(Event*) override; 218}; 219 220// ---------------------------- 221 222class MediaControlSeekForwardButtonElement : public MediaControlSeekButtonElement { 223public: 224 static PassRefPtr<MediaControlSeekForwardButtonElement> create(Document&); 225 226private: 227 explicit MediaControlSeekForwardButtonElement(Document&); 228 virtual const AtomicString& shadowPseudoId() const override; 229 230 virtual bool isForwardButton() const override { return true; } 231}; 232 233// ---------------------------- 234 235class MediaControlSeekBackButtonElement : public MediaControlSeekButtonElement { 236public: 237 static PassRefPtr<MediaControlSeekBackButtonElement> create(Document&); 238 239private: 240 explicit MediaControlSeekBackButtonElement(Document&); 241 virtual const AtomicString& shadowPseudoId() const override; 242 243 virtual bool isForwardButton() const override { return false; } 244}; 245 246// ---------------------------- 247 248class MediaControlRewindButtonElement : public MediaControlInputElement { 249public: 250 static PassRefPtr<MediaControlRewindButtonElement> create(Document&); 251 252#if !PLATFORM(IOS) 253 virtual bool willRespondToMouseClickEvents() override { return true; } 254#endif 255 256private: 257 explicit MediaControlRewindButtonElement(Document&); 258 259 virtual const AtomicString& shadowPseudoId() const override; 260 virtual void defaultEventHandler(Event*) override; 261}; 262 263// ---------------------------- 264 265class MediaControlReturnToRealtimeButtonElement : public MediaControlInputElement { 266public: 267 static PassRefPtr<MediaControlReturnToRealtimeButtonElement> create(Document&); 268 269#if !PLATFORM(IOS) 270 virtual bool willRespondToMouseClickEvents() override { return true; } 271#endif 272 273private: 274 explicit MediaControlReturnToRealtimeButtonElement(Document&); 275 276 virtual const AtomicString& shadowPseudoId() const override; 277 virtual void defaultEventHandler(Event*) override; 278}; 279 280// ---------------------------- 281 282class MediaControlToggleClosedCaptionsButtonElement final : public MediaControlInputElement { 283public: 284 static PassRefPtr<MediaControlToggleClosedCaptionsButtonElement> create(Document&, MediaControls*); 285 286#if !PLATFORM(IOS) 287 virtual bool willRespondToMouseClickEvents() override { return true; } 288#endif 289 290 virtual void updateDisplayType() override; 291 292private: 293 explicit MediaControlToggleClosedCaptionsButtonElement(Document&, MediaControls*); 294 295 virtual const AtomicString& shadowPseudoId() const override; 296 virtual void defaultEventHandler(Event*) override; 297 298#if PLATFORM(COCOA) || PLATFORM(WIN) || PLATFORM(GTK) 299 MediaControls* m_controls; 300#endif 301}; 302 303// ---------------------------- 304 305class MediaControlClosedCaptionsContainerElement final : public MediaControlDivElement { 306public: 307 static PassRefPtr<MediaControlClosedCaptionsContainerElement> create(Document&); 308 309#if !PLATFORM(IOS) 310 virtual bool willRespondToMouseClickEvents() override { return true; } 311#endif 312 313private: 314 MediaControlClosedCaptionsContainerElement(Document&); 315 virtual const AtomicString& shadowPseudoId() const override; 316}; 317 318// ---------------------------- 319 320class MediaControlClosedCaptionsTrackListElement final : public MediaControlDivElement { 321public: 322 static PassRefPtr<MediaControlClosedCaptionsTrackListElement> create(Document&, MediaControls*); 323 324#if !PLATFORM(IOS) 325 virtual bool willRespondToMouseClickEvents() override { return true; } 326#endif 327 328 void updateDisplay(); 329 330private: 331 MediaControlClosedCaptionsTrackListElement(Document&, MediaControls*); 332 333 void rebuildTrackListMenu(); 334 335 virtual const AtomicString& shadowPseudoId() const override; 336 virtual void defaultEventHandler(Event*) override; 337 338 typedef Vector<RefPtr<Element>> TrackMenuItems; 339 TrackMenuItems m_menuItems; 340#if ENABLE(VIDEO_TRACK) 341 typedef HashMap<RefPtr<Element>, RefPtr<TextTrack>> MenuItemToTrackMap; 342 MenuItemToTrackMap m_menuToTrackMap; 343#endif 344 MediaControls* m_controls; 345}; 346 347// ---------------------------- 348 349class MediaControlTimelineElement final : public MediaControlInputElement { 350public: 351 static PassRefPtr<MediaControlTimelineElement> create(Document&, MediaControls*); 352 353#if !PLATFORM(IOS) 354 virtual bool willRespondToMouseClickEvents() override; 355#endif 356 357 void setPosition(double); 358 void setDuration(double); 359 360private: 361 explicit MediaControlTimelineElement(Document&, MediaControls*); 362 363 virtual const AtomicString& shadowPseudoId() const override; 364 virtual void defaultEventHandler(Event*) override; 365 366 MediaControls* m_controls; 367}; 368 369// ---------------------------- 370 371class MediaControlFullscreenButtonElement final : public MediaControlInputElement { 372public: 373 static PassRefPtr<MediaControlFullscreenButtonElement> create(Document&); 374 375#if !PLATFORM(IOS) 376 virtual bool willRespondToMouseClickEvents() override { return true; } 377#endif 378 379 virtual void setIsFullscreen(bool); 380 381private: 382 explicit MediaControlFullscreenButtonElement(Document&); 383 384 virtual const AtomicString& shadowPseudoId() const override; 385 virtual void defaultEventHandler(Event*) override; 386}; 387 388// ---------------------------- 389 390class MediaControlPanelVolumeSliderElement final : public MediaControlVolumeSliderElement { 391public: 392 static PassRefPtr<MediaControlPanelVolumeSliderElement> create(Document&); 393 394private: 395 explicit MediaControlPanelVolumeSliderElement(Document&); 396 virtual const AtomicString& shadowPseudoId() const override; 397}; 398// ---------------------------- 399 400class MediaControlFullscreenVolumeSliderElement : public MediaControlVolumeSliderElement { 401public: 402 static PassRefPtr<MediaControlFullscreenVolumeSliderElement> create(Document&); 403 404private: 405 explicit MediaControlFullscreenVolumeSliderElement(Document&); 406 virtual const AtomicString& shadowPseudoId() const override; 407}; 408 409// ---------------------------- 410 411class MediaControlFullscreenVolumeMinButtonElement : public MediaControlInputElement { 412public: 413 static PassRefPtr<MediaControlFullscreenVolumeMinButtonElement> create(Document&); 414 415#if !PLATFORM(IOS) 416 virtual bool willRespondToMouseClickEvents() override { return true; } 417#endif 418 419private: 420 explicit MediaControlFullscreenVolumeMinButtonElement(Document&); 421 virtual const AtomicString& shadowPseudoId() const override; 422 virtual void defaultEventHandler(Event*) override; 423}; 424 425// ---------------------------- 426 427class MediaControlFullscreenVolumeMaxButtonElement : public MediaControlInputElement { 428public: 429 static PassRefPtr<MediaControlFullscreenVolumeMaxButtonElement> create(Document&); 430 431#if !PLATFORM(IOS) 432 virtual bool willRespondToMouseClickEvents() override { return true; } 433#endif 434 435private: 436 explicit MediaControlFullscreenVolumeMaxButtonElement(Document&); 437 438 virtual const AtomicString& shadowPseudoId() const override; 439 virtual void defaultEventHandler(Event*) override; 440}; 441 442 443// ---------------------------- 444 445class MediaControlTimeRemainingDisplayElement final : public MediaControlTimeDisplayElement { 446public: 447 static PassRefPtr<MediaControlTimeRemainingDisplayElement> create(Document&); 448 449private: 450 explicit MediaControlTimeRemainingDisplayElement(Document&); 451 virtual const AtomicString& shadowPseudoId() const override; 452}; 453 454// ---------------------------- 455 456class MediaControlCurrentTimeDisplayElement final : public MediaControlTimeDisplayElement { 457public: 458 static PassRefPtr<MediaControlCurrentTimeDisplayElement> create(Document&); 459 460private: 461 explicit MediaControlCurrentTimeDisplayElement(Document&); 462 virtual const AtomicString& shadowPseudoId() const override; 463}; 464 465// ---------------------------- 466 467#if ENABLE(VIDEO_TRACK) 468 469class MediaControlTextTrackContainerElement final : public MediaControlDivElement, public TextTrackRepresentationClient { 470public: 471 static PassRefPtr<MediaControlTextTrackContainerElement> create(Document&); 472 473 void updateDisplay(); 474 void updateSizes(bool forceUpdate = false); 475 void enteredFullscreen(); 476 void exitedFullscreen(); 477 static const AtomicString& textTrackContainerElementShadowPseudoId(); 478 479private: 480 void updateTimerFired(Timer<MediaControlTextTrackContainerElement>&); 481 void updateActiveCuesFontSize(); 482 483 explicit MediaControlTextTrackContainerElement(Document&); 484 virtual const AtomicString& shadowPseudoId() const override; 485 486 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 487 488 virtual PassRefPtr<Image> createTextTrackRepresentationImage() override; 489 virtual void textTrackRepresentationBoundsChanged(const IntRect&) override; 490 void updateTextTrackRepresentation(); 491 void clearTextTrackRepresentation(); 492 void updateStyleForTextTrackRepresentation(); 493 OwnPtr<TextTrackRepresentation> m_textTrackRepresentation; 494 495 Timer<MediaControlTextTrackContainerElement> m_updateTimer; 496 IntRect m_videoDisplaySize; 497 int m_fontSize; 498 bool m_fontSizeIsImportant; 499 bool m_updateTextTrackRepresentationStyle; 500}; 501 502#endif 503 504} // namespace WebCore 505 506#endif // ENABLE(VIDEO) 507 508#endif // MediaControlElements_h 509