diff --git a/mozilla/content/xtf/public/Makefile.in b/mozilla/content/xtf/public/Makefile.in index 328f06c4d90..d7ffdf565d1 100644 --- a/mozilla/content/xtf/public/Makefile.in +++ b/mozilla/content/xtf/public/Makefile.in @@ -50,9 +50,11 @@ XPIDLSRCS = \ nsIXTFElement.idl \ nsIXTFSVGVisual.idl \ nsIXTFXMLVisual.idl \ + nsIXTFXULVisual.idl \ nsIXTFGenericElement.idl \ nsIXTFSVGVisualWrapper.idl \ nsIXTFXMLVisualWrapper.idl \ + nsIXTFXULVisualWrapper.idl \ nsIXTFGenericElementWrapper.idl \ nsIXMLContentFragment.idl \ nsIXMLContentBuilder.idl \ diff --git a/mozilla/content/xtf/public/nsIXTFElement.idl b/mozilla/content/xtf/public/nsIXTFElement.idl index 60f033b81ed..3b32e1b020f 100644 --- a/mozilla/content/xtf/public/nsIXTFElement.idl +++ b/mozilla/content/xtf/public/nsIXTFElement.idl @@ -49,6 +49,7 @@ interface nsIXTFElement : nsISupports const unsigned long ELEMENT_TYPE_GENERIC_ELEMENT = 0; const unsigned long ELEMENT_TYPE_SVG_VISUAL = 1; const unsigned long ELEMENT_TYPE_XML_VISUAL = 2; + const unsigned long ELEMENT_TYPE_XUL_VISUAL = 3; readonly attribute unsigned long elementType; diff --git a/mozilla/content/xtf/public/nsIXTFXULVisual.idl b/mozilla/content/xtf/public/nsIXTFXULVisual.idl new file mode 100644 index 00000000000..1a3e97f7ce7 --- /dev/null +++ b/mozilla/content/xtf/public/nsIXTFXULVisual.idl @@ -0,0 +1,50 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ----- BEGIN LICENSE BLOCK ----- + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Mozilla XTF project. + * + * The Initial Developer of the Original Code is + * Alex Fritze. + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alex Fritze (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ----- END LICENSE BLOCK ----- */ + +#include "nsIXTFElement.idl" +#include "nsISupportsArray.idl" + +interface nsIXTFXULVisualWrapper; + +[scriptable, uuid(d4ae63e2-bf46-4792-8ae4-5105aeab26a3)] +interface nsIXTFXULVisual : nsIXTFElement +{ + void onCreated(in nsIXTFXULVisualWrapper wrapper); + + readonly attribute nsISupportsArray visualContent; +}; diff --git a/mozilla/content/xtf/public/nsIXTFXULVisualWrapper.idl b/mozilla/content/xtf/public/nsIXTFXULVisualWrapper.idl new file mode 100644 index 00000000000..aaf62a830f6 --- /dev/null +++ b/mozilla/content/xtf/public/nsIXTFXULVisualWrapper.idl @@ -0,0 +1,48 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ----- BEGIN LICENSE BLOCK ----- + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Mozilla XTF project. + * + * The Initial Developer of the Original Code is + * Alex Fritze. + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alex Fritze (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ----- END LICENSE BLOCK ----- */ + +#include "nsISupports.idl" + +interface nsIDOMElement; + +[scriptable, uuid(b8bb0585-5b59-4e6f-9e0e-13569da1ad33)] +interface nsIXTFXULVisualWrapper : nsISupports +{ + readonly attribute nsIDOMElement elementNode; +}; + diff --git a/mozilla/content/xtf/src/Makefile.in b/mozilla/content/xtf/src/Makefile.in index 76b249fe886..3505c024cf5 100644 --- a/mozilla/content/xtf/src/Makefile.in +++ b/mozilla/content/xtf/src/Makefile.in @@ -66,6 +66,7 @@ CPPSRCS = \ nsXTFGenericElementWrapper.cpp \ nsXTFSVGVisualWrapper.cpp \ nsXTFXMLVisualWrapper.cpp \ + nsXTFXULVisualWrapper.cpp \ nsXMLContentFragment.cpp \ $(NULL) diff --git a/mozilla/content/xtf/src/nsXTFService.cpp b/mozilla/content/xtf/src/nsXTFService.cpp index 833372ab103..7c49bd68687 100644 --- a/mozilla/content/xtf/src/nsXTFService.cpp +++ b/mozilla/content/xtf/src/nsXTFService.cpp @@ -43,6 +43,7 @@ #include "nsIXTFGenericElement.h" #include "nsIXTFSVGVisual.h" #include "nsIXTFXMLVisual.h" +#include "nsIXTFXULVisual.h" #include "nsIElementFactory.h" #include "nsString.h" #include "nsINodeInfo.h" @@ -50,6 +51,7 @@ #include "nsXTFGenericElementWrapper.h" #include "nsXTFSVGVisualWrapper.h" #include "nsXTFXMLVisualWrapper.h" +#include "nsXTFXULVisualWrapper.h" //////////////////////////////////////////////////////////////////////// // nsXTFElementFactoryWrapper class @@ -145,6 +147,12 @@ nsXTFElementFactoryWrapper::CreateInstanceByTag(nsINodeInfo *aNodeInfo, return NS_NewXTFXMLVisualWrapper(elem2, aNodeInfo, aResult); break; } + case nsIXTFElement::ELEMENT_TYPE_XUL_VISUAL: + { + nsCOMPtr elem2 = do_QueryInterface(elem); + return NS_NewXTFXULVisualWrapper(elem2, aNodeInfo, aResult); + break; + } default: NS_ERROR("unknown xtf element type"); break; diff --git a/mozilla/content/xtf/src/nsXTFXULVisualWrapper.cpp b/mozilla/content/xtf/src/nsXTFXULVisualWrapper.cpp new file mode 100644 index 00000000000..ac6bd3b7917 --- /dev/null +++ b/mozilla/content/xtf/src/nsXTFXULVisualWrapper.cpp @@ -0,0 +1,552 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ----- BEGIN LICENSE BLOCK ----- + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Mozilla XTF project. + * + * The Initial Developer of the Original Code is + * Alex Fritze. + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Alex Fritze (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ----- END LICENSE BLOCK ----- */ + +#include "nsCOMPtr.h" +#include "nsIXTFXULVisual.h" +#include "nsString.h" +#include "nsXMLElement.h" +#include "nsIAnonymousContentCreator.h" +#include "nsXTFInterfaceAggregator.h" +#include "nsXTFWeakTearoff.h" +#include "nsIClassInfo.h" +#include "nsIXTFXULVisualWrapper.h" +//XXX get rid of this: +#include "nsSVGAtoms.h" + +typedef nsXMLElement nsXTFXULVisualWrapperBase; + +//////////////////////////////////////////////////////////////////////// +// nsXTFXULVisualWrapper class +class nsXTFXULVisualWrapper : public nsXTFXULVisualWrapperBase, + public nsIClassInfo, + public nsIAnonymousContentCreator, + public nsIXTFXULVisualWrapper +{ +protected: + friend nsresult + NS_NewXTFXULVisualWrapper(nsIXTFXULVisual* xtfElement, + nsINodeInfo* ni, + nsIContent** aResult); + + nsXTFXULVisualWrapper(nsIXTFXULVisual* xtfElement); + virtual ~nsXTFXULVisualWrapper(); + nsresult Init(nsINodeInfo*ni); + +public: + // nsISupports interface + NS_DECL_ISUPPORTS_INHERITED + + // nsIContent specialisations: + void SetDocument(nsIDocument* aDocument, PRBool aDeep, + PRBool aCompileEventHandlers); + void SetParent(nsIContent* aParent); + nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, + PRBool aNotify, PRBool aDeepSetDocument); + nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, + PRBool aNotify, PRBool aDeepSetDocument); + nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument); + nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); + nsIAtom *GetIDAttributeName() const; + nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + PRBool aNotify); + nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr, + PRBool aNotify); + + // nsIClassInfo interface + NS_DECL_NSICLASSINFO + + // nsIXTFXULVisualWrapper interface + NS_DECL_NSIXTFXULVISUALWRAPPER + + // nsIAnonymousContentCreator + NS_IMETHOD CreateAnonymousContent(nsIPresContext* aPresContext, + nsISupportsArray& aAnonymousItems); + + // If the creator doesn't want to create special frame for frame hierarchy + // then it should null out the style content arg and return NS_ERROR_FAILURE + NS_IMETHOD CreateFrameFor(nsIPresContext* aPresContext, + nsIContent * aContent, + nsIFrame** aFrame) { + if (aFrame) *aFrame = nsnull; return NS_ERROR_FAILURE; } + +private: + // implementation helpers: + PRBool AggregatesInterface(REFNSIID aIID); + + + nsCOMPtr mXTFElement; +}; + +//---------------------------------------------------------------------- +// implementation: + +nsXTFXULVisualWrapper::nsXTFXULVisualWrapper(nsIXTFXULVisual* xtfElement) + : mXTFElement(xtfElement) +{ +#ifdef DEBUG + printf("nsXTFXULVisualWrapper CTOR\n"); +#endif +} + +nsresult +nsXTFXULVisualWrapper::Init(nsINodeInfo* ni) +{ + nsresult rv = nsXTFXULVisualWrapperBase::Init(ni); + + // pass a weak wrapper (non base object ref-counted), so that + // our mXTFElement can safely addref/release. + nsISupports *weakWrapper=nsnull; + NS_NewXTFWeakTearoff(NS_GET_IID(nsIXTFXULVisualWrapper), + (nsIXTFXULVisualWrapper*)this, + &weakWrapper); + mXTFElement->OnCreated((nsIXTFXULVisualWrapper*)weakWrapper); + weakWrapper->Release(); + + return rv; +} + +nsXTFXULVisualWrapper::~nsXTFXULVisualWrapper() +{ + mXTFElement->OnDestroyed(); + mXTFElement = nsnull; + +#ifdef DEBUG + printf("nsXTFXULVisualWrapper DTOR\n"); +#endif +} + +nsresult +NS_NewXTFXULVisualWrapper(nsIXTFXULVisual* xtfElement, + nsINodeInfo* ni, + nsIContent** aResult) +{ + NS_PRECONDITION(aResult != nsnull, "null ptr"); + if (!aResult) + return NS_ERROR_NULL_POINTER; + + if (!xtfElement) { + NS_ERROR("can't construct an xtf wrapper without an xtf element"); + return NS_ERROR_FAILURE; + } + + nsXTFXULVisualWrapper* result = new nsXTFXULVisualWrapper(xtfElement); + if (! result) + return NS_ERROR_OUT_OF_MEMORY; + + NS_ADDREF(result); + + // XXX this might fail. + result->Init(ni); + + *aResult = result; + return NS_OK; +} + +//---------------------------------------------------------------------- +// nsISupports implementation + + +NS_IMPL_ADDREF_INHERITED(nsXTFXULVisualWrapper,nsXTFXULVisualWrapperBase) +NS_IMPL_RELEASE_INHERITED(nsXTFXULVisualWrapper,nsXTFXULVisualWrapperBase) + +NS_IMETHODIMP +nsXTFXULVisualWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (AggregatesInterface(aIID)) { +#ifdef DEBUG + printf("nsXTFXULVisualWrapper::QueryInterface(): creating aggregation tearoff\n"); +#endif + return NS_NewXTFInterfaceAggregator(aIID, mXTFElement, (nsIContent*)this, + (nsISupports**)aInstancePtr); + } + else if(aIID.Equals(NS_GET_IID(nsIClassInfo))) { + *aInstancePtr = NS_STATIC_CAST(nsIClassInfo*, this); + NS_ADDREF_THIS(); + return NS_OK; + } + else if(aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) { + *aInstancePtr = NS_STATIC_CAST(nsIAnonymousContentCreator*, this); + NS_ADDREF_THIS(); + return NS_OK; + } + else if(aIID.Equals(NS_GET_IID(nsIXTFXULVisualWrapper))) { + *aInstancePtr = NS_STATIC_CAST(nsIXTFXULVisualWrapper*, this); + NS_ADDREF_THIS(); + return NS_OK; + } + else + return nsXTFXULVisualWrapperBase::QueryInterface(aIID, aInstancePtr); +} + +//---------------------------------------------------------------------- +// nsIContent: + +void +nsXTFXULVisualWrapper::SetDocument(nsIDocument* aDocument, PRBool aDeep, + PRBool aCompileEventHandlers) +{ + mXTFElement->WillChangeDocument(aDocument); + nsXTFXULVisualWrapperBase::SetDocument(aDocument, aDeep, aCompileEventHandlers); + mXTFElement->DocumentChanged(aDocument); +} + +void +nsXTFXULVisualWrapper::SetParent(nsIContent* aParent) +{ + mXTFElement->WillChangeParent(aParent); + nsXTFXULVisualWrapperBase::SetParent(aParent); + mXTFElement->ParentChanged(aParent); +} + +nsresult +nsXTFXULVisualWrapper::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, + PRBool aNotify, PRBool aDeepSetDocument) +{ + nsresult rv; + mXTFElement->WillInsertChild(aKid, aIndex); + rv = nsXTFXULVisualWrapperBase::InsertChildAt(aKid, aIndex, aNotify, aDeepSetDocument); + mXTFElement->ChildInserted(aKid, aIndex); + return rv; +} + +nsresult +nsXTFXULVisualWrapper::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, + PRBool aNotify, PRBool aDeepSetDocument) +{ + nsresult rv; + mXTFElement->WillReplaceChild(aKid, aIndex); + rv = nsXTFXULVisualWrapperBase::ReplaceChildAt(aKid, aIndex, aNotify, aDeepSetDocument); + mXTFElement->ChildReplaced(aKid, aIndex); + return rv; +} + +nsresult +nsXTFXULVisualWrapper::AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) +{ + nsresult rv; + mXTFElement->WillAppendChild(aKid); + rv = nsXTFXULVisualWrapperBase::AppendChildTo(aKid, aNotify, aDeepSetDocument); + mXTFElement->ChildAppended(aKid); + return rv; +} + +nsresult +nsXTFXULVisualWrapper::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) +{ + nsresult rv; + mXTFElement->WillRemoveChild(aIndex); + rv = nsXTFXULVisualWrapperBase::RemoveChildAt(aIndex, aNotify); + mXTFElement->ChildRemoved(aIndex); + return rv; +} + +nsIAtom * +nsXTFXULVisualWrapper::GetIDAttributeName() const +{ + // XXX: + return nsSVGAtoms::id; +} + +nsresult +nsXTFXULVisualWrapper::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + PRBool aNotify) +{ + nsAutoString name; + aName->ToString(name); + + nsresult rv; + mXTFElement->WillSetAttribute(name, aValue); + rv = nsXTFXULVisualWrapperBase::SetAttr(aNameSpaceID, aName, aPrefix, aValue, aNotify); + mXTFElement->AttributeSet(name, aValue); + return rv; +} + +nsresult +nsXTFXULVisualWrapper::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr, + PRBool aNotify) +{ + nsAutoString name; + aAttr->ToString(name); + + nsresult rv; + mXTFElement->WillUnsetAttribute(name); + rv = nsXTFXULVisualWrapperBase::UnsetAttr(aNameSpaceID, aAttr, aNotify); + mXTFElement->AttributeUnset(name); + return rv; +} + +//---------------------------------------------------------------------- +// nsIClassInfo implementation + +/* void getInterfaces (out PRUint32 count, [array, size_is (count), retval] out nsIIDPtr array); */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetInterfaces(PRUint32 *count, nsIID * **array) +{ + return mXTFElement->GetScriptingInterfaces(count, array); +} + +/* nsISupports getHelperForLanguage (in PRUint32 language); */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetHelperForLanguage(PRUint32 language, nsISupports **_retval) +{ + *_retval = nsnull; + return NS_OK; +} + +/* readonly attribute string contractID; */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetContractID(char * *aContractID) +{ + *aContractID = nsnull; + return NS_OK; +} + +/* readonly attribute string classDescription; */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetClassDescription(char * *aClassDescription) +{ + *aClassDescription = nsnull; + return NS_OK; +} + +/* readonly attribute nsCIDPtr classID; */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetClassID(nsCID * *aClassID) +{ + *aClassID = nsnull; + return NS_OK; +} + +/* readonly attribute PRUint32 implementationLanguage; */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetImplementationLanguage(PRUint32 *aImplementationLanguage) +{ + *aImplementationLanguage = nsIProgrammingLanguage::UNKNOWN; + return NS_OK; +} + +/* readonly attribute PRUint32 flags; */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetFlags(PRUint32 *aFlags) +{ + *aFlags = nsIClassInfo::DOM_OBJECT; + return NS_OK; +} + +/* [notxpcom] readonly attribute nsCID classIDNoAlloc; */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) +{ + return NS_ERROR_NOT_AVAILABLE; +} + +//---------------------------------------------------------------------- +// nsIXTFXULVisualWrapper implementation: + +/* readonly attribute nsIDOMElement elementNode; */ +NS_IMETHODIMP +nsXTFXULVisualWrapper::GetElementNode(nsIDOMElement * *aElementNode) +{ + *aElementNode = (nsIDOMElement*)this; + NS_ADDREF(*aElementNode); + return NS_OK; +} + + +//---------------------------------------------------------------------- +// nsIAnonymousContentCreator implementation: + +NS_IMETHODIMP +nsXTFXULVisualWrapper::CreateAnonymousContent(nsIPresContext* aPresContext, + nsISupportsArray& aAnonymousItems) +{ + nsCOMPtr arr; + mXTFElement->GetVisualContent(getter_AddRefs(arr)); + aAnonymousItems.AppendElements(arr); + +// NS_ASSERTION(mDocument, "no document; cannot create anonymous content"); + +// nsCOMPtr nim; +// mDocument->GetNodeInfoManager(*getter_AddRefs(nim)); + +// nsCOMPtr nsm; +// nsServiceManager::GetService(kNameSpaceManagerCID, +// NS_GET_IID(nsINameSpaceManager), +// getter_AddRefs(nsm)); + +// XTLContentDescriptor* cd = GetViewDescription().mDescriptorTree; + +// // see if we're using the primary press shell or not +// nsCOMPtr presShell, primaryShell; +// aPresContext->GetShell(getter_AddRefs(presShell)); + +// mDocument->GetShellAt(0, getter_AddRefs(primaryShell)); +// bool isPrimaryShell = (primaryShell == presShell); + +// // ensure we clear out the old inheritedAttributes map +// mInheritedAttributes.clear(); + +// bool is_root=true; +// if (! isPrimaryShell) { // don't build content, just clone what we have +// #ifdef DEBUG +// // assert if someone tries this with multiple top-level content descriptors +// int contentDescriptorCount=0; +// for (; cd != NULL; cd = cd->nextSibling) ++contentDescriptorCount; +// NS_ASSERTION(contentDescriptorCount==1, "nsXTFXULVisualWrapper::CreateAnonymousContent: \ +// multiple top level elements not supported at present"); +// #endif +// nsCOMPtr clonedViewTree; +// nsresult rv = mViewTree->CloneNode(PR_TRUE, getter_AddRefs(clonedViewTree)); +// if (NS_FAILED(rv)) return rv; + +// aAnonymousItems.AppendElement(clonedViewTree); +// return NS_OK; +// } + +// while (cd) { +// nsCOMPtr content; +// CreateContentElement(cd->mNamespaceID, cd->mTag,cd->firstAttribute, nim, nsm, getter_AddRefs(content)); + +// NS_ASSERTION(content, "could not create content"); + +// if (is_root && content) { +// // map first element to member variable: +// content->QueryInterface(nsIDOMElement::GetIID(), getter_AddRefs(mViewTree)); +// is_root=false; +// } + +// if ( cd->firstChild ) +// CreateNode( content, cd->firstChild, nim, nsm ); + +// aAnonymousItems.AppendElement(content); +// cd = cd->nextSibling; +// } + +// ViewTreeConstructedHook(); + + return NS_OK; +} + +// void nsXTFXULVisualWrapper::CreateNode(nsIContent* parent, XTLContentDescriptor* descriptor, +// nsINodeInfoManager* nim, nsINameSpaceManager* nsm, +// nsIDOMNode**node) +// { +// nsCOMPtr content; +// CreateContentElement(descriptor->mNamespaceID, descriptor->mTag, descriptor->firstAttribute, +// nim, nsm, getter_AddRefs(content)); +// NS_ASSERTION(content, "could not create content"); +// if (content && node) { +// content->QueryInterface(nsIDOMNode::GetIID(), (void**)node); +// } + +// // iterate over children, if there are any +// if (descriptor->firstChild) +// CreateNode(content, descriptor->firstChild, nim, nsm); + +// // append ourselves to +// parent->AppendChildTo( content, false, true ); + +// // iterate over siblings: +// if (descriptor->nextSibling) +// CreateNode(parent, descriptor->nextSibling, nim, nsm); +// } + +// void nsXTFXULVisualWrapper::CreateContentElement(PRInt32 ns, nsIAtom* tagname, XTLAttributeDescriptor* attribs, +// nsINodeInfoManager* nim, +// nsINameSpaceManager* nsm, nsIContent **content) +// { +// nsCOMPtr elementFactory; +// nsm->GetElementFactory(ns, getter_AddRefs(elementFactory)); +// if (!elementFactory) { +// NS_ERROR("no element factory in nsXTFXULVisualWrapper"); +// return; +// } + +// nsCOMPtr nodeinfo; +// nim->GetNodeInfo(tagname, nsnull, ns, *getter_AddRefs(nodeinfo)); + +// elementFactory->CreateInstanceByTag(nodeinfo, content); +// while (attribs) { +// if (!attribs->mIsInherited) +// (*content)->SetAttr(kNameSpaceID_None, attribs->mName, attribs->mValue, PR_FALSE); +// else { + +// mInheritedAttributes.insert( std::pair< nsCOMPtr, Content >( attribs->mName, Content( attribs->mMapTo, *content ) ) ); + +// nsString value; +// GetAttr(kNameSpaceID_None, attribs->mName, value); +// (*content)->SetAttr(kNameSpaceID_None, attribs->mMapTo, value, PR_FALSE); +// } +// attribs = attribs->nextSibling; +// } + +// } + +//---------------------------------------------------------------------- +// implementation helpers: +PRBool +nsXTFXULVisualWrapper::AggregatesInterface(REFNSIID aIID) +{ + nsCOMPtr inst; + mXTFElement->QueryInterface(aIID, getter_AddRefs(inst)); + return (inst!=nsnull); +// // we aggregate all interfaces declared as 'public' in our inner +// // object: +// // XXX we call this so often, it should almost certainly be hashed. +// PRUint32 count=0; +// nsIID **iids=nsnull; + +// mXTFElement->GetPublicInterfaces(&count, &iids); +// for (int i=0; i (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ----- END LICENSE BLOCK ----- */ + +#ifndef __NS_XTFXULVISUALWRAPPER_H__ +#define __NS_XTFXULVISUALWRAPPER_H__ + +class nsIXTFXULVisual; +class nsIContent; +class nsINodeInfo; + +nsresult +NS_NewXTFXULVisualWrapper(nsIXTFXULVisual* xtfElement, + nsINodeInfo* ni, + nsIContent** aResult); + +#endif // __NS_XTFXULVISUALWRAPPER_H__ diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 0b0b2d6dbee..ac62b07280f 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -6779,15 +6779,20 @@ nsCSSFrameConstructor::ConstructXTFFrame(nsIPresShell* aPresShell, xtfElem->GetElementType(&elementType); switch(elementType) { case nsIXTFElement::ELEMENT_TYPE_SVG_VISUAL: - processChildren = PR_TRUE; rv = NS_NewXTFSVGDisplayFrame(aPresShell, aContent, &newFrame); break; + case nsIXTFElement::ELEMENT_TYPE_XML_VISUAL: + // XXX examine display style + rv = NS_NewBlockFrame(aPresShell, &newFrame); + break; + case nsIXTFElement::ELEMENT_TYPE_XUL_VISUAL: + rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, nsnull); + break; case nsIXTFElement::ELEMENT_TYPE_GENERIC_ELEMENT: NS_ERROR("huh? ELEMENT_TYPE_GENERIC_ELEMENT should have been flagged by caller"); break; - case nsIXTFElement::ELEMENT_TYPE_XML_VISUAL: default: - // just let the caller generate a default frame + NS_ERROR("unknown xtf frame!"); return NS_OK; } @@ -6809,14 +6814,16 @@ nsCSSFrameConstructor::ConstructXTFFrame(nsIPresShell* aPresShell, if (processChildren) { rv = ProcessChildren(aPresShell, aPresContext, aState, aContent, newFrame, PR_TRUE, childItems, isBlock); - -// CreateAnonymousFrames(aPresShell, aPresContext, aTag, aState, aContent, newFrame, -// PR_FALSE, childItems); - // don't check tag: - CreateAnonymousFrames(aPresShell, aPresContext, aState, aContent, mDocument, newFrame, - PR_FALSE, childItems); } + // always create anonymous frames: + +// CreateAnonymousFrames(aPresShell, aPresContext, aTag, aState, aContent, newFrame, +// PR_FALSE, childItems); + // call version of CreateAnonymousFrames that doesn't check tag: + CreateAnonymousFrames(aPresShell, aPresContext, aState, aContent, mDocument, newFrame, + PR_FALSE, childItems); + // Set the frame's initial child list newFrame->SetInitialChildList(aPresContext, nsnull, childItems.childList);