mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 657353 part 1. Switch the XML prettyprinter to using a script runner instead of EndUpdate to determine when to drop prettyprinting. r=sicking
This commit is contained in:
parent
967c22d3ce
commit
5bb505a0b1
@ -198,44 +198,33 @@ nsXMLPrettyPrinter::MaybeUnhook(nsIContent* aContent)
|
||||
{
|
||||
// If there either aContent is null (the document-node was modified) or
|
||||
// there isn't a binding parent we know it's non-anonymous content.
|
||||
if (!aContent || !aContent->GetBindingParent()) {
|
||||
if (!aContent || !aContent->GetBindingParent() && !mUnhookPending) {
|
||||
// Can't blindly to mUnhookPending after AddScriptRunner,
|
||||
// since AddScriptRunner _could_ in theory run us
|
||||
// synchronously
|
||||
mUnhookPending = PR_TRUE;
|
||||
nsContentUtils::AddScriptRunner(
|
||||
NS_NewRunnableMethod(this, &nsXMLPrettyPrinter::Unhook));
|
||||
}
|
||||
}
|
||||
|
||||
// nsIDocumentObserver implementation
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::BeginUpdate(nsIDocument* aDocument,
|
||||
nsUpdateType aUpdateType)
|
||||
nsXMLPrettyPrinter::Unhook()
|
||||
{
|
||||
mUpdateDepth++;
|
||||
}
|
||||
mDocument->RemoveObserver(this);
|
||||
nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(mDocument);
|
||||
nsCOMPtr<nsIDOMElement> rootElem;
|
||||
document->GetDocumentElement(getter_AddRefs(rootElem));
|
||||
|
||||
void
|
||||
nsXMLPrettyPrinter::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType)
|
||||
{
|
||||
mUpdateDepth--;
|
||||
|
||||
// Only remove the binding once we're outside all updates. This protects us
|
||||
// from nasty surprices of elements being removed from the document in the
|
||||
// midst of setting attributes etc.
|
||||
if (mUnhookPending && mUpdateDepth == 0) {
|
||||
mDocument->RemoveObserver(this);
|
||||
nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(mDocument);
|
||||
nsCOMPtr<nsIDOMElement> rootElem;
|
||||
document->GetDocumentElement(getter_AddRefs(rootElem));
|
||||
|
||||
if (rootElem) {
|
||||
nsCOMPtr<nsIDOMDocumentXBL> xblDoc = do_QueryInterface(mDocument);
|
||||
xblDoc->RemoveBinding(rootElem,
|
||||
NS_LITERAL_STRING("chrome://global/content/xml/XMLPrettyPrint.xml#prettyprint"));
|
||||
}
|
||||
|
||||
mDocument = nsnull;
|
||||
|
||||
NS_RELEASE_THIS();
|
||||
if (rootElem) {
|
||||
nsCOMPtr<nsIDOMDocumentXBL> xblDoc = do_QueryInterface(mDocument);
|
||||
xblDoc->RemoveBinding(rootElem,
|
||||
NS_LITERAL_STRING("chrome://global/content/xml/XMLPrettyPrint.xml#prettyprint"));
|
||||
}
|
||||
|
||||
mDocument = nsnull;
|
||||
|
||||
NS_RELEASE_THIS();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -51,10 +51,6 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDocumentObserver
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE
|
||||
NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE
|
||||
|
||||
// nsIMutationObserver
|
||||
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
||||
@ -72,6 +68,10 @@ public:
|
||||
*/
|
||||
nsresult PrettyPrint(nsIDocument* aDocument, PRBool* aDidPrettyPrint);
|
||||
|
||||
/**
|
||||
* Unhook the prettyprinter
|
||||
*/
|
||||
void Unhook();
|
||||
private:
|
||||
/**
|
||||
* Signals for unhooking by setting mUnhookPending if the node changed is
|
||||
|
Loading…
Reference in New Issue
Block a user