Commit c3cde884 authored by eric@webkit.org's avatar eric@webkit.org

2010-07-10 Eric Seidel <eric@webkit.org>

        Reviewed by Adam Barth.

        HTMLTreeBuilder needs adjustForeignAttributes support
        https://bugs.webkit.org/show_bug.cgi?id=42022

        * html5lib/runner-expected-html5.txt:
         - We now pass 3 more tests.
2010-07-10  Eric Seidel  <eric@webkit.org>

        Reviewed by Adam Barth.

        HTMLTreeBuilder needs adjustForeignAttributes support
        https://bugs.webkit.org/show_bug.cgi?id=42022

        To add adjust foreign attributes support I had to add an
        AtomicString (prefixed name) to QualifiedName hash.  Once I had
        done that, I decided it would be best for the other "adjust" functions
        to share the same hash logic, so I moved them to using the same
        AtomicString -> QualifiedName hash as well.

        Tested by html5lib/runner.html

        * dom/Attribute.h:
        (WebCore::Attribute::parserSetName):
        * html/HTMLTreeBuilder.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63045 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent eca7f184
2010-07-10 Eric Seidel <eric@webkit.org>
Reviewed by Adam Barth.
HTMLTreeBuilder needs adjustForeignAttributes support
https://bugs.webkit.org/show_bug.cgi?id=42022
* html5lib/runner-expected-html5.txt:
- We now pass 3 more tests.
2010-07-09 Tony Chang <tony@chromium.org> 2010-07-09 Tony Chang <tony@chromium.org>
Reviewed by Ojan Vafai. Reviewed by Ojan Vafai.
...@@ -910,10 +910,6 @@ resources/tests10.dat: ...@@ -910,10 +910,6 @@ resources/tests10.dat:
15 15
18 18
19 19
22
23
24
25
Test 13 of 25 in resources/tests10.dat failed. Input: Test 13 of 25 in resources/tests10.dat failed. Input:
<!DOCTYPE html><body><table><caption><svg><g>foo</g><g>bar</g><p>baz</table><p>quux <!DOCTYPE html><body><table><caption><svg><g>foo</g><g>bar</g><p>baz</table><p>quux
...@@ -1071,102 +1067,6 @@ Expected: ...@@ -1071,102 +1067,6 @@ Expected:
| "bar" | "bar"
| <p> | <p>
| "baz" | "baz"
Test 22 of 25 in resources/tests10.dat failed. Input:
<!DOCTYPE html><body xlink:href=foo><svg xlink:href=foo></svg>
Got:
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| xlink:href="foo"
| <svg svg>
| xlink:href="foo"
Expected:
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| xlink:href="foo"
| <svg svg>
| xlink href="foo"
Test 23 of 25 in resources/tests10.dat failed. Input:
<!DOCTYPE html><body xlink:href=foo xml:lang=en><svg><g xml:lang=en xlink:href=foo></g></svg>
Got:
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| xlink:href="foo"
| xml:lang="en"
| <svg svg>
| <svg g>
| xlink:href="foo"
| xml:lang="en"
Expected:
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| xlink:href="foo"
| xml:lang="en"
| <svg svg>
| <svg g>
| xlink href="foo"
| xml lang="en"
Test 24 of 25 in resources/tests10.dat failed. Input:
<!DOCTYPE html><body xlink:href=foo xml:lang=en><svg><g xml:lang=en xlink:href=foo /></svg>
Got:
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| xlink:href="foo"
| xml:lang="en"
| <svg svg>
| <svg g>
| xlink:href="foo"
| xml:lang="en"
Expected:
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| xlink:href="foo"
| xml:lang="en"
| <svg svg>
| <svg g>
| xlink href="foo"
| xml lang="en"
Test 25 of 25 in resources/tests10.dat failed. Input:
<!DOCTYPE html><body xlink:href=foo xml:lang=en><svg><g xml:lang=en xlink:href=foo />bar</svg>
Got:
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| xlink:href="foo"
| xml:lang="en"
| <svg svg>
| <svg g>
| xlink:href="foo"
| xml:lang="en"
| "bar"
Expected:
| <!DOCTYPE html>
| <html>
| <head>
| <body>
| xlink:href="foo"
| xml:lang="en"
| <svg svg>
| <svg g>
| xlink href="foo"
| xml lang="en"
| "bar"
resources/tests11.dat: resources/tests11.dat:
4 4
8 8
......
2010-07-10 Eric Seidel <eric@webkit.org>
Reviewed by Adam Barth.
HTMLTreeBuilder needs adjustForeignAttributes support
https://bugs.webkit.org/show_bug.cgi?id=42022
To add adjust foreign attributes support I had to add an
AtomicString (prefixed name) to QualifiedName hash. Once I had
done that, I decided it would be best for the other "adjust" functions
to share the same hash logic, so I moved them to using the same
AtomicString -> QualifiedName hash as well.
Tested by html5lib/runner.html
* dom/Attribute.h:
(WebCore::Attribute::parserSetName):
* html/HTMLTreeBuilder.cpp:
2010-07-10 Rob Buis <rwlbuis@gmail.com> 2010-07-10 Rob Buis <rwlbuis@gmail.com>
Reviewed by Darin Adler. Reviewed by Darin Adler.
...@@ -78,13 +78,10 @@ public: ...@@ -78,13 +78,10 @@ public:
void setValue(const AtomicString& value) { m_value = value; } void setValue(const AtomicString& value) { m_value = value; }
void setPrefix(const AtomicString& prefix) { m_name.setPrefix(prefix); } void setPrefix(const AtomicString& prefix) { m_name.setPrefix(prefix); }
// Note: This API is only for HTMLTreeBuilder. It is not safe to change the name // Note: This API is only for HTMLTreeBuilder. It is not safe to change the
// of an attribute once parseMappedAttributes has been called as DOM elements // name of an attribute once parseMappedAttribute has been called as DOM
// may placed the Attribute in a hash. // elements may have placed the Attribute in a hash by name.
void parserSetLocalName(const AtomicString& localName) void parserSetName(const QualifiedName& name) { m_name = name; }
{
m_name = QualifiedName(m_name.prefix(), localName, m_name.namespaceURI());
}
bool isMappedAttribute() { return m_isMappedAttribute; } bool isMappedAttribute() { return m_isMappedAttribute; }
......
...@@ -51,6 +51,9 @@ ...@@ -51,6 +51,9 @@
#include "ScriptController.h" #include "ScriptController.h"
#include "Settings.h" #include "Settings.h"
#include "Text.h" #include "Text.h"
#include "XLinkNames.h"
#include "XMLNSNames.h"
#include "XMLNames.h"
#include <wtf/UnusedParam.h> #include <wtf/UnusedParam.h>
namespace WebCore { namespace WebCore {
...@@ -660,48 +663,20 @@ void HTMLTreeBuilder::processCloseWhenNestedTag(AtomicHTMLToken& token) ...@@ -660,48 +663,20 @@ void HTMLTreeBuilder::processCloseWhenNestedTag(AtomicHTMLToken& token)
namespace { namespace {
#if ENABLE(SVG) typedef HashMap<AtomicString, QualifiedName> PrefixedNameToQualifiedNameMap;
typedef HashMap<AtomicString, AtomicString> NameCaseMap;
void addName(NameCaseMap* map, const QualifiedName& attributeName)
{
map->add(attributeName.localName().lower(), attributeName.localName());
}
NameCaseMap* createCaseMapForNames(QualifiedName** names, size_t length) void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, QualifiedName** names, size_t length)
{ {
NameCaseMap* caseMap = new NameCaseMap;
for (size_t i = 0; i < length; ++i) { for (size_t i = 0; i < length; ++i) {
QualifiedName* name = names[i]; const QualifiedName& name = *names[i];
const AtomicString& localName = name->localName(); const AtomicString& localName = name.localName();
AtomicString loweredLocalName = localName.lower(); AtomicString loweredLocalName = localName.lower();
if (loweredLocalName != localName) if (loweredLocalName != localName)
caseMap->add(loweredLocalName, localName); map->add(loweredLocalName, name);
} }
return caseMap;
} }
void adjustSVGAttributes(AtomicHTMLToken& token) #if ENABLE(SVG)
{
static NameCaseMap* caseMap = 0;
if (!caseMap) {
size_t length = 0;
QualifiedName** svgAttrs = SVGNames::getSVGAttrs(&length);
caseMap = createCaseMapForNames(svgAttrs, length);
}
NamedNodeMap* attributes = token.attributes();
if (!attributes)
return;
for (unsigned x = 0; x < attributes->length(); ++x) {
Attribute* attribute = attributes->attributeItem(x);
const AtomicString& casedName = caseMap->get(attribute->localName());
if (!casedName.isNull())
attribute->parserSetLocalName(casedName);
}
}
// FIXME: This is a hack until we can fix SVGNames to always generate all names. // FIXME: This is a hack until we can fix SVGNames to always generate all names.
QualifiedName svgTagNameFor(const AtomicString& localName) QualifiedName svgTagNameFor(const AtomicString& localName)
...@@ -709,13 +684,19 @@ QualifiedName svgTagNameFor(const AtomicString& localName) ...@@ -709,13 +684,19 @@ QualifiedName svgTagNameFor(const AtomicString& localName)
return QualifiedName(nullAtom, localName, SVGNames::svgNamespaceURI); return QualifiedName(nullAtom, localName, SVGNames::svgNamespaceURI);
} }
void addName(PrefixedNameToQualifiedNameMap* map, const QualifiedName& name)
{
map->add(name.localName().lower(), name);
}
void adjustSVGTagNameCase(AtomicHTMLToken& token) void adjustSVGTagNameCase(AtomicHTMLToken& token)
{ {
static NameCaseMap* caseMap = 0; static PrefixedNameToQualifiedNameMap* caseMap = 0;
if (!caseMap) { if (!caseMap) {
caseMap = new PrefixedNameToQualifiedNameMap;
size_t length = 0; size_t length = 0;
QualifiedName** svgTags = SVGNames::getSVGTags(&length); QualifiedName** svgTags = SVGNames::getSVGTags(&length);
caseMap = createCaseMapForNames(svgTags, length); mapLoweredLocalNameToName(caseMap, svgTags, length);
// FIXME: This is a hack around the fact that SVGNames does not // FIXME: This is a hack around the fact that SVGNames does not
// currently include all values HTML5 expects it to. // currently include all values HTML5 expects it to.
addName(caseMap, svgTagNameFor("altGlyphDef")); addName(caseMap, svgTagNameFor("altGlyphDef"));
...@@ -723,10 +704,32 @@ void adjustSVGTagNameCase(AtomicHTMLToken& token) ...@@ -723,10 +704,32 @@ void adjustSVGTagNameCase(AtomicHTMLToken& token)
addName(caseMap, svgTagNameFor("glyphRef")); addName(caseMap, svgTagNameFor("glyphRef"));
} }
const AtomicString& casedName = caseMap->get(token.name()); const QualifiedName& casedName = caseMap->get(token.name());
if (casedName.isNull()) if (casedName.localName().isNull())
return;
token.setName(casedName.localName());
}
void adjustSVGAttributes(AtomicHTMLToken& token)
{
static PrefixedNameToQualifiedNameMap* caseMap = 0;
if (!caseMap) {
caseMap = new PrefixedNameToQualifiedNameMap;
size_t length = 0;
QualifiedName** svgAttrs = SVGNames::getSVGAttrs(&length);
mapLoweredLocalNameToName(caseMap, svgAttrs, length);
}
NamedNodeMap* attributes = token.attributes();
if (!attributes)
return; return;
token.setName(casedName);
for (unsigned x = 0; x < attributes->length(); ++x) {
Attribute* attribute = attributes->attributeItem(x);
const QualifiedName& casedName = caseMap->get(attribute->localName());
if (!casedName.localName().isNull())
attribute->parserSetName(casedName);
}
} }
#endif #endif
...@@ -738,9 +741,43 @@ void adjustMathMLAttributes(AtomicHTMLToken&) ...@@ -738,9 +741,43 @@ void adjustMathMLAttributes(AtomicHTMLToken&)
} }
#endif #endif
void adjustForeignAttributes(AtomicHTMLToken&) void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const AtomicString& prefix, QualifiedName** names, size_t length)
{ {
notImplemented(); for (size_t i = 0; i < length; ++i) {
QualifiedName* name = names[i];
const AtomicString& localName = name->localName();
AtomicString prefixColonLocalName(prefix + ":" + localName);
QualifiedName nameWithPrefix(prefix, localName, name->namespaceURI());
map->add(prefixColonLocalName, nameWithPrefix);
}
}
void adjustForeignAttributes(AtomicHTMLToken& token)
{
static PrefixedNameToQualifiedNameMap* map = 0;
if (!map) {
map = new PrefixedNameToQualifiedNameMap;
size_t length = 0;
QualifiedName** attrs = XLinkNames::getXLinkAttrs(&length);
addNamesWithPrefix(map, "xlink", attrs, length);
attrs = XMLNames::getXMLAttrs(&length);
addNamesWithPrefix(map, "xml", attrs, length);
map->add("xmlns", XMLNSNames::xmlnsAttr);
map->add("xmlns:xlink", QualifiedName("xmlns", "xlink", XMLNSNames::xmlnsNamespaceURI));
}
NamedNodeMap* attributes = token.attributes();
if (!attributes)
return;
for (unsigned x = 0; x < attributes->length(); ++x) {
Attribute* attribute = attributes->attributeItem(x);
const QualifiedName& name = map->get(attribute->localName());
if (!name.localName().isNull())
attribute->parserSetName(name);
}
} }
} }
......
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