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

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

Issue 2266423003: Revert of Remove the blocking touch handlers for the input[type=range] and add touch-action instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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, 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
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"
50 #include "core/frame/Deprecation.h" 51 #include "core/frame/Deprecation.h"
52 #include "core/frame/EventHandlerRegistry.h"
51 #include "core/frame/FrameHost.h" 53 #include "core/frame/FrameHost.h"
52 #include "core/frame/FrameView.h" 54 #include "core/frame/FrameView.h"
53 #include "core/frame/LocalFrame.h" 55 #include "core/frame/LocalFrame.h"
54 #include "core/frame/UseCounter.h" 56 #include "core/frame/UseCounter.h"
55 #include "core/html/HTMLCollection.h" 57 #include "core/html/HTMLCollection.h"
56 #include "core/html/HTMLDataListElement.h" 58 #include "core/html/HTMLDataListElement.h"
57 #include "core/html/HTMLDataListOptionsCollection.h" 59 #include "core/html/HTMLDataListOptionsCollection.h"
58 #include "core/html/HTMLFormElement.h" 60 #include "core/html/HTMLFormElement.h"
59 #include "core/html/HTMLImageLoader.h" 61 #include "core/html/HTMLImageLoader.h"
60 #include "core/html/HTMLOptionElement.h" 62 #include "core/html/HTMLOptionElement.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 , m_isChecked(false) 106 , m_isChecked(false)
105 , m_dirtyCheckedness(false) 107 , m_dirtyCheckedness(false)
106 , m_isIndeterminate(false) 108 , m_isIndeterminate(false)
107 , m_isActivatedSubmit(false) 109 , m_isActivatedSubmit(false)
108 , m_autocomplete(Uninitialized) 110 , m_autocomplete(Uninitialized)
109 , m_hasNonEmptyList(false) 111 , m_hasNonEmptyList(false)
110 , m_stateRestored(false) 112 , m_stateRestored(false)
111 , m_parsingInProgress(createdByParser) 113 , m_parsingInProgress(createdByParser)
112 , m_valueAttributeWasUpdatedAfterParsing(false) 114 , m_valueAttributeWasUpdatedAfterParsing(false)
113 , m_canReceiveDroppedFiles(false) 115 , m_canReceiveDroppedFiles(false)
116 , m_hasTouchEventHandler(false)
114 , m_shouldRevealPassword(false) 117 , m_shouldRevealPassword(false)
115 , m_needsToUpdateViewValue(true) 118 , m_needsToUpdateViewValue(true)
116 , m_isPlaceholderVisible(false) 119 , m_isPlaceholderVisible(false)
117 // |m_inputType| is lazily created when constructed by the parser to avoid 120 // |m_inputType| is lazily created when constructed by the parser to avoid
118 // constructing unnecessarily a text inputType and its shadow subtree, just 121 // constructing unnecessarily a text inputType and its shadow subtree, just
119 // to destroy them when the |type| attribute gets set by the parser to 122 // to destroy them when the |type| attribute gets set by the parser to
120 // something else than 'text'. 123 // something else than 'text'.
121 , m_inputType(createdByParser ? nullptr : InputType::createText(*this)) 124 , m_inputType(createdByParser ? nullptr : InputType::createText(*this))
122 , m_inputTypeView(m_inputType ? m_inputType->createView() : nullptr) 125 , m_inputTypeView(m_inputType ? m_inputType->createView() : nullptr)
123 { 126 {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 { 394 {
392 m_inputType->disableSecureTextInput(); 395 m_inputType->disableSecureTextInput();
393 m_inputTypeView->handleBlurEvent(); 396 m_inputTypeView->handleBlurEvent();
394 } 397 }
395 398
396 void HTMLInputElement::setType(const AtomicString& type) 399 void HTMLInputElement::setType(const AtomicString& type)
397 { 400 {
398 setAttribute(typeAttr, type); 401 setAttribute(typeAttr, type);
399 } 402 }
400 403
404 void HTMLInputElement::updateTouchEventHandlerRegistry()
405 {
406 DCHECK(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
401 void HTMLInputElement::initializeTypeInParsing() 423 void HTMLInputElement::initializeTypeInParsing()
402 { 424 {
403 DCHECK(m_parsingInProgress); 425 DCHECK(m_parsingInProgress);
404 DCHECK(!m_inputType); 426 DCHECK(!m_inputType);
405 DCHECK(!m_inputTypeView); 427 DCHECK(!m_inputTypeView);
406 428
407 const AtomicString& newTypeName = InputType::normalizeTypeName(fastGetAttrib ute(typeAttr)); 429 const AtomicString& newTypeName = InputType::normalizeTypeName(fastGetAttrib ute(typeAttr));
408 m_inputType = InputType::create(*this, newTypeName); 430 m_inputType = InputType::create(*this, newTypeName);
409 m_inputTypeView = m_inputType->createView(); 431 m_inputTypeView = m_inputType->createView();
410 ensureUserAgentShadowRoot(); 432 ensureUserAgentShadowRoot();
411 433
434 updateTouchEventHandlerRegistry();
435
412 setNeedsWillValidateCheck(); 436 setNeedsWillValidateCheck();
413 437
414 m_inputType->warnIfValueIsInvalid(fastGetAttribute(valueAttr).getString()); 438 m_inputType->warnIfValueIsInvalid(fastGetAttribute(valueAttr).getString());
415 439
416 m_inputTypeView->updateView(); 440 m_inputTypeView->updateView();
417 setTextAsOfLastFormControlChangeEvent(value()); 441 setTextAsOfLastFormControlChangeEvent(value());
418 setChangedSinceLastFormControlChangeEvent(false); 442 setChangedSinceLastFormControlChangeEvent(false);
419 } 443 }
420 444
421 void HTMLInputElement::updateType() 445 void HTMLInputElement::updateType()
(...skipping 12 matching lines...) Expand all
434 bool didRespectHeightAndWidth = m_inputType->shouldRespectHeightAndWidthAttr ibutes(); 458 bool didRespectHeightAndWidth = m_inputType->shouldRespectHeightAndWidthAttr ibutes();
435 bool couldBeSuccessfulSubmitButton = canBeSuccessfulSubmitButton(); 459 bool couldBeSuccessfulSubmitButton = canBeSuccessfulSubmitButton();
436 460
437 m_inputTypeView->destroyShadowSubtree(); 461 m_inputTypeView->destroyShadowSubtree();
438 lazyReattachIfAttached(); 462 lazyReattachIfAttached();
439 463
440 m_inputType = newType; 464 m_inputType = newType;
441 m_inputTypeView = m_inputType->createView(); 465 m_inputTypeView = m_inputType->createView();
442 m_inputTypeView->createShadowSubtree(); 466 m_inputTypeView->createShadowSubtree();
443 467
468 updateTouchEventHandlerRegistry();
469
444 setNeedsWillValidateCheck(); 470 setNeedsWillValidateCheck();
445 471
446 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); 472 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute();
447 473
448 if (didStoreValue && !willStoreValue && hasDirtyValue()) { 474 if (didStoreValue && !willStoreValue && hasDirtyValue()) {
449 setAttribute(valueAttr, AtomicString(m_valueIfDirty)); 475 setAttribute(valueAttr, AtomicString(m_valueIfDirty));
450 m_valueIfDirty = String(); 476 m_valueIfDirty = String();
451 } 477 }
452 if (!didStoreValue && willStoreValue) { 478 if (!didStoreValue && willStoreValue) {
453 AtomicString valueString = fastGetAttribute(valueAttr); 479 AtomicString valueString = fastGetAttribute(valueAttr);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 } 1154 }
1129 1155
1130 void HTMLInputElement::defaultEventHandler(Event* evt) 1156 void HTMLInputElement::defaultEventHandler(Event* evt)
1131 { 1157 {
1132 if (evt->isMouseEvent() && evt->type() == EventTypeNames::click && toMouseEv ent(evt)->button() == static_cast<short>(WebPointerProperties::Button::Left)) { 1158 if (evt->isMouseEvent() && evt->type() == EventTypeNames::click && toMouseEv ent(evt)->button() == static_cast<short>(WebPointerProperties::Button::Left)) {
1133 m_inputTypeView->handleClickEvent(toMouseEvent(evt)); 1159 m_inputTypeView->handleClickEvent(toMouseEvent(evt));
1134 if (evt->defaultHandled()) 1160 if (evt->defaultHandled())
1135 return; 1161 return;
1136 } 1162 }
1137 1163
1164 if (evt->isTouchEvent() && m_inputTypeView->hasTouchEventHandler()) {
1165 m_inputTypeView->handleTouchEvent(toTouchEvent(evt));
1166 if (evt->defaultHandled())
1167 return;
1168 }
1169
1138 if (evt->isKeyboardEvent() && evt->type() == EventTypeNames::keydown) { 1170 if (evt->isKeyboardEvent() && evt->type() == EventTypeNames::keydown) {
1139 m_inputTypeView->handleKeydownEvent(toKeyboardEvent(evt)); 1171 m_inputTypeView->handleKeydownEvent(toKeyboardEvent(evt));
1140 if (evt->defaultHandled()) 1172 if (evt->defaultHandled())
1141 return; 1173 return;
1142 } 1174 }
1143 1175
1144 // Call the base event handler before any of our own event handling for almo st all events in text fields. 1176 // Call the base event handler before any of our own event handling for almo st all events in text fields.
1145 // Makes editing keyboard handling take precedence over the keydown and keyp ress handling in this function. 1177 // Makes editing keyboard handling take precedence over the keydown and keyp ress handling in this function.
1146 bool callBaseClassEarly = isTextField() && (evt->type() == EventTypeNames::k eydown || evt->type() == EventTypeNames::keypress); 1178 bool callBaseClassEarly = isTextField() && (evt->type() == EventTypeNames::k eydown || evt->type() == EventTypeNames::keypress);
1147 if (callBaseClassEarly) { 1179 if (callBaseClassEarly) {
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 1499
1468 void HTMLInputElement::didMoveToNewDocument(Document& oldDocument) 1500 void HTMLInputElement::didMoveToNewDocument(Document& oldDocument)
1469 { 1501 {
1470 if (imageLoader()) 1502 if (imageLoader())
1471 imageLoader()->elementDidMoveToNewDocument(); 1503 imageLoader()->elementDidMoveToNewDocument();
1472 1504
1473 // FIXME: Remove type check. 1505 // FIXME: Remove type check.
1474 if (type() == InputTypeNames::radio) 1506 if (type() == InputTypeNames::radio)
1475 treeScope().radioButtonGroupScope().removeButton(this); 1507 treeScope().radioButtonGroupScope().removeButton(this);
1476 1508
1509 updateTouchEventHandlerRegistry();
1510
1477 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument); 1511 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument);
1478 } 1512 }
1479 1513
1514 void HTMLInputElement::removeAllEventListeners()
1515 {
1516 HTMLTextFormControlElement::removeAllEventListeners();
1517 m_hasTouchEventHandler = false;
1518 }
1519
1480 bool HTMLInputElement::recalcWillValidate() const 1520 bool HTMLInputElement::recalcWillValidate() const
1481 { 1521 {
1482 return m_inputType->supportsValidation() && HTMLTextFormControlElement::reca lcWillValidate(); 1522 return m_inputType->supportsValidation() && HTMLTextFormControlElement::reca lcWillValidate();
1483 } 1523 }
1484 1524
1485 void HTMLInputElement::requiredAttributeChanged() 1525 void HTMLInputElement::requiredAttributeChanged()
1486 { 1526 {
1487 HTMLTextFormControlElement::requiredAttributeChanged(); 1527 HTMLTextFormControlElement::requiredAttributeChanged();
1488 if (RadioButtonGroupScope* scope = radioButtonGroupScope()) 1528 if (RadioButtonGroupScope* scope = radioButtonGroupScope())
1489 scope->requiredAttributeChanged(this); 1529 scope->requiredAttributeChanged(this);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 { 1949 {
1910 return m_inputTypeView->hasFallbackContent(); 1950 return m_inputTypeView->hasFallbackContent();
1911 } 1951 }
1912 1952
1913 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths) 1953 void HTMLInputElement::setFilesFromPaths(const Vector<String>& paths)
1914 { 1954 {
1915 return m_inputType->setFilesFromPaths(paths); 1955 return m_inputType->setFilesFromPaths(paths);
1916 } 1956 }
1917 1957
1918 } // namespace blink 1958 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLInputElement.h ('k') | third_party/WebKit/Source/core/html/forms/InputTypeView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698