From 8995624c0239268bc6587c5e691d2eb67afa84c5 Mon Sep 17 00:00:00 2001 From: SeungSeop Park Date: Thu, 12 Jun 2014 13:15:10 +0900 Subject: [PATCH] break dependency to Ewk_Hit_Test (removed ewk_hit_test.h) Issue: CBEFL-92 Change-Id: Id6b2e26d3b8ca56a96d8c8075987aaed655653fd --- tizen_src/ewk_api_headers/public/ewk_hit_test.h | 35 -------- tizen_src/impl/API/ewk_hit_test_private.h | 6 +- .../renderer_host/render_message_filter_efl.cc | 7 +- .../renderer_host/render_message_filter_efl.h | 5 +- tizen_src/impl/chromium-efl.gyp | 2 + tizen_src/impl/common/render_messages_efl.h | 8 +- tizen_src/impl/eweb_view.cc | 18 ++-- tizen_src/impl/eweb_view.h | 11 ++- .../impl/renderer/render_view_observer_efl.cc | 2 +- tizen_src/impl/tizen_webview/public/tw_hit_test.cc | 95 ++++++++++++++++++++++ tizen_src/impl/tizen_webview/public/tw_hit_test.h | 46 +++++++++++ 11 files changed, 176 insertions(+), 59 deletions(-) delete mode 100644 tizen_src/ewk_api_headers/public/ewk_hit_test.h create mode 100644 tizen_src/impl/tizen_webview/public/tw_hit_test.cc diff --git a/tizen_src/ewk_api_headers/public/ewk_hit_test.h b/tizen_src/ewk_api_headers/public/ewk_hit_test.h deleted file mode 100644 index b91217cc..0000000 --- a/tizen_src/ewk_api_headers/public/ewk_hit_test.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2013 Samsung Electronics - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef ewk_hit_test_h -#define ewk_hit_test_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** Creates a type name for _Ewk_Hit_Test */ -typedef struct _Ewk_Hit_Test Ewk_Hit_Test; - - -#ifdef __cplusplus -} -#endif - -#endif // ewk_hit_test_h diff --git a/tizen_src/impl/API/ewk_hit_test_private.h b/tizen_src/impl/API/ewk_hit_test_private.h index ecfd817a1..377d36b 100644 --- a/tizen_src/impl/API/ewk_hit_test_private.h +++ b/tizen_src/impl/API/ewk_hit_test_private.h @@ -27,8 +27,6 @@ #include #include "third_party/skia/include/core/SkBitmap.h" - -#include "public/ewk_hit_test.h" #include "tizen_webview/public/tw_hit_test.h" typedef std::map NodeAttributesMap; @@ -37,6 +35,10 @@ typedef std::map NodeAttributesMap; struct _Ewk_Hit_Test { _Ewk_Hit_Test(); _Ewk_Hit_Test(const _Ewk_Hit_Test& other); + // TODO: check whether bitwise assignment is acceptable (e.g, attributeHash) + // If not, proper implementation for below should be added: + // _Ewk_Hit_Test& operator=(const _Ewk_Hit_Test&); + // Note: Currently the operation is used in EwebView::UpdateHitTestData(). tizen_webview::Hit_Test_Result_Context context; std::string linkURI; diff --git a/tizen_src/impl/browser/renderer_host/render_message_filter_efl.cc b/tizen_src/impl/browser/renderer_host/render_message_filter_efl.cc index c78dae8..c37b5ad 100644 --- a/tizen_src/impl/browser/renderer_host/render_message_filter_efl.cc +++ b/tizen_src/impl/browser/renderer_host/render_message_filter_efl.cc @@ -67,9 +67,12 @@ void RenderMessageFilterEfl::OnDecideNavigationPolicy(NavigationPolicyParams par } void RenderMessageFilterEfl::OnReceivedHitTestData(int render_view, - const Ewk_Hit_Test& hit_test_data, + const _Ewk_Hit_Test& hit_test_data, const NodeAttributesMap& node_attributes) { - if (content::WebContents* web_contents = WebContentsFromViewID(render_process_id_, render_view)) { + content::WebContents* web_contents = WebContentsFromViewID( + render_process_id_, render_view); + + if (web_contents) { content::WebContentsDelegateEfl* delegate = static_cast(web_contents->GetDelegate()); delegate->web_view()->UpdateHitTestData(hit_test_data, node_attributes); diff --git a/tizen_src/impl/browser/renderer_host/render_message_filter_efl.h b/tizen_src/impl/browser/renderer_host/render_message_filter_efl.h index 9237055..520053c 100644 --- a/tizen_src/impl/browser/renderer_host/render_message_filter_efl.h +++ b/tizen_src/impl/browser/renderer_host/render_message_filter_efl.h @@ -48,8 +48,9 @@ class RenderMessageFilterEfl : public content::BrowserMessageFilter { content::BrowserThread::ID*) OVERRIDE; private: - void OnDecideNavigationPolicy(NavigationPolicyParams, bool*); - void OnReceivedHitTestData(int, const Ewk_Hit_Test&, const NodeAttributesMap&); + void OnDecideNavigationPolicy(NavigationPolicyParams, bool* handled); + void OnReceivedHitTestData(int view, const _Ewk_Hit_Test& hit_test_data, + const NodeAttributesMap& node_attributes); int render_process_id_; }; diff --git a/tizen_src/impl/chromium-efl.gyp b/tizen_src/impl/chromium-efl.gyp index cd9433cb..5085ace 100644 --- a/tizen_src/impl/chromium-efl.gyp +++ b/tizen_src/impl/chromium-efl.gyp @@ -238,6 +238,8 @@ #TODO: making separate gyp for tizen_webview '<(chrome_src_dir)/tizen_webview/public/tw_custom_handlers.h', '<(chrome_src_dir)/tizen_webview/public/tw_custom_handlers.cc', + '<(chrome_src_dir)/tizen_webview/public/tw_hit_test.h', + '<(chrome_src_dir)/tizen_webview/public/tw_hit_test.cc', '<(chrome_src_dir)/tizen_webview/public/tw_notification.cc', '<(chrome_src_dir)/tizen_webview/public/tw_notification.h', '<(chrome_src_dir)/tizen_webview/public/tw_security_origin.cc', diff --git a/tizen_src/impl/common/render_messages_efl.h b/tizen_src/impl/common/render_messages_efl.h index 035dfc6..f68bb96 100644 --- a/tizen_src/impl/common/render_messages_efl.h +++ b/tizen_src/impl/common/render_messages_efl.h @@ -82,17 +82,17 @@ IPC_STRUCT_TRAITS_END() IPC_ENUM_TRAITS(tizen_webview::Hit_Test_Mode) IPC_ENUM_TRAITS(tizen_webview::Hit_Test_Result_Context) -IPC_STRUCT_TRAITS_BEGIN(Ewk_Hit_Test::Hit_Test_Node_Data) +IPC_STRUCT_TRAITS_BEGIN(_Ewk_Hit_Test::Hit_Test_Node_Data) IPC_STRUCT_TRAITS_MEMBER(tagName) IPC_STRUCT_TRAITS_MEMBER(nodeValue) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(Ewk_Hit_Test::Hit_Test_Image_Buffer) +IPC_STRUCT_TRAITS_BEGIN(_Ewk_Hit_Test::Hit_Test_Image_Buffer) IPC_STRUCT_TRAITS_MEMBER(fileNameExtension) IPC_STRUCT_TRAITS_MEMBER(imageBitmap) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(Ewk_Hit_Test) +IPC_STRUCT_TRAITS_BEGIN(_Ewk_Hit_Test) IPC_STRUCT_TRAITS_MEMBER(context) IPC_STRUCT_TRAITS_MEMBER(linkURI) IPC_STRUCT_TRAITS_MEMBER(linkLabel) @@ -211,7 +211,7 @@ IPC_MESSAGE_ROUTED2(EwkHostMsg_DidChangeMaxScrollOffset, IPC_MESSAGE_CONTROL3(EwkViewHostMsg_HitTestReply, int, /* render_view_id */ - Ewk_Hit_Test, /* Ewk Hit test data without node map */ + _Ewk_Hit_Test, /* Ewk Hit test data without node map */ NodeAttributesMap /* node attributes */) IPC_MESSAGE_ROUTED1(EwkViewMsg_GetMHTMLData, diff --git a/tizen_src/impl/eweb_view.cc b/tizen_src/impl/eweb_view.cc index 4e89eff..f737c00 100644 --- a/tizen_src/impl/eweb_view.cc +++ b/tizen_src/impl/eweb_view.cc @@ -56,6 +56,8 @@ #include "grit/webkit_strings.h" #include "ui/base/l10n/l10n_util.h" #include "devtools_delegate_efl.h" + +#include "tizen_webview/public/tw_hit_test.h" #include "tizen_webview/public/tw_touch_point.h" #include "tizen_webview/public/tw_web_context.h" #ifdef OS_TIZEN @@ -929,7 +931,8 @@ void EWebView::DispatchPostponedGestureEvent(ui::GestureEvent* event) { ClearSelection(); if (settings && settings->textSelectionEnabled()) { - _Ewk_Hit_Test* hit_test_data = RequestHitTestDataAt(event->x(), event->y(), TW_HIT_TEST_MODE_DEFAULT); + tizen_webview::Hit_Test* hit_test = RequestHitTestDataAt(event->x(), event->y(), TW_HIT_TEST_MODE_DEFAULT); + _Ewk_Hit_Test* hit_test_data = hit_test->impl; if (hit_test_data && hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_EDITABLE) { selection_controller_->SetSelectionStatus(true); selection_controller_->SetCaretSelectionStatus(true); @@ -953,11 +956,12 @@ void EWebView::DispatchPostponedGestureEvent(ui::GestureEvent* event) { } else { LOG(INFO) << __PRETTY_FUNCTION__ << ":: hit_test = " << hit_test_data->context; } - delete hit_test_data; + delete hit_test; rwhv()->HandleGesture(event); } } else if ((event->details().type() == ui::ET_GESTURE_TAP) || (event->details().type() == ui::ET_GESTURE_SHOW_PRESS)) { - _Ewk_Hit_Test* hit_test_data = RequestHitTestDataAt(event->x(), event->y(), TW_HIT_TEST_MODE_DEFAULT); + tizen_webview::Hit_Test* hit_test = RequestHitTestDataAt(event->x(), event->y(), TW_HIT_TEST_MODE_DEFAULT); + _Ewk_Hit_Test* hit_test_data = hit_test->impl; LOG(INFO) << __PRETTY_FUNCTION__ << " hit_test = " << hit_test_data; if (hit_test_data && hit_test_data->context & TW_HIT_TEST_RESULT_CONTEXT_EDITABLE) { LOG(INFO) << "DispatchPostponedGestureEvent :: TW_HIT_TEST_RESULT_CONTEXT_EDITABLE"; @@ -976,7 +980,7 @@ void EWebView::DispatchPostponedGestureEvent(ui::GestureEvent* event) { selection_controller_->SetSelectionEditable(false); //ClearSelection(); } - delete hit_test_data; + delete hit_test; rwhv()->HandleGesture(event); } else { ClearSelection(); @@ -1478,7 +1482,7 @@ bool EWebView::ClearSelection() { return retval; } -Ewk_Hit_Test* EWebView::RequestHitTestDataAt(int x, int y, tizen_webview::Hit_Test_Mode mode) { +tizen_webview::Hit_Test* EWebView::RequestHitTestDataAt(int x, int y, tizen_webview::Hit_Test_Mode mode) { RenderViewHost* render_view_host = web_contents_delegate()->web_contents()->GetRenderViewHost(); DCHECK(render_view_host); @@ -1489,10 +1493,10 @@ Ewk_Hit_Test* EWebView::RequestHitTestDataAt(int x, int y, tizen_webview::Hit_Te base::ThreadRestrictions::ScopedAllowWait allow_wait; hit_test_completion_.Wait(); } - return new Ewk_Hit_Test(hit_test_data_); + return new tizen_webview::Hit_Test(hit_test_data_); } -void EWebView::UpdateHitTestData(const Ewk_Hit_Test& hit_test_data, const NodeAttributesMap& node_attributes) { +void EWebView::UpdateHitTestData(const _Ewk_Hit_Test& hit_test_data, const NodeAttributesMap& node_attributes) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); hit_test_data_ = hit_test_data; hit_test_data_.nodeData.PopulateNodeAtributes(node_attributes); diff --git a/tizen_src/impl/eweb_view.h b/tizen_src/impl/eweb_view.h index b10622c..aef7848 100644 --- a/tizen_src/impl/eweb_view.h +++ b/tizen_src/impl/eweb_view.h @@ -46,7 +46,6 @@ #include "API/ewk_settings_private.h" #include "API/ewk_web_application_icon_data_private.h" #include "eweb_view_callbacks.h" -#include "public/ewk_hit_test.h" #include "public/ewk_policy_decision.h" #include "public/ewk_view.h" #include "selection_controller_efl.h" @@ -72,10 +71,9 @@ #include "browser/selectpicker/popup_picker.h" #endif -#include "tizen_webview/public/tw_hit_test.h" -#include "tizen_webview/public/tw_touch_event.h" #include "tizen_webview/public/tw_input_type.h" #include "tizen_webview/public/tw_find_options.h" +#include "tizen_webview/public/tw_touch_event.h" namespace content { class RenderViewHost; @@ -95,6 +93,7 @@ class TouchEvent; namespace tizen_webview { class WebContext; +class Hit_Test; } class EwkViewPlainTextGetCallback { @@ -300,8 +299,8 @@ class EWebView NavigationPolicyParams params, bool* handled); void UseSettingsFont(); - Ewk_Hit_Test* RequestHitTestDataAt(int x, int y, tizen_webview::Hit_Test_Mode mode); - void UpdateHitTestData(const Ewk_Hit_Test& hit_test_data, const NodeAttributesMap& node_attributes); + tizen_webview::Hit_Test* RequestHitTestDataAt(int x, int y, tizen_webview::Hit_Test_Mode mode); + void UpdateHitTestData(const _Ewk_Hit_Test& hit_test_data, const NodeAttributesMap& node_attributes); int current_find_request_id() const { return current_find_request_id_; } bool PlainTextGet(Ewk_View_Plain_Text_Get_Callback callback, void* user_data); @@ -481,7 +480,7 @@ class EWebView gfx::Size contents_area_; double progress_; mutable std::string title_; - Ewk_Hit_Test hit_test_data_; + _Ewk_Hit_Test hit_test_data_; base::WaitableEvent hit_test_completion_; IDMap mhtml_callback_map_; double page_scale_factor_; diff --git a/tizen_src/impl/renderer/render_view_observer_efl.cc b/tizen_src/impl/renderer/render_view_observer_efl.cc index 5ebaa3a..ea94a66 100644 --- a/tizen_src/impl/renderer/render_view_observer_efl.cc +++ b/tizen_src/impl/renderer/render_view_observer_efl.cc @@ -58,7 +58,7 @@ bool GetGRBAValuesFromString(const std::string& input, int* r, int* g, int* b, i return parsing_status; } -void PopulateEwkHitTestData(const blink::WebHitTestResult& web_hit_test, Ewk_Hit_Test* ewk_hit_test) +void PopulateEwkHitTestData(const blink::WebHitTestResult& web_hit_test, _Ewk_Hit_Test* ewk_hit_test) { DCHECK(ewk_hit_test); ewk_hit_test->imageURI = web_hit_test.absoluteImageURL().string().utf8(); diff --git a/tizen_src/impl/tizen_webview/public/tw_hit_test.cc b/tizen_src/impl/tizen_webview/public/tw_hit_test.cc new file mode 100644 index 0000000..0d4c720 --- /dev/null +++ b/tizen_src/impl/tizen_webview/public/tw_hit_test.cc @@ -0,0 +1,95 @@ +// Copyright (c) 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "tw_hit_test.h" +#include +#include "API/ewk_hit_test_private.h" + +namespace tizen_webview { + +Hit_Test::Hit_Test() + : impl (new _Ewk_Hit_Test) { +} + +Hit_Test::Hit_Test(const Hit_Test& other) + : impl (new _Ewk_Hit_Test(*other.impl)) { +} + +Hit_Test::Hit_Test(const Hit_Test_Impl& impl_) + : impl (new _Ewk_Hit_Test(impl_)) { +} + +Hit_Test::~Hit_Test() { + delete impl; +} + +Hit_Test& Hit_Test::operator=(const Hit_Test& other) { + if (this != &other) { + Hit_Test temp (other); + Swap(temp); + } + return *this; +} + +void Hit_Test::Swap(Hit_Test& other) { + std::swap(impl, other.impl); +} + +tizen_webview::Hit_Test_Result_Context Hit_Test::GetResultContext() const { + return impl->context; +} + +const char* Hit_Test::GetLinkUri() const { + return impl->linkURI.c_str(); +} + +const char* Hit_Test::GetLinkTitle() const { + return impl->linkTitle.c_str(); +} + +const char* Hit_Test::GetLinkLabel() const { + return impl->linkLabel.c_str(); +} + +const char* Hit_Test::GetImageUri() const { + return impl->imageURI.c_str(); +} + +const char* Hit_Test::GetImageFilenameExtension() const { + return impl->imageData.fileNameExtension.c_str(); +} + +int Hit_Test::GetImageWidth() const { + return impl->imageData.imageBitmap.width(); +} + +int Hit_Test::GetImageHeight() const { + return impl->imageData.imageBitmap.height(); +} + +void* Hit_Test::GetImageBuffer() const { + return impl->imageData.imageBitmap.getPixels(); +} + +size_t Hit_Test::GetImageBufferLength() const { + return impl->imageData.imageBitmap.getSize(); +} + +const char* Hit_Test::GetMediaUri() const { + return impl->mediaURI.c_str(); +} + +const char* Hit_Test::GetNodeTagName() const { + return impl->nodeData.tagName.c_str(); +} + +const char* Hit_Test::GetNodeValue() const { + return impl->nodeData.nodeValue.c_str(); +} + +Eina_Hash* Hit_Test::GetNodeAttributeHash() const { + return impl->nodeData.attributeHash; +} + +} // namespace tizen_webview diff --git a/tizen_src/impl/tizen_webview/public/tw_hit_test.h b/tizen_src/impl/tizen_webview/public/tw_hit_test.h index 9a04921..45635d4 100644 --- a/tizen_src/impl/tizen_webview/public/tw_hit_test.h +++ b/tizen_src/impl/tizen_webview/public/tw_hit_test.h @@ -5,6 +5,12 @@ #ifndef TIZEN_WEBVIEW_PUBLIC_TW_HIT_TEST_MODE_H_ #define TIZEN_WEBVIEW_PUBLIC_TW_HIT_TEST_MODE_H_ +#include +#include // Provides size_t + +struct _Ewk_Hit_Test; +class EWebView; + namespace tizen_webview { /** @@ -45,6 +51,46 @@ enum Hit_Test_Result_Context { TW_HIT_TEST_RESULT_CONTEXT_TEXT = 1 << 7 }; + +class Hit_Test { + public: + Hit_Test(); + Hit_Test(const Hit_Test& other); + ~Hit_Test(); + Hit_Test& operator=(const Hit_Test& other); + + Hit_Test_Result_Context GetResultContext() const; + + const char* GetLinkUri() const; + const char* GetLinkTitle() const; + const char* GetLinkLabel() const; + + const char* GetImageUri() const; + const char* GetImageFilenameExtension() const; + int GetImageWidth() const; + int GetImageHeight() const; + void* GetImageBuffer() const; + size_t GetImageBufferLength() const; + + const char* GetMediaUri() const; + + const char* GetNodeTagName() const; + const char* GetNodeValue() const; + Eina_Hash* GetNodeAttributeHash() const; + + private: + typedef _Ewk_Hit_Test Hit_Test_Impl; + Hit_Test_Impl* impl; + + // construct directly from the impl class; + explicit Hit_Test(const Hit_Test_Impl& impl_); + + // utility function + void Swap(Hit_Test& other); + + friend class ::EWebView; +}; + } // namespace tizen_webview #endif // TIZEN_WEBVIEW_PUBLIC_TW_HIT_TEST_MODE_H_ -- 2.7.4