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

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

Issue 206603002: Add EventHandlerRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tests now seem to pass. Created 6 years, 9 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 19 matching lines...) Expand all
30 #include "core/html/HTMLInputElement.h" 30 #include "core/html/HTMLInputElement.h"
31 31
32 #include "CSSPropertyNames.h" 32 #include "CSSPropertyNames.h"
33 #include "HTMLNames.h" 33 #include "HTMLNames.h"
34 #include "RuntimeEnabledFeatures.h" 34 #include "RuntimeEnabledFeatures.h"
35 #include "bindings/v8/ExceptionMessages.h" 35 #include "bindings/v8/ExceptionMessages.h"
36 #include "bindings/v8/ExceptionState.h" 36 #include "bindings/v8/ExceptionState.h"
37 #include "bindings/v8/ScriptEventListener.h" 37 #include "bindings/v8/ScriptEventListener.h"
38 #include "core/accessibility/AXObjectCache.h" 38 #include "core/accessibility/AXObjectCache.h"
39 #include "core/dom/Document.h" 39 #include "core/dom/Document.h"
40 #include "core/dom/EventHandlerRegistry.h"
40 #include "core/dom/ExceptionCode.h" 41 #include "core/dom/ExceptionCode.h"
41 #include "core/dom/IdTargetObserver.h" 42 #include "core/dom/IdTargetObserver.h"
42 #include "core/dom/shadow/ElementShadow.h" 43 #include "core/dom/shadow/ElementShadow.h"
43 #include "core/dom/shadow/InsertionPoint.h" 44 #include "core/dom/shadow/InsertionPoint.h"
44 #include "core/dom/shadow/ShadowRoot.h" 45 #include "core/dom/shadow/ShadowRoot.h"
45 #include "core/editing/FrameSelection.h" 46 #include "core/editing/FrameSelection.h"
46 #include "core/editing/SpellChecker.h" 47 #include "core/editing/SpellChecker.h"
47 #include "core/events/BeforeTextInsertedEvent.h" 48 #include "core/events/BeforeTextInsertedEvent.h"
48 #include "core/events/KeyboardEvent.h" 49 #include "core/events/KeyboardEvent.h"
49 #include "core/events/MouseEvent.h" 50 #include "core/events/MouseEvent.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 HTMLInputElement::~HTMLInputElement() 162 HTMLInputElement::~HTMLInputElement()
162 { 163 {
163 // Need to remove form association while this is still an HTMLInputElement 164 // Need to remove form association while this is still an HTMLInputElement
164 // so that virtual functions are called correctly. 165 // so that virtual functions are called correctly.
165 setForm(0); 166 setForm(0);
166 // setForm(0) may register this to a document-level radio button group. 167 // setForm(0) may register this to a document-level radio button group.
167 // We should unregister it to avoid accessing a deleted object. 168 // We should unregister it to avoid accessing a deleted object.
168 if (isRadioButton()) 169 if (isRadioButton())
169 document().formController().radioButtonGroupScope().removeButton(this); 170 document().formController().radioButtonGroupScope().removeButton(this);
170 if (m_hasTouchEventHandler) 171 if (m_hasTouchEventHandler)
171 document().didRemoveTouchEventHandler(this); 172 EventHandlerRegistry::from(document())->didRemoveEventHandler(*this, Eve ntTypeNames::touchstart);
Rick Byers 2014/03/27 16:43:31 It's a bit of a lie here to pass just touchstart (
Sami 2014/04/02 19:58:05 Done.
172 } 173 }
173 174
174 const AtomicString& HTMLInputElement::name() const 175 const AtomicString& HTMLInputElement::name() const
175 { 176 {
176 return m_name.isNull() ? emptyAtom : m_name; 177 return m_name.isNull() ? emptyAtom : m_name;
177 } 178 }
178 179
179 Vector<FileChooserFileInfo> HTMLInputElement::filesFromFileInputFormControlState (const FormControlState& state) 180 Vector<FileChooserFileInfo> HTMLInputElement::filesFromFileInputFormControlState (const FormControlState& state)
180 { 181 {
181 return FileInputType::filesFromFormControlState(state); 182 return FileInputType::filesFromFormControlState(state);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 m_inputType = newType.release(); 426 m_inputType = newType.release();
426 if (hasAuthorShadowRoot()) 427 if (hasAuthorShadowRoot())
427 m_inputTypeView = InputTypeView::create(*this); 428 m_inputTypeView = InputTypeView::create(*this);
428 else 429 else
429 m_inputTypeView = m_inputType; 430 m_inputTypeView = m_inputType;
430 m_inputTypeView->createShadowSubtree(); 431 m_inputTypeView->createShadowSubtree();
431 432
432 bool hasTouchEventHandler = m_inputTypeView->hasTouchEventHandler(); 433 bool hasTouchEventHandler = m_inputTypeView->hasTouchEventHandler();
433 if (hasTouchEventHandler != m_hasTouchEventHandler) { 434 if (hasTouchEventHandler != m_hasTouchEventHandler) {
434 if (hasTouchEventHandler) 435 if (hasTouchEventHandler)
435 document().didAddTouchEventHandler(this); 436 EventHandlerRegistry::from(document())->didAddEventHandler(*this, Ev entTypeNames::touchstart);
436 else 437 else
437 document().didRemoveTouchEventHandler(this); 438 EventHandlerRegistry::from(document())->didRemoveEventHandler(*this, EventTypeNames::touchstart);
438 m_hasTouchEventHandler = hasTouchEventHandler; 439 m_hasTouchEventHandler = hasTouchEventHandler;
439 } 440 }
440 441
441 setNeedsWillValidateCheck(); 442 setNeedsWillValidateCheck();
442 443
443 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); 444 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute();
444 445
445 if (didStoreValue && !willStoreValue && hasDirtyValue()) { 446 if (didStoreValue && !willStoreValue && hasDirtyValue()) {
446 setAttribute(valueAttr, AtomicString(m_valueIfDirty)); 447 setAttribute(valueAttr, AtomicString(m_valueIfDirty));
447 m_valueIfDirty = String(); 448 m_valueIfDirty = String();
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 } 1439 }
1439 1440
1440 void HTMLInputElement::didMoveToNewDocument(Document& oldDocument) 1441 void HTMLInputElement::didMoveToNewDocument(Document& oldDocument)
1441 { 1442 {
1442 if (hasImageLoader()) 1443 if (hasImageLoader())
1443 imageLoader()->elementDidMoveToNewDocument(); 1444 imageLoader()->elementDidMoveToNewDocument();
1444 1445
1445 if (isRadioButton()) 1446 if (isRadioButton())
1446 oldDocument.formController().radioButtonGroupScope().removeButton(this); 1447 oldDocument.formController().radioButtonGroupScope().removeButton(this);
1447 if (m_hasTouchEventHandler) 1448 if (m_hasTouchEventHandler)
1448 oldDocument.didRemoveTouchEventHandler(this); 1449 EventHandlerRegistry::from(oldDocument)->didRemoveEventHandler(*this, Ev entTypeNames::touchstart);
1449 1450
1450 if (m_hasTouchEventHandler) 1451 if (m_hasTouchEventHandler)
1451 document().didAddTouchEventHandler(this); 1452 EventHandlerRegistry::from(document())->didAddEventHandler(*this, EventT ypeNames::touchstart);
1452 1453
1453 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument); 1454 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument);
1454 } 1455 }
1455 1456
1456 void HTMLInputElement::removeAllEventListeners() 1457 void HTMLInputElement::removeAllEventListeners()
1457 { 1458 {
1458 HTMLTextFormControlElement::removeAllEventListeners(); 1459 HTMLTextFormControlElement::removeAllEventListeners();
1459 m_hasTouchEventHandler = false; 1460 m_hasTouchEventHandler = false;
1460 } 1461 }
1461 1462
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 } 1879 }
1879 1880
1880 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 1881 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
1881 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() 1882 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
1882 { 1883 {
1883 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer()); 1884 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer());
1884 } 1885 }
1885 #endif 1886 #endif
1886 1887
1887 } // namespace 1888 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698