Bug 73561

Summary: JSC/CSSOM: root(CSSElementStyleDeclaration) should never need to follow the element.
Product: WebKit Reporter: Andreas Kling <kling>
Component: CSSAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, koivisto
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch koivisto: review+, koivisto: commit-queue-

Description Andreas Kling 2011-12-01 07:15:05 PST
While digging following Darin's comment on bug 72881, I realized that root() for a style declaration with an associated element should always return the element sheet unless the element pointer is null. In light of this, we could replace the root-from-element code path with an assertion
Comment 1 Andreas Kling 2011-12-01 07:16:59 PST
Created attachment 117414 [details]
Proposed patch
Comment 2 Antti Koivisto 2011-12-01 10:09:18 PST
Comment on attachment 117414 [details]
Proposed patch

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

> Source/WebCore/bindings/js/JSDOMBinding.h:214
> +#ifndef NDEBUG
> +        // A style declaration with an associated element should've returned a style sheet above.
> +        if (style->isElementStyleDeclaration())
> +            ASSERT(!static_cast<CSSElementStyleDeclaration*>(style)->element());
> +#endif

maybe 

ASSERT(!style->isElementStyleDeclaration() || !static_cast<CSSElementStyleDeclaration*>(style)->element());

so you don't need #ifndef?
Comment 3 Andreas Kling 2011-12-01 10:11:48 PST
(In reply to comment #2)
> (From update of attachment 117414 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=117414&action=review
> 
> > Source/WebCore/bindings/js/JSDOMBinding.h:214
> > +#ifndef NDEBUG
> > +        // A style declaration with an associated element should've returned a style sheet above.
> > +        if (style->isElementStyleDeclaration())
> > +            ASSERT(!static_cast<CSSElementStyleDeclaration*>(style)->element());
> > +#endif
> 
> maybe 
> 
> ASSERT(!style->isElementStyleDeclaration() || !static_cast<CSSElementStyleDeclaration*>(style)->element());
> 
> so you don't need #ifndef?

Duh. Yes, obviously :)
Comment 4 Andreas Kling 2011-12-01 10:50:17 PST
Committed r101687: <http://trac.webkit.org/changeset/101687>