Title: [91012] trunk/Source/WebKit2
Revision
91012
Author
adac...@apple.com
Date
2011-07-14 10:42:12 -0700 (Thu, 14 Jul 2011)

Log Message

        Implement support to center selection on a page for WebKit2.
        https://bugs.webkit.org/show_bug.cgi?id=64481

        Reviewed by Anders Carlsson.

        * UIProcess/API/C/WKPage.cpp:
        (WKPageCenterSelectionInVisibleArea): Added.  Call WebPageProxy::centerSelectionInVisibleArea().
        * UIProcess/API/C/WKPage.h:
        * UIProcess/WebPageProxy.cpp:
        (WebKit::WebPageProxy::centerSelectionInVisibleArea): Send message to the WebProcess to center selection.
        * UIProcess/WebPageProxy.h:
        * WebProcess/WebPage/WebPage.cpp:
        (WebKit::WebPage::centerSelectionInVisibleArea): Get the FrameSelection from the main frame and call
        revealSelection() to center it.
        * WebProcess/WebPage/WebPage.h:
        * WebProcess/WebPage/WebPage.messages.in: Add the CenterSelectionInVisibleArea message.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (91011 => 91012)


--- trunk/Source/WebKit2/ChangeLog	2011-07-14 17:40:21 UTC (rev 91011)
+++ trunk/Source/WebKit2/ChangeLog	2011-07-14 17:42:12 UTC (rev 91012)
@@ -1,3 +1,22 @@
+2011-07-14  Ada Chan  <adac...@apple.com>
+
+        Implement support to center selection on a page for WebKit2.
+        https://bugs.webkit.org/show_bug.cgi?id=64481
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageCenterSelectionInVisibleArea): Added.  Call WebPageProxy::centerSelectionInVisibleArea().
+        * UIProcess/API/C/WKPage.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::centerSelectionInVisibleArea): Send message to the WebProcess to center selection.
+        * UIProcess/WebPageProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::centerSelectionInVisibleArea): Get the FrameSelection from the main frame and call
+        revealSelection() to center it.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in: Add the CenterSelectionInVisibleArea message.
+
 2011-07-14  MORITA Hajime  <morr...@google.com>
 
         Unreviewed, rolling out r90976, r90981, and r90985.

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (91011 => 91012)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2011-07-14 17:40:21 UTC (rev 91011)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2011-07-14 17:42:12 UTC (rev 91012)
@@ -354,6 +354,11 @@
     return toImpl(pageRef)->setMaintainsInactiveSelection(newValue);
 }
 
+void WKPageCenterSelectionInVisibleArea(WKPageRef pageRef)
+{
+    return toImpl(pageRef)->centerSelectionInVisibleArea();
+}
+
 void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
 {
     toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount);

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.h (91011 => 91012)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.h	2011-07-14 17:40:21 UTC (rev 91011)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.h	2011-07-14 17:42:12 UTC (rev 91012)
@@ -367,6 +367,7 @@
 WK_EXPORT bool WKPageIsContentEditable(WKPageRef page);
 
 WK_EXPORT void WKPageSetMaintainsInactiveSelection(WKPageRef page, bool maintainsInactiveSelection);
+WK_EXPORT void WKPageCenterSelectionInVisibleArea(WKPageRef page);
     
 WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
 WK_EXPORT void WKPageHideFindUI(WKPageRef page);

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (91011 => 91012)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-07-14 17:40:21 UTC (rev 91011)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2011-07-14 17:42:12 UTC (rev 91012)
@@ -1006,6 +1006,14 @@
     process()->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
 }
 
+void WebPageProxy::centerSelectionInVisibleArea()
+{
+    if (!isValid())
+        return;
+
+    process()->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
+}
+
 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
 {
     if (!isValid())

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (91011 => 91012)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-07-14 17:40:21 UTC (rev 91011)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2011-07-14 17:42:12 UTC (rev 91012)
@@ -351,6 +351,7 @@
 #endif
 
     void scrollBy(WebCore::ScrollDirection, WebCore::ScrollGranularity);
+    void centerSelectionInVisibleArea();
 
     String pageTitle() const;
     const String& toolTip() const { return m_toolTip; }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (91011 => 91012)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-07-14 17:40:21 UTC (rev 91011)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2011-07-14 17:42:12 UTC (rev 91012)
@@ -1233,6 +1233,15 @@
     scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity));
 }
 
+void WebPage::centerSelectionInVisibleArea()
+{
+    Frame* coreFrame = m_mainFrame->coreFrame();
+    if (!coreFrame)
+        return;
+
+    coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+}
+
 void WebPage::setActive(bool isActive)
 {
     m_page->focusController()->setActive(isActive);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (91011 => 91012)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2011-07-14 17:40:21 UTC (rev 91011)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2011-07-14 17:42:12 UTC (rev 91012)
@@ -153,6 +153,8 @@
 
     void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
 
+    void centerSelectionInVisibleArea();
+
 #if ENABLE(INSPECTOR)
     WebInspector* inspector();
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (91011 => 91012)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2011-07-14 17:40:21 UTC (rev 91011)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2011-07-14 17:42:12 UTC (rev 91012)
@@ -45,6 +45,7 @@
     ContextMenuHidden()
 
     ScrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
+    CenterSelectionInVisibleArea()
 
     GoBack(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
     GoForward(uint64_t backForwardItemID, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to