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