[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
ap at apple.com
ap at apple.com
Tue Jan 5 23:49:26 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 0558fdad7b45fa64286888a108e46c1110cd8b67
Author: ap at apple.com <ap at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Dec 14 21:47:04 2009 +0000
Reviewed by Dave Hyatt.
https://bugs.webkit.org/show_bug.cgi?id=31660
REGRESSION (r49394): Image load event fires before the document fragment is attached.
Test: fast/images/image-load-event-in-fragment.html
We cannot fire load events immediately after parsing a fragment - an element inserted via
innerHTML or equivalent should be reachable via getElementById() by the time its load event
fires.
* dom/Document.cpp: (WebCore::Document::implicitClose): Call dispatchPendingBeforeLoadEvents()
and dispatchPendingLoadEvents() individually. I'm not sure why these calls are here, just
preserving existing behavior.
* dom/XMLTokenizer.cpp: (WebCore::XMLTokenizer::write):
* html/HTMLTokenizer.cpp: (WebCore::HTMLTokenizer::write):
Load events for elements that have just been parsed cannot be dispatched yet, we should give
the elements a chance to be inserted into a document first. There is no compatibility baggage
for beforeload, so it seems OK to dispatch it right away.
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::dispatchPendingBeforeLoadEvents):
(WebCore::ImageLoader::dispatchPendingLoadEvents):
* loader/ImageLoader.h:
Separated dispatchPendingEvents() into individual functions for each event kind.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52116 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f0c6111..33d14a6 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-14 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ https://bugs.webkit.org/show_bug.cgi?id=31660
+ REGRESSION (r49394): Image load event fires before the document fragment is attached.
+
+ * fast/images/image-load-event-in-fragment-expected.txt: Added.
+ * fast/images/image-load-event-in-fragment.html: Added.
+
2009-12-14 Brian Weinstein <bweinstein at apple.com>
Rubber-stamped by Adam Roben.
diff --git a/LayoutTests/fast/images/image-load-event-in-fragment-expected.txt b/LayoutTests/fast/images/image-load-event-in-fragment-expected.txt
new file mode 100644
index 0000000..8c57ab8
--- /dev/null
+++ b/LayoutTests/fast/images/image-load-event-in-fragment-expected.txt
@@ -0,0 +1,4 @@
+Test for bug 31660: Image load event fires before the document fragment is attached.
+
+PASS
+
diff --git a/LayoutTests/fast/images/image-load-event-in-fragment.html b/LayoutTests/fast/images/image-load-event-in-fragment.html
new file mode 100644
index 0000000..20b8551
--- /dev/null
+++ b/LayoutTests/fast/images/image-load-event-in-fragment.html
@@ -0,0 +1,32 @@
+<body onload="test()">
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=31660">bug 31660</a>:
+Image load event fires before the document fragment is attached.</p>
+<div id=result>FAIL - script did not run</div>
+<div id=target></div>
+<!-- Preload an image, possibly making second load synchronous -->
+<img src="resources/boston.gif" style="visibility:hidden">
+<script>
+if (window.layoutTestController) {
+ layoutTestController.waitUntilDone();
+ layoutTestController.dumpAsText();
+}
+function test()
+{
+ // Parsing a fragment immediately triggers image load. This is true in WebKit and Firefox even
+ // if a fragment created with Range.createContextualFragment() does not get attached.
+ var r = document.createRange();
+ r.setStartAfter(document.body);
+ r.setEndAfter(document.body);
+ var frag = r.createContextualFragment('<img style="visibility:hidden" src="resources/boston.gif" onload="loaded()" id="new">');
+
+ document.getElementById("target").appendChild(frag);
+}
+function loaded()
+{
+ // There is code on the Web expecting that an image is in the document by the time its load event fires.
+ document.getElementById("result").innerHTML = (document.getElementById("new")) ? "PASS" : "FAIL";
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+</script>
+</body>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index ecfb902..8a67e1b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2009-12-14 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ https://bugs.webkit.org/show_bug.cgi?id=31660
+ REGRESSION (r49394): Image load event fires before the document fragment is attached.
+
+ Test: fast/images/image-load-event-in-fragment.html
+
+ We cannot fire load events immediately after parsing a fragment - an element inserted via
+ innerHTML or equivalent should be reachable via getElementById() by the time its load event
+ fires.
+
+ * dom/Document.cpp: (WebCore::Document::implicitClose): Call dispatchPendingBeforeLoadEvents()
+ and dispatchPendingLoadEvents() individually. I'm not sure why these calls are here, just
+ preserving existing behavior.
+
+ * dom/XMLTokenizer.cpp: (WebCore::XMLTokenizer::write):
+ * html/HTMLTokenizer.cpp: (WebCore::HTMLTokenizer::write):
+ Load events for elements that have just been parsed cannot be dispatched yet, we should give
+ the elements a chance to be inserted into a document first. There is no compatibility baggage
+ for beforeload, so it seems OK to dispatch it right away.
+
+ * loader/ImageLoader.cpp:
+ (WebCore::ImageLoader::dispatchPendingBeforeLoadEvents):
+ (WebCore::ImageLoader::dispatchPendingLoadEvents):
+ * loader/ImageLoader.h:
+ Separated dispatchPendingEvents() into individual functions for each event kind.
+
2009-12-14 Jakob Petsovits <jpetsovits at rim.com>
Reviewed by Simon Fraser.
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index e00f403..2926872 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -1724,7 +1724,8 @@ void Document::implicitClose()
if (f)
f->animation()->resumeAnimations(this);
- ImageLoader::dispatchPendingEvents();
+ ImageLoader::dispatchPendingBeforeLoadEvents();
+ ImageLoader::dispatchPendingLoadEvents();
dispatchWindowLoadEvent();
dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, false), this);
if (m_pendingStateObject)
diff --git a/WebCore/dom/XMLTokenizer.cpp b/WebCore/dom/XMLTokenizer.cpp
index 56f8ff4..1c43322 100644
--- a/WebCore/dom/XMLTokenizer.cpp
+++ b/WebCore/dom/XMLTokenizer.cpp
@@ -134,8 +134,8 @@ void XMLTokenizer::write(const SegmentedString& s, bool /*appendData*/)
doWrite(s.toString());
- // After parsing, go ahead and dispatch image beforeload/load events.
- ImageLoader::dispatchPendingEvents();
+ // After parsing, go ahead and dispatch image beforeload events.
+ ImageLoader::dispatchPendingBeforeLoadEvents();
}
void XMLTokenizer::handleError(ErrorType type, const char* m, int lineNumber, int columnNumber)
diff --git a/WebCore/html/HTMLTokenizer.cpp b/WebCore/html/HTMLTokenizer.cpp
index a4c4a38..dd0eb31 100644
--- a/WebCore/html/HTMLTokenizer.cpp
+++ b/WebCore/html/HTMLTokenizer.cpp
@@ -1808,8 +1808,8 @@ void HTMLTokenizer::write(const SegmentedString& str, bool appendData)
if (m_noMoreData && !m_inWrite && !state.loadingExtScript() && !m_executingScript && !m_timer.isActive())
end(); // this actually causes us to be deleted
- // After parsing, go ahead and dispatch image beforeload/load events.
- ImageLoader::dispatchPendingEvents();
+ // After parsing, go ahead and dispatch image beforeload events.
+ ImageLoader::dispatchPendingBeforeLoadEvents();
}
void HTMLTokenizer::stopParsing()
diff --git a/WebCore/loader/ImageLoader.cpp b/WebCore/loader/ImageLoader.cpp
index e09d574..25b9096 100644
--- a/WebCore/loader/ImageLoader.cpp
+++ b/WebCore/loader/ImageLoader.cpp
@@ -231,9 +231,13 @@ void ImageLoader::dispatchPendingLoadEvent()
dispatchLoadEvent();
}
-void ImageLoader::dispatchPendingEvents()
+void ImageLoader::dispatchPendingBeforeLoadEvents()
{
beforeLoadEventSender().dispatchPendingEvents();
+}
+
+void ImageLoader::dispatchPendingLoadEvents()
+{
loadEventSender().dispatchPendingEvents();
}
diff --git a/WebCore/loader/ImageLoader.h b/WebCore/loader/ImageLoader.h
index 7f42e33..e7463d5 100644
--- a/WebCore/loader/ImageLoader.h
+++ b/WebCore/loader/ImageLoader.h
@@ -56,7 +56,8 @@ public:
bool haveFiredBeforeLoadEvent() const { return m_firedBeforeLoad; }
bool haveFiredLoadEvent() const { return m_firedLoad; }
- static void dispatchPendingEvents();
+ static void dispatchPendingBeforeLoadEvents();
+ static void dispatchPendingLoadEvents();
protected:
virtual void notifyFinished(CachedResource*);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list