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
Created attachment 117414 [details] Proposed patch
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?
(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 :)
Committed r101687: <http://trac.webkit.org/changeset/101687>