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

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

Issue 2258033002: Replace ASSERT()s with DCHECK*() in core/html/*.{cpp,h}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace ASSERT()s with DCHECK*() in core/html/*.{cpp,h}. Created 4 years, 4 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 reserv ed.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 void HTMLTextAreaElement::handleFocusEvent(Element*, WebFocusType) 271 void HTMLTextAreaElement::handleFocusEvent(Element*, WebFocusType)
272 { 272 {
273 if (LocalFrame* frame = document().frame()) 273 if (LocalFrame* frame = document().frame())
274 frame->spellChecker().didBeginEditing(this); 274 frame->spellChecker().didBeginEditing(this);
275 } 275 }
276 276
277 void HTMLTextAreaElement::subtreeHasChanged() 277 void HTMLTextAreaElement::subtreeHasChanged()
278 { 278 {
279 #if ENABLE(ASSERT) 279 #if DCHECK_IS_ON()
280 // The innerEditor should have either Text nodes or a placeholder break 280 // The innerEditor should have either Text nodes or a placeholder break
281 // element. If we see other nodes, it's a bug in editing code and we should 281 // element. If we see other nodes, it's a bug in editing code and we should
282 // fix it. 282 // fix it.
283 Element* innerEditor = innerEditorElement(); 283 Element* innerEditor = innerEditorElement();
284 for (Node& node : NodeTraversal::descendantsOf(*innerEditor)) { 284 for (Node& node : NodeTraversal::descendantsOf(*innerEditor)) {
285 if (node.isTextNode()) 285 if (node.isTextNode())
286 continue; 286 continue;
287 ASSERT(isHTMLBRElement(node)); 287 DCHECK(isHTMLBRElement(node));
288 ASSERT(&node == innerEditor->lastChild()); 288 DCHECK_EQ(&node, innerEditor->lastChild());
289 } 289 }
290 #endif 290 #endif
291 addPlaceholderBreakElementIfNecessary(); 291 addPlaceholderBreakElementIfNecessary();
292 setChangedSinceLastFormControlChangeEvent(true); 292 setChangedSinceLastFormControlChangeEvent(true);
293 m_valueIsUpToDate = false; 293 m_valueIsUpToDate = false;
294 setNeedsValidityCheck(); 294 setNeedsValidityCheck();
295 setAutofilled(false); 295 setAutofilled(false);
296 updatePlaceholderVisibility(); 296 updatePlaceholderVisibility();
297 297
298 if (!focused()) 298 if (!focused())
299 return; 299 return;
300 300
301 // When typing in a textarea, childrenChanged is not called, so we need to f orce the directionality check. 301 // When typing in a textarea, childrenChanged is not called, so we need to f orce the directionality check.
302 calculateAndAdjustDirectionality(); 302 calculateAndAdjustDirectionality();
303 303
304 ASSERT(document().isActive()); 304 DCHECK(document().isActive());
305 document().frameHost()->chromeClient().didChangeValueInTextField(*this); 305 document().frameHost()->chromeClient().didChangeValueInTextField(*this);
306 } 306 }
307 307
308 void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) const 308 void HTMLTextAreaElement::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event) const
309 { 309 {
310 ASSERT(event); 310 DCHECK(event);
311 ASSERT(layoutObject()); 311 DCHECK(layoutObject());
312 int signedMaxLength = maxLength(); 312 int signedMaxLength = maxLength();
313 if (signedMaxLength < 0) 313 if (signedMaxLength < 0)
314 return; 314 return;
315 unsigned unsignedMaxLength = static_cast<unsigned>(signedMaxLength); 315 unsigned unsignedMaxLength = static_cast<unsigned>(signedMaxLength);
316 316
317 const String& currentValue = innerEditorValue(); 317 const String& currentValue = innerEditorValue();
318 unsigned currentLength = computeLengthForSubmission(currentValue); 318 unsigned currentLength = computeLengthForSubmission(currentValue);
319 if (currentLength + computeLengthForSubmission(event->text()) < unsignedMaxL ength) 319 if (currentLength + computeLengthForSubmission(event->text()) < unsignedMaxL ength)
320 return; 320 return;
321 321
322 // selectionLength represents the selection length of this text field to be 322 // selectionLength represents the selection length of this text field to be
323 // removed by this insertion. 323 // removed by this insertion.
324 // If the text field has no focus, we don't need to take account of the 324 // If the text field has no focus, we don't need to take account of the
325 // selection length. The selection is the source of text drag-and-drop in 325 // selection length. The selection is the source of text drag-and-drop in
326 // that case, and nothing in the text field will be removed. 326 // that case, and nothing in the text field will be removed.
327 unsigned selectionLength = 0; 327 unsigned selectionLength = 0;
328 if (focused()) { 328 if (focused()) {
329 selectionLength = computeLengthForSubmission(document().frame()->selecti on().selectedText()); 329 selectionLength = computeLengthForSubmission(document().frame()->selecti on().selectedText());
330 } 330 }
331 ASSERT(currentLength >= selectionLength); 331 DCHECK_GE(currentLength, selectionLength);
332 unsigned baseLength = currentLength - selectionLength; 332 unsigned baseLength = currentLength - selectionLength;
333 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLeng th - baseLength : 0; 333 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLeng th - baseLength : 0;
334 event->setText(sanitizeUserInputValue(event->text(), appendableLength)); 334 event->setText(sanitizeUserInputValue(event->text(), appendableLength));
335 } 335 }
336 336
337 String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue, unsigned maxLength) 337 String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue, unsigned maxLength)
338 { 338 {
339 unsigned submissionLength = 0; 339 unsigned submissionLength = 0;
340 unsigned i = 0; 340 unsigned i = 0;
341 for (; i < proposedValue.length(); ++i) { 341 for (; i < proposedValue.length(); ++i) {
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 673
674 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s ource) 674 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s ource)
675 { 675 {
676 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle ment&>(source); 676 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle ment&>(source);
677 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); 677 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion);
678 m_isDirty = sourceElement.m_isDirty; 678 m_isDirty = sourceElement.m_isDirty;
679 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); 679 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source);
680 } 680 }
681 681
682 } // namespace blink 682 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698