Log Message
[EFL][WK2] Add APIs to set/get view source mode https://bugs.webkit.org/show_bug.cgi?id=106633
Patch by Jinwoo Song <[email protected]> on 2013-01-21 Reviewed by Gyuyoung Kim. Source/WebKit2: Added APIs to set/get view source mode for enabling to load the source code of the web page. * UIProcess/API/efl/ewk_view.cpp: (ewk_view_source_mode_set): (ewk_view_source_mode_get): * UIProcess/API/efl/ewk_view.h: * UIProcess/API/efl/tests/test_ewk2_view.cpp: (TEST_F): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::WebPageProxy): (WebKit::WebPageProxy::setMainFrameInViewSourceMode): * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::mainFrameInViewSourceMode): (WebPageProxy): Tools: Added a shotcut 'F8' in Minibrowser to display a source code of the web page in a new window. * MiniBrowser/efl/main.c: (on_key_down): (on_window_create): (window_create): (elm_main):
Modified Paths
- trunk/Source/WebKit2/ChangeLog
- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h
- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp
- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
- trunk/Source/WebKit2/UIProcess/WebPageProxy.h
- trunk/Tools/ChangeLog
- trunk/Tools/MiniBrowser/efl/main.c
Diff
Modified: trunk/Source/WebKit2/ChangeLog (140375 => 140376)
--- trunk/Source/WebKit2/ChangeLog 2013-01-22 01:44:42 UTC (rev 140375)
+++ trunk/Source/WebKit2/ChangeLog 2013-01-22 01:52:48 UTC (rev 140376)
@@ -1,3 +1,26 @@
+2013-01-21 Jinwoo Song <[email protected]>
+
+ [EFL][WK2] Add APIs to set/get view source mode
+ https://bugs.webkit.org/show_bug.cgi?id=106633
+
+ Reviewed by Gyuyoung Kim.
+
+ Added APIs to set/get view source mode for enabling to load
+ the source code of the web page.
+
+ * UIProcess/API/efl/ewk_view.cpp:
+ (ewk_view_source_mode_set):
+ (ewk_view_source_mode_get):
+ * UIProcess/API/efl/ewk_view.h:
+ * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+ (TEST_F):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ (WebKit::WebPageProxy::setMainFrameInViewSourceMode):
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::mainFrameInViewSourceMode):
+ (WebPageProxy):
+
2013-01-21 Sudarsana Nagineni <[email protected]>
[EFL][WK2] Implement WebInspector::localizedStringsURL() on EFL
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp (140375 => 140376)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2013-01-22 01:44:42 UTC (rev 140375)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp 2013-01-22 01:52:48 UTC (rev 140376)
@@ -982,3 +982,19 @@
return true;
}
+
+Eina_Bool ewk_view_source_mode_set(Evas_Object* ewkView, Eina_Bool enabled)
+{
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
+
+ impl->page()->setMainFrameInViewSourceMode(enabled);
+
+ return true;
+}
+
+Eina_Bool ewk_view_source_mode_get(const Evas_Object* ewkView)
+{
+ EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
+
+ return impl->page()->mainFrameInViewSourceMode();
+}
Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h (140375 => 140376)
--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2013-01-22 01:44:42 UTC (rev 140375)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view.h 2013-01-22 01:52:48 UTC (rev 140376)
@@ -828,6 +828,30 @@
*/
EAPI Eina_Bool ewk_view_page_contents_get(const Evas_Object *o, Ewk_Page_Contents_Type type, Ewk_Page_Contents_Cb callback);
+/**
+ * Sets the source mode as EINA_TRUE to display the web source code
+ * or EINA_FALSE otherwise. The default value is EINA_FALSE.
+ *
+ * This method should be called before loading new contents on web view
+ * so that the new view mode will be applied to the new contents.
+ *
+ * @param o view object to set the view source mode
+ * @param enabled a state to set view source mode
+ *
+ * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
+ */
+EAPI Eina_Bool ewk_view_source_mode_set(Evas_Object *o, Eina_Bool enabled);
+
+/**
+ * Gets the view source mode of the current web page.
+ *
+ * @param o view object to get the view source mode
+ *
+ * @return @c EINA_TRUE if the view mode is set to load source code, or
+ * @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_view_source_mode_get(const Evas_Object *o);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp (140375 => 140376)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp 2013-01-22 01:44:42 UTC (rev 140375)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp 2013-01-22 01:52:48 UTC (rev 140376)
@@ -945,3 +945,24 @@
while (!isObtainedPageContents)
ecore_main_loop_iterate();
}
+
+TEST_F(EWK2UnitTestBase, ewk_view_source_mode)
+{
+ const char indexHTML[] = "<html><body>Test Web View Mode<script>document.title=window.document.body.innerText;</script></body></html>";
+ const char contents[] = "Test Web View Mode";
+
+ // Default source mode is false.
+ EXPECT_FALSE(ewk_view_source_mode_get(webView()));
+
+ // Load web contents of the web page.
+ ewk_view_html_string_load(webView(), indexHTML, 0, 0);
+ EXPECT_TRUE(waitUntilTitleChangedTo(contents));
+
+ EXPECT_TRUE(ewk_view_source_mode_set(webView(), true));
+ EXPECT_TRUE(ewk_view_source_mode_get(webView()));
+
+ // TODO: Add a test case when the source mode is true.
+ // But it needs a way to retrieve the body contents to compare the loaded contents
+ // such as excuting the _javascript_, 'window.document.body.innerText'.
+ // https://bugs.webkit.org/show_bug.cgi?id=101904.
+}
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (140375 => 140376)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2013-01-22 01:44:42 UTC (rev 140375)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2013-01-22 01:52:48 UTC (rev 140376)
@@ -231,6 +231,7 @@
, m_mainFrameIsPinnedToRightSide(false)
, m_mainFrameIsPinnedToTopSide(false)
, m_mainFrameIsPinnedToBottomSide(false)
+ , m_mainFrameInViewSourceMode(false)
, m_pageCount(0)
, m_renderTreeSize(0)
, m_shouldSendEventsSynchronously(false)
@@ -4255,9 +4256,15 @@
}
#endif // PLATFORM(QT) || PLATFORM(GTK)
-void WebPageProxy::setMainFrameInViewSourceMode(bool inViewSourceMode)
+void WebPageProxy::setMainFrameInViewSourceMode(bool mainFrameInViewSourceMode)
{
- m_process->send(Messages::WebPage::SetMainFrameInViewSourceMode(inViewSourceMode), m_pageID);
+ if (m_mainFrameInViewSourceMode == mainFrameInViewSourceMode)
+ return;
+
+ m_mainFrameInViewSourceMode = mainFrameInViewSourceMode;
+
+ if (isValid())
+ m_process->send(Messages::WebPage::SetMainFrameInViewSourceMode(mainFrameInViewSourceMode), m_pageID);
}
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (140375 => 140376)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2013-01-22 01:44:42 UTC (rev 140375)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2013-01-22 01:52:48 UTC (rev 140376)
@@ -754,6 +754,7 @@
double minimumLayoutWidth() const { return m_minimumLayoutWidth; }
void setMinimumLayoutWidth(double);
+ bool mainFrameInViewSourceMode() const { return m_mainFrameInViewSourceMode; }
void setMainFrameInViewSourceMode(bool);
private:
@@ -1214,6 +1215,8 @@
bool m_mainFrameIsPinnedToTopSide;
bool m_mainFrameIsPinnedToBottomSide;
+ bool m_mainFrameInViewSourceMode;
+
unsigned m_pageCount;
WebCore::IntRect m_visibleScrollerThumbRect;
Modified: trunk/Tools/ChangeLog (140375 => 140376)
--- trunk/Tools/ChangeLog 2013-01-22 01:44:42 UTC (rev 140375)
+++ trunk/Tools/ChangeLog 2013-01-22 01:52:48 UTC (rev 140376)
@@ -1,3 +1,19 @@
+2013-01-21 Jinwoo Song <[email protected]>
+
+ [EFL][WK2] Add APIs to set/get view source mode
+ https://bugs.webkit.org/show_bug.cgi?id=106633
+
+ Reviewed by Gyuyoung Kim.
+
+ Added a shotcut 'F8' in Minibrowser to display a source code
+ of the web page in a new window.
+
+ * MiniBrowser/efl/main.c:
+ (on_key_down):
+ (on_window_create):
+ (window_create):
+ (elm_main):
+
2013-01-21 Nico Weber <[email protected]>
[chromium] Don't archive generated source files.
Modified: trunk/Tools/MiniBrowser/efl/main.c (140375 => 140376)
--- trunk/Tools/MiniBrowser/efl/main.c 2013-01-22 01:44:42 UTC (rev 140375)
+++ trunk/Tools/MiniBrowser/efl/main.c 2013-01-22 01:52:48 UTC (rev 140376)
@@ -141,7 +141,7 @@
}
};
-static Browser_Window *window_create(Evas_Object* opener, const char *url, int width, int height);
+static Browser_Window *window_create(Evas_Object* opener, const char *url, int width, int height, Eina_Bool view_mode);
static Browser_Window *window_find_with_elm_window(Evas_Object *elm_window)
{
@@ -290,16 +290,20 @@
} else if (!strcmp(ev->key, "F6")) {
info("Stop (F6) was pressed, stop loading.\n");
ewk_view_stop(ewk_view);
- } else if (!strcmp(ev->key, "F7")) {
+ } else if (!strcmp(ev->key, "F7")) {
Ewk_Pagination_Mode mode = ewk_view_pagination_mode_get(ewk_view);
mode = (++mode) % (EWK_PAGINATION_MODE_BOTTOM_TO_TOP + 1);
if (ewk_view_pagination_mode_set(ewk_view, mode))
info("Change Pagination Mode (F7) was pressed, changed to: %d\n", mode);
else
info("Change Pagination Mode (F7) was pressed, but NOT changed!");
+ } else if (!strcmp(ev->key, "F8")) {
+ info("Create souce code window (F8) was pressed.\n");
+ Browser_Window *window = window_create(ewk_view, ewk_view_url_get(ewk_view), 0, 0, EINA_TRUE);
+ windows = eina_list_append(windows, window);
} else if (!strcmp(ev->key, "n") && ctrlPressed) {
info("Create new window (Ctrl+n) was pressed.\n");
- Browser_Window *window = window_create(0, DEFAULT_URL, 0, 0);
+ Browser_Window *window = window_create(NULL, DEFAULT_URL, 0, 0, EINA_FALSE);
// 0 equals default width and height.
windows = eina_list_append(windows, window);
} else if (!strcmp(ev->key, "i") && ctrlPressed) {
@@ -879,7 +883,7 @@
if (!height)
height = window_height;
- Browser_Window *window = window_create(smartData->self, url, width, height);
+ Browser_Window *window = window_create(smartData->self, url, width, height, EINA_FALSE);
Evas_Object *new_view = window->ewk_view;
windows = eina_list_append(windows, window);
@@ -1074,7 +1078,7 @@
return button;
}
-static Browser_Window *window_create(Evas_Object *opener, const char *url, int width, int height)
+static Browser_Window *window_create(Evas_Object *opener, const char *url, int width, int height, Eina_Bool view_mode)
{
Browser_Window *window = malloc(sizeof(Browser_Window));
if (!window) {
@@ -1187,6 +1191,7 @@
ewk_view_theme_set(window->ewk_view, THEME_DIR "/default.edj");
if (device_pixel_ratio)
ewk_view_device_pixel_ratio_set(window->ewk_view, (float)device_pixel_ratio);
+ ewk_view_source_mode_set(window->ewk_view, view_mode);
/* Set the zoom level to default */
window->current_zoom_level = DEFAULT_ZOOM_LEVEL;
@@ -1317,10 +1322,10 @@
if (args < argc) {
char *url = ""
- window = window_create(0, url, 0, 0);
+ window = window_create(NULL, url, 0, 0, EINA_FALSE);
free(url);
} else
- window = window_create(0, DEFAULT_URL, 0, 0);
+ window = window_create(NULL, DEFAULT_URL, 0, 0, EINA_FALSE);
if (!window)
return quit(EINA_FALSE, "ERROR: could not create browser window.\n");
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo/webkit-changes
