backing out due to test failure
git-svn-id: svn://10.0.0.236/trunk@237943 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
6b7af38086
commit
e2a13b987b
@ -933,11 +933,6 @@ nsBindingManager::ProcessAttachedQueue()
|
||||
mAttachedStack.RemoveElementAt(lastItem);
|
||||
|
||||
NS_ASSERTION(binding, "null item in attached stack?");
|
||||
nsresult rv = binding->EnsureScriptAPI();
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
binding->ExecuteAttachedHandler();
|
||||
}
|
||||
|
||||
|
||||
@ -272,8 +272,7 @@ nsXBLBinding::nsXBLBinding(nsXBLPrototypeBinding* aBinding)
|
||||
: mPrototypeBinding(aBinding),
|
||||
mInsertionPointTable(nsnull),
|
||||
mIsStyleBinding(PR_TRUE),
|
||||
mMarkedForDeath(PR_FALSE),
|
||||
mInstalledAPI(PR_FALSE)
|
||||
mMarkedForDeath(PR_FALSE)
|
||||
{
|
||||
NS_ASSERTION(mPrototypeBinding, "Must have a prototype binding!");
|
||||
// Grab a ref to the document info so the prototype binding won't die
|
||||
@ -376,6 +375,18 @@ nsXBLBinding::SetBoundElement(nsIContent* aElement)
|
||||
mNextBinding->SetBoundElement(aElement);
|
||||
}
|
||||
|
||||
nsXBLBinding*
|
||||
nsXBLBinding::GetFirstBindingWithConstructor()
|
||||
{
|
||||
if (mPrototypeBinding->GetConstructor())
|
||||
return this;
|
||||
|
||||
if (mNextBinding)
|
||||
return mNextBinding->GetFirstBindingWithConstructor();
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXBLBinding::HasStyleSheets() const
|
||||
{
|
||||
@ -789,22 +800,6 @@ nsXBLBinding::GenerateAnonymousContent()
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXBLBinding::EnsureScriptAPI()
|
||||
{
|
||||
if (mInstalledAPI) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Set mInstalledAPI right away since we'll recurse into here from
|
||||
// nsElementSH::PostCreate when InstallImplementation is called.
|
||||
mInstalledAPI = PR_TRUE;
|
||||
|
||||
InstallEventHandlers();
|
||||
|
||||
return InstallImplementation();
|
||||
}
|
||||
|
||||
void
|
||||
nsXBLBinding::InstallEventHandlers()
|
||||
{
|
||||
|
||||
@ -120,13 +120,15 @@ public:
|
||||
|
||||
void GenerateAnonymousContent();
|
||||
void InstallAnonymousContent(nsIContent* aAnonParent, nsIContent* aElement);
|
||||
nsresult EnsureScriptAPI();
|
||||
void InstallEventHandlers();
|
||||
nsresult InstallImplementation();
|
||||
|
||||
void ExecuteAttachedHandler();
|
||||
void ExecuteDetachedHandler();
|
||||
void UnhookEventHandlers();
|
||||
|
||||
nsIAtom* GetBaseTag(PRInt32* aNameSpaceID);
|
||||
nsXBLBinding* GetFirstBindingWithConstructor();
|
||||
nsXBLBinding* RootBinding();
|
||||
nsXBLBinding* GetFirstStyleBinding();
|
||||
|
||||
@ -167,12 +169,6 @@ public:
|
||||
|
||||
// MEMBER VARIABLES
|
||||
protected:
|
||||
// These two functions recursively install the event handlers
|
||||
// and implementation on this binding and its base class bindings.
|
||||
// External callers should call EnsureScriptAPI instead.
|
||||
void InstallEventHandlers();
|
||||
nsresult InstallImplementation();
|
||||
|
||||
nsAutoRefCnt mRefCnt;
|
||||
nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo
|
||||
nsCOMPtr<nsIContent> mContent; // Strong. Our anonymous content stays around with us.
|
||||
@ -185,7 +181,6 @@ protected:
|
||||
|
||||
PRPackedBool mIsStyleBinding;
|
||||
PRPackedBool mMarkedForDeath;
|
||||
PRPackedBool mInstalledAPI;
|
||||
};
|
||||
|
||||
#endif // nsXBLBinding_h_
|
||||
|
||||
@ -579,11 +579,20 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL,
|
||||
// Tell the binding to build the anonymous content.
|
||||
newBinding->GenerateAnonymousContent();
|
||||
|
||||
// Tell the binding to install event handlers
|
||||
newBinding->InstallEventHandlers();
|
||||
|
||||
// Set up our properties
|
||||
rv = newBinding->InstallImplementation();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Figure out if we need to execute a constructor.
|
||||
*aBinding = newBinding->GetFirstBindingWithConstructor();
|
||||
NS_IF_ADDREF(*aBinding);
|
||||
|
||||
// Figure out if we have any scoped sheets. If so, we do a second resolve.
|
||||
*aResolveStyle = newBinding->HasStyleSheets();
|
||||
|
||||
newBinding.swap(*aBinding);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -6971,19 +6971,11 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
// We must ensure that the XBL Binding is installed before we hand
|
||||
// back this object.
|
||||
|
||||
nsRefPtr<nsXBLBinding> binding;
|
||||
if ((binding = doc->BindingManager()->GetBinding(content))) {
|
||||
// There's already a binding for this element, make sure that
|
||||
// the script API has been installed.
|
||||
// Note that this could end up recusing into code that calls
|
||||
// WrapNative. So don't do anything important beyond this point
|
||||
// as that will not be done to the wrapper returned from that
|
||||
// WrapNative call.
|
||||
// In theory we could also call ExecuteAttachedHandler here if
|
||||
// we also removed the binding from the PAQ queue, but that seems
|
||||
// like a scary change that would mosly just add more inconsistencies.
|
||||
if (doc->BindingManager()->GetBinding(content)) {
|
||||
// There's already a binding for this element so nothing left to
|
||||
// be done here.
|
||||
|
||||
return binding->EnsureScriptAPI();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the computed -moz-binding directly from the style context
|
||||
@ -6992,6 +6984,7 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
|
||||
// Make sure the style context goes away _before_ we execute the binding
|
||||
// constructor, since the constructor can destroy the relevant presshell.
|
||||
nsRefPtr<nsXBLBinding> binding;
|
||||
{
|
||||
// Scope for the nsRefPtr
|
||||
nsRefPtr<nsStyleContext> sc = pctx->StyleSet()->ResolveStyleFor(content,
|
||||
@ -7016,17 +7009,12 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
}
|
||||
|
||||
if (binding) {
|
||||
|
||||
#ifdef DEBUG
|
||||
// Make sure the presshell is in a state where it's safe to execute script
|
||||
PRBool safeToRunScript = PR_FALSE;
|
||||
pctx->PresShell()->IsSafeToFlush(safeToRunScript);
|
||||
NS_ASSERTION(safeToRunScript, "Wrapping when it's not safe to flush");
|
||||
#endif
|
||||
|
||||
rv = binding->EnsureScriptAPI();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
binding->ExecuteAttachedHandler();
|
||||
if (safeToRunScript) {
|
||||
binding->ExecuteAttachedHandler();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user