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

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

Issue 2556043002: Avoid WTF::Vector::at() and operator[] in core/html. (Closed)
Patch Set: _ Created 4 years 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 473 }
474 474
475 void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) { 475 void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) {
476 // To preserve comments, remove only the text nodes, then add a single text 476 // To preserve comments, remove only the text nodes, then add a single text
477 // node. 477 // node.
478 HeapVector<Member<Node>> textNodes; 478 HeapVector<Member<Node>> textNodes;
479 for (Node* n = firstChild(); n; n = n->nextSibling()) { 479 for (Node* n = firstChild(); n; n = n->nextSibling()) {
480 if (n->isTextNode()) 480 if (n->isTextNode())
481 textNodes.append(n); 481 textNodes.append(n);
482 } 482 }
483 size_t size = textNodes.size(); 483 for (const auto& text : textNodes)
484 for (size_t i = 0; i < size; ++i) 484 removeChild(text.get(), IGNORE_EXCEPTION);
485 removeChild(textNodes[i].get(), IGNORE_EXCEPTION);
486 485
487 // Normalize line endings. 486 // Normalize line endings.
488 String value = defaultValue; 487 String value = defaultValue;
489 value.replace("\r\n", "\n"); 488 value.replace("\r\n", "\n");
490 value.replace('\r', '\n'); 489 value.replace('\r', '\n');
491 490
492 insertBefore(document().createTextNode(value), firstChild(), 491 insertBefore(document().createTextNode(value), firstChild(),
493 IGNORE_EXCEPTION); 492 IGNORE_EXCEPTION);
494 493
495 if (!m_isDirty) 494 if (!m_isDirty)
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement( 648 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(
650 const Element& source) { 649 const Element& source) {
651 const HTMLTextAreaElement& sourceElement = 650 const HTMLTextAreaElement& sourceElement =
652 static_cast<const HTMLTextAreaElement&>(source); 651 static_cast<const HTMLTextAreaElement&>(source);
653 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); 652 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion);
654 m_isDirty = sourceElement.m_isDirty; 653 m_isDirty = sourceElement.m_isDirty;
655 TextControlElement::copyNonAttributePropertiesFromElement(source); 654 TextControlElement::copyNonAttributePropertiesFromElement(source);
656 } 655 }
657 656
658 } // namespace blink 657 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698