Commit eebecacc authored by ch.dumez@sisa.samsung.com's avatar ch.dumez@sisa.samsung.com
Browse files

Introduce a SVGUnknownElement class for unknown SVG elements

https://bugs.webkit.org/show_bug.cgi?id=120155

Reviewed by Andreas Kling.

Introduce a SVGUnknownElement class and have it override rendererIsNeeded() to return false.
We now use SVGUnknownElement type (instead of SVGElement) for unknown SVG elements:
- Unknown Elements in SVG namespace
- Registered custom tag elements in SVG namespace:
  http://www.w3.org/TR/2013/WD-custom-elements-20130514/#registering-custom-elements

As a consequence, SVGElement::rendererIsNeeded() is not longer required to return false and
it will be able to behave as SVGStyledElement::rendererIsNeeded() once we merge
SVGStyledElement into SVGElement.

This is a pre-requirement to merging SVGStyledElement into SVGElement.

No new tests, no behavior change.

* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* dom/CustomElementConstructor.cpp:
(WebCore::CustomElementConstructor::createElementInternal):
* dom/make_names.pl:
(defaultParametersHash):
(printJSElementIncludes):
(printWrapperFunctions):
(printWrapperFactoryCppFile):
* svg/SVGElement.cpp:
* svg/SVGElement.h:
* svg/SVGUnknownElement.h: Added.
(WebCore::SVGUnknownElement::create):
(WebCore::SVGUnknownElement::SVGUnknownElement):
* svg/svgtags.in:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154443 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1d087101
2013-08-22 Christophe Dumez <ch.dumez@sisa.samsung.com>
Introduce a SVGUnknownElement class for unknown SVG elements
https://bugs.webkit.org/show_bug.cgi?id=120155
Reviewed by Andreas Kling.
Introduce a SVGUnknownElement class and have it override rendererIsNeeded() to return false.
We now use SVGUnknownElement type (instead of SVGElement) for unknown SVG elements:
- Unknown Elements in SVG namespace
- Registered custom tag elements in SVG namespace:
http://www.w3.org/TR/2013/WD-custom-elements-20130514/#registering-custom-elements
As a consequence, SVGElement::rendererIsNeeded() is not longer required to return false and
it will be able to behave as SVGStyledElement::rendererIsNeeded() once we merge
SVGStyledElement into SVGElement.
This is a pre-requirement to merging SVGStyledElement into SVGElement.
No new tests, no behavior change.
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* dom/CustomElementConstructor.cpp:
(WebCore::CustomElementConstructor::createElementInternal):
* dom/make_names.pl:
(defaultParametersHash):
(printJSElementIncludes):
(printWrapperFunctions):
(printWrapperFactoryCppFile):
* svg/SVGElement.cpp:
* svg/SVGElement.h:
* svg/SVGUnknownElement.h: Added.
(WebCore::SVGUnknownElement::create):
(WebCore::SVGUnknownElement::SVGUnknownElement):
* svg/svgtags.in:
2013-08-22 Rob Buis <rwlbuis@webkit.org> 2013-08-22 Rob Buis <rwlbuis@webkit.org>
   
