Changeset 95890 in webkit


Ignore:
Timestamp:
Sep 23, 2011 5:23:55 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

.: Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
https://bugs.webkit.org/show_bug.cgi?id=68198

Patch by Varun Jain <varunjain@google.com> on 2011-09-23
Reviewed by Dimitri Glazkov.

  • Source/autotools/symbols.filter:

Source/WebCore: Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
https://bugs.webkit.org/show_bug.cgi?id=68198

Patch by Varun Jain <varunjain@google.com> on 2011-09-23
Reviewed by Dimitri Glazkov.

Tests: fast/dom/scroll-element-to-rect-centered.html

fast/dom/scroll-element-to-rect.html

  • WebCore.exp.in:
  • page/FrameView.cpp:

(WebCore::FrameView::scrollElementToRect):

  • page/FrameView.h:
  • testing/Internals.cpp:

(WebCore::Internals::scrollElementToRect):

  • testing/Internals.h:
  • testing/Internals.idl:

Source/WebKit/chromium: Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
https://bugs.webkit.org/show_bug.cgi?id=68198

Patch by Varun Jain <varunjain@google.com> on 2011-09-23
Reviewed by Dimitri Glazkov.

  • public/WebView.h:

(WebKit::WebView::scrollFocusedNodeIntoRect):

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::scrollFocusedNodeIntoRect):

Source/WebKit2: Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
https://bugs.webkit.org/show_bug.cgi?id=68198

Patch by Varun Jain <varunjain@google.com> on 2011-09-23
Reviewed by Dimitri Glazkov.

  • win/WebKit2.def:
  • win/WebKit2CFLite.def:

LayoutTests: Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
https://bugs.webkit.org/show_bug.cgi?id=68198

Patch by Varun Jain <varunjain@google.com> on 2011-09-23
Reviewed by Dimitri Glazkov.

  • fast/dom/scroll-element-to-rect-centered-expected.txt: Added.
  • fast/dom/scroll-element-to-rect-centered.html: Added.
  • fast/dom/scroll-element-to-rect-expected.txt: Added.
  • fast/dom/scroll-element-to-rect.html: Added.
