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

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

Issue 2390563002: Reflow comments in core/html/forms/. (Closed)
Patch Set: 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 element().updateView(); 152 element().updateView();
153 153
154 unsigned max = visibleValue().length(); 154 unsigned max = visibleValue().length();
155 element().setSelectionRange(max, max); 155 element().setSelectionRange(max, max);
156 156
157 if (!valueChanged) 157 if (!valueChanged)
158 return; 158 return;
159 159
160 switch (eventBehavior) { 160 switch (eventBehavior) {
161 case DispatchChangeEvent: 161 case DispatchChangeEvent:
162 // If the user is still editing this field, dispatch an input event rather than a change event. 162 // If the user is still editing this field, dispatch an input event rather
163 // The change event will be dispatched when editing finishes. 163 // than a change event. The change event will be dispatched when editing
164 // finishes.
164 if (element().focused()) 165 if (element().focused())
165 element().dispatchFormControlInputEvent(); 166 element().dispatchFormControlInputEvent();
166 else 167 else
167 element().dispatchFormControlChangeEvent(); 168 element().dispatchFormControlChangeEvent();
168 break; 169 break;
169 170
170 case DispatchInputAndChangeEvent: { 171 case DispatchInputAndChangeEvent: {
171 element().dispatchFormControlInputEvent(); 172 element().dispatchFormControlInputEvent();
172 element().dispatchFormControlChangeEvent(); 173 element().dispatchFormControlChangeEvent();
173 break; 174 break;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 427 }
427 DCHECK_GE(oldLength, selectionLength); 428 DCHECK_GE(oldLength, selectionLength);
428 429
429 // Selected characters will be removed by the next text event. 430 // Selected characters will be removed by the next text event.
430 unsigned baseLength = oldLength - selectionLength; 431 unsigned baseLength = oldLength - selectionLength;
431 unsigned maxLength = static_cast<unsigned>( 432 unsigned maxLength = static_cast<unsigned>(
432 this->maxLength()); // maxLength can never be negative. 433 this->maxLength()); // maxLength can never be negative.
433 unsigned appendableLength = 434 unsigned appendableLength =
434 maxLength > baseLength ? maxLength - baseLength : 0; 435 maxLength > baseLength ? maxLength - baseLength : 0;
435 436
436 // Truncate the inserted text to avoid violating the maxLength and other const raints. 437 // Truncate the inserted text to avoid violating the maxLength and other
438 // constraints.
437 String eventText = event->text(); 439 String eventText = event->text();
438 unsigned textLength = eventText.length(); 440 unsigned textLength = eventText.length();
439 while (textLength > 0 && isASCIILineBreak(eventText[textLength - 1])) 441 while (textLength > 0 && isASCIILineBreak(eventText[textLength - 1]))
440 textLength--; 442 textLength--;
441 eventText.truncate(textLength); 443 eventText.truncate(textLength);
442 eventText.replace("\r\n", " "); 444 eventText.replace("\r\n", " ");
443 eventText.replace('\r', ' '); 445 eventText.replace('\r', ' ');
444 eventText.replace('\n', ' '); 446 eventText.replace('\n', ' ');
445 447
446 event->setText(limitLength(eventText, appendableLength)); 448 event->setText(limitLength(eventText, appendableLength));
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 return shouldSpinButtonRespondToMouseEvents() && element().focused(); 549 return shouldSpinButtonRespondToMouseEvents() && element().focused();
548 } 550 }
549 551
550 void TextFieldInputType::spinButtonDidReleaseMouseCapture( 552 void TextFieldInputType::spinButtonDidReleaseMouseCapture(
551 SpinButtonElement::EventDispatch eventDispatch) { 553 SpinButtonElement::EventDispatch eventDispatch) {
552 if (eventDispatch == SpinButtonElement::EventDispatchAllowed) 554 if (eventDispatch == SpinButtonElement::EventDispatchAllowed)
553 element().dispatchFormControlChangeEvent(); 555 element().dispatchFormControlChangeEvent();
554 } 556 }
555 557
556 } // namespace blink 558 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698