1/* 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef HTMLVideoElement_h 27#define HTMLVideoElement_h 28 29#if ENABLE(VIDEO) 30 31#include "HTMLMediaElement.h" 32#include <memory> 33 34namespace WebCore { 35 36class HTMLImageLoader; 37 38class HTMLVideoElement final : public HTMLMediaElement { 39public: 40 static PassRefPtr<HTMLVideoElement> create(const QualifiedName&, Document&, bool); 41 42 unsigned videoWidth() const; 43 unsigned videoHeight() const; 44 45 // Fullscreen 46 void webkitEnterFullscreen(ExceptionCode&); 47 void webkitExitFullscreen(); 48 bool webkitSupportsFullscreen(); 49 bool webkitDisplayingFullscreen(); 50 51 // FIXME: Maintain "FullScreen" capitalization scheme for backwards compatibility. 52 // https://bugs.webkit.org/show_bug.cgi?id=36081 53 void webkitEnterFullScreen(ExceptionCode& ec) { webkitEnterFullscreen(ec); } 54 void webkitExitFullScreen() { webkitExitFullscreen(); } 55 56#if ENABLE(IOS_AIRPLAY) 57 bool webkitWirelessVideoPlaybackDisabled() const; 58 void setWebkitWirelessVideoPlaybackDisabled(bool); 59#endif 60 61#if ENABLE(MEDIA_STATISTICS) 62 // Statistics 63 unsigned webkitDecodedFrameCount() const; 64 unsigned webkitDroppedFrameCount() const; 65#endif 66 67 // Used by canvas to gain raw pixel access 68 void paintCurrentFrameInContext(GraphicsContext*, const IntRect&); 69 70 PassNativeImagePtr nativeImageForCurrentTime(); 71 72 // Used by WebGL to do GPU-GPU textures copy if possible. 73 // See more details at MediaPlayer::copyVideoTextureToPlatformTexture() defined in Source/WebCore/platform/graphics/MediaPlayer.h. 74 bool copyVideoTextureToPlatformTexture(GraphicsContext3D*, Platform3DObject texture, GC3Dint level, GC3Denum type, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY); 75 76 bool shouldDisplayPosterImage() const { return displayMode() == Poster || displayMode() == PosterWaitingForVideo; } 77 78 URL posterImageURL() const; 79 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 80 81private: 82 HTMLVideoElement(const QualifiedName&, Document&, bool); 83 84 virtual bool rendererIsNeeded(const RenderStyle&) override; 85 virtual void didAttachRenderers() override; 86 virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; 87 virtual bool isPresentationAttribute(const QualifiedName&) const override; 88 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override; 89 virtual bool isVideo() const override { return true; } 90 virtual bool hasVideo() const override { return player() && player()->hasVideo(); } 91 virtual bool supportsFullscreen() const override; 92 virtual bool isURLAttribute(const Attribute&) const override; 93 virtual const AtomicString& imageSourceURL() const override; 94 95 virtual bool hasAvailableVideoFrame() const; 96 virtual void updateDisplayState() override; 97 virtual void didMoveToNewDocument(Document* oldDocument) override; 98 virtual void setDisplayMode(DisplayMode) override; 99 100 std::unique_ptr<HTMLImageLoader> m_imageLoader; 101 102 AtomicString m_defaultPosterURL; 103}; 104 105NODE_TYPE_CASTS(HTMLVideoElement) 106 107} //namespace 108 109#endif 110#endif 111