[EFL][WK2] Add ewk_view_navigate API
authorryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jun 2013 08:10:24 +0000 (08:10 +0000)
committerryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Jun 2013 08:10:24 +0000 (08:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117467

Reviewed by Christophe Dumez.

The applications will use this API to navigate history more than one step.

* UIProcess/API/efl/ewk_back_forward_list_item_private.h:
(EwkBackForwardListItem::wkItem): Return WKBackForwardListItemRef for page to navigate.
* UIProcess/API/efl/ewk_view.cpp:
(ewk_view_navigate_to): Added new API.
* UIProcess/API/efl/ewk_view.h:
* UIProcess/API/efl/tests/test_ewk2_view.cpp:
(TEST_F): Added more test case for navigation.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@151427 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view.h
Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp

index 9db368c..72bde6d 100644 (file)
@@ -1,3 +1,20 @@
+2013-06-11  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [EFL][WK2] Add ewk_view_navigate API
+        https://bugs.webkit.org/show_bug.cgi?id=117467
+
+        Reviewed by Christophe Dumez.
+
+        The applications will use this API to navigate history more than one step.
+
+        * UIProcess/API/efl/ewk_back_forward_list_item_private.h:
+        (EwkBackForwardListItem::wkItem): Return WKBackForwardListItemRef for page to navigate.
+        * UIProcess/API/efl/ewk_view.cpp:
+        (ewk_view_navigate_to): Added new API.
+        * UIProcess/API/efl/ewk_view.h:
+        * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+        (TEST_F): Added more test case for navigation.
+
 2013-06-10  Jae Hyun Park  <jae.park@company100.net>
 
         [CoordinatedGraphics] Typos in custom shader support
index 8225532..7b6d20a 100644 (file)
@@ -48,6 +48,8 @@ public:
     const char* title() const;
     const char* originalURL() const;
 
+    WKBackForwardListItemRef wkItem() const { return m_wkItem.get(); }
+
 private:
     explicit EwkBackForwardListItem(WKBackForwardListItemRef itemRef);
 
index 9c2aded..17c21d5 100644 (file)
@@ -311,6 +311,16 @@ Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView
     return impl->backForwardList();
 }
 
+Eina_Bool ewk_view_navigate_to(Evas_Object* ewkView, const Ewk_Back_Forward_List_Item* item)
+{
+    EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
+    EWK_OBJ_GET_IMPL_OR_RETURN(const EwkBackForwardListItem, item, itemImpl, false);
+
+    WKPageGoToBackForwardListItem(impl->wkPage(), itemImpl->wkItem());
+
+    return true;
+}
+
 Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
 {
     EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
index 8595fd7..e991692 100644 (file)
@@ -490,6 +490,16 @@ EAPI Eina_Bool    ewk_view_forward_possible(Evas_Object *o);
 EAPI Ewk_Back_Forward_List *ewk_view_back_forward_list_get(const Evas_Object *o);
 
 /**
+ * Navigates to specified back-forward list item.
+ *
+ * @param o view object to navigate in the history
+ * @param item the back-forward list item
+ *
+ * @return @c EINA_TRUE on success or @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_view_navigate_to(Evas_Object *o, const Ewk_Back_Forward_List_Item *item);
+
+/**
  * Gets the current title of the main frame.
  *
  * It returns an internal string and should not
index 0ac8766..3968107 100644 (file)
@@ -131,6 +131,26 @@ TEST_F(EWK2UnitTestBase, ewk_view_navigation)
     ASSERT_STREQ("Page2", ewk_view_title_get(webView()));
     ASSERT_TRUE(ewk_view_back_possible(webView()));
     ASSERT_FALSE(ewk_view_forward_possible(webView()));
+
+    // Visit Page3
+    ewk_view_url_set(webView(), httpServer->getURLForPath("/Page3").data());
+    ASSERT_TRUE(waitUntilTitleChangedTo("Page3"));
+    ASSERT_STREQ("Page3", ewk_view_title_get(webView()));
+    ASSERT_TRUE(ewk_view_back_possible(webView()));
+    ASSERT_FALSE(ewk_view_forward_possible(webView()));
+
+    Ewk_Back_Forward_List* list = ewk_view_back_forward_list_get(webView());
+    ASSERT_EQ(3, ewk_back_forward_list_count(list));
+
+    // Navigate to Page1
+    ewk_view_navigate_to(webView(), ewk_back_forward_list_item_at_index_get(list, -2));
+    ASSERT_TRUE(waitUntilTitleChangedTo("Page1"));
+    ASSERT_STREQ("Page1", ewk_view_title_get(webView()));
+
+    // Navigate to Page3
+    ewk_view_navigate_to(webView(), ewk_back_forward_list_item_at_index_get(list, 2));
+    ASSERT_TRUE(waitUntilTitleChangedTo("Page3"));
+    ASSERT_STREQ("Page3", ewk_view_title_get(webView()));
 }
 
 TEST_F(EWK2UnitTestBase, ewk_view_custom_encoding)