From 3aeb5cb791d6e6fa5b1551ab45067d7411b882dc Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Thu, 13 Jan 2000 08:54:16 +0000 Subject: [PATCH] Stubbing out some more XBL functions for future implementation. --- content/xbl/public/nsIXBLBinding.h | 3 +++ content/xbl/src/nsXBLBinding.cpp | 16 ++++++++++++++++ content/xbl/src/nsXBLService.cpp | 16 +++++++++++++--- layout/xbl/public/nsIXBLBinding.h | 3 +++ layout/xbl/src/nsXBLBinding.cpp | 16 ++++++++++++++++ layout/xbl/src/nsXBLService.cpp | 16 +++++++++++++--- 6 files changed, 64 insertions(+), 6 deletions(-) diff --git a/content/xbl/public/nsIXBLBinding.h b/content/xbl/public/nsIXBLBinding.h index 017a893fb82c..946bb773481b 100644 --- a/content/xbl/public/nsIXBLBinding.h +++ b/content/xbl/public/nsIXBLBinding.h @@ -52,6 +52,9 @@ public: NS_IMETHOD GetBindingElement(nsIContent** aResult) = 0; NS_IMETHOD SetBindingElement(nsIContent* aElement) = 0; + + NS_IMETHOD GenerateAnonymousContent(nsIContent* aBoundElement) = 0; + NS_IMETHOD InstallEventHandlers(nsIContent* aBoundElement) = 0; }; extern nsresult diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index 05fd5ba789ce..169db3c441da 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -36,6 +36,9 @@ class nsXBLBinding: public nsIXBLBinding NS_IMETHOD GetBindingElement(nsIContent** aResult); NS_IMETHOD SetBindingElement(nsIContent* aElement); + NS_IMETHOD GenerateAnonymousContent(nsIContent* aBoundElement); + NS_IMETHOD InstallEventHandlers(nsIContent* aBoundElement); + public: nsXBLBinding(); virtual ~nsXBLBinding(); @@ -110,6 +113,19 @@ nsXBLBinding::SetBindingElement(nsIContent* aElement) return NS_OK; } +NS_IMETHODIMP +nsXBLBinding::GenerateAnonymousContent(nsIContent* aBoundElement) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement) +{ + // XXX Implement me! + return NS_OK; +} + // Creation Routine /////////////////////////////////////////////////////////////////////// nsresult diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index a11f819e5275..23e4ee9dca72 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -218,18 +218,28 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL) if (!bindableContent) return NS_ERROR_FAILURE; - nsCAutoString url = aURL; nsCOMPtr binding; + bindableContent->GetBinding(getter_AddRefs(binding)); + if (binding) + return NS_OK; // The bindings are already loaded. + // XXX Think about how to flush them when styles cause a dynamic change + + nsCAutoString url = aURL; if (NS_FAILED(rv = GetBinding(url, getter_AddRefs(binding)))) { NS_ERROR("Failed loading an XBL document for content node."); return rv; } // Install the binding on the content node. - // When installed, the bound content will clone the - // anonymous content and place it into the binding. bindableContent->SetBinding(binding); + // Tell the binding to build the anonymous content. + binding->GenerateAnonymousContent(aContent); + + // Tell the binding to install event handlers + binding->InstallEventHandlers(aContent); + + // XXX Methods and properties. How? return NS_OK; } diff --git a/layout/xbl/public/nsIXBLBinding.h b/layout/xbl/public/nsIXBLBinding.h index 017a893fb82c..946bb773481b 100644 --- a/layout/xbl/public/nsIXBLBinding.h +++ b/layout/xbl/public/nsIXBLBinding.h @@ -52,6 +52,9 @@ public: NS_IMETHOD GetBindingElement(nsIContent** aResult) = 0; NS_IMETHOD SetBindingElement(nsIContent* aElement) = 0; + + NS_IMETHOD GenerateAnonymousContent(nsIContent* aBoundElement) = 0; + NS_IMETHOD InstallEventHandlers(nsIContent* aBoundElement) = 0; }; extern nsresult diff --git a/layout/xbl/src/nsXBLBinding.cpp b/layout/xbl/src/nsXBLBinding.cpp index 05fd5ba789ce..169db3c441da 100644 --- a/layout/xbl/src/nsXBLBinding.cpp +++ b/layout/xbl/src/nsXBLBinding.cpp @@ -36,6 +36,9 @@ class nsXBLBinding: public nsIXBLBinding NS_IMETHOD GetBindingElement(nsIContent** aResult); NS_IMETHOD SetBindingElement(nsIContent* aElement); + NS_IMETHOD GenerateAnonymousContent(nsIContent* aBoundElement); + NS_IMETHOD InstallEventHandlers(nsIContent* aBoundElement); + public: nsXBLBinding(); virtual ~nsXBLBinding(); @@ -110,6 +113,19 @@ nsXBLBinding::SetBindingElement(nsIContent* aElement) return NS_OK; } +NS_IMETHODIMP +nsXBLBinding::GenerateAnonymousContent(nsIContent* aBoundElement) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXBLBinding::InstallEventHandlers(nsIContent* aBoundElement) +{ + // XXX Implement me! + return NS_OK; +} + // Creation Routine /////////////////////////////////////////////////////////////////////// nsresult diff --git a/layout/xbl/src/nsXBLService.cpp b/layout/xbl/src/nsXBLService.cpp index a11f819e5275..23e4ee9dca72 100644 --- a/layout/xbl/src/nsXBLService.cpp +++ b/layout/xbl/src/nsXBLService.cpp @@ -218,18 +218,28 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsString& aURL) if (!bindableContent) return NS_ERROR_FAILURE; - nsCAutoString url = aURL; nsCOMPtr binding; + bindableContent->GetBinding(getter_AddRefs(binding)); + if (binding) + return NS_OK; // The bindings are already loaded. + // XXX Think about how to flush them when styles cause a dynamic change + + nsCAutoString url = aURL; if (NS_FAILED(rv = GetBinding(url, getter_AddRefs(binding)))) { NS_ERROR("Failed loading an XBL document for content node."); return rv; } // Install the binding on the content node. - // When installed, the bound content will clone the - // anonymous content and place it into the binding. bindableContent->SetBinding(binding); + // Tell the binding to build the anonymous content. + binding->GenerateAnonymousContent(aContent); + + // Tell the binding to install event handlers + binding->InstallEventHandlers(aContent); + + // XXX Methods and properties. How? return NS_OK; }