content/html/document/src/MediaDocument.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef mozilla_dom_MediaDocument_h
     7 #define mozilla_dom_MediaDocument_h
     9 #include "mozilla/Attributes.h"
    10 #include "nsHTMLDocument.h"
    11 #include "nsGenericHTMLElement.h"
    12 #include "nsAutoPtr.h"
    13 #include "nsIStringBundle.h"
    15 #define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties"
    17 namespace mozilla {
    18 namespace dom {
    20 class MediaDocument : public nsHTMLDocument
    21 {
    22 public:
    23   MediaDocument();
    24   virtual ~MediaDocument();
    26   virtual nsresult Init() MOZ_OVERRIDE;
    28   virtual nsresult StartDocumentLoad(const char*         aCommand,
    29                                      nsIChannel*         aChannel,
    30                                      nsILoadGroup*       aLoadGroup,
    31                                      nsISupports*        aContainer,
    32                                      nsIStreamListener** aDocListener,
    33                                      bool                aReset = true,
    34                                      nsIContentSink*     aSink = nullptr) MOZ_OVERRIDE;
    36   virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) MOZ_OVERRIDE;
    38   virtual bool WillIgnoreCharsetOverride()
    39   {
    40     return true;
    41   }
    43 protected:
    44   void BecomeInteractive();
    46   virtual nsresult CreateSyntheticDocument();
    48   friend class MediaDocumentStreamListener;
    49   nsresult StartLayout();
    51   void GetFileName(nsAString& aResult);
    53   nsresult LinkStylesheet(const nsAString& aStylesheet);
    55   // |aFormatNames[]| needs to have four elements in the following order: 
    56   // a format name with neither dimension nor file, a format name with
    57   // filename but w/o dimension, a format name with dimension but w/o filename,
    58   // a format name with both of them.  For instance, it can have
    59   // "ImageTitleWithNeitherDimensionsNorFile", "ImageTitleWithoutDimensions",
    60   // "ImageTitleWithDimesions2",  "ImageTitleWithDimensions2AndFile".
    61   //
    62   // Also see MediaDocument.properties if you want to define format names
    63   // for a new subclass. aWidth and aHeight are pixels for |ImageDocument|,
    64   // but could be in other units for other 'media', in which case you have to 
    65   // define format names accordingly. 
    66   void UpdateTitleAndCharset(const nsACString&  aTypeStr,
    67                              const char* const* aFormatNames = sFormatNames,
    68                              int32_t            aWidth = 0,
    69                              int32_t            aHeight = 0,
    70                              const nsAString&   aStatus = EmptyString());
    72   nsCOMPtr<nsIStringBundle>     mStringBundle;
    73   static const char* const      sFormatNames[4];
    75 private:
    76   enum                          {eWithNoInfo, eWithFile, eWithDim, eWithDimAndFile};
    77   bool                          mDocumentElementInserted;   
    78 };
    81 class MediaDocumentStreamListener: public nsIStreamListener
    82 {
    83 public:
    84   MediaDocumentStreamListener(MediaDocument *aDocument);
    85   virtual ~MediaDocumentStreamListener();
    86   void SetStreamListener(nsIStreamListener *aListener);
    88   NS_DECL_ISUPPORTS
    90   NS_DECL_NSIREQUESTOBSERVER
    92   NS_DECL_NSISTREAMLISTENER
    94   nsRefPtr<MediaDocument>      mDocument;
    95   nsCOMPtr<nsIStreamListener>  mNextStream;
    96 };
    98 } // namespace dom
    99 } // namespace mozilla
   101 #endif /* mozilla_dom_MediaDocument_h */

mercurial