Bug 73561 - JSC/CSSOM: root(CSSElementStyleDeclaration) should never need to follow the element.
Summary: JSC/CSSOM: root(CSSElementStyleDeclaration) should never need to follow the e...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-01 07:15 PST by Andreas Kling
Modified: 2011-12-01 10:50 PST (History)
2 users (show)

See Also:


Attachments
Proposed patch (2.00 KB, patch)
2011-12-01 07:16 PST, Andreas Kling
koivisto: review+
koivisto: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>