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

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

Issue 2384273007: reflow comments in core/html/*.{cpp,h},core/html/imports (Closed)
Patch Set: comments Created 4 years, 2 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, 2008, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights
6 * reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 8 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
8 * 9 *
9 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 11 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either 12 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version. 13 * version 2 of the License, or (at your option) any later version.
13 * 14 *
14 * This library is distributed in the hope that it will be useful, 15 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, cols) || 170 if (value.isEmpty() || !parseHTMLNonNegativeInteger(value, cols) ||
170 cols <= 0) 171 cols <= 0)
171 cols = defaultCols; 172 cols = defaultCols;
172 if (m_cols != cols) { 173 if (m_cols != cols) {
173 m_cols = cols; 174 m_cols = cols;
174 if (LayoutObject* layoutObject = this->layoutObject()) 175 if (LayoutObject* layoutObject = this->layoutObject())
175 layoutObject->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( 176 layoutObject->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
176 LayoutInvalidationReason::AttributeChanged); 177 LayoutInvalidationReason::AttributeChanged);
177 } 178 }
178 } else if (name == wrapAttr) { 179 } else if (name == wrapAttr) {
179 // The virtual/physical values were a Netscape extension of HTML 3.0, now de precated. 180 // The virtual/physical values were a Netscape extension of HTML 3.0, now
180 // The soft/hard /off values are a recommendation for HTML 4 extension by IE and NS 4. 181 // deprecated. The soft/hard /off values are a recommendation for HTML 4
182 // extension by IE and NS 4.
181 WrapMethod wrap; 183 WrapMethod wrap;
182 if (equalIgnoringCase(value, "physical") || 184 if (equalIgnoringCase(value, "physical") ||
183 equalIgnoringCase(value, "hard") || equalIgnoringCase(value, "on")) 185 equalIgnoringCase(value, "hard") || equalIgnoringCase(value, "on"))
184 wrap = HardWrap; 186 wrap = HardWrap;
185 else if (equalIgnoringCase(value, "off")) 187 else if (equalIgnoringCase(value, "off"))
186 wrap = NoWrap; 188 wrap = NoWrap;
187 else 189 else
188 wrap = SoftWrap; 190 wrap = SoftWrap;
189 if (wrap != m_wrap) { 191 if (wrap != m_wrap) {
190 m_wrap = wrap; 192 m_wrap = wrap;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 228
227 void HTMLTextAreaElement::resetImpl() { 229 void HTMLTextAreaElement::resetImpl() {
228 setNonDirtyValue(defaultValue()); 230 setNonDirtyValue(defaultValue());
229 } 231 }
230 232
231 bool HTMLTextAreaElement::hasCustomFocusLogic() const { 233 bool HTMLTextAreaElement::hasCustomFocusLogic() const {
232 return true; 234 return true;
233 } 235 }
234 236
235 bool HTMLTextAreaElement::isKeyboardFocusable() const { 237 bool HTMLTextAreaElement::isKeyboardFocusable() const {
236 // If a given text area can be focused at all, then it will always be keyboard focusable. 238 // If a given text area can be focused at all, then it will always be keyboard
239 // focusable.
237 return isFocusable(); 240 return isFocusable();
238 } 241 }
239 242
240 bool HTMLTextAreaElement::shouldShowFocusRingOnMouseFocus() const { 243 bool HTMLTextAreaElement::shouldShowFocusRingOnMouseFocus() const {
241 return true; 244 return true;
242 } 245 }
243 246
244 void HTMLTextAreaElement::updateFocusAppearance( 247 void HTMLTextAreaElement::updateFocusAppearance(
245 SelectionBehaviorOnFocus selectionBehavior) { 248 SelectionBehaviorOnFocus selectionBehavior) {
246 switch (selectionBehavior) { 249 switch (selectionBehavior) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 addPlaceholderBreakElementIfNecessary(); 295 addPlaceholderBreakElementIfNecessary();
293 setChangedSinceLastFormControlChangeEvent(true); 296 setChangedSinceLastFormControlChangeEvent(true);
294 m_valueIsUpToDate = false; 297 m_valueIsUpToDate = false;
295 setNeedsValidityCheck(); 298 setNeedsValidityCheck();
296 setAutofilled(false); 299 setAutofilled(false);
297 updatePlaceholderVisibility(); 300 updatePlaceholderVisibility();
298 301
299 if (!isFocused()) 302 if (!isFocused())
300 return; 303 return;
301 304
302 // When typing in a textarea, childrenChanged is not called, so we need to for ce the directionality check. 305 // When typing in a textarea, childrenChanged is not called, so we need to
306 // force the directionality check.
303 calculateAndAdjustDirectionality(); 307 calculateAndAdjustDirectionality();
304 308
305 DCHECK(document().isActive()); 309 DCHECK(document().isActive());
306 document().frameHost()->chromeClient().didChangeValueInTextField(*this); 310 document().frameHost()->chromeClient().didChangeValueInTextField(*this);
307 } 311 }
308 312
309 void HTMLTextAreaElement::handleBeforeTextInsertedEvent( 313 void HTMLTextAreaElement::handleBeforeTextInsertedEvent(
310 BeforeTextInsertedEvent* event) const { 314 BeforeTextInsertedEvent* event) const {
311 DCHECK(event); 315 DCHECK(event);
312 DCHECK(layoutObject()); 316 DCHECK(layoutObject());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 395 }
392 396
393 void HTMLTextAreaElement::setNonDirtyValue(const String& value) { 397 void HTMLTextAreaElement::setNonDirtyValue(const String& value) {
394 setValueCommon(value, DispatchNoEvent, SetSeletion); 398 setValueCommon(value, DispatchNoEvent, SetSeletion);
395 m_isDirty = false; 399 m_isDirty = false;
396 } 400 }
397 401
398 void HTMLTextAreaElement::setValueCommon(const String& newValue, 402 void HTMLTextAreaElement::setValueCommon(const String& newValue,
399 TextFieldEventBehavior eventBehavior, 403 TextFieldEventBehavior eventBehavior,
400 SetValueCommonOption setValueOption) { 404 SetValueCommonOption setValueOption) {
401 // Code elsewhere normalizes line endings added by the user via the keyboard o r pasting. 405 // Code elsewhere normalizes line endings added by the user via the keyboard
402 // We normalize line endings coming from JavaScript here. 406 // or pasting. We normalize line endings coming from JavaScript here.
403 String normalizedValue = newValue.isNull() ? "" : newValue; 407 String normalizedValue = newValue.isNull() ? "" : newValue;
404 normalizedValue.replace("\r\n", "\n"); 408 normalizedValue.replace("\r\n", "\n");
405 normalizedValue.replace('\r', '\n'); 409 normalizedValue.replace('\r', '\n');
406 410
407 // Return early because we don't want to trigger other side effects 411 // Return early because we don't want to trigger other side effects
408 // when the value isn't changing. 412 // when the value isn't changing.
409 // FIXME: Simple early return doesn't match the Firefox ever. 413 // FIXME: Simple early return doesn't match the Firefox ever.
410 // Remove these lines. 414 // Remove these lines.
411 if (normalizedValue == value()) { 415 if (normalizedValue == value()) {
412 if (setValueOption == SetSeletion) { 416 if (setValueOption == SetSeletion) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // Since there may be comments, ignore nodes other than text nodes. 460 // Since there may be comments, ignore nodes other than text nodes.
457 for (Node* n = firstChild(); n; n = n->nextSibling()) { 461 for (Node* n = firstChild(); n; n = n->nextSibling()) {
458 if (n->isTextNode()) 462 if (n->isTextNode())
459 value.append(toText(n)->data()); 463 value.append(toText(n)->data());
460 } 464 }
461 465
462 return value.toString(); 466 return value.toString();
463 } 467 }
464 468
465 void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) { 469 void HTMLTextAreaElement::setDefaultValue(const String& defaultValue) {
466 // To preserve comments, remove only the text nodes, then add a single text no de. 470 // To preserve comments, remove only the text nodes, then add a single text
471 // node.
467 HeapVector<Member<Node>> textNodes; 472 HeapVector<Member<Node>> textNodes;
468 for (Node* n = firstChild(); n; n = n->nextSibling()) { 473 for (Node* n = firstChild(); n; n = n->nextSibling()) {
469 if (n->isTextNode()) 474 if (n->isTextNode())
470 textNodes.append(n); 475 textNodes.append(n);
471 } 476 }
472 size_t size = textNodes.size(); 477 size_t size = textNodes.size();
473 for (size_t i = 0; i < size; ++i) 478 for (size_t i = 0; i < size; ++i)
474 removeChild(textNodes[i].get(), IGNORE_EXCEPTION); 479 removeChild(textNodes[i].get(), IGNORE_EXCEPTION);
475 480
476 // Normalize line endings. 481 // Normalize line endings.
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement( 687 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(
683 const Element& source) { 688 const Element& source) {
684 const HTMLTextAreaElement& sourceElement = 689 const HTMLTextAreaElement& sourceElement =
685 static_cast<const HTMLTextAreaElement&>(source); 690 static_cast<const HTMLTextAreaElement&>(source);
686 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); 691 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion);
687 m_isDirty = sourceElement.m_isDirty; 692 m_isDirty = sourceElement.m_isDirty;
688 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); 693 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source);
689 } 694 }
690 695
691 } // namespace blink 696 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698