Title: [95252] trunk
Revision
95252
Author
[email protected]
Date
2011-09-15 18:25:24 -0700 (Thu, 15 Sep 2011)

Log Message

Add method to scroll current node to specific position in Chromium WebKit API
https://bugs.webkit.org/show_bug.cgi?id=68192

Patch by Varun Jain <[email protected]> on 2011-09-15
Reviewed by Dimitri Glazkov.

*  Source/WebKit/chromium/public/WebView.h:
*  Source/WebKit/chromium/src/WebViewImpl.cpp:
*  Source/WebKit/chromium/src/WebViewImpl.h:

Modified Paths

Diff

Modified: trunk/ChangeLog (95251 => 95252)


--- trunk/ChangeLog	2011-09-16 01:24:06 UTC (rev 95251)
+++ trunk/ChangeLog	2011-09-16 01:25:24 UTC (rev 95252)
@@ -1,3 +1,14 @@
+2011-09-15  Varun Jain  <[email protected]>
+
+        Add method to scroll current node to specific position in Chromium WebKit API
+        https://bugs.webkit.org/show_bug.cgi?id=68192
+
+        Reviewed by Dimitri Glazkov.
+
+        *  Source/WebKit/chromium/public/WebView.h:
+        *  Source/WebKit/chromium/src/WebViewImpl.cpp:
+        *  Source/WebKit/chromium/src/WebViewImpl.h:
+
 2011-09-15  Eric Seidel  <[email protected]>
 
         Remove ENABLE(SVG_AS_IMAGE) since all major ports have it on by default

Modified: trunk/Source/WebKit/chromium/public/WebView.h (95251 => 95252)


--- trunk/Source/WebKit/chromium/public/WebView.h	2011-09-16 01:24:06 UTC (rev 95251)
+++ trunk/Source/WebKit/chromium/public/WebView.h	2011-09-16 01:25:24 UTC (rev 95252)
@@ -174,7 +174,11 @@
     // Scrolls the node currently in focus into view.
     virtual void scrollFocusedNodeIntoView() = 0;
 
+    // Scrolls the node currently in focus into |rect|, where |rect| is in
+    // screen space.
+    virtual void scrollFocusedNodeIntoRect(const WebRect& rect) { }
 
+
     // Zoom ----------------------------------------------------------------
 
     // Returns the current zoom level.  0 is "original size", and each increment

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (95251 => 95252)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-09-16 01:24:06 UTC (rev 95251)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp	2011-09-16 01:25:24 UTC (rev 95252)
@@ -1817,6 +1817,21 @@
     }
 }
 
+void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect)
+{
+    Node* focusedNode = focusedWebCoreNode();
+    if (!focusedNode || !focusedNode->isElementNode())
+        return;
+    Element* elementNode = static_cast<Element*>(focusedNode);
+    LayoutRect bounds = elementNode->boundsInWindowSpace();
+    int centeringOffsetX = (rect.width - bounds.width()) / 2;
+    int centeringOffsetY = (rect.height - bounds.height()) / 2;
+    IntSize scrollOffset(bounds.x() - centeringOffsetX, bounds.y() - centeringOffsetY);
+    Frame* frame = mainFrameImpl()->frame();
+    if (frame && frame->view())
+        frame->view()->scrollBy(scrollOffset);
+}
+
 double WebViewImpl::zoomLevel()
 {
     return m_zoomLevel;

Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (95251 => 95252)


--- trunk/Source/WebKit/chromium/src/WebViewImpl.h	2011-09-16 01:24:06 UTC (rev 95251)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h	2011-09-16 01:25:24 UTC (rev 95252)
@@ -153,6 +153,7 @@
     virtual void setInitialFocus(bool reverse);
     virtual void clearFocusedNode();
     virtual void scrollFocusedNodeIntoView();
+    virtual void scrollFocusedNodeIntoRect(const WebRect&);
     virtual double zoomLevel();
     virtual double setZoomLevel(bool textOnly, double zoomLevel);
     virtual void zoomLimitsChanged(double minimumZoomLevel,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to