Bug 73121 - Factor element pointer out of CSSMutableStyleDeclaration.
Summary: Factor element pointer out of CSSMutableStyleDeclaration.
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
Depends on: 73227
  Show dependency treegraph
Reported: 2011-11-25 03:53 PST by Andreas Kling
Modified: 2011-11-29 07:23 PST (History)
5 users (show)

See Also:

Proposed patch (25.66 KB, patch)
2011-11-25 04:42 PST, Andreas Kling
koivisto: review+
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-11-25 03:53:33 PST
The element (StyledElement, to be precise) pointer in CSSMutableStyleDeclaration is really only needed by inline and mapped style declarations.
We should factor this out somehow, to reduce the size and complexity of vanilla declarations.
Comment 1 Andreas Kling 2011-11-25 04:42:18 PST
Created attachment 116599 [details]
Proposed patch

First stab at this: move the element pointer to a CSSElementStyleDeclaration subclass (thin, lives next to CSSMutableStyleDeclaration) and let CSSMappedAttributeDeclaration inherit from it along with the new CSSInlineStyleDeclaration class.
Comment 2 Antti Koivisto 2011-11-25 05:11:36 PST
Comment on attachment 116599 [details]
Proposed patch

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

r=me, nice!

> Source/WebCore/css/CSSMutableStyleDeclaration.cpp:615
> +    if (isElementStyleDeclaration() && static_cast<CSSElementStyleDeclaration*>(this)->element()) {
> +        StyledElement* element = static_cast<CSSElementStyleDeclaration*>(this)->element();

This could could live in CSSElementStyleDeclaration

> Source/WebCore/css/CSSMutableStyleDeclaration.h:179
> +class CSSElementStyleDeclaration : public CSSMutableStyleDeclaration {
> +public:

This should probably have a file of its own at some point.

> Source/WebCore/css/CSSStyleDeclaration.h:124
> +    // CSSElementStyleDeclaration bits:
> +    bool m_isElementStyleDeclaration : 1;
> +    bool m_isInlineStyleDeclaration : 1;

Type enum would be another alternative. It might read slightly better in some places (like where the inline bit is passed down in constructor).
Comment 3 Andreas Kling 2011-11-25 06:57:55 PST
Committed r101172: <http://trac.webkit.org/changeset/101172>
Comment 4 Vsevolod Vlasov 2011-11-28 06:23:13 PST
This caused https://bugs.webkit.org/show_bug.cgi?id=73213
Comment 5 Csaba Osztrogonác 2011-11-29 07:23:58 PST
(In reply to comment #4)
> This caused https://bugs.webkit.org/show_bug.cgi?id=73213
and https://bugs.webkit.org/show_bug.cgi?id=73227