Changeset 95715 in webkit


Ignore:
Timestamp:
Sep 22, 2011 6:30:59 AM (13 years ago)
Author:
hclam@chromium.org
Message:

Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=68081
Fix scroll in page scaling mode.

Reviewed by Simon Fraser.

The following things are done in this patch:

  1. Rename Frame::pageScaleFactor() to Frame::frameScaleFactor() to better reflect its purpose.
  2. Frame::frameScaleFactor() returns the scale factor of this frame with respect to the container. So for the main frame it'll return the scale factor of the page, inner frames will return 1.0
  3. scrollBy(), scrollX() and scrollY() to take into account of the frame scale factor, causing incorrect coordinates reported to Javascript.

Tests: fast/events/scale-and-scroll-body.html

fast/events/scale-and-scroll-iframe-body.html
fast/events/scale-and-scroll-iframe-window.html
fast/events/scale-and-scroll-window.html

  • html/HTMLBodyElement.cpp:

(WebCore::adjustForZoom):
(WebCore::HTMLBodyElement::setScrollLeft):
(WebCore::HTMLBodyElement::setScrollTop):

  • loader/HistoryController.cpp:

(WebCore::HistoryController::saveScrollPositionAndViewStateToItem):

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::scrollX):
(WebCore::DOMWindow::scrollY):
(WebCore::DOMWindow::scrollTo):

  • page/Frame.cpp:

(WebCore::Frame::frameScaleFactor): Return page's scale factor if this is

main frame, otherwise 1.0

  • page/Frame.h:
  • page/FrameView.cpp:

(WebCore::FrameView::applyOverflowToViewport):
(WebCore::FrameView::scrollXForFixedPosition):
(WebCore::FrameView::scrollYForFixedPosition):

Source/WebKit2: https://bugs.webkit.org/show_bug.cgi?id=68081
Fix scroll in page scaling mode.

Reviewed by Simon Fraser.

  • WebProcess/Plugins/PluginView.cpp: Rename pageScaleFactor to frameScaleFactor.

(WebKit::PluginView::handleEvent):
(WebKit::PluginView::viewGeometryDidChange):
(WebKit::PluginView::clipRectInWindowCoordinates):

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=68081
Add layout test for page scale and scrolling.

Reviewed by Simon Fraser.

Add tests to cover the following cases:

  1. Scale and scroll window
  2. Scale and scroll document.body
  3. Scale and scroll iframe's contentWindow
  4. Scale and scroll iframe's contentDocument.body
  • fast/events/scale-and-scroll-body-expected.png: Added.
  • fast/events/scale-and-scroll-body-expected.txt: Added.
  • fast/events/scale-and-scroll-body.html: Added.
  • fast/events/scale-and-scroll-iframe-body-expected.png: Added.
  • fast/events/scale-and-scroll-iframe-body-expected.txt: Added.
  • fast/events/scale-and-scroll-iframe-body.html: Added.
  • fast/events/scale-and-scroll-iframe-window-expected.png: Added.
  • fast/events/scale-and-scroll-iframe-window-expected.txt: Added.
  • fast/events/scale-and-scroll-iframe-window.html: Added.
  • fast/events/scale-and-scroll-window-expected.png: Added.
  • fast/events/scale-and-scroll-window-expected.txt: Added.
  • fast/events/scale-and-scroll-window.html: Added.
