dom/xbl/nsXBLContentSink.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/xbl/nsXBLContentSink.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,155 @@
     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 nsXBLContentSink_h__
    1.10 +#define nsXBLContentSink_h__
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "nsXMLContentSink.h"
    1.14 +#include "nsXBLDocumentInfo.h"
    1.15 +#include "nsXBLPrototypeHandler.h"
    1.16 +#include "nsXBLProtoImpl.h"
    1.17 +#include "nsLayoutCID.h"
    1.18 +
    1.19 +/*
    1.20 + * Enum that describes the primary state of the parsing process
    1.21 + */
    1.22 +typedef enum {
    1.23 +  eXBL_InDocument,       /* outside any bindings */
    1.24 +  eXBL_InBindings,       /* Inside a <bindings> element */
    1.25 +  eXBL_InBinding,        /* Inside a <binding> */
    1.26 +  eXBL_InResources,      /* Inside a <resources> */
    1.27 +  eXBL_InImplementation, /* Inside a <implementation> */
    1.28 +  eXBL_InHandlers,       /* Inside a <handlers> */
    1.29 +  eXBL_Error             /* An error has occurred.  Suspend binding construction */
    1.30 +} XBLPrimaryState;
    1.31 +
    1.32 +/*
    1.33 + * Enum that describes our substate (typically when parsing something
    1.34 + * like <handlers> or <implementation>).
    1.35 + */
    1.36 +typedef enum {
    1.37 +  eXBL_None,
    1.38 +  eXBL_InHandler,
    1.39 +  eXBL_InMethod,
    1.40 +  eXBL_InProperty,
    1.41 +  eXBL_InField,
    1.42 +  eXBL_InBody,
    1.43 +  eXBL_InGetter,
    1.44 +  eXBL_InSetter,
    1.45 +  eXBL_InConstructor,
    1.46 +  eXBL_InDestructor
    1.47 +} XBLSecondaryState;
    1.48 +
    1.49 +class nsXULPrototypeElement;
    1.50 +class nsXBLProtoImplMember;
    1.51 +class nsXBLProtoImplProperty;
    1.52 +class nsXBLProtoImplMethod;
    1.53 +class nsXBLProtoImplField;
    1.54 +class nsXBLPrototypeBinding;
    1.55 +
    1.56 +// The XBL content sink overrides the XML content sink to
    1.57 +// builds its own lightweight data structures for the <resources>,
    1.58 +// <handlers>, <implementation>, and 
    1.59 +
    1.60 +class nsXBLContentSink : public nsXMLContentSink {
    1.61 +public:
    1.62 +  nsXBLContentSink();
    1.63 +  ~nsXBLContentSink();
    1.64 +
    1.65 +  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
    1.66 +
    1.67 +  nsresult Init(nsIDocument* aDoc,
    1.68 +                nsIURI* aURL,
    1.69 +                nsISupports* aContainer);
    1.70 +
    1.71 +  // nsIContentSink overrides
    1.72 +  NS_IMETHOD HandleStartElement(const char16_t *aName, 
    1.73 +                                const char16_t **aAtts, 
    1.74 +                                uint32_t aAttsCount, 
    1.75 +                                int32_t aIndex, 
    1.76 +                                uint32_t aLineNumber) MOZ_OVERRIDE;
    1.77 +
    1.78 +  NS_IMETHOD HandleEndElement(const char16_t *aName) MOZ_OVERRIDE;
    1.79 +  
    1.80 +  NS_IMETHOD HandleCDataSection(const char16_t *aData, 
    1.81 +                                uint32_t aLength) MOZ_OVERRIDE;
    1.82 +
    1.83 +protected:
    1.84 +    // nsXMLContentSink overrides
    1.85 +    virtual void MaybeStartLayout(bool aIgnorePendingSheets) MOZ_OVERRIDE;
    1.86 +
    1.87 +    bool OnOpenContainer(const char16_t **aAtts, 
    1.88 +                           uint32_t aAttsCount, 
    1.89 +                           int32_t aNameSpaceID, 
    1.90 +                           nsIAtom* aTagName,
    1.91 +                           uint32_t aLineNumber) MOZ_OVERRIDE;
    1.92 +
    1.93 +    bool NotifyForDocElement() MOZ_OVERRIDE { return false; }
    1.94 +
    1.95 +    nsresult CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
    1.96 +                           nsINodeInfo* aNodeInfo, uint32_t aLineNumber,
    1.97 +                           nsIContent** aResult, bool* aAppendContent,
    1.98 +                           mozilla::dom::FromParser aFromParser) MOZ_OVERRIDE;
    1.99 +    
   1.100 +    nsresult AddAttributes(const char16_t** aAtts, 
   1.101 +                           nsIContent* aContent) MOZ_OVERRIDE;
   1.102 +
   1.103 +#ifdef MOZ_XUL    
   1.104 +    nsresult AddAttributesToXULPrototype(const char16_t **aAtts, 
   1.105 +                                         uint32_t aAttsCount, 
   1.106 +                                         nsXULPrototypeElement* aElement);
   1.107 +#endif
   1.108 +
   1.109 +    // Our own helpers for constructing XBL prototype objects.
   1.110 +    nsresult ConstructBinding(uint32_t aLineNumber);
   1.111 +    void ConstructHandler(const char16_t **aAtts, uint32_t aLineNumber);
   1.112 +    void ConstructResource(const char16_t **aAtts, nsIAtom* aResourceType);
   1.113 +    void ConstructImplementation(const char16_t **aAtts);
   1.114 +    void ConstructProperty(const char16_t **aAtts, uint32_t aLineNumber);
   1.115 +    void ConstructMethod(const char16_t **aAtts);
   1.116 +    void ConstructParameter(const char16_t **aAtts);
   1.117 +    void ConstructField(const char16_t **aAtts, uint32_t aLineNumber);
   1.118 +  
   1.119 +
   1.120 +  // nsXMLContentSink overrides
   1.121 +  nsresult FlushText(bool aReleaseTextNode = true) MOZ_OVERRIDE;
   1.122 +
   1.123 +  // nsIExpatSink overrides
   1.124 +  NS_IMETHOD ReportError(const char16_t* aErrorText,
   1.125 +                         const char16_t* aSourceText,
   1.126 +                         nsIScriptError *aError,
   1.127 +                         bool *_retval) MOZ_OVERRIDE;
   1.128 +
   1.129 +protected:
   1.130 +  nsresult ReportUnexpectedElement(nsIAtom* aElementName, uint32_t aLineNumber);
   1.131 +
   1.132 +  void AddMember(nsXBLProtoImplMember* aMember);
   1.133 +  void AddField(nsXBLProtoImplField* aField);
   1.134 +  
   1.135 +  XBLPrimaryState mState;
   1.136 +  XBLSecondaryState mSecondaryState;
   1.137 +  nsXBLDocumentInfo* mDocInfo;
   1.138 +  bool mIsChromeOrResource; // For bug #45989
   1.139 +  bool mFoundFirstBinding;
   1.140 +
   1.141 +  nsString mCurrentBindingID;
   1.142 +
   1.143 +  nsXBLPrototypeBinding* mBinding;
   1.144 +  nsXBLPrototypeHandler* mHandler; // current handler, owned by its PrototypeBinding
   1.145 +  nsXBLProtoImpl* mImplementation;
   1.146 +  nsXBLProtoImplMember* mImplMember;
   1.147 +  nsXBLProtoImplField* mImplField;
   1.148 +  nsXBLProtoImplProperty* mProperty;
   1.149 +  nsXBLProtoImplMethod* mMethod;
   1.150 +  nsXBLProtoImplField* mField;
   1.151 +};
   1.152 +
   1.153 +nsresult
   1.154 +NS_NewXBLContentSink(nsIXMLContentSink** aResult,
   1.155 +                     nsIDocument* aDoc,
   1.156 +                     nsIURI* aURL,
   1.157 +                     nsISupports* aContainer);
   1.158 +#endif // nsXBLContentSink_h__

mercurial