[webkit-changes] cvs commit: WebCore/kwq KWQSignalStubs.mm
Geoffrey
ggaren at opensource.apple.com
Fri Oct 21 18:41:37 PDT 2005
ggaren 05/10/21 18:41:36
Modified: . ChangeLog
khtml khtml_part.cpp
khtml/html htmltokenizer.cpp htmltokenizer.h
khtml/xml xml_tokenizer.cpp xml_tokenizer.h
kwq KWQSignalStubs.mm
Log:
Reviewed by darin.
WebCore side of fix for <rdar://problem/4184719> window.print() followed by window.close()
causes world leak
No test case added because I have another reviewed patch that will include a test
for this bug as well as many others.
Under some conditions, [WebDataSource stopLoading] did not set [WebDataSource isLoading]
to false, so the didFInishLoad delegates never fired.
The reason isLoading didn't become false was that the tokenizer was still running.
The fix here is to add a call to Tokenizer::stopParsing inside HTMLPart::stopLoading.
Since the WebKit side of the fix eliminates an early return that used to protect
HTMLPart::stopLoading from multiple calls, I added an early return inside
HTMLPart::stopLoading.
I also merged stopped and stopLoading, and merged the way XMLTokenizer and HTMLTokenizer
track whether they're in a stopped state, because anything less would be uncivilized.
* khtml/html/htmltokenizer.cpp:
(khtml::HTMLTokenizer::HTMLTokenizer):
(khtml::HTMLTokenizer::write):
(khtml::HTMLTokenizer::stopParsing):
(khtml::HTMLTokenizer::processToken):
* khtml/html/htmltokenizer.h:
* khtml/khtml_part.cpp:
(KHTMLPart::stopLoading):
(KHTMLPart::endIfNotLoading):
(KHTMLPart::stop):
* khtml/xml/xml_tokenizer.cpp:
(khtml::Tokenizer::Tokenizer):
(khtml::Tokenizer::finishedParsing):
(khtml::XMLTokenizer::XMLTokenizer):
(khtml::XMLTokenizer::endElementNs):
(khtml::XMLTokenizer::characters):
(khtml::XMLTokenizer::error):
(khtml::XMLTokenizer::processingInstruction):
(khtml::XMLTokenizer::cdataBlock):
(khtml::XMLTokenizer::comment):
(khtml::XMLTokenizer::stopParsing):
* khtml/xml/xml_tokenizer.h:
(khtml::Tokenizer::stopParsing):
* kwq/KWQSignalStubs.mm:
(Loader::requestStarted):
Revision Changes Path
1.260 +49 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.259
retrieving revision 1.260
diff -u -r1.259 -r1.260
--- ChangeLog 22 Oct 2005 01:10:28 -0000 1.259
+++ ChangeLog 22 Oct 2005 01:41:34 -0000 1.260
@@ -1,3 +1,52 @@
+2005-10-21 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by darin.
+
+ WebCore side of fix for <rdar://problem/4184719> window.print() followed by window.close()
+ causes world leak
+
+ No test case added because I have another reviewed patch that will include a test
+ for this bug as well as many others.
+
+ Under some conditions, [WebDataSource stopLoading] did not set [WebDataSource isLoading]
+ to false, so the didFInishLoad delegates never fired.
+
+ The reason isLoading didn't become false was that the tokenizer was still running.
+ The fix here is to add a call to Tokenizer::stopParsing inside HTMLPart::stopLoading.
+
+ Since the WebKit side of the fix eliminates an early return that used to protect
+ HTMLPart::stopLoading from multiple calls, I added an early return inside
+ HTMLPart::stopLoading.
+
+ I also merged stopped and stopLoading, and merged the way XMLTokenizer and HTMLTokenizer
+ track whether they're in a stopped state, because anything less would be uncivilized.
+
+ * khtml/html/htmltokenizer.cpp:
+ (khtml::HTMLTokenizer::HTMLTokenizer):
+ (khtml::HTMLTokenizer::write):
+ (khtml::HTMLTokenizer::stopParsing):
+ (khtml::HTMLTokenizer::processToken):
+ * khtml/html/htmltokenizer.h:
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::stopLoading):
+ (KHTMLPart::endIfNotLoading):
+ (KHTMLPart::stop):
+ * khtml/xml/xml_tokenizer.cpp:
+ (khtml::Tokenizer::Tokenizer):
+ (khtml::Tokenizer::finishedParsing):
+ (khtml::XMLTokenizer::XMLTokenizer):
+ (khtml::XMLTokenizer::endElementNs):
+ (khtml::XMLTokenizer::characters):
+ (khtml::XMLTokenizer::error):
+ (khtml::XMLTokenizer::processingInstruction):
+ (khtml::XMLTokenizer::cdataBlock):
+ (khtml::XMLTokenizer::comment):
+ (khtml::XMLTokenizer::stopParsing):
+ * khtml/xml/xml_tokenizer.h:
+ (khtml::Tokenizer::stopParsing):
+ * kwq/KWQSignalStubs.mm:
+ (Loader::requestStarted):
+
2005-10-21 Beth Dakin <bdakin at apple.com>
Reviewed by Hyatt
1.348 +13 -12 WebCore/khtml/khtml_part.cpp
Index: khtml_part.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtml_part.cpp,v
retrieving revision 1.347
retrieving revision 1.348
diff -u -r1.347 -r1.348
--- khtml_part.cpp 21 Oct 2005 23:11:04 -0000 1.347
+++ khtml_part.cpp 22 Oct 2005 01:41:35 -0000 1.348
@@ -600,12 +600,13 @@
cancelRedirection();
}
-
void KHTMLPart::stopLoading(bool sendUnload)
-{
- if (d->m_doc && d->m_doc->tokenizer()) {
- d->m_doc->tokenizer()->stopParsing();
- }
+{
+ if (d->m_bComplete)
+ return;
+
+ if (d->m_doc && d->m_doc->tokenizer())
+ d->m_doc->tokenizer()->stopParsing();
if ( d->m_job )
{
@@ -1751,7 +1752,7 @@
if (d->m_decoder)
write(d->m_decoder->flush());
if (d->m_doc)
- d->m_doc->finishParsing();
+ d->m_doc->finishParsing();
else
// WebKit partially uses WebCore when loading non-HTML docs. In these cases doc==nil, but
// WebCore is enough involved that we need to checkCompleted() in order for m_bComplete to
@@ -1763,17 +1764,17 @@
void KHTMLPart::stop()
{
// make sure nothing's left in there...
- Tokenizer* t = d->m_doc ? d->m_doc->tokenizer() : 0;
- if (t)
- t->stopped();
- if (d->m_doc)
- d->m_doc->finishParsing();
- else
+ if (d->m_doc) {
+ if (d->m_doc->tokenizer())
+ d->m_doc->tokenizer()->stopParsing();
+ d->m_doc->finishParsing();
+ } else {
// WebKit partially uses WebCore when loading non-HTML docs. In these cases doc==nil, but
// WebCore is enough involved that we need to checkCompleted() in order for m_bComplete to
// become true. An example is when a subframe is a pure text doc, and that subframe is the
// last one to complete.
checkCompleted();
+ }
}
#if !APPLE_CHANGES
1.121 +4 -5 WebCore/khtml/html/htmltokenizer.cpp
Index: htmltokenizer.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/htmltokenizer.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- htmltokenizer.cpp 20 Oct 2005 06:02:23 -0000 1.120
+++ htmltokenizer.cpp 22 Oct 2005 01:41:35 -0000 1.121
@@ -170,7 +170,6 @@
onHold = false;
timerId = 0;
includesCommentsInDOM = includesComments;
- loadStopped = false;
begin();
}
@@ -188,7 +187,6 @@
onHold = false;
timerId = 0;
includesCommentsInDOM = includesComments;
- loadStopped = false;
begin();
}
@@ -1384,7 +1382,7 @@
if (!buffer)
return;
- if (loadStopped)
+ if (m_parserStopped)
return;
if ( ( m_executingScript && appendData ) || !pendingScripts.isEmpty() ) {
@@ -1552,8 +1550,9 @@
end(); // this actually causes us to be deleted
}
-void HTMLTokenizer::stopped()
+void HTMLTokenizer::stopParsing()
{
+ Tokenizer::stopParsing();
if (timerId) {
killTimer(timerId);
timerId = 0;
@@ -1730,7 +1729,7 @@
kdDebug( 6036 ) << endl;
#endif
- if (!loadStopped) {
+ if (!m_parserStopped) {
// pass the token over to the parser, the parser DOES NOT delete the token
parser->parseToken(&currToken);
}
1.43 +1 -1 WebCore/khtml/html/htmltokenizer.h
Index: htmltokenizer.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/htmltokenizer.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- htmltokenizer.h 18 Oct 2005 03:15:29 -0000 1.42
+++ htmltokenizer.h 22 Oct 2005 01:41:35 -0000 1.43
@@ -124,7 +124,7 @@
virtual void setOnHold(bool onHold);
virtual void setForceSynchronous(bool force);
virtual bool isWaitingForScripts() const;
- virtual void stopped();
+ virtual void stopParsing();
virtual bool processingData() const;
protected:
1.46 +28 -23 WebCore/khtml/xml/xml_tokenizer.cpp
Index: xml_tokenizer.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/xml_tokenizer.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- xml_tokenizer.cpp 10 Oct 2005 23:48:54 -0000 1.45
+++ xml_tokenizer.cpp 22 Oct 2005 01:41:36 -0000 1.46
@@ -68,6 +68,20 @@
typedef HashMap<DOMStringImpl *, DOMStringImpl *> PrefixForNamespaceMap;
+Tokenizer::Tokenizer() : m_parserStopped(false)
+#if APPLE_CHANGES
+ , m_finishedParsing(this, SIGNAL(finishedParsing()))
+#endif
+{
+}
+
+void Tokenizer::finishedParsing()
+{
+#if APPLE_CHANGES
+ m_finishedParsing.call();
+#endif
+}
+
class XMLTokenizer : public Tokenizer, public CachedObjectClient
{
public:
@@ -82,6 +96,7 @@
virtual void finish();
virtual void setOnHold(bool onHold);
virtual bool isWaitingForScripts() const;
+ virtual void stopParsing();
#ifdef KHTML_XSLT
void setTransformSource(DocumentImpl* doc);
@@ -104,7 +119,6 @@
int lineNumber() const;
int columnNumber() const;
- void stopParsing();
void insertErrorMessageBlock();
@@ -123,7 +137,6 @@
DOM::NodeImpl *m_currentNode;
bool m_sawError;
- bool m_parserStopped;
bool m_sawXSLTransform;
int m_errorCount;
@@ -196,26 +209,22 @@
XMLTokenizer::XMLTokenizer(DocumentPtr *_doc, KHTMLView *_view)
: m_doc(_doc), m_view(_view),
m_context(NULL), m_currentNode(m_doc->document()),
- m_sawError(false), m_parserStopped(false), m_errorCount(0),
+ m_sawError(false), m_errorCount(0),
m_lastErrorLine(0), m_scriptsIt(0), m_cachedScript(0), m_parsingFragment(false)
{
if (m_doc)
m_doc->ref();
-
- //FIXME: XMLTokenizer should use this in a fashion similiar to how
- //HTMLTokenizer uses loadStopped, in the future.
- loadStopped = false;
}
XMLTokenizer::XMLTokenizer(DocumentFragmentImpl *fragment, ElementImpl *parentElement)
: m_doc(fragment->docPtr()), m_view(0),
m_context(0), m_currentNode(fragment),
- m_sawError(false), m_parserStopped(false), m_errorCount(0),
+ m_sawError(false), m_errorCount(0),
m_lastErrorLine(0), m_scriptsIt(0), m_cachedScript(0), m_parsingFragment(true)
{
if (m_doc)
m_doc->ref();
-
+
// Add namespaces based on the parent node
QPtrStack<ElementImpl> elemStack;
while (parentElement) {
@@ -237,10 +246,6 @@
}
}
}
-
- //FIXME: XMLTokenizer should use this in a fashion similiar to how
- //HTMLTokenizer uses loadStopped, in the future.
- loadStopped = false;
}
XMLTokenizer::~XMLTokenizer()
@@ -380,7 +385,8 @@
void XMLTokenizer::endElementNs()
{
- if (m_parserStopped) return;
+ if (m_parserStopped)
+ return;
if (m_currentNode->nodeType() == Node::TEXT_NODE)
exitText();
@@ -394,7 +400,8 @@
void XMLTokenizer::characters(const xmlChar *s, int len)
{
- if (m_parserStopped) return;
+ if (m_parserStopped)
+ return;
if (m_currentNode->nodeType() == Node::TEXT_NODE ||
m_currentNode->nodeType() == Node::CDATA_SECTION_NODE ||
@@ -430,9 +437,8 @@
void XMLTokenizer::error(ErrorType type, const char *message, va_list args)
{
- if (m_parserStopped) {
+ if (m_parserStopped)
return;
- }
if (type == fatal || (m_errorCount < maxErrors && m_lastErrorLine != lineNumber() && m_lastErrorColumn != columnNumber())) {
@@ -479,9 +485,8 @@
void XMLTokenizer::processingInstruction(const xmlChar *target, const xmlChar *data)
{
- if (m_parserStopped) {
+ if (m_parserStopped)
return;
- }
if (m_currentNode->nodeType() == Node::TEXT_NODE)
exitText();
@@ -507,9 +512,8 @@
void XMLTokenizer::cdataBlock(const xmlChar *s, int len)
{
- if (m_parserStopped) {
+ if (m_parserStopped)
return;
- }
if (m_currentNode->nodeType() == Node::TEXT_NODE)
exitText();
@@ -534,7 +538,8 @@
void XMLTokenizer::comment(const xmlChar *s)
{
- if (m_parserStopped) return;
+ if (m_parserStopped)
+ return;
if (m_currentNode->nodeType() == Node::TEXT_NODE)
exitText();
@@ -816,8 +821,8 @@
void XMLTokenizer::stopParsing()
{
+ Tokenizer::stopParsing();
xmlStopParser(m_context);
- m_parserStopped = true;
}
bool parseXMLDocumentFragment(const DOMString &string, DocumentFragmentImpl *fragment, ElementImpl *parent)
1.19 +9 -10 WebCore/khtml/xml/xml_tokenizer.h
Index: xml_tokenizer.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/xml_tokenizer.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- xml_tokenizer.h 19 Aug 2005 16:27:01 -0000 1.18
+++ xml_tokenizer.h 22 Oct 2005 01:41:36 -0000 1.19
@@ -51,6 +51,7 @@
Q_OBJECT
public:
+ Tokenizer();
// script output must be prepended, while new data
// received during executing a script must be appended, hence the
// extra bool to be able to distinguish between both cases. document.write()
@@ -59,26 +60,24 @@
virtual void finish() = 0;
virtual void setOnHold(bool onHold) = 0;
virtual bool isWaitingForScripts() const = 0;
- void stopParsing() { loadStopped = true; }
-
- virtual void stopped() {};
+ virtual void stopParsing() { m_parserStopped = true; }
virtual bool processingData() const { return false; }
- // The tokenizer has buffers which mean parsing can continue even after
- // loading is supposed to be stopped. If the loading process has stopped,
- // so should we.
- bool loadStopped;
+protected:
+ // The tokenizer has buffers, so parsing may continue even after
+ // it stops receiving data. We use m_parserStopped to stop the tokenizer
+ // even when it has buffered data.
+ bool m_parserStopped;
#ifdef KHTML_XSLT
+public:
virtual void setTransformSource(DOM::DocumentImpl* doc) {};
#endif
-
+
signals:
void finishedParsing();
#if APPLE_CHANGES
-public:
- Tokenizer();
private:
KWQSignal m_finishedParsing;
#endif
1.16 +1 -11 WebCore/kwq/KWQSignalStubs.mm
Index: KWQSignalStubs.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQSignalStubs.mm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- KWQSignalStubs.mm 3 Oct 2005 21:13:09 -0000 1.15
+++ KWQSignalStubs.mm 22 Oct 2005 01:41:36 -0000 1.16
@@ -52,14 +52,4 @@
void Loader::requestStarted(DocLoader *l, CachedObject *o)
{
kwq->_requestStarted.call(l, o);
-}
-
-Tokenizer::Tokenizer()
- : m_finishedParsing(this, SIGNAL(finishedParsing()))
-{
-}
-
-void Tokenizer::finishedParsing()
-{
- m_finishedParsing.call();
-}
+}
\ No newline at end of file
More information about the webkit-changes
mailing list