Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: Source/core/html/parser/HTMLTreeBuilder.cpp

Issue 137783012: MakeQualifiedNames should generate lazily created arrays for attributes and tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 if (loweredLocalName != localName) 562 if (loweredLocalName != localName)
563 map->add(loweredLocalName, name); 563 map->add(loweredLocalName, name);
564 } 564 }
565 } 565 }
566 566
567 static void adjustSVGTagNameCase(AtomicHTMLToken* token) 567 static void adjustSVGTagNameCase(AtomicHTMLToken* token)
568 { 568 {
569 static PrefixedNameToQualifiedNameMap* caseMap = 0; 569 static PrefixedNameToQualifiedNameMap* caseMap = 0;
570 if (!caseMap) { 570 if (!caseMap) {
571 caseMap = new PrefixedNameToQualifiedNameMap; 571 caseMap = new PrefixedNameToQualifiedNameMap;
572 const QualifiedName* const* svgTags = SVGNames::getSVGTags(); 572 QualifiedName* svgTags[SVGNames::SVGTagsCount];
573 SVGNames::getSVGTags(svgTags, SVGNames::SVGTagsCount);
573 mapLoweredLocalNameToName(caseMap, svgTags, SVGNames::SVGTagsCount); 574 mapLoweredLocalNameToName(caseMap, svgTags, SVGNames::SVGTagsCount);
574 } 575 }
575 576
576 const QualifiedName& casedName = caseMap->get(token->name()); 577 const QualifiedName& casedName = caseMap->get(token->name());
577 if (casedName.localName().isNull()) 578 if (casedName.localName().isNull())
578 return; 579 return;
579 token->setName(casedName.localName()); 580 token->setName(casedName.localName());
580 } 581 }
581 582
582 template<const QualifiedName* const* getAttrs(), unsigned length> 583 template<void getAttrs(WebCore::QualifiedName*[], unsigned), unsigned length>
583 static void adjustAttributes(AtomicHTMLToken* token) 584 static void adjustAttributes(AtomicHTMLToken* token)
584 { 585 {
585 static PrefixedNameToQualifiedNameMap* caseMap = 0; 586 static PrefixedNameToQualifiedNameMap* caseMap = 0;
586 if (!caseMap) { 587 if (!caseMap) {
587 caseMap = new PrefixedNameToQualifiedNameMap; 588 caseMap = new PrefixedNameToQualifiedNameMap;
588 const QualifiedName* const* attrs = getAttrs(); 589 WebCore::QualifiedName* attrs[length];
Inactive 2014/01/15 19:27:02 You probably don't need the WebCore:: here
590 getAttrs(attrs, length);
589 mapLoweredLocalNameToName(caseMap, attrs, length); 591 mapLoweredLocalNameToName(caseMap, attrs, length);
590 } 592 }
591 593
592 for (unsigned i = 0; i < token->attributes().size(); ++i) { 594 for (unsigned i = 0; i < token->attributes().size(); ++i) {
593 Attribute& tokenAttribute = token->attributes().at(i); 595 Attribute& tokenAttribute = token->attributes().at(i);
594 const QualifiedName& casedName = caseMap->get(tokenAttribute.localName() ); 596 const QualifiedName& casedName = caseMap->get(tokenAttribute.localName() );
595 if (!casedName.localName().isNull()) 597 if (!casedName.localName().isNull())
596 tokenAttribute.parserSetName(casedName); 598 tokenAttribute.parserSetName(casedName);
597 } 599 }
598 } 600 }
(...skipping 18 matching lines...) Expand all
617 map->add(prefixColonLocalName, nameWithPrefix); 619 map->add(prefixColonLocalName, nameWithPrefix);
618 } 620 }
619 } 621 }
620 622
621 static void adjustForeignAttributes(AtomicHTMLToken* token) 623 static void adjustForeignAttributes(AtomicHTMLToken* token)
622 { 624 {
623 static PrefixedNameToQualifiedNameMap* map = 0; 625 static PrefixedNameToQualifiedNameMap* map = 0;
624 if (!map) { 626 if (!map) {
625 map = new PrefixedNameToQualifiedNameMap; 627 map = new PrefixedNameToQualifiedNameMap;
626 628
627 const QualifiedName* const* attrs = XLinkNames::getXLinkAttrs(); 629 WebCore::QualifiedName* attrs[XLinkNames::XLinkAttrsCount];
Inactive 2014/01/15 19:27:02 Ditto.
630 XLinkNames::getXLinkAttrs(attrs, XLinkNames::XLinkAttrsCount);
628 addNamesWithPrefix(map, xlinkAtom, attrs, XLinkNames::XLinkAttrsCount); 631 addNamesWithPrefix(map, xlinkAtom, attrs, XLinkNames::XLinkAttrsCount);
629 632
630 attrs = XMLNames::getXMLAttrs(); 633 WebCore::QualifiedName* xmlAttrs[XMLNames::XMLAttrsCount];
Inactive 2014/01/15 19:27:02 Ditto.
631 addNamesWithPrefix(map, xmlAtom, attrs, XMLNames::XMLAttrsCount); 634 XMLNames::getXMLAttrs(xmlAttrs, XMLNames::XMLAttrsCount);
635 addNamesWithPrefix(map, xmlAtom, xmlAttrs, XMLNames::XMLAttrsCount);
632 636
633 map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr); 637 map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr);
634 map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames:: xmlnsNamespaceURI)); 638 map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, XMLNSNames:: xmlnsNamespaceURI));
635 } 639 }
636 640
637 for (unsigned i = 0; i < token->attributes().size(); ++i) { 641 for (unsigned i = 0; i < token->attributes().size(); ++i) {
638 Attribute& tokenAttribute = token->attributes().at(i); 642 Attribute& tokenAttribute = token->attributes().at(i);
639 const QualifiedName& name = map->get(tokenAttribute.localName()); 643 const QualifiedName& name = map->get(tokenAttribute.localName());
640 if (!name.localName().isNull()) 644 if (!name.localName().isNull())
641 tokenAttribute.parserSetName(name); 645 tokenAttribute.parserSetName(name);
(...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 ASSERT(m_isAttached); 2849 ASSERT(m_isAttached);
2846 // Warning, this may detach the parser. Do not do anything else after this. 2850 // Warning, this may detach the parser. Do not do anything else after this.
2847 m_tree.finishedParsing(); 2851 m_tree.finishedParsing();
2848 } 2852 }
2849 2853
2850 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) 2854 void HTMLTreeBuilder::parseError(AtomicHTMLToken*)
2851 { 2855 {
2852 } 2856 }
2853 2857
2854 } // namespace WebCore 2858 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698