diff --git a/mozilla/content/xbl/public/Makefile.in b/mozilla/content/xbl/public/Makefile.in new file mode 100644 index 00000000000..1379c14a0fa --- /dev/null +++ b/mozilla/content/xbl/public/Makefile.in @@ -0,0 +1,38 @@ +# +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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 mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = layout + +EXPORTS = \ + nsIXBLService.h \ + $(NULL) + +EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) + +include $(topsrcdir)/config/rules.mk + diff --git a/mozilla/content/xbl/public/Manifest b/mozilla/content/xbl/public/Manifest new file mode 100644 index 00000000000..33bd9051c80 --- /dev/null +++ b/mozilla/content/xbl/public/Manifest @@ -0,0 +1,2 @@ +nsIXBLService.h + diff --git a/mozilla/content/xbl/public/makefile.win b/mozilla/content/xbl/public/makefile.win new file mode 100644 index 00000000000..e031b64f841 --- /dev/null +++ b/mozilla/content/xbl/public/makefile.win @@ -0,0 +1,30 @@ +#!nmake +# +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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 mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\.. + +EXPORTS = \ + nsIXBLService.h \ + $(NULL) + +MODULE=raptor + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/content/xbl/public/nsIXBLService.h b/mozilla/content/xbl/public/nsIXBLService.h new file mode 100644 index 00000000000..2311bdc26e8 --- /dev/null +++ b/mozilla/content/xbl/public/nsIXBLService.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + Private interface to the XBL service + +*/ + +#ifndef nsIXBLService_h__ +#define nsIXBLService_h__ + +#include "nsString.h" +#include "nsISupports.h" + +class nsIContent; +class nsISupportsArray; + +// {0E7903E1-C7BB-11d3-97FB-00400553EEF0} +#define NS_IXBLSERVICE_IID \ +{ 0xe7903e1, 0xc7bb, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } } + +class nsIXBLService : public nsISupports +{ +public: + static const nsIID& GetIID() { static nsIID iid = NS_IXBLSERVICE_IID; return iid; } + + // This function loads a particular XBL file and installs all of the bindings + // onto the element. + NS_IMETHOD LoadBindings(nsIContent* aContent, const nsString& aURL); + + // For a given element, returns a flat list of all the anonymous children that need + // frames built. + NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult); +}; + +#endif // nsIXBLService_h__ diff --git a/mozilla/layout/Makefile.in b/mozilla/layout/Makefile.in index d16893dde50..628aded6e99 100644 --- a/mozilla/layout/Makefile.in +++ b/mozilla/layout/Makefile.in @@ -26,7 +26,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS = base html xml xul +DIRS = base html xml xul xbl ifdef MOZ_MATHML DIRS += mathml diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index f9485eb7cd0..d704ee86c02 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -79,6 +79,9 @@ #include "nsGfxTextControlFrame.h" +#include "nsIServiceManager.h" +#include "nsIXBLService.h" + #undef NOISY_FIRST_LETTER #ifdef MOZ_MATHML @@ -3734,16 +3737,47 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell, nsIFrame* aNewFrame, nsFrameItems& aChildItems) { -/* nsCOMPtr styleContext; aNewFrame->GetStyleContext(getter_AddRefs(styleContext)); const nsStyleUserInterface* ui= (const nsStyleUserInterface*) styleContext->GetStyleData(eStyleStruct_UserInterface); - if (ui->mBehavior != "") - printf("The behavior is not the empty string!\n"); -*/ + if (ui->mBehavior != "") { + // Get the XBL loader. + nsresult rv; + NS_WITH_SERVICE(nsIXBLService, xblService, "components://netscape/xbl", &rv); + if (!xblService) + return rv; + + // Load the bindings. + xblService->LoadBindings(aParent, ui->mBehavior); + + // Retrieve the anonymous content that we should build. + nsCOMPtr anonymousItems; + xblService->GetContentList(aParent, getter_AddRefs(anonymousItems)); + + if (!anonymousItems) + return NS_OK; + + // Build the frames for the anonymous content. + PRUint32 count = 0; + anonymousItems->Count(&count); + + for (PRUint32 i=0; i < count; i++) + { + // get our child's content and set its parent to our content + nsCOMPtr node; + anonymousItems->GetElementAt(i,getter_AddRefs(node)); + + nsCOMPtr content(do_QueryInterface(node)); + + // create the frame and attach it to our frame + ConstructFrame(aPresShell, aPresContext, aState, content, aNewFrame, aChildItems); + } + + return NS_OK; + } // only these tags types can have anonymous content. We do this check for performance // reasons. If we did a query interface on every tag it would be very inefficient. diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index f9485eb7cd0..d704ee86c02 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -79,6 +79,9 @@ #include "nsGfxTextControlFrame.h" +#include "nsIServiceManager.h" +#include "nsIXBLService.h" + #undef NOISY_FIRST_LETTER #ifdef MOZ_MATHML @@ -3734,16 +3737,47 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell, nsIFrame* aNewFrame, nsFrameItems& aChildItems) { -/* nsCOMPtr styleContext; aNewFrame->GetStyleContext(getter_AddRefs(styleContext)); const nsStyleUserInterface* ui= (const nsStyleUserInterface*) styleContext->GetStyleData(eStyleStruct_UserInterface); - if (ui->mBehavior != "") - printf("The behavior is not the empty string!\n"); -*/ + if (ui->mBehavior != "") { + // Get the XBL loader. + nsresult rv; + NS_WITH_SERVICE(nsIXBLService, xblService, "components://netscape/xbl", &rv); + if (!xblService) + return rv; + + // Load the bindings. + xblService->LoadBindings(aParent, ui->mBehavior); + + // Retrieve the anonymous content that we should build. + nsCOMPtr anonymousItems; + xblService->GetContentList(aParent, getter_AddRefs(anonymousItems)); + + if (!anonymousItems) + return NS_OK; + + // Build the frames for the anonymous content. + PRUint32 count = 0; + anonymousItems->Count(&count); + + for (PRUint32 i=0; i < count; i++) + { + // get our child's content and set its parent to our content + nsCOMPtr node; + anonymousItems->GetElementAt(i,getter_AddRefs(node)); + + nsCOMPtr content(do_QueryInterface(node)); + + // create the frame and attach it to our frame + ConstructFrame(aPresShell, aPresContext, aState, content, aNewFrame, aChildItems); + } + + return NS_OK; + } // only these tags types can have anonymous content. We do this check for performance // reasons. If we did a query interface on every tag it would be very inefficient. diff --git a/mozilla/layout/makefile.win b/mozilla/layout/makefile.win index cf398c29ac0..47684857797 100644 --- a/mozilla/layout/makefile.win +++ b/mozilla/layout/makefile.win @@ -26,6 +26,7 @@ DIRS= \ html \ xml \ xul \ + xbl \ !if defined(MOZ_XSL) xsl \ !endif diff --git a/mozilla/layout/xbl/public/Makefile.in b/mozilla/layout/xbl/public/Makefile.in new file mode 100644 index 00000000000..1379c14a0fa --- /dev/null +++ b/mozilla/layout/xbl/public/Makefile.in @@ -0,0 +1,38 @@ +# +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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 mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = layout + +EXPORTS = \ + nsIXBLService.h \ + $(NULL) + +EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) + +include $(topsrcdir)/config/rules.mk + diff --git a/mozilla/layout/xbl/public/Manifest b/mozilla/layout/xbl/public/Manifest new file mode 100644 index 00000000000..33bd9051c80 --- /dev/null +++ b/mozilla/layout/xbl/public/Manifest @@ -0,0 +1,2 @@ +nsIXBLService.h + diff --git a/mozilla/layout/xbl/public/makefile.win b/mozilla/layout/xbl/public/makefile.win new file mode 100644 index 00000000000..e031b64f841 --- /dev/null +++ b/mozilla/layout/xbl/public/makefile.win @@ -0,0 +1,30 @@ +#!nmake +# +# The contents of this file are subject to the Netscape 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/NPL/ +# +# 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 mozilla.org code. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): + +DEPTH=..\..\.. + +EXPORTS = \ + nsIXBLService.h \ + $(NULL) + +MODULE=raptor + +include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/layout/xbl/public/nsIXBLService.h b/mozilla/layout/xbl/public/nsIXBLService.h new file mode 100644 index 00000000000..2311bdc26e8 --- /dev/null +++ b/mozilla/layout/xbl/public/nsIXBLService.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + + Private interface to the XBL service + +*/ + +#ifndef nsIXBLService_h__ +#define nsIXBLService_h__ + +#include "nsString.h" +#include "nsISupports.h" + +class nsIContent; +class nsISupportsArray; + +// {0E7903E1-C7BB-11d3-97FB-00400553EEF0} +#define NS_IXBLSERVICE_IID \ +{ 0xe7903e1, 0xc7bb, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } } + +class nsIXBLService : public nsISupports +{ +public: + static const nsIID& GetIID() { static nsIID iid = NS_IXBLSERVICE_IID; return iid; } + + // This function loads a particular XBL file and installs all of the bindings + // onto the element. + NS_IMETHOD LoadBindings(nsIContent* aContent, const nsString& aURL); + + // For a given element, returns a flat list of all the anonymous children that need + // frames built. + NS_IMETHOD GetContentList(nsIContent* aContent, nsISupportsArray** aResult); +}; + +#endif // nsIXBLService_h__