Bug 107361

Summary: Don't recalcStyle and layout when changing page scale.
Product: WebKit Reporter: Dongseong Hwang <dongseong.hwang>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: bdakin, cmarrin, darin, kenneth, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 105978    

Description Dongseong Hwang 2013-01-18 22:57:19 PST
When we do pinch zoom, WebCore recalculates style and re-layouts. It affects user experience badly.
void Page::setPageScaleFactor(float scale, const IntPoint& origin)
{
    ...
    if (document->renderer())
        document->renderer()->setNeedsLayout(true);

    document->recalcStyle(Node::Force);
    ...
}

It is originated from Bug 48385, which created Frame::scalePage.
AFAIK, Bug 48385 made Frame::scalePage recalcStyle and layout, because it want to apply pageScale to transform.
However, I concern why we should apply pageScale to transform.
GraphicsLayer can know pageScale. GraphicsLayer can handle pageScale without scaled transform.

On the other hands, near past, deviceScaleFactor was born, but we don't apply deviceScaleFactor to transform. I think it is a bit weird.
When we work near device screen, we must consider pageScale * deviceScaleFactor.
It forces us to apply deviceScaleFactor to transform before drawing contents on device. And we must remember it is not allowed to apply pageScale to transform at that time.

In my opinion, StyleResolver should not slightly apply pageScale to transform, and we apply pageScale when it is needed. (e.g. r73525)
It will be more clear as well as performance benefit.
I wish Page::setPageScaleFactor not to cause recalcStyle and layout. I need your opinion.
Comment 1 Simon Fraser (smfr) 2013-01-19 11:02:58 PST
Page scale uses a transform on the root (RenderView), just like a CSS transform. Changing transforms requires layout, because it affects overflow; this is used to update the scrollbars when scaled.
Comment 2 Dongseong Hwang 2013-01-23 02:19:06 PST
(In reply to comment #1)
> Page scale uses a transform on the root (RenderView), just like a CSS transform. Changing transforms requires layout, because it affects overflow; this is used to update the scrollbars when scaled.

Thank you for your explanation. I can grasp how transform effects. Chromium avoids changing transform using Settings::applyPageScaleFactorInCompositorKey(). EFL and Qt will follows Chromium's way.