Bug 1274505 - Remove SVG-based custom element support. r=wchen

--HG--
extra : rebase_source : a2caaa0fc1a49ca989dafc9e73c55ad752b83752
This commit is contained in:
John Dai 2016-07-26 00:35:00 -04:00
parent d7252a1c8d
commit 0ff1457b76
7 changed files with 12 additions and 74 deletions

View File

@ -174,7 +174,6 @@
#include "nsSMILAnimationController.h"
#include "imgIContainer.h"
#include "nsSVGUtils.h"
#include "SVGElementFactory.h"
#include "nsRefreshDriver.h"
@ -192,7 +191,6 @@
#include "nsTextNode.h"
#include "mozilla/dom/Link.h"
#include "mozilla/dom/HTMLElementBinding.h"
#include "mozilla/dom/SVGElementBinding.h"
#include "nsXULAppAPI.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/dom/TouchEvent.h"
@ -6257,7 +6255,6 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
JS::Rooted<JSObject*> protoObject(aCx);
{
JS::Rooted<JSObject*> htmlProto(aCx);
JS::Rooted<JSObject*> svgProto(aCx);
{
JSAutoCompartment ac(aCx, global);
@ -6266,12 +6263,6 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
svgProto = SVGElementBinding::GetProtoObjectHandle(aCx);
if (!svgProto) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
}
if (!aOptions.mPrototype) {
@ -6323,23 +6314,16 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
JS::Rooted<JSObject*> protoProto(aCx, protoObject);
if (!JS_WrapObject(aCx, &htmlProto) || !JS_WrapObject(aCx, &svgProto)) {
if (!JS_WrapObject(aCx, &htmlProto)) {
rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
}
// If PROTOTYPE's interface inherits from SVGElement, set NAMESPACE to SVG
// Namespace.
while (protoProto) {
if (protoProto == htmlProto) {
break;
}
if (protoProto == svgProto) {
namespaceID = kNameSpaceID_SVG;
break;
}
if (!JS_GetPrototype(aCx, protoProto, &protoProto)) {
rv.Throw(NS_ERROR_UNEXPECTED);
return;
@ -6350,21 +6334,16 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
// If name was provided and not null...
if (!lcName.IsEmpty()) {
// Let BASE be the element interface for NAME and NAMESPACE.
bool known = false;
nameAtom = NS_Atomize(lcName);
if (namespaceID == kNameSpaceID_XHTML) {
nsIParserService* ps = nsContentUtils::GetParserService();
if (!ps) {
rv.Throw(NS_ERROR_UNEXPECTED);
return;
}
known =
ps->HTMLCaseSensitiveAtomTagToId(nameAtom) != eHTMLTag_userdefined;
} else {
known = SVGElementFactory::Exists(nameAtom);
nsIParserService* ps = nsContentUtils::GetParserService();
if (!ps) {
rv.Throw(NS_ERROR_UNEXPECTED);
return;
}
bool known =
ps->HTMLCaseSensitiveAtomTagToId(nameAtom) != eHTMLTag_userdefined;
// If BASE does not exist or is an interface for a custom element, set ERROR
// to InvalidName and stop.
// If BASE exists, then it cannot be an interface for a custom element.
@ -6373,12 +6352,6 @@ nsDocument::RegisterElement(JSContext* aCx, const nsAString& aType,
return;
}
} else {
// If NAMESPACE is SVG Namespace, set ERROR to InvalidName and stop.
if (namespaceID == kNameSpaceID_SVG) {
rv.Throw(NS_ERROR_UNEXPECTED);
return;
}
nameAtom = typeAtom;
}
} // Leaving the document's compartment for the LifecycleCallbacks init

View File

@ -104,14 +104,6 @@ SVGElementFactory::Shutdown()
}
}
bool
SVGElementFactory::Exists(nsIAtom *aTag)
{
MOZ_ASSERT(sTagAtomTable, "no lookup table, needs SVGElementFactory::Init");
void* tag = PL_HashTableLookupConst(sTagAtomTable, aTag);
return tag != nullptr;
}
nsresult
NS_NewSVGElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
FromParser aFromParser)

View File

@ -16,8 +16,6 @@ class SVGElementFactory {
public:
static void Init();
static void Shutdown();
static bool Exists(nsIAtom *aTag);
};
} // namespace dom

View File

@ -46,7 +46,6 @@ function startTest() {
testRegisterSimple("some-elem", HTMLElement.prototype, true);
testRegisterSimple("x-html-p", HTMLParagraphElement.prototype, true);
testRegisterSimple("x-html-span", HTMLSpanElement.prototype, true);
testRegisterSimple("x-svg-proto", SVGElement.prototype, true);
// Make sure the prototype on unresolved elements is HTMLElement not HTMLUnknownElement.
var unresolved = document.getElementById("unresolved");
@ -57,23 +56,14 @@ function startTest() {
// Registering without a prototype should automatically create one inheriting from HTMLElement.
testRegisterSimple("x-elem-no-proto", null, false);
var simpleElem = document.createElement("x-elem-no-proto");
is(simpleElem.__proto__.__proto__, HTMLElement.prototype, "Default prototype should inherit from HTMLElement");
var simpleProto = Object.create(HTMLElement.prototype);
testRegisterSimple("x-elem-simple-proto", simpleProto, false);
var simpleProtoElem = document.createElement("x-elem-simple-proto");
is(simpleProtoElem.__proto__, simpleProto, "Custom element should use registered prototype.");
var anotherSimpleElem = document.createElementNS("http://www.w3.org/1999/xhtml", "x-elem-simple-proto");
is(anotherSimpleElem.__proto__, simpleProto, "Custom element should use registered prototype.");
// Test registering some invalid prototypes.
testRegisterSimple("x-invalid-number", 42, true);
testRegisterSimple("x-invalid-boolean", false, true);
testRegisterSimple("x-invalid-float", 1.0, true);
// Can not register with a prototype that inherits from SVGElement
// without extending an existing element type.
testRegisterSimple("x-html-obj-svg", Object.create(SVGElement.prototype), true);
// A prototype with a non-configurable "constructor" property must throw.
var nonConfigProto = Object.create(HTMLElement.prototype,
{ constructor: { configurable: false, value: function() {} } });
@ -96,7 +86,6 @@ function startTest() {
// Test registering elements that extend from a non-existing element.
testRegisterExtend("x-extend-span-nonexist", "nonexisting", Object.create(HTMLElement.prototype), true);
testRegisterExtend("x-extend-svg-nonexist", "nonexisting", Object.create(SVGElement.prototype), true);
// Test registration with duplicate type.
testRegisterSimple("x-dupe-me", Object.create(HTMLElement.prototype), false);
@ -104,14 +93,6 @@ function startTest() {
testRegisterSimple("X-DUPE-ME", Object.create(HTMLElement.prototype), true);
testRegisterSimple("x-dupe-me", null, true);
testRegisterExtend("x-dupe-me", "span", Object.create(HTMLElement.prototype), true);
testRegisterExtend("x-dupe-me", "shape", Object.create(SVGElement.prototype), true);
testRegisterExtend("x-svg-dupe-me", "circle", Object.create(SVGElement.prototype), false);
testRegisterSimple("x-svg-dupe-me", Object.create(HTMLElement.prototype), true);
testRegisterSimple("X-SVG-DUPE-ME", Object.create(HTMLElement.prototype), true);
testRegisterSimple("x-svg-dupe-me", null, true);
testRegisterExtend("x-svg-dupe-me", "span", Object.create(HTMLElement.prototype), true);
testRegisterExtend("x-svg-dupe-me", "shape", Object.create(SVGElement.prototype), true);
// document.createElement with extended type.
var extendedProto = Object.create(HTMLButtonElement.prototype);

View File

@ -1,5 +0,0 @@
[custom-element-constructor-prototype.html]
type: testharness
[If custom element type is registered with prototype, the custom element constructor should have the prototype specified in registerElement() call]
expected: FAIL

View File

@ -1,5 +0,0 @@
[custom-element-prototype.html]
type: testharness
[If custom element type is registered with prototype, the custom element instance should have the prototype specified in registerElement() call]
expected: FAIL

View File

@ -0,0 +1,4 @@
[definition-construction-algorithm-svg-namespace.html]
type: testharness
[For SVG prototype namespace is SVG namespace]
expected: FAIL