Location:
trunk
Files:
4 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r95849 r95890  
     12011-09-23  Varun Jain  <varunjain@google.com>
     2
     3        Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
     4        https://bugs.webkit.org/show_bug.cgi?id=68198
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * Source/autotools/symbols.filter:
     9
    1102011-09-23  Mark Hahnenberg  <mhahnenberg@apple.com>
    211
  • trunk/LayoutTests/ChangeLog

    r95888 r95890  
     12011-09-23  Varun Jain  <varunjain@google.com>
     2
     3        Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
     4        https://bugs.webkit.org/show_bug.cgi?id=68198
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * fast/dom/scroll-element-to-rect-centered-expected.txt: Added.
     9        * fast/dom/scroll-element-to-rect-centered.html: Added.
     10        * fast/dom/scroll-element-to-rect-expected.txt: Added.
     11        * fast/dom/scroll-element-to-rect.html: Added.
     12
    1132011-09-23  Dean Jackson  <dino@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r95889 r95890  
     12011-09-23  Varun Jain  <varunjain@google.com>
     2
     3        Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
     4        https://bugs.webkit.org/show_bug.cgi?id=68198
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Tests: fast/dom/scroll-element-to-rect-centered.html
     9               fast/dom/scroll-element-to-rect.html
     10
     11        * WebCore.exp.in:
     12        * page/FrameView.cpp:
     13        (WebCore::FrameView::scrollElementToRect):
     14        * page/FrameView.h:
     15        * testing/Internals.cpp:
     16        (WebCore::Internals::scrollElementToRect):
     17        * testing/Internals.h:
     18        * testing/Internals.idl:
     19
    1202011-09-23  Mihai Parparita  <mihaip@chromium.org>
    221
  • trunk/Source/WebCore/WebCore.exp.in

    r95849 r95890  
    986986__ZN7WebCore9FrameView6createEPNS_5FrameERKNS_7IntSizeE
    987987__ZN7WebCore9FrameView17paintControlTintsEv
     988__ZN7WebCore9FrameView19scrollElementToRectEPNS_7ElementERKNS_7IntRectE
    988989__ZN7WebCore9HTMLNames10listingTagE
    989990__ZN7WebCore9HTMLNames11textareaTagE
  • trunk/Source/WebCore/page/FrameView.cpp

    r95738 r95890  
    16231623}
    16241624
     1625void FrameView::scrollElementToRect(Element* element, const IntRect& rect)
     1626{
     1627    m_frame->document()->updateLayoutIgnorePendingStylesheets();
     1628
     1629    LayoutRect bounds = element->boundsInWindowSpace();
     1630    int centeringOffsetX = (rect.width() - bounds.width()) / 2;
     1631    int centeringOffsetY = (rect.height() - bounds.height()) / 2;
     1632    scrollBy(IntSize(bounds.x() - centeringOffsetX - rect.x(), bounds.y() - centeringOffsetY - rect.y()));
     1633}
     1634
    16251635void FrameView::setScrollPosition(const LayoutPoint& scrollPoint)
    16261636{
  • trunk/Source/WebCore/page/FrameView.h

    r95738 r95890  
    3737
    3838class Color;
     39class Element;
    3940class Event;
    4041class FloatSize;
     
    261262    bool scrollToAnchor(const String&);
    262263    void maintainScrollPositionAtAnchor(Node*);
     264    void scrollElementToRect(Element*, const IntRect&);
    263265
    264266    // Methods to convert points and rects between the coordinate space of the renderer, and this view.
  • trunk/Source/WebCore/testing/Internals.cpp

    r95685 r95890  
    3838#include "HTMLTextAreaElement.h"
    3939#include "InspectorController.h"
     40#include "IntRect.h"
    4041#include "MemoryCache.h"
    4142#include "NodeRenderingContext.h"
     
    377378}
    378379
    379 }
     380void Internals::scrollElementToRect(Element* element, long x, long y, long w, long h, ExceptionCode& ec)
     381{
     382    if (!element || !element->document() || !element->document()->view()) {
     383        ec = INVALID_ACCESS_ERR;
     384        return;
     385    }
     386    FrameView* frameView = element->document()->view();
     387    frameView->scrollElementToRect(element, IntRect(x, y, w, h));
     388}
     389
     390}
  • trunk/Source/WebCore/testing/Internals.h

    r95685 r95890  
    8888    String suggestedValue(Element* inputElement, ExceptionCode&);
    8989    void setSuggestedValue(Element* inputElement, const String&, ExceptionCode&);
     90    void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionCode&);
    9091
    9192    static const char* internalsId;
  • trunk/Source/WebCore/testing/Internals.idl

    r95685 r95890  
    6464
    6565        void paintControlTints(in Document document) raises (DOMException);
     66
     67        void scrollElementToRect(in Element element, in long x, in long y, in long w, in long h) raises (DOMException);
    6668    };
    6769}
  • trunk/Source/WebKit/chromium/ChangeLog

    r95889 r95890  
     12011-09-23  Varun Jain  <varunjain@google.com>
     2
     3        Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
     4        https://bugs.webkit.org/show_bug.cgi?id=68198
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * public/WebView.h:
     9        (WebKit::WebView::scrollFocusedNodeIntoRect):
     10        * src/WebViewImpl.cpp:
     11        (WebKit::WebViewImpl::scrollFocusedNodeIntoRect):
     12
    1132011-09-23  Mihai Parparita  <mihaip@chromium.org>
    214
  • trunk/Source/WebKit/chromium/public/WebView.h

    r95252 r95890  
    176176
    177177    // Scrolls the node currently in focus into |rect|, where |rect| is in
    178     // screen space.
    179     virtual void scrollFocusedNodeIntoRect(const WebRect& rect) { }
     178    // window space.
     179    virtual void scrollFocusedNodeIntoRect(const WebRect&) { }
    180180
    181181
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r95861 r95890  
    18211821void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect)
    18221822{
     1823    Frame* frame = page()->mainFrame();
    18231824    Node* focusedNode = focusedWebCoreNode();
    1824     if (!focusedNode || !focusedNode->isElementNode())
     1825    if (!frame || !frame->view() || !focusedNode || !focusedNode->isElementNode())
    18251826        return;
    18261827    Element* elementNode = static_cast<Element*>(focusedNode);
    1827     LayoutRect bounds = elementNode->boundsInWindowSpace();
    1828     int centeringOffsetX = (rect.width - bounds.width()) / 2;
    1829     int centeringOffsetY = (rect.height - bounds.height()) / 2;
    1830     IntSize scrollOffset(bounds.x() - centeringOffsetX, bounds.y() - centeringOffsetY);
    1831     Frame* frame = mainFrameImpl()->frame();
    1832     if (frame && frame->view())
    1833         frame->view()->scrollBy(scrollOffset);
     1828    frame->view()->scrollElementToRect(elementNode, IntRect(rect.x, rect.y, rect.width, rect.height));
    18341829}
    18351830
  • trunk/Source/WebKit2/ChangeLog

    r95878 r95890  
     12011-09-23  Varun Jain  <varunjain@google.com>
     2
     3        Refactor WebViewImpl::scrollFocusedNodeIntoRect to a better place and add tests
     4        https://bugs.webkit.org/show_bug.cgi?id=68198
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * win/WebKit2.def:
     9        * win/WebKit2CFLite.def:
     10
    1112011-09-23  Chang Shu  <cshu@webkit.org>
    212
  • trunk/Source/WebKit2/win/WebKit2.def

    r95685 r95890  
    163163        ?page@Document@WebCore@@QBEPAVPage@2@XZ
    164164        ?paintControlTints@FrameView@WebCore@@AAEXXZ
     165        ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z
    165166        ?removeShadowRoot@Element@WebCore@@QAEXXZ
    166167        ?setDisabled@MemoryCache@WebCore@@QAEX_N@Z
  • trunk/Source/WebKit2/win/WebKit2CFLite.def

    r95685 r95890  
    157157        ?page@Document@WebCore@@QBEPAVPage@2@XZ
    158158        ?paintControlTints@FrameView@WebCore@@AAEXXZ
     159        ?scrollElementToRect@FrameView@WebCore@@QAEXPAVElement@2@ABVIntRect@2@@Z
    159160        ?removeShadowRoot@Element@WebCore@@QAEXXZ
    160161        ?setDisabled@MemoryCache@WebCore@@QAEX_N@Z
  • trunk/Source/autotools/symbols.filter

    r95849 r95890  
    7878_ZN7WebCore10ScrollView23setScrollbarsSuppressedEbb;
    7979_ZN7WebCore9FrameView17paintControlTintsEv;
     80_ZN7WebCore9FrameView19scrollElementToRectEPNS_7ElementERKNS_7IntRectE;
    8081local:
    8182_Z*;
Note: See TracChangeset for help on using the changeset viewer.