Bug 155695 - Purge PassRefPtr from CSSParser
Summary: Purge PassRefPtr from CSSParser
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joonghun Park
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-20 04:24 PDT by Joonghun Park
Modified: 2019-04-30 07:56 PDT (History)
0 users

See Also:


Attachments
Patch (36.19 KB, patch)
2016-03-20 04:26 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff
Fix build break of Efl port (36.94 KB, patch)
2016-03-20 05:20 PDT, Joonghun Park
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joonghun Park 2016-03-20 04:24:25 PDT
Purge PassRefPtr from CSSParser.
Comment 1 Joonghun Park 2016-03-20 04:26:44 PDT
Created attachment 274536 [details]
Patch
Comment 2 Joonghun Park 2016-03-20 05:20:24 PDT
Created attachment 274537 [details]
Fix build break of Efl port
Comment 3 Darin Adler 2016-03-20 09:53:52 PDT
Comment on attachment 274537 [details]
Fix build break of Efl port

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

> Source/WebCore/css/CSSParser.cpp:1488
> +bool CSSParser::parseDeclaration(MutableStyleProperties* declaration, const String& string, RefPtr<CSSRuleSourceData>&& aRuleSourceData, StyleSheetContents* contextStyleSheet)

The use of the "a" prefix here is peculiar and not WebKit coding style. Lets just call this ruleSourceData.

> Source/WebCore/css/CSSParser.cpp:1495
> +    CSSRuleSourceData* ruleSourceData = aRuleSourceData.get();

I suppose it’s OK to make this local copy to avoid reference count churn. It is a little dangerous, though, since we are counting on m_currentRuleDataStack to keep the object alive after this point. And tricky to figure out names for the two local variables (the one that is null because we moved out of it and the raw pointer that is not). An "a" prefix won’t do it.

> Source/WebCore/css/CSSParser.cpp:1641
> +    RefPtr<CSSValue> val = value.copyRef();
> +    addProperty(propId, WTFMove(value), important, implicit);

Not the right way to do it. If we have to do the reference count churn here then we should just do:

    addProperty(propId, value.copyRef(), important, implicit);

Then we can use "value" below instead of "val".

> Source/WebCore/css/CSSParser.cpp:7865
> +    void commitColor(Ref<CSSPrimitiveValue>&& val)

Since we are touching this it would be good to replace the abbreviation "val" with a word like "value" or multiple words like "colorValue".

> Source/WebCore/css/CSSParser.cpp:8153
>          return createBorderImageValue(m_image, m_imageSlice, m_borderSlice, m_outset, m_repeat);

These should all be moving/releasing rather than copying for the same reason that commitBorderImage below should be.

> Source/WebCore/css/CSSParser.cpp:8162
> +        commitBorderImageProperty(CSSPropertyBorderImageSource, parser, m_image.copyRef(), important);
> +        commitBorderImageProperty(CSSPropertyBorderImageSlice, parser, m_imageSlice.copyRef(), important);
> +        commitBorderImageProperty(CSSPropertyBorderImageWidth, parser, m_borderSlice.copyRef(), important);
> +        commitBorderImageProperty(CSSPropertyBorderImageOutset, parser, m_outset.copyRef(), important);
> +        commitBorderImageProperty(CSSPropertyBorderImageRepeat, parser, m_repeat.copyRef(), important);

These should all be WTFMove rather than copyRef; this function is used just before destroying a BorderImageParseContext.

> Source/WebCore/css/CSSParser.cpp:8667
> +static Ref<CSSPrimitiveValue> parseDeprecatedGradientPoint(CSSParserValue& value, bool horizontal)

This doesn’t seem right. There are lots of paths here that turn into nullptr.

> Source/WebCore/css/CSSParser.cpp:8681
> +    return result.releaseNonNull();

I see no guarantee that this is non-null.

> Source/WebCore/css/CSSParser.cpp:12776
> +RefPtr<StyleRuleBase> CSSParser::createMediaRule(RefPtr<MediaQuerySet>&& media, RuleList* rules)

I don’t see this using WTFMove when calling StyleRuleMedia::create. So the rvalue reference is doing us no good here. What’s the story?