REGRESSION: Assertion failure !collection->hasExactlyOneItem() in WebCore::namedItemGetter REGRESSION: Assertion failure !collection->hasExactlyOneItem() in WebCore::namedItemGetter
...@@ -5307,6 +5307,7 @@ webcore_svg_sources += \ ...@@ -5307,6 +5307,7 @@ webcore_svg_sources += \
Source/WebCore/svg/SVGUnitTypes.h \ Source/WebCore/svg/SVGUnitTypes.h \
Source/WebCore/svg/SVGURIReference.cpp \ Source/WebCore/svg/SVGURIReference.cpp \
Source/WebCore/svg/SVGURIReference.h \ Source/WebCore/svg/SVGURIReference.h \
Source/WebCore/svg/SVGUnknownElement.h \
Source/WebCore/svg/SVGUseElement.cpp \ Source/WebCore/svg/SVGUseElement.cpp \
Source/WebCore/svg/SVGUseElement.h \ Source/WebCore/svg/SVGUseElement.h \
Source/WebCore/svg/SVGViewElement.cpp \ Source/WebCore/svg/SVGViewElement.cpp \
......
...@@ -2811,6 +2811,7 @@ HEADERS += \ ...@@ -2811,6 +2811,7 @@ HEADERS += \
svg/SVGTRefElement.h \ svg/SVGTRefElement.h \
svg/SVGTSpanElement.h \ svg/SVGTSpanElement.h \
svg/SVGURIReference.h \ svg/SVGURIReference.h \
svg/SVGUnknownElement.h \
svg/SVGUseElement.h \ svg/SVGUseElement.h \
svg/SVGViewElement.h \ svg/SVGViewElement.h \
svg/SVGViewSpec.h \ svg/SVGViewSpec.h \
......
...@@ -20930,6 +20930,7 @@ ...@@ -20930,6 +20930,7 @@
<ClInclude Include="..\svg\SVGTSpanElement.h" /> <ClInclude Include="..\svg\SVGTSpanElement.h" />
<ClInclude Include="..\svg\SVGUnitTypes.h" /> <ClInclude Include="..\svg\SVGUnitTypes.h" />
<ClInclude Include="..\svg\SVGURIReference.h" /> <ClInclude Include="..\svg\SVGURIReference.h" />
<ClInclude Include="..\svg\SVGUnknownElement.h" />
<ClInclude Include="..\svg\SVGUseElement.h" /> <ClInclude Include="..\svg\SVGUseElement.h" />
<ClInclude Include="..\svg\SVGViewElement.h" /> <ClInclude Include="..\svg\SVGViewElement.h" />
<ClInclude Include="..\svg\SVGViewSpec.h" /> <ClInclude Include="..\svg\SVGViewSpec.h" />
...@@ -21392,4 +21393,4 @@ ...@@ -21392,4 +21393,4 @@
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" /> <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -12214,6 +12214,9 @@ ...@@ -12214,6 +12214,9 @@
<ClInclude Include="..\svg\SVGURIReference.h"> <ClInclude Include="..\svg\SVGURIReference.h">
<Filter>rendering\svg</Filter> <Filter>rendering\svg</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\svg\SVGUnknownElement.h">
<Filter>rendering\svg</Filter>
</ClInclude>
<ClInclude Include="..\svg\SVGUseElement.h"> <ClInclude Include="..\svg\SVGUseElement.h">
<Filter>rendering\svg</Filter> <Filter>rendering\svg</Filter>
</ClInclude> </ClInclude>
...@@ -15778,4 +15781,4 @@ ...@@ -15778,4 +15781,4 @@
<Filter>plugins\win</Filter> <Filter>plugins\win</Filter>
</MASM> </MASM>
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
#include "Document.h" #include "Document.h"
#include "HTMLElement.h" #include "HTMLElement.h"
#include "HTMLNames.h" #include "HTMLNames.h"
#include "SVGElement.h"
#include "SVGNames.h" #include "SVGNames.h"
#include "SVGUnknownElement.h"
#include <wtf/Assertions.h> #include <wtf/Assertions.h>
namespace WebCore { namespace WebCore {
...@@ -83,7 +83,7 @@ PassRefPtr<Element> CustomElementConstructor::createElementInternal() ...@@ -83,7 +83,7 @@ PassRefPtr<Element> CustomElementConstructor::createElementInternal()
return HTMLElement::create(m_typeName, document()); return HTMLElement::create(m_typeName, document());
#if ENABLE(SVG) #if ENABLE(SVG)
if (SVGNames::svgNamespaceURI == m_typeName.namespaceURI()) if (SVGNames::svgNamespaceURI == m_typeName.namespaceURI())
return SVGElement::create(m_typeName, document()); return SVGUnknownElement::create(m_typeName, document());
#endif #endif
return Element::create(m_typeName, document()); return Element::create(m_typeName, document());
} }
......
...@@ -153,6 +153,7 @@ die "You must specify a namespace (e.g. SVG) for <namespace>Names.h" unless $par ...@@ -153,6 +153,7 @@ die "You must specify a namespace (e.g. SVG) for <namespace>Names.h" unless $par
die "You must specify a namespaceURI (e.g. http://www.w3.org/2000/svg)" unless $parameters{namespaceURI}; die "You must specify a namespaceURI (e.g. http://www.w3.org/2000/svg)" unless $parameters{namespaceURI};
$parameters{namespacePrefix} = $parameters{namespace} unless $parameters{namespacePrefix}; $parameters{namespacePrefix} = $parameters{namespace} unless $parameters{namespacePrefix};
$parameters{fallbackJSInterfaceName} = $parameters{fallbackInterfaceName} unless $parameters{fallbackJSInterfaceName};
my $namesBasePath = "$outputDir/$parameters{namespace}Names"; my $namesBasePath = "$outputDir/$parameters{namespace}Names";
my $factoryBasePath = "$outputDir/$parameters{namespace}ElementFactory"; my $factoryBasePath = "$outputDir/$parameters{namespace}ElementFactory";
...@@ -199,7 +200,8 @@ sub defaultParametersHash ...@@ -199,7 +200,8 @@ sub defaultParametersHash
'guardFactoryWith' => '', 'guardFactoryWith' => '',
'tagsNullNamespace' => 0, 'tagsNullNamespace' => 0,
'attrsNullNamespace' => 0, 'attrsNullNamespace' => 0,
'fallbackInterfaceName' => '' 'fallbackInterfaceName' => '',
'fallbackJSInterfaceName' => ''
); );
} }
...@@ -731,7 +733,7 @@ sub printJSElementIncludes ...@@ -731,7 +733,7 @@ sub printJSElementIncludes
print F "#include \"JS${JSInterfaceName}.h\"\n"; print F "#include \"JS${JSInterfaceName}.h\"\n";
} }
print F "#include \"JS$parameters{fallbackInterfaceName}.h\"\n"; print F "#include \"JS$parameters{fallbackJSInterfaceName}.h\"\n";
} }
sub printElementIncludes sub printElementIncludes
...@@ -1033,7 +1035,7 @@ sub printWrapperFunctions ...@@ -1033,7 +1035,7 @@ sub printWrapperFunctions
for my $tagName (sort keys %enabledTags) { for my $tagName (sort keys %enabledTags) {
# Avoid defining the same wrapper method twice. # Avoid defining the same wrapper method twice.
my $JSInterfaceName = $enabledTags{$tagName}{JSInterfaceName}; my $JSInterfaceName = $enabledTags{$tagName}{JSInterfaceName};
next if defined($tagsSeen{$JSInterfaceName}) || (usesDefaultJSWrapper($tagName) && ($parameters{fallbackInterfaceName} eq $parameters{namespace} . "Element")); next if defined($tagsSeen{$JSInterfaceName}) || (usesDefaultJSWrapper($tagName) && ($parameters{fallbackJSInterfaceName} eq $parameters{namespace} . "Element"));
$tagsSeen{$JSInterfaceName} = 1; $tagsSeen{$JSInterfaceName} = 1;
my $conditional = $enabledTags{$tagName}{conditional}; my $conditional = $enabledTags{$tagName}{conditional};
...@@ -1063,7 +1065,7 @@ static JSDOMWrapper* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGloba ...@@ -1063,7 +1065,7 @@ static JSDOMWrapper* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGloba
{ {
if (!ContextFeatures::${contextConditional}Enabled(element->document())) { if (!ContextFeatures::${contextConditional}Enabled(element->document())) {
ASSERT(!element || element->is$parameters{fallbackInterfaceName}()); ASSERT(!element || element->is$parameters{fallbackInterfaceName}());
return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackInterfaceName}, element.get()); return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackJSInterfaceName}, element.get());
} }
return CREATE_DOM_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get()); return CREATE_DOM_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get());
...@@ -1077,7 +1079,7 @@ static JSDOMWrapper* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGloba ...@@ -1077,7 +1079,7 @@ static JSDOMWrapper* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGloba
{ {
if (!RuntimeEnabledFeatures::${runtimeConditional}Enabled()) { if (!RuntimeEnabledFeatures::${runtimeConditional}Enabled()) {
ASSERT(!element || element->is$parameters{fallbackInterfaceName}()); ASSERT(!element || element->is$parameters{fallbackInterfaceName}());
return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackInterfaceName}, element.get()); return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackJSInterfaceName}, element.get());
} }
return CREATE_DOM_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get()); return CREATE_DOM_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get());
...@@ -1170,7 +1172,7 @@ END ...@@ -1170,7 +1172,7 @@ END
for my $tag (sort keys %enabledTags) { for my $tag (sort keys %enabledTags) {
# Do not add the name to the map if it does not have a JS wrapper constructor or uses the default wrapper. # Do not add the name to the map if it does not have a JS wrapper constructor or uses the default wrapper.
next if (usesDefaultJSWrapper($tag, \%enabledTags) && ($parameters{fallbackInterfaceName} eq $parameters{namespace} . "Element")); next if (usesDefaultJSWrapper($tag, \%enabledTags) && ($parameters{fallbackJSInterfaceName} eq $parameters{namespace} . "Element"));
my $conditional = $enabledTags{$tag}{conditional}; my $conditional = $enabledTags{$tag}{conditional};
if ($conditional) { if ($conditional) {
...@@ -1198,7 +1200,7 @@ END ...@@ -1198,7 +1200,7 @@ END
; ;
print F <<END print F <<END
return createWrapperFunction(exec, globalObject, element); return createWrapperFunction(exec, globalObject, element);
return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackInterfaceName}, element.get()); return CREATE_DOM_WRAPPER(exec, globalObject, $parameters{fallbackJSInterfaceName}, element.get());
END END
; ;
print F <<END print F <<END
......
...@@ -54,11 +54,6 @@ SVGElement::SVGElement(const QualifiedName& tagName, Document* document) ...@@ -54,11 +54,6 @@ SVGElement::SVGElement(const QualifiedName& tagName, Document* document)
{ {
} }
PassRefPtr<SVGElement> SVGElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new SVGElement(tagName, document));
}
SVGElement::~SVGElement() SVGElement::~SVGElement()
{ {
if (!hasSVGRareData()) if (!hasSVGRareData())
......
...@@ -45,9 +45,6 @@ class SVGSVGElement; ...@@ -45,9 +45,6 @@ class SVGSVGElement;
class SVGElement : public StyledElement, public SVGLangSpace { class SVGElement : public StyledElement, public SVGLangSpace {
public: public:
static PassRefPtr<SVGElement> create(const QualifiedName&, Document*);
virtual ~SVGElement();
bool isOutermostSVGSVGElement() const; bool isOutermostSVGSVGElement() const;
String xmlbase() const; String xmlbase() const;
...@@ -126,6 +123,7 @@ public: ...@@ -126,6 +123,7 @@ public:
protected: protected:
SVGElement(const QualifiedName&, Document*); SVGElement(const QualifiedName&, Document*);
virtual ~SVGElement();
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE; virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
......
/*
* Copyright (C) 2013 Samsung Electronics. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SVGUnknownElement_h
#define SVGUnknownElement_h
#if ENABLE(SVG)
#include "SVGElement.h"
namespace WebCore {
// This type is used for 2 kinds of elements:
// - Unknown Elements in SVG namespace
// - Registered custom tag elements in SVG namespace (http://www.w3.org/TR/2013/WD-custom-elements-20130514/#registering-custom-elements)
//
// The main purpose of this class at the moment is to override rendererIsNeeded() to return
// false to make sure we don't attempt to render such elements.
class SVGUnknownElement FINAL : public SVGElement {
public:
static PassRefPtr<SVGUnknownElement> create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new SVGUnknownElement(tagName, document));
}
private:
SVGUnknownElement(const QualifiedName& tagName, Document* document)
: SVGElement(tagName, document)
{
}
virtual bool rendererIsNeeded(const RenderStyle&) OVERRIDE { return false; }
};
} // namespace WebCore
#endif // ENABLE(SVG)
#endif // SVGUnknownElement_h
namespace="SVG" namespace="SVG"
namespaceURI="http://www.w3.org/2000/svg" namespaceURI="http://www.w3.org/2000/svg"
guardFactoryWith="ENABLE(SVG)" guardFactoryWith="ENABLE(SVG)"
fallbackInterfaceName="SVGElement" fallbackInterfaceName="SVGUnknownElement"
fallbackJSInterfaceName="SVGElement"
a a
#if ENABLE_SVG_FONTS #if ENABLE_SVG_FONTS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment