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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 if (item->isSpecialNode() && !item->hasTagName(addressTag) && !item->has
TagName(divTag) && !item->hasTagName(pTag)) | 539 if (item->isSpecialNode() && !item->hasTagName(addressTag) && !item->has
TagName(divTag) && !item->hasTagName(pTag)) |
540 break; | 540 break; |
541 nodeRecord = nodeRecord->next(); | 541 nodeRecord = nodeRecord->next(); |
542 } | 542 } |
543 processFakePEndTagIfPInButtonScope(); | 543 processFakePEndTagIfPInButtonScope(); |
544 m_tree.insertHTMLElement(token); | 544 m_tree.insertHTMLElement(token); |
545 } | 545 } |
546 | 546 |
547 typedef HashMap<AtomicString, QualifiedName> PrefixedNameToQualifiedNameMap; | 547 typedef HashMap<AtomicString, QualifiedName> PrefixedNameToQualifiedNameMap; |
548 | 548 |
549 static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, const
QualifiedName* const* names, size_t length) | 549 static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, const
Vector<const QualifiedName*>& names) |
550 { | 550 { |
| 551 size_t length = names.size(); |
551 for (size_t i = 0; i < length; ++i) { | 552 for (size_t i = 0; i < length; ++i) { |
552 const QualifiedName& name = *names[i]; | 553 const QualifiedName& name = *names[i]; |
553 const AtomicString& localName = name.localName(); | 554 const AtomicString& localName = name.localName(); |
554 AtomicString loweredLocalName = localName.lower(); | 555 AtomicString loweredLocalName = localName.lower(); |
555 if (loweredLocalName != localName) | 556 if (loweredLocalName != localName) |
556 map->add(loweredLocalName, name); | 557 map->add(loweredLocalName, name); |
557 } | 558 } |
558 } | 559 } |
559 | 560 |
560 static void adjustSVGTagNameCase(AtomicHTMLToken* token) | 561 static void adjustSVGTagNameCase(AtomicHTMLToken* token) |
561 { | 562 { |
562 static PrefixedNameToQualifiedNameMap* caseMap = 0; | 563 static PrefixedNameToQualifiedNameMap* caseMap = 0; |
563 if (!caseMap) { | 564 if (!caseMap) { |
564 caseMap = new PrefixedNameToQualifiedNameMap; | 565 caseMap = new PrefixedNameToQualifiedNameMap; |
565 const QualifiedName* const* svgTags = SVGNames::getSVGTags(); | 566 Vector<const QualifiedName*> svgTags; |
566 mapLoweredLocalNameToName(caseMap, svgTags, SVGNames::SVGTagsCount); | 567 SVGNames::getSVGTags(svgTags); |
| 568 mapLoweredLocalNameToName(caseMap, svgTags); |
567 } | 569 } |
568 | 570 |
569 const QualifiedName& casedName = caseMap->get(token->name()); | 571 const QualifiedName& casedName = caseMap->get(token->name()); |
570 if (casedName.localName().isNull()) | 572 if (casedName.localName().isNull()) |
571 return; | 573 return; |
572 token->setName(casedName.localName()); | 574 token->setName(casedName.localName()); |
573 } | 575 } |
574 | 576 |
575 template<const QualifiedName* const* getAttrs(), unsigned length> | 577 template<void getAttrs(Vector<const QualifiedName*>&)> |
576 static void adjustAttributes(AtomicHTMLToken* token) | 578 static void adjustAttributes(AtomicHTMLToken* token) |
577 { | 579 { |
578 static PrefixedNameToQualifiedNameMap* caseMap = 0; | 580 static PrefixedNameToQualifiedNameMap* caseMap = 0; |
579 if (!caseMap) { | 581 if (!caseMap) { |
580 caseMap = new PrefixedNameToQualifiedNameMap; | 582 caseMap = new PrefixedNameToQualifiedNameMap; |
581 const QualifiedName* const* attrs = getAttrs(); | 583 Vector<const QualifiedName*> attrs; |
582 mapLoweredLocalNameToName(caseMap, attrs, length); | 584 getAttrs(attrs); |
| 585 mapLoweredLocalNameToName(caseMap, attrs); |
583 } | 586 } |
584 | 587 |
585 for (unsigned i = 0; i < token->attributes().size(); ++i) { | 588 for (unsigned i = 0; i < token->attributes().size(); ++i) { |
586 Attribute& tokenAttribute = token->attributes().at(i); | 589 Attribute& tokenAttribute = token->attributes().at(i); |
587 const QualifiedName& casedName = caseMap->get(tokenAttribute.localName()
); | 590 const QualifiedName& casedName = caseMap->get(tokenAttribute.localName()
); |
588 if (!casedName.localName().isNull()) | 591 if (!casedName.localName().isNull()) |
589 tokenAttribute.parserSetName(casedName); | 592 tokenAttribute.parserSetName(casedName); |
590 } | 593 } |
591 } | 594 } |
592 | 595 |
593 static void adjustSVGAttributes(AtomicHTMLToken* token) | 596 static void adjustSVGAttributes(AtomicHTMLToken* token) |
594 { | 597 { |
595 adjustAttributes<SVGNames::getSVGAttrs, SVGNames::SVGAttrsCount>(token); | 598 adjustAttributes<SVGNames::getSVGAttrs>(token); |
596 } | 599 } |
597 | 600 |
598 static void adjustMathMLAttributes(AtomicHTMLToken* token) | 601 static void adjustMathMLAttributes(AtomicHTMLToken* token) |
599 { | 602 { |
600 adjustAttributes<MathMLNames::getMathMLAttrs, MathMLNames::MathMLAttrsCount>
(token); | 603 adjustAttributes<MathMLNames::getMathMLAttrs>(token); |
601 } | 604 } |
602 | 605 |
603 static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const Atomic
String& prefix, const QualifiedName* const* names, size_t length) | 606 static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, const Atomic
String& prefix, const Vector<const QualifiedName*>& names) |
604 { | 607 { |
| 608 size_t length = names.size(); |
605 for (size_t i = 0; i < length; ++i) { | 609 for (size_t i = 0; i < length; ++i) { |
606 const QualifiedName* name = names[i]; | 610 const QualifiedName* name = names[i]; |
607 const AtomicString& localName = name->localName(); | 611 const AtomicString& localName = name->localName(); |
608 AtomicString prefixColonLocalName = prefix + ':' + localName; | 612 AtomicString prefixColonLocalName = prefix + ':' + localName; |
609 QualifiedName nameWithPrefix(prefix, localName, name->namespaceURI()); | 613 QualifiedName nameWithPrefix(prefix, localName, name->namespaceURI()); |
610 map->add(prefixColonLocalName, nameWithPrefix); | 614 map->add(prefixColonLocalName, nameWithPrefix); |
611 } | 615 } |
612 } | 616 } |
613 | 617 |
614 static void adjustForeignAttributes(AtomicHTMLToken* token) | 618 static void adjustForeignAttributes(AtomicHTMLToken* token) |
615 { | 619 { |
616 static PrefixedNameToQualifiedNameMap* map = 0; | 620 static PrefixedNameToQualifiedNameMap* map = 0; |
617 if (!map) { | 621 if (!map) { |
618 map = new PrefixedNameToQualifiedNameMap; | 622 map = new PrefixedNameToQualifiedNameMap; |
619 | 623 |
620 const QualifiedName* const* attrs = XLinkNames::getXLinkAttrs(); | 624 Vector<const QualifiedName*> attrs; |
621 addNamesWithPrefix(map, xlinkAtom, attrs, XLinkNames::XLinkAttrsCount); | 625 XLinkNames::getXLinkAttrs(attrs); |
| 626 addNamesWithPrefix(map, xlinkAtom, attrs); |
622 | 627 |
623 attrs = XMLNames::getXMLAttrs(); | 628 XMLNames::getXMLAttrs(attrs); |
624 addNamesWithPrefix(map, xmlAtom, attrs, XMLNames::XMLAttrsCount); | 629 addNamesWithPrefix(map, xmlAtom, attrs); |
625 | 630 |
626 map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr); | 631 map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr); |
627 map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames::
xmlnsNamespaceURI)); | 632 map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames::
xmlnsNamespaceURI)); |
628 } | 633 } |
629 | 634 |
630 for (unsigned i = 0; i < token->attributes().size(); ++i) { | 635 for (unsigned i = 0; i < token->attributes().size(); ++i) { |
631 Attribute& tokenAttribute = token->attributes().at(i); | 636 Attribute& tokenAttribute = token->attributes().at(i); |
632 const QualifiedName& name = map->get(tokenAttribute.localName()); | 637 const QualifiedName& name = map->get(tokenAttribute.localName()); |
633 if (!name.localName().isNull()) | 638 if (!name.localName().isNull()) |
634 tokenAttribute.parserSetName(name); | 639 tokenAttribute.parserSetName(name); |
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2822 ASSERT(m_isAttached); | 2827 ASSERT(m_isAttached); |
2823 // Warning, this may detach the parser. Do not do anything else after this. | 2828 // Warning, this may detach the parser. Do not do anything else after this. |
2824 m_tree.finishedParsing(); | 2829 m_tree.finishedParsing(); |
2825 } | 2830 } |
2826 | 2831 |
2827 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) | 2832 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) |
2828 { | 2833 { |
2829 } | 2834 } |
2830 | 2835 |
2831 } // namespace WebCore | 2836 } // namespace WebCore |
OLD | NEW |