Bug 84882 - Remove owner node pointer from StyleSheetInternal
Summary: Remove owner node pointer from StyleSheetInternal
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 77745
  Show dependency treegraph
 
Reported: 2012-04-25 12:32 PDT by Antti Koivisto
Modified: 2012-04-25 16:10 PDT (History)
4 users (show)

See Also:


Attachments
patch (40.56 KB, patch)
2012-04-25 14:39 PDT, Antti Koivisto
kling: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2012-04-25 12:32:25 PDT
To make sharing between multiple nodes possible, StyleSheetInternal should not have a Node pointer.
Comment 1 Antti Koivisto 2012-04-25 14:39:34 PDT
Created attachment 138875 [details]
patch
Comment 2 Andreas Kling 2012-04-25 15:32:54 PDT
Comment on attachment 138875 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=138875&action=review

r=me with the Node reffing change we discussed.

> Source/WebCore/css/CSSImportRule.cpp:67
> +    CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : CSSStrictMode;

Not a huge fan of this construction syntax. But NABD.

> Source/WebCore/css/CSSStyleSheet.cpp:326
> -    RefPtr<Node> owner = ownerNode();
> -    if (!owner)
> +    StyleSheetInternal* parentSheet = parentStyleSheet();
> +    if (parentSheet) {
> +        parentSheet->checkLoaded();
> +        m_loadCompleted = true;
> +        return;
> +    }
> +    Node* ownerNode = singleOwnerNode();
> +    if (!ownerNode) {
>          m_loadCompleted = true;
> -    else {
> -        m_loadCompleted = owner->sheetLoaded();
> -        if (m_loadCompleted)
> -            owner->notifyLoadedSheetAndAllCriticalSubresources(m_didLoadErrorOccur);
> +        return;
>      }
> +    // This may run javascript and kill the node.
> +    m_loadCompleted = ownerNode->sheetLoaded();
> +    // Get the node again.
> +    ownerNode = singleOwnerNode();
> +    if (m_loadCompleted && ownerNode)
> +        ownerNode->notifyLoadedSheetAndAllCriticalSubresources(m_didLoadErrorOccur);

We should hold a ref on the owner Node throughout the sheetLoaded() call to prevent it from disappearing under us. (Like the old code did.)

> Source/WebCore/dom/Document.cpp:2626
> +        // Element sheet is a silly. It never contains anything.

I agree. :)
I have an occasional daydream where we remove it. Someday..
Comment 3 Antti Koivisto 2012-04-25 16:10:15 PDT
http://trac.webkit.org/changeset/115250