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

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: Add test for external handlers. Created 6 years, 8 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 HTMLInputElement::~HTMLInputElement() 161 HTMLInputElement::~HTMLInputElement()
161 { 162 {
162 // Need to remove form association while this is still an HTMLInputElement 163 // Need to remove form association while this is still an HTMLInputElement
163 // so that virtual functions are called correctly. 164 // so that virtual functions are called correctly.
164 setForm(0); 165 setForm(0);
165 // setForm(0) may register this to a document-level radio button group. 166 // setForm(0) may register this to a document-level radio button group.
166 // We should unregister it to avoid accessing a deleted object. 167 // We should unregister it to avoid accessing a deleted object.
167 if (isRadioButton()) 168 if (isRadioButton())
168 document().formController().radioButtonGroupScope().removeButton(this); 169 document().formController().radioButtonGroupScope().removeButton(this);
169 if (m_hasTouchEventHandler) 170 if (m_hasTouchEventHandler)
170 document().didRemoveTouchEventHandler(this); 171 EventHandlerRegistry::from(document())->didRemoveEventHandler(*this, Eve ntHandlerRegistry::TouchEvent);
171 } 172 }
172 173
173 const AtomicString& HTMLInputElement::name() const 174 const AtomicString& HTMLInputElement::name() const
174 { 175 {
175 return m_name.isNull() ? emptyAtom : m_name; 176 return m_name.isNull() ? emptyAtom : m_name;
176 } 177 }
177 178
178 Vector<FileChooserFileInfo> HTMLInputElement::filesFromFileInputFormControlState (const FormControlState& state) 179 Vector<FileChooserFileInfo> HTMLInputElement::filesFromFileInputFormControlState (const FormControlState& state)
179 { 180 {
180 return FileInputType::filesFromFormControlState(state); 181 return FileInputType::filesFromFormControlState(state);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 m_inputType = newType.release(); 425 m_inputType = newType.release();
425 if (hasAuthorShadowRoot()) 426 if (hasAuthorShadowRoot())
426 m_inputTypeView = InputTypeView::create(*this); 427 m_inputTypeView = InputTypeView::create(*this);
427 else 428 else
428 m_inputTypeView = m_inputType; 429 m_inputTypeView = m_inputType;
429 m_inputTypeView->createShadowSubtree(); 430 m_inputTypeView->createShadowSubtree();
430 431
431 bool hasTouchEventHandler = m_inputTypeView->hasTouchEventHandler(); 432 bool hasTouchEventHandler = m_inputTypeView->hasTouchEventHandler();
432 if (hasTouchEventHandler != m_hasTouchEventHandler) { 433 if (hasTouchEventHandler != m_hasTouchEventHandler) {
433 if (hasTouchEventHandler) 434 if (hasTouchEventHandler)
434 document().didAddTouchEventHandler(this); 435 EventHandlerRegistry::from(document())->didAddEventHandler(*this, Ev entHandlerRegistry::TouchEvent);
435 else 436 else
436 document().didRemoveTouchEventHandler(this); 437 EventHandlerRegistry::from(document())->didRemoveEventHandler(*this, EventHandlerRegistry::TouchEvent);
437 m_hasTouchEventHandler = hasTouchEventHandler; 438 m_hasTouchEventHandler = hasTouchEventHandler;
438 } 439 }
439 440
440 setNeedsWillValidateCheck(); 441 setNeedsWillValidateCheck();
441 442
442 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute(); 443 bool willStoreValue = m_inputType->storesValueSeparateFromAttribute();
443 444
444 if (didStoreValue && !willStoreValue && hasDirtyValue()) { 445 if (didStoreValue && !willStoreValue && hasDirtyValue()) {
445 setAttribute(valueAttr, AtomicString(m_valueIfDirty)); 446 setAttribute(valueAttr, AtomicString(m_valueIfDirty));
446 m_valueIfDirty = String(); 447 m_valueIfDirty = String();
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 } 1441 }
1441 1442
1442 void HTMLInputElement::didMoveToNewDocument(Document& oldDocument) 1443 void HTMLInputElement::didMoveToNewDocument(Document& oldDocument)
1443 { 1444 {
1444 if (hasImageLoader()) 1445 if (hasImageLoader())
1445 imageLoader()->elementDidMoveToNewDocument(); 1446 imageLoader()->elementDidMoveToNewDocument();
1446 1447
1447 if (isRadioButton()) 1448 if (isRadioButton())
1448 oldDocument.formController().radioButtonGroupScope().removeButton(this); 1449 oldDocument.formController().radioButtonGroupScope().removeButton(this);
1449 if (m_hasTouchEventHandler) 1450 if (m_hasTouchEventHandler)
1450 oldDocument.didRemoveTouchEventHandler(this); 1451 EventHandlerRegistry::from(oldDocument)->didRemoveEventHandler(*this, Ev entHandlerRegistry::TouchEvent);
1451 1452
1452 if (m_hasTouchEventHandler) 1453 if (m_hasTouchEventHandler)
1453 document().didAddTouchEventHandler(this); 1454 EventHandlerRegistry::from(document())->didAddEventHandler(*this, EventH andlerRegistry::TouchEvent);
1454 1455
1455 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument); 1456 HTMLTextFormControlElement::didMoveToNewDocument(oldDocument);
1456 } 1457 }
1457 1458
1458 void HTMLInputElement::removeAllEventListeners() 1459 void HTMLInputElement::removeAllEventListeners()
1459 { 1460 {
1460 HTMLTextFormControlElement::removeAllEventListeners(); 1461 HTMLTextFormControlElement::removeAllEventListeners();
1461 m_hasTouchEventHandler = false; 1462 m_hasTouchEventHandler = false;
1462 } 1463 }
1463 1464
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 } 1881 }
1881 1882
1882 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) 1883 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
1883 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer() 1884 PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
1884 { 1885 {
1885 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer()); 1886 return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer());
1886 } 1887 }
1887 #endif 1888 #endif
1888 1889
1889 } // namespace 1890 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698