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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 305723002: Use method registration approach for creating events on core and modules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaseline Created 6 years, 6 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
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 3904 matching lines...) Expand 10 before | Expand all | Expand 10 after
3915 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ()); 3915 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ());
3916 } 3916 }
3917 3917
3918 void Document::enqueueResizeEvent() 3918 void Document::enqueueResizeEvent()
3919 { 3919 {
3920 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::resize); 3920 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::resize);
3921 event->setTarget(domWindow()); 3921 event->setTarget(domWindow());
3922 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); 3922 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release());
3923 } 3923 }
3924 3924
3925 Document::EventFactorySet& Document::eventFactories()
3926 {
3927 DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ());
3928 return s_eventFactory;
3929 }
3930
3931 void Document::registerEventFactory(EventFactoryBase* eventFactory)
3932 {
3933 ASSERT(!eventFactories().contains(eventFactory));
3934 eventFactories().add(eventFactory);
3935 }
3936
3925 PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, Exc eptionState& exceptionState) 3937 PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, Exc eptionState& exceptionState)
3926 { 3938 {
3927 RefPtrWillBeRawPtr<Event> event = EventFactory::create(eventType); 3939 RefPtrWillBeRawPtr<Event> event = nullptr;
3928 if (event) 3940 for (EventFactorySet::const_iterator it = eventFactories().begin(); it != ev entFactories().end(); ++it) {
3929 return event.release(); 3941 event = (*it)->create(eventType);
3930 3942 if (event)
3943 return event.release();
3944 }
3931 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid."); 3945 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid.");
3932 return nullptr; 3946 return nullptr;
3933 } 3947 }
3934 3948
3935 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) 3949 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType)
3936 { 3950 {
3937 if (ContextFeatures::mutationEventsEnabled(this)) 3951 if (ContextFeatures::mutationEventsEnabled(this))
3938 addListenerType(listenerType); 3952 addListenerType(listenerType);
3939 } 3953 }
3940 3954
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
5801 visitor->trace(m_timeline); 5815 visitor->trace(m_timeline);
5802 visitor->trace(m_compositorPendingAnimations); 5816 visitor->trace(m_compositorPendingAnimations);
5803 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5817 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5804 DocumentSupplementable::trace(visitor); 5818 DocumentSupplementable::trace(visitor);
5805 TreeScope::trace(visitor); 5819 TreeScope::trace(visitor);
5806 ContainerNode::trace(visitor); 5820 ContainerNode::trace(visitor);
5807 ExecutionContext::trace(visitor); 5821 ExecutionContext::trace(visitor);
5808 } 5822 }
5809 5823
5810 } // namespace WebCore 5824 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698