dom/xbl/nsXBLContentSink.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 nsXBLContentSink_h__
     7 #define nsXBLContentSink_h__
     9 #include "mozilla/Attributes.h"
    10 #include "nsXMLContentSink.h"
    11 #include "nsXBLDocumentInfo.h"
    12 #include "nsXBLPrototypeHandler.h"
    13 #include "nsXBLProtoImpl.h"
    14 #include "nsLayoutCID.h"
    16 /*
    17  * Enum that describes the primary state of the parsing process
    18  */
    19 typedef enum {
    20   eXBL_InDocument,       /* outside any bindings */
    21   eXBL_InBindings,       /* Inside a <bindings> element */
    22   eXBL_InBinding,        /* Inside a <binding> */
    23   eXBL_InResources,      /* Inside a <resources> */
    24   eXBL_InImplementation, /* Inside a <implementation> */
    25   eXBL_InHandlers,       /* Inside a <handlers> */
    26   eXBL_Error             /* An error has occurred.  Suspend binding construction */
    27 } XBLPrimaryState;
    29 /*
    30  * Enum that describes our substate (typically when parsing something
    31  * like <handlers> or <implementation>).
    32  */
    33 typedef enum {
    34   eXBL_None,
    35   eXBL_InHandler,
    36   eXBL_InMethod,
    37   eXBL_InProperty,
    38   eXBL_InField,
    39   eXBL_InBody,
    40   eXBL_InGetter,
    41   eXBL_InSetter,
    42   eXBL_InConstructor,
    43   eXBL_InDestructor
    44 } XBLSecondaryState;
    46 class nsXULPrototypeElement;
    47 class nsXBLProtoImplMember;
    48 class nsXBLProtoImplProperty;
    49 class nsXBLProtoImplMethod;
    50 class nsXBLProtoImplField;
    51 class nsXBLPrototypeBinding;
    53 // The XBL content sink overrides the XML content sink to
    54 // builds its own lightweight data structures for the <resources>,
    55 // <handlers>, <implementation>, and 
    57 class nsXBLContentSink : public nsXMLContentSink {
    58 public:
    59   nsXBLContentSink();
    60   ~nsXBLContentSink();
    62   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
    64   nsresult Init(nsIDocument* aDoc,
    65                 nsIURI* aURL,
    66                 nsISupports* aContainer);
    68   // nsIContentSink overrides
    69   NS_IMETHOD HandleStartElement(const char16_t *aName, 
    70                                 const char16_t **aAtts, 
    71                                 uint32_t aAttsCount, 
    72                                 int32_t aIndex, 
    73                                 uint32_t aLineNumber) MOZ_OVERRIDE;
    75   NS_IMETHOD HandleEndElement(const char16_t *aName) MOZ_OVERRIDE;
    77   NS_IMETHOD HandleCDataSection(const char16_t *aData, 
    78                                 uint32_t aLength) MOZ_OVERRIDE;
    80 protected:
    81     // nsXMLContentSink overrides
    82     virtual void MaybeStartLayout(bool aIgnorePendingSheets) MOZ_OVERRIDE;
    84     bool OnOpenContainer(const char16_t **aAtts, 
    85                            uint32_t aAttsCount, 
    86                            int32_t aNameSpaceID, 
    87                            nsIAtom* aTagName,
    88                            uint32_t aLineNumber) MOZ_OVERRIDE;
    90     bool NotifyForDocElement() MOZ_OVERRIDE { return false; }
    92     nsresult CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
    93                            nsINodeInfo* aNodeInfo, uint32_t aLineNumber,
    94                            nsIContent** aResult, bool* aAppendContent,
    95                            mozilla::dom::FromParser aFromParser) MOZ_OVERRIDE;
    97     nsresult AddAttributes(const char16_t** aAtts, 
    98                            nsIContent* aContent) MOZ_OVERRIDE;
   100 #ifdef MOZ_XUL    
   101     nsresult AddAttributesToXULPrototype(const char16_t **aAtts, 
   102                                          uint32_t aAttsCount, 
   103                                          nsXULPrototypeElement* aElement);
   104 #endif
   106     // Our own helpers for constructing XBL prototype objects.
   107     nsresult ConstructBinding(uint32_t aLineNumber);
   108     void ConstructHandler(const char16_t **aAtts, uint32_t aLineNumber);
   109     void ConstructResource(const char16_t **aAtts, nsIAtom* aResourceType);
   110     void ConstructImplementation(const char16_t **aAtts);
   111     void ConstructProperty(const char16_t **aAtts, uint32_t aLineNumber);
   112     void ConstructMethod(const char16_t **aAtts);
   113     void ConstructParameter(const char16_t **aAtts);
   114     void ConstructField(const char16_t **aAtts, uint32_t aLineNumber);
   117   // nsXMLContentSink overrides
   118   nsresult FlushText(bool aReleaseTextNode = true) MOZ_OVERRIDE;
   120   // nsIExpatSink overrides
   121   NS_IMETHOD ReportError(const char16_t* aErrorText,
   122                          const char16_t* aSourceText,
   123                          nsIScriptError *aError,
   124                          bool *_retval) MOZ_OVERRIDE;
   126 protected:
   127   nsresult ReportUnexpectedElement(nsIAtom* aElementName, uint32_t aLineNumber);
   129   void AddMember(nsXBLProtoImplMember* aMember);
   130   void AddField(nsXBLProtoImplField* aField);
   132   XBLPrimaryState mState;
   133   XBLSecondaryState mSecondaryState;
   134   nsXBLDocumentInfo* mDocInfo;
   135   bool mIsChromeOrResource; // For bug #45989
   136   bool mFoundFirstBinding;
   138   nsString mCurrentBindingID;
   140   nsXBLPrototypeBinding* mBinding;
   141   nsXBLPrototypeHandler* mHandler; // current handler, owned by its PrototypeBinding
   142   nsXBLProtoImpl* mImplementation;
   143   nsXBLProtoImplMember* mImplMember;
   144   nsXBLProtoImplField* mImplField;
   145   nsXBLProtoImplProperty* mProperty;
   146   nsXBLProtoImplMethod* mMethod;
   147   nsXBLProtoImplField* mField;
   148 };
   150 nsresult
   151 NS_NewXBLContentSink(nsIXMLContentSink** aResult,
   152                      nsIDocument* aDoc,
   153                      nsIURI* aURL,
   154                      nsISupports* aContainer);
   155 #endif // nsXBLContentSink_h__

mercurial