Changes between Version 19 and Version 20 of Modules
- Timestamp:
- Feb 27, 2012, 11:43:58 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Modules
v19 v20 23 23 Sometimes a module needs to associate state with a core object, such as Page or Navigator. Typically, this state doesn't interact with any of the other state associated with this object and simply piggybacks on the lifetime of the core object. Rather than bloating the core objects with your feature-specific state, you can associate your feature's data with the core object using [http://trac.webkit.org/browser/trunk/Source/WebCore/platform/Supplementable.h Supplementable.h]. This mechanism allocates your data lazily, which saves memory on pages that don't use your feature. 24 24 25 For example, the Gampad module...25 For example, the [http://trac.webkit.org/browser/trunk/Source/WebCore/Modules/gamepad/ Gampad] module needs to associate a GamepadList with Navigator. Notice that in the [http://trac.webkit.org/browser/trunk/Source/WebCore/Modules/gamepad/NavigatorGamepad.h implementation] of its [http://trac.webkit.org/browser/trunk/Source/WebCore/Modules/gamepad/NavigatorGamepad.idl supplemental interface], the Gamepad module declares that NavigatorGamepad inherits from Supplement<Navigator>, which lets us store NavigatorGamepad in [http://trac.webkit.org/browser/trunk/Source/WebCore/platform/Supplementable.h Navigator's m_supplements HashMap]. 26 26 27 27 == Observing the lifecycle of "core" objects ==