зеркало из https://github.com/mozilla/gecko-dev.git
Call BeginUpdate before going into the guts of updating a style attribute so that the resulting flush happens sooner. (Bug 522595) r=bzbarsky
This commit is contained in:
Родитель
d9e602a186
Коммит
ab7ecc4372
|
@ -916,6 +916,7 @@ public:
|
|||
nsICSSLoader** aCSSLoader,
|
||||
nsICSSParser** aCSSParser);
|
||||
virtual nsresult DeclarationChanged();
|
||||
virtual nsIDocument* DocToUpdate();
|
||||
|
||||
// Override |AddRef| and |Release| for being a member of
|
||||
// |DOMCSSStyleRuleImpl|.
|
||||
|
@ -1109,6 +1110,12 @@ DOMCSSDeclarationImpl::DeclarationChanged()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocument*
|
||||
DOMCSSDeclarationImpl::DocToUpdate()
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
DOMCSSStyleRuleImpl::DOMCSSStyleRuleImpl(nsICSSStyleRule* aRule)
|
||||
: mDOMDeclaration(aRule)
|
||||
{
|
||||
|
|
|
@ -105,6 +105,14 @@ nsDOMCSSAttributeDeclaration::DeclarationChanged()
|
|||
mContent->SetInlineStyleRule(newRule, PR_TRUE);
|
||||
}
|
||||
|
||||
nsIDocument*
|
||||
nsDOMCSSAttributeDeclaration::DocToUpdate()
|
||||
{
|
||||
// We need GetOwnerDoc() rather than GetCurrentDoc() because it might
|
||||
// be the BeginUpdate call that inserts mContent into the document.
|
||||
return mContent->GetOwnerDoc();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMCSSAttributeDeclaration::GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
PRBool aAllocate)
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual nsresult DeclarationChanged();
|
||||
virtual nsIDocument* DocToUpdate();
|
||||
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "nsIPrincipal.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
|
||||
|
||||
nsDOMCSSDeclaration::~nsDOMCSSDeclaration()
|
||||
|
@ -263,6 +264,13 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
|
|||
return result;
|
||||
}
|
||||
|
||||
// For nsDOMCSSAttributeDeclaration, DeclarationChanged will lead to
|
||||
// Attribute setting code, which leads in turn to BeginUpdate. We
|
||||
// need to start the update now so that the old rule doesn't get used
|
||||
// between when we mutate the declaration and when we set the new
|
||||
// rule (see stack in bug 209575).
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), PR_TRUE);
|
||||
|
||||
PRBool changed;
|
||||
result = cssParser->ParseProperty(aPropID, aPropValue, sheetURI, baseURI,
|
||||
sheetPrincipal, decl, &changed);
|
||||
|
@ -303,6 +311,13 @@ nsDOMCSSDeclaration::ParseDeclaration(const nsAString& aDecl,
|
|||
return result;
|
||||
}
|
||||
|
||||
// For nsDOMCSSAttributeDeclaration, DeclarationChanged will lead to
|
||||
// Attribute setting code, which leads in turn to BeginUpdate. We
|
||||
// need to start the update now so that the old rule doesn't get used
|
||||
// between when we mutate the declaration and when we set the new
|
||||
// rule (see stack in bug 209575).
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), PR_TRUE);
|
||||
|
||||
PRBool changed;
|
||||
result = cssParser->ParseAndAppendDeclaration(aDecl, sheetURI, baseURI,
|
||||
sheetPrincipal, decl,
|
||||
|
@ -330,6 +345,13 @@ nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
|
|||
return rv;
|
||||
}
|
||||
|
||||
// For nsDOMCSSAttributeDeclaration, DeclarationChanged will lead to
|
||||
// Attribute setting code, which leads in turn to BeginUpdate. We
|
||||
// need to start the update now so that the old rule doesn't get used
|
||||
// between when we mutate the declaration and when we set the new
|
||||
// rule (see stack in bug 209575).
|
||||
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), PR_TRUE);
|
||||
|
||||
rv = decl->RemoveProperty(aPropID);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
@ -50,6 +50,7 @@ class nsICSSParser;
|
|||
class nsICSSLoader;
|
||||
class nsIURI;
|
||||
class nsIPrincipal;
|
||||
class nsIDocument;
|
||||
|
||||
class CSS2PropertiesTearoff : public nsIDOMNSCSS2Properties
|
||||
{
|
||||
|
@ -101,6 +102,10 @@ protected:
|
|||
virtual nsresult GetCSSDeclaration(nsCSSDeclaration **aDecl,
|
||||
PRBool aAllocate) = 0;
|
||||
virtual nsresult DeclarationChanged() = 0;
|
||||
// Document that we must call BeginUpdate/EndUpdate on around the
|
||||
// calls to DeclarationChanged and the style rule mutation that leads
|
||||
// to it.
|
||||
virtual nsIDocument* DocToUpdate() = 0;
|
||||
|
||||
// This will only fail if it can't get a parser or a principal.
|
||||
// This means it can return NS_OK without aURI or aCSSLoader being
|
||||
|
|
Загрузка…
Ссылка в новой задаче