| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 if (item->isSpecialNode() && !item->hasTagName(addressTag) && !item->has
TagName(divTag) && !item->hasTagName(pTag)) | 546 if (item->isSpecialNode() && !item->hasTagName(addressTag) && !item->has
TagName(divTag) && !item->hasTagName(pTag)) |
| 547 break; | 547 break; |
| 548 nodeRecord = nodeRecord->next(); | 548 nodeRecord = nodeRecord->next(); |
| 549 } | 549 } |
| 550 processFakePEndTagIfPInButtonScope(); | 550 processFakePEndTagIfPInButtonScope(); |
| 551 m_tree.insertHTMLElement(token); | 551 m_tree.insertHTMLElement(token); |
| 552 } | 552 } |
| 553 | 553 |
| 554 typedef HashMap<AtomicString, QualifiedName> PrefixedNameToQualifiedNameMap; | 554 typedef HashMap<AtomicString, QualifiedName> PrefixedNameToQualifiedNameMap; |
| 555 | 555 |
| 556 static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, const
QualifiedName* const* names, size_t length) | 556 static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, const
Vector<const QualifiedName*>& names) |
| 557 { | 557 { |
| 558 size_t length = names.size(); |
| 558 for (size_t i = 0; i < length; ++i) { | 559 for (size_t i = 0; i < length; ++i) { |
| 559 const QualifiedName& name = *names[i]; | 560 const QualifiedName& name = *names[i]; |
| 560 const AtomicString& localName = name.localName(); | 561 const AtomicString& localName = name.localName(); |
| 561 AtomicString loweredLocalName = localName.lower(); | 562 AtomicString loweredLocalName = localName.lower(); |
| 562 if (loweredLocalName != localName) | 563 if (loweredLocalName != localName) |
| 563 map->add(loweredLocalName, name); | 564 map->add(loweredLocalName, name); |
| 564 } | 565 } |
| 565 } | 566 } |
| 566 | 567 |
| 567 static void adjustSVGTagNameCase(AtomicHTMLToken* token) | 568 static void adjustSVGTagNameCase(AtomicHTMLToken* token) |
| 568 { | 569 { |
| 569 static PrefixedNameToQualifiedNameMap* caseMap = 0; | 570 static PrefixedNameToQualifiedNameMap* caseMap = 0; |
| 570 if (!caseMap) { | 571 if (!caseMap) { |
| 571 caseMap = new PrefixedNameToQualifiedNameMap; | 572 caseMap = new PrefixedNameToQualifiedNameMap; |
| 572 const QualifiedName* const* svgTags = SVGNames::getSVGTags(); | 573 Vector<const QualifiedName*> svgTags; |
| 573 mapLoweredLocalNameToName(caseMap, svgTags, SVGNames::SVGTagsCount); | 574 SVGNames::getSVGTags(svgTags); |
| 575 mapLoweredLocalNameToName(caseMap, svgTags); |
| 574 } | 576 } |
| 575 | 577 |
| 576 const QualifiedName& casedName = caseMap->get(token->name()); | 578 const QualifiedName& casedName = caseMap->get(token->name()); |
| 577 if (casedName.localName().isNull()) | 579 if (casedName.localName().isNull()) |
| 578 return; | 580 return; |
| 579 token->setName(casedName.localName()); | 581 token->setName(casedName.localName()); |
| 580 } | 582 } |
| 581 | 583 |
| 582 template<const QualifiedName* const* getAttrs(), unsigned length> | 584 template<void getAttrs(Vector<const QualifiedName*>&)> |
| 583 static void adjustAttributes(AtomicHTMLToken* token) | 585 static void adjustAttributes(AtomicHTMLToken* token) |
| 584 { | 586 { |
| 585 static PrefixedNameToQualifiedNameMap* caseMap = 0; | 587 static PrefixedNameToQualifiedNameMap* caseMap = 0; |
| 586 if (!caseMap) { | 588 if (!caseMap) { |
| 587 caseMap = new PrefixedNameToQualifiedNameMap; | 589 caseMap = new PrefixedNameToQualifiedNameMap; |
| 588 const QualifiedName* const* attrs = getAttrs(); | 590 Vector<const QualifiedName*> attrs; |
| 589 mapLoweredLocalNameToName(caseMap, attrs, length); | 591 getAttrs(attrs); |
| 592 mapLoweredLocalNameToName(caseMap, attrs); |
| 590 } | 593 } |
| 591 | 594 |
| 592 for (unsigned i = 0; i < token->attributes().size(); ++i) { | 595 for (unsigned i = 0; i < token->attributes().size(); ++i) { |
| 593 Attribute& tokenAttribute = token->attributes().at(i); | 596 Attribute& tokenAttribute = token->attributes().at(i); |
| 594 const QualifiedName& casedName = caseMap->get(tokenAttribute.localName()
); | 597 const QualifiedName& casedName = caseMap->get(tokenAttribute.localName()
); |
| 595 if (!casedName.localName().isNull()) | 598 if (!casedName.localName().isNull()) |
| 596 tokenAttribute.parserSetName(casedName); | 599 tokenAttribute.parserSetName(casedName); |
| 597 } | 600 } |
| 598 } | 601 } |
| 599 | 602 |
| 600 static void adjustSVGAttributes(AtomicHTMLToken* token) | 603 static void adjustSVGAttributes(AtomicHTMLToken* token) |
| 601 { | 604 { |
| 602 adjustAttributes<SVGNames::getSVGAttrs, SVGNames::SVGAttrsCount>(token); | 605 adjustAttributes<SVGNames::getSVGAttrs>(token); |
| 603 } | 606 } |
| 604 | 607 |
| 605 static void adjustMathMLAttributes(AtomicHTMLToken* token) | 608 static void adjustMathMLAttributes(AtomicHTMLToken* token) |
| 606 { | 609 { |
| 607 adjustAttributes<MathMLNames::getMathMLAttrs, MathMLNames::MathMLAttrsCount>
(token); | 610 adjustAttributes<MathMLNames::getMathMLAttrs>(token); |
| 608 } | 611 } |
| 609 | 612 |
| 610 static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const Atomic
String& prefix, const QualifiedName* const* names, size_t length) | 613 static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const Atomic
String& prefix, const Vector<const QualifiedName*>& names) |
| 611 { | 614 { |
| 615 size_t length = names.size(); |
| 612 for (size_t i = 0; i < length; ++i) { | 616 for (size_t i = 0; i < length; ++i) { |
| 613 const QualifiedName* name = names[i]; | 617 const QualifiedName* name = names[i]; |
| 614 const AtomicString& localName = name->localName(); | 618 const AtomicString& localName = name->localName(); |
| 615 AtomicString prefixColonLocalName = prefix + ':' + localName; | 619 AtomicString prefixColonLocalName = prefix + ':' + localName; |
| 616 QualifiedName nameWithPrefix(prefix, localName, name->namespaceURI()); | 620 QualifiedName nameWithPrefix(prefix, localName, name->namespaceURI()); |
| 617 map->add(prefixColonLocalName, nameWithPrefix); | 621 map->add(prefixColonLocalName, nameWithPrefix); |
| 618 } | 622 } |
| 619 } | 623 } |
| 620 | 624 |
| 621 static void adjustForeignAttributes(AtomicHTMLToken* token) | 625 static void adjustForeignAttributes(AtomicHTMLToken* token) |
| 622 { | 626 { |
| 623 static PrefixedNameToQualifiedNameMap* map = 0; | 627 static PrefixedNameToQualifiedNameMap* map = 0; |
| 624 if (!map) { | 628 if (!map) { |
| 625 map = new PrefixedNameToQualifiedNameMap; | 629 map = new PrefixedNameToQualifiedNameMap; |
| 626 | 630 |
| 627 const QualifiedName* const* attrs = XLinkNames::getXLinkAttrs(); | 631 Vector<const QualifiedName*> attrs; |
| 628 addNamesWithPrefix(map, xlinkAtom, attrs, XLinkNames::XLinkAttrsCount); | 632 XLinkNames::getXLinkAttrs(attrs); |
| 633 addNamesWithPrefix(map, xlinkAtom, attrs); |
| 629 | 634 |
| 630 attrs = XMLNames::getXMLAttrs(); | 635 XMLNames::getXMLAttrs(attrs); |
| 631 addNamesWithPrefix(map, xmlAtom, attrs, XMLNames::XMLAttrsCount); | 636 addNamesWithPrefix(map, xmlAtom, attrs); |
| 632 | 637 |
| 633 map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr); | 638 map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr); |
| 634 map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames::
xmlnsNamespaceURI)); | 639 map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames::
xmlnsNamespaceURI)); |
| 635 } | 640 } |
| 636 | 641 |
| 637 for (unsigned i = 0; i < token->attributes().size(); ++i) { | 642 for (unsigned i = 0; i < token->attributes().size(); ++i) { |
| 638 Attribute& tokenAttribute = token->attributes().at(i); | 643 Attribute& tokenAttribute = token->attributes().at(i); |
| 639 const QualifiedName& name = map->get(tokenAttribute.localName()); | 644 const QualifiedName& name = map->get(tokenAttribute.localName()); |
| 640 if (!name.localName().isNull()) | 645 if (!name.localName().isNull()) |
| 641 tokenAttribute.parserSetName(name); | 646 tokenAttribute.parserSetName(name); |
| (...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2845 ASSERT(m_isAttached); | 2850 ASSERT(m_isAttached); |
| 2846 // Warning, this may detach the parser. Do not do anything else after this. | 2851 // Warning, this may detach the parser. Do not do anything else after this. |
| 2847 m_tree.finishedParsing(); | 2852 m_tree.finishedParsing(); |
| 2848 } | 2853 } |
| 2849 | 2854 |
| 2850 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) | 2855 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) |
| 2851 { | 2856 { |
| 2852 } | 2857 } |
| 2853 | 2858 |
| 2854 } // namespace WebCore | 2859 } // namespace WebCore |
| OLD | NEW |