[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-142-g786665c
commit-queue at webkit.org
commit-queue at webkit.org
Mon Dec 27 16:27:37 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 6522820df006f5547df144f3c2d3450dd91b803e
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Dec 21 19:24:08 2010 +0000
2010-12-21 Yong Li <yoli at rim.com>
Reviewed by Adam Barth.
Suspend HTMLParserScheduler when page load is deferred to
avoid potential JS re-entrancy. Otherwise, when JS execution is triggered
from an external script or by events, and is blocked by a modal dialog,
WebKit can parse more HTML source and also start another JS execution.
https://bugs.webkit.org/show_bug.cgi?id=48077
Test case: WebCore/manual-tests/bugzilla-48077.html.
* dom/DocumentParser.cpp:
(WebCore::DocumentParser::suspendParsing):
(WebCore::DocumentParser::resumeParsing):
* dom/DocumentParser.h:
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::suspendParsing):
(WebCore::HTMLDocumentParser::resumeParsing):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
(WebCore::HTMLParserScheduler::isScheduledForResume):
* page/PageGroupLoadDeferrer.cpp:
(WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer):
(WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74420 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f4f20ea..e2d02cf 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-12-21 Yong Li <yoli at rim.com>
+
+ Reviewed by Adam Barth.
+
+ Suspend HTMLParserScheduler when page load is deferred to
+ avoid potential JS re-entrancy. Otherwise, when JS execution is triggered
+ from an external script or by events, and is blocked by a modal dialog,
+ WebKit can parse more HTML source and also start another JS execution.
+
+ https://bugs.webkit.org/show_bug.cgi?id=48077
+
+ Test case: WebCore/manual-tests/bugzilla-48077.html.
+
+ * dom/DocumentParser.cpp:
+ (WebCore::DocumentParser::suspendParsing):
+ (WebCore::DocumentParser::resumeParsing):
+ * dom/DocumentParser.h:
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::suspendParsing):
+ (WebCore::HTMLDocumentParser::resumeParsing):
+ * html/parser/HTMLParserScheduler.cpp:
+ (WebCore::HTMLParserScheduler::HTMLParserScheduler):
+ (WebCore::HTMLParserScheduler::suspend):
+ (WebCore::HTMLParserScheduler::resume):
+ * html/parser/HTMLParserScheduler.h:
+ (WebCore::HTMLParserScheduler::isScheduledForResume):
+ * page/PageGroupLoadDeferrer.cpp:
+ (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer):
+ (WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer):
+
2010-12-21 Anders Carlsson <andersca at apple.com>
Reviewed by John Sullivan.
diff --git a/WebCore/dom/DocumentParser.cpp b/WebCore/dom/DocumentParser.cpp
index 5f8e04f..f4eebcc 100644
--- a/WebCore/dom/DocumentParser.cpp
+++ b/WebCore/dom/DocumentParser.cpp
@@ -68,5 +68,13 @@ void DocumentParser::detach()
m_document = 0;
}
+void DocumentParser::suspendParsing()
+{
+}
+
+void DocumentParser::resumeParsing()
+{
+}
+
};
diff --git a/WebCore/dom/DocumentParser.h b/WebCore/dom/DocumentParser.h
index aa18a64..bedae8d 100644
--- a/WebCore/dom/DocumentParser.h
+++ b/WebCore/dom/DocumentParser.h
@@ -91,6 +91,10 @@ public:
void setDocumentWasLoadedAsPartOfNavigation() { m_documentWasLoadedAsPartOfNavigation = true; }
bool documentWasLoadedAsPartOfNavigation() const { return m_documentWasLoadedAsPartOfNavigation; }
+ // FIXME: The names are not very accurate :(
+ virtual void suspendParsing();
+ virtual void resumeParsing();
+
protected:
DocumentParser(Document*);
diff --git a/WebCore/html/parser/HTMLDocumentParser.cpp b/WebCore/html/parser/HTMLDocumentParser.cpp
index c32f9db..9b9780c 100644
--- a/WebCore/html/parser/HTMLDocumentParser.cpp
+++ b/WebCore/html/parser/HTMLDocumentParser.cpp
@@ -519,4 +519,14 @@ bool HTMLDocumentParser::usePreHTML5ParserQuirks(Document* document)
return document->settings() && document->settings()->usePreHTML5ParserQuirks();
}
+void HTMLDocumentParser::suspendParsing()
+{
+ m_parserScheduler->suspend();
+}
+
+void HTMLDocumentParser::resumeParsing()
+{
+ m_parserScheduler->resume();
+}
+
}
diff --git a/WebCore/html/parser/HTMLDocumentParser.h b/WebCore/html/parser/HTMLDocumentParser.h
index 05053df..27bb11b 100644
--- a/WebCore/html/parser/HTMLDocumentParser.h
+++ b/WebCore/html/parser/HTMLDocumentParser.h
@@ -93,6 +93,8 @@ private:
virtual void executeScriptsWaitingForStylesheets();
virtual int lineNumber() const;
virtual TextPosition0 textPosition() const;
+ virtual void suspendParsing();
+ virtual void resumeParsing();
// HTMLScriptRunnerHost
virtual void watchForLoad(CachedResource*);
diff --git a/WebCore/html/parser/HTMLParserScheduler.cpp b/WebCore/html/parser/HTMLParserScheduler.cpp
index 6e67697..56db1aa 100644
--- a/WebCore/html/parser/HTMLParserScheduler.cpp
+++ b/WebCore/html/parser/HTMLParserScheduler.cpp
@@ -65,6 +65,7 @@ HTMLParserScheduler::HTMLParserScheduler(HTMLDocumentParser* parser)
, m_parserTimeLimit(parserTimeLimit(m_parser->document()->page()))
, m_parserChunkSize(parserChunkSize(m_parser->document()->page()))
, m_continueNextChunkTimer(this, &HTMLParserScheduler::continueNextChunkTimerFired)
+ , m_isSuspendedWithActiveTimer(false)
{
}
@@ -92,4 +93,22 @@ void HTMLParserScheduler::continueNextChunkTimerFired(Timer<HTMLParserScheduler>
m_parser->resumeParsingAfterYield();
}
+void HTMLParserScheduler::suspend()
+{
+ ASSERT(!m_isSuspendedWithActiveTimer);
+ if (!m_continueNextChunkTimer.isActive())
+ return;
+ m_isSuspendedWithActiveTimer = true;
+ m_continueNextChunkTimer.stop();
+}
+
+void HTMLParserScheduler::resume()
+{
+ ASSERT(!m_continueNextChunkTimer.isActive());
+ if (!m_isSuspendedWithActiveTimer)
+ return;
+ m_isSuspendedWithActiveTimer = false;
+ m_continueNextChunkTimer.startOneShot(0);
+}
+
}
diff --git a/WebCore/html/parser/HTMLParserScheduler.h b/WebCore/html/parser/HTMLParserScheduler.h
index 5be33b0..3a20b2b 100644
--- a/WebCore/html/parser/HTMLParserScheduler.h
+++ b/WebCore/html/parser/HTMLParserScheduler.h
@@ -71,7 +71,10 @@ public:
return true;
}
- bool isScheduledForResume() const { return m_continueNextChunkTimer.isActive(); }
+ bool isScheduledForResume() const { return m_isSuspendedWithActiveTimer || m_continueNextChunkTimer.isActive(); }
+
+ void suspend();
+ void resume();
private:
HTMLParserScheduler(HTMLDocumentParser*);
@@ -83,6 +86,7 @@ private:
double m_parserTimeLimit;
int m_parserChunkSize;
Timer<HTMLParserScheduler> m_continueNextChunkTimer;
+ bool m_isSuspendedWithActiveTimer;
};
}
diff --git a/WebCore/page/PageGroupLoadDeferrer.cpp b/WebCore/page/PageGroupLoadDeferrer.cpp
index 98a4720..680c52f 100644
--- a/WebCore/page/PageGroupLoadDeferrer.cpp
+++ b/WebCore/page/PageGroupLoadDeferrer.cpp
@@ -22,6 +22,7 @@
#include "PageGroupLoadDeferrer.h"
#include "AsyncScriptRunner.h"
+#include "DocumentParser.h"
#include "Frame.h"
#include "Page.h"
#include "PageGroup.h"
@@ -49,6 +50,8 @@ PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
frame->document()->suspendActiveDOMObjects(ActiveDOMObject::WillShowDialog);
frame->document()->asyncScriptRunner()->suspend();
+ if (DocumentParser* parser = frame->document()->parser())
+ parser->suspendParsing();
}
}
}
@@ -69,6 +72,8 @@ PageGroupLoadDeferrer::~PageGroupLoadDeferrer()
for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
frame->document()->resumeActiveDOMObjects();
frame->document()->asyncScriptRunner()->resume();
+ if (DocumentParser* parser = frame->document()->parser())
+ parser->resumeParsing();
}
}
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list