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

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

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs Created 3 years, 10 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, 2014 Apple Inc. All rights reserved. 3 * Copyright (C) 2011, 2014 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 442
443 template <typename TableQualifiedName> 443 template <typename TableQualifiedName>
444 static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map, 444 static void mapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map,
445 const TableQualifiedName* const* names, 445 const TableQualifiedName* const* names,
446 size_t length) { 446 size_t length) {
447 for (size_t i = 0; i < length; ++i) { 447 for (size_t i = 0; i < length; ++i) {
448 const QualifiedName& name = *names[i]; 448 const QualifiedName& name = *names[i];
449 const AtomicString& localName = name.localName(); 449 const AtomicString& localName = name.localName();
450 AtomicString loweredLocalName = localName.lower(); 450 AtomicString loweredLocalName = localName.lower();
451 if (loweredLocalName != localName) 451 if (loweredLocalName != localName)
452 map->add(loweredLocalName, name); 452 map->insert(loweredLocalName, name);
453 } 453 }
454 } 454 }
455 455
456 static void adjustSVGTagNameCase(AtomicHTMLToken* token) { 456 static void adjustSVGTagNameCase(AtomicHTMLToken* token) {
457 static PrefixedNameToQualifiedNameMap* caseMap = 0; 457 static PrefixedNameToQualifiedNameMap* caseMap = 0;
458 if (!caseMap) { 458 if (!caseMap) {
459 caseMap = new PrefixedNameToQualifiedNameMap; 459 caseMap = new PrefixedNameToQualifiedNameMap;
460 std::unique_ptr<const SVGQualifiedName* []> svgTags = 460 std::unique_ptr<const SVGQualifiedName* []> svgTags =
461 SVGNames::getSVGTags(); 461 SVGNames::getSVGTags();
462 mapLoweredLocalNameToName(caseMap, svgTags.get(), SVGNames::SVGTagsCount); 462 mapLoweredLocalNameToName(caseMap, svgTags.get(), SVGNames::SVGTagsCount);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 495
496 static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map, 496 static void addNamesWithPrefix(PrefixedNameToQualifiedNameMap* map,
497 const AtomicString& prefix, 497 const AtomicString& prefix,
498 const QualifiedName* const* names, 498 const QualifiedName* const* names,
499 size_t length) { 499 size_t length) {
500 for (size_t i = 0; i < length; ++i) { 500 for (size_t i = 0; i < length; ++i) {
501 const QualifiedName* name = names[i]; 501 const QualifiedName* name = names[i];
502 const AtomicString& localName = name->localName(); 502 const AtomicString& localName = name->localName();
503 AtomicString prefixColonLocalName = prefix + ':' + localName; 503 AtomicString prefixColonLocalName = prefix + ':' + localName;
504 QualifiedName nameWithPrefix(prefix, localName, name->namespaceURI()); 504 QualifiedName nameWithPrefix(prefix, localName, name->namespaceURI());
505 map->add(prefixColonLocalName, nameWithPrefix); 505 map->insert(prefixColonLocalName, nameWithPrefix);
506 } 506 }
507 } 507 }
508 508
509 static void adjustForeignAttributes(AtomicHTMLToken* token) { 509 static void adjustForeignAttributes(AtomicHTMLToken* token) {
510 static PrefixedNameToQualifiedNameMap* map = 0; 510 static PrefixedNameToQualifiedNameMap* map = 0;
511 if (!map) { 511 if (!map) {
512 map = new PrefixedNameToQualifiedNameMap; 512 map = new PrefixedNameToQualifiedNameMap;
513 513
514 std::unique_ptr<const QualifiedName* []> attrs = 514 std::unique_ptr<const QualifiedName* []> attrs =
515 XLinkNames::getXLinkAttrs(); 515 XLinkNames::getXLinkAttrs();
516 addNamesWithPrefix(map, xlinkAtom, attrs.get(), 516 addNamesWithPrefix(map, xlinkAtom, attrs.get(),
517 XLinkNames::XLinkAttrsCount); 517 XLinkNames::XLinkAttrsCount);
518 518
519 std::unique_ptr<const QualifiedName* []> xmlAttrs = XMLNames::getXMLAttrs(); 519 std::unique_ptr<const QualifiedName* []> xmlAttrs = XMLNames::getXMLAttrs();
520 addNamesWithPrefix(map, xmlAtom, xmlAttrs.get(), XMLNames::XMLAttrsCount); 520 addNamesWithPrefix(map, xmlAtom, xmlAttrs.get(), XMLNames::XMLAttrsCount);
521 521
522 map->add(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr); 522 map->insert(WTF::xmlnsAtom, XMLNSNames::xmlnsAttr);
523 map->add("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom, 523 map->insert("xmlns:xlink", QualifiedName(xmlnsAtom, xlinkAtom,
524 XMLNSNames::xmlnsNamespaceURI)); 524 XMLNSNames::xmlnsNamespaceURI));
525 } 525 }
526 526
527 for (unsigned i = 0; i < token->attributes().size(); ++i) { 527 for (unsigned i = 0; i < token->attributes().size(); ++i) {
528 Attribute& tokenAttribute = token->attributes().at(i); 528 Attribute& tokenAttribute = token->attributes().at(i);
529 const QualifiedName& name = map->get(tokenAttribute.localName()); 529 const QualifiedName& name = map->get(tokenAttribute.localName());
530 if (!name.localName().isNull()) 530 if (!name.localName().isNull())
531 tokenAttribute.parserSetName(name); 531 tokenAttribute.parserSetName(name);
532 } 532 }
533 } 533 }
534 534
(...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 DEFINE_STRINGIFY(AfterFramesetMode) 2755 DEFINE_STRINGIFY(AfterFramesetMode)
2756 DEFINE_STRINGIFY(AfterAfterBodyMode) 2756 DEFINE_STRINGIFY(AfterAfterBodyMode)
2757 DEFINE_STRINGIFY(AfterAfterFramesetMode) 2757 DEFINE_STRINGIFY(AfterAfterFramesetMode)
2758 #undef DEFINE_STRINGIFY 2758 #undef DEFINE_STRINGIFY
2759 } 2759 }
2760 return "<unknown>"; 2760 return "<unknown>";
2761 } 2761 }
2762 #endif 2762 #endif
2763 2763
2764 } // namespace blink 2764 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698