Bug 100776 - Avoid unnecessary style recalcs on class attribute mutation
Summary: Avoid unnecessary style recalcs on class attribute mutation
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:
 
Reported: 2012-10-30 11:48 PDT by Antti Koivisto
Modified: 2012-10-30 13:34 PDT (History)
6 users (show)

See Also:


Attachments
patch (12.09 KB, patch)
2012-10-30 12:13 PDT, Antti Koivisto
kling: review-
Details | Formatted Diff | Diff
another try (12.65 KB, patch)
2012-10-30 12:53 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-10-30 11:48:39 PDT
There is no need to invalidate element style on class attribute change if neither the added or removed classes featured in any active stylesheet.
Comment 1 Antti Koivisto 2012-10-30 12:13:11 PDT
Created attachment 171495 [details]
patch
Comment 2 Andreas Kling 2012-10-30 12:30:26 PDT
Comment on attachment 171495 [details]
patch

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

Cool idea!

r- for causing unnecessary conversions from immutable to mutable attribute data, rest looks good.

> Source/WebCore/css/RuleFeature.cpp:46
> +    end = other.classesInRules.end();
> +    for (HashSet<AtomicStringImpl*>::iterator it = other.classesInRules.begin(); it != end; ++it)
> +        classesInRules.add(*it);

Looks like we could be using const_iterators in this function.

> Source/WebCore/dom/Element.cpp:786
> +        SpaceSplitString oldClasses = mutableAttributeData()->classNames();

This will force promotion from ImmutableElementAttributeData to MutableElementAttributeData for all elements with a class attribute the first time they're parsed.

> Source/WebCore/dom/SpaceSplitString.cpp:122
> +    // FIXME: add() does not allow duplicates but createVector() does.

Huh.
Comment 3 Antti Koivisto 2012-10-30 12:53:58 PDT
Created attachment 171509 [details]
another try
Comment 4 Antti Koivisto 2012-10-30 13:34:41 PDT
http://trac.webkit.org/changeset/132941