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

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: Fix oilpan compilation. 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
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 3896 matching lines...) Expand 10 before | Expand all | Expand 10 after
3907 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ()); 3907 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ());
3908 } 3908 }
3909 3909
3910 void Document::enqueueResizeEvent() 3910 void Document::enqueueResizeEvent()
3911 { 3911 {
3912 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::resize); 3912 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::resize);
3913 event->setTarget(domWindow()); 3913 event->setTarget(domWindow());
3914 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); 3914 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release());
3915 } 3915 }
3916 3916
3917 Document::EventFactorySet& Document::eventFactories()
3918 {
3919 DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ());
3920 return s_eventFactory;
3921 }
3922
3923 void Document::registerEventFactory(EventFactoryBase* eventFactory)
3924 {
3925 ASSERT(!eventFactories().contains(eventFactory));
3926 eventFactories().add(eventFactory);
3927 }
3928
3917 PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, Exc eptionState& exceptionState) 3929 PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, Exc eptionState& exceptionState)
3918 { 3930 {
3919 RefPtrWillBeRawPtr<Event> event = EventFactory::create(eventType); 3931 RefPtrWillBeRawPtr<Event> event = nullptr;
3920 if (event) 3932 for (EventFactorySet::const_iterator it = eventFactories().begin(); it != ev entFactories().end(); ++it) {
3921 return event.release(); 3933 event = (*it)->create(eventType);
3922 3934 if (event)
3935 return event.release();
3936 }
3923 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid."); 3937 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid.");
3924 return nullptr; 3938 return nullptr;
3925 } 3939 }
3926 3940
3927 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) 3941 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType)
3928 { 3942 {
3929 if (ContextFeatures::mutationEventsEnabled(this)) 3943 if (ContextFeatures::mutationEventsEnabled(this))
3930 addListenerType(listenerType); 3944 addListenerType(listenerType);
3931 } 3945 }
3932 3946
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after
5794 visitor->trace(m_timeline); 5808 visitor->trace(m_timeline);
5795 visitor->trace(m_compositorPendingAnimations); 5809 visitor->trace(m_compositorPendingAnimations);
5796 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5810 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5797 DocumentSupplementable::trace(visitor); 5811 DocumentSupplementable::trace(visitor);
5798 TreeScope::trace(visitor); 5812 TreeScope::trace(visitor);
5799 ContainerNode::trace(visitor); 5813 ContainerNode::trace(visitor);
5800 ExecutionContext::trace(visitor); 5814 ExecutionContext::trace(visitor);
5801 } 5815 }
5802 5816
5803 } // namespace WebCore 5817 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698