LCOV - code coverage report
Current view: top level - dom/xbl - nsXBLContentSink.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef nsXBLContentSink_h__
       8             : #define nsXBLContentSink_h__
       9             : 
      10             : #include "mozilla/Attributes.h"
      11             : #include "nsXMLContentSink.h"
      12             : #include "nsXBLDocumentInfo.h"
      13             : #include "nsXBLPrototypeHandler.h"
      14             : #include "nsXBLProtoImpl.h"
      15             : #include "nsLayoutCID.h"
      16             : 
      17             : /*
      18             :  * Enum that describes the primary state of the parsing process
      19             :  */
      20             : typedef enum {
      21             :   eXBL_InDocument,       /* outside any bindings */
      22             :   eXBL_InBindings,       /* Inside a <bindings> element */
      23             :   eXBL_InBinding,        /* Inside a <binding> */
      24             :   eXBL_InResources,      /* Inside a <resources> */
      25             :   eXBL_InImplementation, /* Inside a <implementation> */
      26             :   eXBL_InHandlers,       /* Inside a <handlers> */
      27             :   eXBL_Error             /* An error has occurred.  Suspend binding construction */
      28             : } XBLPrimaryState;
      29             : 
      30             : /*
      31             :  * Enum that describes our substate (typically when parsing something
      32             :  * like <handlers> or <implementation>).
      33             :  */
      34             : typedef enum {
      35             :   eXBL_None,
      36             :   eXBL_InHandler,
      37             :   eXBL_InMethod,
      38             :   eXBL_InProperty,
      39             :   eXBL_InField,
      40             :   eXBL_InBody,
      41             :   eXBL_InGetter,
      42             :   eXBL_InSetter,
      43             :   eXBL_InConstructor,
      44             :   eXBL_InDestructor
      45             : } XBLSecondaryState;
      46             : 
      47             : class nsXULPrototypeElement;
      48             : class nsXBLProtoImplMember;
      49             : class nsXBLProtoImplProperty;
      50             : class nsXBLProtoImplMethod;
      51             : class nsXBLProtoImplField;
      52             : class nsXBLPrototypeBinding;
      53             : 
      54             : // The XBL content sink overrides the XML content sink to
      55             : // builds its own lightweight data structures for the <resources>,
      56             : // <handlers>, <implementation>, and
      57             : 
      58             : class nsXBLContentSink : public nsXMLContentSink {
      59             : public:
      60             :   nsXBLContentSink();
      61             :   ~nsXBLContentSink();
      62             : 
      63             :   nsresult Init(nsIDocument* aDoc,
      64             :                 nsIURI* aURL,
      65             :                 nsISupports* aContainer);
      66             : 
      67             :   // nsIContentSink overrides
      68             :   NS_IMETHOD HandleStartElement(const char16_t *aName,
      69             :                                 const char16_t **aAtts,
      70             :                                 uint32_t aAttsCount,
      71             :                                 uint32_t aLineNumber) override;
      72             : 
      73             :   NS_IMETHOD HandleEndElement(const char16_t *aName) override;
      74             : 
      75             :   NS_IMETHOD HandleCDataSection(const char16_t *aData,
      76             :                                 uint32_t aLength) override;
      77             : 
      78             : protected:
      79             :     // nsXMLContentSink overrides
      80             :     virtual void MaybeStartLayout(bool aIgnorePendingSheets) override;
      81             : 
      82             :     bool OnOpenContainer(const char16_t **aAtts,
      83             :                            uint32_t aAttsCount,
      84             :                            int32_t aNameSpaceID,
      85             :                            nsIAtom* aTagName,
      86             :                            uint32_t aLineNumber) override;
      87             : 
      88           1 :     bool NotifyForDocElement() override { return false; }
      89             : 
      90             :     nsresult CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
      91             :                            mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
      92             :                            nsIContent** aResult, bool* aAppendContent,
      93             :                            mozilla::dom::FromParser aFromParser) override;
      94             : 
      95             :     nsresult AddAttributes(const char16_t** aAtts,
      96             :                            nsIContent* aContent) override;
      97             : 
      98             : #ifdef MOZ_XUL
      99             :     nsresult AddAttributesToXULPrototype(const char16_t **aAtts,
     100             :                                          uint32_t aAttsCount,
     101             :                                          nsXULPrototypeElement* aElement);
     102             : #endif
     103             : 
     104             :     // Our own helpers for constructing XBL prototype objects.
     105             :     nsresult ConstructBinding(uint32_t aLineNumber);
     106             :     void ConstructHandler(const char16_t **aAtts, uint32_t aLineNumber);
     107             :     void ConstructResource(const char16_t **aAtts, nsIAtom* aResourceType);
     108             :     void ConstructImplementation(const char16_t **aAtts);
     109             :     void ConstructProperty(const char16_t **aAtts, uint32_t aLineNumber);
     110             :     void ConstructMethod(const char16_t **aAtts);
     111             :     void ConstructParameter(const char16_t **aAtts);
     112             :     void ConstructField(const char16_t **aAtts, uint32_t aLineNumber);
     113             : 
     114             : 
     115             :   // nsXMLContentSink overrides
     116             :   nsresult FlushText(bool aReleaseTextNode = true) override;
     117             : 
     118             :   // nsIExpatSink overrides
     119             :   NS_IMETHOD ReportError(const char16_t* aErrorText,
     120             :                          const char16_t* aSourceText,
     121             :                          nsIScriptError *aError,
     122             :                          bool *_retval) override;
     123             : 
     124             : protected:
     125             :   nsresult ReportUnexpectedElement(nsIAtom* aElementName, uint32_t aLineNumber);
     126             : 
     127             :   void AddMember(nsXBLProtoImplMember* aMember);
     128             :   void AddField(nsXBLProtoImplField* aField);
     129             : 
     130             :   XBLPrimaryState mState;
     131             :   XBLSecondaryState mSecondaryState;
     132             :   nsXBLDocumentInfo* mDocInfo;
     133             :   bool mIsChromeOrResource; // For bug #45989
     134             :   bool mFoundFirstBinding;
     135             : 
     136             :   nsString mCurrentBindingID;
     137             : 
     138             :   nsXBLPrototypeBinding* mBinding;
     139             :   nsXBLPrototypeHandler* mHandler; // current handler, owned by its PrototypeBinding
     140             :   nsXBLProtoImpl* mImplementation;
     141             :   nsXBLProtoImplMember* mImplMember;
     142             :   nsXBLProtoImplField* mImplField;
     143             :   nsXBLProtoImplProperty* mProperty;
     144             :   nsXBLProtoImplMethod* mMethod;
     145             :   nsXBLProtoImplField* mField;
     146             : };
     147             : 
     148             : nsresult
     149             : NS_NewXBLContentSink(nsIXMLContentSink** aResult,
     150             :                      nsIDocument* aDoc,
     151             :                      nsIURI* aURL,
     152             :                      nsISupports* aContainer);
     153             : #endif // nsXBLContentSink_h__

Generated by: LCOV version 1.13