зеркало из https://github.com/mozilla/gecko-dev.git
Bug 552938 - Implement the SVG load event in text/html, make the SVG load event in XML async and only supported on <svg>. r=dholbert, sr=roc.
--HG-- extra : rebase_source : 6b4eb0b424b328cbb7853d767c2552ed01abc519
This commit is contained in:
Родитель
38a188aa08
Коммит
a34b2ccbd0
|
@ -52,8 +52,6 @@
|
||||||
#include "nsIDocShell.h"
|
#include "nsIDocShell.h"
|
||||||
#include "nsIDocShellTreeItem.h"
|
#include "nsIDocShellTreeItem.h"
|
||||||
#include "nsIStyleSheetLinkingElement.h"
|
#include "nsIStyleSheetLinkingElement.h"
|
||||||
#include "nsPresContext.h"
|
|
||||||
#include "nsIPresShell.h"
|
|
||||||
#include "nsIDOMComment.h"
|
#include "nsIDOMComment.h"
|
||||||
#include "nsIDOMCDATASection.h"
|
#include "nsIDOMCDATASection.h"
|
||||||
#include "nsDOMDocumentType.h"
|
#include "nsDOMDocumentType.h"
|
||||||
|
@ -96,12 +94,11 @@
|
||||||
#include "nsNodeUtils.h"
|
#include "nsNodeUtils.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsIHTMLDocument.h"
|
#include "nsIHTMLDocument.h"
|
||||||
#include "nsEventDispatcher.h"
|
|
||||||
#include "mozAutoDocUpdate.h"
|
#include "mozAutoDocUpdate.h"
|
||||||
#include "nsMimeTypes.h"
|
#include "nsMimeTypes.h"
|
||||||
|
|
||||||
#ifdef MOZ_SVG
|
#ifdef MOZ_SVG
|
||||||
#include "nsGUIEvent.h"
|
#include "nsHtml5SVGLoadDispatcher.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// XXX Open Issues:
|
// XXX Open Issues:
|
||||||
|
@ -1158,29 +1155,13 @@ nsXMLContentSink::HandleEndElement(const PRUnichar *aName,
|
||||||
DidAddContent();
|
DidAddContent();
|
||||||
|
|
||||||
#ifdef MOZ_SVG
|
#ifdef MOZ_SVG
|
||||||
if (mDocument &&
|
if (content->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||||
content->GetNameSpaceID() == kNameSpaceID_SVG &&
|
content->Tag() == nsGkAtoms::svg) {
|
||||||
(
|
|
||||||
#ifdef MOZ_SMIL
|
|
||||||
content->Tag() == nsGkAtoms::svg ||
|
|
||||||
#endif
|
|
||||||
content->HasAttr(kNameSpaceID_None, nsGkAtoms::onload))) {
|
|
||||||
FlushTags();
|
FlushTags();
|
||||||
|
nsCOMPtr<nsIRunnable> event = new nsHtml5SVGLoadDispatcher(content);
|
||||||
nsEvent event(PR_TRUE, NS_SVG_LOAD);
|
if (NS_FAILED(NS_DispatchToMainThread(event))) {
|
||||||
event.eventStructType = NS_SVG_EVENT;
|
NS_WARNING("failed to dispatch svg load dispatcher");
|
||||||
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->GetPrimaryShell();
|
|
||||||
if (shell) {
|
|
||||||
ctx = shell->GetPresContext();
|
|
||||||
}
|
}
|
||||||
nsEventDispatcher::Dispatch(content, ctx, &event);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ load 384637-1.svg
|
||||||
load 384728-1.svg
|
load 384728-1.svg
|
||||||
load 385246-1.svg
|
load 385246-1.svg
|
||||||
load 385246-2.svg
|
load 385246-2.svg
|
||||||
asserts(1) load 385840-1.svg # bug 385845
|
load 385840-1.svg
|
||||||
load 385852-1.svg
|
load 385852-1.svg
|
||||||
load 386475-1.xhtml
|
load 386475-1.xhtml
|
||||||
load 386566-1.svg
|
load 386566-1.svg
|
||||||
|
|
|
@ -50,6 +50,12 @@ EXPORTS = \
|
||||||
nsHtml5Module.h \
|
nsHtml5Module.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
ifdef MOZ_SVG
|
||||||
|
EXPORTS += \
|
||||||
|
nsHtml5SVGLoadDispatcher.h \
|
||||||
|
$(NULL)
|
||||||
|
endif
|
||||||
|
|
||||||
CPPSRCS = \
|
CPPSRCS = \
|
||||||
nsHtml5Atoms.cpp \
|
nsHtml5Atoms.cpp \
|
||||||
nsHtml5Atom.cpp \
|
nsHtml5Atom.cpp \
|
||||||
|
@ -77,6 +83,12 @@ CPPSRCS = \
|
||||||
nsHtml5SpeculativeLoad.cpp \
|
nsHtml5SpeculativeLoad.cpp \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
ifdef MOZ_SVG
|
||||||
|
CPPSRCS += \
|
||||||
|
nsHtml5SVGLoadDispatcher.cpp \
|
||||||
|
$(NULL)
|
||||||
|
endif
|
||||||
|
|
||||||
FORCE_STATIC_LIB = 1
|
FORCE_STATIC_LIB = 1
|
||||||
|
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/* ***** 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"
|
||||||
|
|
||||||
|
nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
|
||||||
|
: mElement(aElement)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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()->GetPrimaryShell();
|
||||||
|
if (shell) {
|
||||||
|
ctx = shell->GetPresContext();
|
||||||
|
}
|
||||||
|
nsEventDispatcher::Dispatch(mElement, ctx, &event);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/* ***** 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;
|
||||||
|
public:
|
||||||
|
nsHtml5SVGLoadDispatcher(nsIContent* aElement);
|
||||||
|
NS_IMETHOD Run();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // nsHtml5SVGLoadDispatcher_h_
|
|
@ -486,24 +486,13 @@ nsHtml5TreeBuilder::elementPopped(PRInt32 aNamespace, nsIAtom* aName, nsIContent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (aNamespace == kNameSpaceID_SVG) {
|
if (aNamespace == kNameSpaceID_SVG) {
|
||||||
#if 0
|
#ifdef MOZ_SVG
|
||||||
if (aElement->HasAttr(kNameSpaceID_None, nsHtml5Atoms::onload)) {
|
if (aName == nsHtml5Atoms::svg) {
|
||||||
nsEvent event(PR_TRUE, NS_SVG_LOAD);
|
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||||
event.eventStructType = NS_SVG_EVENT;
|
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||||
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
|
treeOp->Init(eTreeOpSvgLoad, aElement);
|
||||||
// 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()->GetPrimaryShell();
|
|
||||||
if (shell) {
|
|
||||||
ctx = shell->GetPresContext();
|
|
||||||
}
|
|
||||||
nsEventDispatcher::Dispatch(aElement, ctx, &event);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// TODO soft flush the op queue every now and then
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// we now have only HTML
|
// we now have only HTML
|
||||||
|
|
|
@ -61,6 +61,10 @@
|
||||||
#include "nsIFormProcessor.h"
|
#include "nsIFormProcessor.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
|
|
||||||
|
#ifdef MOZ_SVG
|
||||||
|
#include "nsHtml5SVGLoadDispatcher.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
|
static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -660,6 +664,16 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||||
sele->FreezeUriAsyncDefer();
|
sele->FreezeUriAsyncDefer();
|
||||||
return rv;
|
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: {
|
default: {
|
||||||
NS_NOTREACHED("Bogus tree op");
|
NS_NOTREACHED("Bogus tree op");
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,9 @@ enum eHtml5TreeOperation {
|
||||||
eTreeOpStreamEnded,
|
eTreeOpStreamEnded,
|
||||||
eTreeOpSetStyleLineNumber,
|
eTreeOpSetStyleLineNumber,
|
||||||
eTreeOpSetScriptLineNumberAndFreeze,
|
eTreeOpSetScriptLineNumberAndFreeze,
|
||||||
|
#ifdef MOZ_SVG
|
||||||
|
eTreeOpSvgLoad,
|
||||||
|
#endif
|
||||||
eTreeOpStartLayout
|
eTreeOpStartLayout
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,8 @@ _TEST_FILES = parser_datreader.js \
|
||||||
bug_502091_iframe.html \
|
bug_502091_iframe.html \
|
||||||
test_compatmode.html \
|
test_compatmode.html \
|
||||||
invalidchar.xml \
|
invalidchar.xml \
|
||||||
|
test_bug552938.html \
|
||||||
|
test_bug552938-2.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
|
|
@ -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>
|
|
@ -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>
|
Загрузка…
Ссылка в новой задаче