= The Care and Feeding of WebCore Modules = == Overview == As we add more features to WebCore, the project becomes more complex. Some self-contained features, like IndexedDB and MediaStream, expose DOM interfaces but aren't otherwise involved in the core functionality of the engine, such as layout and rendering. The module system let us reduce the complexity of the project by loosening the coupling of between these features and the rest of WebCore. This document describes how WebCore's module system works and how to leverage it when building a new feature. == Dependency diagram == The code for a module belongs in a subdirectory of the [http://trac.webkit.org/browser/trunk/Source/WebCore/Modules/ Modules] directory and in a subdirectory of [http://trac.webkit.org/browser/trunk/Source/WebCore/platform/ WebCore/platform]. For example, the MediaStream module is contained in http://trac.webkit.org/browser/trunk/Source/WebCore/Modules/mediastream and http://trac.webkit.org/browser/trunk/Source/WebCore/platform/mediastream. Keeping the code for your feature in a single directory reduces the burden that your feature places on other WebKit contributors as they develop other modules and core functionality of the engine. This [https://docs.google.com/drawings/d/10WlCj2J3arxf4cDGRKteNinaP755iFnmYtYtnNSCQOY/edit?authkey=CP6plYAI dependency diagram] shows how the WebAudio, MediaStream, and IndexedDB modules fit into the WebKit's dependency diagram. Notice, in particular, that WebCore proper ''should not'' have dependencies on your module. == Associating JavaScript APIs with "core" objects == * http://trac.webkit.org/wiki/WebKitIDL#Supplemental == Associating state with "core" objects == * http://trac.webkit.org/browser/trunk/Source/WebCore/platform/Supplementable.h == Observing the lifecycle of "core" objects == * http://trac.webkit.org/browser/trunk/Source/WebCore/page/FrameDestructionObserver.h * http://trac.webkit.org/browser/trunk/Source/WebCore/dom/ContextDestructionObserver.h * http://trac.webkit.org/browser/trunk/Source/WebCore/dom/ActiveDOMObject.h == Adding new events and exceptions == * http://trac.webkit.org/browser/trunk/Source/WebCore/dom/EventFactory.in (should be EventNames.in) * http://trac.webkit.org/browser/trunk/Source/WebCore/dom/DOMExceptions.in