LCOV - code coverage report
Current view: directory - content/html/content/src - nsHTMLVideoElement.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 63 0 0.0 %
Date: 2012-06-02 Functions: 28 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is the Mozilla Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2007
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *  Chris Double <chris.double@double.co.nz>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "mozilla/Util.h"
      40                 : 
      41                 : #include "nsIDOMHTMLVideoElement.h"
      42                 : #include "nsIDOMHTMLSourceElement.h"
      43                 : #include "nsHTMLVideoElement.h"
      44                 : #include "nsGenericHTMLElement.h"
      45                 : #include "nsGkAtoms.h"
      46                 : #include "nsSize.h"
      47                 : #include "nsIFrame.h"
      48                 : #include "nsIDocument.h"
      49                 : #include "nsIDOMDocument.h"
      50                 : #include "nsDOMError.h"
      51                 : #include "nsNodeInfoManager.h"
      52                 : #include "plbase64.h"
      53                 : #include "nsNetUtil.h"
      54                 : #include "prmem.h"
      55                 : #include "nsNetUtil.h"
      56                 : #include "nsXPCOMStrings.h"
      57                 : #include "prlock.h"
      58                 : #include "nsThreadUtils.h"
      59                 : 
      60                 : #include "nsIScriptSecurityManager.h"
      61                 : #include "nsIXPConnect.h"
      62                 : #include "jsapi.h"
      63                 : 
      64                 : #include "nsITimer.h"
      65                 : 
      66                 : #include "nsEventDispatcher.h"
      67                 : #include "nsIDOMProgressEvent.h"
      68                 : #include "nsMediaError.h"
      69                 : 
      70                 : using namespace mozilla;
      71                 : using namespace mozilla::dom;
      72                 : 
      73               0 : NS_IMPL_NS_NEW_HTML_ELEMENT(Video)
      74                 : 
      75               0 : NS_IMPL_ADDREF_INHERITED(nsHTMLVideoElement, nsHTMLMediaElement)
      76               0 : NS_IMPL_RELEASE_INHERITED(nsHTMLVideoElement, nsHTMLMediaElement)
      77                 : 
      78               0 : DOMCI_NODE_DATA(HTMLVideoElement, nsHTMLVideoElement)
      79                 : 
      80               0 : NS_INTERFACE_TABLE_HEAD(nsHTMLVideoElement)
      81               0 :   NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLVideoElement, nsIDOMHTMLMediaElement, nsIDOMHTMLVideoElement)
      82               0 :   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLVideoElement,
      83                 :                                                nsHTMLMediaElement)
      84               0 : NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLVideoElement)
      85                 : 
      86               0 : NS_IMPL_ELEMENT_CLONE(nsHTMLVideoElement)
      87                 : 
      88                 : // nsIDOMHTMLVideoElement
      89               0 : NS_IMPL_INT_ATTR(nsHTMLVideoElement, Width, width)
      90               0 : NS_IMPL_INT_ATTR(nsHTMLVideoElement, Height, height)
      91                 : 
      92                 : // nsIDOMHTMLVideoElement
      93                 : /* readonly attribute unsigned long videoWidth; */
      94               0 : NS_IMETHODIMP nsHTMLVideoElement::GetVideoWidth(PRUint32 *aVideoWidth)
      95                 : {
      96               0 :   *aVideoWidth = mMediaSize.width == -1 ? 0 : mMediaSize.width;
      97               0 :   return NS_OK;
      98                 : }
      99                 : 
     100                 : /* readonly attribute unsigned long videoHeight; */
     101               0 : NS_IMETHODIMP nsHTMLVideoElement::GetVideoHeight(PRUint32 *aVideoHeight)
     102                 : {
     103               0 :   *aVideoHeight = mMediaSize.height == -1 ? 0 : mMediaSize.height;
     104               0 :   return NS_OK;
     105                 : }
     106                 : 
     107               0 : nsHTMLVideoElement::nsHTMLVideoElement(already_AddRefed<nsINodeInfo> aNodeInfo)
     108               0 :   : nsHTMLMediaElement(aNodeInfo)
     109                 : {
     110               0 : }
     111                 : 
     112               0 : nsHTMLVideoElement::~nsHTMLVideoElement()
     113                 : {
     114               0 : }
     115                 : 
     116               0 : nsIntSize nsHTMLVideoElement::GetVideoSize(nsIntSize aDefaultSize)
     117                 : {
     118               0 :   return mMediaSize.width == -1 && mMediaSize.height == -1 ? aDefaultSize : mMediaSize;
     119                 : }
     120                 : 
     121                 : bool
     122               0 : nsHTMLVideoElement::ParseAttribute(PRInt32 aNamespaceID,
     123                 :                                    nsIAtom* aAttribute,
     124                 :                                    const nsAString& aValue,
     125                 :                                    nsAttrValue& aResult)
     126                 : {
     127               0 :    if (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height) {
     128               0 :      return aResult.ParseSpecialIntValue(aValue);
     129                 :    }
     130                 : 
     131                 :    return nsHTMLMediaElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
     132               0 :                                              aResult);
     133                 : }
     134                 : 
     135                 : static void
     136               0 : MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
     137                 :                       nsRuleData* aData)
     138                 : {
     139               0 :   nsGenericHTMLElement::MapImageSizeAttributesInto(aAttributes, aData);
     140               0 :   nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
     141               0 : }
     142                 : 
     143                 : NS_IMETHODIMP_(bool)
     144               0 : nsHTMLVideoElement::IsAttributeMapped(const nsIAtom* aAttribute) const
     145                 : {
     146                 :   static const MappedAttributeEntry attributes[] = {
     147                 :     { &nsGkAtoms::width },
     148                 :     { &nsGkAtoms::height },
     149                 :     { nsnull }
     150                 :   };
     151                 : 
     152                 :   static const MappedAttributeEntry* const map[] = {
     153                 :     attributes,
     154                 :     sCommonAttributeMap
     155                 :   };
     156                 : 
     157               0 :   return FindAttributeDependence(aAttribute, map);
     158                 : }
     159                 : 
     160                 : nsMapRuleToAttributesFunc
     161               0 : nsHTMLVideoElement::GetAttributeMappingFunction() const
     162                 : {
     163               0 :   return &MapAttributesIntoRule;
     164                 : }
     165                 : 
     166               0 : nsresult nsHTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel)
     167                 : {
     168                 :   nsCAutoString value(
     169                 : #ifdef MOZ_WEBM
     170                 :       "video/webm,"
     171                 : #endif
     172                 : #ifdef MOZ_OGG
     173                 :       "video/ogg,"
     174                 : #endif
     175                 :       "video/*;q=0.9,"
     176                 : #ifdef MOZ_OGG
     177                 :       "application/ogg;q=0.7,"
     178                 : #endif
     179               0 :       "audio/*;q=0.6,*/*;q=0.5");
     180                 : 
     181               0 :   return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
     182                 :                                     value,
     183               0 :                                     false);
     184                 : }
     185                 : 
     186               0 : NS_IMPL_URI_ATTR(nsHTMLVideoElement, Poster, poster)
     187                 : 
     188               0 : NS_IMETHODIMP nsHTMLVideoElement::GetMozParsedFrames(PRUint32 *aMozParsedFrames)
     189                 : {
     190               0 :   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
     191               0 :   *aMozParsedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetParsedFrames() : 0;
     192               0 :   return NS_OK;
     193                 : }
     194                 : 
     195               0 : NS_IMETHODIMP nsHTMLVideoElement::GetMozDecodedFrames(PRUint32 *aMozDecodedFrames)
     196                 : {
     197               0 :   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
     198               0 :   *aMozDecodedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetDecodedFrames() : 0;
     199               0 :   return NS_OK;
     200                 : }
     201                 : 
     202               0 : NS_IMETHODIMP nsHTMLVideoElement::GetMozPresentedFrames(PRUint32 *aMozPresentedFrames)
     203                 : {
     204               0 :   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
     205               0 :   *aMozPresentedFrames = mDecoder ? mDecoder->GetFrameStatistics().GetPresentedFrames() : 0;
     206               0 :   return NS_OK;
     207                 : }
     208                 : 
     209               0 : NS_IMETHODIMP nsHTMLVideoElement::GetMozPaintedFrames(PRUint32 *aMozPaintedFrames)
     210                 : {
     211               0 :   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
     212               0 :   ImageContainer* container = GetImageContainer();
     213               0 :   *aMozPaintedFrames = container ? container->GetPaintCount() : 0;
     214               0 :   return NS_OK;
     215                 : }
     216                 : 
     217               0 : NS_IMETHODIMP nsHTMLVideoElement::GetMozFrameDelay(double *aMozFrameDelay) {
     218               0 :   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
     219               0 :   VideoFrameContainer* container = GetVideoFrameContainer();
     220               0 :   *aMozFrameDelay = container ?  container->GetFrameDelay() : 0;
     221               0 :   return NS_OK;
     222                 : }

Generated by: LCOV version 1.7