mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 552938 - Implement the SVG load event in text/html, make the SVG load event in XML async and only supported on <svg>. (Also disable/tweak 2 broken tests) r=dholbert, sr=roc
This commit is contained in:
parent
afe13ab23c
commit
5bf17b6fc0
@ -25,6 +25,7 @@ SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function main() {
|
||||
var svg = document.getElementById("svg");
|
||||
svg.setCurrentTime(0);
|
||||
ok(svg.animationsPaused(), "should be paused by <svg> load handler");
|
||||
is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
|
||||
|
||||
|
@ -52,8 +52,6 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMCDATASection.h"
|
||||
#include "nsDOMDocumentType.h"
|
||||
@ -96,12 +94,11 @@
|
||||
#include "nsNodeUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsHtml5SVGLoadDispatcher.h"
|
||||
#endif
|
||||
|
||||
// XXX Open Issues:
|
||||
@ -1157,29 +1154,13 @@ nsXMLContentSink::HandleEndElement(const PRUnichar *aName,
|
||||
DidAddContent();
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
if (mDocument &&
|
||||
content->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
(
|
||||
#ifdef MOZ_SMIL
|
||||
content->Tag() == nsGkAtoms::svg ||
|
||||
#endif
|
||||
content->HasAttr(kNameSpaceID_None, nsGkAtoms::onload))) {
|
||||
if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
content->Tag() == nsGkAtoms::svg) {
|
||||
FlushTags();
|
||||
|
||||
nsEvent event(PR_TRUE, NS_SVG_LOAD);
|
||||
event.eventStructType = NS_SVG_EVENT;
|
||||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
|
||||
// Do we care about forcing presshell creation if it hasn't happened yet?
|
||||
// That is, should this code flush or something? Does it really matter?
|
||||
// For that matter, do we really want to try getting the prescontext? Does
|
||||
// this event ever want one?
|
||||
nsRefPtr<nsPresContext> ctx;
|
||||
nsCOMPtr<nsIPresShell> shell = mDocument->GetShell();
|
||||
if (shell) {
|
||||
ctx = shell->GetPresContext();
|
||||
nsCOMPtr<nsIRunnable> event = new nsHtml5SVGLoadDispatcher(content);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(event))) {
|
||||
NS_WARNING("failed to dispatch svg load dispatcher");
|
||||
}
|
||||
nsEventDispatcher::Dispatch(content, ctx, &event);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -65,7 +65,7 @@ include svg-integration/reftest.list
|
||||
== dynamic-textPath-01.svg dynamic-textPath-01-ref.svg
|
||||
== dynamic-use-01.svg pass.svg
|
||||
== dynamic-use-02.svg pass.svg
|
||||
== dynamic-use-nested-01.svg dynamic-use-nested-01-ref.svg
|
||||
random == dynamic-use-nested-01.svg dynamic-use-nested-01-ref.svg # bug 467498
|
||||
== dynamic-use-remove-width.svg dynamic-use-remove-width-ref.svg
|
||||
== linked-pattern-01.svg pass.svg
|
||||
== use-01-extref.svg pass.svg
|
||||
|
@ -49,7 +49,7 @@ load 384637-1.svg
|
||||
load 384728-1.svg
|
||||
load 385246-1.svg
|
||||
load 385246-2.svg
|
||||
asserts(1) load 385840-1.svg # bug 385845
|
||||
load 385840-1.svg
|
||||
load 385852-1.svg
|
||||
load 386475-1.xhtml
|
||||
load 386566-1.svg
|
||||
|
@ -50,6 +50,12 @@ EXPORTS = \
|
||||
nsHtml5Module.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_SVG
|
||||
EXPORTS += \
|
||||
nsHtml5SVGLoadDispatcher.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
nsHtml5Atoms.cpp \
|
||||
nsHtml5Atom.cpp \
|
||||
@ -77,6 +83,12 @@ CPPSRCS = \
|
||||
nsHtml5SpeculativeLoad.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_SVG
|
||||
CPPSRCS += \
|
||||
nsHtml5SVGLoadDispatcher.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
72
parser/html/nsHtml5SVGLoadDispatcher.cpp
Normal file
72
parser/html/nsHtml5SVGLoadDispatcher.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Henri Sivonen <hsivonen@iki.fi>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsHtml5SVGLoadDispatcher.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsGUIEvent.h"
|
||||
|
||||
nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
|
||||
: mElement(aElement)
|
||||
, mDocument(mElement->GetOwnerDoc())
|
||||
{
|
||||
mDocument->BlockOnload();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHtml5SVGLoadDispatcher::Run()
|
||||
{
|
||||
nsEvent event(PR_TRUE, NS_SVG_LOAD);
|
||||
event.eventStructType = NS_SVG_EVENT;
|
||||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
// Do we care about forcing presshell creation if it hasn't happened yet?
|
||||
// That is, should this code flush or something? Does it really matter?
|
||||
// For that matter, do we really want to try getting the prescontext?
|
||||
// Does this event ever want one?
|
||||
nsRefPtr<nsPresContext> ctx;
|
||||
nsCOMPtr<nsIPresShell> shell = mElement->GetOwnerDoc()->GetShell();
|
||||
if (shell) {
|
||||
ctx = shell->GetPresContext();
|
||||
}
|
||||
nsEventDispatcher::Dispatch(mElement, ctx, &event);
|
||||
// Unblocking onload on the same document that it was blocked even if
|
||||
// the element has moved between docs since blocking.
|
||||
mDocument->UnblockOnload(PR_FALSE);
|
||||
return NS_OK;
|
||||
}
|
54
parser/html/nsHtml5SVGLoadDispatcher.h
Normal file
54
parser/html/nsHtml5SVGLoadDispatcher.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Asynchronous SVG load event dispatching code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Henri Sivonen <hsivonen@iki.fi>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsHtml5SVGLoadDispatcher_h_
|
||||
#define nsHtml5SVGLoadDispatcher_h_
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsHtml5SVGLoadDispatcher : public nsRunnable
|
||||
{
|
||||
private:
|
||||
nsCOMPtr<nsIContent> mElement;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
public:
|
||||
nsHtml5SVGLoadDispatcher(nsIContent* aElement);
|
||||
NS_IMETHOD Run();
|
||||
};
|
||||
|
||||
#endif // nsHtml5SVGLoadDispatcher_h_
|
@ -494,24 +494,13 @@ nsHtml5TreeBuilder::elementPopped(PRInt32 aNamespace, nsIAtom* aName, nsIContent
|
||||
return;
|
||||
}
|
||||
if (aNamespace == kNameSpaceID_SVG) {
|
||||
#if 0
|
||||
if (aElement->HasAttr(kNameSpaceID_None, nsHtml5Atoms::onload)) {
|
||||
nsEvent event(PR_TRUE, NS_SVG_LOAD);
|
||||
event.eventStructType = NS_SVG_EVENT;
|
||||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
||||
// Do we care about forcing presshell creation if it hasn't happened yet?
|
||||
// That is, should this code flush or something? Does it really matter?
|
||||
// For that matter, do we really want to try getting the prescontext? Does
|
||||
// this event ever want one?
|
||||
nsRefPtr<nsPresContext> ctx;
|
||||
nsCOMPtr<nsIPresShell> shell = parser->GetDocument()->GetShell();
|
||||
if (shell) {
|
||||
ctx = shell->GetPresContext();
|
||||
}
|
||||
nsEventDispatcher::Dispatch(aElement, ctx, &event);
|
||||
#ifdef MOZ_SVG
|
||||
if (aName == nsHtml5Atoms::svg) {
|
||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||
treeOp->Init(eTreeOpSvgLoad, aElement);
|
||||
}
|
||||
#endif
|
||||
// TODO soft flush the op queue every now and then
|
||||
return;
|
||||
}
|
||||
// we now have only HTML
|
||||
|
@ -61,6 +61,10 @@
|
||||
#include "nsIFormProcessor.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsHtml5SVGLoadDispatcher.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
|
||||
|
||||
/**
|
||||
@ -676,6 +680,16 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
sele->FreezeUriAsyncDefer();
|
||||
return rv;
|
||||
}
|
||||
#ifdef MOZ_SVG
|
||||
case eTreeOpSvgLoad: {
|
||||
nsIContent* node = *(mOne.node);
|
||||
nsCOMPtr<nsIRunnable> event = new nsHtml5SVGLoadDispatcher(node);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(event))) {
|
||||
NS_WARNING("failed to dispatch svg load dispatcher");
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
default: {
|
||||
NS_NOTREACHED("Bogus tree op");
|
||||
}
|
||||
|
@ -82,6 +82,9 @@ enum eHtml5TreeOperation {
|
||||
eTreeOpStreamEnded,
|
||||
eTreeOpSetStyleLineNumber,
|
||||
eTreeOpSetScriptLineNumberAndFreeze,
|
||||
#ifdef MOZ_SVG
|
||||
eTreeOpSvgLoad,
|
||||
#endif
|
||||
eTreeOpStartLayout
|
||||
};
|
||||
|
||||
|
@ -59,6 +59,8 @@ _TEST_FILES = parser_datreader.js \
|
||||
test_bug460437.xhtml \
|
||||
test_bug502091.html \
|
||||
bug_502091_iframe.html \
|
||||
test_bug552938.html \
|
||||
test_bug552938-2.html \
|
||||
test_bug566879.html \
|
||||
test_compatmode.html \
|
||||
invalidchar.xml \
|
||||
|
38
parser/htmlparser/tests/mochitest/test_bug552938-2.html
Normal file
38
parser/htmlparser/tests/mochitest/test_bug552938-2.html
Normal file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=552938
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 552938</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload='runTest();'>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=552938">Mozilla Bug 552938</a>
|
||||
<script>
|
||||
var svgLoadFired = false;
|
||||
</script>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<svg>
|
||||
<script>
|
||||
document.getElementsByTagName("svg")[0].addEventListener("SVGLoad",
|
||||
function() { svgLoadFired = true; }, false);
|
||||
</script>
|
||||
</svg>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 552938 **/
|
||||
function runTest() {
|
||||
ok(svgLoadFired, "The SVG load event should have fired.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
33
parser/htmlparser/tests/mochitest/test_bug552938.html
Normal file
33
parser/htmlparser/tests/mochitest/test_bug552938.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=552938
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 552938</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload='runTest();'>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=552938">Mozilla Bug 552938</a>
|
||||
<script>
|
||||
var svgLoadFired = false;
|
||||
</script>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<svg onload="svgLoadFired = true;"></svg>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 552938 **/
|
||||
function runTest() {
|
||||
ok(svgLoadFired, "The SVG load event should have fired.");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user