OLD | NEW |
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, 2009, 2010, 2011 Apple Inc. All | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 * rights reserved. | 6 * rights 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 * Copyright (C) 2010 Google Inc. All rights reserved. | 9 * Copyright (C) 2010 Google Inc. All rights reserved. |
10 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. | 10 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 | 1039 |
1040 const String& HTMLInputElement::suggestedValue() const { | 1040 const String& HTMLInputElement::suggestedValue() const { |
1041 return m_suggestedValue; | 1041 return m_suggestedValue; |
1042 } | 1042 } |
1043 | 1043 |
1044 void HTMLInputElement::setSuggestedValue(const String& value) { | 1044 void HTMLInputElement::setSuggestedValue(const String& value) { |
1045 if (!m_inputType->canSetSuggestedValue()) | 1045 if (!m_inputType->canSetSuggestedValue()) |
1046 return; | 1046 return; |
1047 m_needsToUpdateViewValue = true; | 1047 m_needsToUpdateViewValue = true; |
1048 m_suggestedValue = sanitizeValue(value); | 1048 m_suggestedValue = sanitizeValue(value); |
1049 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( | 1049 setNeedsStyleRecalc( |
1050 StyleChangeReason::ControlValue)); | 1050 SubtreeStyleChange, |
| 1051 StyleChangeReasonForTracing::create(StyleChangeReason::ControlValue)); |
1051 m_inputTypeView->updateView(); | 1052 m_inputTypeView->updateView(); |
1052 } | 1053 } |
1053 | 1054 |
1054 void HTMLInputElement::setEditingValue(const String& value) { | 1055 void HTMLInputElement::setEditingValue(const String& value) { |
1055 if (!layoutObject() || !isTextField()) | 1056 if (!layoutObject() || !isTextField()) |
1056 return; | 1057 return; |
1057 setInnerEditorValue(value); | 1058 setInnerEditorValue(value); |
1058 subtreeHasChanged(); | 1059 subtreeHasChanged(); |
1059 | 1060 |
1060 unsigned max = value.length(); | 1061 unsigned max = value.length(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 | 1220 |
1220 if (evt->isKeyboardEvent() && evt->type() == EventTypeNames::keydown) { | 1221 if (evt->isKeyboardEvent() && evt->type() == EventTypeNames::keydown) { |
1221 m_inputTypeView->handleKeydownEvent(toKeyboardEvent(evt)); | 1222 m_inputTypeView->handleKeydownEvent(toKeyboardEvent(evt)); |
1222 if (evt->defaultHandled()) | 1223 if (evt->defaultHandled()) |
1223 return; | 1224 return; |
1224 } | 1225 } |
1225 | 1226 |
1226 // Call the base event handler before any of our own event handling for almost | 1227 // Call the base event handler before any of our own event handling for almost |
1227 // all events in text fields. Makes editing keyboard handling take precedence | 1228 // all events in text fields. Makes editing keyboard handling take precedence |
1228 // over the keydown and keypress handling in this function. | 1229 // over the keydown and keypress handling in this function. |
1229 bool callBaseClassEarly = | 1230 bool callBaseClassEarly = isTextField() && |
1230 isTextField() && (evt->type() == EventTypeNames::keydown || | 1231 (evt->type() == EventTypeNames::keydown || |
1231 evt->type() == EventTypeNames::keypress); | 1232 evt->type() == EventTypeNames::keypress); |
1232 if (callBaseClassEarly) { | 1233 if (callBaseClassEarly) { |
1233 TextControlElement::defaultEventHandler(evt); | 1234 TextControlElement::defaultEventHandler(evt); |
1234 if (evt->defaultHandled()) | 1235 if (evt->defaultHandled()) |
1235 return; | 1236 return; |
1236 } | 1237 } |
1237 | 1238 |
1238 // DOMActivate events cause the input to be "activated" - in the case of image | 1239 // DOMActivate events cause the input to be "activated" - in the case of image |
1239 // and submit inputs, this means actually submitting the form. For reset | 1240 // and submit inputs, this means actually submitting the form. For reset |
1240 // inputs, the form is reset. These events are sent when the user clicks on | 1241 // inputs, the form is reset. These events are sent when the user clicks on |
1241 // the element, or presses enter while it is the active element. JavaScript | 1242 // the element, or presses enter while it is the active element. JavaScript |
(...skipping 16 matching lines...) Expand all Loading... |
1258 if (evt->isKeyboardEvent() && evt->type() == EventTypeNames::keyup) { | 1259 if (evt->isKeyboardEvent() && evt->type() == EventTypeNames::keyup) { |
1259 m_inputTypeView->handleKeyupEvent(toKeyboardEvent(evt)); | 1260 m_inputTypeView->handleKeyupEvent(toKeyboardEvent(evt)); |
1260 if (evt->defaultHandled()) | 1261 if (evt->defaultHandled()) |
1261 return; | 1262 return; |
1262 } | 1263 } |
1263 | 1264 |
1264 if (m_inputTypeView->shouldSubmitImplicitly(evt)) { | 1265 if (m_inputTypeView->shouldSubmitImplicitly(evt)) { |
1265 // FIXME: Remove type check. | 1266 // FIXME: Remove type check. |
1266 if (type() == InputTypeNames::search) { | 1267 if (type() == InputTypeNames::search) { |
1267 TaskRunnerHelper::get(TaskType::UserInteraction, &document()) | 1268 TaskRunnerHelper::get(TaskType::UserInteraction, &document()) |
1268 ->postTask(BLINK_FROM_HERE, WTF::bind(&HTMLInputElement::onSearch, | 1269 ->postTask( |
1269 wrapPersistent(this))); | 1270 BLINK_FROM_HERE, |
| 1271 WTF::bind(&HTMLInputElement::onSearch, wrapPersistent(this))); |
1270 } | 1272 } |
1271 // Form submission finishes editing, just as loss of focus does. | 1273 // Form submission finishes editing, just as loss of focus does. |
1272 // If there was a change, send the event now. | 1274 // If there was a change, send the event now. |
1273 if (wasChangedSinceLastFormControlChangeEvent()) | 1275 if (wasChangedSinceLastFormControlChangeEvent()) |
1274 dispatchFormControlChangeEvent(); | 1276 dispatchFormControlChangeEvent(); |
1275 | 1277 |
1276 HTMLFormElement* formForSubmission = m_inputTypeView->formForSubmission(); | 1278 HTMLFormElement* formForSubmission = m_inputTypeView->formForSubmission(); |
1277 // Form may never have been present, or may have been destroyed by code | 1279 // Form may never have been present, or may have been destroyed by code |
1278 // responding to the change event. | 1280 // responding to the change event. |
1279 if (formForSubmission) | 1281 if (formForSubmission) |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 | 1888 |
1887 bool HTMLInputElement::hasFallbackContent() const { | 1889 bool HTMLInputElement::hasFallbackContent() const { |
1888 return m_inputTypeView->hasFallbackContent(); | 1890 return m_inputTypeView->hasFallbackContent(); |
1889 } | 1891 } |
1890 | 1892 |
1891 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) { | 1893 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) { |
1892 return m_inputType->setFilesFromPaths(paths); | 1894 return m_inputType->setFilesFromPaths(paths); |
1893 } | 1895 } |
1894 | 1896 |
1895 } // namespace blink | 1897 } // namespace blink |
OLD | NEW |