mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Make elements deal better with a no-op SetDocument call. Bug 212262,
r=caillon, sr=jst
This commit is contained in:
parent
d042aa0b80
commit
679ed391c9
@ -230,16 +230,19 @@ NS_IMETHODIMP
|
||||
nsHTMLAnchorElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
|
||||
// Unregister the access key for the old document.
|
||||
if (mDocument) {
|
||||
if (documentChanging && mDocument) {
|
||||
RegUnRegAccessKey(PR_FALSE);
|
||||
}
|
||||
|
||||
nsresult rv = nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep,
|
||||
aCompileEventHandlers);
|
||||
nsresult rv =
|
||||
nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep,
|
||||
aCompileEventHandlers);
|
||||
|
||||
// Register the access key for the new document.
|
||||
if (mDocument) {
|
||||
if (documentChanging && mDocument) {
|
||||
RegUnRegAccessKey(PR_TRUE);
|
||||
}
|
||||
|
||||
|
@ -272,8 +272,10 @@ NS_IMETHODIMP
|
||||
nsHTMLAreaElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
|
||||
// Unregister the access key for the old document.
|
||||
if (mDocument) {
|
||||
if (documentChanging && mDocument) {
|
||||
RegUnRegAccessKey(PR_FALSE);
|
||||
}
|
||||
|
||||
@ -281,7 +283,7 @@ nsHTMLAreaElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
aCompileEventHandlers);
|
||||
|
||||
// Register the access key for the new document.
|
||||
if (mDocument) {
|
||||
if (documentChanging && mDocument) {
|
||||
RegUnRegAccessKey(PR_TRUE);
|
||||
}
|
||||
|
||||
|
@ -511,7 +511,7 @@ NS_IMETHODIMP
|
||||
nsHTMLBodyElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
if (nsnull != mContentStyleRule) {
|
||||
if (aDocument != mDocument && mContentStyleRule) {
|
||||
mContentStyleRule->mPart = nsnull;
|
||||
mContentStyleRule->mSheet = nsnull;
|
||||
|
||||
|
@ -311,16 +311,19 @@ NS_IMETHODIMP
|
||||
nsHTMLLabelElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
|
||||
// Unregister the access key for the old document.
|
||||
if (mDocument) {
|
||||
if (documentChanging && mDocument) {
|
||||
RegUnRegAccessKey(PR_FALSE);
|
||||
}
|
||||
|
||||
nsresult rv = nsGenericHTMLContainerFormElement::SetDocument(aDocument,
|
||||
aDeep, aCompileEventHandlers);
|
||||
nsresult rv =
|
||||
nsGenericHTMLContainerFormElement::SetDocument(aDocument, aDeep,
|
||||
aCompileEventHandlers);
|
||||
|
||||
// Register the access key for the new document.
|
||||
if (mDocument) {
|
||||
if (documentChanging && mDocument) {
|
||||
RegUnRegAccessKey(PR_TRUE);
|
||||
}
|
||||
|
||||
|
@ -138,24 +138,30 @@ NS_IMETHODIMP
|
||||
nsHTMLMapElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
|
||||
nsresult rv;
|
||||
PRBool documentChanging = (aDocument != mDocument);
|
||||
|
||||
if (documentChanging) {
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
|
||||
|
||||
if (htmlDoc) {
|
||||
htmlDoc->RemoveImageMap(this);
|
||||
if (htmlDoc) {
|
||||
htmlDoc->RemoveImageMap(this);
|
||||
}
|
||||
}
|
||||
|
||||
rv = nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep,
|
||||
aCompileEventHandlers);
|
||||
nsresult rv = nsGenericHTMLContainerElement::SetDocument(aDocument, aDeep,
|
||||
aCompileEventHandlers);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (documentChanging) {
|
||||
// Since we changed the document, gotta re-QI
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(mDocument));
|
||||
|
||||
// Since we changed the document, gotta re-QI
|
||||
htmlDoc = do_QueryInterface(mDocument);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && htmlDoc) {
|
||||
htmlDoc->AddImageMap(this);
|
||||
if (htmlDoc) {
|
||||
htmlDoc->AddImageMap(this);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
Reference in New Issue
Block a user