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

Side by Side Diff: Source/core/html/HTMLTextFormControlElement.cpp

Issue 1119663002: Making Unicode character names consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code changes to correct Test Expectation Created 5 years, 7 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) 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 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (event->type() == EventTypeNames::blur || event->type() == EventTypeNames ::focus) 112 if (event->type() == EventTypeNames::blur || event->type() == EventTypeNames ::focus)
113 return; 113 return;
114 innerEditorElement()->defaultEventHandler(event); 114 innerEditorElement()->defaultEventHandler(event);
115 } 115 }
116 116
117 String HTMLTextFormControlElement::strippedPlaceholder() const 117 String HTMLTextFormControlElement::strippedPlaceholder() const
118 { 118 {
119 // According to the HTML5 specification, we need to remove CR and LF from 119 // According to the HTML5 specification, we need to remove CR and LF from
120 // the attribute value. 120 // the attribute value.
121 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr); 121 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr);
122 if (!attributeValue.contains(newlineCharacter) && !attributeValue.contains(c arriageReturn)) 122 if (!attributeValue.contains(characterNewline) && !attributeValue.contains(c haracterCarriageReturn))
123 return attributeValue; 123 return attributeValue;
124 124
125 StringBuilder stripped; 125 StringBuilder stripped;
126 unsigned length = attributeValue.length(); 126 unsigned length = attributeValue.length();
127 stripped.reserveCapacity(length); 127 stripped.reserveCapacity(length);
128 for (unsigned i = 0; i < length; ++i) { 128 for (unsigned i = 0; i < length; ++i) {
129 UChar character = attributeValue[i]; 129 UChar character = attributeValue[i];
130 if (character == newlineCharacter || character == carriageReturn) 130 if (character == characterNewline || character == characterCarriageRetur n)
131 continue; 131 continue;
132 stripped.append(character); 132 stripped.append(character);
133 } 133 }
134 return stripped.toString(); 134 return stripped.toString();
135 } 135 }
136 136
137 static bool isNotLineBreak(UChar ch) { return ch != newlineCharacter && ch != ca rriageReturn; } 137 static bool isNotLineBreak(UChar ch) { return ch != characterNewline && ch != ch aracterCarriageReturn; }
138 138
139 bool HTMLTextFormControlElement::isPlaceholderEmpty() const 139 bool HTMLTextFormControlElement::isPlaceholderEmpty() const
140 { 140 {
141 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr); 141 const AtomicString& attributeValue = fastGetAttribute(placeholderAttr);
142 return attributeValue.string().find(isNotLineBreak) == kNotFound; 142 return attributeValue.string().find(isNotLineBreak) == kNotFound;
143 } 143 }
144 144
145 bool HTMLTextFormControlElement::placeholderShouldBeVisible() const 145 bool HTMLTextFormControlElement::placeholderShouldBeVisible() const
146 { 146 {
147 return supportsPlaceholder() 147 return supportsPlaceholder()
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 String HTMLTextFormControlElement::innerEditorValue() const 651 String HTMLTextFormControlElement::innerEditorValue() const
652 { 652 {
653 ASSERT(!hasOpenShadowRoot()); 653 ASSERT(!hasOpenShadowRoot());
654 HTMLElement* innerEditor = innerEditorElement(); 654 HTMLElement* innerEditor = innerEditorElement();
655 if (!innerEditor || !isTextFormControl()) 655 if (!innerEditor || !isTextFormControl())
656 return emptyString(); 656 return emptyString();
657 657
658 StringBuilder result; 658 StringBuilder result;
659 for (Node& node : NodeTraversal::inclusiveDescendantsOf(*innerEditor)) { 659 for (Node& node : NodeTraversal::inclusiveDescendantsOf(*innerEditor)) {
660 if (isHTMLBRElement(node)) 660 if (isHTMLBRElement(node))
661 result.append(newlineCharacter); 661 result.append(characterNewline);
662 else if (node.isTextNode()) 662 else if (node.isTextNode())
663 result.append(toText(node).data()); 663 result.append(toText(node).data());
664 } 664 }
665 return finishText(result); 665 return finishText(result);
666 } 666 }
667 667
668 static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& b reakOffset) 668 static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& b reakOffset)
669 { 669 {
670 RootInlineBox* next; 670 RootInlineBox* next;
671 for (; line; line = next) { 671 for (; line; line = next) {
(...skipping 26 matching lines...) Expand all
698 unsigned breakOffset; 698 unsigned breakOffset;
699 RootInlineBox* line = layoutObject->firstRootBox(); 699 RootInlineBox* line = layoutObject->firstRootBox();
700 if (!line) 700 if (!line)
701 return value(); 701 return value();
702 702
703 getNextSoftBreak(line, breakNode, breakOffset); 703 getNextSoftBreak(line, breakNode, breakOffset);
704 704
705 StringBuilder result; 705 StringBuilder result;
706 for (Node& node : NodeTraversal::descendantsOf(*innerText)) { 706 for (Node& node : NodeTraversal::descendantsOf(*innerText)) {
707 if (isHTMLBRElement(node)) { 707 if (isHTMLBRElement(node)) {
708 result.append(newlineCharacter); 708 result.append(characterNewline);
709 } else if (node.isTextNode()) { 709 } else if (node.isTextNode()) {
710 String data = toText(node).data(); 710 String data = toText(node).data();
711 unsigned length = data.length(); 711 unsigned length = data.length();
712 unsigned position = 0; 712 unsigned position = 0;
713 while (breakNode == node && breakOffset <= length) { 713 while (breakNode == node && breakOffset <= length) {
714 if (breakOffset > position) { 714 if (breakOffset > position) {
715 result.append(data, position, breakOffset - position); 715 result.append(data, position, breakOffset - position);
716 position = breakOffset; 716 position = breakOffset;
717 result.append(newlineCharacter); 717 result.append(characterNewline);
718 } 718 }
719 getNextSoftBreak(line, breakNode, breakOffset); 719 getNextSoftBreak(line, breakNode, breakOffset);
720 } 720 }
721 result.append(data, position, length - position); 721 result.append(data, position, length - position);
722 } 722 }
723 while (breakNode == node) 723 while (breakNode == node)
724 getNextSoftBreak(line, breakNode, breakOffset); 724 getNextSoftBreak(line, breakNode, breakOffset);
725 } 725 }
726 return finishText(result); 726 return finishText(result);
727 } 727 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 } 1007 }
1008 1008
1009 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) 1009 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source)
1010 { 1010 {
1011 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); 1011 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source);
1012 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; 1012 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit;
1013 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); 1013 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source);
1014 } 1014 }
1015 1015
1016 } // namespace blink 1016 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698