2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-11-02 04:53:13 +03:00
|
|
|
|
|
|
|
#ifndef nsXBLContentSink_h__
|
|
|
|
#define nsXBLContentSink_h__
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2001-11-02 04:53:13 +03:00
|
|
|
#include "nsXMLContentSink.h"
|
|
|
|
#include "nsXBLDocumentInfo.h"
|
2003-02-28 04:04:45 +03:00
|
|
|
#include "nsXBLPrototypeHandler.h"
|
2001-11-13 07:09:56 +03:00
|
|
|
#include "nsXBLProtoImpl.h"
|
2001-11-03 13:12:20 +03:00
|
|
|
#include "nsLayoutCID.h"
|
2001-11-02 04:53:13 +03:00
|
|
|
|
2004-01-06 21:30:45 +03:00
|
|
|
/*
|
|
|
|
* Enum that describes the primary state of the parsing process
|
|
|
|
*/
|
2001-11-02 04:53:13 +03:00
|
|
|
typedef enum {
|
2004-01-06 21:30:45 +03:00
|
|
|
eXBL_InDocument, /* outside any bindings */
|
|
|
|
eXBL_InBindings, /* Inside a <bindings> element */
|
|
|
|
eXBL_InBinding, /* Inside a <binding> */
|
|
|
|
eXBL_InResources, /* Inside a <resources> */
|
|
|
|
eXBL_InImplementation, /* Inside a <implementation> */
|
|
|
|
eXBL_InHandlers, /* Inside a <handlers> */
|
2010-05-13 16:19:50 +04:00
|
|
|
eXBL_Error /* An error has occurred. Suspend binding construction */
|
2001-11-02 04:53:13 +03:00
|
|
|
} XBLPrimaryState;
|
|
|
|
|
2004-01-06 21:30:45 +03:00
|
|
|
/*
|
|
|
|
* Enum that describes our substate (typically when parsing something
|
|
|
|
* like <handlers> or <implementation>).
|
|
|
|
*/
|
2001-11-02 04:53:13 +03:00
|
|
|
typedef enum {
|
|
|
|
eXBL_None,
|
|
|
|
eXBL_InHandler,
|
|
|
|
eXBL_InMethod,
|
|
|
|
eXBL_InProperty,
|
|
|
|
eXBL_InField,
|
|
|
|
eXBL_InBody,
|
|
|
|
eXBL_InGetter,
|
2001-11-13 07:09:56 +03:00
|
|
|
eXBL_InSetter,
|
|
|
|
eXBL_InConstructor,
|
|
|
|
eXBL_InDestructor
|
2001-11-02 04:53:13 +03:00
|
|
|
} XBLSecondaryState;
|
|
|
|
|
2001-11-03 13:12:20 +03:00
|
|
|
class nsXULPrototypeElement;
|
2001-11-13 07:09:56 +03:00
|
|
|
class nsXBLProtoImplMember;
|
|
|
|
class nsXBLProtoImplProperty;
|
|
|
|
class nsXBLProtoImplMethod;
|
|
|
|
class nsXBLProtoImplField;
|
2003-03-07 02:59:18 +03:00
|
|
|
class nsXBLPrototypeBinding;
|
2001-11-03 13:12:20 +03:00
|
|
|
|
2001-11-02 04:53:13 +03:00
|
|
|
// The XBL content sink overrides the XML content sink to
|
|
|
|
// builds its own lightweight data structures for the <resources>,
|
|
|
|
// <handlers>, <implementation>, and
|
|
|
|
|
|
|
|
class nsXBLContentSink : public nsXMLContentSink {
|
|
|
|
public:
|
|
|
|
nsXBLContentSink();
|
|
|
|
~nsXBLContentSink();
|
|
|
|
|
2007-02-02 05:12:48 +03:00
|
|
|
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
|
|
|
|
2001-11-02 04:53:13 +03:00
|
|
|
nsresult Init(nsIDocument* aDoc,
|
|
|
|
nsIURI* aURL,
|
2003-04-03 22:57:33 +04:00
|
|
|
nsISupports* aContainer);
|
2001-11-02 04:53:13 +03:00
|
|
|
|
|
|
|
// nsIContentSink overrides
|
2014-01-04 19:02:17 +04:00
|
|
|
NS_IMETHOD HandleStartElement(const char16_t *aName,
|
|
|
|
const char16_t **aAtts,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aAttsCount,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aLineNumber) override;
|
2002-01-09 04:37:50 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD HandleEndElement(const char16_t *aName) override;
|
2002-01-09 04:37:50 +03:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
NS_IMETHOD HandleCDataSection(const char16_t *aData,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aLength) override;
|
2001-11-02 04:53:13 +03:00
|
|
|
|
|
|
|
protected:
|
2002-01-09 04:37:50 +03:00
|
|
|
// nsXMLContentSink overrides
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void MaybeStartLayout(bool aIgnorePendingSheets) override;
|
2007-01-31 00:21:06 +03:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
bool OnOpenContainer(const char16_t **aAtts,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aAttsCount,
|
|
|
|
int32_t aNameSpaceID,
|
2003-06-24 05:20:40 +04:00
|
|
|
nsIAtom* aTagName,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aLineNumber) override;
|
2010-05-03 17:23:36 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
bool NotifyForDocElement() override { return false; }
|
2010-05-03 17:23:36 +04:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
nsresult CreateElement(const char16_t** aAtts, uint32_t aAttsCount,
|
2014-06-20 06:01:40 +04:00
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, uint32_t aLineNumber,
|
2011-09-29 10:19:26 +04:00
|
|
|
nsIContent** aResult, bool* aAppendContent,
|
2015-03-21 19:28:04 +03:00
|
|
|
mozilla::dom::FromParser aFromParser) override;
|
2002-01-09 04:37:50 +03:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
nsresult AddAttributes(const char16_t** aAtts,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIContent* aContent) override;
|
2003-04-11 04:56:27 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
2014-01-04 19:02:17 +04:00
|
|
|
nsresult AddAttributesToXULPrototype(const char16_t **aAtts,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aAttsCount,
|
2002-01-09 04:37:50 +03:00
|
|
|
nsXULPrototypeElement* aElement);
|
2003-04-11 04:56:27 +04:00
|
|
|
#endif
|
|
|
|
|
2002-01-09 04:37:50 +03:00
|
|
|
// Our own helpers for constructing XBL prototype objects.
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult ConstructBinding(uint32_t aLineNumber);
|
2014-01-04 19:02:17 +04:00
|
|
|
void ConstructHandler(const char16_t **aAtts, uint32_t aLineNumber);
|
|
|
|
void ConstructResource(const char16_t **aAtts, nsIAtom* aResourceType);
|
|
|
|
void ConstructImplementation(const char16_t **aAtts);
|
|
|
|
void ConstructProperty(const char16_t **aAtts, uint32_t aLineNumber);
|
|
|
|
void ConstructMethod(const char16_t **aAtts);
|
|
|
|
void ConstructParameter(const char16_t **aAtts);
|
|
|
|
void ConstructField(const char16_t **aAtts, uint32_t aLineNumber);
|
2002-01-09 04:37:50 +03:00
|
|
|
|
|
|
|
|
2001-11-02 04:53:13 +03:00
|
|
|
// nsXMLContentSink overrides
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult FlushText(bool aReleaseTextNode = true) override;
|
2002-08-06 16:55:44 +04:00
|
|
|
|
|
|
|
// nsIExpatSink overrides
|
2014-01-04 19:02:17 +04:00
|
|
|
NS_IMETHOD ReportError(const char16_t* aErrorText,
|
|
|
|
const char16_t* aSourceText,
|
2006-08-25 20:34:57 +04:00
|
|
|
nsIScriptError *aError,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool *_retval) override;
|
2002-08-06 16:55:44 +04:00
|
|
|
|
2001-11-02 04:53:13 +03:00
|
|
|
protected:
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult ReportUnexpectedElement(nsIAtom* aElementName, uint32_t aLineNumber);
|
2004-09-10 19:29:19 +04:00
|
|
|
|
|
|
|
void AddMember(nsXBLProtoImplMember* aMember);
|
2007-09-28 17:45:01 +04:00
|
|
|
void AddField(nsXBLProtoImplField* aField);
|
2004-01-06 21:30:45 +03:00
|
|
|
|
2001-11-02 04:53:13 +03:00
|
|
|
XBLPrimaryState mState;
|
|
|
|
XBLSecondaryState mSecondaryState;
|
2010-07-15 05:53:11 +04:00
|
|
|
nsXBLDocumentInfo* mDocInfo;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsChromeOrResource; // For bug #45989
|
|
|
|
bool mFoundFirstBinding;
|
2001-11-02 04:53:13 +03:00
|
|
|
|
2013-08-22 03:45:52 +04:00
|
|
|
nsString mCurrentBindingID;
|
|
|
|
|
2003-03-07 02:59:18 +03:00
|
|
|
nsXBLPrototypeBinding* mBinding;
|
2003-02-28 04:04:45 +03:00
|
|
|
nsXBLPrototypeHandler* mHandler; // current handler, owned by its PrototypeBinding
|
2001-11-13 07:09:56 +03:00
|
|
|
nsXBLProtoImpl* mImplementation;
|
|
|
|
nsXBLProtoImplMember* mImplMember;
|
2007-09-28 17:45:01 +04:00
|
|
|
nsXBLProtoImplField* mImplField;
|
2001-11-13 07:09:56 +03:00
|
|
|
nsXBLProtoImplProperty* mProperty;
|
|
|
|
nsXBLProtoImplMethod* mMethod;
|
|
|
|
nsXBLProtoImplField* mField;
|
2001-11-02 04:53:13 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewXBLContentSink(nsIXMLContentSink** aResult,
|
|
|
|
nsIDocument* aDoc,
|
|
|
|
nsIURI* aURL,
|
2003-04-03 22:57:33 +04:00
|
|
|
nsISupports* aContainer);
|
2001-11-02 04:53:13 +03:00
|
|
|
#endif // nsXBLContentSink_h__
|