https://bugs.webkit.org/show_bug.cgi?id=68192
Patch by Varun Jain <varunjain@google.com> 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:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@95252
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-15 Varun Jain <varunjain@google.com>
+
+ 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 <eric@webkit.org>
Remove ENABLE(SVG_AS_IMAGE) since all major ports have it on by default
// 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 ----------------------------------------------------------------
}
}
+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;
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,