[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
hyatt at apple.com
hyatt at apple.com
Thu Oct 29 20:40:34 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit f052b826a28f04d43218578f205e9b3afdd8f544
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 6 22:26:08 2009 +0000
WebCore: https://bugs.webkit.org/show_bug.cgi?id=30132, make beforeload work with <link> elements and
XML processing instructions.
Reviewed by Adam Roben.
Fix up ProcessingInstruction's setData call so that it actually updates a stylesheet when the
data gets changed.
Move dispatchBeforeLoadedEvent to ContainerNode so all Elements (and ProcessingInstruction) can
access it.
Added fast/dom/beforeload/link-before-load.html
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::dispatchBeforeLoadEvent):
* dom/ContainerNode.h:
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::checkStyleSheet):
(WebCore::ProcessingInstruction::setData):
* dom/ScriptElement.cpp:
(WebCore::ScriptElementData::requestScript):
* dom/ScriptElement.h:
* dom/XMLTokenizerLibxml2.cpp:
(WebCore::XMLTokenizer::endElementNs):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::parseMappedAttribute):
(WebCore::HTMLLinkElement::process):
* html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::forAttributeValue):
* html/HTMLScriptElement.h:
* svg/SVGScriptElement.cpp:
* svg/SVGScriptElement.h:
LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=30132, make beforeload work with CSS stylesheets loaded from
<link> elements and XML processing instructions.
Reviewed by Adam Roben.
* fast/dom/beforeload/link-before-load-expected.txt: Added.
* fast/dom/beforeload/link-before-load.html: Added.
* fast/dom/beforeload/pi-before-load-expected.txt: Added.
* fast/dom/beforeload/pi-before-load.xhtml: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8dce8a1..4404466 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2009-10-06 Dave Hyatt <hyatt at apple.com>
+
+ Reviewed by Adam Roben.
+
+ https://bugs.webkit.org/show_bug.cgi?id=30132, make beforeload work with CSS stylesheets loaded from
+ <link> elements and XML processing instructions.
+
+ * fast/dom/beforeload/link-before-load-expected.txt: Added.
+ * fast/dom/beforeload/link-before-load.html: Added.
+ * fast/dom/beforeload/pi-before-load-expected.txt: Added.
+ * fast/dom/beforeload/pi-before-load.xhtml: Added.
+
2009-10-06 Simon Fraser <simon.fraser at apple.com>
Reviewed by Mark Rowe.
diff --git a/LayoutTests/fast/dom/beforeload/link-before-load-expected.txt b/LayoutTests/fast/dom/beforeload/link-before-load-expected.txt
new file mode 100644
index 0000000..d9bd273
--- /dev/null
+++ b/LayoutTests/fast/dom/beforeload/link-before-load-expected.txt
@@ -0,0 +1,3 @@
+This page tests the beforeload event on link elements. You should see the word PASS below underneath a green square.
+
+PASS
diff --git a/LayoutTests/fast/dom/beforeload/link-before-load.html b/LayoutTests/fast/dom/beforeload/link-before-load.html
new file mode 100644
index 0000000..d652a5a
--- /dev/null
+++ b/LayoutTests/fast/dom/beforeload/link-before-load.html
@@ -0,0 +1,39 @@
+<html>
+<head>
+<style>
+.block {
+ width: 100px;
+ height: 100px;
+ background-color: green;
+}
+</style>
+<link onbeforeload="return false" rel="stylesheet" href="resources/fail.css">
+<script>
+function print(message, color)
+{
+ var paragraph = document.createElement("div");
+ paragraph.appendChild(document.createTextNode(message));
+ paragraph.style.fontFamily = "monospace";
+ if (color)
+ paragraph.style.color = color;
+ document.getElementById("console").appendChild(paragraph);
+}
+
+function test()
+{
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ if (document.getElementById('block').offsetWidth == 100)
+ print("PASS", "green");
+ else
+ print("FAIL", "red");
+}
+</script>
+</head>
+<body onload="test()">
+<p>This page tests the beforeload event on link elements. You should see the word PASS below underneath a green square.</p>
+<hr>
+<div id="block" class="block"></div>
+<hr>
+<div id="console"></div>
diff --git a/LayoutTests/editing/selection/doubleclick-whitespace-img-crash-expected.txt b/LayoutTests/fast/dom/beforeload/pi-before-load-expected.txt
similarity index 100%
copy from LayoutTests/editing/selection/doubleclick-whitespace-img-crash-expected.txt
copy to LayoutTests/fast/dom/beforeload/pi-before-load-expected.txt
diff --git a/LayoutTests/fast/dom/beforeload/pi-before-load.xhtml b/LayoutTests/fast/dom/beforeload/pi-before-load.xhtml
new file mode 100644
index 0000000..fa8edf8
--- /dev/null
+++ b/LayoutTests/fast/dom/beforeload/pi-before-load.xhtml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<style>
+.block {
+ width: 100px;
+ height: 100px;
+ background-color: green;
+}
+</style>
+<script>
+function print(message, color)
+{
+ var paragraph = document.createElement("div");
+ paragraph.appendChild(document.createTextNode(message));
+ paragraph.style.fontFamily = "monospace";
+ if (color)
+ paragraph.style.color = color;
+ document.getElementById("console").appendChild(paragraph);
+}
+
+function test()
+{
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ if (document.getElementById('block').offsetWidth == 100)
+ print("PASS", "green");
+ else
+ print("FAIL", "red");
+}
+</script>
+</head>
+<body onload="test()">
+<div id="block" class="block"></div>
+<script>
+function beforeLoadFunc()
+{
+ event.preventDefault();
+}
+
+document.addEventListener("beforeload", beforeLoadFunc, true);
+
+var pi = document.createProcessingInstruction("xml-stylesheet", "type=\"text/css\" href=\"resources/fail.css\"");
+document.insertBefore(pi, document.documentElement);
+</script>
+<hr/>
+<div id="console"></div>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/beforeload/resources/fail.css b/LayoutTests/fast/dom/beforeload/resources/fail.css
new file mode 100644
index 0000000..1a5960a
--- /dev/null
+++ b/LayoutTests/fast/dom/beforeload/resources/fail.css
@@ -0,0 +1,5 @@
+.block {
+ background-color:red !important;
+ width: 200px !important;
+ height:200px !important;
+}
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 46841c5..ae3d2fa 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,38 @@
+2009-10-06 Dave Hyatt <hyatt at apple.com>
+
+ Reviewed by Adam Roben.
+
+ https://bugs.webkit.org/show_bug.cgi?id=30132, make beforeload work with <link> elements and
+ XML processing instructions.
+
+ Fix up ProcessingInstruction's setData call so that it actually updates a stylesheet when the
+ data gets changed.
+
+ Move dispatchBeforeLoadedEvent to ContainerNode so all Elements (and ProcessingInstruction) can
+ access it.
+
+ Added fast/dom/beforeload/link-before-load.html
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::dispatchBeforeLoadEvent):
+ * dom/ContainerNode.h:
+ * dom/ProcessingInstruction.cpp:
+ (WebCore::ProcessingInstruction::checkStyleSheet):
+ (WebCore::ProcessingInstruction::setData):
+ * dom/ScriptElement.cpp:
+ (WebCore::ScriptElementData::requestScript):
+ * dom/ScriptElement.h:
+ * dom/XMLTokenizerLibxml2.cpp:
+ (WebCore::XMLTokenizer::endElementNs):
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::parseMappedAttribute):
+ (WebCore::HTMLLinkElement::process):
+ * html/HTMLScriptElement.cpp:
+ (WebCore::HTMLScriptElement::forAttributeValue):
+ * html/HTMLScriptElement.h:
+ * svg/SVGScriptElement.cpp:
+ * svg/SVGScriptElement.h:
+
2009-10-06 Simon Fraser <simon.fraser at apple.com>
Reviewed by Mark Rowe.
diff --git a/WebCore/dom/ContainerNode.cpp b/WebCore/dom/ContainerNode.cpp
index 7274b5d..99b2c4f 100644
--- a/WebCore/dom/ContainerNode.cpp
+++ b/WebCore/dom/ContainerNode.cpp
@@ -23,6 +23,7 @@
#include "config.h"
#include "ContainerNode.h"
+#include "BeforeLoadEvent.h"
#include "Cache.h"
#include "ContainerNodeAlgorithms.h"
#include "DeleteButtonController.h"
@@ -909,4 +910,12 @@ static void dispatchChildRemovalEvents(Node* child)
}
}
+bool ContainerNode::dispatchBeforeLoadEvent(const String& sourceURL)
+{
+ RefPtr<ContainerNode> protector(this);
+ RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL);
+ dispatchEvent(beforeLoadEvent.get());
+ return inDocument() && !beforeLoadEvent->defaultPrevented();
+}
+
} // namespace WebCore
diff --git a/WebCore/dom/ContainerNode.h b/WebCore/dom/ContainerNode.h
index aa480a7..9789f1f 100644
--- a/WebCore/dom/ContainerNode.h
+++ b/WebCore/dom/ContainerNode.h
@@ -71,6 +71,8 @@ public:
void removeAllChildren();
void cloneChildNodes(ContainerNode* clone);
+
+ bool dispatchBeforeLoadEvent(const String& sourceURL);
protected:
ContainerNode(Document*, ConstructionType = CreateContainer);
diff --git a/WebCore/dom/ProcessingInstruction.cpp b/WebCore/dom/ProcessingInstruction.cpp
index 8404481..72993dd 100644
--- a/WebCore/dom/ProcessingInstruction.cpp
+++ b/WebCore/dom/ProcessingInstruction.cpp
@@ -64,6 +64,7 @@ void ProcessingInstruction::setData(const String& data, ExceptionCode&)
int oldLength = m_data.length();
m_data = data;
document()->textRemoved(this, 0, oldLength);
+ checkStyleSheet();
}
String ProcessingInstruction::nodeName() const
@@ -142,13 +143,21 @@ void ProcessingInstruction::checkStyleSheet()
}
#endif
} else {
+ if (m_cachedSheet) {
+ m_cachedSheet->removeClient(this);
+ m_cachedSheet = 0;
+ }
+
+ String url = document()->completeURL(href).string();
+ if (!dispatchBeforeLoadEvent(url))
+ return;
+
m_loading = true;
document()->addPendingSheet();
- if (m_cachedSheet)
- m_cachedSheet->removeClient(this);
+
#if ENABLE(XSLT)
if (m_isXSL)
- m_cachedSheet = document()->docLoader()->requestXSLStyleSheet(document()->completeURL(href).string());
+ m_cachedSheet = document()->docLoader()->requestXSLStyleSheet(url);
else
#endif
{
@@ -156,10 +165,15 @@ void ProcessingInstruction::checkStyleSheet()
if (charset.isEmpty())
charset = document()->frame()->loader()->encoding();
- m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(document()->completeURL(href).string(), charset);
+ m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(url, charset);
}
if (m_cachedSheet)
m_cachedSheet->addClient(this);
+ else {
+ // The request may have been denied if (for example) the stylesheet is local and the document is remote.
+ m_loading = false;
+ document()->removePendingSheet();
+ }
}
}
}
diff --git a/WebCore/dom/ScriptElement.cpp b/WebCore/dom/ScriptElement.cpp
index a6db8ba..827aff3 100644
--- a/WebCore/dom/ScriptElement.cpp
+++ b/WebCore/dom/ScriptElement.cpp
@@ -151,7 +151,7 @@ void ScriptElementData::requestScript(const String& sourceUrl)
if (!document->frame())
return;
- if (!m_scriptElement->dispatchBeforeLoadEvent(sourceUrl))
+ if (!m_element->dispatchBeforeLoadEvent(sourceUrl))
return;
ASSERT(!m_cachedScript);
diff --git a/WebCore/dom/ScriptElement.h b/WebCore/dom/ScriptElement.h
index 09b0aae..0aed5e8 100644
--- a/WebCore/dom/ScriptElement.h
+++ b/WebCore/dom/ScriptElement.h
@@ -44,7 +44,6 @@ public:
virtual String languageAttributeValue() const = 0;
virtual String forAttributeValue() const = 0;
- virtual bool dispatchBeforeLoadEvent(const String& sourceURL) = 0;
virtual void dispatchLoadEvent() = 0;
virtual void dispatchErrorEvent() = 0;
diff --git a/WebCore/dom/XMLTokenizerLibxml2.cpp b/WebCore/dom/XMLTokenizerLibxml2.cpp
index ebee074..e4a98d5 100644
--- a/WebCore/dom/XMLTokenizerLibxml2.cpp
+++ b/WebCore/dom/XMLTokenizerLibxml2.cpp
@@ -851,7 +851,7 @@ void XMLTokenizer::endElementNs()
if (!scriptHref.isEmpty()) {
// we have a src attribute
String scriptCharset = scriptElement->scriptCharset();
- if (scriptElement->dispatchBeforeLoadEvent(scriptHref) &&
+ if (element->dispatchBeforeLoadEvent(scriptHref) &&
(m_pendingScript = m_doc->docLoader()->requestScript(scriptHref, scriptCharset))) {
m_scriptElement = element;
m_pendingScript->addClient(this);
diff --git a/WebCore/html/HTMLLinkElement.cpp b/WebCore/html/HTMLLinkElement.cpp
index 47b620e..6b74221 100644
--- a/WebCore/html/HTMLLinkElement.cpp
+++ b/WebCore/html/HTMLLinkElement.cpp
@@ -38,6 +38,7 @@
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "Page.h"
+#include "ScriptEventListener.h"
#include "Settings.h"
namespace WebCore {
@@ -126,7 +127,9 @@ void HTMLLinkElement::parseMappedAttribute(MappedAttribute *attr)
process();
} else if (attr->name() == disabledAttr) {
setDisabledState(!attr->isNull());
- } else {
+ } else if (attr->name() == onbeforeloadAttr)
+ setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
+ else {
if (attr->name() == titleAttr && m_sheet)
m_sheet->setTitle(attr->value());
HTMLElement::parseMappedAttribute(attr);
@@ -187,11 +190,7 @@ void HTMLLinkElement::process()
// This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh
if (m_disabledState != 2 && (m_isStyleSheet || acceptIfTypeContainsTextCSS && type.contains("text/css")) && document()->frame() && m_url.isValid()) {
// also, don't load style sheets for standalone documents
- // Add ourselves as a pending sheet, but only if we aren't an alternate
- // stylesheet. Alternate stylesheets don't hold up render tree construction.
- if (!isAlternate())
- document()->addPendingSheet();
-
+
String charset = getAttribute(charsetAttr);
if (charset.isEmpty() && document()->frame())
charset = document()->frame()->loader()->encoding();
@@ -200,14 +199,28 @@ void HTMLLinkElement::process()
if (m_loading)
document()->removePendingSheet();
m_cachedSheet->removeClient(this);
+ m_cachedSheet = 0;
}
+
+ if (!dispatchBeforeLoadEvent(m_url))
+ return;
+
m_loading = true;
+
+ // Add ourselves as a pending sheet, but only if we aren't an alternate
+ // stylesheet. Alternate stylesheets don't hold up render tree construction.
+ if (!isAlternate())
+ document()->addPendingSheet();
+
m_cachedSheet = document()->docLoader()->requestCSSStyleSheet(m_url, charset);
+
if (m_cachedSheet)
m_cachedSheet->addClient(this);
- else if (!isAlternate()) { // The request may have been denied if stylesheet is local and document is remote.
+ else {
+ // The request may have been denied if (for example) the stylesheet is local and the document is remote.
m_loading = false;
- document()->removePendingSheet();
+ if (!isAlternate())
+ document()->removePendingSheet();
}
} else if (m_sheet) {
// we no longer contain a stylesheet, e.g. perhaps rel or type was changed
diff --git a/WebCore/html/HTMLScriptElement.cpp b/WebCore/html/HTMLScriptElement.cpp
index 5321d56..636c579 100644
--- a/WebCore/html/HTMLScriptElement.cpp
+++ b/WebCore/html/HTMLScriptElement.cpp
@@ -23,7 +23,6 @@
#include "config.h"
#include "HTMLScriptElement.h"
-#include "BeforeLoadEvent.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
@@ -220,14 +219,6 @@ String HTMLScriptElement::forAttributeValue() const
{
return getAttribute(forAttr).string();
}
-
-bool HTMLScriptElement::dispatchBeforeLoadEvent(const String& sourceURL)
-{
- RefPtr<HTMLScriptElement> protector(this);
- RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL);
- dispatchEvent(beforeLoadEvent.get());
- return inDocument() && !beforeLoadEvent->defaultPrevented();
-}
void HTMLScriptElement::dispatchLoadEvent()
{
diff --git a/WebCore/html/HTMLScriptElement.h b/WebCore/html/HTMLScriptElement.h
index 1846a89..4d18beb 100644
--- a/WebCore/html/HTMLScriptElement.h
+++ b/WebCore/html/HTMLScriptElement.h
@@ -77,8 +77,6 @@ public:
bool haveFiredLoadEvent() const { return m_data.haveFiredLoadEvent(); }
- virtual bool dispatchBeforeLoadEvent(const String& sourceURL);
-
protected:
virtual String sourceAttributeValue() const;
virtual String charsetAttributeValue() const;
diff --git a/WebCore/svg/SVGScriptElement.cpp b/WebCore/svg/SVGScriptElement.cpp
index f4a5e3d..587542c 100644
--- a/WebCore/svg/SVGScriptElement.cpp
+++ b/WebCore/svg/SVGScriptElement.cpp
@@ -25,7 +25,6 @@
#if ENABLE(SVG)
#include "SVGScriptElement.h"
-#include "BeforeLoadEvent.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
@@ -181,14 +180,6 @@ String SVGScriptElement::forAttributeValue() const
return String();
}
-bool SVGScriptElement::dispatchBeforeLoadEvent(const String& sourceURL)
-{
- RefPtr<SVGScriptElement> protector(this);
- RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL);
- dispatchEvent(beforeLoadEvent.get());
- return inDocument() && !beforeLoadEvent->defaultPrevented();
-}
-
void SVGScriptElement::dispatchLoadEvent()
{
bool externalResourcesRequired = externalResourcesRequiredBaseValue();
diff --git a/WebCore/svg/SVGScriptElement.h b/WebCore/svg/SVGScriptElement.h
index fa51825..f2efc8e 100644
--- a/WebCore/svg/SVGScriptElement.h
+++ b/WebCore/svg/SVGScriptElement.h
@@ -69,7 +69,6 @@ namespace WebCore {
virtual String languageAttributeValue() const;
virtual String forAttributeValue() const;
- virtual bool dispatchBeforeLoadEvent(const String& sourceURL);
virtual void dispatchLoadEvent();
virtual void dispatchErrorEvent();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list