Changeset 84527 in webkit


Ignore:
Timestamp:
Apr 21, 2011 11:29:12 AM (13 years ago)
Author:
ggaren@apple.com
Message:

2011-04-20 Geoffrey Garen <ggaren@apple.com>

Reviewed by Oliver Hunt.

Removed a use of markDOMObjectWrapper: CSS Object Model
https://bugs.webkit.org/show_bug.cgi?id=59057

This is 24 hours of my life I will never get back. Thank you, W3C.

  • GNUmakefile.list.am:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj: Build!
  • bindings/js/JSCSSFontFaceRuleCustom.cpp:
  • bindings/js/JSCSSImportRuleCustom.cpp:
  • bindings/js/JSCSSMediaRuleCustom.cpp:
  • bindings/js/JSCSSPageRuleCustom.cpp:
  • bindings/js/JSCSSRuleCustom.cpp: (WebCore::JSCSSRuleOwner::isReachableFromOpaqueRoots): (WebCore::JSCSSRuleOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::JSCSSRule::markChildren):
  • bindings/js/JSCSSRuleListCustom.cpp: (WebCore::JSCSSRuleListOwner::isReachableFromOpaqueRoots): (WebCore::JSCSSRuleListOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::toJS):
  • bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclarationOwner::isReachableFromOpaqueRoots): (WebCore::JSCSSStyleDeclarationOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::JSCSSStyleDeclaration::markChildren): Removed custom mark functions, and replaced with use of the opaque roots system. This has the nice benefit of allowing us to eagerly recycle far more CSS wrappers and their associated DOM wrappers.

(WebCore::JSCSSStyleDeclaration::getPropertyCSSValue): Made this function
custom because it must maintain the sorrowful invariant that primitive
values can be mapped back to objects that are reachable through the DOM.
We maintain this invariant through an external hash table because
making all primitive values bigger would be a too-large memory use
penalty. Luckily, nobody uses this feature, so the cost of the hash table
is no big deal.

(WebCore::toJS): We need a custom toJS so we can specify our own WeakHandleOwner.

  • bindings/js/JSCSSStyleRuleCustom.cpp: Removed custom mark, as above.
  • bindings/js/JSCSSValueCustom.cpp: (WebCore::cssValueRoots): (WebCore::JSCSSValueOwner::isReachableFromOpaqueRoots): (WebCore::JSCSSValueOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): Use the opaque roots system. Piggy-back on the external hash table filled by JSCSSStyleDeclaration::getPropertyCSSValue.
  • bindings/js/JSDocumentCustom.cpp: (WebCore::JSDocument::markChildren): No need to mark our stylesheet list, since all style-related objects can use our opaque root to determine liveness.
  • bindings/js/JSMediaListCustom.cpp: Added. (WebCore::JSMediaListOwner::isReachableFromOpaqueRoots): (WebCore::JSMediaListOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::toJS): Use the opaque roots system.
  • bindings/js/JSNodeCustom.h: (WebCore::root): Added helpers for computing style-related roots.
  • bindings/js/JSStyleSheetCustom.cpp: (WebCore::JSStyleSheetOwner::isReachableFromOpaqueRoots): (WebCore::JSStyleSheetOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::JSStyleSheet::markChildren): Use the opaque roots system instead of direct marking.


  • bindings/js/JSStyleSheetListCustom.cpp: (WebCore::JSStyleSheetListOwner::isReachableFromOpaqueRoots): (WebCore::JSStyleSheetListOwner::finalize): (WebCore::wrapperOwner): (WebCore::wrapperContext): (WebCore::toJS): Ditto.
  • bindings/js/JSWebKitCSSKeyframeRuleCustom.cpp:
  • bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp:
  • css/CSSFontFaceRule.idl:
  • css/CSSImportRule.idl: No more custom mark, since we use the opaque roots system instead.
  • css/CSSMediaRule.cpp: (WebCore::CSSMediaRule::CSSMediaRule): Fixed a bug where a media rule would incorrectly have no parent, since this got in the way of correctly computing the media rule's root.
  • css/CSSMediaRule.idl:
  • css/CSSPageRule.idl:
  • css/CSSRuleList.idl:
  • css/CSSStyleDeclaration.idl:
  • css/CSSStyleRule.idl:
  • css/MediaList.idl: Match behavior changes above.
  • css/StyleBase.cpp: (WebCore::StyleBase::node): Helper function for computing roots of the style system. This object model is pretty weird and not very well factored, but I'm pretty sure this covers all the relevant cases.
  • css/StyleBase.h:
  • css/StyleSheetList.idl:
  • css/WebKitCSSKeyframeRule.idl:
  • css/WebKitCSSKeyframesRule.idl: Updated to match the behavior changes above.
