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

Side by Side Diff: Source/core/inspector/InspectorDOMAgent.cpp

Issue 337753005: Make iterator for Element's attributes more lightweight (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Proper rebase Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 717 }
718 718
719 String caseAdjustedName = name ? (shouldIgnoreCase ? name->lower() : *name) : String(); 719 String caseAdjustedName = name ? (shouldIgnoreCase ? name->lower() : *name) : String();
720 720
721 if (!parsedElement->hasAttributes() && name) { 721 if (!parsedElement->hasAttributes() && name) {
722 m_domEditor->removeAttribute(element, caseAdjustedName, errorString); 722 m_domEditor->removeAttribute(element, caseAdjustedName, errorString);
723 return; 723 return;
724 } 724 }
725 725
726 bool foundOriginalAttribute = false; 726 bool foundOriginalAttribute = false;
727 AttributeIteratorAccessor attributes = parsedElement->attributesIterator(); 727 AttributeCollection attributes = parsedElement->attributes();
728 AttributeConstIterator end = attributes.end(); 728 AttributeCollection::const_iterator end = attributes.end();
729 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 729 for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
730 // Add attribute pair 730 // Add attribute pair
731 String attributeName = it->name().toString(); 731 String attributeName = it->name().toString();
732 if (shouldIgnoreCase) 732 if (shouldIgnoreCase)
733 attributeName = attributeName.lower(); 733 attributeName = attributeName.lower();
734 foundOriginalAttribute |= name && attributeName == caseAdjustedName; 734 foundOriginalAttribute |= name && attributeName == caseAdjustedName;
735 if (!m_domEditor->setAttribute(element, attributeName, it->value(), erro rString)) 735 if (!m_domEditor->setAttribute(element, attributeName, it->value(), erro rString))
736 return; 736 return;
737 } 737 }
738 738
739 if (!foundOriginalAttribute && name && !name->stripWhiteSpace().isEmpty()) 739 if (!foundOriginalAttribute && name && !name->stripWhiteSpace().isEmpty())
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 || (startTagFound && !endTagFound && node->nodeName().starts With(tagNameQuery, false)) 977 || (startTagFound && !endTagFound && node->nodeName().starts With(tagNameQuery, false))
978 || (!startTagFound && endTagFound && node->nodeName().endsWi th(tagNameQuery, false))) { 978 || (!startTagFound && endTagFound && node->nodeName().endsWi th(tagNameQuery, false))) {
979 resultCollector.add(node); 979 resultCollector.add(node);
980 break; 980 break;
981 } 981 }
982 // Go through all attributes and serialize them. 982 // Go through all attributes and serialize them.
983 const Element* element = toElement(node); 983 const Element* element = toElement(node);
984 if (!element->hasAttributes()) 984 if (!element->hasAttributes())
985 break; 985 break;
986 986
987 AttributeIteratorAccessor attributes = element->attributesIterat or(); 987 AttributeCollection attributes = element->attributes();
988 AttributeConstIterator end = attributes.end(); 988 AttributeCollection::const_iterator end = attributes.end();
989 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 989 for (AttributeCollection::const_iterator it = attributes.begin() ; it != end; ++it) {
990 // Add attribute pair 990 // Add attribute pair
991 if (it->localName().find(whitespaceTrimmedQuery, 0, false) ! = kNotFound) { 991 if (it->localName().find(whitespaceTrimmedQuery, 0, false) ! = kNotFound) {
992 resultCollector.add(node); 992 resultCollector.add(node);
993 break; 993 break;
994 } 994 }
995 size_t foundPosition = it->value().find(attributeQuery, 0, f alse); 995 size_t foundPosition = it->value().find(attributeQuery, 0, f alse);
996 if (foundPosition != kNotFound) { 996 if (foundPosition != kNotFound) {
997 if (!exactAttributeMatch || (!foundPosition && it->value ().length() == attributeQuery.length())) { 997 if (!exactAttributeMatch || (!foundPosition && it->value ().length() == attributeQuery.length())) {
998 resultCollector.add(node); 998 resultCollector.add(node);
999 break; 999 break;
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 1593
1594 return value.release(); 1594 return value.release();
1595 } 1595 }
1596 1596
1597 PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA ttributes(Element* element) 1597 PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA ttributes(Element* element)
1598 { 1598 {
1599 RefPtr<TypeBuilder::Array<String> > attributesValue = TypeBuilder::Array<Str ing>::create(); 1599 RefPtr<TypeBuilder::Array<String> > attributesValue = TypeBuilder::Array<Str ing>::create();
1600 // Go through all attributes and serialize them. 1600 // Go through all attributes and serialize them.
1601 if (!element->hasAttributes()) 1601 if (!element->hasAttributes())
1602 return attributesValue.release(); 1602 return attributesValue.release();
1603 AttributeIteratorAccessor attributes = element->attributesIterator(); 1603 AttributeCollection attributes = element->attributes();
1604 AttributeConstIterator end = attributes.end(); 1604 AttributeCollection::const_iterator end = attributes.end();
1605 for (AttributeConstIterator it = attributes.begin(); it != end; ++it) { 1605 for (AttributeCollection::const_iterator it = attributes.begin(); it != end; ++it) {
1606 // Add attribute pair 1606 // Add attribute pair
1607 attributesValue->addItem(it->name().toString()); 1607 attributesValue->addItem(it->name().toString());
1608 attributesValue->addItem(it->value()); 1608 attributesValue->addItem(it->value());
1609 } 1609 }
1610 return attributesValue.release(); 1610 return attributesValue.release();
1611 } 1611 }
1612 1612
1613 PassRefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > InspectorDOMAgent::build ArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap) 1613 PassRefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > InspectorDOMAgent::build ArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap)
1614 { 1614 {
1615 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeBuilder:: Array<TypeBuilder::DOM::Node>::create(); 1615 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeBuilder:: Array<TypeBuilder::DOM::Node>::create();
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 if (!m_documentNodeToIdMap->contains(m_document.get())) { 2098 if (!m_documentNodeToIdMap->contains(m_document.get())) {
2099 RefPtr<TypeBuilder::DOM::Node> root; 2099 RefPtr<TypeBuilder::DOM::Node> root;
2100 getDocument(errorString, root); 2100 getDocument(errorString, root);
2101 return errorString->isEmpty(); 2101 return errorString->isEmpty();
2102 } 2102 }
2103 return true; 2103 return true;
2104 } 2104 }
2105 2105
2106 } // namespace WebCore 2106 } // namespace WebCore
2107 2107
OLDNEW
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/page/PageSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698