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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLTextFormControlElement.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 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 210
211 void HTMLTextFormControlElement::setChangedSinceLastFormControlChangeEvent( 211 void HTMLTextFormControlElement::setChangedSinceLastFormControlChangeEvent(
212 bool changed) { 212 bool changed) {
213 m_wasChangedSinceLastFormControlChangeEvent = changed; 213 m_wasChangedSinceLastFormControlChangeEvent = changed;
214 } 214 }
215 215
216 void HTMLTextFormControlElement::setFocused(bool flag) { 216 void HTMLTextFormControlElement::setFocused(bool flag) {
217 HTMLFormControlElementWithState::setFocused(flag); 217 HTMLFormControlElementWithState::setFocused(flag);
218 218
219 if (!flag && wasChangedSinceLastFormControlChangeEvent()) 219 if (!flag) {
220 dispatchFormControlChangeEvent(); 220 if (wasChangedSinceLastFormControlChangeEvent()) {
221 dispatchFormControlChangeEvent();
222 } else {
223 // |value| IDL attribute setter haven't updated
224 // textAsOfLastFormControlChangeEvent while this is focused. So we
225 // synchronize now.
226 setTextAsOfLastFormControlChangeEvent(value());
227 }
228 }
221 } 229 }
222 230
223 bool HTMLTextFormControlElement::shouldDispatchFormControlChangeEvent( 231 bool HTMLTextFormControlElement::shouldDispatchFormControlChangeEvent(
224 String& oldValue, 232 String& oldValue,
225 String& newValue) { 233 String& newValue) {
226 return !equalIgnoringNullity(oldValue, newValue); 234 return !equalIgnoringNullity(oldValue, newValue);
227 } 235 }
228 236
229 void HTMLTextFormControlElement::dispatchFormControlChangeEvent() { 237 void HTMLTextFormControlElement::dispatchFormControlChangeEvent() {
230 String newValue = value(); 238 String newValue = value();
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1124
1117 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement( 1125 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(
1118 const Element& source) { 1126 const Element& source) {
1119 const HTMLTextFormControlElement& sourceElement = 1127 const HTMLTextFormControlElement& sourceElement =
1120 static_cast<const HTMLTextFormControlElement&>(source); 1128 static_cast<const HTMLTextFormControlElement&>(source);
1121 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; 1129 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit;
1122 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); 1130 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source);
1123 } 1131 }
1124 1132
1125 } // namespace blink 1133 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698