Location:
trunk
Files:
12 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95714 r95715  
     12011-09-22  Alpha Lam  <hclam@chromium.org>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68081
     4        Add layout test for page scale and scrolling.
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add tests to cover the following cases:
     9        1. Scale and scroll window
     10        2. Scale and scroll document.body
     11        3. Scale and scroll iframe's contentWindow
     12        4. Scale and scroll iframe's contentDocument.body
     13
     14        * fast/events/scale-and-scroll-body-expected.png: Added.
     15        * fast/events/scale-and-scroll-body-expected.txt: Added.
     16        * fast/events/scale-and-scroll-body.html: Added.
     17        * fast/events/scale-and-scroll-iframe-body-expected.png: Added.
     18        * fast/events/scale-and-scroll-iframe-body-expected.txt: Added.
     19        * fast/events/scale-and-scroll-iframe-body.html: Added.
     20        * fast/events/scale-and-scroll-iframe-window-expected.png: Added.
     21        * fast/events/scale-and-scroll-iframe-window-expected.txt: Added.
     22        * fast/events/scale-and-scroll-iframe-window.html: Added.
     23        * fast/events/scale-and-scroll-window-expected.png: Added.
     24        * fast/events/scale-and-scroll-window-expected.txt: Added.
     25        * fast/events/scale-and-scroll-window.html: Added.
     26
    1272011-09-22  Andreas Kling  <kling@webkit.org>
    228
  • trunk/Source/WebCore/ChangeLog

    r95714 r95715  
     12011-09-22  Alpha Lam  <hclam@chromium.org>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68081
     4        Fix scroll in page scaling mode.
     5
     6        Reviewed by Simon Fraser.
     7
     8        The following things are done in this patch:
     9        1. Rename Frame::pageScaleFactor() to Frame::frameScaleFactor() to better
     10           reflect its purpose.
     11        2. Frame::frameScaleFactor() returns the scale factor of this frame with
     12           respect to the container. So for the main frame it'll return the scale
     13           factor of the page, inner frames will return 1.0
     14        3. scrollBy(), scrollX() and scrollY() to take into account of the frame
     15           scale factor, causing incorrect coordinates reported to Javascript.
     16
     17        Tests: fast/events/scale-and-scroll-body.html
     18               fast/events/scale-and-scroll-iframe-body.html
     19               fast/events/scale-and-scroll-iframe-window.html
     20               fast/events/scale-and-scroll-window.html
     21
     22        * html/HTMLBodyElement.cpp:
     23        (WebCore::adjustForZoom):
     24        (WebCore::HTMLBodyElement::setScrollLeft):
     25        (WebCore::HTMLBodyElement::setScrollTop):
     26        * loader/HistoryController.cpp:
     27        (WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
     28        * page/DOMWindow.cpp:
     29        (WebCore::DOMWindow::scrollX):
     30        (WebCore::DOMWindow::scrollY):
     31        (WebCore::DOMWindow::scrollTo):
     32        * page/Frame.cpp:
     33        (WebCore::Frame::frameScaleFactor): Return page's scale factor if this is
     34                                            main frame, otherwise 1.0
     35        * page/Frame.h:
     36        * page/FrameView.cpp:
     37        (WebCore::FrameView::applyOverflowToViewport):
     38        (WebCore::FrameView::scrollXForFixedPosition):
     39        (WebCore::FrameView::scrollYForFixedPosition):
     40
    1412011-09-22  Andreas Kling  <kling@webkit.org>
    242
  • trunk/Source/WebCore/WebCore.exp.in

    r95685 r95715  
    747747__ZN7WebCore5Frame23visiblePositionForPointERKNS_8IntPointE
    748748__ZN7WebCore5Frame25matchLabelsAgainstElementEP7NSArrayPNS_7ElementE
    749 __ZNK7WebCore5Frame15pageScaleFactorEv
     749__ZNK7WebCore5Frame15frameScaleFactorEv
    750750__ZN7WebCore5Frame25setPageAndTextZoomFactorsEff
    751751__ZN7WebCore5Frame27resizePageRectsKeepingRatioERKNS_9FloatSizeES3_
  • trunk/Source/WebCore/html/HTMLBodyElement.cpp

    r95612 r95715  
    268268{
    269269    Frame* frame = document->frame();
    270     float zoomFactor = frame->pageZoomFactor() * frame->pageScaleFactor();
     270    float zoomFactor = frame->pageZoomFactor() * frame->frameScaleFactor();
    271271    if (zoomFactor == 1)
    272272        return value;
     
    296296    if (!view)
    297297        return;
    298     view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZoomFactor() * frame->pageScaleFactor()), view->scrollY()));
     298    view->setScrollPosition(IntPoint(static_cast<int>(scrollLeft * frame->pageZoomFactor() * frame->frameScaleFactor()), view->scrollY()));
    299299}
    300300
     
    318318    if (!view)
    319319        return;
    320     view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor() * frame->pageScaleFactor())));
     320    view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(scrollTop * frame->pageZoomFactor() * frame->frameScaleFactor())));
    321321}
    322322
  • trunk/Source/WebCore/loader/HistoryController.cpp

    r95612 r95715  
    8787        item->setScrollPoint(m_frame->view()->scrollPosition());
    8888
    89     item->setPageScaleFactor(m_frame->pageScaleFactor());
     89    item->setPageScaleFactor(m_frame->frameScaleFactor());
    9090   
    9191    // FIXME: It would be great to work out a way to put this code in WebCore instead of calling through to the client.
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r95612 r95715  
    11441144    m_frame->document()->updateLayoutIgnorePendingStylesheets();
    11451145
    1146     return static_cast<int>(view->scrollX() / m_frame->pageZoomFactor());
     1146    return static_cast<int>(view->scrollX() / (m_frame->pageZoomFactor() * m_frame->frameScaleFactor()));
    11471147}
    11481148
     
    11581158    m_frame->document()->updateLayoutIgnorePendingStylesheets();
    11591159
    1160     return static_cast<int>(view->scrollY() / m_frame->pageZoomFactor());
     1160    return static_cast<int>(view->scrollY() / (m_frame->pageZoomFactor() * m_frame->frameScaleFactor()));
    11611161}
    11621162
     
    13851385        return;
    13861386
    1387     int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor());
    1388     int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor());
     1387    int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor() * m_frame->frameScaleFactor());
     1388    int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor() * m_frame->frameScaleFactor());
    13891389    view->setScrollPosition(IntPoint(zoomedX, zoomedY));
    13901390}
  • trunk/Source/WebCore/page/Frame.cpp

    r95612 r95715  
    10241024}
    10251025
    1026 float Frame::pageScaleFactor() const
     1026float Frame::frameScaleFactor() const
    10271027{
    10281028    Page* page = this->page();
    1029     if (!page)
     1029
     1030    // Main frame is scaled with respect to he container but inner frames are not scaled with respect to the main frame.
     1031    if (!page || page->mainFrame() != this)
    10301032        return 1;
    10311033    return page->pageScaleFactor();
  • trunk/Source/WebCore/page/Frame.h

    r95612 r95715  
    162162        void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
    163163
    164         // Convenience helper method that grabs the pageScaleFactor from Page.
    165         float pageScaleFactor() const;
     164        // Scale factor of this frame with respect to the container.
     165        float frameScaleFactor() const;
    166166
    167167#if USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/page/FrameView.cpp

    r95685 r95715  
    526526
    527527    // To combat the inability to scroll on a page with overflow:hidden on the root when scaled, disregard hidden when
    528     // there is a pageScaleFactor that is greater than one on the main frame.
    529 
    530     bool overrideHidden = m_frame->page() && m_frame->page()->mainFrame() == m_frame && m_frame->pageScaleFactor() > 1;
     528    // there is a frameScaleFactor that is greater than one on the main frame.
     529
     530    bool overrideHidden = m_frame->page() && m_frame->page()->mainFrame() == m_frame && m_frame->frameScaleFactor() > 1;
    531531
    532532    switch (o->style()->overflowX()) {
     
    13501350        return x;
    13511351
    1352     float pageScaleFactor = m_frame->pageScaleFactor();
     1352    float frameScaleFactor = m_frame->frameScaleFactor();
    13531353
    13541354    // When the page is scaled, the scaled "viewport" with respect to which fixed object are positioned
    13551355    // doesn't move as fast as the content view, so that when the content is scrolled all the way to the
    13561356    // end, the bottom of the scaled "viewport" touches the bottom of the real viewport.
    1357     float dragFactor = (contentsWidth() - visibleContentWidth * pageScaleFactor) / maxX;
    1358 
    1359     return x * dragFactor / pageScaleFactor;
     1357    float dragFactor = (contentsWidth() - visibleContentWidth * frameScaleFactor) / maxX;
     1358
     1359    return x * dragFactor / frameScaleFactor;
    13601360}
    13611361
     
    13851385        return y;
    13861386
    1387     float pageScaleFactor = m_frame->pageScaleFactor();
    1388     float dragFactor = (contentsHeight() - visibleContentHeight * pageScaleFactor) / maxY;
    1389 
    1390     return y * dragFactor / pageScaleFactor;
     1387    float frameScaleFactor = m_frame->frameScaleFactor();
     1388    float dragFactor = (contentsHeight() - visibleContentHeight * frameScaleFactor) / maxY;
     1389
     1390    return y * dragFactor / frameScaleFactor;
    13911391}
    13921392
  • trunk/Source/WebKit2/ChangeLog

    r95710 r95715  
     12011-09-22  Alpha Lam  <hclam@chromium.org>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68081
     4        Fix scroll in page scaling mode.
     5
     6        Reviewed by Simon Fraser.
     7
     8        * WebProcess/Plugins/PluginView.cpp: Rename pageScaleFactor to frameScaleFactor.
     9        (WebKit::PluginView::handleEvent):
     10        (WebKit::PluginView::viewGeometryDidChange):
     11        (WebKit::PluginView::clipRectInWindowCoordinates):
     12
    1132011-09-22  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
    214
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp

    r95585 r95715  
    583583            focusPluginElement();
    584584       
    585         // Adjust mouse coordinates to account for pageScaleFactor
    586         WebMouseEvent eventWithScaledCoordinates(*static_cast<const WebMouseEvent*>(currentEvent), frame()->pageScaleFactor());
     585        // Adjust mouse coordinates to account for frameScaleFactor
     586        WebMouseEvent eventWithScaledCoordinates(*static_cast<const WebMouseEvent*>(currentEvent), frame()->frameScaleFactor());
    587587        didHandleEvent = m_plugin->handleMouseEvent(eventWithScaledCoordinates);
    588588    } else if (event->type() == eventNames().mousewheelEvent && currentEvent->type() == WebEvent::Wheel) {
     
    650650    IntRect frameRectInWindowCoordinates = parent()->contentsToWindow(frameRect());
    651651   
    652     // Adjust bounds to account for pageScaleFactor
    653     frameRectInWindowCoordinates.scale(1 / frame()->pageScaleFactor());
     652    // Adjust bounds to account for frameScaleFactor
     653    frameRectInWindowCoordinates.scale(1 / frame()->frameScaleFactor());
    654654    m_plugin->geometryDidChange(frameRectInWindowCoordinates, clipRectInWindowCoordinates());
    655655}
     
    677677    frameRectInWindowCoordinates.intersect(windowClipRect);
    678678
    679     frameRectInWindowCoordinates.scale(1 / frame->pageScaleFactor());
     679    frameRectInWindowCoordinates.scale(1 / frame->frameScaleFactor());
    680680    return frameRectInWindowCoordinates;
    681681}
Note: See TracChangeset for help on using the changeset viewer.