content/html/document/src/MediaDocument.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/html/document/src/MediaDocument.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,101 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_dom_MediaDocument_h
    1.10 +#define mozilla_dom_MediaDocument_h
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "nsHTMLDocument.h"
    1.14 +#include "nsGenericHTMLElement.h"
    1.15 +#include "nsAutoPtr.h"
    1.16 +#include "nsIStringBundle.h"
    1.17 +
    1.18 +#define NSMEDIADOCUMENT_PROPERTIES_URI "chrome://global/locale/layout/MediaDocument.properties"
    1.19 +
    1.20 +namespace mozilla {
    1.21 +namespace dom {
    1.22 +
    1.23 +class MediaDocument : public nsHTMLDocument
    1.24 +{
    1.25 +public:
    1.26 +  MediaDocument();
    1.27 +  virtual ~MediaDocument();
    1.28 +
    1.29 +  virtual nsresult Init() MOZ_OVERRIDE;
    1.30 +
    1.31 +  virtual nsresult StartDocumentLoad(const char*         aCommand,
    1.32 +                                     nsIChannel*         aChannel,
    1.33 +                                     nsILoadGroup*       aLoadGroup,
    1.34 +                                     nsISupports*        aContainer,
    1.35 +                                     nsIStreamListener** aDocListener,
    1.36 +                                     bool                aReset = true,
    1.37 +                                     nsIContentSink*     aSink = nullptr) MOZ_OVERRIDE;
    1.38 +
    1.39 +  virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) MOZ_OVERRIDE;
    1.40 +
    1.41 +  virtual bool WillIgnoreCharsetOverride()
    1.42 +  {
    1.43 +    return true;
    1.44 +  }
    1.45 +
    1.46 +protected:
    1.47 +  void BecomeInteractive();
    1.48 +
    1.49 +  virtual nsresult CreateSyntheticDocument();
    1.50 +
    1.51 +  friend class MediaDocumentStreamListener;
    1.52 +  nsresult StartLayout();
    1.53 +
    1.54 +  void GetFileName(nsAString& aResult);
    1.55 +
    1.56 +  nsresult LinkStylesheet(const nsAString& aStylesheet);
    1.57 +
    1.58 +  // |aFormatNames[]| needs to have four elements in the following order: 
    1.59 +  // a format name with neither dimension nor file, a format name with
    1.60 +  // filename but w/o dimension, a format name with dimension but w/o filename,
    1.61 +  // a format name with both of them.  For instance, it can have
    1.62 +  // "ImageTitleWithNeitherDimensionsNorFile", "ImageTitleWithoutDimensions",
    1.63 +  // "ImageTitleWithDimesions2",  "ImageTitleWithDimensions2AndFile".
    1.64 +  //
    1.65 +  // Also see MediaDocument.properties if you want to define format names
    1.66 +  // for a new subclass. aWidth and aHeight are pixels for |ImageDocument|,
    1.67 +  // but could be in other units for other 'media', in which case you have to 
    1.68 +  // define format names accordingly. 
    1.69 +  void UpdateTitleAndCharset(const nsACString&  aTypeStr,
    1.70 +                             const char* const* aFormatNames = sFormatNames,
    1.71 +                             int32_t            aWidth = 0,
    1.72 +                             int32_t            aHeight = 0,
    1.73 +                             const nsAString&   aStatus = EmptyString());
    1.74 +
    1.75 +  nsCOMPtr<nsIStringBundle>     mStringBundle;
    1.76 +  static const char* const      sFormatNames[4];
    1.77 +  
    1.78 +private:
    1.79 +  enum                          {eWithNoInfo, eWithFile, eWithDim, eWithDimAndFile};
    1.80 +  bool                          mDocumentElementInserted;   
    1.81 +};
    1.82 +
    1.83 +
    1.84 +class MediaDocumentStreamListener: public nsIStreamListener
    1.85 +{
    1.86 +public:
    1.87 +  MediaDocumentStreamListener(MediaDocument *aDocument);
    1.88 +  virtual ~MediaDocumentStreamListener();
    1.89 +  void SetStreamListener(nsIStreamListener *aListener);
    1.90 +
    1.91 +  NS_DECL_ISUPPORTS
    1.92 +
    1.93 +  NS_DECL_NSIREQUESTOBSERVER
    1.94 +
    1.95 +  NS_DECL_NSISTREAMLISTENER
    1.96 +
    1.97 +  nsRefPtr<MediaDocument>      mDocument;
    1.98 +  nsCOMPtr<nsIStreamListener>  mNextStream;
    1.99 +};
   1.100 +
   1.101 +} // namespace dom
   1.102 +} // namespace mozilla
   1.103 +
   1.104 +#endif /* mozilla_dom_MediaDocument_h */

mercurial