зеркало из https://github.com/mozilla/gecko-dev.git
Fix for 71262 and 71485, r=jag, srs=shaver on 71262 and hewitt on 71485
This commit is contained in:
Родитель
37306c1267
Коммит
d741df52e2
|
@ -1095,16 +1095,17 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, PRInt32 aDocIndex,
|
|||
|
||||
if (sheetMap) {
|
||||
PRInt32 insertIndex = sheetMap->Count();
|
||||
PRBool insertedSheet = PR_FALSE;
|
||||
while (0 <= --insertIndex) {
|
||||
PRInt32 targetIndex = (PRInt32)sheetMap->ElementAt(insertIndex);
|
||||
if (targetIndex < aDocIndex) {
|
||||
mDocument->InsertStyleSheetAt(aSheet, insertIndex + 1, aNotify);
|
||||
sheetMap->InsertElementAt((void*)aDocIndex, insertIndex + 1);
|
||||
aSheet = nsnull;
|
||||
insertedSheet = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nsnull != aSheet) { // didn't insert yet
|
||||
if (!insertedSheet) { // didn't insert yet
|
||||
mDocument->InsertStyleSheetAt(aSheet, 0, aNotify);
|
||||
sheetMap->InsertElementAt((void*)aDocIndex, 0);
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@
|
|||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<constructor action="this._initSelection()"/>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="mousedown">
|
||||
|
@ -174,7 +175,6 @@
|
|||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="bindingattached" action="this._initSelection()"/>
|
||||
|
||||
<!-- Selection Management -->
|
||||
<handler event="keypress" keycode="vk_up">
|
||||
|
|
|
@ -66,12 +66,13 @@ public:
|
|||
NS_IMETHOD SetBoundElement(nsIContent* aElement) = 0;
|
||||
|
||||
NS_IMETHOD GenerateAnonymousContent() = 0;
|
||||
NS_IMETHOD InstallEventHandlers(nsIXBLBinding** aBinding) = 0;
|
||||
NS_IMETHOD InstallEventHandlers() = 0;
|
||||
NS_IMETHOD InstallProperties() = 0;
|
||||
NS_IMETHOD LoadResources()=0;
|
||||
|
||||
|
||||
NS_IMETHOD HasStyleSheets(PRBool* aResolveStyle) = 0;
|
||||
|
||||
NS_IMETHOD GetFirstBindingWithConstructor(nsIXBLBinding** aResult)=0;
|
||||
|
||||
NS_IMETHOD GetBaseTag(PRInt32* aNameSpaceID, nsIAtom** aResult) = 0;
|
||||
|
||||
// Called when an attribute changes on a binding.
|
||||
|
|
|
@ -51,8 +51,7 @@ public:
|
|||
static const nsIID& GetIID() { static nsIID iid = NS_IXBLDOCUMENTINFO_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument** aResult)=0;
|
||||
NS_IMETHOD GetRuleProcessors(nsISupportsArray** aResult)=0;
|
||||
|
||||
|
||||
NS_IMETHOD GetScriptAccess(PRBool* aResult)=0;
|
||||
NS_IMETHOD SetScriptAccess(PRBool aAccess)=0;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ class nsIDOMEventReceiver;
|
|||
class nsIXBLDocumentInfo;
|
||||
class nsIXBLPrototypeHandler;
|
||||
class nsIXBLBinding;
|
||||
class nsISupportsArray;
|
||||
|
||||
// {34D700F5-C1A2-4408-A0B1-DD8F891DD1FE}
|
||||
#define NS_IXBLPROTOTYPEBINDING_IID \
|
||||
|
@ -55,14 +56,12 @@ public:
|
|||
NS_IMETHOD BindingAttached(nsIDOMEventReceiver* aReceiver)=0;
|
||||
NS_IMETHOD BindingDetached(nsIDOMEventReceiver* aReceiver)=0;
|
||||
|
||||
NS_IMETHOD LoadResources()=0;
|
||||
NS_IMETHOD LoadResources(PRBool* aLoaded)=0;
|
||||
|
||||
NS_IMETHOD InheritsStyle(PRBool* aResult)=0;
|
||||
|
||||
NS_IMETHOD GetPrototypeHandlers(nsIXBLPrototypeHandler** aHandler,
|
||||
nsIXBLPrototypeHandler** aSpecialHandler)=0;
|
||||
NS_IMETHOD SetPrototypeHandlers(nsIXBLPrototypeHandler* aHandler,
|
||||
nsIXBLPrototypeHandler* aSpecialHandler)=0;
|
||||
NS_IMETHOD GetPrototypeHandlers(nsIXBLPrototypeHandler** aHandler)=0;
|
||||
NS_IMETHOD SetPrototypeHandlers(nsIXBLPrototypeHandler* aHandler)=0;
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceID, PRBool aRemoveFlag,
|
||||
nsIContent* aChangedElement, nsIContent* aAnonymousContent)=0;
|
||||
|
@ -77,7 +76,10 @@ public:
|
|||
|
||||
NS_IMETHOD SetInitialAttributes(nsIContent* aBoundElement, nsIContent* aAnonymousContent)=0;
|
||||
|
||||
NS_IMETHOD GetRuleProcessors(nsISupportsArray** aResult)=0;
|
||||
|
||||
NS_IMETHOD HasInsertionPoints(PRBool* aResult)=0;
|
||||
NS_IMETHOD HasStyleSheets(PRBool* aResult)=0;
|
||||
|
||||
NS_IMETHOD InstantiateInsertionPoints(nsIXBLBinding* aBinding)=0;
|
||||
|
||||
|
@ -95,6 +97,10 @@ public:
|
|||
NS_IMETHOD ImplementsInterface(REFNSIID aIID, PRBool* aResult)=0;
|
||||
|
||||
NS_IMETHOD ShouldBuildChildFrames(PRBool* aResult)=0;
|
||||
|
||||
NS_IMETHOD AddResourceListener(nsIContent* aBoundElement)=0;
|
||||
|
||||
NS_IMETHOD GetConstructor(nsIXBLPrototypeHandler** aResult)=0;
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
NS_IMETHOD ExecuteHandler(nsIDOMEventReceiver* aReceiver, nsIDOMEvent* aEvent) = 0;
|
||||
|
||||
NS_IMETHOD GetEventName(nsIAtom** aResult) = 0;
|
||||
NS_IMETHOD SetEventName(nsIAtom* aName) = 0;
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
|
|
|
@ -80,7 +80,6 @@ public:
|
|||
virtual ~nsXBLDocumentInfo();
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument** aResult) { *aResult = mDocument; NS_IF_ADDREF(*aResult); return NS_OK; };
|
||||
NS_IMETHOD GetRuleProcessors(nsISupportsArray** aResult);
|
||||
|
||||
NS_IMETHOD GetScriptAccess(PRBool* aResult) { *aResult = mScriptAccess; return NS_OK; };
|
||||
NS_IMETHOD SetScriptAccess(PRBool aAccess) { mScriptAccess = aAccess; return NS_OK; };
|
||||
|
@ -93,7 +92,6 @@ public:
|
|||
private:
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCString mDocURI;
|
||||
nsCOMPtr<nsISupportsArray> mRuleProcessors;
|
||||
PRBool mScriptAccess;
|
||||
nsSupportsHashtable* mBindingTable;
|
||||
};
|
||||
|
@ -117,42 +115,6 @@ nsXBLDocumentInfo::~nsXBLDocumentInfo()
|
|||
delete mBindingTable;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLDocumentInfo::GetRuleProcessors(nsISupportsArray** aResult)
|
||||
{
|
||||
if (!mRuleProcessors) {
|
||||
// Gather the rule processors.
|
||||
PRInt32 count = mDocument->GetNumberOfStyleSheets();
|
||||
if (count > 2) {
|
||||
nsCOMPtr<nsIHTMLContentContainer> container(do_QueryInterface(mDocument));
|
||||
nsCOMPtr<nsIHTMLCSSStyleSheet> inlineSheet;
|
||||
container->GetInlineStyleSheet(getter_AddRefs(inlineSheet));
|
||||
nsCOMPtr<nsIHTMLStyleSheet> attrSheet;
|
||||
container->GetAttributeStyleSheet(getter_AddRefs(attrSheet));
|
||||
nsCOMPtr<nsIStyleSheet> inlineCSS(do_QueryInterface(inlineSheet));
|
||||
nsCOMPtr<nsIStyleSheet> attrCSS(do_QueryInterface(attrSheet));
|
||||
NS_NewISupportsArray(getter_AddRefs(mRuleProcessors));
|
||||
nsCOMPtr<nsIStyleRuleProcessor> prevProcessor;
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet = getter_AddRefs(mDocument->GetStyleSheetAt(i));
|
||||
if (sheet == inlineCSS || sheet == attrCSS)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIStyleRuleProcessor> processor;
|
||||
sheet->GetStyleRuleProcessor(*getter_AddRefs(processor), prevProcessor);
|
||||
if (processor != prevProcessor) {
|
||||
mRuleProcessors->AppendElement(processor);
|
||||
prevProcessor = processor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*aResult = mRuleProcessors;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLDocumentInfo::GetPrototypeBinding(const nsAReadableCString& aRef, nsIXBLPrototypeBinding** aResult)
|
||||
{
|
||||
|
|
|
@ -434,18 +434,31 @@ nsXBLBinding::SetBoundElement(nsIContent* aElement)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetFirstBindingWithConstructor(nsIXBLBinding** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> constructor;
|
||||
mPrototypeBinding->GetConstructor(getter_AddRefs(constructor));
|
||||
if (constructor) {
|
||||
*aResult = this;
|
||||
NS_ADDREF(*aResult);
|
||||
}
|
||||
else if (mNextBinding)
|
||||
return mNextBinding->GetFirstBindingWithConstructor(aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::HasStyleSheets(PRBool* aResolveStyle)
|
||||
{
|
||||
// Find out if we need to re-resolve style. We'll need to do this
|
||||
// if we have additional stylesheets in our binding document.
|
||||
nsCOMPtr<nsIXBLDocumentInfo> info;
|
||||
mPrototypeBinding->GetXBLDocumentInfo(mBoundElement, getter_AddRefs(info));
|
||||
if (!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISupportsArray> rules;
|
||||
info->GetRuleProcessors(getter_AddRefs(rules));
|
||||
if (rules) {
|
||||
PRBool hasSheets;
|
||||
mPrototypeBinding->HasStyleSheets(&hasSheets);
|
||||
if (hasSheets) {
|
||||
*aResolveStyle = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -850,7 +863,7 @@ nsXBLBinding::GenerateAnonymousContent()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::InstallEventHandlers(nsIXBLBinding** aBinding)
|
||||
nsXBLBinding::InstallEventHandlers()
|
||||
{
|
||||
// Don't install handlers if scripts aren't allowed.
|
||||
if (AllowScripts()) {
|
||||
|
@ -861,14 +874,8 @@ nsXBLBinding::InstallEventHandlers(nsIXBLBinding** aBinding)
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> handlerChain;
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> specialChain;
|
||||
mPrototypeBinding->GetPrototypeHandlers(getter_AddRefs(handlerChain), getter_AddRefs(specialChain));
|
||||
mPrototypeBinding->GetPrototypeHandlers(getter_AddRefs(handlerChain));
|
||||
|
||||
if (specialChain && !*aBinding) {
|
||||
*aBinding = this;
|
||||
NS_ADDREF(*aBinding);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> curr = handlerChain;
|
||||
nsXBLEventHandler* currHandler = nsnull;
|
||||
|
||||
|
@ -1017,14 +1024,8 @@ nsXBLBinding::InstallEventHandlers(nsIXBLBinding** aBinding)
|
|||
}
|
||||
}
|
||||
|
||||
if (mNextBinding) {
|
||||
nsCOMPtr<nsIXBLBinding> binding;
|
||||
mNextBinding->InstallEventHandlers(getter_AddRefs(binding));
|
||||
if (!*aBinding) {
|
||||
*aBinding = binding;
|
||||
NS_IF_ADDREF(*aBinding);
|
||||
}
|
||||
}
|
||||
if (mNextBinding)
|
||||
mNextBinding->InstallEventHandlers();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1307,15 +1308,6 @@ nsXBLBinding::InstallProperties()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::LoadResources()
|
||||
{
|
||||
mPrototypeBinding->LoadResources();
|
||||
if (mNextBinding)
|
||||
mNextBinding->LoadResources();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLBinding::GetBaseTag(PRInt32* aNameSpaceID, nsIAtom** aResult)
|
||||
{
|
||||
|
@ -1483,12 +1475,8 @@ nsXBLBinding::WalkRules(nsISupportsArrayEnumFunc aFunc, void* aData)
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXBLDocumentInfo> info;
|
||||
mPrototypeBinding->GetXBLDocumentInfo(mBoundElement, getter_AddRefs(info));
|
||||
if (!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISupportsArray> rules;
|
||||
info->GetRuleProcessors(getter_AddRefs(rules));
|
||||
mPrototypeBinding->GetRuleProcessors(getter_AddRefs(rules));
|
||||
if (rules)
|
||||
rules->EnumerateForwards(aFunc, aData);
|
||||
|
||||
|
|
|
@ -60,12 +60,13 @@ class nsXBLBinding: public nsIXBLBinding
|
|||
NS_IMETHOD SetBoundElement(nsIContent* aElement);
|
||||
|
||||
NS_IMETHOD GenerateAnonymousContent();
|
||||
NS_IMETHOD InstallEventHandlers(nsIXBLBinding** aBinding);
|
||||
NS_IMETHOD InstallEventHandlers();
|
||||
NS_IMETHOD InstallProperties();
|
||||
NS_IMETHOD LoadResources();
|
||||
|
||||
|
||||
NS_IMETHOD HasStyleSheets(PRBool* aResolveStyle);
|
||||
|
||||
NS_IMETHOD GetFirstBindingWithConstructor(nsIXBLBinding** aResult);
|
||||
|
||||
NS_IMETHOD GetBaseTag(PRInt32* aNameSpaceID, nsIAtom** aResult);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceID, PRBool aRemoveFlag);
|
||||
|
|
|
@ -53,6 +53,12 @@
|
|||
#include "nsFixedSizeAllocator.h"
|
||||
#include "xptinfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
|
||||
#ifdef USE_IMG2
|
||||
#include "imgILoader.h"
|
||||
|
@ -185,12 +191,14 @@ nsIAtom* nsXBLPrototypeBinding::kIncludesAtom = nsnull;
|
|||
nsIAtom* nsXBLPrototypeBinding::kContentAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kResourcesAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kResourceAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kTypeAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kStyleSheetAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kSrcAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kInheritsAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kHTMLAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kValueAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kXBLTextAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kConstructorAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kDestructorAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kImplementationAtom = nsnull;
|
||||
nsIAtom* nsXBLPrototypeBinding::kImplementsAtom = nsnull;
|
||||
nsFixedSizeAllocator nsXBLPrototypeBinding::kAttrPool;
|
||||
|
@ -215,7 +223,7 @@ static const PRInt32 kInsInitialSize = (NS_SIZE_IN_HEAP(sizeof(nsXBLInsertionPoi
|
|||
// Implementation /////////////////////////////////////////////////////////////////
|
||||
|
||||
// Implement our nsISupports methods
|
||||
NS_IMPL_ISUPPORTS1(nsXBLPrototypeBinding, nsIXBLPrototypeBinding)
|
||||
NS_IMPL_ISUPPORTS2(nsXBLPrototypeBinding, nsIXBLPrototypeBinding, nsICSSLoaderObserver)
|
||||
|
||||
// Constructors/Destructors
|
||||
nsXBLPrototypeBinding::nsXBLPrototypeBinding(const nsAReadableCString& aID, nsIContent* aElement,
|
||||
|
@ -223,10 +231,12 @@ nsXBLPrototypeBinding::nsXBLPrototypeBinding(const nsAReadableCString& aID, nsIC
|
|||
: mID(aID),
|
||||
mInheritStyle(PR_TRUE),
|
||||
mHasBaseProto(PR_TRUE),
|
||||
mLoadedResources(PR_FALSE),
|
||||
mLoadingResources(PR_FALSE),
|
||||
mPendingSheets(0),
|
||||
mAttributeTable(nsnull),
|
||||
mInsertionPointTable(nsnull),
|
||||
mInterfaceTable(nsnull)
|
||||
mInterfaceTable(nsnull),
|
||||
mStyleSheetList(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
|
@ -245,13 +255,15 @@ nsXBLPrototypeBinding::nsXBLPrototypeBinding(const nsAReadableCString& aID, nsIC
|
|||
kContentAtom = NS_NewAtom("content");
|
||||
kResourcesAtom = NS_NewAtom("resources");
|
||||
kResourceAtom = NS_NewAtom("resource");
|
||||
kTypeAtom = NS_NewAtom("type");
|
||||
kStyleSheetAtom = NS_NewAtom("stylesheet");
|
||||
kSrcAtom = NS_NewAtom("src");
|
||||
kIncludesAtom = NS_NewAtom("includes");
|
||||
kInheritsAtom = NS_NewAtom("inherits");
|
||||
kHTMLAtom = NS_NewAtom("html");
|
||||
kValueAtom = NS_NewAtom("value");
|
||||
kXBLTextAtom = NS_NewAtom("xbl:text");
|
||||
kConstructorAtom = NS_NewAtom("constructor");
|
||||
kDestructorAtom = NS_NewAtom("destructor");
|
||||
kImplementationAtom = NS_NewAtom("implementation");
|
||||
kImplementsAtom = NS_NewAtom("implements");
|
||||
}
|
||||
|
@ -293,13 +305,15 @@ nsXBLPrototypeBinding::~nsXBLPrototypeBinding(void)
|
|||
NS_RELEASE(kContentAtom);
|
||||
NS_RELEASE(kResourcesAtom);
|
||||
NS_RELEASE(kResourceAtom);
|
||||
NS_RELEASE(kTypeAtom);
|
||||
NS_RELEASE(kStyleSheetAtom);
|
||||
NS_RELEASE(kSrcAtom);
|
||||
NS_RELEASE(kIncludesAtom);
|
||||
NS_RELEASE(kInheritsAtom);
|
||||
NS_RELEASE(kHTMLAtom);
|
||||
NS_RELEASE(kValueAtom);
|
||||
NS_RELEASE(kXBLTextAtom);
|
||||
NS_RELEASE(kConstructorAtom);
|
||||
NS_RELEASE(kDestructorAtom);
|
||||
NS_RELEASE(kImplementationAtom);
|
||||
NS_RELEASE(kImplementsAtom);
|
||||
}
|
||||
|
@ -396,49 +410,92 @@ nsXBLPrototypeBinding::GetAllowScripts(PRBool* aResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::LoadResources()
|
||||
nsXBLPrototypeBinding::LoadResources(PRBool* aResult)
|
||||
{
|
||||
if (mLoadedResources)
|
||||
if (mLoadingResources) {
|
||||
*aResult = (mPendingSheets == 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mLoadedResources = PR_TRUE;
|
||||
mLoadingResources = PR_TRUE;
|
||||
*aResult = PR_TRUE;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
GetImmediateChild(kResourcesAtom, getter_AddRefs(content));
|
||||
if (content) {
|
||||
#ifdef USE_IMG2
|
||||
// Get the image loader.
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1"));
|
||||
if (!il) return NS_ERROR_FAILURE;
|
||||
|
||||
// Declare our loaders.
|
||||
nsCOMPtr<imgILoader> il;
|
||||
#endif
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
|
||||
PRInt32 childCount;
|
||||
content->ChildCount(childCount);
|
||||
|
||||
nsCOMPtr<nsIXBLDocumentInfo> info;
|
||||
GetXBLDocumentInfo(nsnull, getter_AddRefs(info));
|
||||
if (!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
info->GetDocument(getter_AddRefs(doc));
|
||||
|
||||
nsCOMPtr<nsIURI> docURL = getter_AddRefs(doc->GetDocumentURL());
|
||||
|
||||
for (PRInt32 i = 0; i < childCount; i++) {
|
||||
nsCOMPtr<nsIContent> resource;
|
||||
content->ChildAt(i, *getter_AddRefs(resource));
|
||||
|
||||
nsAutoString type;
|
||||
resource->GetAttribute(kNameSpaceID_None, kTypeAtom, type);
|
||||
if (type.EqualsIgnoreCase("image")) {
|
||||
// Obtain our src attribute.
|
||||
nsAutoString src;
|
||||
resource->GetAttribute(kNameSpaceID_None, kSrcAtom, src);
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
resource->GetTag(*getter_AddRefs(tag));
|
||||
|
||||
nsAutoString src;
|
||||
resource->GetAttribute(kNameSpaceID_None, kSrcAtom, src);
|
||||
|
||||
if (src.Length() == 0)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIURI> url;
|
||||
rv = NS_NewURI(getter_AddRefs(url), src, docURL);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
#ifdef USE_IMG2
|
||||
if (tag.get() == nsHTMLAtoms::image) {
|
||||
// Obtain our src attribute.
|
||||
// Construct a URI out of our src attribute.
|
||||
if (src.Length() > 0) {
|
||||
nsCAutoString csrc; csrc.AssignWithConversion(src);
|
||||
|
||||
nsCOMPtr<nsIURL> uri;
|
||||
nsComponentManager::CreateInstance("@mozilla.org/network/standard-url;1",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIURL),
|
||||
getter_AddRefs(uri));
|
||||
uri->SetSpec(csrc);
|
||||
|
||||
// Now kick off the image load
|
||||
nsCOMPtr<imgIRequest> req;
|
||||
il->LoadImage(uri, nsnull, nsnull, nsnull, getter_AddRefs(req));
|
||||
// We need to ensure the image loader is constructed.
|
||||
if (!il) {
|
||||
il = do_GetService("@mozilla.org/image/loader;1");
|
||||
if (!il) continue;
|
||||
}
|
||||
|
||||
// Now kick off the image load
|
||||
nsCOMPtr<imgIRequest> req;
|
||||
il->LoadImage(url, nsnull, nsnull, nsnull, getter_AddRefs(req));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (tag.get() == kStyleSheetAtom) {
|
||||
if (!cssLoader) {
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContent(do_QueryInterface(doc));
|
||||
htmlContent->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
}
|
||||
|
||||
if (!cssLoader)
|
||||
continue;
|
||||
|
||||
// Kick off the load of the stylesheet.
|
||||
PRBool doneLoading;
|
||||
nsAutoString empty, media;
|
||||
resource->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::media, media);
|
||||
rv = cssLoader->LoadStyleLink(nsnull, url, empty, media, kNameSpaceID_Unknown,
|
||||
doc->GetNumberOfStyleSheets(),
|
||||
nsnull,
|
||||
doneLoading, this);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mPendingSheets++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,24 +504,25 @@ nsXBLPrototypeBinding::LoadResources()
|
|||
PRInt32 index;
|
||||
mBinding->IndexOf(content, index);
|
||||
mBinding->RemoveChildAt(index, PR_FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
*aResult = (mPendingSheets == 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::BindingAttached(nsIDOMEventReceiver* aReceiver)
|
||||
{
|
||||
if (mSpecialHandler)
|
||||
return mSpecialHandler->BindingAttached(aReceiver);
|
||||
if (mConstructor)
|
||||
return mConstructor->BindingAttached(aReceiver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::BindingDetached(nsIDOMEventReceiver* aReceiver)
|
||||
{
|
||||
if (mSpecialHandler)
|
||||
return mSpecialHandler->BindingDetached(aReceiver);
|
||||
if (mDestructor)
|
||||
return mDestructor->BindingDetached(aReceiver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -503,22 +561,17 @@ nsXBLPrototypeBinding::SetHasBasePrototype(PRBool aHasBase)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::GetPrototypeHandlers(nsIXBLPrototypeHandler** aResult,
|
||||
nsIXBLPrototypeHandler** aSpecialResult)
|
||||
nsXBLPrototypeBinding::GetPrototypeHandlers(nsIXBLPrototypeHandler** aResult)
|
||||
{
|
||||
*aResult = mPrototypeHandler;
|
||||
*aSpecialResult = mSpecialHandler;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
NS_IF_ADDREF(*aSpecialResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::SetPrototypeHandlers(nsIXBLPrototypeHandler* aHandler,
|
||||
nsIXBLPrototypeHandler* aSpecialHandler)
|
||||
nsXBLPrototypeBinding::SetPrototypeHandlers(nsIXBLPrototypeHandler* aHandler)
|
||||
{
|
||||
mPrototypeHandler = aHandler;
|
||||
mSpecialHandler = aSpecialHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -838,7 +891,29 @@ nsXBLPrototypeBinding::ConstructHandlers()
|
|||
nsCOMPtr<nsIContent> handlers;
|
||||
GetImmediateChild(kHandlersAtom, getter_AddRefs(handlers));
|
||||
if (handlers)
|
||||
nsXBLService::BuildHandlerChain(handlers, getter_AddRefs(mPrototypeHandler), getter_AddRefs(mSpecialHandler));
|
||||
nsXBLService::BuildHandlerChain(handlers, getter_AddRefs(mPrototypeHandler));
|
||||
|
||||
nsCOMPtr<nsIContent> impl;
|
||||
GetImmediateChild(kImplementationAtom, getter_AddRefs(impl));
|
||||
if (impl) {
|
||||
// Look for <constructor> and <destructor>.
|
||||
PRInt32 count;
|
||||
impl->ChildCount(count);
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
impl->ChildAt(i, *getter_AddRefs(child));
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
child->GetTag(*getter_AddRefs(tag));
|
||||
if (tag.get() == kConstructorAtom) {
|
||||
NS_NewXBLPrototypeHandler(child, getter_AddRefs(mConstructor));
|
||||
mConstructor->SetEventName(tag);
|
||||
}
|
||||
else if (tag.get() == kDestructorAtom) {
|
||||
NS_NewXBLPrototypeHandler(child, getter_AddRefs(mDestructor));
|
||||
mDestructor->SetEventName(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -954,6 +1029,14 @@ nsXBLPrototypeBinding::SetInitialAttributes(nsIContent* aBoundElement, nsIConten
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::GetRuleProcessors(nsISupportsArray** aResult)
|
||||
{
|
||||
*aResult = mRuleProcessors;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::ShouldBuildChildFrames(PRBool* aResult)
|
||||
{
|
||||
|
@ -1205,6 +1288,97 @@ nsXBLPrototypeBinding::GetNestedChildren(nsIAtom* aTag, nsIContent* aContent, ns
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::AddResourceListener(nsIContent* aBoundElement)
|
||||
{
|
||||
if (!mBoundElements)
|
||||
NS_NewISupportsArray(getter_AddRefs(mBoundElements));
|
||||
|
||||
mBoundElements->AppendElement(aBoundElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHODIMP
|
||||
nsXBLPrototypeBinding::StyleSheetLoaded(nsICSSStyleSheet* aSheet, PRBool aNotify)
|
||||
{
|
||||
if (!mStyleSheetList)
|
||||
NS_NewISupportsArray(getter_AddRefs(mStyleSheetList));
|
||||
|
||||
mStyleSheetList->AppendElement(aSheet);
|
||||
mPendingSheets--;
|
||||
if (mPendingSheets == 0) {
|
||||
// All stylesheets are loaded.
|
||||
nsCOMPtr<nsIStyleRuleProcessor> prevProcessor;
|
||||
NS_NewISupportsArray(getter_AddRefs(mRuleProcessors));
|
||||
PRUint32 count;
|
||||
mStyleSheetList->Count(&count);
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsISupports> supp = getter_AddRefs(mStyleSheetList->ElementAt(i));
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet(do_QueryInterface(supp));
|
||||
|
||||
nsCOMPtr<nsIStyleRuleProcessor> processor;
|
||||
sheet->GetStyleRuleProcessor(*getter_AddRefs(processor), prevProcessor);
|
||||
if (processor != prevProcessor) {
|
||||
mRuleProcessors->AppendElement(processor);
|
||||
prevProcessor = processor;
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Check for mPendingScripts when scripts also come online.
|
||||
NotifyBoundElements();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLPrototypeBinding::NotifyBoundElements()
|
||||
{
|
||||
nsCOMPtr<nsIXBLService> xblService(do_GetService("@mozilla.org/xbl;1"));
|
||||
nsCAutoString bindingURI;
|
||||
GetBindingURI(bindingURI);
|
||||
|
||||
PRUint32 eltCount;
|
||||
mBoundElements->Count(&eltCount);
|
||||
for (PRUint32 j = 0; j < eltCount; j++) {
|
||||
nsCOMPtr<nsISupports> supp = getter_AddRefs(mBoundElements->ElementAt(j));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(supp));
|
||||
|
||||
PRBool ready = PR_FALSE;
|
||||
xblService->BindingReady(content, bindingURI, &ready);
|
||||
|
||||
if (ready) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
content->GetDocument(*getter_AddRefs(doc));
|
||||
|
||||
// Flush first
|
||||
doc->FlushPendingNotifications();
|
||||
|
||||
// Notify
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
content->GetParent(*getter_AddRefs(parent));
|
||||
PRInt32 index = 0;
|
||||
if (parent)
|
||||
parent->IndexOf(content, index);
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(doc->GetShellAt(0));
|
||||
if (shell) {
|
||||
nsIFrame* childFrame;
|
||||
shell->GetPrimaryFrameFor(content, &childFrame);
|
||||
nsCOMPtr<nsIDocumentObserver> obs(do_QueryInterface(shell));
|
||||
if (!childFrame)
|
||||
obs->ContentInserted(doc, parent, content, index);
|
||||
}
|
||||
|
||||
// Flush again
|
||||
doc->FlushPendingNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
// Clear out the whole array.
|
||||
mBoundElements = nsnull;
|
||||
}
|
||||
|
||||
// Creation Routine ///////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIXBLPrototypeBinding.h"
|
||||
#include "nsIXBLPrototypeHandler.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIAtom;
|
||||
|
@ -38,10 +40,13 @@ class nsFixedSizeAllocator;
|
|||
// *********************************************************************/
|
||||
// The XBLPrototypeBinding class
|
||||
|
||||
class nsXBLPrototypeBinding: public nsIXBLPrototypeBinding
|
||||
class nsXBLPrototypeBinding: public nsIXBLPrototypeBinding, public nsICSSLoaderObserver
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet* aSheet, PRBool aNotify);
|
||||
|
||||
// nsIXBLPrototypeBinding
|
||||
NS_IMETHOD GetBindingElement(nsIContent** aResult);
|
||||
NS_IMETHOD SetBindingElement(nsIContent* aElement);
|
||||
|
@ -55,12 +60,12 @@ class nsXBLPrototypeBinding: public nsIXBLPrototypeBinding
|
|||
NS_IMETHOD BindingAttached(nsIDOMEventReceiver* aRec);
|
||||
NS_IMETHOD BindingDetached(nsIDOMEventReceiver* aRec);
|
||||
|
||||
NS_IMETHOD LoadResources();
|
||||
NS_IMETHOD LoadResources(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD InheritsStyle(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD GetPrototypeHandlers(nsIXBLPrototypeHandler** aHandler, nsIXBLPrototypeHandler** aSpecialHandler);
|
||||
NS_IMETHOD SetPrototypeHandlers(nsIXBLPrototypeHandler* aHandler, nsIXBLPrototypeHandler* aSpecialHandler);
|
||||
NS_IMETHOD GetPrototypeHandlers(nsIXBLPrototypeHandler** aHandler);
|
||||
NS_IMETHOD SetPrototypeHandlers(nsIXBLPrototypeHandler* aHandler);
|
||||
|
||||
NS_IMETHOD AttributeChanged(nsIAtom* aAttribute, PRInt32 aNameSpaceID, PRBool aRemoveFlag,
|
||||
nsIContent* aChangedElement, nsIContent* aAnonymousContent);
|
||||
|
@ -75,7 +80,10 @@ class nsXBLPrototypeBinding: public nsIXBLPrototypeBinding
|
|||
|
||||
NS_IMETHOD SetInitialAttributes(nsIContent* aBoundElement, nsIContent* aAnonymousContent);
|
||||
|
||||
NS_IMETHOD GetRuleProcessors(nsISupportsArray** aResult);
|
||||
|
||||
NS_IMETHOD HasInsertionPoints(PRBool* aResult) { *aResult = (mInsertionPointTable != nsnull); return NS_OK; };
|
||||
NS_IMETHOD HasStyleSheets(PRBool* aResult) { *aResult = (mStyleSheetList != nsnull); return NS_OK; };
|
||||
|
||||
NS_IMETHOD InstantiateInsertionPoints(nsIXBLBinding* aBinding);
|
||||
|
||||
|
@ -94,6 +102,10 @@ class nsXBLPrototypeBinding: public nsIXBLPrototypeBinding
|
|||
|
||||
NS_IMETHOD ShouldBuildChildFrames(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD AddResourceListener(nsIContent* aBoundElement);
|
||||
|
||||
NS_IMETHOD GetConstructor(nsIXBLPrototypeHandler** aResult) { *aResult = mConstructor; NS_IF_ADDREF(*aResult); return NS_OK; };
|
||||
|
||||
public:
|
||||
nsXBLPrototypeBinding(const nsAReadableCString& aRef, nsIContent* aElement,
|
||||
nsIXBLDocumentInfo* aInfo);
|
||||
|
@ -108,12 +120,14 @@ public:
|
|||
static nsIAtom* kContentAtom;
|
||||
static nsIAtom* kResourcesAtom;
|
||||
static nsIAtom* kResourceAtom;
|
||||
static nsIAtom* kTypeAtom;
|
||||
static nsIAtom* kStyleSheetAtom;
|
||||
static nsIAtom* kSrcAtom;
|
||||
static nsIAtom* kInheritsAtom;
|
||||
static nsIAtom* kHTMLAtom;
|
||||
static nsIAtom* kValueAtom;
|
||||
static nsIAtom* kXBLTextAtom;
|
||||
static nsIAtom* kConstructorAtom;
|
||||
static nsIAtom* kDestructorAtom;
|
||||
static nsIAtom* kImplementationAtom;
|
||||
static nsIAtom* kImplementsAtom;
|
||||
|
||||
|
@ -132,7 +146,8 @@ protected:
|
|||
void ConstructInsertionTable(nsIContent* aElement);
|
||||
void ConstructInterfaceTable(nsIContent* aElement);
|
||||
void GetNestedChildren(nsIAtom* aTag, nsIContent* aContent, nsISupportsArray** aList);
|
||||
|
||||
void NotifyBoundElements();
|
||||
|
||||
protected:
|
||||
// Internal helper class for managing our IID table.
|
||||
class nsIIDKey : public nsHashKey {
|
||||
|
@ -163,12 +178,16 @@ protected:
|
|||
|
||||
nsCOMPtr<nsIContent> mBinding; // Strong. We own a ref to our content element in the binding doc.
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> mPrototypeHandler; // Strong. DocInfo owns us, and we own the handlers.
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> mSpecialHandler; // Strong. Our bindingattached/detached handlers.
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> mConstructor; // Strong. Our constructor.
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> mDestructor; // Strong. Our destructor.
|
||||
|
||||
nsCOMPtr<nsIXBLPrototypeBinding> mBaseBinding; // Strong. We own the base binding in our explicit inheritance chain.
|
||||
PRPackedBool mInheritStyle;
|
||||
PRPackedBool mHasBaseProto;
|
||||
PRPackedBool mLoadedResources;
|
||||
PRPackedBool mLoadingResources;
|
||||
|
||||
PRInt32 mPendingSheets; // The number of stylesheets that have yet to load.
|
||||
nsCOMPtr<nsISupportsArray> mBoundElements; // Bound elements that are waiting on the stylesheets and scripts.
|
||||
|
||||
nsWeakPtr mXBLDocInfoWeak; // A pointer back to our doc info. Weak, since it owns us.
|
||||
|
||||
|
@ -180,6 +199,9 @@ protected:
|
|||
|
||||
nsSupportsHashtable* mInterfaceTable; // A table of cached interfaces that we support.
|
||||
|
||||
nsCOMPtr<nsISupportsArray> mStyleSheetList; // A list of loaded stylesheets for this binding.
|
||||
nsCOMPtr<nsISupportsArray> mRuleProcessors; // The list of stylesheets converted to rule processors.
|
||||
|
||||
PRInt32 mBaseNameSpaceID; // If we extend a tagname/namespace, then that information will
|
||||
nsCOMPtr<nsIAtom> mBaseTag; // be stored in here.
|
||||
};
|
||||
|
|
|
@ -365,44 +365,39 @@ NS_IMETHODIMP
|
|||
nsXBLPrototypeHandler::BindingAttached(nsIDOMEventReceiver* aReceiver)
|
||||
{
|
||||
nsresult ret;
|
||||
if (mEventName.get() == kBindingAttachedAtom) {
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_MENU_ACTION;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_MENU_ACTION;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
|
||||
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
||||
if (NS_FAILED(ret = aReceiver->GetListenerManager(getter_AddRefs(listenerManager)))) {
|
||||
NS_ERROR("Unable to instantiate a listener manager on this event.");
|
||||
return ret;
|
||||
}
|
||||
nsAutoString empty;
|
||||
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
||||
if (NS_FAILED(ret = aReceiver->GetListenerManager(getter_AddRefs(listenerManager)))) {
|
||||
NS_ERROR("Unable to instantiate a listener manager on this event.");
|
||||
return ret;
|
||||
}
|
||||
nsAutoString empty;
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
if (NS_FAILED(ret = listenerManager->CreateEvent(nsnull, &event, empty, getter_AddRefs(domEvent)))) {
|
||||
NS_ERROR("The binding attach handler will fail without the ability to create the event early.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// We need to explicitly set the target here, because the
|
||||
// DOM implementation will try to compute the target from
|
||||
// the frame. If we don't have a frame then that breaks.
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
|
||||
if (privateEvent) {
|
||||
privateEvent->SetTarget(aReceiver);
|
||||
}
|
||||
|
||||
ExecuteHandler(aReceiver, domEvent);
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
if (NS_FAILED(ret = listenerManager->CreateEvent(nsnull, &event, empty, getter_AddRefs(domEvent)))) {
|
||||
NS_ERROR("The binding attach handler will fail without the ability to create the event early.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (mNextHandler)
|
||||
return mNextHandler->BindingAttached(aReceiver);
|
||||
|
||||
// We need to explicitly set the target here, because the
|
||||
// DOM implementation will try to compute the target from
|
||||
// the frame. If we don't have a frame then that breaks.
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
|
||||
if (privateEvent) {
|
||||
privateEvent->SetTarget(aReceiver);
|
||||
}
|
||||
|
||||
ExecuteHandler(aReceiver, domEvent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -410,43 +405,38 @@ NS_IMETHODIMP
|
|||
nsXBLPrototypeHandler::BindingDetached(nsIDOMEventReceiver* aReceiver)
|
||||
{
|
||||
nsresult ret;
|
||||
if (mEventName.get() == kBindingDetachedAtom) {
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_MENU_ACTION;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_MENU_ACTION;
|
||||
event.isShift = PR_FALSE;
|
||||
event.isControl = PR_FALSE;
|
||||
event.isAlt = PR_FALSE;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.clickCount = 0;
|
||||
event.widget = nsnull;
|
||||
|
||||
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
||||
if (NS_FAILED(ret = aReceiver->GetListenerManager(getter_AddRefs(listenerManager)))) {
|
||||
NS_ERROR("Unable to instantiate a listener manager on this event.");
|
||||
return ret;
|
||||
}
|
||||
nsAutoString empty;
|
||||
nsCOMPtr<nsIEventListenerManager> listenerManager;
|
||||
if (NS_FAILED(ret = aReceiver->GetListenerManager(getter_AddRefs(listenerManager)))) {
|
||||
NS_ERROR("Unable to instantiate a listener manager on this event.");
|
||||
return ret;
|
||||
}
|
||||
nsAutoString empty;
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
if (NS_FAILED(ret = listenerManager->CreateEvent(nsnull, &event, empty, getter_AddRefs(domEvent)))) {
|
||||
NS_ERROR("The binding attach handler will fail without the ability to create the event early.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// We need to explicitly set the target here, because the
|
||||
// DOM implementation will try to compute the target from
|
||||
// the frame. If we don't have a frame then that breaks.
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
|
||||
if (privateEvent) {
|
||||
privateEvent->SetTarget(aReceiver);
|
||||
}
|
||||
|
||||
ExecuteHandler(aReceiver, domEvent);
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
if (NS_FAILED(ret = listenerManager->CreateEvent(nsnull, &event, empty, getter_AddRefs(domEvent)))) {
|
||||
NS_ERROR("The binding attach handler will fail without the ability to create the event early.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (mNextHandler)
|
||||
return mNextHandler->BindingDetached(aReceiver);
|
||||
// We need to explicitly set the target here, because the
|
||||
// DOM implementation will try to compute the target from
|
||||
// the frame. If we don't have a frame then that breaks.
|
||||
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
|
||||
if (privateEvent) {
|
||||
privateEvent->SetTarget(aReceiver);
|
||||
}
|
||||
|
||||
ExecuteHandler(aReceiver, domEvent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
NS_IMETHOD ExecuteHandler(nsIDOMEventReceiver* aReceiver, nsIDOMEvent* aEvent);
|
||||
|
||||
NS_IMETHOD GetEventName(nsIAtom** aResult);
|
||||
NS_IMETHOD SetEventName(nsIAtom* aName) { mEventName = aName; return NS_OK; };
|
||||
|
||||
NS_IMETHOD BindingAttached(nsIDOMEventReceiver* aReceiver);
|
||||
NS_IMETHOD BindingDetached(nsIDOMEventReceiver* aReceiver);
|
||||
|
|
|
@ -692,17 +692,17 @@ nsXBLService::LoadBindings(nsIContent* aContent, const nsAReadableString& aURL,
|
|||
newBinding->GenerateAnonymousContent();
|
||||
|
||||
// Tell the binding to install event handlers
|
||||
newBinding->InstallEventHandlers(aBinding);
|
||||
newBinding->InstallEventHandlers();
|
||||
|
||||
// Set up our properties
|
||||
newBinding->InstallProperties();
|
||||
|
||||
// Load our resources.
|
||||
newBinding->LoadResources();
|
||||
// Figure out if we need to execute a constructor.
|
||||
newBinding->GetFirstBindingWithConstructor(aBinding);
|
||||
|
||||
// Figure out if we have any scoped sheets. If so, we do a second resolve.
|
||||
newBinding->HasStyleSheets(aResolveStyle);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -965,6 +965,16 @@ NS_IMETHODIMP nsXBLService::GetBindingInternal(nsIContent* aBoundElement,
|
|||
if (!protoBinding)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Our prototype binding must have all its resources loaded.
|
||||
PRBool ready;
|
||||
protoBinding->LoadResources(&ready);
|
||||
if (!ready) {
|
||||
// Add our bound element to the protos list of elts that should
|
||||
// be notified when the stylesheets and scripts finish loading.
|
||||
protoBinding->AddResourceListener(aBoundElement);
|
||||
return NS_ERROR_FAILURE; // The binding isn't ready yet.
|
||||
}
|
||||
|
||||
// If our prototype already has a base, then don't check for an "extends" attribute.
|
||||
nsCOMPtr<nsIXBLBinding> baseBinding;
|
||||
nsCOMPtr<nsIXBLPrototypeBinding> baseProto;
|
||||
|
@ -1345,52 +1355,34 @@ static void GetImmediateChild(nsIAtom* aTag, nsIContent* aParent, nsIContent** a
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXBLService::BuildHandlerChain(nsIContent* aContent, nsIXBLPrototypeHandler** aResult,
|
||||
nsIXBLPrototypeHandler** aSpecialResult)
|
||||
nsXBLService::BuildHandlerChain(nsIContent* aContent, nsIXBLPrototypeHandler** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> firstHandler;
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> currHandler;
|
||||
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> firstSpecialHandler;
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> currSpecialHandler;
|
||||
|
||||
PRInt32 handlerCount;
|
||||
aContent->ChildCount(handlerCount);
|
||||
for (PRInt32 j = 0; j < handlerCount; j++) {
|
||||
nsCOMPtr<nsIContent> handler;
|
||||
aContent->ChildAt(j, *getter_AddRefs(handler));
|
||||
|
||||
PRBool special = PR_FALSE;
|
||||
nsAutoString event;
|
||||
handler->GetAttribute(kNameSpaceID_None, kEventAtom, event);
|
||||
if (event.Equals(NS_LITERAL_STRING("bindingattached")) ||
|
||||
event.Equals(NS_LITERAL_STRING("bindingdetached")))
|
||||
special = PR_TRUE;
|
||||
|
||||
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> newHandler;
|
||||
NS_NewXBLPrototypeHandler(handler, getter_AddRefs(newHandler));
|
||||
|
||||
if (newHandler) {
|
||||
if (special) {
|
||||
if (currSpecialHandler)
|
||||
currSpecialHandler->SetNextHandler(newHandler);
|
||||
else firstSpecialHandler = newHandler;
|
||||
currSpecialHandler = newHandler;
|
||||
}
|
||||
else {
|
||||
if (currHandler)
|
||||
currHandler->SetNextHandler(newHandler);
|
||||
else firstHandler = newHandler;
|
||||
currHandler = newHandler;
|
||||
}
|
||||
if (currHandler)
|
||||
currHandler->SetNextHandler(newHandler);
|
||||
else firstHandler = newHandler;
|
||||
currHandler = newHandler;
|
||||
}
|
||||
}
|
||||
|
||||
*aResult = firstHandler;
|
||||
*aSpecialResult = firstSpecialHandler;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
NS_IF_ADDREF(*aSpecialResult);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,8 +101,7 @@ public:
|
|||
// This method walks a binding document and removes any text nodes
|
||||
// that contain only whitespace.
|
||||
static nsresult StripWhitespaceNodes(nsIContent* aContent);
|
||||
static nsresult BuildHandlerChain(nsIContent* aContent, nsIXBLPrototypeHandler** aResult,
|
||||
nsIXBLPrototypeHandler** aSpecialResult);
|
||||
static nsresult BuildHandlerChain(nsIContent* aContent, nsIXBLPrototypeHandler** aResult);
|
||||
|
||||
// MEMBER VARIABLES
|
||||
public:
|
||||
|
|
|
@ -148,10 +148,8 @@ nsXBLSpecialDocInfo::GetHandlers(nsIXBLDocumentInfo* aInfo,
|
|||
}
|
||||
}
|
||||
|
||||
if (binding) {
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> dummy;
|
||||
binding->GetPrototypeHandlers(aResult, getter_AddRefs(dummy)); // Addref happens here.
|
||||
}
|
||||
if (binding)
|
||||
binding->GetPrototypeHandlers(aResult); // Addref happens here.
|
||||
} // GetHandlers
|
||||
|
||||
void
|
||||
|
|
|
@ -86,8 +86,7 @@ nsXBLWindowKeyHandler::EnsureHandlers()
|
|||
if (mHandler)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
nsCOMPtr<nsIXBLPrototypeHandler> dummy;
|
||||
rv = nsXBLService::BuildHandlerChain(content, getter_AddRefs(mHandler), getter_AddRefs(dummy));
|
||||
rv = nsXBLService::BuildHandlerChain(content, getter_AddRefs(mHandler));
|
||||
}
|
||||
else
|
||||
nsXBLWindowHandler::EnsureHandlers();
|
||||
|
|
|
@ -74,13 +74,11 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<constructor><![CDATA[
|
||||
this.mOpened = false;
|
||||
]]></constructor>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="bindingattached"><![CDATA[
|
||||
this.mOpened = false;
|
||||
]]></handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
|
@ -91,16 +91,15 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="bindingattached"><![CDATA[
|
||||
<constructor><![CDATA[
|
||||
this.mEditorCache = {};
|
||||
this.mEditing = false;
|
||||
this.mEditingCell = null;
|
||||
this.mEditingEditor = null;
|
||||
]]></handler>
|
||||
]]></constructor>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="mousedown"><![CDATA[
|
||||
if (this.mEditing && event.target != this.mEditingEditor)
|
||||
this.stopEdit();
|
||||
|
|
|
@ -1095,16 +1095,17 @@ CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, PRInt32 aDocIndex,
|
|||
|
||||
if (sheetMap) {
|
||||
PRInt32 insertIndex = sheetMap->Count();
|
||||
PRBool insertedSheet = PR_FALSE;
|
||||
while (0 <= --insertIndex) {
|
||||
PRInt32 targetIndex = (PRInt32)sheetMap->ElementAt(insertIndex);
|
||||
if (targetIndex < aDocIndex) {
|
||||
mDocument->InsertStyleSheetAt(aSheet, insertIndex + 1, aNotify);
|
||||
sheetMap->InsertElementAt((void*)aDocIndex, insertIndex + 1);
|
||||
aSheet = nsnull;
|
||||
insertedSheet = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nsnull != aSheet) { // didn't insert yet
|
||||
if (!insertedSheet) { // didn't insert yet
|
||||
mDocument->InsertStyleSheetAt(aSheet, 0, aNotify);
|
||||
sheetMap->InsertElementAt((void*)aDocIndex, 0);
|
||||
}
|
||||
|
|
|
@ -387,17 +387,15 @@
|
|||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="bindingattached">
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
// initialize strings
|
||||
var bundle = srGetStrBundle("chrome://messenger/locale/messenger.properties");
|
||||
this.fillStringsForChildren(document.getAnonymousNodes(this)[1].firstChild, bundle);
|
||||
this.fillStringsForChildren(document.getAnonymousNodes(this)[2].firstChild, bundle);
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
<binding id="searchterm" name="searchTerm" extends="xul:box">
|
||||
<implementation>
|
||||
|
|
|
@ -377,12 +377,12 @@ oncommand="goPreferences('pref-themes.xul','chrome://communicator/content/pref/p
|
|||
|
||||
<menu value="XBL Demos">
|
||||
<menupopup>
|
||||
<menuitem value="#0 Remote XBL" oncommand="window._content.location.href='http://www.shadowland.org/xbl/test0/test.xul'"/>
|
||||
<menuitem value="#1 Technicolor DIV" oncommand="window._content.location.href='http://www.shadowland.org/xbl/test1/test.html'"/>
|
||||
<menuitem value="#2 Rollover Madness" oncommand="window._content.location.href='http://www.shadowland.org/xbl/test2/test.html'"/>
|
||||
<menuitem value="#3 Popups in HTML" oncommand="window._content.location.href='http://www.shadowland.org/xbl/test3/test.html'"/>
|
||||
<menuitem value="#4 Partition Magic" oncommand="window._content.location.href='http://www.shadowland.org/xbl/test4/test.html'"/>
|
||||
<menuitem value="#5 Sticky Notes" oncommand="window._content.location.href='http://www.shadowland.org/xbl/test5/test.html'"/>
|
||||
<menuitem value="#0 Remote XBL" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test0/test.xul'"/>
|
||||
<menuitem value="#1 Technicolor DIV" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test1/test.html'"/>
|
||||
<menuitem value="#2 Rollover Madness" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test2/test.html'"/>
|
||||
<menuitem value="#3 Popups in HTML" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test3/test.html'"/>
|
||||
<menuitem value="#4 Partition Magic" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test4/test.html'"/>
|
||||
<menuitem value="#5 Sticky Notes" oncommand="window._content.location.href='http://www.mozilla.org/projects/xbl/test5/test.html'"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
|
|
|
@ -321,14 +321,12 @@
|
|||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
||||
<constructor> this.init(); </constructor>
|
||||
<destructor> this.destroy(); </destructor>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="bindingattached"> this.init(); </handler>
|
||||
|
||||
<handler event="bindingdetached"> this.destroy(); </handler>
|
||||
|
||||
<handler event="mousedown"><![CDATA[
|
||||
if (event.button == 0 || event.button == 2) {
|
||||
var target = event.originalTarget;
|
||||
|
|
|
@ -238,13 +238,13 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<constructor><![CDATA[
|
||||
this.initialize();
|
||||
]]></constructor>
|
||||
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="bindingattached"><![CDATA[
|
||||
this.initialize();
|
||||
]]></handler>
|
||||
|
||||
<handler event="mouseover"><![CDATA[
|
||||
this.hoverCell(event.originalTarget);
|
||||
]]></handler>
|
||||
|
@ -399,13 +399,13 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<constructor><![CDATA[
|
||||
this.initialize();
|
||||
]]></constructor>
|
||||
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="bindingattached"><![CDATA[
|
||||
this.initialize();
|
||||
]]></handler>
|
||||
|
||||
<handler event="keydown"><![CDATA[
|
||||
// open popup if key is up/left/right/down and popup is closed
|
||||
if (event.keyCode > 36 && event.keyCode < 41 && !this.mOpen)
|
||||
|
|
|
@ -28,9 +28,11 @@
|
|||
}
|
||||
]]>
|
||||
</handler>
|
||||
<handler event="bindingattached" action="this.setInitialSelection()"/>
|
||||
</handlers>
|
||||
<implementation>
|
||||
<constructor>
|
||||
this.setInitialSelection()
|
||||
</constructor>
|
||||
<method name="setInitialSelection">
|
||||
<body>
|
||||
<![CDATA[
|
||||
|
|
|
@ -64,10 +64,10 @@
|
|||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<constructor>
|
||||
this.initScrollbar();
|
||||
</constructor>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="bindingattached" action="this.initScrollbar();"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
|
||||
|
|
|
@ -108,30 +108,28 @@
|
|||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
// first and last tabs need to be able to have unique styles
|
||||
// and also need to select first tab on startup.
|
||||
var tabs = this.getElementsByTagNameNS(
|
||||
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
||||
"tab");
|
||||
if (tabs.length) {
|
||||
if (tabs.length > 1) {
|
||||
tabs[0].setAttribute("first-tab", "true");
|
||||
tabs[tabs.length - 1].setAttribute("last-tab", "true");
|
||||
}
|
||||
else if (tabs.length == 1)
|
||||
tabs[0].setAttribute("first-tab", "true");
|
||||
}
|
||||
this.selectedTab = tabs[0];
|
||||
var o = this.getAttribute("orient");
|
||||
if (!o)
|
||||
this.setAttribute("orient", "horizontal");
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="bindingattached">
|
||||
<![CDATA[
|
||||
// first and last tabs need to be able to have unique styles
|
||||
// and also need to select first tab on startup.
|
||||
var tabs = this.getElementsByTagNameNS(
|
||||
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
||||
"tab");
|
||||
if (tabs.length) {
|
||||
if (tabs.length > 1) {
|
||||
tabs[0].setAttribute("first-tab", "true");
|
||||
tabs[tabs.length - 1].setAttribute("last-tab", "true");
|
||||
}
|
||||
else if (tabs.length == 1)
|
||||
tabs[0].setAttribute("first-tab", "true");
|
||||
}
|
||||
this.selectedTab = tabs[0];
|
||||
var o = this.getAttribute("orient");
|
||||
if (!o)
|
||||
this.setAttribute("orient", "horizontal");
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="tabpanel" extends="xul:deck">
|
||||
|
|
|
@ -192,12 +192,10 @@ Contributor(s):
|
|||
return val;
|
||||
</setter>
|
||||
</property>
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="bindingattached">
|
||||
<constructor>
|
||||
this.init(event);
|
||||
</handler>
|
||||
</handlers>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="toolbar" extends="xul:box">
|
||||
|
|
|
@ -358,6 +358,13 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<constructor action="var str = this.boxObject.getProperty('value');
|
||||
if (str) {
|
||||
this.inputField.value=str;
|
||||
this.boxObject.removeProperty('value');
|
||||
}"/>
|
||||
<destructor action="if (this.inputField.value) this.boxObject.setProperty('value', this.inputField.value);"/>
|
||||
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="focus" phase="capturing">
|
||||
|
@ -378,14 +385,7 @@
|
|||
}
|
||||
]]>
|
||||
</handler>
|
||||
<!-- Ensure that our state gets saved/restored across skin switches. -->
|
||||
<handler event="bindingattached" action="var str = this.boxObject.getProperty('value');
|
||||
if (str) {
|
||||
this.inputField.value=str;
|
||||
this.boxObject.removeProperty('value');
|
||||
}"/>
|
||||
<handler event="bindingdetached" action="if (this.inputField.value) this.boxObject.setProperty('value', this.inputField.value);"/>
|
||||
</handlers>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="textarea" extends="chrome://global/content/xulBindings.xml#textfield">
|
||||
|
|
Загрузка…
Ссылка в новой задаче