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

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

Issue 180723006: Have ElementData::attributeItem() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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 if (!parsedElement->hasAttributes() && name) { 718 if (!parsedElement->hasAttributes() && name) {
719 m_domEditor->removeAttribute(element, caseAdjustedName, errorString); 719 m_domEditor->removeAttribute(element, caseAdjustedName, errorString);
720 return; 720 return;
721 } 721 }
722 722
723 bool foundOriginalAttribute = false; 723 bool foundOriginalAttribute = false;
724 unsigned numAttrs = parsedElement->attributeCount(); 724 unsigned numAttrs = parsedElement->attributeCount();
725 for (unsigned i = 0; i < numAttrs; ++i) { 725 for (unsigned i = 0; i < numAttrs; ++i) {
726 // Add attribute pair 726 // Add attribute pair
727 const Attribute* attribute = parsedElement->attributeItem(i); 727 const Attribute& attribute = parsedElement->attributeItem(i);
728 String attributeName = attribute->name().toString(); 728 String attributeName = attribute.name().toString();
729 if (shouldIgnoreCase) 729 if (shouldIgnoreCase)
730 attributeName = attributeName.lower(); 730 attributeName = attributeName.lower();
731 foundOriginalAttribute |= name && attributeName == caseAdjustedName; 731 foundOriginalAttribute |= name && attributeName == caseAdjustedName;
732 if (!m_domEditor->setAttribute(element, attributeName, attribute->value( ), errorString)) 732 if (!m_domEditor->setAttribute(element, attributeName, attribute.value() , errorString))
733 return; 733 return;
734 } 734 }
735 735
736 if (!foundOriginalAttribute && name && !name->stripWhiteSpace().isEmpty()) 736 if (!foundOriginalAttribute && name && !name->stripWhiteSpace().isEmpty())
737 m_domEditor->removeAttribute(element, caseAdjustedName, errorString); 737 m_domEditor->removeAttribute(element, caseAdjustedName, errorString);
738 } 738 }
739 739
740 void InspectorDOMAgent::removeAttribute(ErrorString* errorString, int elementId, const String& name) 740 void InspectorDOMAgent::removeAttribute(ErrorString* errorString, int elementId, const String& name)
741 { 741 {
742 Element* element = assertEditableElement(errorString, elementId); 742 Element* element = assertEditableElement(errorString, elementId);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 break; 977 break;
978 } 978 }
979 // Go through all attributes and serialize them. 979 // Go through all attributes and serialize them.
980 const Element* element = toElement(node); 980 const Element* element = toElement(node);
981 if (!element->hasAttributes()) 981 if (!element->hasAttributes())
982 break; 982 break;
983 983
984 unsigned numAttrs = element->attributeCount(); 984 unsigned numAttrs = element->attributeCount();
985 for (unsigned i = 0; i < numAttrs; ++i) { 985 for (unsigned i = 0; i < numAttrs; ++i) {
986 // Add attribute pair 986 // Add attribute pair
987 const Attribute* attribute = element->attributeItem(i); 987 const Attribute& attribute = element->attributeItem(i);
988 if (attribute->localName().find(whitespaceTrimmedQuery, 0, f alse) != kNotFound) { 988 if (attribute.localName().find(whitespaceTrimmedQuery, 0, fa lse) != kNotFound) {
989 resultCollector.add(node); 989 resultCollector.add(node);
990 break; 990 break;
991 } 991 }
992 size_t foundPosition = attribute->value().find(attributeQuer y, 0, false); 992 size_t foundPosition = attribute.value().find(attributeQuery , 0, false);
993 if (foundPosition != kNotFound) { 993 if (foundPosition != kNotFound) {
994 if (!exactAttributeMatch || (!foundPosition && attribute ->value().length() == attributeQuery.length())) { 994 if (!exactAttributeMatch || (!foundPosition && attribute .value().length() == attributeQuery.length())) {
995 resultCollector.add(node); 995 resultCollector.add(node);
996 break; 996 break;
997 } 997 }
998 } 998 }
999 } 999 }
1000 break; 1000 break;
1001 } 1001 }
1002 default: 1002 default:
1003 break; 1003 break;
1004 } 1004 }
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 1573
1574 PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA ttributes(Element* element) 1574 PassRefPtr<TypeBuilder::Array<String> > InspectorDOMAgent::buildArrayForElementA ttributes(Element* element)
1575 { 1575 {
1576 RefPtr<TypeBuilder::Array<String> > attributesValue = TypeBuilder::Array<Str ing>::create(); 1576 RefPtr<TypeBuilder::Array<String> > attributesValue = TypeBuilder::Array<Str ing>::create();
1577 // Go through all attributes and serialize them. 1577 // Go through all attributes and serialize them.
1578 if (!element->hasAttributes()) 1578 if (!element->hasAttributes())
1579 return attributesValue.release(); 1579 return attributesValue.release();
1580 unsigned numAttrs = element->attributeCount(); 1580 unsigned numAttrs = element->attributeCount();
1581 for (unsigned i = 0; i < numAttrs; ++i) { 1581 for (unsigned i = 0; i < numAttrs; ++i) {
1582 // Add attribute pair 1582 // Add attribute pair
1583 const Attribute* attribute = element->attributeItem(i); 1583 const Attribute& attribute = element->attributeItem(i);
1584 attributesValue->addItem(attribute->name().toString()); 1584 attributesValue->addItem(attribute.name().toString());
1585 attributesValue->addItem(attribute->value()); 1585 attributesValue->addItem(attribute.value());
1586 } 1586 }
1587 return attributesValue.release(); 1587 return attributesValue.release();
1588 } 1588 }
1589 1589
1590 PassRefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > InspectorDOMAgent::build ArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap) 1590 PassRefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > InspectorDOMAgent::build ArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap)
1591 { 1591 {
1592 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeBuilder:: Array<TypeBuilder::DOM::Node>::create(); 1592 RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node> > children = TypeBuilder:: Array<TypeBuilder::DOM::Node>::create();
1593 if (depth == 0) { 1593 if (depth == 0) {
1594 // Special-case the only text child - pretend that container's children have been requested. 1594 // Special-case the only text child - pretend that container's children have been requested.
1595 Node* firstChild = container->firstChild(); 1595 Node* firstChild = container->firstChild();
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 if (!m_documentNodeToIdMap.contains(m_document)) { 2051 if (!m_documentNodeToIdMap.contains(m_document)) {
2052 RefPtr<TypeBuilder::DOM::Node> root; 2052 RefPtr<TypeBuilder::DOM::Node> root;
2053 getDocument(errorString, root); 2053 getDocument(errorString, root);
2054 return errorString->isEmpty(); 2054 return errorString->isEmpty();
2055 } 2055 }
2056 return true; 2056 return true;
2057 } 2057 }
2058 2058
2059 } // namespace WebCore 2059 } // namespace WebCore
2060 2060
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