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 r ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. |
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 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) | 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) |
10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. | 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. |
(...skipping 29 matching lines...) Expand all Loading... | |
40 #include "core/dom/IdTargetObserver.h" | 40 #include "core/dom/IdTargetObserver.h" |
41 #include "core/dom/StyleChangeReason.h" | 41 #include "core/dom/StyleChangeReason.h" |
42 #include "core/dom/shadow/InsertionPoint.h" | 42 #include "core/dom/shadow/InsertionPoint.h" |
43 #include "core/dom/shadow/ShadowRoot.h" | 43 #include "core/dom/shadow/ShadowRoot.h" |
44 #include "core/editing/FrameSelection.h" | 44 #include "core/editing/FrameSelection.h" |
45 #include "core/editing/spellcheck/SpellChecker.h" | 45 #include "core/editing/spellcheck/SpellChecker.h" |
46 #include "core/events/BeforeTextInsertedEvent.h" | 46 #include "core/events/BeforeTextInsertedEvent.h" |
47 #include "core/events/KeyboardEvent.h" | 47 #include "core/events/KeyboardEvent.h" |
48 #include "core/events/MouseEvent.h" | 48 #include "core/events/MouseEvent.h" |
49 #include "core/events/ScopedEventQueue.h" | 49 #include "core/events/ScopedEventQueue.h" |
50 #include "core/events/TouchEvent.h" | |
51 #include "core/frame/Deprecation.h" | 50 #include "core/frame/Deprecation.h" |
52 #include "core/frame/EventHandlerRegistry.h" | |
53 #include "core/frame/FrameHost.h" | 51 #include "core/frame/FrameHost.h" |
54 #include "core/frame/FrameView.h" | 52 #include "core/frame/FrameView.h" |
55 #include "core/frame/LocalFrame.h" | 53 #include "core/frame/LocalFrame.h" |
56 #include "core/frame/UseCounter.h" | 54 #include "core/frame/UseCounter.h" |
57 #include "core/html/HTMLCollection.h" | 55 #include "core/html/HTMLCollection.h" |
58 #include "core/html/HTMLDataListElement.h" | 56 #include "core/html/HTMLDataListElement.h" |
59 #include "core/html/HTMLDataListOptionsCollection.h" | 57 #include "core/html/HTMLDataListOptionsCollection.h" |
60 #include "core/html/HTMLFormElement.h" | 58 #include "core/html/HTMLFormElement.h" |
61 #include "core/html/HTMLImageLoader.h" | 59 #include "core/html/HTMLImageLoader.h" |
62 #include "core/html/HTMLOptionElement.h" | 60 #include "core/html/HTMLOptionElement.h" |
63 #include "core/html/forms/ColorChooser.h" | 61 #include "core/html/forms/ColorChooser.h" |
64 #include "core/html/forms/DateTimeChooser.h" | 62 #include "core/html/forms/DateTimeChooser.h" |
65 #include "core/html/forms/FileInputType.h" | 63 #include "core/html/forms/FileInputType.h" |
66 #include "core/html/forms/FormController.h" | 64 #include "core/html/forms/FormController.h" |
67 #include "core/html/forms/InputType.h" | 65 #include "core/html/forms/InputType.h" |
68 #include "core/html/forms/SearchInputType.h" | 66 #include "core/html/forms/SearchInputType.h" |
69 #include "core/html/parser/HTMLParserIdioms.h" | 67 #include "core/html/parser/HTMLParserIdioms.h" |
68 #include "core/html/shadow/ShadowElementNames.h" | |
tkent
2016/08/17 01:32:00
This change isn't necessary.
| |
70 #include "core/layout/LayoutTheme.h" | 69 #include "core/layout/LayoutTheme.h" |
71 #include "core/page/ChromeClient.h" | 70 #include "core/page/ChromeClient.h" |
72 #include "platform/Language.h" | 71 #include "platform/Language.h" |
73 #include "platform/PlatformMouseEvent.h" | 72 #include "platform/PlatformMouseEvent.h" |
74 #include "platform/RuntimeEnabledFeatures.h" | 73 #include "platform/RuntimeEnabledFeatures.h" |
75 #include "platform/text/PlatformLocale.h" | 74 #include "platform/text/PlatformLocale.h" |
76 #include "wtf/MathExtras.h" | 75 #include "wtf/MathExtras.h" |
77 | 76 |
78 namespace blink { | 77 namespace blink { |
79 | 78 |
(...skipping 26 matching lines...) Expand all Loading... | |
106 , m_isChecked(false) | 105 , m_isChecked(false) |
107 , m_dirtyCheckedness(false) | 106 , m_dirtyCheckedness(false) |
108 , m_isIndeterminate(false) | 107 , m_isIndeterminate(false) |
109 , m_isActivatedSubmit(false) | 108 , m_isActivatedSubmit(false) |
110 , m_autocomplete(Uninitialized) | 109 , m_autocomplete(Uninitialized) |
111 , m_hasNonEmptyList(false) | 110 , m_hasNonEmptyList(false) |
112 , m_stateRestored(false) | 111 , m_stateRestored(false) |
113 , m_parsingInProgress(createdByParser) | 112 , m_parsingInProgress(createdByParser) |
114 , m_valueAttributeWasUpdatedAfterParsing(false) | 113 , m_valueAttributeWasUpdatedAfterParsing(false) |
115 , m_canReceiveDroppedFiles(false) | 114 , m_canReceiveDroppedFiles(false) |
116 , m_hasTouchEventHandler(false) | |
117 , m_shouldRevealPassword(false) | 115 , m_shouldRevealPassword(false) |
118 , m_needsToUpdateViewValue(true) | 116 , m_needsToUpdateViewValue(true) |
119 , m_isPlaceholderVisible(false) | 117 , m_isPlaceholderVisible(false) |
120 // |m_inputType| is lazily created when constructed by the parser to avoid | 118 // |m_inputType| is lazily created when constructed by the parser to avoid |
121 // constructing unnecessarily a text inputType and its shadow subtree, just | 119 // constructing unnecessarily a text inputType and its shadow subtree, just |
122 // to destroy them when the |type| attribute gets set by the parser to | 120 // to destroy them when the |type| attribute gets set by the parser to |
123 // something else than 'text'. | 121 // something else than 'text'. |
124 , m_inputType(createdByParser ? nullptr : InputType::createText(*this)) | 122 , m_inputType(createdByParser ? nullptr : InputType::createText(*this)) |
125 , m_inputTypeView(m_inputType ? m_inputType->createView() : nullptr) | 123 , m_inputTypeView(m_inputType ? m_inputType->createView() : nullptr) |
126 { | 124 { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 { | 392 { |
395 m_inputType->disableSecureTextInput(); | 393 m_inputType->disableSecureTextInput(); |
396 m_inputTypeView->handleBlurEvent(); | 394 m_inputTypeView->handleBlurEvent(); |
397 } | 395 } |
398 | 396 |
399 void HTMLInputElement::setType(const AtomicString& type) | 397 void HTMLInputElement::setType(const AtomicString& type) |
400 { | 398 { |
401 setAttribute(typeAttr, type); | 399 setAttribute(typeAttr, type); |
402 } | 400 } |
403 | 401 |
404 void HTMLInputElement::updateTouchEventHandlerRegistry() | |
405 { | |
406 ASSERT(m_inputTypeView); | |
407 | |
408 bool hasTouchEventHandler = m_inputTypeView->hasTouchEventHandler(); | |
409 if (hasTouchEventHandler == !!m_hasTouchEventHandler) | |
410 return; | |
411 // If the Document is being or has been stopped, don't register any handlers . | |
412 if (document().frameHost() && document().lifecycle().state() < DocumentLifec ycle::Stopping) { | |
413 EventHandlerRegistry& registry = document().frameHost()->eventHandlerReg istry(); | |
414 // TODO(dtapuska): Make this passive touch listener see crbug.com/584438 | |
415 if (hasTouchEventHandler) | |
416 registry.didAddEventHandler(*this, EventHandlerRegistry::TouchStartO rMoveEventBlocking); | |
417 else | |
418 registry.didRemoveEventHandler(*this, EventHandlerRegistry::TouchSta rtOrMoveEventBlocking); | |
419 m_hasTouchEventHandler = hasTouchEventHandler; | |
420 } | |
421 } | |
422 | |
423 void HTMLInputElement::initializeTypeInParsing() | 402 void HTMLInputElement::initializeTypeInParsing() |
424 { | 403 { |
425 ASSERT(m_parsingInProgress); | 404 ASSERT(m_parsingInProgress); |
426 ASSERT(!m_inputType); | 405 ASSERT(!m_inputType); |
427 ASSERT(!m_inputTypeView); | 406 ASSERT(!m_inputTypeView); |
428 | 407 |
429 const AtomicString& newTypeName = InputType::normalizeTypeName(fastGetAttrib ute(typeAttr)); | 408 const AtomicString& newTypeName = InputType::normalizeTypeName(fastGetAttrib ute(typeAttr)); |
430 m_inputType = InputType::create(*this, newTypeName); | 409 m_inputType = InputType::create(*this, newTypeName); |
431 m_inputTypeView = m_inputType->createView(); | 410 m_inputTypeView = m_inputType->createView(); |
432 ensureUserAgentShadowRoot(); | 411 ensureUserAgentShadowRoot(); |
433 | 412 |
434 updateTouchEventHandlerRegistry(); | |
435 | |
436 setNeedsWillValidateCheck(); | 413 setNeedsWillValidateCheck(); |
437 | 414 |
438 m_inputType->warnIfValueIsInvalid(fastGetAttribute(valueAttr).getString()); | 415 m_inputType->warnIfValueIsInvalid(fastGetAttribute(valueAttr).getString()); |
439 | 416 |
440 m_inputTypeView->updateView(); | 417 m_inputTypeView->updateView(); |
441 setTextAsOfLastFormControlChangeEvent(value()); | 418 setTextAsOfLastFormControlChangeEvent(value()); |
442 setChangedSinceLastFormControlChangeEvent(false); | 419 setChangedSinceLastFormControlChangeEvent(false); |
443 } | 420 } |
444 | 421 |
445 void HTMLInputElement::updateType() | 422 void HTMLInputElement::updateType() |
(...skipping 12 matching lines...) Expand all Loading... | |
458 bool didRespectHeightAndWidth = m_inputType->shouldRespectHeightAndWidthAttr ibutes(); | 435 bool didRespectHeightAndWidth = m_inputType->shouldRespectHeightAndWidthAttr ibutes(); |
459 bool couldBeSuccessfulSubmitButton = canBeSuccessfulSubmitButton(); | 436 bool couldBeSuccessfulSubmitButton = canBeSuccessfulSubmitButton(); |
460 | 437 |
461 m_inputTypeView->destroyShadowSubtree(); | 438 m_inputTypeView->destroyShadowSubtree(); |
462 lazyReattachIfAttached(); | 439 lazyReattachIfAttached(); |
463 | 440 |
464 m_inputType = newType; | 441 m_inputType = newType; |
465 m_inputTypeView = m_inputType->createView(); | 442 m_inputTypeView = m_inputType->createView(); |
466 m_inputTypeView->createShadowSubtree(); | 443 m_inputTypeView->createShadowSubtree(); |
467 | 444 |
468 updateTouchEventHandlerRegistry(); | |
469 | |
470 setNeedsWillValidateCheck(); | 445 setNeedsWillValidateCheck(); |
471 | 446 |
472 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); | 447 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); |
473 | 448 |
474 if (didStoreValue && !willStoreValue && hasDirtyValue()) { | 449 if (didStoreValue && !willStoreValue && hasDirtyValue()) { |
475 setAttribute(valueAttr, AtomicString(m_valueIfDirty)); | 450 setAttribute(valueAttr, AtomicString(m_valueIfDirty)); |
476 m_valueIfDirty = String(); | 451 m_valueIfDirty = String(); |
477 } | 452 } |
478 if (!didStoreValue && willStoreValue) { | 453 if (!didStoreValue && willStoreValue) { |
479 AtomicString valueString = fastGetAttribute(valueAttr); | 454 AtomicString valueString = fastGetAttribute(valueAttr); |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1154 } | 1129 } |
1155 | 1130 |
1156 void HTMLInputElement::defaultEventHandler(Event* evt) | 1131 void HTMLInputElement::defaultEventHandler(Event* evt) |
1157 { | 1132 { |
1158 if (evt->isMouseEvent() && evt->type() == EventTypeNames::click && toMouseEv ent(evt)->button() == LeftButton) { | 1133 if (evt->isMouseEvent() && evt->type() == EventTypeNames::click && toMouseEv ent(evt)->button() == LeftButton) { |
1159 m_inputTypeView->handleClickEvent(toMouseEvent(evt)); | 1134 m_inputTypeView->handleClickEvent(toMouseEvent(evt)); |
1160 if (evt->defaultHandled()) | 1135 if (evt->defaultHandled()) |
1161 return; | 1136 return; |
1162 } | 1137 } |
1163 | 1138 |
1164 if (evt->isTouchEvent() && m_inputTypeView->hasTouchEventHandler()) { | |
1165 m_inputTypeView->handleTouchEvent(toTouchEvent(evt)); | |
1166 if (evt->defaultHandled()) | |
1167 return; | |
1168 } | |
1169 | |
1170 if (evt->isKeyboardEvent() && evt->type() == EventTypeNames::keydown) { | 1139 if (evt->isKeyboardEvent() && evt->type() == EventTypeNames::keydown) { |
1171 m_inputTypeView->handleKeydownEvent(toKeyboardEvent(evt)); | 1140 m_inputTypeView->handleKeydownEvent(toKeyboardEvent(evt)); |
1172 if (evt->defaultHandled()) | 1141 if (evt->defaultHandled()) |
1173 return; | 1142 return; |
1174 } | 1143 } |
1175 | 1144 |
1176 // Call the base event handler before any of our own event handling for almo st all events in text fields. | 1145 // Call the base event handler before any of our own event handling for almo st all events in text fields. |
1177 // Makes editing keyboard handling take precedence over the keydown and keyp ress handling in this function. | 1146 // Makes editing keyboard handling take precedence over the keydown and keyp ress handling in this function. |
1178 bool callBaseClassEarly = isTextField() && (evt->type() == EventTypeNames::k eydown || evt->type() == EventTypeNames::keypress); | 1147 bool callBaseClassEarly = isTextField() && (evt->type() == EventTypeNames::k eydown || evt->type() == EventTypeNames::keypress); |
1179 if (callBaseClassEarly) { | 1148 if (callBaseClassEarly) { |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1499 | 1468 |
1500 void HTMLInputElement::didMoveToNewDocument(Document& oldDocument) | 1469 void HTMLInputElement::didMoveToNewDocument(Document& oldDocument) |
1501 { | 1470 { |
1502 if (imageLoader()) | 1471 if (imageLoader()) |
1503 imageLoader()->elementDidMoveToNewDocument(); | 1472 imageLoader()->elementDidMoveToNewDocument(); |
1504 | 1473 |
1505 // FIXME: Remove type check. | 1474 // FIXME: Remove type check. |
1506 if (type() == InputTypeNames::radio) | 1475 if (type() == InputTypeNames::radio) |
1507 treeScope().radioButtonGroupScope().removeButton(this); | 1476 treeScope().radioButtonGroupScope().removeButton(this); |
1508 | 1477 |
1509 updateTouchEventHandlerRegistry(); | |
1510 | |
1511 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument); | 1478 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument); |
1512 } | 1479 } |
1513 | 1480 |
1514 void HTMLInputElement::removeAllEventListeners() | |
1515 { | |
1516 HTMLTextFormControlElement::removeAllEventListeners(); | |
1517 m_hasTouchEventHandler = false; | |
1518 } | |
1519 | |
1520 bool HTMLInputElement::recalcWillValidate() const | 1481 bool HTMLInputElement::recalcWillValidate() const |
1521 { | 1482 { |
1522 return m_inputType->supportsValidation() && HTMLTextFormControlElement::reca lcWillValidate(); | 1483 return m_inputType->supportsValidation() && HTMLTextFormControlElement::reca lcWillValidate(); |
1523 } | 1484 } |
1524 | 1485 |
1525 void HTMLInputElement::requiredAttributeChanged() | 1486 void HTMLInputElement::requiredAttributeChanged() |
1526 { | 1487 { |
1527 HTMLTextFormControlElement::requiredAttributeChanged(); | 1488 HTMLTextFormControlElement::requiredAttributeChanged(); |
1528 if (RadioButtonGroupScope* scope = radioButtonGroupScope()) | 1489 if (RadioButtonGroupScope* scope = radioButtonGroupScope()) |
1529 scope->requiredAttributeChanged(this); | 1490 scope->requiredAttributeChanged(this); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1914 { | 1875 { |
1915 return m_inputTypeView->hasFallbackContent(); | 1876 return m_inputTypeView->hasFallbackContent(); |
1916 } | 1877 } |
1917 | 1878 |
1918 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) | 1879 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) |
1919 { | 1880 { |
1920 return m_inputType->setFilesFromPaths(paths); | 1881 return m_inputType->setFilesFromPaths(paths); |
1921 } | 1882 } |
1922 | 1883 |
1923 } // namespace blink | 1884 } // namespace blink |
OLD | NEW |