Bug 70408 - Move rule matching and applying to separate functions from CSSStyleSelector::styleForElement
Summary: Move rule matching and applying to separate functions from CSSStyleSelector::...
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: 2011-10-19 03:20 PDT by Antti Koivisto
Modified: 2011-10-20 04:24 PDT (History)
0 users

See Also:


Attachments
patch (15.05 KB, patch)
2011-10-19 03:27 PDT, Antti Koivisto
kling: review+
Details | Formatted Diff | Diff
new patch (20.33 KB, patch)
2011-10-19 09:07 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 2011-10-19 03:20:12 PDT
A cleanup.
Comment 1 Antti Koivisto 2011-10-19 03:27:32 PDT
Created attachment 111587 [details]
patch
Comment 2 Andreas Kling 2011-10-19 03:56:57 PDT
Comment on attachment 111587 [details]
patch

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

r=me.

I suspect that this code is vulnerable to some integer overflows with all the assignments of unsigned/size_t values to int variables (the MatchResult members.)
Still, r+ since you're just moving the code around.

> Source/WebCore/css/CSSStyleSelector.cpp:752
> +    if (!resolveForRootDefault) {

We should use early return here.

> Source/WebCore/css/CSSStyleSelector.cpp:760
> +            // Ask if the HTML element has mapped attributes.

This comment implies that m_styledElement is an HTML element, but given the isHTMLElement() check further down, is that always the case?

> Source/WebCore/css/CSSStyleSelector.cpp:764
> +                for (unsigned i = 0; i < map->length(); i++) {

Style, ++i.
NamedNodeMap::length() returns size_t, not unsigned.

> Source/WebCore/css/CSSStyleSelector.cpp:769
> +                            result.firstAuthorRule =result.lastAuthorRule;

Also style, should have space after =.

> Source/WebCore/css/CSSStyleSelector.cpp:786
> +                    for (unsigned i = 0; i < additionalDeclsSize; i++)

Style, ++i.

> Source/WebCore/css/CSSStyleSelector.cpp:1653
> +    // If we have first-letter pseudo style, do not share this style

Might as well tack on a period at the end of this comment.

> Source/WebCore/css/CSSStyleSelector.cpp:2189
> +    // Line-height is set when we are sure we decided on the font-size

Ditto.
Comment 3 Andreas Kling 2011-10-19 03:59:10 PDT
Comment on attachment 111587 [details]
patch

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

> Source/WebCore/css/CSSStyleSelector.cpp:782
> +                    unsigned additionalDeclsSize = m_additionalAttributeStyleDecls.size();

Vector::size() returns size_t.
Comment 4 Antti Koivisto 2011-10-19 09:07:35 PDT
Created attachment 111632 [details]
new patch

Expanded the refactoring a bit so requesting re-review. This patch uses the MatchResult struct in more places and gets rid of the resolveForRootDefault parameter for the new functions.
Comment 5 Andreas Kling 2011-10-20 04:21:01 PDT
Comment on attachment 111632 [details]
new patch

r=me, though let's fight about size_t vs unsigned indexing at some point.
Comment 6 Antti Koivisto 2011-10-20 04:24:24 PDT
http://trac.webkit.org/changeset/97962