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

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

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