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

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

Issue 2467263002: INPUT/TEXTAREA elements: Dispatch 'change' event even if a user-edit value is overwritten by JS (Closed)
Patch Set: Created 4 years, 1 month 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 StyleChangeReason::ControlValue)); 428 StyleChangeReason::ControlValue));
429 m_suggestedValue = String(); 429 m_suggestedValue = String();
430 setNeedsValidityCheck(); 430 setNeedsValidityCheck();
431 if (isFinishedParsingChildren()) { 431 if (isFinishedParsingChildren()) {
432 // Set the caret to the end of the text value except for initialize. 432 // Set the caret to the end of the text value except for initialize.
433 unsigned endOfString = m_value.length(); 433 unsigned endOfString = m_value.length();
434 setSelectionRange(endOfString, endOfString); 434 setSelectionRange(endOfString, endOfString);
435 } 435 }
436 436
437 notifyFormStateChanged(); 437 notifyFormStateChanged();
438 if (eventBehavior == DispatchNoEvent) { 438 switch (eventBehavior) {
439 setTextAsOfLastFormControlChangeEvent(normalizedValue); 439 case DispatchChangeEvent:
440 } else { 440 dispatchFormControlChangeEvent();
441 if (eventBehavior == DispatchInputAndChangeEvent) 441 break;
442
443 case DispatchInputAndChangeEvent:
442 dispatchFormControlInputEvent(); 444 dispatchFormControlInputEvent();
443 dispatchFormControlChangeEvent(); 445 dispatchFormControlChangeEvent();
446 break;
447
448 case DispatchNoEvent:
449 // We need to update textAsOfLastFormControlChangeEvent for |value| IDL
450 // setter without focus because input-assist features use setValue("...",
451 // DispatchChangeEvent) without setting focus.
452 if (!isFocused())
453 setTextAsOfLastFormControlChangeEvent(normalizedValue);
454 break;
444 } 455 }
445 } 456 }
446 457
447 void HTMLTextAreaElement::setInnerEditorValue(const String& value) { 458 void HTMLTextAreaElement::setInnerEditorValue(const String& value) {
448 HTMLTextFormControlElement::setInnerEditorValue(value); 459 HTMLTextFormControlElement::setInnerEditorValue(value);
449 m_valueIsUpToDate = true; 460 m_valueIsUpToDate = true;
450 } 461 }
451 462
452 String HTMLTextAreaElement::defaultValue() const { 463 String HTMLTextAreaElement::defaultValue() const {
453 StringBuilder value; 464 StringBuilder value;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement( 693 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(
683 const Element& source) { 694 const Element& source) {
684 const HTMLTextAreaElement& sourceElement = 695 const HTMLTextAreaElement& sourceElement =
685 static_cast<const HTMLTextAreaElement&>(source); 696 static_cast<const HTMLTextAreaElement&>(source);
686 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); 697 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion);
687 m_isDirty = sourceElement.m_isDirty; 698 m_isDirty = sourceElement.m_isDirty;
688 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); 699 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source);
689 } 700 }
690 701
691 } // namespace blink 702 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698