Location:
trunk/Source/WebCore
Files:
1 added
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84522 r84527  
     12011-04-20  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Removed a use of markDOMObjectWrapper: CSS Object Model
     6        https://bugs.webkit.org/show_bug.cgi?id=59057
     7
     8        This is 24 hours of my life I will never get back. Thank you, W3C.
     9
     10        * GNUmakefile.list.am:
     11        * WebCore.gypi:
     12        * WebCore.vcproj/WebCore.vcproj:
     13        * WebCore.xcodeproj/project.pbxproj: Build!
     14
     15        * bindings/js/JSCSSFontFaceRuleCustom.cpp:
     16        * bindings/js/JSCSSImportRuleCustom.cpp:
     17        * bindings/js/JSCSSMediaRuleCustom.cpp:
     18        * bindings/js/JSCSSPageRuleCustom.cpp:
     19        * bindings/js/JSCSSRuleCustom.cpp:
     20        (WebCore::JSCSSRuleOwner::isReachableFromOpaqueRoots):
     21        (WebCore::JSCSSRuleOwner::finalize):
     22        (WebCore::wrapperOwner):
     23        (WebCore::wrapperContext):
     24        (WebCore::JSCSSRule::markChildren):
     25        * bindings/js/JSCSSRuleListCustom.cpp:
     26        (WebCore::JSCSSRuleListOwner::isReachableFromOpaqueRoots):
     27        (WebCore::JSCSSRuleListOwner::finalize):
     28        (WebCore::wrapperOwner):
     29        (WebCore::wrapperContext):
     30        (WebCore::toJS):
     31        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
     32        (WebCore::JSCSSStyleDeclarationOwner::isReachableFromOpaqueRoots):
     33        (WebCore::JSCSSStyleDeclarationOwner::finalize):
     34        (WebCore::wrapperOwner):
     35        (WebCore::wrapperContext):
     36        (WebCore::JSCSSStyleDeclaration::markChildren): Removed custom mark functions,
     37        and replaced with use of the opaque roots system. This has the nice benefit
     38        of allowing us to eagerly recycle far more CSS wrappers and their associated
     39        DOM wrappers.
     40
     41        (WebCore::JSCSSStyleDeclaration::getPropertyCSSValue): Made this function
     42        custom because it must maintain the sorrowful invariant that primitive
     43        values can be mapped back to objects that are reachable through the DOM.
     44        We maintain this invariant through an external hash table because
     45        making all primitive values bigger would be a too-large memory use
     46        penalty. Luckily, nobody uses this feature, so the cost of the hash table
     47        is no big deal.
     48
     49        (WebCore::toJS): We need a custom toJS so we can specify our own WeakHandleOwner.
     50
     51        * bindings/js/JSCSSStyleRuleCustom.cpp: Removed custom mark, as above.
     52
     53        * bindings/js/JSCSSValueCustom.cpp:
     54        (WebCore::cssValueRoots):
     55        (WebCore::JSCSSValueOwner::isReachableFromOpaqueRoots):
     56        (WebCore::JSCSSValueOwner::finalize):
     57        (WebCore::wrapperOwner):
     58        (WebCore::wrapperContext): Use the opaque roots system. Piggy-back on
     59        the external hash table filled by JSCSSStyleDeclaration::getPropertyCSSValue.
     60
     61        * bindings/js/JSDocumentCustom.cpp:
     62        (WebCore::JSDocument::markChildren): No need to mark our stylesheet list,
     63        since all style-related objects can use our opaque root to determine
     64        liveness.
     65
     66        * bindings/js/JSMediaListCustom.cpp: Added.
     67        (WebCore::JSMediaListOwner::isReachableFromOpaqueRoots):
     68        (WebCore::JSMediaListOwner::finalize):
     69        (WebCore::wrapperOwner):
     70        (WebCore::wrapperContext):
     71        (WebCore::toJS): Use the opaque roots system.
     72
     73        * bindings/js/JSNodeCustom.h:
     74        (WebCore::root): Added helpers for computing style-related roots.
     75
     76        * bindings/js/JSStyleSheetCustom.cpp:
     77        (WebCore::JSStyleSheetOwner::isReachableFromOpaqueRoots):
     78        (WebCore::JSStyleSheetOwner::finalize):
     79        (WebCore::wrapperOwner):
     80        (WebCore::wrapperContext):
     81        (WebCore::JSStyleSheet::markChildren): Use the opaque roots system instead
     82        of direct marking.
     83       
     84        * bindings/js/JSStyleSheetListCustom.cpp:
     85        (WebCore::JSStyleSheetListOwner::isReachableFromOpaqueRoots):
     86        (WebCore::JSStyleSheetListOwner::finalize):
     87        (WebCore::wrapperOwner):
     88        (WebCore::wrapperContext):
     89        (WebCore::toJS): Ditto.
     90
     91        * bindings/js/JSWebKitCSSKeyframeRuleCustom.cpp:
     92        * bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp:
     93        * css/CSSFontFaceRule.idl:
     94        * css/CSSImportRule.idl: No more custom mark, since we use the opaque
     95        roots system instead.
     96
     97        * css/CSSMediaRule.cpp:
     98        (WebCore::CSSMediaRule::CSSMediaRule): Fixed a bug where a media rule
     99        would incorrectly have no parent, since this got in the way of correctly
     100        computing the media rule's root.
     101
     102        * css/CSSMediaRule.idl:
     103        * css/CSSPageRule.idl:
     104        * css/CSSRuleList.idl:
     105        * css/CSSStyleDeclaration.idl:
     106        * css/CSSStyleRule.idl:
     107        * css/MediaList.idl: Match behavior changes above.
     108
     109        * css/StyleBase.cpp:
     110        (WebCore::StyleBase::node): Helper function for computing roots of the
     111        style system. This object model is pretty weird and not very well factored,
     112        but I'm pretty sure this covers all the relevant cases.
     113
     114        * css/StyleBase.h:
     115        * css/StyleSheetList.idl:
     116        * css/WebKitCSSKeyframeRule.idl:
     117        * css/WebKitCSSKeyframesRule.idl: Updated to match the behavior changes above.
     118
    11192011-04-21  Dirk Schulze  <krit@webkit.org>
    2120
  • trunk/Source/WebCore/GNUmakefile.list.am

    r84522 r84527  
    761761        Source/WebCore/bindings/js/JSMainThreadExecState.cpp \
    762762        Source/WebCore/bindings/js/JSMainThreadExecState.h \
     763        Source/WebCore/bindings/js/JSMediaListCustom.cpp \
    763764        Source/WebCore/bindings/js/JSMemoryInfoCustom.cpp \
    764765        Source/WebCore/bindings/js/JSMessageChannelCustom.cpp \
  • trunk/Source/WebCore/UseJSC.cmake

    r83792 r84527  
    1919    bindings/js/JSCSSFontFaceRuleCustom.cpp
    2020    bindings/js/JSCSSImportRuleCustom.cpp
     21    bindings/js/JSCSSMediaListCustom.cpp
    2122    bindings/js/JSCSSMediaRuleCustom.cpp
    2223    bindings/js/JSCSSPageRuleCustom.cpp
  • trunk/Source/WebCore/WebCore.gypi

    r84522 r84527  
    18251825            'bindings/js/JSMainThreadExecState.cpp',
    18261826            'bindings/js/JSMainThreadExecState.h',
     1827            'bindings/js/JSMediaListCustom.cpp',
    18271828            'bindings/js/JSMemoryInfoCustom.cpp',
    18281829            'bindings/js/JSMessageChannelCustom.cpp',
  • trunk/Source/WebCore/WebCore.pro

    r84522 r84527  
    239239        bindings/js/JSCSSFontFaceRuleCustom.cpp \
    240240        bindings/js/JSCSSImportRuleCustom.cpp \
     241        bindings/js/JSCSSMediaListCustom.cpp \
    241242        bindings/js/JSCSSMediaRuleCustom.cpp \
    242243        bindings/js/JSCSSPageRuleCustom.cpp \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r84522 r84527  
    6149461494                                </File>
    6149561495                                <File
     61496                                        RelativePath="..\bindings\js\JSMediaListCustom.cpp"
     61497                                        >
     61498                                        <FileConfiguration
     61499                                                Name="Debug|Win32"
     61500                                                ExcludedFromBuild="true"
     61501                                                >
     61502                                                <Tool
     61503                                                        Name="VCCLCompilerTool"
     61504                                                />
     61505                                        </FileConfiguration>
     61506                                        <FileConfiguration
     61507                                                Name="Release|Win32"
     61508                                                ExcludedFromBuild="true"
     61509                                                >
     61510                                                <Tool
     61511                                                        Name="VCCLCompilerTool"
     61512                                                />
     61513                                        </FileConfiguration>
     61514                                        <FileConfiguration
     61515                                                Name="Debug_Cairo_CFLite|Win32"
     61516                                                ExcludedFromBuild="true"
     61517                                                >
     61518                                                <Tool
     61519                                                        Name="VCCLCompilerTool"
     61520                                                />
     61521                                        </FileConfiguration>
     61522                                        <FileConfiguration
     61523                                                Name="Release_Cairo_CFLite|Win32"
     61524                                                ExcludedFromBuild="true"
     61525                                                >
     61526                                                <Tool
     61527                                                        Name="VCCLCompilerTool"
     61528                                                />
     61529                                        </FileConfiguration>
     61530                                        <FileConfiguration
     61531                                                Name="Debug_All|Win32"
     61532                                                ExcludedFromBuild="true"
     61533                                                >
     61534                                                <Tool
     61535                                                        Name="VCCLCompilerTool"
     61536                                                />
     61537                                        </FileConfiguration>
     61538                                        <FileConfiguration
     61539                                                Name="Production|Win32"
     61540                                                ExcludedFromBuild="true"
     61541                                                >
     61542                                                <Tool
     61543                                                        Name="VCCLCompilerTool"
     61544                                                />
     61545                                        </FileConfiguration>
     61546                                </File>
     61547                                <File
    6149661548                                        RelativePath="..\bindings\js\JSMemoryInfoCustom.cpp"
    6149761549                                        >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r84522 r84527  
    299299                1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1449E24A107D4A8400B5793F /* JSCallbackData.h */; };
    300300                1449E287107D4DB400B5793F /* JSCallbackData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1449E286107D4DB400B5793F /* JSCallbackData.cpp */; };
     301                1464E06C135EC10600FDB00A /* JSMediaListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1464E06B135EC10600FDB00A /* JSMediaListCustom.cpp */; };
    301302                1477E7760BF4134A00152872 /* PageCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1477E7740BF4134A00152872 /* PageCache.cpp */; };
    302303                1477E7770BF4134A00152872 /* PageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1477E7750BF4134A00152872 /* PageCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    67486749                1449E24A107D4A8400B5793F /* JSCallbackData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackData.h; sourceTree = "<group>"; };
    67496750                1449E286107D4DB400B5793F /* JSCallbackData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackData.cpp; sourceTree = "<group>"; };
     6751                1464E06B135EC10600FDB00A /* JSMediaListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaListCustom.cpp; sourceTree = "<group>"; };
    67506752                1477E7740BF4134A00152872 /* PageCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PageCache.cpp; sourceTree = "<group>"; };
    67516753                1477E7750BF4134A00152872 /* PageCache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PageCache.h; sourceTree = "<group>"; };
     
    1820418206                                8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */,
    1820518207                                8F934D831189F1EE00508D5D /* JSMainThreadExecState.h */,
     18208                                1464E06B135EC10600FDB00A /* JSMediaListCustom.cpp */,
    1820618209                                9FDC8FF112FAB0060099AB1C /* JSMemoryInfoCustom.cpp */,
    1820718210                                93B70D4F09EB0C7C009D8468 /* JSPluginElementFunctions.cpp */,
     
    2577025773                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
    2577125774                                977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */,
     25775                                1464E06C135EC10600FDB00A /* JSMediaListCustom.cpp in Sources */,
    2577225776                                087E0AF613606D0B00FA4BA8 /* SVGGlyph.cpp in Sources */,
    2577325777                                4358E86B1360A21600E4748C /* DOMSVGFEDropShadowElement.mm in Sources */,
  • trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r83079 r84527  
    114114#include "JSLocationCustom.cpp"
    115115#include "JSMainThreadExecState.cpp"
     116#include "JSMediaListCustom.cpp"
    116117#include "JSMemoryInfoCustom.cpp"
    117118#include "JSMessageChannelCustom.cpp"
  • trunk/Source/WebCore/bindings/js/JSCSSFontFaceRuleCustom.cpp

    r72590 r84527  
    3333namespace WebCore {
    3434
    35 void JSCSSFontFaceRule::markChildren(MarkStack& markStack)
    36 {
    37     Base::markChildren(markStack);
    38 
    39     if (CSSMutableStyleDeclaration* style = static_cast<CSSFontFaceRule*>(impl())->style())
    40         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), style);
    4135}
    42 
    43 }
  • trunk/Source/WebCore/bindings/js/JSCSSImportRuleCustom.cpp

    r72590 r84527  
    3333namespace WebCore {
    3434
    35 void JSCSSImportRule::markChildren(MarkStack& markStack)
    36 {
    37     Base::markChildren(markStack);
    38 
    39     if (CSSStyleSheet* sheet = static_cast<CSSImportRule*>(impl())->styleSheet())
    40         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), sheet);
    41 
    42     if (MediaList* media = static_cast<CSSImportRule*>(impl())->media())
    43         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), media);
    4435}
    45 
    46 }
  • trunk/Source/WebCore/bindings/js/JSCSSMediaRuleCustom.cpp

    r72590 r84527  
    3333namespace WebCore {
    3434
    35 void JSCSSMediaRule::markChildren(MarkStack& markStack)
    36 {
    37     Base::markChildren(markStack);
    38 
    39     if (MediaList* media = static_cast<CSSMediaRule*>(impl())->media())
    40         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), media);
    41 
    42     if (CSSRuleList* rules = static_cast<CSSMediaRule*>(impl())->cssRules())
    43         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), rules);
    4435}
    45 
    46 }
  • trunk/Source/WebCore/bindings/js/JSCSSPageRuleCustom.cpp

    r72590 r84527  
    3333namespace WebCore {
    3434
    35 void JSCSSPageRule::markChildren(MarkStack& markStack)
    36 {
    37     Base::markChildren(markStack);
    38 
    39     if (CSSMutableStyleDeclaration* style = static_cast<CSSPageRule*>(impl())->style())
    40         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), style);
    4135}
    42 
    43 }
  • trunk/Source/WebCore/bindings/js/JSCSSRuleCustom.cpp

    r84194 r84527  
    3939#include "JSCSSPageRule.h"
    4040#include "JSCSSStyleRule.h"
     41#include "JSNode.h"
    4142#include "JSWebKitCSSKeyframeRule.h"
    4243#include "JSWebKitCSSKeyframesRule.h"
     
    4849namespace WebCore {
    4950
     51class JSCSSRuleOwner : public JSC::WeakHandleOwner {
     52    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     53    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     54};
     55
     56bool JSCSSRuleOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, MarkStack& markStack)
     57{
     58    JSCSSRule* jsCSSRule = static_cast<JSCSSRule*>(handle.get().asCell());
     59    if (!jsCSSRule->hasCustomProperties())
     60        return false;
     61    return markStack.containsOpaqueRoot(root(jsCSSRule->impl()));
     62}
     63
     64void JSCSSRuleOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     65{
     66    JSCSSRule* jsCSSRule = static_cast<JSCSSRule*>(handle.get().asCell());
     67    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     68    uncacheWrapper(world, jsCSSRule->impl(), jsCSSRule);
     69}
     70
     71inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, CSSRule*)
     72{
     73    DEFINE_STATIC_LOCAL(JSCSSRuleOwner, jsCSSRuleOwner, ());
     74    return &jsCSSRuleOwner;
     75}
     76
     77inline void* wrapperContext(DOMWrapperWorld* world, CSSRule*)
     78{
     79    return world;
     80}
     81
    5082void JSCSSRule::markChildren(MarkStack& markStack)
    5183{
    5284    Base::markChildren(markStack);
    53 
    54     if (CSSStyleSheet* parentStyleSheet = impl()->parentStyleSheet())
    55         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), parentStyleSheet);
    56 
    57     if (CSSRule* parentRule = impl()->parentRule())
    58         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), parentRule);
     85    markStack.addOpaqueRoot(root(impl()));
    5986}
    6087
  • trunk/Source/WebCore/bindings/js/JSCSSRuleListCustom.cpp

    r47165 r84527  
    2727#include "JSCSSRuleList.h"
    2828
     29#include "CSSRule.h"
    2930#include "CSSRuleList.h"
     31#include "JSNode.h"
     32#include "StyleList.h"
    3033
    3134using namespace JSC;
     
    3336namespace WebCore {
    3437
    35 void JSCSSRuleList::markChildren(MarkStack& markStack)
     38class JSCSSRuleListOwner : public JSC::WeakHandleOwner {
     39    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     40    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     41};
     42
     43bool JSCSSRuleListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, MarkStack& markStack)
    3644{
    37     Base::markChildren(markStack);
     45    JSCSSRuleList* jsCSSRuleList = static_cast<JSCSSRuleList*>(handle.get().asCell());
     46    if (!jsCSSRuleList->hasCustomProperties())
     47        return false;
     48    if (StyleList* styleList = jsCSSRuleList->impl()->styleList())
     49        return markStack.containsOpaqueRoot(root(styleList));
     50    if (CSSRule* cssRule = jsCSSRuleList->impl()->item(0))
     51        return markStack.containsOpaqueRoot(root(cssRule));
     52    return false;
     53}
    3854
    39     CSSRuleList* list = impl();
    40     JSGlobalData& globalData = *Heap::heap(this)->globalData();
     55void JSCSSRuleListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     56{
     57    JSCSSRuleList* jsCSSRuleList = static_cast<JSCSSRuleList*>(handle.get().asCell());
     58    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     59    uncacheWrapper(world, jsCSSRuleList->impl(), jsCSSRuleList);
     60}
    4161
    42     unsigned length = list->length();
    43     for (unsigned i = 0; i < length; ++i)
    44         markDOMObjectWrapper(markStack, globalData, list->item(i));
     62inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, CSSRuleList*)
     63{
     64    DEFINE_STATIC_LOCAL(JSCSSRuleListOwner, jsCSSRuleListOwner, ());
     65    return &jsCSSRuleListOwner;
     66}
     67
     68inline void* wrapperContext(DOMWrapperWorld* world, CSSRuleList*)
     69{
     70    return world;
     71}
     72
     73JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, CSSRuleList* impl)
     74{
     75    return wrap<JSCSSRuleList>(exec, globalObject, impl);
    4576}
    4677
  • trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp

    r83119 r84527  
    3030#include "CSSPrimitiveValue.h"
    3131#include "CSSValue.h"
     32#include "JSCSSValue.h"
     33#include "JSNode.h"
    3234#include "PlatformString.h"
    3335#include <runtime/StringObjectThatMasqueradesAsUndefined.h>
     
    4345namespace WebCore {
    4446
     47class JSCSSStyleDeclarationOwner : public JSC::WeakHandleOwner {
     48    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     49    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     50};
     51
     52bool JSCSSStyleDeclarationOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, MarkStack& markStack)
     53{
     54    JSCSSStyleDeclaration* jsCSSStyleDeclaration = static_cast<JSCSSStyleDeclaration*>(handle.get().asCell());
     55    return markStack.containsOpaqueRoot(root(jsCSSStyleDeclaration->impl()));
     56}
     57
     58void JSCSSStyleDeclarationOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     59{
     60    JSCSSStyleDeclaration* jsCSSStyleDeclaration = static_cast<JSCSSStyleDeclaration*>(handle.get().asCell());
     61    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     62    uncacheWrapper(world, jsCSSStyleDeclaration->impl(), jsCSSStyleDeclaration);
     63}
     64
     65inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, CSSStyleDeclaration*)
     66{
     67    DEFINE_STATIC_LOCAL(JSCSSStyleDeclarationOwner, jsCSSStyleDeclarationOwner, ());
     68    return &jsCSSStyleDeclarationOwner;
     69}
     70
     71inline void* wrapperContext(DOMWrapperWorld* world, CSSStyleDeclaration*)
     72{
     73    return world;
     74}
     75
    4576void JSCSSStyleDeclaration::markChildren(MarkStack& markStack)
    4677{
    4778    Base::markChildren(markStack);
    48 
    49     CSSStyleDeclaration* declaration = impl();
    50     JSGlobalData& globalData = *Heap::heap(this)->globalData();
    51 
    52     if (CSSRule* parentRule = declaration->parentRule())
    53         markDOMObjectWrapper(markStack, globalData, parentRule);
    54 
    55     if (declaration->isMutableStyleDeclaration()) {
    56         CSSMutableStyleDeclaration* mutableDeclaration = static_cast<CSSMutableStyleDeclaration*>(declaration);
    57         CSSMutableStyleDeclaration::const_iterator end = mutableDeclaration->end();
    58         for (CSSMutableStyleDeclaration::const_iterator it = mutableDeclaration->begin(); it != end; ++it)
    59             markDOMObjectWrapper(markStack, globalData, it->value());
    60     }
     79    markStack.addOpaqueRoot(root(impl()));
    6180}
    6281
     
    176195}
    177196
    178 
    179197bool JSCSSStyleDeclaration::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot&)
    180198{
     
    193211}
    194212
     213JSValue JSCSSStyleDeclaration::getPropertyCSSValue(ExecState* exec)
     214{
     215    const String& propertyName(ustringToString(exec->argument(0).toString(exec)));
     216    if (exec->hadException())
     217        return jsUndefined();
     218
     219    RefPtr<CSSValue> cssValue = impl()->getPropertyCSSValue(propertyName);
     220    if (!cssValue)
     221        return jsNull();
     222
     223    cssValueRoots().add(cssValue.get(), root(impl())); // Balanced by JSCSSValueOwner::finalize().
     224    return toJS(exec, globalObject(), WTF::getPtr(cssValue));
     225}
     226
     227JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, CSSStyleDeclaration* impl)
     228{
     229    return wrap<JSCSSStyleDeclaration>(exec, globalObject, impl);
     230}
     231
    195232} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSCSSStyleRuleCustom.cpp

    r72590 r84527  
    3333namespace WebCore {
    3434
    35 void JSCSSStyleRule::markChildren(MarkStack& markStack)
    36 {
    37     Base::markChildren(markStack);
    38 
    39     if (CSSMutableStyleDeclaration* style = static_cast<CSSStyleRule*>(impl())->style())
    40         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), style);
    4135}
    42 
    43 }
  • trunk/Source/WebCore/bindings/js/JSCSSValueCustom.cpp

    r84194 r84527  
    3131#include "JSCSSPrimitiveValue.h"
    3232#include "JSCSSValueList.h"
     33#include "JSNode.h"
    3334#include "JSWebKitCSSTransformValue.h"
    3435#include "WebKitCSSTransformValue.h"
     
    4445
    4546namespace WebCore {
     47
     48HashMap<CSSValue*, void*>& cssValueRoots()
     49{
     50    typedef HashMap<CSSValue*, void*> MapType;
     51    DEFINE_STATIC_LOCAL(MapType, cssValueRoots, ());
     52    return cssValueRoots;
     53}
     54
     55class JSCSSValueOwner : public JSC::WeakHandleOwner {
     56    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     57    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     58};
     59
     60bool JSCSSValueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, MarkStack& markStack)
     61{
     62    JSCSSValue* jsCSSValue = static_cast<JSCSSValue*>(handle.get().asCell());
     63    if (!jsCSSValue->hasCustomProperties())
     64        return false;
     65    void* root = cssValueRoots().get(jsCSSValue->impl());
     66    if (!root)
     67        return false;
     68    return markStack.containsOpaqueRoot(root);
     69}
     70
     71void JSCSSValueOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     72{
     73    JSCSSValue* jsCSSValue = static_cast<JSCSSValue*>(handle.get().asCell());
     74    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     75    uncacheWrapper(world, jsCSSValue->impl(), jsCSSValue);
     76    cssValueRoots().remove(jsCSSValue->impl());
     77}
     78
     79inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, CSSValue*)
     80{
     81    DEFINE_STATIC_LOCAL(JSCSSValueOwner, jsCSSValueOwner, ());
     82    return &jsCSSValueOwner;
     83}
     84
     85inline void* wrapperContext(DOMWrapperWorld* world, CSSValue*)
     86{
     87    return world;
     88}
    4689
    4790JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, CSSValue* value)
  • trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp

    r84371 r84527  
    5757    markActiveObjectsForContext(markStack, globalData, document);
    5858    markDOMObjectWrapper(markStack, globalData, document->implementation());
    59     markDOMObjectWrapper(markStack, globalData, document->styleSheets());
    6059}
    6160
  • trunk/Source/WebCore/bindings/js/JSNodeCustom.h

    r84194 r84527  
    2828
    2929#include "JSDOMBinding.h"
     30#include "StyleBase.h"
    3031#include <wtf/AlwaysInline.h>
    3132
    3233namespace WebCore {
     34
     35class CSSValue;
    3336
    3437class JSNodeOwner : public JSC::WeakHandleOwner {
     
    8790}
    8891
    89 static inline Node* root(Node* node)
     92static inline void* root(Node* node)
    9093{
    9194    if (node->inDocument())
     
    97100}
    98101
     102static inline void* root(StyleBase* styleBase)
     103{
     104    while (styleBase->parent())
     105        styleBase = styleBase->parent();
     106
     107    if (Node* node = styleBase->node())
     108        return root(node);
     109    return styleBase;
     110}
     111
     112HashMap<CSSValue*, void*>& cssValueRoots();
     113
    99114}
    100115
  • trunk/Source/WebCore/bindings/js/JSStyleSheetCustom.cpp

    r84194 r84527  
    3636namespace WebCore {
    3737
     38class JSStyleSheetOwner : public JSC::WeakHandleOwner {
     39    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     40    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     41};
     42
     43bool JSStyleSheetOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, MarkStack& markStack)
     44{
     45    JSStyleSheet* jsStyleSheet = static_cast<JSStyleSheet*>(handle.get().asCell());
     46    if (!jsStyleSheet->hasCustomProperties())
     47        return false;
     48    return markStack.containsOpaqueRoot(root(jsStyleSheet->impl()));
     49}
     50
     51void JSStyleSheetOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     52{
     53    JSStyleSheet* jsStyleSheet = static_cast<JSStyleSheet*>(handle.get().asCell());
     54    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     55    uncacheWrapper(world, jsStyleSheet->impl(), jsStyleSheet);
     56}
     57
     58inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, StyleSheet*)
     59{
     60    DEFINE_STATIC_LOCAL(JSStyleSheetOwner, jsStyleSheetOwner, ());
     61    return &jsStyleSheetOwner;
     62}
     63
     64inline void* wrapperContext(DOMWrapperWorld* world, StyleSheet*)
     65{
     66    return world;
     67}
     68
     69void JSStyleSheet::markChildren(MarkStack& markStack)
     70{
     71    Base::markChildren(markStack);
     72    markStack.addOpaqueRoot(root(impl()));
     73}
     74
    3875JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, StyleSheet* styleSheet)
    3976{
     
    5390}
    5491
    55 void JSStyleSheet::markChildren(MarkStack& markStack)
    56 {
    57     Base::markChildren(markStack);
    58 
    59     StyleSheet* sheet = impl();
    60     JSGlobalData& globalData = *Heap::heap(this)->globalData();
    61 
    62     unsigned length = sheet->length();
    63     for (unsigned i = 0; i < length; ++i)
    64         markDOMObjectWrapper(markStack, globalData, sheet->item(i));
    65 }
    66 
    6792} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp

    r57738 r84527  
    3636namespace WebCore {
    3737
    38 void JSStyleSheetList::markChildren(MarkStack& markStack)
     38class JSStyleSheetListOwner : public JSC::WeakHandleOwner {
     39    virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::MarkStack&);
     40    virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
     41};
     42
     43bool JSStyleSheetListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, MarkStack& markStack)
    3944{
    40     Base::markChildren(markStack);
     45    JSStyleSheetList* jsStyleSheetList = static_cast<JSStyleSheetList*>(handle.get().asCell());
     46    if (!jsStyleSheetList->hasCustomProperties())
     47        return false;
     48    Document* document = jsStyleSheetList->impl()->document();
     49    if (!document)
     50        return false;
     51    return markStack.containsOpaqueRoot(document);
     52}
    4153
    42     StyleSheetList* list = impl();
    43     JSGlobalData& globalData = *Heap::heap(this)->globalData();
     54void JSStyleSheetListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
     55{
     56    JSStyleSheetList* jsStyleSheetList = static_cast<JSStyleSheetList*>(handle.get().asCell());
     57    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
     58    uncacheWrapper(world, jsStyleSheetList->impl(), jsStyleSheetList);
     59}
    4460
    45     unsigned length = list->length();
    46     for (unsigned i = 0; i < length; ++i)
    47         markDOMObjectWrapper(markStack, globalData, list->item(i));
     61inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, StyleSheetList*)
     62{
     63    DEFINE_STATIC_LOCAL(JSStyleSheetListOwner, jsStyleSheetListOwner, ());
     64    return &jsStyleSheetListOwner;
     65}
     66
     67inline void* wrapperContext(DOMWrapperWorld* world, StyleSheetList*)
     68{
     69    return world;
    4870}
    4971
     
    6183}
    6284
     85JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, StyleSheetList* impl)
     86{
     87    return wrap<JSStyleSheetList>(exec, globalObject, impl);
     88}
     89
    6390} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSWebKitCSSKeyframeRuleCustom.cpp

    r72590 r84527  
    3333namespace WebCore {
    3434
    35 void JSWebKitCSSKeyframeRule::markChildren(MarkStack& markStack)
    36 {
    37     Base::markChildren(markStack);
    38 
    39     if (CSSMutableStyleDeclaration* style = static_cast<WebKitCSSKeyframeRule*>(impl())->style())
    40         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), style);
    4135}
    42 
    43 }
  • trunk/Source/WebCore/bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp

    r72590 r84527  
    3333namespace WebCore {
    3434
    35 void JSWebKitCSSKeyframesRule::markChildren(MarkStack& markStack)
    36 {
    37     Base::markChildren(markStack);
    38 
    39     if (CSSRuleList* rules = static_cast<WebKitCSSKeyframesRule*>(impl())->cssRules())
    40         markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), rules);
    4135}
    42 
    43 }
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r84319 r84527  
    25542554    return 0 if $interfaceName eq "SVGElementInstance";
    25552555    return 0 if $interfaceName eq "NodeList";
     2556    return 0 if $interfaceName eq "CSSRuleList";
     2557    return 0 if $interfaceName eq "CSSStyleDeclaration";
     2558    return 0 if $interfaceName eq "MediaList";
     2559    return 0 if $interfaceName eq "StyleSheetList";
    25562560
    25572561    # For everything else, do what JSC does.
  • trunk/Source/WebCore/css/CSSFontFaceRule.idl

    r72590 r84527  
    2222
    2323    // Introduced in DOM Level 2:
    24     interface [CustomMarkFunction] CSSFontFaceRule : CSSRule {
     24    interface CSSFontFaceRule : CSSRule {
    2525        readonly attribute CSSStyleDeclaration style;
    2626    };
  • trunk/Source/WebCore/css/CSSImportRule.idl

    r72590 r84527  
    2222
    2323    // Introduced in DOM Level 2:
    24     interface [CustomMarkFunction] CSSImportRule : CSSRule {
     24    interface CSSImportRule : CSSRule {
    2525        readonly attribute [ConvertNullStringTo=Null] DOMString href;
    2626        readonly attribute MediaList media;
  • trunk/Source/WebCore/css/CSSMediaRule.cpp

    r76728 r84527  
    3434    , m_lstCSSRules(rules)
    3535{
     36    m_lstMedia->setParent(this);
    3637    int length = m_lstCSSRules->length();
    3738    for (int i = 0; i < length; i++)
  • trunk/Source/WebCore/css/CSSMediaRule.idl

    r72590 r84527  
    2222
    2323    // Introduced in DOM Level 2:
    24     interface [CustomMarkFunction] CSSMediaRule : CSSRule {
     24    interface CSSMediaRule : CSSRule {
    2525        readonly attribute MediaList media;
    2626        readonly attribute CSSRuleList cssRules;
  • trunk/Source/WebCore/css/CSSPageRule.idl

    r72590 r84527  
    2222
    2323    // Introduced in DOM Level 2:
    24     interface [CustomMarkFunction] CSSPageRule : CSSRule {
     24    interface CSSPageRule : CSSRule {
    2525
    2626                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString selectorText;
  • trunk/Source/WebCore/css/CSSRuleList.idl

    r52921 r84527  
    2828    // Introduced in DOM Level 2:
    2929    interface [
    30         CustomMarkFunction,
     30        CustomToJS,
    3131        HasIndexGetter
    3232    ] CSSRuleList {
  • trunk/Source/WebCore/css/CSSStyleDeclaration.idl

    r52921 r84527  
    2424    interface [
    2525        CustomMarkFunction,
     26        CustomToJS,
    2627        DelegatingPutFunction,
    2728        HasNameGetter,
     
    3233
    3334        [ConvertNullStringTo=Null] DOMString          getPropertyValue(in DOMString propertyName);
    34         CSSValue           getPropertyCSSValue(in DOMString propertyName);
     35        [JSCCustom] CSSValue           getPropertyCSSValue(in DOMString propertyName);
    3536        [ConvertNullStringTo=Null] DOMString          removeProperty(in DOMString propertyName)
    3637            raises(DOMException);
  • trunk/Source/WebCore/css/CSSStyleRule.idl

    r72590 r84527  
    2222
    2323    // Introduced in DOM Level 2:
    24     interface [CustomMarkFunction] CSSStyleRule : CSSRule {
     24    interface CSSStyleRule : CSSRule {
    2525
    2626                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString selectorText;
  • trunk/Source/WebCore/css/MediaList.idl

    r52921 r84527  
    2828    // Introduced in DOM Level 2:
    2929    interface [
     30        CustomToJS,
    3031        HasIndexGetter
    3132    ] MediaList {
  • trunk/Source/WebCore/css/StyleBase.cpp

    r54645 r84527  
    2424#include "StyleBase.h"
    2525
     26#include "CSSMutableStyleDeclaration.h"
    2627#include "Document.h"
    2728#include "Node.h"
     
    3940    if (parent())
    4041        parent()->checkLoaded();
     42}
     43
     44Node* StyleBase::node()
     45{
     46    if (isStyleSheet())
     47        return static_cast<StyleSheet*>(this)->ownerNode();
     48
     49    if (isMutableStyleDeclaration())
     50        return static_cast<CSSMutableStyleDeclaration*>(this)->node();
     51
     52    return 0;
    4153}
    4254
  • trunk/Source/WebCore/css/StyleBase.h

    r72116 r84527  
    2929namespace WebCore {
    3030
     31    class KURL;
     32    class Node;
    3133    class StyleSheet;
    32     class KURL;
    3334
    3435    // Base class for most CSS DOM objects.
     
    7273
    7374        StyleSheet* stylesheet();
     75        Node* node();
    7476
    7577    protected:
  • trunk/Source/WebCore/css/StyleSheetList.idl

    r52921 r84527  
    2323    // Introduced in DOM Level 2:
    2424    interface [
    25         CustomMarkFunction,
     25        CustomToJS,
    2626        HasIndexGetter,
    2727        HasNameGetter
  • trunk/Source/WebCore/css/WebKitCSSKeyframeRule.idl

    r72590 r84527  
    3030
    3131    // Introduced in DOM Level ?:
    32     interface [CustomMarkFunction] WebKitCSSKeyframeRule : CSSRule {
     32    interface WebKitCSSKeyframeRule : CSSRule {
    3333
    3434        attribute DOMString keyText;
  • trunk/Source/WebCore/css/WebKitCSSKeyframesRule.idl

    r72590 r84527  
    3131    // Introduced in DOM Level ?:
    3232    interface [
    33         CustomMarkFunction,
    3433        HasIndexGetter
    3534    ] WebKitCSSKeyframesRule : CSSRule {
Note: See TracChangeset for help on using the changeset viewer.