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

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

Issue 1955963002: [Autofill] Send events to fields being autofilled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 Node::InsertionNotificationRequest HTMLTextFormControlElement::insertedInto(Cont ainerNode* insertionPoint) 73 Node::InsertionNotificationRequest HTMLTextFormControlElement::insertedInto(Cont ainerNode* insertionPoint)
74 { 74 {
75 HTMLFormControlElementWithState::insertedInto(insertionPoint); 75 HTMLFormControlElementWithState::insertedInto(insertionPoint);
76 if (!insertionPoint->inShadowIncludingDocument()) 76 if (!insertionPoint->inShadowIncludingDocument())
77 return InsertionDone; 77 return InsertionDone;
78 String initialValue = value(); 78 String initialValue = value();
79 setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString() : initialValue); 79 setTextAsOfLastFormControlChangeEvent(initialValue.isNull() ? emptyString() : initialValue);
80 return InsertionDone; 80 return InsertionDone;
81 } 81 }
82 82
83 void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type, InputDeviceCapabilities* sourceCapabilities)
84 {
85 if (supportsPlaceholder())
86 updatePlaceholderVisibility();
87 handleFocusEvent(oldFocusedElement, type);
88 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type, sourceCapabilities);
89 }
90
91 void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, W ebFocusType type, InputDeviceCapabilities* sourceCapabilities)
92 {
93 if (supportsPlaceholder())
94 updatePlaceholderVisibility();
95 handleBlurEvent();
96 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type, sourceCapabilities);
97 }
98
99 void HTMLTextFormControlElement::defaultEventHandler(Event* event) 83 void HTMLTextFormControlElement::defaultEventHandler(Event* event)
100 { 84 {
101 if (event->type() == EventTypeNames::webkitEditableContentChanged && layoutO bject() && layoutObject()->isTextControl()) { 85 if (event->type() == EventTypeNames::webkitEditableContentChanged && layoutO bject() && layoutObject()->isTextControl()) {
102 m_lastChangeWasUserEdit = !document().isRunningExecCommand(); 86 m_lastChangeWasUserEdit = !document().isRunningExecCommand();
103 subtreeHasChanged(); 87 subtreeHasChanged();
104 return; 88 return;
105 } 89 }
106 90
107 HTMLFormControlElementWithState::defaultEventHandler(event); 91 HTMLFormControlElementWithState::defaultEventHandler(event);
108 } 92 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void HTMLTextFormControlElement::dispatchFormControlChangeEvent() 185 void HTMLTextFormControlElement::dispatchFormControlChangeEvent()
202 { 186 {
203 String newValue = value(); 187 String newValue = value();
204 if (shouldDispatchFormControlChangeEvent(m_textAsOfLastFormControlChangeEven t, newValue)) { 188 if (shouldDispatchFormControlChangeEvent(m_textAsOfLastFormControlChangeEven t, newValue)) {
205 setTextAsOfLastFormControlChangeEvent(newValue); 189 setTextAsOfLastFormControlChangeEvent(newValue);
206 dispatchChangeEvent(); 190 dispatchChangeEvent();
207 } 191 }
208 setChangedSinceLastFormControlChangeEvent(false); 192 setChangedSinceLastFormControlChangeEvent(false);
209 } 193 }
210 194
195 void HTMLTextFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, WebFocusType type, InputDeviceCapabilities* sourceCapabilities)
196 {
197 if (supportsPlaceholder())
198 updatePlaceholderVisibility();
199 handleFocusEvent(oldFocusedElement, type);
200 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type, sourceCapabilities);
201 }
202
203 void HTMLTextFormControlElement::dispatchBlurEvent(Element* newFocusedElement, W ebFocusType type, InputDeviceCapabilities* sourceCapabilities)
204 {
205 if (supportsPlaceholder())
206 updatePlaceholderVisibility();
207 handleBlurEvent();
208 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement, type, sourceCapabilities);
209 }
210
211 void HTMLTextFormControlElement::setRangeText(const String& replacement, Excepti onState& exceptionState) 211 void HTMLTextFormControlElement::setRangeText(const String& replacement, Excepti onState& exceptionState)
212 { 212 {
213 setRangeText(replacement, selectionStart(), selectionEnd(), "preserve", exce ptionState); 213 setRangeText(replacement, selectionStart(), selectionEnd(), "preserve", exce ptionState);
214 } 214 }
215 215
216 void HTMLTextFormControlElement::setRangeText(const String& replacement, unsigne d start, unsigned end, const String& selectionMode, ExceptionState& exceptionSta te) 216 void HTMLTextFormControlElement::setRangeText(const String& replacement, unsigne d start, unsigned end, const String& selectionMode, ExceptionState& exceptionSta te)
217 { 217 {
218 if (start > end) { 218 if (start > end) {
219 exceptionState.throwDOMException(IndexSizeError, "The provided start val ue (" + String::number(start) + ") is larger than the provided end value (" + St ring::number(end) + ")."); 219 exceptionState.throwDOMException(IndexSizeError, "The provided start val ue (" + String::number(start) + ") is larger than the provided end value (" + St ring::number(end) + ").");
220 return; 220 return;
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 } 1028 }
1029 1029
1030 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source) 1030 void HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(const Ele ment& source)
1031 { 1031 {
1032 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source); 1032 const HTMLTextFormControlElement& sourceElement = static_cast<const HTMLText FormControlElement&>(source);
1033 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit; 1033 m_lastChangeWasUserEdit = sourceElement.m_lastChangeWasUserEdit;
1034 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source); 1034 HTMLFormControlElement::copyNonAttributePropertiesFromElement(source);
1035 } 1035 }
1036 1036
1037 } // namespace blink 1037 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698