Bug 86551 - Kill RenderLayer::relativePositionOffset(LayoutUnit& relX, LayoutUnit& relY) and cleanup RenderInline::clippedOverflowRectForRepaint
Summary: Kill RenderLayer::relativePositionOffset(LayoutUnit& relX, LayoutUnit& relY) ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Julien Chaffraix
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-15 17:30 PDT by Julien Chaffraix
Modified: 2012-05-17 14:30 PDT (History)
4 users (show)

See Also:


Attachments
Proposed removal 1. (5.33 KB, patch)
2012-05-15 17:38 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff
Patch v2: Improved after Darin's comments + added more explanation on hasLayer() in ChangeLog. (5.46 KB, patch)
2012-05-16 11:13 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff
Patch for landing (5.21 KB, patch)
2012-05-17 13:44 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Chaffraix 2012-05-15 17:30:00 PDT
The function is only called once and could easily be replaced by the usual IntPoint / LayoutPoint manipulation.

Patch forthcoming.
Comment 1 Julien Chaffraix 2012-05-15 17:38:24 PDT
Created attachment 142109 [details]
Proposed removal 1.
Comment 2 Darin Adler 2012-05-15 17:46:17 PDT
Comment on attachment 142109 [details]
Proposed removal 1.

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

> Source/WebCore/rendering/RenderInline.cpp:948
> -        if (inlineFlow->style()->position() == RelativePosition && inlineFlow->hasLayer())
> -            toRenderInline(inlineFlow)->layer()->relativePositionOffset(left, top);
> +        if (inlineFlow->style()->position() == RelativePosition)
> +            repaintRect.move(toRenderInline(inlineFlow)->layer()->relativePositionOffset());

Why is it OK to remove the inlineFlow->hasLayer() check? Presumably somehow you know that it has a layer, but how?

> Source/WebCore/rendering/RenderInline.cpp:968
> -        LayoutRect repaintRect(r);
> -        repaintRect.move(-cb->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
> +        LayoutRect scrolledRepaintRect(repaintRect);
> +        scrolledRepaintRect.move(-cb->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
>  
>          LayoutRect boxRect(LayoutPoint(), cb->cachedSizeForOverflowClip());
> -        r = intersection(repaintRect, boxRect);
> +        repaintRect = intersection(scrolledRepaintRect, boxRect);

Why do we need a separate variable for scrolledRepaintRect? We should use repaintRect directly.

> Source/WebCore/rendering/RenderInline.cpp:977
> +                LayoutRect childRect = curr->rectWithOutlineForRepaint(repaintContainer, outlineSize);
> +                repaintRect.unite(childRect);

I don’t think the local variable here helps.

> Source/WebCore/rendering/RenderInline.cpp:983
> +            LayoutRect contRect = continuation()->rectWithOutlineForRepaint(repaintContainer, outlineSize);
> +            repaintRect.unite(contRect);

I don’t think the local variable here helps.
Comment 3 Julien Chaffraix 2012-05-15 18:36:46 PDT
Comment on attachment 142109 [details]
Proposed removal 1.

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

>> Source/WebCore/rendering/RenderInline.cpp:948
>> +            repaintRect.move(toRenderInline(inlineFlow)->layer()->relativePositionOffset());
> 
> Why is it OK to remove the inlineFlow->hasLayer() check? Presumably somehow you know that it has a layer, but how?

Mostly because we ensure that RenderInline has a RenderLayer for position:relative. See the isRelPositioned() check in RenderInline::requiresLayer().

Also the classes inheriting from RenderInline either override clippedOverflowForRepaint (RenderSVGInline) or don't override requiresLayer (RenderRubyAsInline).

The only way we could crash here is if we have an SVG inline ancestor with a RenderInline or RenderRubyAsInline child. I don't think this is something we allow.

>> Source/WebCore/rendering/RenderInline.cpp:968
>> +        repaintRect = intersection(scrolledRepaintRect, boxRect);
> 
> Why do we need a separate variable for scrolledRepaintRect? We should use repaintRect directly.

I agree with you, I just didn't feel strongly enough to remove it. Will be changed of course.
Comment 4 Julien Chaffraix 2012-05-16 11:13:13 PDT
Created attachment 142305 [details]
Patch v2: Improved after Darin's comments + added more explanation on hasLayer() in ChangeLog.
Comment 5 Abhishek Arya 2012-05-17 12:29:39 PDT
Comment on attachment 142305 [details]
Patch v2: Improved after Darin's comments + added more explanation on hasLayer() in ChangeLog.

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

r=me. please do bring the null check back.

> Source/WebCore/ChangeLog:3
> +        Kill RenderLayer::relativePositionOffset(LayoutUnit& relX, LayoutUnit& relY)

Do you want to add "and cleanup RenderInline::clippedOverflowRectForRepaint".

> Source/WebCore/ChangeLog:8
> +        No expected change in behavior.

Probably like 'No new tests since there is no expected change in behavior.'

> Source/WebCore/ChangeLog:14
> +        variable and removed 2 unneeded NULL-checks:

s/variable/variables.
s/NULL/null

> Source/WebCore/ChangeLog:16
> +            - we ensure that a RenderInlie with position: relative has a RenderLayer

typo RenderInlie. however we won't need this. see comment below.

> Source/WebCore/rendering/RenderInline.cpp:947
> +        if (inlineFlow->style()->position() == RelativePosition)

I think we should bring the hasLayer() check back. If some new class (like svg) inherits from renderinline and overrides hasLayer() and does not need the isRelPositioned() check, we will crash with a null.
Comment 6 Julien Chaffraix 2012-05-17 13:28:43 PDT
Comment on attachment 142305 [details]
Patch v2: Improved after Darin's comments + added more explanation on hasLayer() in ChangeLog.

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

>> Source/WebCore/ChangeLog:3
>> +        Kill RenderLayer::relativePositionOffset(LayoutUnit& relX, LayoutUnit& relY)
> 
> Do you want to add "and cleanup RenderInline::clippedOverflowRectForRepaint".

Sure.

>> Source/WebCore/ChangeLog:14
>> +        variable and removed 2 unneeded NULL-checks:
> 
> s/variable/variables.
> s/NULL/null

I prefer NULL in capital letters to match the C constant.

>> Source/WebCore/rendering/RenderInline.cpp:947
>> +        if (inlineFlow->style()->position() == RelativePosition)
> 
> I think we should bring the hasLayer() check back. If some new class (like svg) inherits from renderinline and overrides hasLayer() and does not need the isRelPositioned() check, we will crash with a null.

I don't think that's possible in our current code but it's likely for the better. I will add it back.
Comment 7 Julien Chaffraix 2012-05-17 13:44:48 PDT
Created attachment 142542 [details]
Patch for landing
Comment 8 WebKit Review Bot 2012-05-17 14:30:25 PDT
Comment on attachment 142542 [details]
Patch for landing

Clearing flags on attachment: 142542

Committed r117497: <http://trac.webkit.org/changeset/117497>
Comment 9 WebKit Review Bot 2012-05-17 14:30:30 PDT
All reviewed patches have been landed.  Closing bug.