diff --git a/cef.gyp b/cef.gyp index a737f25d..d0274b6c 100644 --- a/cef.gyp +++ b/cef.gyp @@ -399,8 +399,6 @@ 'tests/cefclient/client_app.h', 'tests/cefclient/client_switches.cpp', 'tests/cefclient/client_switches.h', - 'tests/cefclient/resource_util.h', - 'tests/cefclient/res/osr_test.html', 'tests/unittests/browser_info_map_unittest.cc', 'tests/unittests/command_line_unittest.cc', 'tests/unittests/cookie_unittest.cc', @@ -413,7 +411,6 @@ 'tests/unittests/life_span_unittest.cc', 'tests/unittests/message_router_unittest.cc', 'tests/unittests/navigation_unittest.cc', - 'tests/unittests/os_rendering_unittest.cc', 'tests/unittests/process_message_unittest.cc', 'tests/unittests/request_context_unittest.cc', 'tests/unittests/request_handler_unittest.cc', @@ -443,7 +440,6 @@ 'tests/unittests/zip_reader_unittest.cc', ], 'mac_bundle_resources': [ - 'tests/cefclient/res/osr_test.html', 'tests/unittests/mac/unittests.icns', 'tests/unittests/mac/English.lproj/InfoPlist.strings', 'tests/unittests/mac/English.lproj/MainMenu.xib', @@ -473,10 +469,6 @@ 'cef_sandbox', 'libcef', ], - 'sources': [ - 'tests/cefclient/cefclient.rc', - 'tests/cefclient/resource_util_win.cpp', - ], 'msvs_settings': { 'VCManifestTool': { 'AdditionalManifestFiles': [ @@ -568,10 +560,6 @@ ], }, 'sources': [ - 'tests/cefclient/resource_util_mac.mm', - 'tests/cefclient/resource_util_posix.cpp', - 'tests/unittests/os_rendering_unittest_mac.h', - 'tests/unittests/os_rendering_unittest_mac.mm', 'tests/unittests/run_all_unittests_mac.mm', ], }], @@ -581,18 +569,6 @@ '<(DEPTH)/build/linux/system.gyp:gtkprint', 'libcef', ], - 'sources': [ - 'tests/cefclient/resource_util_linux.cpp', - 'tests/cefclient/resource_util_posix.cpp', - ], - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)/files', - 'files': [ - 'tests/cefclient/res/osr_test.html', - ], - }, - ], }], ], }, @@ -867,8 +843,6 @@ ], 'sources': [ '<@(includes_common)', - 'libcef/browser/backing_store_osr.cc', - 'libcef/browser/backing_store_osr.h', 'libcef/browser/browser_context.h', 'libcef/browser/browser_context_impl.cc', 'libcef/browser/browser_context_impl.h', @@ -939,8 +913,6 @@ 'libcef/browser/printing/print_view_manager_base.h', 'libcef/browser/process_util_impl.cc', 'libcef/browser/proxy_stubs.cc', - 'libcef/browser/render_widget_host_view_osr.cc', - 'libcef/browser/render_widget_host_view_osr.h', 'libcef/browser/resource_dispatcher_host_delegate.cc', 'libcef/browser/resource_dispatcher_host_delegate.h', 'libcef/browser/resource_request_job.cc', @@ -971,8 +943,6 @@ 'libcef/browser/url_request_interceptor.h', 'libcef/browser/url_request_user_data.cc', 'libcef/browser/url_request_user_data.h', - 'libcef/browser/web_contents_view_osr.cc', - 'libcef/browser/web_contents_view_osr.h', 'libcef/browser/web_plugin_impl.cc', 'libcef/browser/web_plugin_impl.h', 'libcef/browser/xml_reader_impl.cc', @@ -1118,20 +1088,11 @@ [ 'OS=="mac"', { 'sources': [ '<@(includes_mac)', - 'libcef/browser/backing_store_osr.cc', - 'libcef/browser/backing_store_osr.h', 'libcef/browser/browser_host_impl_mac.mm', 'libcef/browser/browser_main_mac.mm', 'libcef/browser/javascript_dialog_mac.mm', 'libcef/browser/menu_creator_runner_mac.h', 'libcef/browser/menu_creator_runner_mac.mm', - 'libcef/browser/render_widget_host_view_osr_mac.mm', - 'libcef/browser/render_widget_host_view_osr.cc', - 'libcef/browser/render_widget_host_view_osr.h', - 'libcef/browser/text_input_client_osr_mac.mm', - 'libcef/browser/text_input_client_osr_mac.h', - 'libcef/browser/web_contents_view_osr.cc', - 'libcef/browser/web_contents_view_osr.h', # Include sources for printing. '<(DEPTH)/chrome/renderer/printing/print_web_view_helper_mac.mm', ], diff --git a/cef_paths.gypi b/cef_paths.gypi index e322ce38..db582fbb 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -41,7 +41,6 @@ 'include/cef_path_util.h', 'include/cef_process_message.h', 'include/cef_process_util.h', - 'include/cef_render_handler.h', 'include/cef_render_process_handler.h', 'include/cef_request.h', 'include/cef_request_context.h', @@ -93,7 +92,6 @@ 'include/capi/cef_path_util_capi.h', 'include/capi/cef_process_message_capi.h', 'include/capi/cef_process_util_capi.h', - 'include/capi/cef_render_handler_capi.h', 'include/capi/cef_render_process_handler_capi.h', 'include/capi/cef_request_capi.h', 'include/capi/cef_request_context_capi.h', @@ -212,8 +210,6 @@ 'libcef_dll/cpptoc/quota_callback_cpptoc.h', 'libcef_dll/ctocpp/read_handler_ctocpp.cc', 'libcef_dll/ctocpp/read_handler_ctocpp.h', - 'libcef_dll/ctocpp/render_handler_ctocpp.cc', - 'libcef_dll/ctocpp/render_handler_ctocpp.h', 'libcef_dll/ctocpp/render_process_handler_ctocpp.cc', 'libcef_dll/ctocpp/render_process_handler_ctocpp.h', 'libcef_dll/cpptoc/request_cpptoc.cc', @@ -374,8 +370,6 @@ 'libcef_dll/ctocpp/quota_callback_ctocpp.h', 'libcef_dll/cpptoc/read_handler_cpptoc.cc', 'libcef_dll/cpptoc/read_handler_cpptoc.h', - 'libcef_dll/cpptoc/render_handler_cpptoc.cc', - 'libcef_dll/cpptoc/render_handler_cpptoc.h', 'libcef_dll/cpptoc/render_process_handler_cpptoc.cc', 'libcef_dll/cpptoc/render_process_handler_cpptoc.h', 'libcef_dll/ctocpp/request_ctocpp.cc', diff --git a/cef_paths2.gypi b/cef_paths2.gypi index 032b6cc0..571a8845 100644 --- a/cef_paths2.gypi +++ b/cef_paths2.gypi @@ -91,7 +91,6 @@ 'tests/cefclient/res/domaccess.html', 'tests/cefclient/res/localstorage.html', 'tests/cefclient/res/logo.png', - 'tests/cefclient/res/osr_test.html', 'tests/cefclient/res/other_tests.html', 'tests/cefclient/res/performance.html', 'tests/cefclient/res/performance2.html', @@ -117,8 +116,6 @@ 'tests/cefclient/dialog_test.h', 'tests/cefclient/dom_test.cpp', 'tests/cefclient/dom_test.h', - 'tests/cefclient/osrenderer.h', - 'tests/cefclient/osrenderer.cpp', 'tests/cefclient/performance_test.cpp', 'tests/cefclient/performance_test.h', 'tests/cefclient/performance_test_setup.h', @@ -136,8 +133,6 @@ 'cefclient_sources_win': [ 'tests/cefclient/cefclient.exe.manifest', 'tests/cefclient/cefclient.rc', - 'tests/cefclient/cefclient_osr_widget_win.h', - 'tests/cefclient/cefclient_osr_widget_win.cpp', 'tests/cefclient/cefclient_win.cpp', 'tests/cefclient/client_handler_win.cpp', 'tests/cefclient/resource.h', @@ -148,8 +143,6 @@ ], 'cefclient_sources_mac': [ 'tests/cefclient/cefclient_mac.mm', - 'tests/cefclient/cefclient_osr_widget_mac.h', - 'tests/cefclient/cefclient_osr_widget_mac.mm', 'tests/cefclient/client_handler_mac.mm', 'tests/cefclient/resource_util_mac.mm', 'tests/cefclient/resource_util_posix.cpp', @@ -198,8 +191,6 @@ ], 'cefclient_sources_linux': [ 'tests/cefclient/cefclient_gtk.cpp', - 'tests/cefclient/cefclient_osr_widget_gtk.h', - 'tests/cefclient/cefclient_osr_widget_gtk.cpp', 'tests/cefclient/client_handler_gtk.cpp', 'tests/cefclient/resource_util_linux.cpp', 'tests/cefclient/resource_util_posix.cpp', diff --git a/include/capi/cef_browser_capi.h b/include/capi/cef_browser_capi.h index 46eb1a71..35030f92 100644 --- a/include/capi/cef_browser_capi.h +++ b/include/capi/cef_browser_capi.h @@ -351,46 +351,6 @@ typedef struct _cef_browser_host_t { int (CEF_CALLBACK *is_mouse_cursor_change_disabled)( struct _cef_browser_host_t* self); - /// - // Returns true (1) if window rendering is disabled. - /// - int (CEF_CALLBACK *is_window_rendering_disabled)( - struct _cef_browser_host_t* self); - - /// - // Notify the browser that the widget has been resized. The browser will first - // call cef_render_handler_t::GetViewRect to get the new size and then call - // cef_render_handler_t::OnPaint asynchronously with the updated regions. This - // function is only used when window rendering is disabled. - /// - void (CEF_CALLBACK *was_resized)(struct _cef_browser_host_t* self); - - /// - // Notify the browser that it has been hidden or shown. Layouting and - // cef_render_handler_t::OnPaint notification will stop when the browser is - // hidden. This function is only used when window rendering is disabled. - /// - void (CEF_CALLBACK *was_hidden)(struct _cef_browser_host_t* self, int hidden); - - /// - // Send a notification to the browser that the screen info has changed. The - // browser will then call cef_render_handler_t::GetScreenInfo to update the - // screen information with the new values. This simulates moving the webview - // window from one display to another, or changing the properties of the - // current display. This function is only used when window rendering is - // disabled. - /// - void (CEF_CALLBACK *notify_screen_info_changed)( - struct _cef_browser_host_t* self); - - /// - // Invalidate the |dirtyRect| region of the view. The browser will call - // cef_render_handler_t::OnPaint asynchronously with the updated regions. This - // function is only used when window rendering is disabled. - /// - void (CEF_CALLBACK *invalidate)(struct _cef_browser_host_t* self, - const cef_rect_t* dirtyRect, cef_paint_element_type_t type); - /// // Send a key event to the browser. /// @@ -416,8 +376,6 @@ typedef struct _cef_browser_host_t { // Send a mouse wheel event to the browser. The |x| and |y| coordinates are // relative to the upper-left corner of the view. The |deltaX| and |deltaY| // values represent the movement delta in the X and Y directions respectively. - // In order to scroll inside select popups with window rendering disabled - // cef_render_handler_t::GetScreenPoint should be implemented properly. /// void (CEF_CALLBACK *send_mouse_wheel_event)(struct _cef_browser_host_t* self, const struct _cef_mouse_event_t* event, int deltaX, int deltaY); @@ -433,26 +391,6 @@ typedef struct _cef_browser_host_t { /// void (CEF_CALLBACK *send_capture_lost_event)( struct _cef_browser_host_t* self); - - /// - // Get the NSTextInputContext implementation for enabling IME on Mac when - // window rendering is disabled. - /// - cef_text_input_context_t (CEF_CALLBACK *get_nstext_input_context)( - struct _cef_browser_host_t* self); - - /// - // Handles a keyDown event prior to passing it through the NSTextInputClient - // machinery. - /// - void (CEF_CALLBACK *handle_key_event_before_text_input_client)( - struct _cef_browser_host_t* self, cef_event_handle_t keyEvent); - - /// - // Performs any additional actions after NSTextInputClient handles the event. - /// - void (CEF_CALLBACK *handle_key_event_after_text_input_client)( - struct _cef_browser_host_t* self, cef_event_handle_t keyEvent); } cef_browser_host_t; diff --git a/include/capi/cef_client_capi.h b/include/capi/cef_client_capi.h index b5148497..f0a8b211 100644 --- a/include/capi/cef_client_capi.h +++ b/include/capi/cef_client_capi.h @@ -51,7 +51,6 @@ #include "include/capi/cef_life_span_handler_capi.h" #include "include/capi/cef_load_handler_capi.h" #include "include/capi/cef_process_message_capi.h" -#include "include/capi/cef_render_handler_capi.h" #include "include/capi/cef_request_handler_capi.h" #ifdef __cplusplus @@ -139,12 +138,6 @@ typedef struct _cef_client_t { struct _cef_load_handler_t* (CEF_CALLBACK *get_load_handler)( struct _cef_client_t* self); - /// - // Return the handler for off-screen rendering events. - /// - struct _cef_render_handler_t* (CEF_CALLBACK *get_render_handler)( - struct _cef_client_t* self); - /// // Return the handler for browser request events. /// diff --git a/include/capi/cef_render_handler_capi.h b/include/capi/cef_render_handler_capi.h deleted file mode 100644 index 03ee32ab..00000000 --- a/include/capi/cef_render_handler_capi.h +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the name Chromium Embedded -// Framework nor the names of its contributors may be used to endorse -// or promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// --------------------------------------------------------------------------- -// -// This file was generated by the CEF translator tool and should not edited -// by hand. See the translator.README.txt file in the tools directory for -// more information. -// - -#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ -#define CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ -#pragma once - -#include "include/capi/cef_base_capi.h" -#include "include/capi/cef_browser_capi.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -/// -// Implement this structure to handle events when window rendering is disabled. -// The functions of this structure will be called on the UI thread. -/// -typedef struct _cef_render_handler_t { - /// - // Base structure. - /// - cef_base_t base; - - /// - // Called to retrieve the root window rectangle in screen coordinates. Return - // true (1) if the rectangle was provided. - /// - int (CEF_CALLBACK *get_root_screen_rect)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, cef_rect_t* rect); - - /// - // Called to retrieve the view rectangle which is relative to screen - // coordinates. Return true (1) if the rectangle was provided. - /// - int (CEF_CALLBACK *get_view_rect)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, cef_rect_t* rect); - - /// - // Called to retrieve the translation from view coordinates to actual screen - // coordinates. Return true (1) if the screen coordinates were provided. - /// - int (CEF_CALLBACK *get_screen_point)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, int viewX, int viewY, int* screenX, - int* screenY); - - /// - // Called to allow the client to fill in the CefScreenInfo object with - // appropriate values. Return true (1) if the |screen_info| structure has been - // modified. - // - // If the screen info rectangle is left NULL the rectangle from GetViewRect - // will be used. If the rectangle is still NULL or invalid popups may not be - // drawn correctly. - /// - int (CEF_CALLBACK *get_screen_info)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, struct _cef_screen_info_t* screen_info); - - /// - // Called when the browser wants to show or hide the popup widget. The popup - // should be shown if |show| is true (1) and hidden if |show| is false (0). - /// - void (CEF_CALLBACK *on_popup_show)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, int show); - - /// - // Called when the browser wants to move or resize the popup widget. |rect| - // contains the new location and size. - /// - void (CEF_CALLBACK *on_popup_size)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, const cef_rect_t* rect); - - /// - // Called when an element should be painted. |type| indicates whether the - // element is the view or the popup widget. |buffer| contains the pixel data - // for the whole image. |dirtyRects| contains the set of rectangles that need - // to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes in - // size and represents a BGRA image with an upper-left origin. - /// - void (CEF_CALLBACK *on_paint)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, cef_paint_element_type_t type, - size_t dirtyRectsCount, cef_rect_t const* dirtyRects, const void* buffer, - int width, int height); - - /// - // Called when the browser window's cursor has changed. - /// - void (CEF_CALLBACK *on_cursor_change)(struct _cef_render_handler_t* self, - struct _cef_browser_t* browser, cef_cursor_handle_t cursor); - - /// - // Called when the scroll offset has changed. - /// - void (CEF_CALLBACK *on_scroll_offset_changed)( - struct _cef_render_handler_t* self, struct _cef_browser_t* browser); -} cef_render_handler_t; - - -#ifdef __cplusplus -} -#endif - -#endif // CEF_INCLUDE_CAPI_CEF_RENDER_HANDLER_CAPI_H_ diff --git a/include/cef_browser.h b/include/cef_browser.h index 77d6651a..da5b738a 100644 --- a/include/cef_browser.h +++ b/include/cef_browser.h @@ -220,7 +220,6 @@ class CefBrowserHost : public virtual CefBase { public: typedef cef_file_dialog_mode_t FileDialogMode; typedef cef_mouse_button_type_t MouseButtonType; - typedef cef_paint_element_type_t PaintElementType; /// // Create a new browser window using the window parameters specified by @@ -396,48 +395,6 @@ class CefBrowserHost : public virtual CefBase { /*--cef()--*/ virtual bool IsMouseCursorChangeDisabled() =0; - /// - // Returns true if window rendering is disabled. - /// - /*--cef()--*/ - virtual bool IsWindowRenderingDisabled() =0; - - /// - // Notify the browser that the widget has been resized. The browser will first - // call CefRenderHandler::GetViewRect to get the new size and then call - // CefRenderHandler::OnPaint asynchronously with the updated regions. This - // method is only used when window rendering is disabled. - /// - /*--cef()--*/ - virtual void WasResized() =0; - - /// - // Notify the browser that it has been hidden or shown. Layouting and - // CefRenderHandler::OnPaint notification will stop when the browser is - // hidden. This method is only used when window rendering is disabled. - /// - /*--cef()--*/ - virtual void WasHidden(bool hidden) =0; - - /// - // Send a notification to the browser that the screen info has changed. The - // browser will then call CefRenderHandler::GetScreenInfo to update the - // screen information with the new values. This simulates moving the webview - // window from one display to another, or changing the properties of the - // current display. This method is only used when window rendering is - // disabled. - /// - /*--cef()--*/ - virtual void NotifyScreenInfoChanged() =0; - - /// - // Invalidate the |dirtyRect| region of the view. The browser will call - // CefRenderHandler::OnPaint asynchronously with the updated regions. This - // method is only used when window rendering is disabled. - /// - /*--cef()--*/ - virtual void Invalidate(const CefRect& dirtyRect, PaintElementType type) =0; - /// // Send a key event to the browser. /// @@ -465,8 +422,6 @@ class CefBrowserHost : public virtual CefBase { // Send a mouse wheel event to the browser. The |x| and |y| coordinates are // relative to the upper-left corner of the view. The |deltaX| and |deltaY| // values represent the movement delta in the X and Y directions respectively. - // In order to scroll inside select popups with window rendering disabled - // CefRenderHandler::GetScreenPoint should be implemented properly. /// /*--cef()--*/ virtual void SendMouseWheelEvent(const CefMouseEvent& event, @@ -483,26 +438,6 @@ class CefBrowserHost : public virtual CefBase { /// /*--cef()--*/ virtual void SendCaptureLostEvent() =0; - - /// - // Get the NSTextInputContext implementation for enabling IME on Mac when - // window rendering is disabled. - /// - /*--cef(default_retval=NULL)--*/ - virtual CefTextInputContext GetNSTextInputContext() =0; - - /// - // Handles a keyDown event prior to passing it through the NSTextInputClient - // machinery. - /// - /*--cef()--*/ - virtual void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent) =0; - - /// - // Performs any additional actions after NSTextInputClient handles the event. - /// - /*--cef()--*/ - virtual void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent) =0; }; #endif // CEF_INCLUDE_CEF_BROWSER_H_ diff --git a/include/cef_client.h b/include/cef_client.h index d413e0e6..f70a9b27 100644 --- a/include/cef_client.h +++ b/include/cef_client.h @@ -51,7 +51,6 @@ #include "include/cef_life_span_handler.h" #include "include/cef_load_handler.h" #include "include/cef_process_message.h" -#include "include/cef_render_handler.h" #include "include/cef_request_handler.h" /// @@ -153,14 +152,6 @@ class CefClient : public virtual CefBase { return NULL; } - /// - // Return the handler for off-screen rendering events. - /// - /*--cef()--*/ - virtual CefRefPtr GetRenderHandler() { - return NULL; - } - /// // Return the handler for browser request events. /// diff --git a/include/cef_render_handler.h b/include/cef_render_handler.h deleted file mode 100644 index c0997247..00000000 --- a/include/cef_render_handler.h +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the name Chromium Embedded -// Framework nor the names of its contributors may be used to endorse -// or promote products derived from this software without specific prior -// written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// --------------------------------------------------------------------------- -// -// The contents of this file must follow a specific format in order to -// support the CEF translator tool. See the translator.README.txt file in the -// tools directory for more information. -// - -#ifndef CEF_INCLUDE_CEF_RENDER_HANDLER_H_ -#define CEF_INCLUDE_CEF_RENDER_HANDLER_H_ -#pragma once - -#include "include/cef_base.h" -#include "include/cef_browser.h" -#include - -/// -// Implement this interface to handle events when window rendering is disabled. -// The methods of this class will be called on the UI thread. -/// -/*--cef(source=client)--*/ -class CefRenderHandler : public virtual CefBase { - public: - typedef cef_paint_element_type_t PaintElementType; - typedef std::vector RectList; - - /// - // Called to retrieve the root window rectangle in screen coordinates. Return - // true if the rectangle was provided. - /// - /*--cef()--*/ - virtual bool GetRootScreenRect(CefRefPtr browser, - CefRect& rect) { return false; } - - /// - // Called to retrieve the view rectangle which is relative to screen - // coordinates. Return true if the rectangle was provided. - /// - /*--cef()--*/ - virtual bool GetViewRect(CefRefPtr browser, CefRect& rect) =0; - - /// - // Called to retrieve the translation from view coordinates to actual screen - // coordinates. Return true if the screen coordinates were provided. - /// - /*--cef()--*/ - virtual bool GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) { return false; } - - /// - // Called to allow the client to fill in the CefScreenInfo object with - // appropriate values. Return true if the |screen_info| structure has been - // modified. - // - // If the screen info rectangle is left empty the rectangle from GetViewRect - // will be used. If the rectangle is still empty or invalid popups may not be - // drawn correctly. - /// - /*--cef()--*/ - virtual bool GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) { return false; } - - /// - // Called when the browser wants to show or hide the popup widget. The popup - // should be shown if |show| is true and hidden if |show| is false. - /// - /*--cef()--*/ - virtual void OnPopupShow(CefRefPtr browser, - bool show) {} - - /// - // Called when the browser wants to move or resize the popup widget. |rect| - // contains the new location and size. - /// - /*--cef()--*/ - virtual void OnPopupSize(CefRefPtr browser, - const CefRect& rect) {} - - /// - // Called when an element should be painted. |type| indicates whether the - // element is the view or the popup widget. |buffer| contains the pixel data - // for the whole image. |dirtyRects| contains the set of rectangles that need - // to be repainted. On Windows |buffer| will be |width|*|height|*4 bytes - // in size and represents a BGRA image with an upper-left origin. - /// - /*--cef()--*/ - virtual void OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, int height) =0; - - /// - // Called when the browser window's cursor has changed. - /// - /*--cef()--*/ - virtual void OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) {} - - /// - // Called when the scroll offset has changed. - /// - /*--cef()--*/ - virtual void OnScrollOffsetChanged(CefRefPtr browser) {} -}; - -#endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_ diff --git a/include/internal/cef_linux.h b/include/internal/cef_linux.h index fba5a678..6695eeb8 100644 --- a/include/internal/cef_linux.h +++ b/include/internal/cef_linux.h @@ -72,7 +72,6 @@ class CefCriticalSection { #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; @@ -110,8 +109,6 @@ struct CefWindowInfoTraits { static inline void set(const struct_type* src, struct_type* target, bool copy) { target->parent_widget = src->parent_widget; - target->windowless_rendering_enabled = src->windowless_rendering_enabled; - target->transparent_painting_enabled = src->transparent_painting_enabled; target->widget = src->widget; } }; @@ -131,24 +128,6 @@ class CefWindowInfo : public CefStructBase { void SetAsChild(CefWindowHandle parent) { parent_widget = parent; } - - /// - // Create the browser using windowless (off-screen) rendering. No widget - // will be created for the browser and all rendering will occur via the - // CefRenderHandler interface. The |parent| value will be used to identify - // monitor info and to act as the parent widget for dialogs, context menus, - // etc. If |parent| is not provided then the main screen monitor will be used - // and some functionality that requires a parent widget may not function - // correctly. If |transparent| is true a transparent background color will be - // used (RGBA=0x00000000). If |transparent| is false the background will be - // white and opaque. In order to create windowless browsers the - // CefSettings.windowless_rendering_enabled value must be set to true. - /// - void SetAsWindowless(CefWindowHandle parent, bool transparent) { - windowless_rendering_enabled = true; - parent_widget = parent; - transparent_painting_enabled = transparent; - } }; #endif // OS_LINUX diff --git a/include/internal/cef_mac.h b/include/internal/cef_mac.h index 2e4bcbc0..4d61f85c 100644 --- a/include/internal/cef_mac.h +++ b/include/internal/cef_mac.h @@ -72,7 +72,6 @@ class CefCriticalSection { #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; @@ -120,8 +119,6 @@ struct CefWindowInfoTraits { target->height = src->height; target->hidden = src->hidden; target->parent_view = src->parent_view; - target->windowless_rendering_enabled = src->windowless_rendering_enabled; - target->transparent_painting_enabled = src->transparent_painting_enabled; target->view = src->view; } }; @@ -147,24 +144,6 @@ class CefWindowInfo : public CefStructBase { this->height = height; hidden = false; } - - /// - // Create the browser using windowless (off-screen) rendering. No view - // will be created for the browser and all rendering will occur via the - // CefRenderHandler interface. The |parent| value will be used to identify - // monitor info and to act as the parent view for dialogs, context menus, - // etc. If |parent| is not provided then the main screen monitor will be used - // and some functionality that requires a parent view may not function - // correctly. If |transparent| is true a transparent background color will be - // used (RGBA=0x00000000). If |transparent| is false the background will be - // white and opaque. In order to create windowless browsers the - // CefSettings.windowless_rendering_enabled value must be set to true. - /// - void SetAsWindowless(CefWindowHandle parent, bool transparent) { - windowless_rendering_enabled = true; - parent_view = parent; - transparent_painting_enabled = transparent; - } }; #endif // OS_MACOSX diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 1df93017..534c5846 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -223,13 +223,6 @@ typedef struct _cef_settings_t { /// int multi_threaded_message_loop; - /// - // Set to true (1) to enable windowless (off-screen) rendering support. Do not - // enable this value if the application does not use windowless rendering as - // it may reduce rendering performance on some systems. - /// - int windowless_rendering_enabled; - /// // Set to true (1) to disable configuration of browser process features using // standard CEF and Chromium command-line arguments. Configuration can still @@ -1321,14 +1314,6 @@ typedef struct _cef_mouse_event_t { uint32 modifiers; } cef_mouse_event_t; -/// -// Paint element types. -/// -typedef enum { - PET_VIEW = 0, - PET_POPUP, -} cef_paint_element_type_t; - /// // Supported event bit flags. /// diff --git a/include/internal/cef_types_linux.h b/include/internal/cef_types_linux.h index cac15690..4c43d2e4 100644 --- a/include/internal/cef_types_linux.h +++ b/include/internal/cef_types_linux.h @@ -46,7 +46,6 @@ extern "C" { #define cef_cursor_handle_t GdkCursor* #define cef_event_handle_t GdkEvent* #define cef_window_handle_t GtkWidget* -#define cef_text_input_context_t void* /// // Structure representing CefExecuteProcess arguments. @@ -65,26 +64,6 @@ typedef struct _cef_window_info_t { /// cef_window_handle_t parent_widget; - /// - // Set to true (1) to create the browser using windowless (off-screen) - // rendering. No widget will be created for the browser and all rendering will - // occur via the CefRenderHandler interface. The |parent_widget| value will be - // used to identify monitor info and to act as the parent widget for dialogs, - // context menus, etc. If |parent_widget| is not provided then the main screen - // monitor will be used and some functionality that requires a parent widget - // may not function correctly. In order to create windowless browsers the - // CefSettings.windowless_rendering_enabled value must be set to true. - /// - int windowless_rendering_enabled; - - /// - // Set to true (1) to enable transparent painting in combination with - // windowless rendering. When this value is true a transparent background - // color will be used (RGBA=0x00000000). When this value is false the - // background will be white and opaque. - /// - int transparent_painting_enabled; - /// // Pointer for the new browser widget. Only used with windowed rendering. /// diff --git a/include/internal/cef_types_mac.h b/include/internal/cef_types_mac.h index 8d66705b..e29fc43c 100644 --- a/include/internal/cef_types_mac.h +++ b/include/internal/cef_types_mac.h @@ -43,22 +43,18 @@ @class NSCursor; @class NSEvent; @class NSView; -@class NSTextInputContext; #else class NSCursor; class NSEvent; struct NSView; -class NSTextInputContext; #endif #define cef_cursor_handle_t NSCursor* #define cef_event_handle_t NSEvent* #define cef_window_handle_t NSView* -#define cef_text_input_context_t NSTextInputContext* #else #define cef_cursor_handle_t void* #define cef_event_handle_t void* #define cef_window_handle_t void* -#define cef_text_input_context_t void* #endif #ifdef __cplusplus @@ -93,26 +89,6 @@ typedef struct _cef_window_info_t { /// cef_window_handle_t parent_view; - /// - // Set to true (1) to create the browser using windowless (off-screen) - // rendering. No view will be created for the browser and all rendering will - // occur via the CefRenderHandler interface. The |parent_view| value will be - // used to identify monitor info and to act as the parent view for dialogs, - // context menus, etc. If |parent_view| is not provided then the main screen - // monitor will be used and some functionality that requires a parent view - // may not function correctly. In order to create windowless browsers the - // CefSettings.windowless_rendering_enabled value must be set to true. - /// - int windowless_rendering_enabled; - - /// - // Set to true (1) to enable transparent painting in combination with - // windowless rendering. When this value is true a transparent background - // color will be used (RGBA=0x00000000). When this value is false the - // background will be white and opaque. - /// - int transparent_painting_enabled; - /// // NSView pointer for the new browser view. Only used with windowed rendering. /// diff --git a/include/internal/cef_types_win.h b/include/internal/cef_types_win.h index e3d53c5b..7302c45c 100644 --- a/include/internal/cef_types_win.h +++ b/include/internal/cef_types_win.h @@ -46,7 +46,6 @@ extern "C" { #define cef_cursor_handle_t HCURSOR #define cef_event_handle_t MSG* #define cef_window_handle_t HWND -#define cef_text_input_context_t void* /// // Structure representing CefExecuteProcess arguments. @@ -70,26 +69,6 @@ typedef struct _cef_window_info_t { cef_window_handle_t parent_window; HMENU menu; - /// - // Set to true (1) to create the browser using windowless (off-screen) - // rendering. No window will be created for the browser and all rendering will - // occur via the CefRenderHandler interface. The |parent_window| value will be - // used to identify monitor info and to act as the parent window for dialogs, - // context menus, etc. If |parent_window| is not provided then the main screen - // monitor will be used and some functionality that requires a parent window - // may not function correctly. In order to create windowless browsers the - // CefSettings.windowless_rendering_enabled value must be set to true. - /// - int windowless_rendering_enabled; - - /// - // Set to true (1) to enable transparent painting in combination with - // windowless rendering. When this value is true a transparent background - // color will be used (RGBA=0x00000000). When this value is false the - // background will be white and opaque. - /// - int transparent_painting_enabled; - /// // Handle for the new browser window. Only used with windowed rendering. /// diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 53296bd2..74a4d271 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -349,7 +349,6 @@ struct CefSettingsTraits { src->browser_subprocess_path.length, &target->browser_subprocess_path, copy); target->multi_threaded_message_loop = src->multi_threaded_message_loop; - target->windowless_rendering_enabled = src->windowless_rendering_enabled; target->command_line_args_disabled = src->command_line_args_disabled; cef_string_set(src->cache_path.str, src->cache_path.length, diff --git a/include/internal/cef_win.h b/include/internal/cef_win.h index 4346f2b6..857ae7b6 100644 --- a/include/internal/cef_win.h +++ b/include/internal/cef_win.h @@ -71,7 +71,6 @@ class CefCriticalSection { #define CefCursorHandle cef_cursor_handle_t #define CefEventHandle cef_event_handle_t #define CefWindowHandle cef_window_handle_t -#define CefTextInputContext cef_text_input_context_t struct CefMainArgsTraits { typedef cef_main_args_t struct_type; @@ -119,8 +118,6 @@ struct CefWindowInfoTraits { target->height = src->height; target->parent_window = src->parent_window; target->menu = src->menu; - target->transparent_painting_enabled = src->transparent_painting_enabled; - target->windowless_rendering_enabled = src->windowless_rendering_enabled; target->window = src->window; } }; @@ -163,24 +160,6 @@ class CefWindowInfo : public CefStructBase { cef_string_copy(windowName.c_str(), windowName.length(), &window_name); } - - /// - // Create the browser using windowless (off-screen) rendering. No window - // will be created for the browser and all rendering will occur via the - // CefRenderHandler interface. The |parent| value will be used to identify - // monitor info and to act as the parent window for dialogs, context menus, - // etc. If |parent| is not provided then the main screen monitor will be used - // and some functionality that requires a parent window may not function - // correctly. If |transparent| is true a transparent background color will be - // used (RGBA=0x00000000). If |transparent| is false the background will be - // white and opaque. In order to create windowless browsers the - // CefSettings.windowless_rendering_enabled value must be set to true. - /// - void SetAsWindowless(CefWindowHandle parent, bool transparent) { - windowless_rendering_enabled = TRUE; - parent_window = parent; - transparent_painting_enabled = transparent; - } }; #endif // OS_WIN diff --git a/libcef/browser/backing_store_osr.cc b/libcef/browser/backing_store_osr.cc deleted file mode 100644 index 1fcca11f..00000000 --- a/libcef/browser/backing_store_osr.cc +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2012 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 "libcef/browser/backing_store_osr.h" - -#include - -#include "content/browser/renderer_host/dip_util.h" -#include "content/public/browser/render_process_host.h" -#include "content/public/browser/render_widget_host.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/rect_conversions.h" -#include "ui/gfx/size_conversions.h" -#include "ui/gfx/vector2d_conversions.h" -#include "ui/surface/transport_dib.h" - -// Assume that somewhere along the line, someone will do width * height * 4 -// with signed numbers. If the maximum value is 2**31, then 2**31 / 4 = -// 2**29 and floor(sqrt(2**29)) = 23170. - -// Max height and width for layers -static const int kMaxVideoLayerSize = 23170; - -BackingStoreOSR::BackingStoreOSR(content::RenderWidgetHost* widget, - const gfx::Size& size, - float scale_factor) - : content::BackingStore(widget, size), - device_scale_factor_(scale_factor) { - gfx::Size pixel_size = gfx::ToFlooredSize( - gfx::ScaleSize(size, device_scale_factor_)); - SkImageInfo info = SkImageInfo::MakeN32Premul(pixel_size.width(), - pixel_size.height()); - device_.reset(SkBitmapDevice::Create(info)); - canvas_.reset(new SkCanvas(device_.get())); - - canvas_->drawColor(SK_ColorWHITE); -} - -void BackingStoreOSR::ScaleFactorChanged(float scale_factor) { - if (scale_factor == device_scale_factor_) - return; - - gfx::Size old_pixel_size = gfx::ToFlooredSize( - gfx::ScaleSize(size(), device_scale_factor_)); - device_scale_factor_ = scale_factor; - - gfx::Size pixel_size = gfx::ToFlooredSize( - gfx::ScaleSize(size(), device_scale_factor_)); - - SkImageInfo info = SkImageInfo::MakeN32Premul(pixel_size.width(), - pixel_size.height()); - scoped_ptr new_device(SkBitmapDevice::Create(info)); - - scoped_ptr new_canvas(new SkCanvas(new_device.get())); - - // Copy old contents; a low-res flash is better than a black flash. - SkPaint copy_paint; - copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); - SkIRect src_rect = SkIRect::MakeWH(old_pixel_size.width(), - old_pixel_size.height()); - SkRect dst_rect = SkRect::MakeWH(pixel_size.width(), pixel_size.height()); - new_canvas.get()->drawBitmapRect(device_->accessBitmap(false), &src_rect, - dst_rect, ©_paint); - - canvas_.swap(new_canvas); - device_.swap(new_device); -} - -size_t BackingStoreOSR::MemorySize() { - // NOTE: The computation may be different when the canvas is a subrectangle of - // a larger bitmap. - return gfx::ToFlooredSize( - gfx::ScaleSize(size(), device_scale_factor_)).GetArea() * 4; -} - -void BackingStoreOSR::PaintToBackingStore( - content::RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect, - const std::vector& copy_rects, - float scale_factor, - const base::Closure& completion_callback, - bool* scheduled_completion_callback) { - *scheduled_completion_callback = false; - if (bitmap_rect.IsEmpty()) - return; - - gfx::Rect pixel_bitmap_rect = gfx::ToEnclosedRect( - gfx::ScaleRect(bitmap_rect, scale_factor)); - - const int width = pixel_bitmap_rect.width(); - const int height = pixel_bitmap_rect.height(); - - if (width <= 0 || width > kMaxVideoLayerSize || - height <= 0 || height > kMaxVideoLayerSize) { - return; - } - - TransportDIB* dib = process->GetTransportDIB(bitmap); - if (!dib) - return; - - SkBitmap src_bitmap; - src_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); - src_bitmap.setPixels(dib->memory()); - - SkPaint copy_paint; - copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); - - for (size_t i = 0; i < copy_rects.size(); i++) { - const gfx::Rect pixel_copy_rect = gfx::ToEnclosingRect( - gfx::ScaleRect(copy_rects[i], scale_factor)); - SkIRect src_rect = - SkIRect::MakeXYWH(pixel_copy_rect.x() - pixel_bitmap_rect.x(), - pixel_copy_rect.y() - pixel_bitmap_rect.y(), - pixel_copy_rect.width(), - pixel_copy_rect.height()); - - const gfx::Rect pixel_copy_dst_rect = gfx::ToEnclosingRect( - gfx::ScaleRect(copy_rects[i], device_scale_factor_)); - SkRect paint_rect = SkRect::MakeXYWH(pixel_copy_dst_rect.x(), - pixel_copy_dst_rect.y(), - pixel_copy_dst_rect.width(), - pixel_copy_dst_rect.height()); - canvas_->drawBitmapRect(src_bitmap, &src_rect, paint_rect, ©_paint); - } - src_bitmap.setPixels(0); -} - -bool BackingStoreOSR::CopyFromBackingStore(const gfx::Rect& rect, - skia::PlatformBitmap* output) { - const int width = - std::min(size().width(), rect.width()) * device_scale_factor_; - const int height = - std::min(size().height(), rect.height()) * device_scale_factor_; - if (!output->Allocate(width, height, true)) - return false; - - SkPaint copy_paint; - copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); - - SkCanvas canvas(output->GetBitmap()); - canvas.drawColor(SK_ColorWHITE); - canvas.drawBitmap(device_->accessBitmap(false), 0, 0, ©_paint); - return true; -} - -void BackingStoreOSR::ScrollBackingStore(const gfx::Vector2d& delta, - const gfx::Rect& clip_rect, - const gfx::Size& view_size) { - gfx::Rect pixel_rect = gfx::ToEnclosingRect( - gfx::ScaleRect(clip_rect, device_scale_factor_)); - gfx::Vector2d pixel_delta = gfx::ToFlooredVector2d( - gfx::ScaleVector2d(delta, device_scale_factor_)); - - int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_delta.x()); - int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_delta.y()); - int w = pixel_rect.width() + abs(pixel_delta.x()); - int h = pixel_rect.height() + abs(pixel_delta.y()); - SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); - - device_->accessBitmap(true).scrollRect(&rect, - pixel_delta.x(), - pixel_delta.y()); -} - -const void* BackingStoreOSR::getPixels() const { - return const_cast(this)->device_-> - accessBitmap(false).getPixels(); -} diff --git a/libcef/browser/backing_store_osr.h b/libcef/browser/backing_store_osr.h deleted file mode 100644 index 35bf7047..00000000 --- a/libcef/browser/backing_store_osr.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef CEF_LIBCEF_BROWSER_BACKING_STORE_OSR_H_ -#define CEF_LIBCEF_BROWSER_BACKING_STORE_OSR_H_ - -#include - -#include "content/browser/renderer_host/backing_store.h" -#include "ui/gfx/canvas.h" - -class CefRenderWidgetHostViewOSR; - -class BackingStoreOSR : public content::BackingStore { - public: - static BackingStoreOSR* From(content::BackingStore* backing_store) { - return static_cast(backing_store); - } - - // BackingStore implementation. - virtual size_t MemorySize() OVERRIDE; - virtual void PaintToBackingStore( - content::RenderProcessHost* process, - TransportDIB::Id bitmap, - const gfx::Rect& bitmap_rect, - const std::vector& copy_rects, - float scale_factor, - const base::Closure& completion_callback, - bool* scheduled_completion_callback) OVERRIDE; - virtual bool CopyFromBackingStore(const gfx::Rect& rect, - skia::PlatformBitmap* output) OVERRIDE; - virtual void ScrollBackingStore(const gfx::Vector2d& delta, - const gfx::Rect& clip_rect, - const gfx::Size& view_size) OVERRIDE; - - void ScaleFactorChanged(float scale_factor); - - const void* getPixels() const; - - private: - // Can be instantiated only within CefRenderWidgetHostViewOSR. - friend class CefRenderWidgetHostViewOSR; - - explicit BackingStoreOSR(content::RenderWidgetHost* widget, - const gfx::Size& size, float scale_factor); - virtual ~BackingStoreOSR() {} - - scoped_ptr device_; - scoped_ptr canvas_; - - float device_scale_factor_; - - DISALLOW_COPY_AND_ASSIGN(BackingStoreOSR); -}; - -#endif // CEF_LIBCEF_BROWSER_BACKING_STORE_OSR_H_ - diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index 11e4674f..528b3710 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -19,11 +19,9 @@ #include "libcef/browser/media_capture_devices_dispatcher.h" #include "libcef/browser/navigate_params.h" #include "libcef/browser/printing/print_view_manager.h" -#include "libcef/browser/render_widget_host_view_osr.h" #include "libcef/browser/request_context_impl.h" #include "libcef/browser/scheme_handler.h" #include "libcef/browser/thread_util.h" -#include "libcef/browser/web_contents_view_osr.h" #include "libcef/common/cef_messages.h" #include "libcef/common/cef_switches.h" #include "libcef/common/drag_data_impl.h" @@ -286,28 +284,9 @@ bool CefBrowserHost::CreateBrowser( return false; } - CefBrowserSettings new_settings = settings; - - // Verify that render handler is in place for a windowless browser. - if (CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)) { - if (!CefContext::Get()->settings().windowless_rendering_enabled) { - NOTREACHED() << "Windowless rendering must be enabled"; - return false; - } - if (!client->GetRenderHandler().get()) { - NOTREACHED() << "CefRenderHandler implementation is required"; - return false; - } - if (new_settings.accelerated_compositing != STATE_DISABLED) { - // Accelerated compositing is not supported when window rendering is - // disabled. - new_settings.accelerated_compositing = STATE_DISABLED; - } - } - // Create the browser on the UI thread. CreateBrowserHelper* helper = - new CreateBrowserHelper(windowInfo, client, url, new_settings, + new CreateBrowserHelper(windowInfo, client, url, settings, request_context); CEF_POST_TASK(CEF_UIT, base::Bind(CreateBrowserWithHelper, helper)); @@ -358,35 +337,10 @@ CefRefPtr CefBrowserHostImpl::Create( CefWindowHandle opener, bool is_popup, CefRefPtr request_context) { - CefBrowserSettings new_settings = settings; - - // Verify that render handler is in place for a windowless browser. - if (CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)) { - if (!CefContext::Get()->settings().windowless_rendering_enabled) { - NOTREACHED() << "Windowless rendering must be enabled"; - return NULL; - } - if (!client->GetRenderHandler().get()) { - NOTREACHED() << "CefRenderHandler implementation is required"; - return NULL; - } - if (new_settings.accelerated_compositing != STATE_DISABLED) { - // Accelerated compositing is not supported when window rendering is - // disabled. - new_settings.accelerated_compositing = STATE_DISABLED; - } - } - - CefContentBrowserClient::Get()->set_use_osr_next_contents_view( - CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)); - scoped_refptr info = CefContentBrowserClient::Get()->CreateBrowserInfo(is_popup); - - info->set_window_rendering_disabled( - CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)); CefRefPtr browser = - CefBrowserHostImpl::CreateInternal(windowInfo, new_settings, client, NULL, + CefBrowserHostImpl::CreateInternal(windowInfo, settings, client, NULL, info, opener, request_context); if (browser && !url.empty()) { browser->LoadURL(CefFrameHostImpl::kMainFrameId, url, content::Referrer(), @@ -429,8 +383,7 @@ CefRefPtr CefBrowserHostImpl::CreateInternal( CefRefPtr browser = new CefBrowserHostImpl(window_info, settings, client, web_contents, browser_info, opener); - if (!browser->IsWindowRenderingDisabled() && - !browser->PlatformCreateWindow()) { + if (!browser->PlatformCreateWindow()) { return NULL; } @@ -654,8 +607,7 @@ void CefBrowserHostImpl::CloseBrowser(bool force_close) { if (CEF_CURRENTLY_ON_UIT()) { // Exit early if a close attempt is already pending and this method is // called again from somewhere other than WindowDestroyed(). - if (destruction_state_ >= DESTRUCTION_STATE_PENDING && - (IsWindowRenderingDisabled() || !window_destroyed_)) { + if (destruction_state_ >= DESTRUCTION_STATE_PENDING && !window_destroyed_) { if (force_close && destruction_state_ == DESTRUCTION_STATE_PENDING) { // Upgrade the destruction state. destruction_state_ = DESTRUCTION_STATE_ACCEPTED; @@ -887,109 +839,6 @@ bool CefBrowserHostImpl::IsMouseCursorChangeDisabled() { return mouse_cursor_change_disabled_; } -bool CefBrowserHostImpl::IsWindowRenderingDisabled() { - return IsWindowRenderingDisabled(window_info_); -} - -void CefBrowserHostImpl::WasResized() { - if (!IsWindowRenderingDisabled()) { - NOTREACHED() << "Window rendering is not disabled"; - return; - } - - if (!CEF_CURRENTLY_ON_UIT()) { - CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::WasResized, this)); - return; - } - - if (!web_contents()) - return; - - content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); - if (widget) - widget->WasResized(); -} - -void CefBrowserHostImpl::WasHidden(bool hidden) { - if (!IsWindowRenderingDisabled()) { - NOTREACHED() << "Window rendering is not disabled"; - return; - } - - if (!CEF_CURRENTLY_ON_UIT()) { - CEF_POST_TASK(CEF_UIT, - base::Bind(&CefBrowserHost::WasHidden, this, hidden)); - return; - } - - if (!web_contents()) - return; - - content::RenderWidgetHostImpl* widget = - content::RenderWidgetHostImpl::From(web_contents()->GetRenderViewHost()); - if (!widget) - return; - - if (hidden) - widget->WasHidden(); - else - widget->WasShown(); -} - -void CefBrowserHostImpl::NotifyScreenInfoChanged() { - if (!CEF_CURRENTLY_ON_UIT()) { - CEF_POST_TASK(CEF_UIT, - base::Bind(&CefBrowserHostImpl::NotifyScreenInfoChanged, this)); - return; - } - - if (!IsWindowRenderingDisabled()) { - NOTREACHED() << "Window rendering is not disabled"; - return; - } - - if (!web_contents()) - return; - - content::RenderWidgetHostView* view = - web_contents()->GetRenderViewHost()->GetView(); - if (!view) - return; - - CefRenderWidgetHostViewOSR* orview = - static_cast(view); - - orview->OnScreenInfoChanged(); -} - -void CefBrowserHostImpl::Invalidate(const CefRect& dirtyRect, - PaintElementType type) { - if (!IsWindowRenderingDisabled()) { - NOTREACHED() << "Window rendering is not disabled"; - return; - } - - if (!CEF_CURRENTLY_ON_UIT()) { - CEF_POST_TASK(CEF_UIT, - base::Bind(&CefBrowserHostImpl::Invalidate, this, dirtyRect, type)); - return; - } - - if (!web_contents()) - return; - - content::RenderWidgetHostView* view = - web_contents()->GetRenderViewHost()->GetView(); - CefRenderWidgetHostViewOSR* orview = - static_cast(view); - - if (orview) { - gfx::Rect rect(dirtyRect.x, dirtyRect.y, - dirtyRect.width, dirtyRect.height); - orview->Invalidate(rect, type); - } -} - void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) { if (!CEF_CURRENTLY_ON_UIT()) { CEF_POST_TASK(CEF_UIT, @@ -1000,20 +849,9 @@ void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) { content::NativeWebKeyboardEvent web_event; PlatformTranslateKeyEvent(web_event, event); - if (!IsWindowRenderingDisabled()) { - content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); - if (widget) - widget->ForwardKeyboardEvent(web_event); - } else { - if (!web_contents()) - return; - content::RenderWidgetHostView* view = - web_contents()->GetRenderViewHost()->GetView(); - CefRenderWidgetHostViewOSR* orview = - static_cast(view); - if (orview) - orview->SendKeyEvent(web_event); - } + content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); + if (widget) + widget->ForwardKeyboardEvent(web_event); } void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event, @@ -1058,21 +896,9 @@ void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event, blink::WebMouseWheelEvent web_event; PlatformTranslateWheelEvent(web_event, event, deltaX, deltaY); - if (!IsWindowRenderingDisabled()) { - content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); - if (widget) - widget->ForwardWheelEvent(web_event); - } else { - if (!web_contents()) - return; - content::RenderWidgetHostView* view = - web_contents()->GetRenderViewHost()->GetView(); - CefRenderWidgetHostViewOSR* orview = - static_cast(view); - - if (orview) - orview->SendMouseWheelEvent(web_event); - } + content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); + if (widget) + widget->ForwardWheelEvent(web_event); } int CefBrowserHostImpl::TranslateModifiers(uint32 cef_modifiers) { @@ -1106,21 +932,9 @@ int CefBrowserHostImpl::TranslateModifiers(uint32 cef_modifiers) { } void CefBrowserHostImpl::SendMouseEvent(const blink::WebMouseEvent& event) { - if (!IsWindowRenderingDisabled()) { - content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); - if (widget) - widget->ForwardMouseEvent(event); - } else { - if (!web_contents()) - return; - content::RenderWidgetHostView* view = - web_contents()->GetRenderViewHost()->GetView(); - CefRenderWidgetHostViewOSR* orview = - static_cast(view); - - if (orview) - orview->SendMouseEvent(event); - } + content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost(); + if (widget) + widget->ForwardMouseEvent(event); } void CefBrowserHostImpl::SendFocusEvent(bool setFocus) { @@ -1691,12 +1505,10 @@ void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) { web_contents_->GetView()->Focus(); #if defined(OS_WIN) - if (!IsWindowRenderingDisabled()) { - // When windowed rendering is used in combination with Aura on Windows we - // need to explicitly set focus to the native window handle. Otherwise, - // the window doesn't get keyboard focus. - PlatformSetViewFocus(); - } + // When windowed rendering is used in combination with Aura on Windows we + // need to explicitly set focus to the native window handle. Otherwise, + // the window doesn't get keyboard focus. + PlatformSetViewFocus(); #endif // defined(OS_WIN) } else { CEF_POST_TASK(CEF_UIT, @@ -1712,23 +1524,6 @@ void CefBrowserHostImpl::RunFileChooser( callback)); } -#if !defined(OS_MACOSX) -CefTextInputContext CefBrowserHostImpl::GetNSTextInputContext() { - NOTREACHED(); - return NULL; -} - -void CefBrowserHostImpl::HandleKeyEventBeforeTextInputClient( - CefEventHandle keyEvent) { - NOTREACHED(); -} - -void CefBrowserHostImpl::HandleKeyEventAfterTextInputClient( - CefEventHandle keyEvent) { - NOTREACHED(); -} -#endif // !defined(OS_MACOSX) - // content::WebContentsDelegate methods. // ----------------------------------------------------------------------------- @@ -1775,7 +1570,7 @@ void CefBrowserHostImpl::CloseContents(content::WebContents* source) { // If this method is called in response to something other than // WindowDestroyed() ask the user if the browser should close. - if (client_.get() && (IsWindowRenderingDisabled() || !window_destroyed_)) { + if (client_.get() && !window_destroyed_) { CefRefPtr handler = client_->GetLifeSpanHandler(); if (handler.get()) { @@ -1787,7 +1582,7 @@ void CefBrowserHostImpl::CloseContents(content::WebContents* source) { if (destruction_state_ != DESTRUCTION_STATE_ACCEPTED) destruction_state_ = DESTRUCTION_STATE_ACCEPTED; - if (!IsWindowRenderingDisabled() && !window_destroyed_) { + if (!window_destroyed_) { // A window exists so try to close it using the platform method. Will // result in a call to WindowDestroyed() if/when the window is destroyed // via the platform window destruction mechanism. @@ -1799,10 +1594,8 @@ void CefBrowserHostImpl::CloseContents(content::WebContents* source) { // No window exists. Destroy the browser immediately. DestroyBrowser(); - if (!IsWindowRenderingDisabled()) { - // Release the reference added in PlatformCreateWindow(). - Release(); - } + // Release the reference added in PlatformCreateWindow(). + Release(); } } else if (destruction_state_ != DESTRUCTION_STATE_NONE) { destruction_state_ = DESTRUCTION_STATE_NONE; @@ -1930,26 +1723,6 @@ bool CefBrowserHostImpl::CanDragEnter( return true; } -bool CefBrowserHostImpl::ShouldCreateWebContents( - content::WebContents* web_contents, - int route_id, - WindowContainerType window_container_type, - const base::string16& frame_name, - const GURL& target_url, - const std::string& partition_id, - content::SessionStorageNamespace* session_storage_namespace) { - // In cases where the navigation will occur in a new render process the - // |route_id| value will be MSG_ROUTING_NONE here (because the existing - // renderer will not be able to communicate with the new renderer) and - // OpenURLFromTab will be called after WebContentsCreated. - base::AutoLock lock_scope(pending_popup_info_lock_); - DCHECK(pending_popup_info_.get()); - CefContentBrowserClient::Get()->set_use_osr_next_contents_view( - IsWindowRenderingDisabled(pending_popup_info_->window_info)); - - return true; -} - void CefBrowserHostImpl::WebContentsCreated( content::WebContents* source_contents, int opener_render_frame_id, @@ -2424,14 +2197,6 @@ CefBrowserHostImpl::CefBrowserHostImpl( // Make sure RenderViewCreated is called at least one time. RenderViewCreated(web_contents->GetRenderViewHost()); - - if (IsWindowRenderingDisabled()) { - CefRenderWidgetHostViewOSR* view = - static_cast( - web_contents->GetRenderViewHost()->GetView()); - if (view) - view->set_browser_impl(this); - } } CefRefPtr CefBrowserHostImpl::GetOrCreateFrame( diff --git a/libcef/browser/browser_host_impl.h b/libcef/browser/browser_host_impl.h index b653b606..de9f39aa 100644 --- a/libcef/browser/browser_host_impl.h +++ b/libcef/browser/browser_host_impl.h @@ -120,9 +120,6 @@ class CefBrowserHostImpl : public CefBrowserHost, static CefRefPtr GetBrowserForFrame( int render_process_id, int render_routing_id); - // Returns true if window rendering is disabled in CefWindowInfo. - static bool IsWindowRenderingDisabled(const CefWindowInfo& info); - // CefBrowserHost methods. virtual CefRefPtr GetBrowser() OVERRIDE; virtual void CloseBrowser(bool force_close) OVERRIDE; @@ -150,12 +147,6 @@ class CefBrowserHostImpl : public CefBrowserHost, virtual void CloseDevTools() OVERRIDE; virtual void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE; virtual bool IsMouseCursorChangeDisabled() OVERRIDE; - virtual bool IsWindowRenderingDisabled() OVERRIDE; - virtual void WasResized() OVERRIDE; - virtual void WasHidden(bool hidden) OVERRIDE; - virtual void NotifyScreenInfoChanged() OVERRIDE; - virtual void Invalidate(const CefRect& dirtyRect, - PaintElementType type) OVERRIDE; virtual void SendKeyEvent(const CefKeyEvent& event) OVERRIDE; virtual void SendMouseClickEvent(const CefMouseEvent& event, MouseButtonType type, @@ -166,11 +157,6 @@ class CefBrowserHostImpl : public CefBrowserHost, int deltaX, int deltaY) OVERRIDE; virtual void SendFocusEvent(bool setFocus) OVERRIDE; virtual void SendCaptureLostEvent() OVERRIDE; - virtual CefTextInputContext GetNSTextInputContext() OVERRIDE; - virtual void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent) - OVERRIDE; - virtual void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent) - OVERRIDE; // CefBrowser methods. virtual CefRefPtr GetHost() OVERRIDE; @@ -258,8 +244,6 @@ class CefBrowserHostImpl : public CefBrowserHost, // Returns the URL that is currently loading (or loaded) in the main frame. GURL GetLoadingURL(); - bool IsTransparent(); - #if defined(OS_WIN) static void RegisterWindowClass(); #endif @@ -344,14 +328,6 @@ class CefBrowserHostImpl : public CefBrowserHost, content::WebContents* source, const content::DropData& data, blink::WebDragOperationsMask operations_allowed) OVERRIDE; - virtual bool ShouldCreateWebContents( - content::WebContents* web_contents, - int route_id, - WindowContainerType window_container_type, - const base::string16& frame_name, - const GURL& target_url, - const std::string& partition_id, - content::SessionStorageNamespace* session_storage_namespace) OVERRIDE; virtual void WebContentsCreated(content::WebContents* source_contents, int opener_render_frame_id, const base::string16& frame_name, @@ -494,7 +470,7 @@ class CefBrowserHostImpl : public CefBrowserHost, const CefMouseEvent& mouse_event, int deltaX, int deltaY); void PlatformTranslateMouseEvent(blink::WebMouseEvent& web_event, - const CefMouseEvent& mouse_event); + const CefMouseEvent& mouse_event); int TranslateModifiers(uint32 cefKeyStates); void SendMouseEvent(const blink::WebMouseEvent& web_event); diff --git a/libcef/browser/browser_host_impl_gtk.cc b/libcef/browser/browser_host_impl_gtk.cc index 257f5363..1350ffbb 100644 --- a/libcef/browser/browser_host_impl_gtk.cc +++ b/libcef/browser/browser_host_impl_gtk.cc @@ -320,9 +320,7 @@ void CefBrowserHostImpl::PlatformSizeTo(int width, int height) { } CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() { - return IsWindowRenderingDisabled() ? - window_info_.parent_widget : - window_info_.widget; + return window_info_.widget; } bool CefBrowserHostImpl::PlatformViewText(const std::string& text) { @@ -383,15 +381,6 @@ void CefBrowserHostImpl::PlatformRunFileChooser( void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) { } -// static -bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) { - return info.windowless_rendering_enabled ? true : false; -} - -bool CefBrowserHostImpl::IsTransparent() { - return window_info_.transparent_painting_enabled ? true : false; -} - void CefBrowserHostImpl::PlatformTranslateKeyEvent( content::NativeWebKeyboardEvent& result, const CefKeyEvent& key_event) { @@ -553,18 +542,12 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent( result.globalY = result.y; // global position - if (IsWindowRenderingDisabled()) { - GetClient()->GetRenderHandler()->GetScreenPoint(GetBrowser(), - result.x, result.y, - result.globalX, result.globalY); - } else { - GtkWidget* window = gtk_widget_get_toplevel(GetWindowHandle()); - GdkWindow* gdk_window = gtk_widget_get_window(window); - gint xorigin, yorigin; - gdk_window_get_root_origin(gdk_window, &xorigin, &yorigin); - result.globalX = xorigin + result.x; - result.globalY = yorigin + result.y; - } + GtkWidget* window = gtk_widget_get_toplevel(GetWindowHandle()); + GdkWindow* gdk_window = gtk_widget_get_window(window); + gint xorigin, yorigin; + gdk_window_get_root_origin(gdk_window, &xorigin, &yorigin); + result.globalX = xorigin + result.x; + result.globalY = yorigin + result.y; // modifiers result.modifiers |= TranslateModifiers(mouse_event.modifiers); diff --git a/libcef/browser/browser_host_impl_mac.mm b/libcef/browser/browser_host_impl_mac.mm index 4b127145..1835fbe6 100644 --- a/libcef/browser/browser_host_impl_mac.mm +++ b/libcef/browser/browser_host_impl_mac.mm @@ -8,8 +8,6 @@ #import #import -#include "libcef/browser/render_widget_host_view_osr.h" -#include "libcef/browser/text_input_client_osr_mac.h" #include "libcef/browser/thread_util.h" #include "base/file_util.h" @@ -258,59 +256,6 @@ bool RunSaveFileDialog(const content::FileChooserParams& params, } // namespace -CefTextInputContext CefBrowserHostImpl::GetNSTextInputContext() { - if (!IsWindowRenderingDisabled()) { - NOTREACHED() << "Window rendering is not disabled"; - return NULL; - } - - if (!CEF_CURRENTLY_ON_UIT()) { - NOTREACHED() << "Called on invalid thread"; - return NULL; - } - - CefRenderWidgetHostViewOSR* rwhv = static_cast( - GetWebContents()->GetRenderWidgetHostView()); - - return rwhv->GetNSTextInputContext(); -} - -void CefBrowserHostImpl::HandleKeyEventBeforeTextInputClient( - CefEventHandle keyEvent) { - if (!IsWindowRenderingDisabled()) { - NOTREACHED() << "Window rendering is not disabled"; - return; - } - - if (!CEF_CURRENTLY_ON_UIT()) { - NOTREACHED() << "Called on invalid thread"; - return; - } - - CefRenderWidgetHostViewOSR* rwhv = static_cast( - GetWebContents()->GetRenderWidgetHostView()); - - rwhv->HandleKeyEventBeforeTextInputClient(keyEvent); -} - -void CefBrowserHostImpl::HandleKeyEventAfterTextInputClient( - CefEventHandle keyEvent) { - if (!IsWindowRenderingDisabled()) { - NOTREACHED() << "Window rendering is not disabled"; - return; - } - - if (!CEF_CURRENTLY_ON_UIT()) { - NOTREACHED() << "Called on invalid thread"; - return; - } - - CefRenderWidgetHostViewOSR* rwhv = static_cast( - GetWebContents()->GetRenderWidgetHostView()); - - rwhv->HandleKeyEventAfterTextInputClient(keyEvent); -} - bool CefBrowserHostImpl::PlatformViewText(const std::string& text) { NOTIMPLEMENTED(); return false; @@ -402,9 +347,7 @@ void CefBrowserHostImpl::PlatformSizeTo(int width, int height) { } CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() { - return IsWindowRenderingDisabled() ? - window_info_.parent_view : - window_info_.view; + return window_info_.view; } void CefBrowserHostImpl::PlatformHandleKeyboardEvent( @@ -436,15 +379,6 @@ void CefBrowserHostImpl::PlatformRunFileChooser( void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) { } -// static -bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) { - return info.windowless_rendering_enabled ? true : false; -} - -bool CefBrowserHostImpl::IsTransparent() { - return window_info_.transparent_painting_enabled ? true : false; -} - static NSTimeInterval currentEventTimestamp() { NSEvent* currentEvent = [NSApp currentEvent]; if (currentEvent) @@ -627,20 +561,14 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent( result.globalX = result.x; result.globalY = result.y; - if (IsWindowRenderingDisabled()) { - GetClient()->GetRenderHandler()->GetScreenPoint(GetBrowser(), - result.x, result.y, - result.globalX, result.globalY); - } else { - NSView* view = window_info_.parent_view; - if (view) { - NSRect bounds = [view bounds]; - NSPoint view_pt = {result.x, bounds.size.height - result.y}; - NSPoint window_pt = [view convertPoint:view_pt toView:nil]; - NSPoint screen_pt = [[view window] convertBaseToScreen:window_pt]; - result.globalX = screen_pt.x; - result.globalY = screen_pt.y; - } + NSView* view = window_info_.parent_view; + if (view) { + NSRect bounds = [view bounds]; + NSPoint view_pt = {result.x, bounds.size.height - result.y}; + NSPoint window_pt = [view convertPoint:view_pt toView:nil]; + NSPoint screen_pt = [[view window] convertBaseToScreen:window_pt]; + result.globalX = screen_pt.x; + result.globalY = screen_pt.y; } // modifiers diff --git a/libcef/browser/browser_host_impl_win.cc b/libcef/browser/browser_host_impl_win.cc index 86b77f4b..cd0440df 100644 --- a/libcef/browser/browser_host_impl_win.cc +++ b/libcef/browser/browser_host_impl_win.cc @@ -47,23 +47,6 @@ namespace { -bool IsAeroGlassEnabled() { - if (base::win::GetVersion() < base::win::VERSION_VISTA) - return false; - - BOOL enabled = FALSE; - return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; -} - -void SetAeroGlass(HWND hWnd) { - if (!IsAeroGlassEnabled()) - return; - - // Make the whole window transparent. - MARGINS mgMarInset = { -1, -1, -1, -1 }; - DwmExtendFrameIntoClientArea(hWnd, &mgMarInset); -} - HWND GetHWND(views::Widget* widget) { gfx::NativeWindow window = widget->GetNativeWindow(); DCHECK(window); @@ -714,13 +697,6 @@ LRESULT CALLBACK CefBrowserHostImpl::WndProc(HWND hwnd, UINT message, case WM_ERASEBKGND: return 0; - - case WM_DWMCOMPOSITIONCHANGED: - // Message sent to top-level windows when composition has been enabled or - // disabled. - if (browser && browser->IsTransparent()) - SetAeroGlass(hwnd); - break; } return DefWindowProc(hwnd, message, wParam, lParam); @@ -761,12 +737,6 @@ bool CefBrowserHostImpl::PlatformCreateWindow() { if (!window_info_.window) return false; - if (window_info_.transparent_painting_enabled && - !(window_info_.style & WS_CHILD)) { - // Transparent top-level windows will be given "sheet of glass" effect. - SetAeroGlass(window_info_.window); - } - // Set window user data to this object for future reference from the window // procedure. gfx::SetWindowUserData(window_info_.window, this); @@ -823,9 +793,7 @@ void CefBrowserHostImpl::PlatformSizeTo(int width, int height) { } CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() { - return IsWindowRenderingDisabled() ? - window_info_.parent_window : - window_info_.window; + return window_info_.window; } bool CefBrowserHostImpl::PlatformViewText(const std::string& text) { @@ -905,15 +873,6 @@ void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) { } } -// static -bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) { - return info.windowless_rendering_enabled ? true : false; -} - -bool CefBrowserHostImpl::IsTransparent() { - return window_info_.transparent_painting_enabled ? true : false; -} - void CefBrowserHostImpl::PlatformTranslateKeyEvent( content::NativeWebKeyboardEvent& result, const CefKeyEvent& key_event) { result.timeStampSeconds = GetMessageTime() / 1000.0; @@ -1058,16 +1017,10 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent( result.globalY = result.y; // global position - if (IsWindowRenderingDisabled()) { - GetClient()->GetRenderHandler()->GetScreenPoint(GetBrowser(), - result.x, result.y, - result.globalX, result.globalY); - } else { - POINT globalPoint = { result.x, result.y }; - ClientToScreen(GetWindowHandle(), &globalPoint); - result.globalX = globalPoint.x; - result.globalY = globalPoint.y; - } + POINT globalPoint = { result.x, result.y }; + ClientToScreen(GetWindowHandle(), &globalPoint); + result.globalX = globalPoint.x; + result.globalY = globalPoint.y; // modifiers result.modifiers |= TranslateModifiers(mouse_event.modifiers); diff --git a/libcef/browser/browser_info.cc b/libcef/browser/browser_info.cc index cdb36d9d..24f6d552 100644 --- a/libcef/browser/browser_info.cc +++ b/libcef/browser/browser_info.cc @@ -7,18 +7,13 @@ CefBrowserInfo::CefBrowserInfo(int browser_id, bool is_popup) : browser_id_(browser_id), - is_popup_(is_popup), - is_window_rendering_disabled_(false) { + is_popup_(is_popup) { DCHECK_GT(browser_id, 0); } CefBrowserInfo::~CefBrowserInfo() { } -void CefBrowserInfo::set_window_rendering_disabled(bool disabled) { - is_window_rendering_disabled_ = disabled; -} - void CefBrowserInfo::add_render_view_id( int render_process_id, int render_routing_id) { add_render_id(&render_view_id_set_, render_process_id, render_routing_id); diff --git a/libcef/browser/browser_info.h b/libcef/browser/browser_info.h index 772a7187..22755c19 100644 --- a/libcef/browser/browser_info.h +++ b/libcef/browser/browser_info.h @@ -24,12 +24,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe { int browser_id() const { return browser_id_; }; bool is_popup() const { return is_popup_; } - bool is_window_rendering_disabled() const { - return is_window_rendering_disabled_; - } - void set_window_rendering_disabled(bool disabled); - // Adds an ID pair if it doesn't already exist. void add_render_view_id(int render_process_id, int render_routing_id); void add_render_frame_id(int render_process_id, int render_routing_id); @@ -60,7 +55,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe { int browser_id_; bool is_popup_; - bool is_window_rendering_disabled_; base::Lock lock_; diff --git a/libcef/browser/browser_message_filter.cc b/libcef/browser/browser_message_filter.cc index b9785855..d3127212 100644 --- a/libcef/browser/browser_message_filter.cc +++ b/libcef/browser/browser_message_filter.cc @@ -91,7 +91,6 @@ void CefBrowserMessageFilter::OnGetNewBrowserInfo( render_frame_routing_id); params->browser_id = info->browser_id(); params->is_popup = info->is_popup(); - params->is_window_rendering_disabled = info->is_window_rendering_disabled(); } void CefBrowserMessageFilter::OnCreateWindow( diff --git a/libcef/browser/content_browser_client.cc b/libcef/browser/content_browser_client.cc index 83e915e0..9a4cebda 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -20,7 +20,6 @@ #include "libcef/browser/resource_dispatcher_host_delegate.h" #include "libcef/browser/speech_recognition_manager_delegate.h" #include "libcef/browser/thread_util.h" -#include "libcef/browser/web_contents_view_osr.h" #include "libcef/browser/web_plugin_impl.h" #include "libcef/common/cef_switches.h" #include "libcef/common/command_line_impl.h" @@ -349,8 +348,7 @@ int GetCrashSignalFD(const CommandLine& command_line) { CefContentBrowserClient::CefContentBrowserClient() : browser_main_parts_(NULL), - next_browser_id_(0), - use_osr_next_contents_view_(false) { + next_browser_id_(0) { plugin_service_filter_.reset(new CefPluginServiceFilter); content::PluginServiceImpl::GetInstance()->SetFilter( plugin_service_filter_.get()); @@ -541,23 +539,6 @@ content::BrowserMainParts* CefContentBrowserClient::CreateBrowserMainParts( return browser_main_parts_; } -content::WebContentsViewPort* -CefContentBrowserClient::OverrideCreateWebContentsView( - content::WebContents* web_contents, - content::RenderViewHostDelegateView** render_view_host_delegate_view) { - content::WebContentsViewPort* view = NULL; - *render_view_host_delegate_view = NULL; - - if (use_osr_next_contents_view()) { - CefWebContentsViewOSR* view_or = new CefWebContentsViewOSR(web_contents, - GetWebContentsViewDelegate(web_contents)); - *render_view_host_delegate_view = view_or; - view = view_or; - } - - return view; -} - void CefContentBrowserClient::RenderProcessWillLaunch( content::RenderProcessHost* host) { host->GetChannel()->AddFilter(new CefBrowserMessageFilter(host)); @@ -817,20 +798,6 @@ bool CefContentBrowserClient::CanCreateWindow( pending_info->client, pending_info->settings, no_javascript_access); - if (allow) { - if (CefBrowserHostImpl::IsWindowRenderingDisabled( - pending_info->window_info)) { - if (!pending_info->client->GetRenderHandler().get()) { - NOTREACHED() << "CefRenderHandler implementation is required"; - allow = false; - } - if (pending_info->settings.accelerated_compositing != STATE_DISABLED) { - // Accelerated compositing is not supported when window rendering is - // disabled. - pending_info->settings.accelerated_compositing = STATE_DISABLED; - } - } - } } } diff --git a/libcef/browser/content_browser_client.h b/libcef/browser/content_browser_client.h index 0d7901b5..e7eb9d71 100644 --- a/libcef/browser/content_browser_client.h +++ b/libcef/browser/content_browser_client.h @@ -81,9 +81,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient { // ContentBrowserClient implementation. virtual content::BrowserMainParts* CreateBrowserMainParts( const content::MainFunctionParams& parameters) OVERRIDE; - virtual content::WebContentsViewPort* OverrideCreateWebContentsView( - content::WebContents* web_contents, - content::RenderViewHostDelegateView** rvhdv) OVERRIDE; virtual void RenderProcessWillLaunch( content::RenderProcessHost* host) OVERRIDE; virtual net::URLRequestContextGetter* CreateRequestContext( @@ -165,16 +162,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient { }; void set_last_create_window_params(const LastCreateWindowParams& params); - // To disable window rendering call this function with |override|=true - // just before calling WebContents::Create. This will cause - // OverrideCreateWebContentsView to create a windowless WebContentsView. - void set_use_osr_next_contents_view(bool value) { - use_osr_next_contents_view_ = value; - } - bool use_osr_next_contents_view() const { - return use_osr_next_contents_view_; - } - CefBrowserContext* browser_context() const; scoped_refptr request_context() const; CefDevToolsDelegate* devtools_delegate() const; @@ -199,8 +186,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient { // Only accessed on the IO thread. LastCreateWindowParams last_create_window_params_; - - bool use_osr_next_contents_view_; }; #endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_ diff --git a/libcef/browser/menu_creator_runner_gtk.cc b/libcef/browser/menu_creator_runner_gtk.cc index be06e52b..24ec6c22 100644 --- a/libcef/browser/menu_creator_runner_gtk.cc +++ b/libcef/browser/menu_creator_runner_gtk.cc @@ -31,33 +31,14 @@ bool CefMenuCreatorRunnerGtk::RunContextMenu(CefMenuCreator* manager) { gfx::Point screen_point; GdkEventButton* event = NULL; - if (manager->browser()->IsWindowRenderingDisabled()) { - CefRefPtr client = manager->browser()->GetClient(); - if (!client.get()) - return false; + gfx::Rect bounds; + manager->browser()->GetWebContents()->GetView()->GetContainerBounds(&bounds); + screen_point = bounds.origin(); + screen_point.Offset(manager->params().x, manager->params().y); - CefRefPtr handler = client->GetRenderHandler(); - if (!handler.get()) - return false; - - int screenX = 0, screenY = 0; - if (!handler->GetScreenPoint(manager->browser(), - manager->params().x, manager->params().y, - screenX, screenY)) { - return false; - } - - screen_point = gfx::Point(screenX, screenY); - } else { - gfx::Rect bounds; - manager->browser()->GetWebContents()->GetView()->GetContainerBounds(&bounds); - screen_point = bounds.origin(); - screen_point.Offset(manager->params().x, manager->params().y); - - content::RenderWidgetHostView* view = - manager->browser()->GetWebContents()->GetRenderWidgetHostView(); - event = view->GetLastMouseDown(); - } + content::RenderWidgetHostView* view = + manager->browser()->GetWebContents()->GetRenderWidgetHostView(); + event = view->GetLastMouseDown(); if (!menu_delegate_.get()) menu_delegate_.reset(new CefMenuDelegate); diff --git a/libcef/browser/menu_creator_runner_mac.mm b/libcef/browser/menu_creator_runner_mac.mm index 4dcad49f..d43614e4 100644 --- a/libcef/browser/menu_creator_runner_mac.mm +++ b/libcef/browser/menu_creator_runner_mac.mm @@ -62,33 +62,9 @@ bool CefMenuCreatorRunnerMac::RunContextMenu(CefMenuCreator* manager) { base::mac::ScopedSendingEvent sendingEventScoper; // Show the menu. Blocks until the menu is dismissed. - if (manager->browser()->IsWindowRenderingDisabled()) { - // Showing the menu in OSR is pretty much self contained, only using - // the initialized menu_controller_ in this function, and the scoped - // variables in this block. - int screenX = 0, screenY = 0; - CefRefPtr handler = - manager->browser()->GetClient()->GetRenderHandler(); - if (!handler->GetScreenPoint(manager->browser(), - manager->params().x, manager->params().y, - screenX, screenY)) { - return false; - } - - // Don't show the menu unless there is a parent native window to tie it to - if (!manager->browser()->GetWindowHandle()) - return false; - - NSPoint screen_position = - NSPointFromCGPoint(gfx::Point(screenX, screenY).ToCGPoint()); - [[menu_controller_ menu] popUpMenuPositioningItem:nil - atLocation:screen_position - inView:nil]; - } else { - [NSMenu popUpContextMenu:[menu_controller_ menu] - withEvent:clickEvent - forView:parent_view]; - } + [NSMenu popUpContextMenu:[menu_controller_ menu] + withEvent:clickEvent + forView:parent_view]; } return true; diff --git a/libcef/browser/menu_creator_runner_win.cc b/libcef/browser/menu_creator_runner_win.cc index 48e69f6e..e3274ea7 100644 --- a/libcef/browser/menu_creator_runner_win.cc +++ b/libcef/browser/menu_creator_runner_win.cc @@ -25,29 +25,10 @@ bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) { gfx::Point screen_point; - if (manager->browser()->IsWindowRenderingDisabled()) { - CefRefPtr client = manager->browser()->GetClient(); - if (!client.get()) - return false; - - CefRefPtr handler = client->GetRenderHandler(); - if (!handler.get()) - return false; - - int screenX = 0, screenY = 0; - if (!handler->GetScreenPoint(manager->browser(), - manager->params().x, manager->params().y, - screenX, screenY)) { - return false; - } - - screen_point = gfx::Point(screenX, screenY); - } else { - aura::Window* window = manager->browser()->GetContentView(); - const gfx::Rect& bounds_in_screen = window->GetBoundsInScreen(); - screen_point = gfx::Point(bounds_in_screen.x() + manager->params().x, - bounds_in_screen.y() + manager->params().y); - } + aura::Window* window = manager->browser()->GetContentView(); + const gfx::Rect& bounds_in_screen = window->GetBoundsInScreen(); + screen_point = gfx::Point(bounds_in_screen.x() + manager->params().x, + bounds_in_screen.y() + manager->params().y); // Show the menu. Blocks until the menu is dismissed. menu_->RunMenuAt(screen_point, views::Menu2::ALIGN_TOPLEFT); diff --git a/libcef/browser/render_widget_host_view_osr.cc b/libcef/browser/render_widget_host_view_osr.cc deleted file mode 100644 index c8580158..00000000 --- a/libcef/browser/render_widget_host_view_osr.cc +++ /dev/null @@ -1,736 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2011 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 "libcef/browser/backing_store_osr.h" -#include "libcef/browser/browser_host_impl.h" -#include "libcef/browser/render_widget_host_view_osr.h" - -#include "base/message_loop/message_loop.h" -#include "content/browser/renderer_host/render_widget_host_impl.h" -#include "content/common/cursors/webcursor.h" -#include "content/public/browser/content_browser_client.h" -#include "content/public/browser/render_view_host.h" -#include "third_party/WebKit/public/platform/WebScreenInfo.h" -#include "ui/gfx/size_conversions.h" - -namespace { - -const float kDefaultScaleFactor = 1.0; - -static blink::WebScreenInfo webScreenInfoFrom(const CefScreenInfo& src) { - blink::WebScreenInfo webScreenInfo; - webScreenInfo.deviceScaleFactor = src.device_scale_factor; - webScreenInfo.depth = src.depth; - webScreenInfo.depthPerComponent = src.depth_per_component; - webScreenInfo.isMonochrome = src.is_monochrome ? true : false; - webScreenInfo.rect = blink::WebRect(src.rect.x, src.rect.y, - src.rect.width, src.rect.height); - webScreenInfo.availableRect = blink::WebRect(src.available_rect.x, - src.available_rect.y, - src.available_rect.width, - src.available_rect.height); - - return webScreenInfo; -} - -} // namespace - -/////////////////////////////////////////////////////////////////////////////// -// CefRenderWidgetHostViewOSR, public: - -CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR( - content::RenderWidgetHost* widget) - : weak_factory_(this), - render_widget_host_(content::RenderWidgetHostImpl::From(widget)), - parent_host_view_(NULL), - popup_host_view_(NULL), - about_to_validate_and_paint_(false) -#if defined(OS_MACOSX) - , text_input_context_osr_mac_(NULL) -#endif - { - DCHECK(render_widget_host_); - render_widget_host_->SetView(this); - - // CefBrowserHostImpl might not be created at this time for popups. - if (render_widget_host_->IsRenderView()) { - browser_impl_ = CefBrowserHostImpl::GetBrowserForHost( - content::RenderViewHost::From(render_widget_host_)); - } -} - -CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() { -} - - -// RenderWidgetHostView implementation. - -gfx::Size CefRenderWidgetHostViewOSR::GetPhysicalBackingSize() const { - return gfx::ToCeiledSize(gfx::ScaleSize(GetViewBounds().size(), - GetDeviceScaleFactor())); -} - -void CefRenderWidgetHostViewOSR::InitAsChild(gfx::NativeView parent_view) { -} - -content::RenderWidgetHost* - CefRenderWidgetHostViewOSR::GetRenderWidgetHost() const { - return render_widget_host_; -} - -void CefRenderWidgetHostViewOSR::SetSize(const gfx::Size& size) { -} - -void CefRenderWidgetHostViewOSR::SetBounds(const gfx::Rect& rect) { -} - -gfx::NativeView CefRenderWidgetHostViewOSR::GetNativeView() const { - return NULL; -} - -gfx::NativeViewId CefRenderWidgetHostViewOSR::GetNativeViewId() const { - if (!browser_impl_.get()) - return gfx::NativeViewId(); - // This Id is used on Windows as HWND to retrieve monitor info - // If this Id is not a valid window, the main screen monitor info is used - return reinterpret_cast(browser_impl_->GetWindowHandle()); -} - -gfx::NativeViewAccessible - CefRenderWidgetHostViewOSR::GetNativeViewAccessible() { - return gfx::NativeViewAccessible(); -} - -bool CefRenderWidgetHostViewOSR::HasFocus() const { - return false; -} - -bool CefRenderWidgetHostViewOSR::IsSurfaceAvailableForCopy() const { - return false; -} - -void CefRenderWidgetHostViewOSR::Show() { - WasShown(); -} - -void CefRenderWidgetHostViewOSR::Hide() { - WasHidden(); -} - -bool CefRenderWidgetHostViewOSR::IsShowing() { - return true; -} - -gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() const { - if (IsPopupWidget()) - return popup_position_; - - if (!browser_impl_.get()) - return gfx::Rect(); - CefRect rc; - browser_impl_->GetClient()->GetRenderHandler()->GetViewRect( - browser_impl_->GetBrowser(), rc); - return gfx::Rect(rc.x, rc.y, rc.width, rc.height); -} - -// Implementation of RenderWidgetHostViewPort. -void CefRenderWidgetHostViewOSR::InitAsPopup( - RenderWidgetHostView* parent_host_view, - const gfx::Rect& pos) { - parent_host_view_ = static_cast( - parent_host_view); - browser_impl_ = parent_host_view_->get_browser_impl(); - if (!browser_impl_.get()) - return; - - parent_host_view_->CancelWidget(); - - parent_host_view_->set_popup_host_view(this); - NotifyShowWidget(); - - popup_position_ = pos; - NotifySizeWidget(); -} - -void CefRenderWidgetHostViewOSR::InitAsFullscreen( - RenderWidgetHostView* reference_host_view) { - NOTREACHED() << "Fullscreen widgets are not supported in OSR"; -} - -void CefRenderWidgetHostViewOSR::WasShown() { - if (render_widget_host_) - render_widget_host_->WasShown(); -} - -void CefRenderWidgetHostViewOSR::WasHidden() { - if (render_widget_host_) - render_widget_host_->WasHidden(); -} - -void CefRenderWidgetHostViewOSR::MovePluginWindows( - const gfx::Vector2d& scroll_offset, - const std::vector& moves) { -} - -void CefRenderWidgetHostViewOSR::Focus() { -} - -void CefRenderWidgetHostViewOSR::Blur() { -} - -void CefRenderWidgetHostViewOSR::UpdateCursor( - const content::WebCursor& cursor) { - TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::UpdateCursor"); - if (!browser_impl_.get()) - return; -#if defined(USE_AURA) - content::WebCursor web_cursor = cursor; - - ui::PlatformCursor platform_cursor; - if (web_cursor.IsCustom()) { - // |web_cursor| owns the resulting |platform_cursor|. - platform_cursor = web_cursor.GetPlatformCursor(); - } else { - content::WebCursor::CursorInfo cursor_info; - cursor.GetCursorInfo(&cursor_info); - platform_cursor = browser_impl_->GetPlatformCursor(cursor_info.type); - } - - browser_impl_->GetClient()->GetRenderHandler()->OnCursorChange( - browser_impl_->GetBrowser(), platform_cursor); -#elif defined(OS_MACOSX) || defined(TOOLKIT_GTK) - // |web_cursor| owns the resulting |native_cursor|. - content::WebCursor web_cursor = cursor; - CefCursorHandle native_cursor = web_cursor.GetNativeCursor(); - browser_impl_->GetClient()->GetRenderHandler()->OnCursorChange( - browser_impl_->GetBrowser(), native_cursor); -#else - // TODO(port): Implement this method to work on other platforms as part of - // off-screen rendering support. - NOTREACHED(); -#endif -} - -void CefRenderWidgetHostViewOSR::SetIsLoading(bool is_loading) { -} - -#if !defined(OS_MACOSX) -void CefRenderWidgetHostViewOSR::TextInputTypeChanged( - ui::TextInputType type, - ui::TextInputMode mode, - bool can_compose_inline) { -} - -void CefRenderWidgetHostViewOSR::ImeCancelComposition() { -} - -#if defined(OS_WIN) || defined(USE_AURA) -void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged( - const gfx::Range& range, - const std::vector& character_bounds) { -} -#endif -#endif // !defined(OS_MACOSX) - -void CefRenderWidgetHostViewOSR::DidUpdateBackingStore( - const gfx::Rect& scroll_rect, - const gfx::Vector2d& scroll_delta, - const std::vector& copy_rects, - const std::vector& latency_info) { - if (!scroll_rect.IsEmpty()) { - std::vector dirty_rects(copy_rects); - dirty_rects.push_back(scroll_rect); - Paint(dirty_rects); - } else { - Paint(copy_rects); - } -} - -void CefRenderWidgetHostViewOSR::RenderProcessGone( - base::TerminationStatus status, - int error_code) { - render_widget_host_ = NULL; - parent_host_view_ = NULL; - popup_host_view_ = NULL; -} - -#if defined(OS_WIN) && !defined(USE_AURA) -void CefRenderWidgetHostViewOSR::WillWmDestroy() { - // Will not be called if GetNativeView returns NULL. - NOTREACHED(); -} -#endif - -#if defined(OS_WIN) && defined(USE_AURA) -void CefRenderWidgetHostViewOSR::SetParentNativeViewAccessible( - gfx::NativeViewAccessible accessible_parent) { -} - -gfx::NativeViewId - CefRenderWidgetHostViewOSR::GetParentForWindowlessPlugin() const { - if (browser_impl_.get()) { - return reinterpret_cast( - browser_impl_->GetWindowHandle()); - } - return NULL; -} -#endif // defined(OS_WIN) && defined(USE_AURA) - -void CefRenderWidgetHostViewOSR::GetScreenInfo(blink::WebScreenInfo* results) { - if (!browser_impl_.get()) - return; - - CefScreenInfo screen_info( - kDefaultScaleFactor, 0, 0, false, CefRect(), CefRect()); - - CefRefPtr handler = - browser_impl_->client()->GetRenderHandler(); - if (!handler->GetScreenInfo(browser_impl_.get(), screen_info) || - screen_info.rect.width == 0 || - screen_info.rect.height == 0 || - screen_info.available_rect.width == 0 || - screen_info.available_rect.height == 0) { - // If a screen rectangle was not provided, try using the view rectangle - // instead. Otherwise, popup views may be drawn incorrectly, or not at all. - CefRect screenRect; - if (!handler->GetViewRect(browser_impl_.get(), screenRect)) { - NOTREACHED(); - screenRect = CefRect(); - } - - if (screen_info.rect.width == 0 && screen_info.rect.height == 0) - screen_info.rect = screenRect; - - if (screen_info.available_rect.width == 0 && - screen_info.available_rect.height == 0) - screen_info.available_rect = screenRect; - } - - *results = webScreenInfoFrom(screen_info); -} - -gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() { - if (!browser_impl_.get()) - return gfx::Rect(); - CefRect rc; - if (browser_impl_->GetClient()->GetRenderHandler()->GetRootScreenRect( - browser_impl_->GetBrowser(), rc)) { - return gfx::Rect(rc.x, rc.y, rc.width, rc.height); - } - return gfx::Rect(); -} - -void CefRenderWidgetHostViewOSR::CreateBrowserAccessibilityManagerIfNeeded() { -} - -void CefRenderWidgetHostViewOSR::Destroy() { - if (IsPopupWidget()) { - if (parent_host_view_) - parent_host_view_->CancelWidget(); - } else { - CancelWidget(); - } - - delete this; -} - -void CefRenderWidgetHostViewOSR::SetTooltipText( - const base::string16& tooltip_text) { - if (!browser_impl_.get()) - return; - - CefString tooltip(tooltip_text); - CefRefPtr handler = - browser_impl_->GetClient()->GetDisplayHandler(); - if (handler.get()) { - handler->OnTooltip(browser_impl_->GetBrowser(), tooltip); - } -} - -void CefRenderWidgetHostViewOSR::SelectionBoundsChanged( - const ViewHostMsg_SelectionBounds_Params& params) { -} - -void CefRenderWidgetHostViewOSR::ScrollOffsetChanged() { - if (!browser_impl_.get()) - return; - browser_impl_->GetClient()->GetRenderHandler()-> - OnScrollOffsetChanged(browser_impl_.get()); -} - -content::BackingStore* CefRenderWidgetHostViewOSR::AllocBackingStore( - const gfx::Size& size) { - return render_widget_host_ ? - new BackingStoreOSR(render_widget_host_, size, GetDeviceScaleFactor()) : - NULL; -} - -void CefRenderWidgetHostViewOSR::CopyFromCompositingSurface( - const gfx::Rect& src_subrect, - const gfx::Size& dst_size, - const base::Callback& callback, - const SkBitmap::Config config) { -} - -void CefRenderWidgetHostViewOSR::CopyFromCompositingSurfaceToVideoFrame( - const gfx::Rect& src_subrect, - const scoped_refptr& target, - const base::Callback& callback) { -} - -bool CefRenderWidgetHostViewOSR::CanCopyToVideoFrame() const { - return false; -} - -void CefRenderWidgetHostViewOSR::OnAcceleratedCompositingStateChange() { -} - -void CefRenderWidgetHostViewOSR::AcceleratedSurfaceInitialized( - int host_id, int route_id) { -} - -void CefRenderWidgetHostViewOSR::SetHasHorizontalScrollbar( - bool has_horizontal_scrollbar) { -} - -void CefRenderWidgetHostViewOSR::SetScrollOffsetPinning( - bool is_pinned_to_left, bool is_pinned_to_right) { -} - -gfx::GLSurfaceHandle CefRenderWidgetHostViewOSR::GetCompositingSurface() { - return gfx::GLSurfaceHandle(); -} - -void CefRenderWidgetHostViewOSR::AcceleratedSurfaceBuffersSwapped( - const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, - int gpu_host_id) { -} - -void CefRenderWidgetHostViewOSR::AcceleratedSurfacePostSubBuffer( - const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, - int gpu_host_id) { -} - -void CefRenderWidgetHostViewOSR::AcceleratedSurfaceSuspend() { -} - -void CefRenderWidgetHostViewOSR::AcceleratedSurfaceRelease() { -} - -bool CefRenderWidgetHostViewOSR::HasAcceleratedSurface( - const gfx::Size& desired_size) { - return false; -} - -bool CefRenderWidgetHostViewOSR::LockMouse() { - return false; -} - -void CefRenderWidgetHostViewOSR::UnlockMouse() { -} - -#if defined(OS_WIN) && !defined(USE_AURA) -void CefRenderWidgetHostViewOSR::SetClickthroughRegion(SkRegion* region) { -} -#endif - -void CefRenderWidgetHostViewOSR::SetBackground(const SkBitmap& background) { - if (!render_widget_host_) - return; - RenderWidgetHostViewBase::SetBackground(background); - render_widget_host_->SetBackground(background); -} - -void CefRenderWidgetHostViewOSR::Invalidate(const gfx::Rect& rect, - CefBrowserHost::PaintElementType type) { - TRACE_EVENT1("libcef", "CefRenderWidgetHostViewOSR::Invalidate", "type", type); - if (!IsPopupWidget() && type == PET_POPUP) { - if (popup_host_view_) - popup_host_view_->Invalidate(rect, type); - return; - } - std::vector dirtyRects; - dirtyRects.push_back(rect); - Paint(dirtyRects); -} - -void CefRenderWidgetHostViewOSR::Paint( - const std::vector& copy_rects) { - TRACE_EVENT1("libcef", "CefRenderWidgetHostViewOSR::Paint", "rects", copy_rects.size()); - if (about_to_validate_and_paint_ || - !browser_impl_.get() || - !render_widget_host_) { - pending_update_rects_.insert(pending_update_rects_.end(), - copy_rects.begin(), copy_rects.end()); - return; - } - - about_to_validate_and_paint_ = true; - BackingStoreOSR* backing_store = - BackingStoreOSR::From(render_widget_host_->GetBackingStore(true)); - about_to_validate_and_paint_ = false; - - if (backing_store) { - const gfx::Rect client_rect(backing_store->size()); - SkRegion damaged_rgn; - - for (size_t i = 0; i < copy_rects.size(); ++i) { - SkIRect skRect = SkIRect::MakeLTRB( - copy_rects[i].x(), copy_rects[i].y(), - copy_rects[i].right(), copy_rects[i].bottom()); - damaged_rgn.op(skRect, SkRegion::kUnion_Op); - } - - for (size_t i = 0; i < pending_update_rects_.size(); ++i) { - SkIRect skRect = SkIRect::MakeLTRB( - pending_update_rects_[i].x(), pending_update_rects_[i].y(), - pending_update_rects_[i].right(), pending_update_rects_[i].bottom()); - damaged_rgn.op(skRect, SkRegion::kUnion_Op); - } - pending_update_rects_.clear(); - - CefRenderHandler::RectList rcList; - SkRegion::Cliperator iterator(damaged_rgn, - SkIRect::MakeWH(client_rect.width(), client_rect.height())); - for (; !iterator.done(); iterator.next()) { - const SkIRect& r = iterator.rect(); - rcList.push_back( - CefRect(r.left(), r.top(), r.width(), r.height())); - } - - if (rcList.size() == 0) - return; - - browser_impl_->GetClient()->GetRenderHandler()->OnPaint( - browser_impl_->GetBrowser(), - IsPopupWidget() ? PET_POPUP : PET_VIEW, - rcList, - backing_store->getPixels(), - client_rect.width(), - client_rect.height()); - } -} - -bool CefRenderWidgetHostViewOSR::InstallTransparency() { - if (browser_impl_.get() && browser_impl_->IsTransparent()) { - SkBitmap bg; - bg.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); // 1x1 alpha bitmap. - bg.allocPixels(); - bg.eraseARGB(0x00, 0x00, 0x00, 0x00); - SetBackground(bg); - return true; - } - return false; -} - -void CefRenderWidgetHostViewOSR::CancelWidget() { - if (IsPopupWidget()) { - if (render_widget_host_) - render_widget_host_->LostCapture(); - - if (browser_impl_.get()) { - NotifyHideWidget(); - browser_impl_ = NULL; - } - - if (parent_host_view_) { - parent_host_view_->set_popup_host_view(NULL); - parent_host_view_ = NULL; - } - - if (!weak_factory_.HasWeakPtrs()) { - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&CefRenderWidgetHostViewOSR::ShutdownHost, - weak_factory_.GetWeakPtr())); - } - } else if (popup_host_view_) { - popup_host_view_->CancelWidget(); - } -} - -void CefRenderWidgetHostViewOSR::NotifyShowWidget() { - if (browser_impl_.get()) { - browser_impl_->GetClient()->GetRenderHandler()->OnPopupShow( - browser_impl_->GetBrowser(), true); - } -} - -void CefRenderWidgetHostViewOSR::NotifyHideWidget() { - if (browser_impl_.get()) { - browser_impl_->GetClient()->GetRenderHandler()->OnPopupShow( - browser_impl_->GetBrowser(), false); - } -} - -void CefRenderWidgetHostViewOSR::NotifySizeWidget() { - if (browser_impl_.get()) { - CefRect widget_pos(popup_position_.x(), popup_position_.y(), - popup_position_.width(), popup_position_.height()); - browser_impl_->GetClient()->GetRenderHandler()->OnPopupSize( - browser_impl_->GetBrowser(), widget_pos); - } -} - -CefRefPtr - CefRenderWidgetHostViewOSR::get_browser_impl() const { - return browser_impl_; -} - -void CefRenderWidgetHostViewOSR::set_browser_impl( - CefRefPtr browser) { - browser_impl_ = browser; -} - -void CefRenderWidgetHostViewOSR::set_popup_host_view( - CefRenderWidgetHostViewOSR* popup_view) { - popup_host_view_ = popup_view; -} - -void CefRenderWidgetHostViewOSR::ShutdownHost() { - weak_factory_.InvalidateWeakPtrs(); - if (render_widget_host_) - render_widget_host_->Shutdown(); - // Do not touch any members at this point, |this| has been deleted. -} - -void CefRenderWidgetHostViewOSR::set_parent_host_view( - CefRenderWidgetHostViewOSR* parent_view) { - parent_host_view_ = parent_view; -} - -void CefRenderWidgetHostViewOSR::SendKeyEvent( - const content::NativeWebKeyboardEvent& event) { - TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendKeyEvent"); - if (!render_widget_host_) - return; - render_widget_host_->ForwardKeyboardEvent(event); -} - -void CefRenderWidgetHostViewOSR::SendMouseEvent( - const blink::WebMouseEvent& event) { - TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseEvent"); - if (!IsPopupWidget() && popup_host_view_) { - if (popup_host_view_->popup_position_.Contains(event.x, event.y)) { - blink::WebMouseEvent popup_event(event); - popup_event.x -= popup_host_view_->popup_position_.x(); - popup_event.y -= popup_host_view_->popup_position_.y(); - popup_event.windowX = popup_event.x; - popup_event.windowY = popup_event.y; - - popup_host_view_->SendMouseEvent(popup_event); - return; - } - } - if (!render_widget_host_) - return; - render_widget_host_->ForwardMouseEvent(event); -} - -void CefRenderWidgetHostViewOSR::SendMouseWheelEvent( - const blink::WebMouseWheelEvent& event) { - TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent"); - if (!IsPopupWidget() && popup_host_view_) { - if (popup_host_view_->popup_position_.Contains(event.x, event.y)) { - blink::WebMouseWheelEvent popup_event(event); - popup_event.x -= popup_host_view_->popup_position_.x(); - popup_event.y -= popup_host_view_->popup_position_.y(); - popup_event.windowX = popup_event.x; - popup_event.windowY = popup_event.y; - popup_host_view_->SendMouseWheelEvent(popup_event); - return; - } else { - // scrolling outside the popup widget, will destroy widget - CancelWidget(); - } - } - if (!render_widget_host_) - return; - render_widget_host_->ForwardWheelEvent(event); -} - -void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() { - TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::OnScreenInfoChanged"); - if (!render_widget_host_) - return; - - BackingStoreOSR* backing_store = - BackingStoreOSR::From(render_widget_host_->GetBackingStore(true)); - if (backing_store) - backing_store->ScaleFactorChanged(GetDeviceScaleFactor()); - - // What could be taken from UpdateScreenInfo(window_) - updates the renderer - // cached rectangles - //render_widget_host_->SendScreenRects(); - - render_widget_host_->NotifyScreenInfoChanged(); - // We might want to change the cursor scale factor here as well - see the - // cache for the current_cursor_, as passed by UpdateCursor from the renderer - // in the rwhv_aura (current_cursor_.SetScaleFactor) -} - -float CefRenderWidgetHostViewOSR::GetDeviceScaleFactor() const { - if (!browser_impl_.get()) - return kDefaultScaleFactor; - - CefScreenInfo screen_info( - kDefaultScaleFactor, 0, 0, false, CefRect(), CefRect()); - if (!browser_impl_->GetClient()->GetRenderHandler()->GetScreenInfo( - browser_impl_->GetBrowser(), screen_info)) { - // Use the default - return kDefaultScaleFactor; - } - - return screen_info.device_scale_factor; -} - -#if defined(OS_MACOSX) -bool CefRenderWidgetHostViewOSR::PostProcessEventForPluginIme( - const content::NativeWebKeyboardEvent& event) { - return false; -} -#endif - -#if defined(OS_MACOSX) -void CefRenderWidgetHostViewOSR::SetActive(bool active) { -} - -void CefRenderWidgetHostViewOSR::SetTakesFocusOnlyOnMouseDown(bool flag) { -} - -void CefRenderWidgetHostViewOSR::SetWindowVisibility(bool visible) { -} - -void CefRenderWidgetHostViewOSR::WindowFrameChanged() { -} - -void CefRenderWidgetHostViewOSR::ShowDefinitionForSelection() { -} - - -bool CefRenderWidgetHostViewOSR::SupportsSpeech() const { - return false; -} - -void CefRenderWidgetHostViewOSR::SpeakSelection() { -} - -bool CefRenderWidgetHostViewOSR::IsSpeaking() const { - return false; -} - -void CefRenderWidgetHostViewOSR::StopSpeaking() { -} -#endif // defined(OS_MACOSX) - -#if defined(TOOLKIT_GTK) -GdkEventButton* CefRenderWidgetHostViewOSR::GetLastMouseDown() { - return NULL; -} - -gfx::NativeView CefRenderWidgetHostViewOSR::BuildInputMethodsGtkMenu() { - return NULL; -} -#endif // defined(TOOLKIT_GTK) - diff --git a/libcef/browser/render_widget_host_view_osr.h b/libcef/browser/render_widget_host_view_osr.h deleted file mode 100644 index a4ba8a9c..00000000 --- a/libcef/browser/render_widget_host_view_osr.h +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2011 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. - -#ifndef CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_ -#define CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_ -#pragma once - -#include - -#include "include/cef_base.h" -#include "include/cef_browser.h" - -#include "base/memory/weak_ptr.h" -#include "content/browser/renderer_host/render_widget_host_view_base.h" - -namespace content { - class RenderWidgetHost; - class BackingStore; -} - -class CefBrowserHostImpl; -class CefWebContentsViewOSR; - -/////////////////////////////////////////////////////////////////////////////// -// CefRenderWidgetHostViewOSR -// -// An object representing the "View" of a rendered web page. This object is -// responsible for sending paint events to the the CefRenderHandler -// when window rendering is disabled. It is the implementation of the -// RenderWidgetHostView that the cross-platform RenderWidgetHost object uses -// to display the data. -// -// Comment excerpted from render_widget_host.h: -// -// "The lifetime of the RenderWidgetHostHWND is tied to the render process. -// If the render process dies, the RenderWidgetHostHWND goes away and all -// references to it must become NULL." -// -// RenderWidgetHostView class hierarchy described in render_widget_host_view.h. -/////////////////////////////////////////////////////////////////////////////// - -class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase { -#if defined(OS_MACOSX) - public: - NSTextInputContext* GetNSTextInputContext(); - void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent); - void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent); - - bool GetCachedFirstRectForCharacterRange(gfx::Range range, gfx::Rect* rect, - gfx::Range* actual_range) const; - - private: - // Returns composition character boundary rectangle. The |range| is - // composition based range. Also stores |actual_range| which is corresponding - // to actually used range for returned rectangle. - gfx::Rect GetFirstRectForCompositionRange(const gfx::Range& range, - gfx::Range* actual_range) const; - - // Converts from given whole character range to composition oriented range. If - // the conversion failed, return gfx::Range::InvalidRange. - gfx::Range ConvertCharacterRangeToCompositionRange( - const gfx::Range& request_range) const; - - // Returns true if there is line break in |range| and stores line breaking - // point to |line_breaking_point|. The |line_break_point| is valid only if - // this function returns true. - static bool GetLineBreakIndex(const std::vector& bounds, - const gfx::Range& range, - size_t* line_break_point); - - void DestroyNSTextInputOSR(); -#endif // defined(OS_MACOSX) - - public: - // RenderWidgetHostView methods. - virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE; - virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; - virtual content::RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; - virtual void SetSize(const gfx::Size& size) OVERRIDE; - virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; - virtual gfx::NativeView GetNativeView() const OVERRIDE; - virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; - virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; - virtual bool HasFocus() const OVERRIDE; - virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; - virtual void Show() OVERRIDE; - virtual void Hide() OVERRIDE; - virtual bool IsShowing() OVERRIDE; - virtual gfx::Rect GetViewBounds() const OVERRIDE; -#if defined(OS_MACOSX) - virtual void SetActive(bool active) OVERRIDE; - virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE; - virtual void SetWindowVisibility(bool visible) OVERRIDE; - virtual void WindowFrameChanged() OVERRIDE; - virtual void ShowDefinitionForSelection() OVERRIDE; - virtual bool SupportsSpeech() const OVERRIDE; - virtual void SpeakSelection() OVERRIDE; - virtual bool IsSpeaking() const OVERRIDE; - virtual void StopSpeaking() OVERRIDE; -#endif // defined(OS_MACOSX) -#if defined(TOOLKIT_GTK) - virtual GdkEventButton* GetLastMouseDown() OVERRIDE; - virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE; -#endif // defined(TOOLKIT_GTK) - - // RenderWidgetHostViewPort methods. - virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, - const gfx::Rect& pos) OVERRIDE; - virtual void InitAsFullscreen( - RenderWidgetHostView* reference_host_view) OVERRIDE; - virtual void WasShown() OVERRIDE; - virtual void WasHidden() OVERRIDE; - virtual void MovePluginWindows( - const gfx::Vector2d& scroll_offset, - const std::vector& moves) OVERRIDE; - virtual void Focus() OVERRIDE; - virtual void Blur() OVERRIDE; - virtual void UpdateCursor(const content::WebCursor& cursor) OVERRIDE; - virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void TextInputTypeChanged(ui::TextInputType type, - ui::TextInputMode mode, - bool can_compose_inline) OVERRIDE; - virtual void ImeCancelComposition() OVERRIDE; -#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) - virtual void ImeCompositionRangeChanged( - const gfx::Range& range, - const std::vector& character_bounds) OVERRIDE; -#endif - virtual void DidUpdateBackingStore( - const gfx::Rect& scroll_rect, - const gfx::Vector2d& scroll_delta, - const std::vector& copy_rects, - const std::vector& latency_info) OVERRIDE; - virtual void RenderProcessGone(base::TerminationStatus status, - int error_code) OVERRIDE; -#if defined(OS_WIN) && !defined(USE_AURA) - virtual void WillWmDestroy() OVERRIDE; -#endif -#if defined(OS_WIN) && defined(USE_AURA) - virtual void SetParentNativeViewAccessible( - gfx::NativeViewAccessible accessible_parent) OVERRIDE; - virtual gfx::NativeViewId GetParentForWindowlessPlugin() const OVERRIDE; -#endif - virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE; - virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; - virtual void CreateBrowserAccessibilityManagerIfNeeded() OVERRIDE; - virtual void Destroy() OVERRIDE; - virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE; - virtual void SelectionBoundsChanged( - const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE; - virtual void ScrollOffsetChanged() OVERRIDE; - virtual content::BackingStore* - AllocBackingStore(const gfx::Size& size) OVERRIDE; - virtual void CopyFromCompositingSurface( - const gfx::Rect& src_subrect, - const gfx::Size& dst_size, - const base::Callback& callback, - const SkBitmap::Config config) OVERRIDE; - virtual void CopyFromCompositingSurfaceToVideoFrame( - const gfx::Rect& src_subrect, - const scoped_refptr& target, - const base::Callback& callback) OVERRIDE; - virtual bool CanCopyToVideoFrame() const OVERRIDE; - virtual void OnAcceleratedCompositingStateChange() OVERRIDE; - virtual void AcceleratedSurfaceInitialized( - int host_id, int route_id) OVERRIDE; - virtual void SetHasHorizontalScrollbar( - bool has_horizontal_scrollbar) OVERRIDE; - virtual void SetScrollOffsetPinning( - bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; - virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; - virtual void AcceleratedSurfaceBuffersSwapped( - const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, - int gpu_host_id) OVERRIDE; - virtual void AcceleratedSurfacePostSubBuffer( - const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, - int gpu_host_id) OVERRIDE; - virtual void AcceleratedSurfaceSuspend() OVERRIDE; - virtual void AcceleratedSurfaceRelease() OVERRIDE; - virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; - virtual bool LockMouse() OVERRIDE; - virtual void UnlockMouse() OVERRIDE; - -#if defined(OS_WIN) && !defined(USE_AURA) - virtual void SetClickthroughRegion(SkRegion* region) OVERRIDE; -#endif - -#if defined(OS_MACOSX) - virtual bool PostProcessEventForPluginIme( - const content::NativeWebKeyboardEvent& event) OVERRIDE; -#endif - - // RenderWidgetHostViewBase methods. - virtual void SetBackground(const SkBitmap& background) OVERRIDE; - - void SendKeyEvent(const content::NativeWebKeyboardEvent& event); - void SendMouseEvent(const blink::WebMouseEvent& event); - void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event); - - void Invalidate(const gfx::Rect& rect, - CefBrowserHost::PaintElementType type); - void Paint(const std::vector& copy_rects); - bool InstallTransparency(); - - void OnScreenInfoChanged(); - float GetDeviceScaleFactor() const; - - void CancelWidget(); - void NotifyShowWidget(); - void NotifyHideWidget(); - void NotifySizeWidget(); - - content::RenderWidgetHostImpl* get_render_widget_host_impl() const - { return render_widget_host_; } - CefRefPtr get_browser_impl() const; - void set_browser_impl(CefRefPtr browser); - void set_popup_host_view(CefRenderWidgetHostViewOSR* popup_view); - void set_parent_host_view(CefRenderWidgetHostViewOSR* parent_view); - - bool IsPopupWidget() const { - return popup_type_ != blink::WebPopupTypeNone; - } - - private: - friend class CefWebContentsViewOSR; - - explicit CefRenderWidgetHostViewOSR(content::RenderWidgetHost* widget); - virtual ~CefRenderWidgetHostViewOSR(); - - // After calling this function, object gets deleted - void ShutdownHost(); - - // Factory used to safely scope delayed calls to ShutdownHost(). - base::WeakPtrFactory weak_factory_; - - // The associated Model. While |this| is being Destroyed, - // |render_widget_host_| is NULL and the Windows message loop is run one last - // time. Message handlers must check for a NULL |render_widget_host_|. - content::RenderWidgetHostImpl* render_widget_host_; - CefRenderWidgetHostViewOSR* parent_host_view_; - CefRenderWidgetHostViewOSR* popup_host_view_; - - CefRefPtr browser_impl_; - - bool about_to_validate_and_paint_; - std::vector pending_update_rects_; - - gfx::Rect popup_position_; - -#if defined(OS_MACOSX) - NSTextInputContext* text_input_context_osr_mac_; -#endif // defined(OS_MACOSX) - - DISALLOW_COPY_AND_ASSIGN(CefRenderWidgetHostViewOSR); -}; - -#endif // CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_ diff --git a/libcef/browser/render_widget_host_view_osr_mac.mm b/libcef/browser/render_widget_host_view_osr_mac.mm deleted file mode 100644 index ebe51a91..00000000 --- a/libcef/browser/render_widget_host_view_osr_mac.mm +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2011 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 "libcef/browser/render_widget_host_view_osr.h" -#include "libcef/browser/text_input_client_osr_mac.h" - -static CefTextInputClientOSRMac* GetInputClientFromContext( - const NSTextInputContext* context) { - if (!context) - return NULL; - return reinterpret_cast([context client]); -} - -CefTextInputContext CefRenderWidgetHostViewOSR::GetNSTextInputContext() { - if (!text_input_context_osr_mac_) { - CefTextInputClientOSRMac* text_input_client_osr_mac = - [[CefTextInputClientOSRMac alloc] initWithRenderWidgetHostViewOSR: - this]; - - text_input_context_osr_mac_ = [[NSTextInputContext alloc] initWithClient: - text_input_client_osr_mac]; - } - - return text_input_context_osr_mac_; -} - -void CefRenderWidgetHostViewOSR::HandleKeyEventBeforeTextInputClient( - CefEventHandle keyEvent) { - CefTextInputClientOSRMac* client = GetInputClientFromContext( - text_input_context_osr_mac_); - if (client) - [client HandleKeyEventBeforeTextInputClient: keyEvent]; -} - -void CefRenderWidgetHostViewOSR::HandleKeyEventAfterTextInputClient( - CefEventHandle keyEvent) { - CefTextInputClientOSRMac* client = GetInputClientFromContext( - text_input_context_osr_mac_); - if (client) - [client HandleKeyEventAfterTextInputClient: keyEvent]; -} - -void CefRenderWidgetHostViewOSR::DestroyNSTextInputOSR() { - CefTextInputClientOSRMac* client = GetInputClientFromContext( - text_input_context_osr_mac_); - if (client) { - [client release]; - client = NULL; - } - - [text_input_context_osr_mac_ release]; - text_input_context_osr_mac_ = NULL; -} - -void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged( - const gfx::Range& range, - const std::vector& character_bounds) { - CefTextInputClientOSRMac* client = GetInputClientFromContext( - text_input_context_osr_mac_); - if (!client) - return; - - client->markedRange_ = range.ToNSRange(); - client->composition_range_ = range; - client->composition_bounds_ = character_bounds; -} - -void CefRenderWidgetHostViewOSR::ImeCancelComposition() { - CefTextInputClientOSRMac* client = GetInputClientFromContext( - text_input_context_osr_mac_); - if (client) - [client cancelComposition]; -} - -void CefRenderWidgetHostViewOSR::TextInputTypeChanged( - ui::TextInputType type, - ui::TextInputMode mode, - bool can_compose_inline) { - [NSApp updateWindows]; -} - -bool CefRenderWidgetHostViewOSR::GetLineBreakIndex( - const std::vector& bounds, - const gfx::Range& range, - size_t* line_break_point) { - DCHECK(line_break_point); - if (range.start() >= bounds.size() || range.is_reversed() || range.is_empty()) - return false; - - // We can't check line breaking completely from only rectangle array. Thus we - // assume the line breaking as the next character's y offset is larger than - // a threshold. Currently the threshold is determined as minimum y offset plus - // 75% of maximum height. - const size_t loop_end_idx = std::min(bounds.size(), range.end()); - int max_height = 0; - int min_y_offset = kint32max; - for (size_t idx = range.start(); idx < loop_end_idx; ++idx) { - max_height = std::max(max_height, bounds[idx].height()); - min_y_offset = std::min(min_y_offset, bounds[idx].y()); - } - int line_break_threshold = min_y_offset + (max_height * 3 / 4); - for (size_t idx = range.start(); idx < loop_end_idx; ++idx) { - if (bounds[idx].y() > line_break_threshold) { - *line_break_point = idx; - return true; - } - } - return false; -} - -gfx::Rect CefRenderWidgetHostViewOSR::GetFirstRectForCompositionRange( - const gfx::Range& range, gfx::Range* actual_range) const { - CefTextInputClientOSRMac* client = GetInputClientFromContext( - text_input_context_osr_mac_); - - DCHECK(client); - DCHECK(actual_range); - DCHECK(!client->composition_bounds_.empty()); - DCHECK_LE(range.start(), client->composition_bounds_.size()); - DCHECK_LE(range.end(), client->composition_bounds_.size()); - - if (range.is_empty()) { - *actual_range = range; - if (range.start() == client->composition_bounds_.size()) { - return gfx::Rect(client->composition_bounds_[range.start() - 1].right(), - client->composition_bounds_[range.start() - 1].y(), - 0, - client->composition_bounds_[range.start() - 1].height()); - } else { - return gfx::Rect(client->composition_bounds_[range.start()].x(), - client->composition_bounds_[range.start()].y(), - 0, - client->composition_bounds_[range.start()].height()); - } - } - - size_t end_idx; - if (!GetLineBreakIndex(client->composition_bounds_, - range, &end_idx)) { - end_idx = range.end(); - } - *actual_range = gfx::Range(range.start(), end_idx); - gfx::Rect rect = client->composition_bounds_[range.start()]; - for (size_t i = range.start() + 1; i < end_idx; ++i) { - rect.Union(client->composition_bounds_[i]); - } - return rect; -} - -gfx::Range CefRenderWidgetHostViewOSR::ConvertCharacterRangeToCompositionRange( - const gfx::Range& request_range) const { - CefTextInputClientOSRMac* client = GetInputClientFromContext( - text_input_context_osr_mac_); - DCHECK(client); - - if (client->composition_range_.is_empty()) - return gfx::Range::InvalidRange(); - - if (request_range.is_reversed()) - return gfx::Range::InvalidRange(); - - if (request_range.start() < client->composition_range_.start() - || request_range.start() > client->composition_range_.end() - || request_range.end() > client->composition_range_.end()) - return gfx::Range::InvalidRange(); - - return gfx::Range(request_range.start() - client->composition_range_.start(), - request_range.end() - client->composition_range_.start()); -} - -bool CefRenderWidgetHostViewOSR::GetCachedFirstRectForCharacterRange( - gfx::Range range, gfx::Rect* rect, gfx::Range* actual_range) const { - DCHECK(rect); - CefTextInputClientOSRMac* client = GetInputClientFromContext( - text_input_context_osr_mac_); - - // If requested range is same as caret location, we can just return it. - if (selection_range_.is_empty() && gfx::Range(range) == selection_range_) { - if (actual_range) - *actual_range = range; - *rect = client->caret_rect_; - return true; - } - - const gfx::Range request_range_in_composition = - ConvertCharacterRangeToCompositionRange(gfx::Range(range)); - if (request_range_in_composition == gfx::Range::InvalidRange()) - return false; - - // If firstRectForCharacterRange in WebFrame is failed in renderer, - // ImeCompositionRangeChanged will be sent with empty vector. - if (client->composition_bounds_.empty()) - return false; - - DCHECK_EQ(client->composition_bounds_.size(), - client->composition_range_.length()); - - gfx::Range ui_actual_range; - *rect = GetFirstRectForCompositionRange(request_range_in_composition, - &ui_actual_range); - if (actual_range) { - *actual_range = gfx::Range( - client->composition_range_.start() + ui_actual_range.start(), - client->composition_range_.start() + ui_actual_range.end()).ToNSRange(); - } - return true; -} diff --git a/libcef/browser/text_input_client_osr_mac.h b/libcef/browser/text_input_client_osr_mac.h deleted file mode 100644 index 5b10caab..00000000 --- a/libcef/browser/text_input_client_osr_mac.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#ifndef CEF_LIBCEF_BROWSER_TEXT_INPUT_CLIENT_OSR_MAC_H_ -#define CEF_LIBCEF_BROWSER_TEXT_INPUT_CLIENT_OSR_MAC_H_ -#pragma once - -#import -#include - -#include "libcef/browser/render_widget_host_view_osr.h" - -#include "base/mac/scoped_nsobject.h" -#include "base/strings/string16.h" -#include "content/browser/renderer_host/render_widget_host_impl.h" -#include "content/common/edit_command.h" -#include "third_party/WebKit/public/web/WebCompositionUnderline.h" - -// Implementation for the NSTextInputClient protocol used for enabling IME on -// mac when window rendering is disabled. - -@interface CefTextInputClientOSRMac : NSObject { - - @public - // The range of current marked text inside the whole content of the DOM node - // being edited. - NSRange markedRange_; - - // The current composition character range and its bounds. - gfx::Range composition_range_; - std::vector composition_bounds_; - - // The current caret bounds. - gfx::Rect caret_rect_; - - @private - // Represents the input-method attributes supported by this object. - base::scoped_nsobject validAttributesForMarkedText_; - - // Indicates if we are currently handling a key down event. - BOOL handlingKeyDown_; - - // Indicates if there is any marked text. - BOOL hasMarkedText_; - - // Indicates whether there was any marked text prior to handling - // the current key event. - BOOL oldHasMarkedText_; - - // Indicates if unmarkText is called or not when handling a keyboard - // event. - BOOL unmarkTextCalled_; - - // The selected range, cached from a message sent by the renderer. - NSRange selectedRange_; - - // Text to be inserted which was generated by handling a key down event. - base::string16 textToBeInserted_; - - // Marked text which was generated by handling a key down event. - base::string16 markedText_; - - // Underline information of the |markedText_|. - std::vector underlines_; - - // Indicates if doCommandBySelector method receives any edit command when - // handling a key down event. - BOOL hasEditCommands_; - - // Contains edit commands received by the -doCommandBySelector: method when - // handling a key down event, not including inserting commands, eg. insertTab, - // etc. - content::EditCommands editCommands_; - - CefRenderWidgetHostViewOSR* renderWidgetHostView_; -} - -@property(nonatomic, readonly) NSRange selectedRange; -@property(nonatomic) BOOL handlingKeyDown; - -- (id)initWithRenderWidgetHostViewOSR:(CefRenderWidgetHostViewOSR*) rwhv; -- (void)HandleKeyEventBeforeTextInputClient:(NSEvent*)keyEvent; -- (void)HandleKeyEventAfterTextInputClient:(NSEvent*)keyEvent; -- (void)cancelComposition; - -@end - -#endif // CEF_LIBCEF_BROWSER_TEXT_INPUT_CLIENT_OSR_MAC_H_ diff --git a/libcef/browser/text_input_client_osr_mac.mm b/libcef/browser/text_input_client_osr_mac.mm deleted file mode 100644 index 937aeb8a..00000000 --- a/libcef/browser/text_input_client_osr_mac.mm +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework 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 "libcef/browser/text_input_client_osr_mac.h" -#include "libcef/browser/browser_host_impl.h" - -#include "base/strings/sys_string_conversions.h" -#import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.h" -#import "content/browser/renderer_host/text_input_client_mac.h" -#include "content/common/input_messages.h" - -namespace { - -// TODO(suzhe): Upstream this function. -blink::WebColor WebColorFromNSColor(NSColor *color) { - CGFloat r, g, b, a; - [color getRed:&r green:&g blue:&b alpha:&a]; - - return - std::max(0, std::min(static_cast(lroundf(255.0f * a)), 255)) << 24 | - std::max(0, std::min(static_cast(lroundf(255.0f * r)), 255)) << 16 | - std::max(0, std::min(static_cast(lroundf(255.0f * g)), 255)) << 8 | - std::max(0, std::min(static_cast(lroundf(255.0f * b)), 255)); -} - -// Extract underline information from an attributed string. Mostly copied from -// third_party/WebKit/Source/WebKit/mac/WebView/WebHTMLView.mm -void ExtractUnderlines(NSAttributedString* string, - std::vector* underlines) { - int length = [[string string] length]; - int i = 0; - while (i < length) { - NSRange range; - NSDictionary* attrs = [string attributesAtIndex:i - longestEffectiveRange:&range - inRange:NSMakeRange(i, length - i)]; - NSNumber *style = [attrs objectForKey: NSUnderlineStyleAttributeName]; - if (style) { - blink::WebColor color = SK_ColorBLACK; - if (NSColor *colorAttr = - [attrs objectForKey:NSUnderlineColorAttributeName]) { - color = WebColorFromNSColor( - [colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]); - } - underlines->push_back(blink::WebCompositionUnderline( - range.location, NSMaxRange(range), color, [style intValue] > 1)); - } - i = range.location + range.length; - } -} - -} // namespace - -extern "C" { - extern NSString* NSTextInputReplacementRangeAttributeName; -} - -@implementation CefTextInputClientOSRMac - -@synthesize selectedRange = selectedRange_; -@synthesize handlingKeyDown = handlingKeyDown_; - -- (id)initWithRenderWidgetHostViewOSR:(CefRenderWidgetHostViewOSR*)rwhv { - self = [super init]; - renderWidgetHostView_ = rwhv; - - return self; -} - -- (NSArray*)validAttributesForMarkedText { - if (!validAttributesForMarkedText_) { - validAttributesForMarkedText_.reset([[NSArray alloc] initWithObjects: - NSUnderlineStyleAttributeName, - NSUnderlineColorAttributeName, - NSMarkedClauseSegmentAttributeName, - NSTextInputReplacementRangeAttributeName, - nil]); - } - return validAttributesForMarkedText_.get(); -} - -- (NSRange)markedRange { - return hasMarkedText_ ? markedRange_ : NSMakeRange(NSNotFound, 0); -} - -- (BOOL)hasMarkedText { - return hasMarkedText_; -} - -- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange { - BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]]; - NSString* im_text = isAttributedString ? [aString string] : aString; - if (handlingKeyDown_) { - textToBeInserted_.append(base::SysNSStringToUTF16(im_text)); - } else { - gfx::Range replacement_range(replacementRange); - - renderWidgetHostView_->get_render_widget_host_impl()->ImeConfirmComposition( - base::SysNSStringToUTF16(im_text), replacement_range, false); - } - - // Inserting text will delete all marked text automatically. - hasMarkedText_ = NO; -} - -- (void)doCommandBySelector:(SEL)aSelector { - // An input method calls this function to dispatch an editing command to be - // handled by this view. - if (aSelector == @selector(noop:)) - return; - std::string command([content::RenderWidgetHostViewMacEditCommandHelper:: - CommandNameForSelector(aSelector) UTF8String]); - - // If this method is called when handling a key down event, then we need to - // handle the command in the key event handler. Otherwise we can just handle - // it here. - if (handlingKeyDown_) { - hasEditCommands_ = YES; - // We ignore commands that insert characters, because this was causing - // strange behavior (e.g. tab always inserted a tab rather than moving to - // the next field on the page). - if (!StartsWithASCII(command, "insert", false)) - editCommands_.push_back(content::EditCommand(command, "")); - } else { - renderWidgetHostView_->get_render_widget_host_impl()->Send( - new InputMsg_ExecuteEditCommand( - renderWidgetHostView_->get_render_widget_host_impl()-> - GetRoutingID(), command, "")); - } -} - -- (void)setMarkedText:(id)aString selectedRange:(NSRange)newSelRange - replacementRange:(NSRange)replacementRange { - // An input method updates the composition string. - // We send the given text and range to the renderer so it can update the - // composition node of WebKit. - - BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]]; - NSString* im_text = isAttributedString ? [aString string] : aString; - int length = [im_text length]; - - // |markedRange_| will get set on a callback from ImeSetComposition(). - selectedRange_ = newSelRange; - markedText_ = base::SysNSStringToUTF16(im_text); - hasMarkedText_ = (length > 0); - underlines_.clear(); - - if (isAttributedString) { - ExtractUnderlines(aString, &underlines_); - } else { - // Use a thin black underline by default. - underlines_.push_back(blink::WebCompositionUnderline(0, length, - SK_ColorBLACK, false)); - } - - // If we are handling a key down event, then SetComposition() will be - // called in keyEvent: method. - // Input methods of Mac use setMarkedText calls with an empty text to cancel - // an ongoing composition. So, we should check whether or not the given text - // is empty to update the input method state. (Our input method backend can - // automatically cancels an ongoing composition when we send an empty text. - // So, it is OK to send an empty text to the renderer.) - if (!handlingKeyDown_) { - renderWidgetHostView_->get_render_widget_host_impl()->ImeSetComposition( - markedText_, underlines_, newSelRange.location, - NSMaxRange(newSelRange)); - } -} - -- (void)unmarkText { - // Delete the composition node of the renderer and finish an ongoing - // composition. - // It seems an input method calls the setMarkedText method and set an empty - // text when it cancels an ongoing composition, i.e. I have never seen an - // input method calls this method. - hasMarkedText_ = NO; - markedText_.clear(); - underlines_.clear(); - - // If we are handling a key down event, then ConfirmComposition() will be - // called in keyEvent: method. - if (!handlingKeyDown_) { - renderWidgetHostView_->get_render_widget_host_impl()-> - ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), - false); - } else { - unmarkTextCalled_ = YES; - } -} - -- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)range - actualRange:(NSRangePointer)actualRange { - if (actualRange) - *actualRange = range; - NSAttributedString* str = content::TextInputClientMac::GetInstance()-> - GetAttributedSubstringFromRange( - renderWidgetHostView_->GetRenderWidgetHost(), range); - return str; -} - -- (NSRect)firstViewRectForCharacterRange:(NSRange)theRange - actualRange:(NSRangePointer)actualRange { - NSRect rect; - gfx::Rect gfxRect; - gfx::Range range(theRange); - gfx::Range actual_range; - if (!renderWidgetHostView_->GetCachedFirstRectForCharacterRange(range, - &gfxRect, &actual_range)) { - rect = content::TextInputClientMac::GetInstance()-> - GetFirstRectForRange(renderWidgetHostView_->GetRenderWidgetHost(), - range.ToNSRange()); - - if (actualRange) - *actualRange = range.ToNSRange(); - } else { - rect = NSRectFromCGRect(gfxRect.ToCGRect()); - } - - return rect; -} - -- (NSRect) screenRectFromViewRect:(NSRect)rect { - NSRect screenRect; - - int screenX, screenY; - renderWidgetHostView_->get_browser_impl()->GetClient()->GetRenderHandler()-> - GetScreenPoint(renderWidgetHostView_->get_browser_impl()->GetBrowser(), - rect.origin.x, rect.origin.y, screenX, screenY); - screenRect.origin = NSMakePoint(screenX, screenY); - screenRect.size = rect.size; - - return screenRect; -} - -- (NSRect)firstRectForCharacterRange:(NSRange)theRange - actualRange:(NSRangePointer)actualRange { - NSRect rect = [self firstViewRectForCharacterRange:theRange - actualRange:actualRange]; - - // Convert into screen coordinates for return. - rect = [self screenRectFromViewRect:rect]; - - if (rect.origin.y >= rect.size.height) - rect.origin.y -= rect.size.height; - else - rect.origin.y = 0; - - return rect; -} - -- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint { - // |thePoint| is in screen coordinates, but needs to be converted to WebKit - // coordinates (upper left origin). Scroll offsets will be taken care of in - // the renderer. - - CefRect view_rect; - renderWidgetHostView_->get_browser_impl()->GetClient()->GetRenderHandler()-> - GetViewRect(renderWidgetHostView_->get_browser_impl()->GetBrowser(), - view_rect); - - thePoint.x -= view_rect.x; - thePoint.y -= view_rect.y; - thePoint.y = view_rect.height - thePoint.y; - - NSUInteger index = content::TextInputClientMac::GetInstance()-> - GetCharacterIndexAtPoint(renderWidgetHostView_->GetRenderWidgetHost(), - gfx::Point(thePoint.x, thePoint.y)); - return index; -} - -- (void)HandleKeyEventBeforeTextInputClient:(NSEvent*)keyEvent { - DCHECK([keyEvent type] == NSKeyDown); - // Don't call this method recursively. - DCHECK(!handlingKeyDown_); - - oldHasMarkedText_ = hasMarkedText_; - handlingKeyDown_ = YES; - - // These variables might be set when handling the keyboard event. - // Clear them here so that we can know whether they have changed afterwards. - textToBeInserted_.clear(); - markedText_.clear(); - underlines_.clear(); - unmarkTextCalled_ = NO; - hasEditCommands_ = NO; - editCommands_.clear(); -} - -- (void)HandleKeyEventAfterTextInputClient:(NSEvent*)keyEvent { - handlingKeyDown_ = NO; - - // Then send keypress and/or composition related events. - // If there was a marked text or the text to be inserted is longer than 1 - // character, then we send the text by calling ConfirmComposition(). - // Otherwise, if the text to be inserted only contains 1 character, then we - // can just send a keypress event which is fabricated by changing the type of - // the keydown event, so that we can retain all necessary informations, such - // as unmodifiedText, etc. And we need to set event.skip_in_browser to true to - // prevent the browser from handling it again. - // Note that, |textToBeInserted_| is a UTF-16 string, but it's fine to only - // handle BMP characters here, as we can always insert non-BMP characters as - // text. - - if (!hasMarkedText_ && !oldHasMarkedText_ && - textToBeInserted_.length() <= 1) { - content::NativeWebKeyboardEvent event(keyEvent); - if (textToBeInserted_.length() == 1) { - event.type = blink::WebInputEvent::Type::Char; - event.text[0] = textToBeInserted_[0]; - event.text[1] = 0; - } - renderWidgetHostView_->SendKeyEvent(event); - } - - BOOL textInserted = NO; - if (textToBeInserted_.length() > - ((hasMarkedText_ || oldHasMarkedText_) ? 0u : 1u)) { - renderWidgetHostView_->get_render_widget_host_impl()->ImeConfirmComposition( - textToBeInserted_, gfx::Range::InvalidRange(), false); - textToBeInserted_ = YES; - } - - // Updates or cancels the composition. If some text has been inserted, then - // we don't need to cancel the composition explicitly. - if (hasMarkedText_ && markedText_.length()) { - // Sends the updated marked text to the renderer so it can update the - // composition node in WebKit. - // When marked text is available, |selectedRange_| will be the range being - // selected inside the marked text. - renderWidgetHostView_->get_render_widget_host_impl()->ImeSetComposition( - markedText_, underlines_, selectedRange_.location, - NSMaxRange(selectedRange_)); - } else if (oldHasMarkedText_ && !hasMarkedText_ && !textInserted) { - if (unmarkTextCalled_) { - renderWidgetHostView_->get_render_widget_host_impl()-> - ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), - false); - } else { - renderWidgetHostView_->get_render_widget_host_impl()-> - ImeCancelComposition(); - } - } -} - -- (void)cancelComposition { - if (!hasMarkedText_) - return; - - // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:] - // doesn't call any NSTextInput functions, such as setMarkedText or - // insertText. So, we need to send an IPC message to a renderer so it can - // delete the composition node. - NSInputManager *currentInputManager = [NSInputManager currentInputManager]; - [currentInputManager markedTextAbandoned:self]; - - hasMarkedText_ = NO; - // Should not call [self unmarkText] here, because it'll send unnecessary - // cancel composition IPC message to the renderer. -} - -@end diff --git a/libcef/browser/web_contents_view_osr.cc b/libcef/browser/web_contents_view_osr.cc deleted file mode 100644 index 03656c66..00000000 --- a/libcef/browser/web_contents_view_osr.cc +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2011 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 "libcef/browser/render_widget_host_view_osr.h" -#include "libcef/browser/web_contents_view_osr.h" - -#include "content/public/browser/render_widget_host.h" -#include "content/public/browser/web_contents.h" - -CefWebContentsViewOSR::CefWebContentsViewOSR( - content::WebContents* web_contents, - content::WebContentsViewDelegate* delegate) - : web_contents_(web_contents), - view_(NULL) { -} - -CefWebContentsViewOSR::~CefWebContentsViewOSR() { -} - -// Overridden from WebContentsView: - -void CefWebContentsViewOSR::CreateView(const gfx::Size& initial_size, - gfx::NativeView context) { -} - -content::RenderWidgetHostView* CefWebContentsViewOSR::CreateViewForWidget( - content::RenderWidgetHost* render_widget_host) { - if (render_widget_host->GetView()) - return render_widget_host->GetView(); - - view_ = new CefRenderWidgetHostViewOSR(render_widget_host); - return view_; -} - -content::RenderWidgetHostView* CefWebContentsViewOSR::CreateViewForPopupWidget( - content::RenderWidgetHost* render_widget_host) { - CefRenderWidgetHostViewOSR* popup_widget = - new CefRenderWidgetHostViewOSR(render_widget_host); - return popup_widget; -} - -gfx::NativeView CefWebContentsViewOSR::GetNativeView() const { - return gfx::NativeView(); -} - -gfx::NativeView CefWebContentsViewOSR::GetContentNativeView() const { - return gfx::NativeView(); -} - -gfx::NativeWindow CefWebContentsViewOSR::GetTopLevelNativeWindow() const { - return gfx::NativeWindow(); -} - - -void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect *out) const { - *out = GetViewBounds(); -} - -void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) { -} - -void CefWebContentsViewOSR::OnTabCrashed(base::TerminationStatus status, - int error_code) { - view_ = NULL; -} - -void CefWebContentsViewOSR::SizeContents(const gfx::Size& size) { -} - -void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) { - if (view_) { - CefRenderWidgetHostViewOSR* osr_view = - static_cast(view_); - osr_view->InstallTransparency(); - } -} - -void CefWebContentsViewOSR::RenderViewSwappedIn(content::RenderViewHost* host) { -} - -void CefWebContentsViewOSR::SetOverscrollControllerEnabled(bool enabled) { -} - -void CefWebContentsViewOSR::Focus() { -} - -void CefWebContentsViewOSR::SetInitialFocus() { -} - -void CefWebContentsViewOSR::StoreFocus() { -} - -void CefWebContentsViewOSR::RestoreFocus() { -} - -content::DropData* CefWebContentsViewOSR::GetDropData() const { - return NULL; -} - -gfx::Rect CefWebContentsViewOSR::GetViewBounds() const { - return view_ ? view_->GetViewBounds() : gfx::Rect(); -} - -#if defined(OS_MACOSX) -bool CefWebContentsViewOSR::IsEventTracking() const { - return false; -} - -void CefWebContentsViewOSR::CloseTabAfterEventTracking() { -} - -void CefWebContentsViewOSR::SetAllowOverlappingViews(bool overlapping) { -} - -bool CefWebContentsViewOSR::GetAllowOverlappingViews() const { - return false; -} - -void CefWebContentsViewOSR::SetOverlayView(content::WebContentsView* overlay, - const gfx::Point& offset) { -} - -void CefWebContentsViewOSR::RemoveOverlayView() { -} -#endif // defined(OS_MACOSX) - -// RenderViewHostDelegateView methods. - -void CefWebContentsViewOSR::StartDragging( - const content::DropData& drop_data, - blink::WebDragOperationsMask allowed_ops, - const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset, - const content::DragEventSourceInfo& event_info) { - // Dragging is not supported when window rendering is disabled. - web_contents_->SystemDragEnded(); -} - -void CefWebContentsViewOSR::ShowPopupMenu( - const gfx::Rect& bounds, - int item_height, - double item_font_size, - int selected_item, - const std::vector& items, - bool right_aligned, - bool allow_multiple_selection) { -} diff --git a/libcef/browser/web_contents_view_osr.h b/libcef/browser/web_contents_view_osr.h deleted file mode 100644 index 15da0958..00000000 --- a/libcef/browser/web_contents_view_osr.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2011 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. - -#ifndef CEF_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_ -#define CEF_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_ - -#include - -#include "content/port/browser/render_view_host_delegate_view.h" -#include "content/port/browser/web_contents_view_port.h" - -namespace content { -class WebContents; -class WebContentsViewDelegate; -} - -class CefBrowserHostImpl; - -// An implementation of WebContentsView for off-screen rendering. -class CefWebContentsViewOSR : public content::WebContentsViewPort, - public content::RenderViewHostDelegateView { - public: - CefWebContentsViewOSR(content::WebContents* web_contents, - content::WebContentsViewDelegate* delegate); - virtual ~CefWebContentsViewOSR(); - - // WebContentsView methods. - virtual void CreateView(const gfx::Size& initial_size, - gfx::NativeView context) OVERRIDE; - virtual content::RenderWidgetHostView* CreateViewForWidget( - content::RenderWidgetHost* render_widget_host) OVERRIDE; - virtual content::RenderWidgetHostView* CreateViewForPopupWidget( - content::RenderWidgetHost* render_widget_host); - virtual gfx::NativeView GetNativeView() const OVERRIDE; - virtual gfx::NativeView GetContentNativeView() const OVERRIDE; - virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; - virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE; - virtual void SetPageTitle(const base::string16& title) OVERRIDE; - virtual void OnTabCrashed(base::TerminationStatus status, - int error_code) OVERRIDE; - virtual void SizeContents(const gfx::Size& size) OVERRIDE; - virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE; - virtual void RenderViewSwappedIn(content::RenderViewHost* host) OVERRIDE; - virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE; - virtual void Focus() OVERRIDE; - virtual void SetInitialFocus() OVERRIDE; - virtual void StoreFocus() OVERRIDE; - virtual void RestoreFocus() OVERRIDE; - virtual content::DropData* GetDropData() const OVERRIDE; - virtual gfx::Rect GetViewBounds() const OVERRIDE; -#if defined(OS_MACOSX) - virtual bool IsEventTracking() const OVERRIDE; - virtual void CloseTabAfterEventTracking() OVERRIDE; - virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE; - virtual bool GetAllowOverlappingViews() const OVERRIDE; - virtual void SetOverlayView(content::WebContentsView* overlay, - const gfx::Point& offset) OVERRIDE; - virtual void RemoveOverlayView() OVERRIDE; -#endif // defined(OS_MACOSX) - - // RenderViewHostDelegateView methods. - virtual void StartDragging( - const content::DropData& drop_data, - blink::WebDragOperationsMask allowed_ops, - const gfx::ImageSkia& image, - const gfx::Vector2d& image_offset, - const content::DragEventSourceInfo& event_info) OVERRIDE; - virtual void ShowPopupMenu( - const gfx::Rect& bounds, - int item_height, - double item_font_size, - int selected_item, - const std::vector& items, - bool right_aligned, - bool allow_multiple_selection) OVERRIDE; - - private: - content::WebContents* web_contents_; - content::RenderWidgetHostView* view_; - - DISALLOW_COPY_AND_ASSIGN(CefWebContentsViewOSR); -}; - -#endif // CEF_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_ diff --git a/libcef/common/cef_messages.h b/libcef/common/cef_messages.h index e149796c..1feaa751 100644 --- a/libcef/common/cef_messages.h +++ b/libcef/common/cef_messages.h @@ -151,7 +151,6 @@ IPC_SYNC_MESSAGE_CONTROL0_1( IPC_STRUCT_BEGIN(CefProcessHostMsg_GetNewBrowserInfo_Params) IPC_STRUCT_MEMBER(int, browser_id) IPC_STRUCT_MEMBER(bool, is_popup) - IPC_STRUCT_MEMBER(bool, is_window_rendering_disabled) IPC_STRUCT_END() // Retrieve information about a newly created browser. diff --git a/libcef/common/main_delegate.cc b/libcef/common/main_delegate.cc index 25ed91e7..4c325712 100644 --- a/libcef/common/main_delegate.cc +++ b/libcef/common/main_delegate.cc @@ -288,13 +288,6 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) { command_line->AppendSwitchASCII(switches::kContextSafetyImplementation, base::IntToString(settings.context_safety_implementation)); } - - if (settings.windowless_rendering_enabled) { - // Must disable delegated renderer and threaded compositing for select - // popups to display correctly in a windowless browser. - command_line->AppendSwitch(switches::kDisableDelegatedRenderer); - command_line->AppendSwitch(switches::kDisableThreadedCompositing); - } } if (content_client_.application().get()) { diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index 1963ab38..fb8606a4 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -267,12 +267,10 @@ bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process, CefBrowserImpl::CefBrowserImpl(content::RenderView* render_view, int browser_id, - bool is_popup, - bool is_window_rendering_disabled) + bool is_popup) : content::RenderViewObserver(render_view), browser_id_(browser_id), is_popup_(is_popup), - is_window_rendering_disabled_(is_window_rendering_disabled), last_focused_frame_id_(webkit_glue::kInvalidFrameId) { response_manager_.reset(new CefResponseManager); } diff --git a/libcef/renderer/browser_impl.h b/libcef/renderer/browser_impl.h index 68daf5f9..95895779 100644 --- a/libcef/renderer/browser_impl.h +++ b/libcef/renderer/browser_impl.h @@ -79,8 +79,7 @@ class CefBrowserImpl : public CefBrowser, CefBrowserImpl(content::RenderView* render_view, int browser_id, - bool is_popup, - bool is_window_rendering_disabled); + bool is_popup); virtual ~CefBrowserImpl(); void LoadRequest(const CefMsg_LoadRequest_Params& params); @@ -100,9 +99,6 @@ class CefBrowserImpl : public CefBrowser, int browser_id() const { return browser_id_; } bool is_popup() const { return is_popup_; } - bool is_window_rendering_disabled() const { - return is_window_rendering_disabled_; - } content::RenderView* render_view() const { return content::RenderViewObserver::render_view(); } @@ -144,7 +140,6 @@ class CefBrowserImpl : public CefBrowser, // same browser ID. int browser_id_; bool is_popup_; - bool is_window_rendering_disabled_; // Id of the last frame that had focus. int64 last_focused_frame_id_; diff --git a/libcef/renderer/content_renderer_client.cc b/libcef/renderer/content_renderer_client.cc index 0fa32493..9ca4461f 100644 --- a/libcef/renderer/content_renderer_client.cc +++ b/libcef/renderer/content_renderer_client.cc @@ -436,90 +436,6 @@ void CefContentRendererClient::RenderViewCreated( BrowserCreated(render_view, render_view->GetMainRenderFrame()); } -bool CefContentRendererClient::OverrideCreatePlugin( - content::RenderFrame* render_frame, - blink::WebFrame* frame, - const blink::WebPluginParams& params, - blink::WebPlugin** plugin) { - CefRefPtr browser = - CefBrowserImpl::GetBrowserForMainFrame(frame->top()); - if (!browser || !browser->is_window_rendering_disabled()) - return false; - -#if defined(ENABLE_PLUGINS) - if (base::UTF16ToASCII(params.mimeType) == content::kBrowserPluginMimeType) - return false; - - content::RenderFrameImpl* render_frame_impl = - static_cast(render_frame); - - content::WebPluginInfo info; - std::string mime_type; - bool found = false; - render_frame_impl->Send( - new FrameHostMsg_GetPluginInfo( - render_frame_impl->GetRoutingID(), - params.url, - frame->top()->document().url(), - params.mimeType.utf8(), - &found, - &info, - &mime_type)); - if (!found) - return false; - - bool flash = LowerCaseEqualsASCII(mime_type, - "application/x-shockwave-flash"); - bool silverlight = StartsWithASCII(mime_type, - "application/x-silverlight", false); - - if (flash) { - // "wmode" values of "opaque" or "transparent" are allowed. - size_t size = params.attributeNames.size(); - for (size_t i = 0; i < size; ++i) { - std::string name = params.attributeNames[i].utf8(); - if (name == "wmode") { - std::string value = params.attributeValues[i].utf8(); - if (value == "opaque" || value == "transparent") - flash = false; - break; - } - } - } - - if (flash || silverlight) { - // Force Flash and Silverlight plugins to use windowless mode. - blink::WebPluginParams params_to_use = params; - params_to_use.mimeType = blink::WebString::fromUTF8(mime_type); - - size_t size = params.attributeNames.size(); - blink::WebVector new_names(size+1), - new_values(size+1); - - for (size_t i = 0; i < size; ++i) { - new_names[i] = params.attributeNames[i]; - new_values[i] = params.attributeValues[i]; - } - - if (flash) { - new_names[size] = "wmode"; - new_values[size] = "opaque"; - } else if (silverlight) { - new_names[size] = "windowless"; - new_values[size] = "true"; - } - - params_to_use.attributeNames.swap(new_names); - params_to_use.attributeValues.swap(new_values); - - *plugin = render_frame_impl->CreatePlugin(frame, info, params_to_use); - return true; - } -#endif // defined(ENABLE_PLUGINS) - - return false; -} - bool CefContentRendererClient::HandleNavigation( content::RenderFrame* render_frame, content::DocumentState* document_state, @@ -662,18 +578,8 @@ void CefContentRendererClient::BrowserCreated( if (GetBrowserForView(render_view)) return; -#if defined(OS_MACOSX) - // FIXME: It would be better if this API would be a callback from the - // WebKit layer, or if it would be exposed as an WebView instance method; the - // current implementation uses a static variable, and WebKit needs to be - // patched in order to make it work for each WebView instance - render_view->GetWebView()->setUseExternalPopupMenusThisInstance( - !params.is_window_rendering_disabled); -#endif - CefRefPtr browser = - new CefBrowserImpl(render_view, params.browser_id, params.is_popup, - params.is_window_rendering_disabled); + new CefBrowserImpl(render_view, params.browser_id, params.is_popup); browsers_.insert(std::make_pair(render_view, browser)); new CefPrerendererClient(render_view); diff --git a/libcef/renderer/content_renderer_client.h b/libcef/renderer/content_renderer_client.h index eb036271..105f1374 100644 --- a/libcef/renderer/content_renderer_client.h +++ b/libcef/renderer/content_renderer_client.h @@ -76,11 +76,6 @@ class CefContentRendererClient : public content::ContentRendererClient, virtual void RenderThreadStarted() OVERRIDE; virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE; virtual void RenderViewCreated(content::RenderView* render_view) OVERRIDE; - virtual bool OverrideCreatePlugin( - content::RenderFrame* render_frame, - blink::WebFrame* frame, - const blink::WebPluginParams& params, - blink::WebPlugin** plugin) OVERRIDE; virtual bool HandleNavigation(content::RenderFrame* render_frame, content::DocumentState* document_state, int opener_id, diff --git a/libcef_dll/cpptoc/browser_host_cpptoc.cc b/libcef_dll/cpptoc/browser_host_cpptoc.cc index 04986c14..8abde1a8 100644 --- a/libcef_dll/cpptoc/browser_host_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_host_cpptoc.cc @@ -397,78 +397,6 @@ int CEF_CALLBACK browser_host_is_mouse_cursor_change_disabled( return _retval; } -int CEF_CALLBACK browser_host_is_window_rendering_disabled( - struct _cef_browser_host_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - bool _retval = CefBrowserHostCppToC::Get(self)->IsWindowRenderingDisabled(); - - // Return type: bool - return _retval; -} - -void CEF_CALLBACK browser_host_was_resized(struct _cef_browser_host_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefBrowserHostCppToC::Get(self)->WasResized(); -} - -void CEF_CALLBACK browser_host_was_hidden(struct _cef_browser_host_t* self, - int hidden) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefBrowserHostCppToC::Get(self)->WasHidden( - hidden?true:false); -} - -void CEF_CALLBACK browser_host_notify_screen_info_changed( - struct _cef_browser_host_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefBrowserHostCppToC::Get(self)->NotifyScreenInfoChanged(); -} - -void CEF_CALLBACK browser_host_invalidate(struct _cef_browser_host_t* self, - const cef_rect_t* dirtyRect, cef_paint_element_type_t type) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: dirtyRect; type: simple_byref_const - DCHECK(dirtyRect); - if (!dirtyRect) - return; - - // Translate param: dirtyRect; type: simple_byref_const - CefRect dirtyRectVal = dirtyRect?*dirtyRect:CefRect(); - - // Execute - CefBrowserHostCppToC::Get(self)->Invalidate( - dirtyRectVal, - type); -} - void CEF_CALLBACK browser_host_send_key_event(struct _cef_browser_host_t* self, const struct _cef_key_event_t* event) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -591,48 +519,6 @@ void CEF_CALLBACK browser_host_send_capture_lost_event( CefBrowserHostCppToC::Get(self)->SendCaptureLostEvent(); } -cef_text_input_context_t CEF_CALLBACK browser_host_get_nstext_input_context( - struct _cef_browser_host_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return NULL; - - // Execute - cef_text_input_context_t _retval = CefBrowserHostCppToC::Get( - self)->GetNSTextInputContext(); - - // Return type: simple - return _retval; -} - -void CEF_CALLBACK browser_host_handle_key_event_before_text_input_client( - struct _cef_browser_host_t* self, cef_event_handle_t keyEvent) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefBrowserHostCppToC::Get(self)->HandleKeyEventBeforeTextInputClient( - keyEvent); -} - -void CEF_CALLBACK browser_host_handle_key_event_after_text_input_client( - struct _cef_browser_host_t* self, cef_event_handle_t keyEvent) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - - // Execute - CefBrowserHostCppToC::Get(self)->HandleKeyEventAfterTextInputClient( - keyEvent); -} - // CONSTRUCTOR - Do not edit by hand. @@ -659,13 +545,6 @@ CefBrowserHostCppToC::CefBrowserHostCppToC(CefBrowserHost* cls) browser_host_set_mouse_cursor_change_disabled; struct_.struct_.is_mouse_cursor_change_disabled = browser_host_is_mouse_cursor_change_disabled; - struct_.struct_.is_window_rendering_disabled = - browser_host_is_window_rendering_disabled; - struct_.struct_.was_resized = browser_host_was_resized; - struct_.struct_.was_hidden = browser_host_was_hidden; - struct_.struct_.notify_screen_info_changed = - browser_host_notify_screen_info_changed; - struct_.struct_.invalidate = browser_host_invalidate; struct_.struct_.send_key_event = browser_host_send_key_event; struct_.struct_.send_mouse_click_event = browser_host_send_mouse_click_event; struct_.struct_.send_mouse_move_event = browser_host_send_mouse_move_event; @@ -673,12 +552,6 @@ CefBrowserHostCppToC::CefBrowserHostCppToC(CefBrowserHost* cls) struct_.struct_.send_focus_event = browser_host_send_focus_event; struct_.struct_.send_capture_lost_event = browser_host_send_capture_lost_event; - struct_.struct_.get_nstext_input_context = - browser_host_get_nstext_input_context; - struct_.struct_.handle_key_event_before_text_input_client = - browser_host_handle_key_event_before_text_input_client; - struct_.struct_.handle_key_event_after_text_input_client = - browser_host_handle_key_event_after_text_input_client; } #ifndef NDEBUG diff --git a/libcef_dll/cpptoc/client_cpptoc.cc b/libcef_dll/cpptoc/client_cpptoc.cc index 9b4ac4e5..02d4bea0 100644 --- a/libcef_dll/cpptoc/client_cpptoc.cc +++ b/libcef_dll/cpptoc/client_cpptoc.cc @@ -22,7 +22,6 @@ #include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" #include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" #include "libcef_dll/cpptoc/load_handler_cpptoc.h" -#include "libcef_dll/cpptoc/render_handler_cpptoc.h" #include "libcef_dll/cpptoc/request_handler_cpptoc.h" #include "libcef_dll/ctocpp/browser_ctocpp.h" #include "libcef_dll/ctocpp/process_message_ctocpp.h" @@ -206,22 +205,6 @@ struct _cef_load_handler_t* CEF_CALLBACK client_get_load_handler( return CefLoadHandlerCppToC::Wrap(_retval); } -struct _cef_render_handler_t* CEF_CALLBACK client_get_render_handler( - struct _cef_client_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return NULL; - - // Execute - CefRefPtr _retval = CefClientCppToC::Get( - self)->GetRenderHandler(); - - // Return type: refptr_same - return CefRenderHandlerCppToC::Wrap(_retval); -} - struct _cef_request_handler_t* CEF_CALLBACK client_get_request_handler( struct _cef_client_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -281,7 +264,6 @@ CefClientCppToC::CefClientCppToC(CefClient* cls) struct_.struct_.get_keyboard_handler = client_get_keyboard_handler; struct_.struct_.get_life_span_handler = client_get_life_span_handler; struct_.struct_.get_load_handler = client_get_load_handler; - struct_.struct_.get_render_handler = client_get_render_handler; struct_.struct_.get_request_handler = client_get_request_handler; struct_.struct_.on_process_message_received = client_on_process_message_received; diff --git a/libcef_dll/cpptoc/render_handler_cpptoc.cc b/libcef_dll/cpptoc/render_handler_cpptoc.cc deleted file mode 100644 index 9d4d9df7..00000000 --- a/libcef_dll/cpptoc/render_handler_cpptoc.cc +++ /dev/null @@ -1,307 +0,0 @@ -// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. -// -// --------------------------------------------------------------------------- -// -// This file was generated by the CEF translator tool. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/cpptoc/render_handler_cpptoc.h" -#include "libcef_dll/ctocpp/browser_ctocpp.h" - - -// MEMBER FUNCTIONS - Body may be edited by hand. - -int CEF_CALLBACK render_handler_get_root_screen_rect( - struct _cef_render_handler_t* self, cef_browser_t* browser, - cef_rect_t* rect) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return 0; - // Verify param: rect; type: simple_byref - DCHECK(rect); - if (!rect) - return 0; - - // Translate param: rect; type: simple_byref - CefRect rectVal = rect?*rect:CefRect(); - - // Execute - bool _retval = CefRenderHandlerCppToC::Get(self)->GetRootScreenRect( - CefBrowserCToCpp::Wrap(browser), - rectVal); - - // Restore param: rect; type: simple_byref - if (rect) - *rect = rectVal; - - // Return type: bool - return _retval; -} - -int CEF_CALLBACK render_handler_get_view_rect( - struct _cef_render_handler_t* self, cef_browser_t* browser, - cef_rect_t* rect) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return 0; - // Verify param: rect; type: simple_byref - DCHECK(rect); - if (!rect) - return 0; - - // Translate param: rect; type: simple_byref - CefRect rectVal = rect?*rect:CefRect(); - - // Execute - bool _retval = CefRenderHandlerCppToC::Get(self)->GetViewRect( - CefBrowserCToCpp::Wrap(browser), - rectVal); - - // Restore param: rect; type: simple_byref - if (rect) - *rect = rectVal; - - // Return type: bool - return _retval; -} - -int CEF_CALLBACK render_handler_get_screen_point( - struct _cef_render_handler_t* self, cef_browser_t* browser, int viewX, - int viewY, int* screenX, int* screenY) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return 0; - // Verify param: screenX; type: simple_byref - DCHECK(screenX); - if (!screenX) - return 0; - // Verify param: screenY; type: simple_byref - DCHECK(screenY); - if (!screenY) - return 0; - - // Translate param: screenX; type: simple_byref - int screenXVal = screenX?*screenX:0; - // Translate param: screenY; type: simple_byref - int screenYVal = screenY?*screenY:0; - - // Execute - bool _retval = CefRenderHandlerCppToC::Get(self)->GetScreenPoint( - CefBrowserCToCpp::Wrap(browser), - viewX, - viewY, - screenXVal, - screenYVal); - - // Restore param: screenX; type: simple_byref - if (screenX) - *screenX = screenXVal; - // Restore param: screenY; type: simple_byref - if (screenY) - *screenY = screenYVal; - - // Return type: bool - return _retval; -} - -int CEF_CALLBACK render_handler_get_screen_info( - struct _cef_render_handler_t* self, cef_browser_t* browser, - struct _cef_screen_info_t* screen_info) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return 0; - // Verify param: screen_info; type: struct_byref - DCHECK(screen_info); - if (!screen_info) - return 0; - - // Translate param: screen_info; type: struct_byref - CefScreenInfo screen_infoObj; - if (screen_info) - screen_infoObj.AttachTo(*screen_info); - - // Execute - bool _retval = CefRenderHandlerCppToC::Get(self)->GetScreenInfo( - CefBrowserCToCpp::Wrap(browser), - screen_infoObj); - - // Restore param: screen_info; type: struct_byref - if (screen_info) - screen_infoObj.DetachTo(*screen_info); - - // Return type: bool - return _retval; -} - -void CEF_CALLBACK render_handler_on_popup_show( - struct _cef_render_handler_t* self, cef_browser_t* browser, int show) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return; - - // Execute - CefRenderHandlerCppToC::Get(self)->OnPopupShow( - CefBrowserCToCpp::Wrap(browser), - show?true:false); -} - -void CEF_CALLBACK render_handler_on_popup_size( - struct _cef_render_handler_t* self, cef_browser_t* browser, - const cef_rect_t* rect) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return; - // Verify param: rect; type: simple_byref_const - DCHECK(rect); - if (!rect) - return; - - // Translate param: rect; type: simple_byref_const - CefRect rectVal = rect?*rect:CefRect(); - - // Execute - CefRenderHandlerCppToC::Get(self)->OnPopupSize( - CefBrowserCToCpp::Wrap(browser), - rectVal); -} - -void CEF_CALLBACK render_handler_on_paint(struct _cef_render_handler_t* self, - cef_browser_t* browser, cef_paint_element_type_t type, - size_t dirtyRectsCount, cef_rect_t const* dirtyRects, const void* buffer, - int width, int height) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return; - // Verify param: dirtyRects; type: simple_vec_byref_const - DCHECK(dirtyRectsCount == 0 || dirtyRects); - if (dirtyRectsCount > 0 && !dirtyRects) - return; - // Verify param: buffer; type: simple_byaddr - DCHECK(buffer); - if (!buffer) - return; - - // Translate param: dirtyRects; type: simple_vec_byref_const - std::vector dirtyRectsList; - if (dirtyRectsCount > 0) { - for (size_t i = 0; i < dirtyRectsCount; ++i) { - dirtyRectsList.push_back(dirtyRects[i]); - } - } - - // Execute - CefRenderHandlerCppToC::Get(self)->OnPaint( - CefBrowserCToCpp::Wrap(browser), - type, - dirtyRectsList, - buffer, - width, - height); -} - -void CEF_CALLBACK render_handler_on_cursor_change( - struct _cef_render_handler_t* self, cef_browser_t* browser, - cef_cursor_handle_t cursor) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return; - - // Execute - CefRenderHandlerCppToC::Get(self)->OnCursorChange( - CefBrowserCToCpp::Wrap(browser), - cursor); -} - -void CEF_CALLBACK render_handler_on_scroll_offset_changed( - struct _cef_render_handler_t* self, cef_browser_t* browser) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: browser; type: refptr_diff - DCHECK(browser); - if (!browser) - return; - - // Execute - CefRenderHandlerCppToC::Get(self)->OnScrollOffsetChanged( - CefBrowserCToCpp::Wrap(browser)); -} - - -// CONSTRUCTOR - Do not edit by hand. - -CefRenderHandlerCppToC::CefRenderHandlerCppToC(CefRenderHandler* cls) - : CefCppToC( - cls) { - struct_.struct_.get_root_screen_rect = render_handler_get_root_screen_rect; - struct_.struct_.get_view_rect = render_handler_get_view_rect; - struct_.struct_.get_screen_point = render_handler_get_screen_point; - struct_.struct_.get_screen_info = render_handler_get_screen_info; - struct_.struct_.on_popup_show = render_handler_on_popup_show; - struct_.struct_.on_popup_size = render_handler_on_popup_size; - struct_.struct_.on_paint = render_handler_on_paint; - struct_.struct_.on_cursor_change = render_handler_on_cursor_change; - struct_.struct_.on_scroll_offset_changed = - render_handler_on_scroll_offset_changed; -} - -#ifndef NDEBUG -template<> long CefCppToC::DebugObjCt = 0; -#endif - diff --git a/libcef_dll/cpptoc/render_handler_cpptoc.h b/libcef_dll/cpptoc/render_handler_cpptoc.h deleted file mode 100644 index 3c0498af..00000000 --- a/libcef_dll/cpptoc/render_handler_cpptoc.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. -// -// --------------------------------------------------------------------------- -// -// This file was generated by the CEF translator tool. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#ifndef CEF_LIBCEF_DLL_CPPTOC_RENDER_HANDLER_CPPTOC_H_ -#define CEF_LIBCEF_DLL_CPPTOC_RENDER_HANDLER_CPPTOC_H_ -#pragma once - -#ifndef USING_CEF_SHARED -#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") -#else // USING_CEF_SHARED - -#include "include/cef_render_handler.h" -#include "include/capi/cef_render_handler_capi.h" -#include "libcef_dll/cpptoc/cpptoc.h" - -// Wrap a C++ class with a C structure. -// This class may be instantiated and accessed wrapper-side only. -class CefRenderHandlerCppToC - : public CefCppToC { - public: - explicit CefRenderHandlerCppToC(CefRenderHandler* cls); - virtual ~CefRenderHandlerCppToC() {} -}; - -#endif // USING_CEF_SHARED -#endif // CEF_LIBCEF_DLL_CPPTOC_RENDER_HANDLER_CPPTOC_H_ - diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.cc b/libcef_dll/ctocpp/browser_host_ctocpp.cc index 6a4f73eb..8f208c0b 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_host_ctocpp.cc @@ -319,63 +319,6 @@ bool CefBrowserHostCToCpp::IsMouseCursorChangeDisabled() { return _retval?true:false; } -bool CefBrowserHostCToCpp::IsWindowRenderingDisabled() { - if (CEF_MEMBER_MISSING(struct_, is_window_rendering_disabled)) - return false; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = struct_->is_window_rendering_disabled(struct_); - - // Return type: bool - return _retval?true:false; -} - -void CefBrowserHostCToCpp::WasResized() { - if (CEF_MEMBER_MISSING(struct_, was_resized)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - struct_->was_resized(struct_); -} - -void CefBrowserHostCToCpp::WasHidden(bool hidden) { - if (CEF_MEMBER_MISSING(struct_, was_hidden)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - struct_->was_hidden(struct_, - hidden); -} - -void CefBrowserHostCToCpp::NotifyScreenInfoChanged() { - if (CEF_MEMBER_MISSING(struct_, notify_screen_info_changed)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - struct_->notify_screen_info_changed(struct_); -} - -void CefBrowserHostCToCpp::Invalidate(const CefRect& dirtyRect, - PaintElementType type) { - if (CEF_MEMBER_MISSING(struct_, invalidate)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - struct_->invalidate(struct_, - &dirtyRect, - type); -} - void CefBrowserHostCToCpp::SendKeyEvent(const CefKeyEvent& event) { if (CEF_MEMBER_MISSING(struct_, send_key_event)) return; @@ -450,43 +393,6 @@ void CefBrowserHostCToCpp::SendCaptureLostEvent() { struct_->send_capture_lost_event(struct_); } -CefTextInputContext CefBrowserHostCToCpp::GetNSTextInputContext() { - if (CEF_MEMBER_MISSING(struct_, get_nstext_input_context)) - return NULL; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_text_input_context_t _retval = struct_->get_nstext_input_context(struct_); - - // Return type: simple - return _retval; -} - -void CefBrowserHostCToCpp::HandleKeyEventBeforeTextInputClient( - CefEventHandle keyEvent) { - if (CEF_MEMBER_MISSING(struct_, handle_key_event_before_text_input_client)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - struct_->handle_key_event_before_text_input_client(struct_, - keyEvent); -} - -void CefBrowserHostCToCpp::HandleKeyEventAfterTextInputClient( - CefEventHandle keyEvent) { - if (CEF_MEMBER_MISSING(struct_, handle_key_event_after_text_input_client)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - struct_->handle_key_event_after_text_input_client(struct_, - keyEvent); -} - #ifndef NDEBUG template<> long CefCToCpp CefClientCToCpp::GetLoadHandler() { return CefLoadHandlerCToCpp::Wrap(_retval); } -CefRefPtr CefClientCToCpp::GetRenderHandler() { - if (CEF_MEMBER_MISSING(struct_, get_render_handler)) - return NULL; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_render_handler_t* _retval = struct_->get_render_handler(struct_); - - // Return type: refptr_same - return CefRenderHandlerCToCpp::Wrap(_retval); -} - CefRefPtr CefClientCToCpp::GetRequestHandler() { if (CEF_MEMBER_MISSING(struct_, get_request_handler)) return NULL; diff --git a/libcef_dll/ctocpp/client_ctocpp.h b/libcef_dll/ctocpp/client_ctocpp.h index e793c39f..f017223c 100644 --- a/libcef_dll/ctocpp/client_ctocpp.h +++ b/libcef_dll/ctocpp/client_ctocpp.h @@ -43,7 +43,6 @@ class CefClientCToCpp virtual CefRefPtr GetKeyboardHandler() OVERRIDE; virtual CefRefPtr GetLifeSpanHandler() OVERRIDE; virtual CefRefPtr GetLoadHandler() OVERRIDE; - virtual CefRefPtr GetRenderHandler() OVERRIDE; virtual CefRefPtr GetRequestHandler() OVERRIDE; virtual bool OnProcessMessageReceived(CefRefPtr browser, CefProcessId source_process, diff --git a/libcef_dll/ctocpp/render_handler_ctocpp.cc b/libcef_dll/ctocpp/render_handler_ctocpp.cc deleted file mode 100644 index 276bff98..00000000 --- a/libcef_dll/ctocpp/render_handler_ctocpp.cc +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. -// -// --------------------------------------------------------------------------- -// -// This file was generated by the CEF translator tool. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#include "libcef_dll/cpptoc/browser_cpptoc.h" -#include "libcef_dll/ctocpp/render_handler_ctocpp.h" - - -// VIRTUAL METHODS - Body may be edited by hand. - -bool CefRenderHandlerCToCpp::GetRootScreenRect(CefRefPtr browser, - CefRect& rect) { - if (CEF_MEMBER_MISSING(struct_, get_root_screen_rect)) - return false; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return false; - - // Execute - int _retval = struct_->get_root_screen_rect(struct_, - CefBrowserCppToC::Wrap(browser), - &rect); - - // Return type: bool - return _retval?true:false; -} - -bool CefRenderHandlerCToCpp::GetViewRect(CefRefPtr browser, - CefRect& rect) { - if (CEF_MEMBER_MISSING(struct_, get_view_rect)) - return false; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return false; - - // Execute - int _retval = struct_->get_view_rect(struct_, - CefBrowserCppToC::Wrap(browser), - &rect); - - // Return type: bool - return _retval?true:false; -} - -bool CefRenderHandlerCToCpp::GetScreenPoint(CefRefPtr browser, - int viewX, int viewY, int& screenX, int& screenY) { - if (CEF_MEMBER_MISSING(struct_, get_screen_point)) - return false; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return false; - - // Execute - int _retval = struct_->get_screen_point(struct_, - CefBrowserCppToC::Wrap(browser), - viewX, - viewY, - &screenX, - &screenY); - - // Return type: bool - return _retval?true:false; -} - -bool CefRenderHandlerCToCpp::GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) { - if (CEF_MEMBER_MISSING(struct_, get_screen_info)) - return false; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return false; - - // Execute - int _retval = struct_->get_screen_info(struct_, - CefBrowserCppToC::Wrap(browser), - &screen_info); - - // Return type: bool - return _retval?true:false; -} - -void CefRenderHandlerCToCpp::OnPopupShow(CefRefPtr browser, - bool show) { - if (CEF_MEMBER_MISSING(struct_, on_popup_show)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return; - - // Execute - struct_->on_popup_show(struct_, - CefBrowserCppToC::Wrap(browser), - show); -} - -void CefRenderHandlerCToCpp::OnPopupSize(CefRefPtr browser, - const CefRect& rect) { - if (CEF_MEMBER_MISSING(struct_, on_popup_size)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return; - - // Execute - struct_->on_popup_size(struct_, - CefBrowserCppToC::Wrap(browser), - &rect); -} - -void CefRenderHandlerCToCpp::OnPaint(CefRefPtr browser, - PaintElementType type, const RectList& dirtyRects, const void* buffer, - int width, int height) { - if (CEF_MEMBER_MISSING(struct_, on_paint)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return; - // Verify param: buffer; type: simple_byaddr - DCHECK(buffer); - if (!buffer) - return; - - // Translate param: dirtyRects; type: simple_vec_byref_const - const size_t dirtyRectsCount = dirtyRects.size(); - cef_rect_t* dirtyRectsList = NULL; - if (dirtyRectsCount > 0) { - dirtyRectsList = new cef_rect_t[dirtyRectsCount]; - DCHECK(dirtyRectsList); - if (dirtyRectsList) { - for (size_t i = 0; i < dirtyRectsCount; ++i) { - dirtyRectsList[i] = dirtyRects[i]; - } - } - } - - // Execute - struct_->on_paint(struct_, - CefBrowserCppToC::Wrap(browser), - type, - dirtyRectsCount, - dirtyRectsList, - buffer, - width, - height); - - // Restore param:dirtyRects; type: simple_vec_byref_const - if (dirtyRectsList) - delete [] dirtyRectsList; -} - -void CefRenderHandlerCToCpp::OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) { - if (CEF_MEMBER_MISSING(struct_, on_cursor_change)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return; - - // Execute - struct_->on_cursor_change(struct_, - CefBrowserCppToC::Wrap(browser), - cursor); -} - -void CefRenderHandlerCToCpp::OnScrollOffsetChanged( - CefRefPtr browser) { - if (CEF_MEMBER_MISSING(struct_, on_scroll_offset_changed)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: browser; type: refptr_diff - DCHECK(browser.get()); - if (!browser.get()) - return; - - // Execute - struct_->on_scroll_offset_changed(struct_, - CefBrowserCppToC::Wrap(browser)); -} - - -#ifndef NDEBUG -template<> long CefCToCpp::DebugObjCt = 0; -#endif - diff --git a/libcef_dll/ctocpp/render_handler_ctocpp.h b/libcef_dll/ctocpp/render_handler_ctocpp.h deleted file mode 100644 index 2025a04b..00000000 --- a/libcef_dll/ctocpp/render_handler_ctocpp.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. -// -// --------------------------------------------------------------------------- -// -// This file was generated by the CEF translator tool. If making changes by -// hand only do so within the body of existing method and function -// implementations. See the translator.README.txt file in the tools directory -// for more information. -// - -#ifndef CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ -#define CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ -#pragma once - -#ifndef BUILDING_CEF_SHARED -#pragma message("Warning: "__FILE__" may be accessed DLL-side only") -#else // BUILDING_CEF_SHARED - -#include "include/cef_render_handler.h" -#include "include/capi/cef_render_handler_capi.h" -#include "libcef_dll/ctocpp/ctocpp.h" - -// Wrap a C structure with a C++ class. -// This class may be instantiated and accessed DLL-side only. -class CefRenderHandlerCToCpp - : public CefCToCpp { - public: - explicit CefRenderHandlerCToCpp(cef_render_handler_t* str) - : CefCToCpp(str) {} - virtual ~CefRenderHandlerCToCpp() {} - - // CefRenderHandler methods - virtual bool GetRootScreenRect(CefRefPtr browser, - CefRect& rect) OVERRIDE; - virtual bool GetViewRect(CefRefPtr browser, - CefRect& rect) OVERRIDE; - virtual bool GetScreenPoint(CefRefPtr browser, int viewX, - int viewY, int& screenX, int& screenY) OVERRIDE; - virtual bool GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) OVERRIDE; - virtual void OnPopupShow(CefRefPtr browser, bool show) OVERRIDE; - virtual void OnPopupSize(CefRefPtr browser, - const CefRect& rect) OVERRIDE; - virtual void OnPaint(CefRefPtr browser, PaintElementType type, - const RectList& dirtyRects, const void* buffer, int width, - int height) OVERRIDE; - virtual void OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) OVERRIDE; - virtual void OnScrollOffsetChanged(CefRefPtr browser) OVERRIDE; -}; - -#endif // BUILDING_CEF_SHARED -#endif // CEF_LIBCEF_DLL_CTOCPP_RENDER_HANDLER_CTOCPP_H_ - diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index 960d68a8..f71c7f11 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -89,7 +89,6 @@ #include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" #include "libcef_dll/ctocpp/load_handler_ctocpp.h" #include "libcef_dll/ctocpp/read_handler_ctocpp.h" -#include "libcef_dll/ctocpp/render_handler_ctocpp.h" #include "libcef_dll/ctocpp/render_process_handler_ctocpp.h" #include "libcef_dll/ctocpp/request_handler_ctocpp.h" #include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h" @@ -218,7 +217,6 @@ CEF_EXPORT void cef_shutdown() { DCHECK_EQ(CefProcessMessageCppToC::DebugObjCt, 0); DCHECK_EQ(CefQuotaCallbackCppToC::DebugObjCt, 0); DCHECK_EQ(CefReadHandlerCToCpp::DebugObjCt, 0); - DCHECK_EQ(CefRenderHandlerCToCpp::DebugObjCt, 0); DCHECK_EQ(CefRenderProcessHandlerCToCpp::DebugObjCt, 0); DCHECK_EQ(CefRequestHandlerCToCpp::DebugObjCt, 0); DCHECK_EQ(CefResourceBundleHandlerCToCpp::DebugObjCt, 0); diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index 94f69577..21a3de52 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -53,7 +53,6 @@ #include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" #include "libcef_dll/cpptoc/load_handler_cpptoc.h" #include "libcef_dll/cpptoc/read_handler_cpptoc.h" -#include "libcef_dll/cpptoc/render_handler_cpptoc.h" #include "libcef_dll/cpptoc/render_process_handler_cpptoc.h" #include "libcef_dll/cpptoc/request_handler_cpptoc.h" #include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h" @@ -210,7 +209,6 @@ CEF_GLOBAL void CefShutdown() { DCHECK_EQ(CefProcessMessageCToCpp::DebugObjCt, 0); DCHECK_EQ(CefQuotaCallbackCToCpp::DebugObjCt, 0); DCHECK_EQ(CefReadHandlerCppToC::DebugObjCt, 0); - DCHECK_EQ(CefRenderHandlerCppToC::DebugObjCt, 0); DCHECK_EQ(CefRenderProcessHandlerCppToC::DebugObjCt, 0); DCHECK_EQ(CefRequestHandlerCppToC::DebugObjCt, 0); DCHECK_EQ(CefResourceBundleHandlerCppToC::DebugObjCt, 0); diff --git a/patch/patch.cfg b/patch/patch.cfg index 28387165..02d0ec5f 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -43,11 +43,6 @@ patches = [ 'name': 'gyp_331', 'path': '../tools/gyp/pylib/', }, - { - # Enable popups in offscreen rendering on OS X. - 'name': 'webkit_popups', - 'path': '../third_party/WebKit/', - }, { # Fix export of UnderlayOpenGLHostingWindow for 64-bit OS X builds. # http://code.google.com/p/chromiumembedded/issues/detail?id=1051 diff --git a/patch/patches/webkit_popups.patch b/patch/patches/webkit_popups.patch deleted file mode 100644 index 3e83dbc9..00000000 --- a/patch/patches/webkit_popups.patch +++ /dev/null @@ -1,76 +0,0 @@ -Index: public/web/WebView.h -=================================================================== ---- public/web/WebView.h (revision 170525) -+++ public/web/WebView.h (working copy) -@@ -416,6 +416,7 @@ - - // Sets whether select popup menus should be rendered by the browser. - BLINK_EXPORT static void setUseExternalPopupMenus(bool); -+ virtual void setUseExternalPopupMenusThisInstance(bool) = 0; - - // Hides any popup (suggestions, selects...) that might be showing. - virtual void hidePopups() = 0; -Index: Source/web/ChromeClientImpl.cpp -=================================================================== ---- Source/web/ChromeClientImpl.cpp (revision 170525) -+++ Source/web/ChromeClientImpl.cpp (working copy) -@@ -755,7 +755,7 @@ - - PassRefPtr ChromeClientImpl::createPopupMenu(LocalFrame& frame, PopupMenuClient* client) const - { -- if (WebViewImpl::useExternalPopupMenus()) -+ if (m_webView->useExternalPopupMenus()) - return adoptRef(new ExternalPopupMenu(frame, client, *m_webView)); - - return adoptRef(new PopupMenuChromium(frame, client)); -Index: Source/web/WebViewImpl.cpp -=================================================================== ---- Source/web/WebViewImpl.cpp (revision 170525) -+++ Source/web/WebViewImpl.cpp (working copy) -@@ -339,6 +339,7 @@ - , m_fakePageScaleAnimationPageScaleFactor(0) - , m_fakePageScaleAnimationUseAnchor(false) - , m_contextMenuAllowed(false) -+ , m_shouldUseExternalPopupMenus(shouldUseExternalPopupMenus) - , m_doingDragAndDrop(false) - , m_ignoreInputEvents(false) - , m_compositorDeviceScaleFactorOverride(0) -@@ -3488,9 +3489,14 @@ - updateLayerTreeViewport(); - } - -+void WebViewImpl::setUseExternalPopupMenusThisInstance(bool useExternalPopupMenus) -+{ -+ m_shouldUseExternalPopupMenus = useExternalPopupMenus; -+} -+ - bool WebViewImpl::useExternalPopupMenus() - { -- return shouldUseExternalPopupMenus; -+ return m_shouldUseExternalPopupMenus; - } - - void WebViewImpl::startDragging(LocalFrame* frame, -Index: Source/web/WebViewImpl.h -=================================================================== ---- Source/web/WebViewImpl.h (revision 170525) -+++ Source/web/WebViewImpl.h (working copy) -@@ -390,7 +390,8 @@ - - // Returns true if popup menus should be rendered by the browser, false if - // they should be rendered by WebKit (which is the default). -- static bool useExternalPopupMenus(); -+ void setUseExternalPopupMenusThisInstance(bool); -+ bool useExternalPopupMenus(); - - bool contextMenuAllowed() const - { -@@ -668,6 +669,8 @@ - - bool m_contextMenuAllowed; - -+ bool m_shouldUseExternalPopupMenus; -+ - bool m_doingDragAndDrop; - - bool m_ignoreInputEvents; diff --git a/tests/cefclient/cefclient.cpp b/tests/cefclient/cefclient.cpp index 1f4e37b5..203e1377 100644 --- a/tests/cefclient/cefclient.cpp +++ b/tests/cefclient/cefclient.cpp @@ -62,17 +62,6 @@ void AppGetSettings(CefSettings& settings) { CefString(&settings.cache_path) = g_command_line->GetSwitchValue(cefclient::kCachePath); - - if (g_command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled)) - settings.windowless_rendering_enabled = true; -} - -bool AppIsOffScreenRenderingEnabled() { - ASSERT(g_command_line.get()); - if (!g_command_line.get()) - return false; - - return g_command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled); } void RunGetSourceTest(CefRefPtr browser) { diff --git a/tests/cefclient/cefclient.h b/tests/cefclient/cefclient.h index d04046dd..1978df66 100644 --- a/tests/cefclient/cefclient.h +++ b/tests/cefclient/cefclient.h @@ -32,10 +32,6 @@ CefRefPtr AppGetCommandLine(); // Returns the application settings based on command line arguments. void AppGetSettings(CefSettings& settings); -// Returns true if off-screen rendering is enabled via the command line -// argument. -bool AppIsOffScreenRenderingEnabled(); - // Quit the application message loop. void AppQuitMessageLoop(); diff --git a/tests/cefclient/cefclient.rc b/tests/cefclient/cefclient.rc index 18b8c4f8..a645797c 100644 --- a/tests/cefclient/cefclient.rc +++ b/tests/cefclient/cefclient.rc @@ -33,7 +33,6 @@ IDS_DIALOGS BINARY "res\\dialogs.html" IDS_DOMACCESS BINARY "res\\domaccess.html" IDS_LOCALSTORAGE BINARY "res\\localstorage.html" IDS_LOGO BINARY "res\\logo.png" -IDS_OSRTEST BINARY "res\\osr_test.html" IDS_OTHER_TESTS BINARY "res\\other_tests.html" IDS_PERFORMANCE BINARY "res\\performance.html" IDS_PERFORMANCE2 BINARY "res\\performance2.html" diff --git a/tests/cefclient/cefclient_gtk.cpp b/tests/cefclient/cefclient_gtk.cpp index 47bc608c..53c6be6b 100644 --- a/tests/cefclient/cefclient_gtk.cpp +++ b/tests/cefclient/cefclient_gtk.cpp @@ -16,7 +16,6 @@ #include "include/cef_browser.h" #include "include/cef_frame.h" #include "include/cef_runnable.h" -#include "cefclient/cefclient_osr_widget_gtk.h" #include "cefclient/client_handler.h" #include "cefclient/client_switches.h" #include "cefclient/scheme_test.h" @@ -27,15 +26,6 @@ char szWorkingDir[512]; // The current working directory // The global ClientHandler reference. extern CefRefPtr g_handler; -class MainBrowserProvider : public OSRBrowserProvider { - virtual CefRefPtr GetBrowser() { - if (g_handler.get()) - return g_handler->GetBrowser(); - - return NULL; - } -} g_main_browser_provider; - void destroy(GtkWidget* widget, gpointer data) { // Quitting CEF is handled in ClientHandler::OnBeforeClose(). } @@ -353,18 +343,7 @@ int main(int argc, char* argv[]) { CefWindowInfo window_info; CefBrowserSettings browserSettings; - if (AppIsOffScreenRenderingEnabled()) { - CefRefPtr cmd_line = AppGetCommandLine(); - bool transparent = - cmd_line->HasSwitch(cefclient::kTransparentPaintingEnabled); - - CefRefPtr osr_window = - OSRWindow::Create(&g_main_browser_provider, transparent, vbox); - window_info.SetAsWindowless(osr_window->GetWindowHandle(), transparent); - g_handler->SetOSRHandler(osr_window.get()); - } else { - window_info.SetAsChild(vbox); - } + window_info.SetAsChild(vbox); CefBrowserHost::CreateBrowserSync( window_info, g_handler.get(), diff --git a/tests/cefclient/cefclient_mac.mm b/tests/cefclient/cefclient_mac.mm index 1602951d..ae3b90f2 100644 --- a/tests/cefclient/cefclient_mac.mm +++ b/tests/cefclient/cefclient_mac.mm @@ -11,7 +11,6 @@ #include "include/cef_browser.h" #include "include/cef_frame.h" #include "include/cef_runnable.h" -#include "cefclient/cefclient_osr_widget_mac.h" #include "cefclient/client_handler.h" #include "cefclient/client_switches.h" #include "cefclient/resource_util.h" @@ -21,15 +20,6 @@ // The global ClientHandler reference. extern CefRefPtr g_handler; -class MainBrowserProvider : public OSRBrowserProvider { - virtual CefRefPtr GetBrowser() { - if (g_handler.get()) - return g_handler->GetBrowser(); - - return NULL; - } -} g_main_browser_provider; - char szWorkingDir[512]; // The current working directory // Sizes for URL bar layout @@ -393,20 +383,8 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { CefWindowInfo window_info; CefBrowserSettings settings; - if (AppIsOffScreenRenderingEnabled()) { - CefRefPtr cmd_line = AppGetCommandLine(); - bool transparent = - cmd_line->HasSwitch(cefclient::kTransparentPaintingEnabled); - - CefRefPtr osr_window = - OSRWindow::Create(&g_main_browser_provider, transparent, contentView, - CefRect(0, 0, kWindowWidth, kWindowHeight)); - window_info.SetAsWindowless(osr_window->GetWindowHandle(), transparent); - g_handler->SetOSRHandler(osr_window->GetRenderHandler().get()); - } else { - // Initialize window info to the defaults for a child window. - window_info.SetAsChild(contentView, 0, 0, kWindowWidth, kWindowHeight); - } + // Initialize window info to the defaults for a child window. + window_info.SetAsChild(contentView, 0, 0, kWindowWidth, kWindowHeight); CefBrowserHost::CreateBrowser(window_info, g_handler.get(), g_handler->GetStartupURL(), settings, NULL); diff --git a/tests/cefclient/cefclient_osr_widget_gtk.cpp b/tests/cefclient/cefclient_osr_widget_gtk.cpp deleted file mode 100644 index 2320cb38..00000000 --- a/tests/cefclient/cefclient_osr_widget_gtk.cpp +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework 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 "cefclient/cefclient_osr_widget_gtk.h" - -// This value is defined in build/common.gypi and must be undefined here -// in order for gtkglext to compile. -#undef GTK_DISABLE_SINGLE_INCLUDES - -#include -#include -#include -#include -#include -#include - -#include "include/cef_runnable.h" -#include "cefclient/util.h" - -namespace { - -gint glarea_size_allocation(GtkWidget* widget, - GtkAllocation* allocation, - OSRWindow* window) { - CefRefPtr host = window->GetBrowserHost(); - host->WasResized(); - return TRUE; -} - -int get_cef_state_modifiers(guint state) { - int modifiers = 0; - if (state & GDK_SHIFT_MASK) - modifiers |= EVENTFLAG_SHIFT_DOWN; - if (state & GDK_LOCK_MASK) - modifiers |= EVENTFLAG_CAPS_LOCK_ON; - if (state & GDK_CONTROL_MASK) - modifiers |= EVENTFLAG_CONTROL_DOWN; - if (state & GDK_MOD1_MASK) - modifiers |= EVENTFLAG_ALT_DOWN; - if (state & GDK_BUTTON1_MASK) - modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON; - if (state & GDK_BUTTON2_MASK) - modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON; - if (state & GDK_BUTTON3_MASK) - modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON; - return modifiers; -} - -gint glarea_click_event(GtkWidget* widget, - GdkEventButton* event, - OSRWindow* window) { - CefRefPtr host = window->GetBrowserHost(); - - CefBrowserHost::MouseButtonType button_type = MBT_LEFT; - switch (event->button) { - case 1: - break; - case 2: - button_type = MBT_MIDDLE; - break; - case 3: - button_type = MBT_RIGHT; - break; - default: - // Other mouse buttons are not handled here. - return FALSE; - } - - CefMouseEvent mouse_event; - mouse_event.x = event->x; - mouse_event.y = event->y; - window->ApplyPopupOffset(mouse_event.x, mouse_event.y); - mouse_event.modifiers = get_cef_state_modifiers(event->state); - - bool mouse_up = (event->type == GDK_BUTTON_RELEASE); - if (!mouse_up) - gtk_widget_grab_focus(widget); - - int click_count = 1; - switch (event->type) { - case GDK_2BUTTON_PRESS: - click_count = 2; - break; - case GDK_3BUTTON_PRESS: - click_count = 3; - break; - default: - break; - } - - host->SendMouseClickEvent(mouse_event, button_type, mouse_up, click_count); - return TRUE; -} - -gint glarea_move_event(GtkWidget* widget, - GdkEventMotion* event, - OSRWindow* window) { - gint x, y; - GdkModifierType state; - - if (event->is_hint) { - gdk_window_get_pointer(event->window, &x, &y, &state); - } else { - x = (gint)event->x; - y = (gint)event->y; - state = (GdkModifierType)event->state; - } - - CefRefPtr host = window->GetBrowserHost(); - - CefMouseEvent mouse_event; - mouse_event.x = x; - mouse_event.y = y; - window->ApplyPopupOffset(mouse_event.x, mouse_event.y); - mouse_event.modifiers = get_cef_state_modifiers(state); - - bool mouse_leave = (event->type == GDK_LEAVE_NOTIFY); - - host->SendMouseMoveEvent(mouse_event, mouse_leave); - return TRUE; -} - -gint glarea_scroll_event(GtkWidget* widget, - GdkEventScroll* event, - OSRWindow* window) { - CefRefPtr host = window->GetBrowserHost(); - - CefMouseEvent mouse_event; - mouse_event.x = event->x; - mouse_event.y = event->y; - window->ApplyPopupOffset(mouse_event.x, mouse_event.y); - mouse_event.modifiers = get_cef_state_modifiers(event->state); - - static const int scrollbarPixelsPerGtkTick = 40; - int deltaX = 0; - int deltaY = 0; - switch (event->direction) { - case GDK_SCROLL_UP: - deltaY = scrollbarPixelsPerGtkTick; - break; - case GDK_SCROLL_DOWN: - deltaY = -scrollbarPixelsPerGtkTick; - break; - case GDK_SCROLL_LEFT: - deltaX = scrollbarPixelsPerGtkTick; - break; - case GDK_SCROLL_RIGHT: - deltaX = -scrollbarPixelsPerGtkTick; - break; - } - - host->SendMouseWheelEvent(mouse_event, deltaX, deltaY); - return TRUE; -} - -gint glarea_key_event(GtkWidget* widget, - GdkEventKey* event, - OSRWindow* window) { - CefRefPtr host = window->GetBrowserHost(); - - CefKeyEvent key_event; - key_event.native_key_code = event->keyval; - key_event.modifiers = get_cef_state_modifiers(event->state); - - if (event->type == GDK_KEY_PRESS) { - key_event.type = KEYEVENT_RAWKEYDOWN; - host->SendKeyEvent(key_event); - } else { - // Need to send both KEYUP and CHAR events. - key_event.type = KEYEVENT_KEYUP; - host->SendKeyEvent(key_event); - key_event.type = KEYEVENT_CHAR; - host->SendKeyEvent(key_event); - } - - return TRUE; -} - -gint glarea_focus_event(GtkWidget* widget, - GdkEventFocus* event, - OSRWindow* window) { - CefRefPtr host = window->GetBrowserHost(); - host->SendFocusEvent(event->in == TRUE); - return TRUE; -} - -void widget_get_rect_in_screen(GtkWidget* widget, GdkRectangle* r) { - gint x, y, w, h; - GdkRectangle extents; - - GdkWindow* window = gtk_widget_get_parent_window(widget); - - // Get parent's left-top screen coordinates. - gdk_window_get_root_origin(window, &x, &y); - // Get parent's width and height. - gdk_drawable_get_size(window, &w, &h); - // Get parent's extents including decorations. - gdk_window_get_frame_extents(window, &extents); - - // X and Y calculations assume that left, right and bottom border sizes are - // all the same. - const gint border = (extents.width - w) / 2; - r->x = x + border + widget->allocation.x; - r->y = y + (extents.height - h) - border + widget->allocation.y; - r->width = widget->allocation.width; - r->height = widget->allocation.height; -} - -class ScopedGLContext { - public: - ScopedGLContext(GtkWidget* widget, bool swap_buffers) - : swap_buffers_(swap_buffers) { - GdkGLContext* glcontext = gtk_widget_get_gl_context(widget); - gldrawable_ = gtk_widget_get_gl_drawable(widget); - is_valid_ = gdk_gl_drawable_gl_begin(gldrawable_, glcontext); - } - - virtual ~ScopedGLContext() { - if (is_valid_) { - gdk_gl_drawable_gl_end(gldrawable_); - - if(swap_buffers_) { - if (gdk_gl_drawable_is_double_buffered(gldrawable_)) - gdk_gl_drawable_swap_buffers(gldrawable_); - else - glFlush(); - } - } - } - - bool IsValid() const { return is_valid_; } - - private: - bool swap_buffers_; - GdkGLContext* glcontext_; - GdkGLDrawable* gldrawable_; - bool is_valid_; -}; - -} // namespace - -// static -CefRefPtr OSRWindow::Create(OSRBrowserProvider* browser_provider, - bool transparent, - CefWindowHandle parentView) { - ASSERT(browser_provider); - if (!browser_provider) - return NULL; - - return new OSRWindow(browser_provider, transparent, parentView); -} - -// static -CefRefPtr OSRWindow::From( - CefRefPtr renderHandler) { - return static_cast(renderHandler.get()); -} - -void OSRWindow::OnBeforeClose(CefRefPtr browser) { - // Disconnect all signal handlers that reference |this|. - g_signal_handlers_disconnect_matched(glarea_, G_SIGNAL_MATCH_DATA, 0, 0, - NULL, NULL, this); - - DisableGL(); -} - -bool OSRWindow::GetViewRect(CefRefPtr browser, - CefRect& rect) { - if (!glarea_) - return false; - - // The simulated screen and view rectangle are the same. This is necessary - // for popup menus to be located and sized inside the view. - rect.x = rect.y = 0; - rect.width = glarea_->allocation.width; - rect.height = glarea_->allocation.height; - return true; -} - -bool OSRWindow::GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) { - GdkRectangle screen_rect; - widget_get_rect_in_screen(glarea_, &screen_rect); - screenX = screen_rect.x + viewX; - screenY = screen_rect.y + viewY; - return true; -} - -void OSRWindow::OnPopupShow(CefRefPtr browser, - bool show) { - if (!show) { - CefRect dirty_rect = renderer_.popup_rect(); - renderer_.ClearPopupRects(); - browser->GetHost()->Invalidate(dirty_rect, PET_VIEW); - } - renderer_.OnPopupShow(browser, show); -} - -void OSRWindow::OnPopupSize(CefRefPtr browser, - const CefRect& rect) { - renderer_.OnPopupSize(browser, rect); -} - -void OSRWindow::OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, int height) { - if (painting_popup_) { - renderer_.OnPaint(browser, type, dirtyRects, buffer, width, height); - return; - } - - if (!gl_enabled_) - EnableGL(); - - ScopedGLContext scoped_gl_context(glarea_, true); - if (!scoped_gl_context.IsValid()) - return; - - renderer_.OnPaint(browser, type, dirtyRects, buffer, width, height); - if (type == PET_VIEW && !renderer_.popup_rect().IsEmpty()) { - painting_popup_ = true; - CefRect client_popup_rect(0, 0, - renderer_.popup_rect().width, - renderer_.popup_rect().height); - browser->GetHost()->Invalidate(client_popup_rect, PET_POPUP); - painting_popup_ = false; - } - renderer_.Render(); -} - -void OSRWindow::OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) { - GtkWidget* window = gtk_widget_get_toplevel(glarea_); - GdkWindow* gdk_window = gtk_widget_get_window(window); - if (cursor->type == GDK_LAST_CURSOR) - cursor = NULL; - gdk_window_set_cursor(gdk_window, cursor); -} - -void OSRWindow::Invalidate() { - if (!CefCurrentlyOn(TID_UI)) { - CefPostTask(TID_UI, NewCefRunnableMethod(this, &OSRWindow::Invalidate)); - return; - } - - // Don't post another task if the previous task is still pending. - if (render_task_pending_) - return; - - render_task_pending_ = true; - - // Render at 30fps. - static const int kRenderDelay = 1000 / 30; - CefPostDelayedTask(TID_UI, NewCefRunnableMethod(this, &OSRWindow::Render), - kRenderDelay); -} - -bool OSRWindow::IsOverPopupWidget(int x, int y) const { - const CefRect& rc = renderer_.popup_rect(); - int popup_right = rc.x + rc.width; - int popup_bottom = rc.y + rc.height; - return (x >= rc.x) && (x < popup_right) && - (y >= rc.y) && (y < popup_bottom); -} - -int OSRWindow::GetPopupXOffset() const { - return renderer_.original_popup_rect().x - renderer_.popup_rect().x; -} - -int OSRWindow::GetPopupYOffset() const { - return renderer_.original_popup_rect().y - renderer_.popup_rect().y; -} - -void OSRWindow::ApplyPopupOffset(int& x, int& y) const { - if (IsOverPopupWidget(x, y)) { - x += GetPopupXOffset(); - y += GetPopupYOffset(); - } -} - -OSRWindow::OSRWindow(OSRBrowserProvider* browser_provider, - bool transparent, - CefWindowHandle parentView) - : renderer_(transparent), - browser_provider_(browser_provider), - gl_enabled_(false), - painting_popup_(false), - render_task_pending_(false) { - glarea_ = gtk_drawing_area_new(); - ASSERT(glarea_); - - GdkGLConfig* glconfig = gdk_gl_config_new_by_mode( - static_cast(GDK_GL_MODE_RGB | - GDK_GL_MODE_DEPTH | - GDK_GL_MODE_DOUBLE)); - ASSERT(glconfig); - - gtk_widget_set_gl_capability(glarea_, glconfig, NULL, TRUE, - GDK_GL_RGBA_TYPE); - - gtk_widget_set_can_focus(glarea_, TRUE); - - g_signal_connect(G_OBJECT(glarea_), "size_allocate", - G_CALLBACK(glarea_size_allocation), this); - - gtk_widget_set_events(glarea_, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_KEY_PRESS_MASK | - GDK_KEY_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_SCROLL_MASK | - GDK_FOCUS_CHANGE_MASK); - g_signal_connect(G_OBJECT(glarea_), "button_press_event", - G_CALLBACK(glarea_click_event), this); - g_signal_connect(G_OBJECT(glarea_), "button_release_event", - G_CALLBACK(glarea_click_event), this); - g_signal_connect(G_OBJECT(glarea_), "key_press_event", - G_CALLBACK(glarea_key_event), this); - g_signal_connect(G_OBJECT(glarea_), "key_release_event", - G_CALLBACK(glarea_key_event), this); - g_signal_connect(G_OBJECT(glarea_), "enter_notify_event", - G_CALLBACK(glarea_move_event), this); - g_signal_connect(G_OBJECT(glarea_), "leave_notify_event", - G_CALLBACK(glarea_move_event), this); - g_signal_connect(G_OBJECT(glarea_), "motion_notify_event", - G_CALLBACK(glarea_move_event), this); - g_signal_connect(G_OBJECT(glarea_), "scroll_event", - G_CALLBACK(glarea_scroll_event), this); - g_signal_connect(G_OBJECT(glarea_), "focus_in_event", - G_CALLBACK(glarea_focus_event), this); - g_signal_connect(G_OBJECT(glarea_), "focus_out_event", - G_CALLBACK(glarea_focus_event), this); - - gtk_container_add(GTK_CONTAINER(parentView), glarea_); -} - -OSRWindow::~OSRWindow() { -} - -void OSRWindow::Render() { - ASSERT(CefCurrentlyOn(TID_UI)); - if (render_task_pending_) - render_task_pending_ = false; - - if (!gl_enabled_) - EnableGL(); - - ScopedGLContext scoped_gl_context(glarea_, true); - if (!scoped_gl_context.IsValid()) - return; - - renderer_.Render(); -} - -void OSRWindow::EnableGL() { - ASSERT(CefCurrentlyOn(TID_UI)); - if (gl_enabled_) - return; - - ScopedGLContext scoped_gl_context(glarea_, false); - if (!scoped_gl_context.IsValid()) - return; - - renderer_.Initialize(); - - gl_enabled_ = true; -} - -void OSRWindow::DisableGL() { - ASSERT(CefCurrentlyOn(TID_UI)); - - if (!gl_enabled_) - return; - - ScopedGLContext scoped_gl_context(glarea_, false); - if (!scoped_gl_context.IsValid()) - return; - - renderer_.Cleanup(); - - gl_enabled_ = false; -} - diff --git a/tests/cefclient/cefclient_osr_widget_gtk.h b/tests/cefclient/cefclient_osr_widget_gtk.h deleted file mode 100644 index 10e4b43d..00000000 --- a/tests/cefclient/cefclient_osr_widget_gtk.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_GTK_H_ -#define CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_GTK_H_ -#pragma once - -#include "include/cef_render_handler.h" -#include "cefclient/client_handler.h" -#include "cefclient/osrenderer.h" - -class OSRBrowserProvider { - public: - virtual CefRefPtr GetBrowser() =0; - - protected: - virtual ~OSRBrowserProvider() {} -}; - -class OSRWindow : public ClientHandler::RenderHandler { - public: - // Create a new OSRWindow instance. |browser_provider| must outlive this - // object. - static CefRefPtr Create(OSRBrowserProvider* browser_provider, - bool transparent, - CefWindowHandle parentView); - - static CefRefPtr From( - CefRefPtr renderHandler); - - CefWindowHandle GetWindowHandle() const { - return glarea_; - } - CefRefPtr GetBrowserHost() const { - return browser_provider_->GetBrowser()->GetHost(); - } - - // ClientHandler::RenderHandler methods - virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; - - // CefRenderHandler methods - virtual bool GetViewRect(CefRefPtr browser, - CefRect& rect) OVERRIDE; - virtual bool GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) OVERRIDE; - virtual void OnPopupShow(CefRefPtr browser, - bool show) OVERRIDE; - virtual void OnPopupSize(CefRefPtr browser, - const CefRect& rect) OVERRIDE; - virtual void OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, - int height) OVERRIDE; - virtual void OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) OVERRIDE; - - void Invalidate(); - bool IsOverPopupWidget(int x, int y) const; - int GetPopupXOffset() const; - int GetPopupYOffset() const; - void ApplyPopupOffset(int& x, int& y) const; - - private: - OSRWindow(OSRBrowserProvider* browser_provider, - bool transparent, - CefWindowHandle parentView); - virtual ~OSRWindow(); - - void Render(); - void EnableGL(); - void DisableGL(); - - ClientOSRenderer renderer_; - OSRBrowserProvider* browser_provider_; - CefWindowHandle glarea_; - bool gl_enabled_; - - bool painting_popup_; - bool render_task_pending_; - - IMPLEMENT_REFCOUNTING(OSRWindow); -}; - -#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_GTK_H_ diff --git a/tests/cefclient/cefclient_osr_widget_mac.h b/tests/cefclient/cefclient_osr_widget_mac.h deleted file mode 100644 index ea0716ac..00000000 --- a/tests/cefclient/cefclient_osr_widget_mac.h +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_MAC_H_ -#define CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_MAC_H_ - -#include "include/cef_client.h" -#include "cefclient/client_handler.h" - -class ClientOSRenderer; - -class OSRBrowserProvider { - public: - virtual CefRefPtr GetBrowser() =0; - - protected: - virtual ~OSRBrowserProvider() {} -}; - -// The client OpenGL view. -@interface ClientOpenGLView : NSOpenGLView { -@public - NSTrackingArea* tracking_area_; - OSRBrowserProvider* browser_provider_; - ClientOSRenderer* renderer_; - NSPoint last_mouse_pos_; - NSPoint cur_mouse_pos_; - bool rotating_; - - bool was_last_mouse_down_on_view_; - - // Event monitor for scroll wheel end event. - id endWheelMonitor_; -} - -- (id)initWithFrame:(NSRect)frame andTransparency:(bool)transparency; -- (NSPoint)getClickPointForEvent:(NSEvent*)event; -- (void)getKeyEvent:(CefKeyEvent&)keyEvent forEvent:(NSEvent*)event; -- (void)getMouseEvent:(CefMouseEvent&)mouseEvent forEvent:(NSEvent*)event; -- (int)getModifiersForEvent:(NSEvent*)event; -- (BOOL)isKeyUpEvent:(NSEvent*)event; -- (BOOL)isKeyPadEvent:(NSEvent*)event; -- (CefRefPtr)getBrowser; -@end - -// Handler for off-screen rendering windows. -class ClientOSRHandler : public ClientHandler::RenderHandler { - public: - explicit ClientOSRHandler(ClientOpenGLView* view, - OSRBrowserProvider* browser_provider); - virtual ~ClientOSRHandler(); - - void Disconnect(); - - // ClientHandler::RenderHandler - virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; - - // CefRenderHandler methods - - virtual bool GetViewRect(CefRefPtr browser, - CefRect& rect) OVERRIDE; - - virtual bool GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) OVERRIDE; - virtual bool GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) OVERRIDE; - - virtual void OnPopupShow(CefRefPtr browser, - bool show) OVERRIDE; - - virtual void OnPopupSize(CefRefPtr browser, - const CefRect& rect) OVERRIDE; - - virtual void OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, int height) OVERRIDE; - - virtual void OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) OVERRIDE; - - CefWindowHandle view() { return view_; } - - private: - void SetLoading(bool isLoading); - - ClientOpenGLView* view_; - - bool painting_popup_; - - // Include the default reference counting implementation. - IMPLEMENT_REFCOUNTING(ClientOSRHandler); -}; - -class OSRWindow { - public: - static CefRefPtr Create(OSRBrowserProvider* browser_provider, - bool transparent, - CefWindowHandle parentView, - const CefRect& frame); - - CefRefPtr GetRenderHandler() { - return render_client.get(); - } - - CefWindowHandle GetWindowHandle() { return view_; } - - private: - OSRWindow(OSRBrowserProvider* browser_provider, - bool transparent, - CefWindowHandle parentView, - const CefRect& frame); - - ~OSRWindow(); - - CefRefPtr render_client; - CefWindowHandle view_; - - IMPLEMENT_REFCOUNTING(OSRWindow); -}; - -#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_MAC_H_ - diff --git a/tests/cefclient/cefclient_osr_widget_mac.mm b/tests/cefclient/cefclient_osr_widget_mac.mm deleted file mode 100644 index 61ad9f5c..00000000 --- a/tests/cefclient/cefclient_osr_widget_mac.mm +++ /dev/null @@ -1,930 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file. - -#import -#import -#include - -#include "cefclient/cefclient_osr_widget_mac.h" - -#include "include/cef_application_mac.h" -#include "include/cef_browser.h" -#include "include/cef_client.h" -#include "cefclient/cefclient.h" -#include "cefclient/osrenderer.h" -#include "cefclient/resource_util.h" -#include "cefclient/util.h" - -// This method will return YES for OS X versions 10.7.3 and later, and NO -// otherwise. -// Used to prevent a crash when building with the 10.7 SDK and accessing the -// notification below. See: http://crbug.com/260595. -static BOOL SupportsBackingPropertiesChangedNotification() { - // windowDidChangeBackingProperties: method has been added to the - // NSWindowDelegate protocol in 10.7.3, at the same time as the - // NSWindowDidChangeBackingPropertiesNotification notification was added. - // If the protocol contains this method description, the notification should - // be supported as well. - Protocol* windowDelegateProtocol = NSProtocolFromString(@"NSWindowDelegate"); - struct objc_method_description methodDescription = - protocol_getMethodDescription( - windowDelegateProtocol, - @selector(windowDidChangeBackingProperties:), - NO, - YES); - - // If the protocol does not contain the method, the returned method - // description is {NULL, NULL} - return methodDescription.name != NULL || methodDescription.types != NULL; -} - -@interface ClientOpenGLView () -- (float)getDeviceScaleFactor; -- (void)windowDidChangeBackingProperties:(NSNotification*)notification; - -- (bool) isOverPopupWidgetX: (int) x andY: (int) y; -- (void) applyPopupOffsetToX: (int&) x andY: (int&) y; -- (int) getPopupXOffset; -- (int) getPopupYOffset; - -- (void) sendMouseClick: (NSEvent *)event - button: (CefBrowserHost::MouseButtonType)type - isUp: (bool)isUp; - -- (void) convertRects: (const CefRenderHandler::RectList&) rects - toBackingRects: (CefRenderHandler::RectList*) scaled_rects - andSize: (const NSSize) size - toBackingSize: (NSSize*) scaled_size; - -- (CefRect) convertRectToBackingInternal: (const CefRect&) rect; -- (CefRect) convertRectFromBackingInternal: (const CefRect&) rect; - -@property (readwrite, atomic) bool was_last_mouse_down_on_view; -@end - -namespace { - -static CefRect convertRect(const NSRect& target, const NSRect& frame) { - NSRect rect = target; - rect.origin.y = NSMaxY(frame) - NSMaxY(target); - return CefRect(rect.origin.x, - rect.origin.y, - rect.size.width, - rect.size.height); -} - -} // namespace - -ClientOSRHandler::ClientOSRHandler(ClientOpenGLView* view, - OSRBrowserProvider* browser_provider) - : view_(view), - painting_popup_(false) { - [view_ retain]; - view_->browser_provider_ = browser_provider; - - // Backing property notifications crash on 10.6 when building with the 10.7 - // SDK, see http://crbug.com/260595. - static BOOL supportsBackingPropertiesNotification = - SupportsBackingPropertiesChangedNotification(); - if (supportsBackingPropertiesNotification) { - [[NSNotificationCenter defaultCenter] - addObserver:view_ - selector:@selector(windowDidChangeBackingProperties:) - name:NSWindowDidChangeBackingPropertiesNotification - object:[view_ window]]; - } -} - -ClientOSRHandler:: ~ClientOSRHandler() { - static BOOL supportsBackingPropertiesNotification = - SupportsBackingPropertiesChangedNotification(); - - if (supportsBackingPropertiesNotification) { - [[NSNotificationCenter defaultCenter] - removeObserver:view_ - name:NSWindowDidChangeBackingPropertiesNotification - object:[view_ window]]; - } -} - -void ClientOSRHandler::Disconnect() { - [view_ release]; - view_ = nil; -} - -// CefRenderHandler methods -void ClientOSRHandler::OnBeforeClose(CefRefPtr browser) { - if (view_) - view_->browser_provider_ = NULL; -} - -bool ClientOSRHandler::GetViewRect(CefRefPtr browser, - CefRect& rect) { - REQUIRE_UI_THREAD(); - - if (!view_) - return false; - - // The simulated screen and view rectangle are the same. This is necessary - // for popup menus to be located and sized inside the view. - const NSRect bounds = [view_ bounds]; - rect.x = rect.y = 0; - rect.width = bounds.size.width; - rect.height = bounds.size.height; - return true; -} - -bool ClientOSRHandler::GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) { - REQUIRE_UI_THREAD(); - - if (!view_) - return false; - - // Convert the point from view coordinates to actual screen coordinates. - NSRect bounds = [view_ bounds]; - NSPoint view_pt = NSMakePoint(viewX, bounds.size.height - viewY); - NSPoint window_pt = [view_ convertPoint:view_pt toView:nil]; - NSPoint screen_pt = [[view_ window] convertBaseToScreen:window_pt]; - screenX = screen_pt.x; - screenY = screen_pt.y; - return true; -} - -bool ClientOSRHandler::GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) { - REQUIRE_UI_THREAD(); - - if (!view_) - return false; - - NSWindow* window = [view_ window]; - if (!window) - return false; - - screen_info.device_scale_factor = [view_ getDeviceScaleFactor]; - - NSScreen* screen = [window screen]; - if (!screen) - screen = [NSScreen deepestScreen]; - - screen_info.depth = NSBitsPerPixelFromDepth([screen depth]); - screen_info.depth_per_component = NSBitsPerSampleFromDepth([screen depth]); - screen_info.is_monochrome = - [[screen colorSpace] colorSpaceModel] == NSGrayColorSpaceModel; - // screen_info.is_monochrome = true; - screen_info.rect = convertRect([screen frame], [screen frame]); - screen_info.available_rect = - convertRect([screen visibleFrame], [screen frame]); - - return true; -} - -void ClientOSRHandler::OnPopupShow(CefRefPtr browser, - bool show) { - REQUIRE_UI_THREAD(); - - if (!view_) - return; - - if (!show) { - CefRect client_popup_rect = view_->renderer_->popup_rect(); - - // Clear the popup rectangles, so that the paint triggered by Invalidate - // will not repaint the popup content over the OpenGL view. - view_->renderer_->ClearPopupRects(); - CefRect scaled_rect = - [view_ convertRectFromBackingInternal:client_popup_rect]; - browser->GetHost()->Invalidate(scaled_rect, PET_VIEW); - } - - view_->renderer_->OnPopupShow(browser, show); -} - -void ClientOSRHandler::OnPopupSize(CefRefPtr browser, - const CefRect& rect) { - REQUIRE_UI_THREAD(); - - if (!view_) - return; - - CefRect scaled_rect = [view_ convertRectToBackingInternal:rect]; - view_->renderer_->OnPopupSize(browser, scaled_rect); -} - -void ClientOSRHandler::OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, int height) { - REQUIRE_UI_THREAD(); - - if (!view_) - return; - - if (painting_popup_) { - RectList scaled_dirty_rects; - NSSize scaled_size = NSMakeSize(0, 0); - [view_ convertRects:dirtyRects - toBackingRects:&scaled_dirty_rects - andSize:NSMakeSize(width, height) - toBackingSize:&scaled_size]; - view_->renderer_->OnPaint(browser, type, scaled_dirty_rects, buffer, - scaled_size.width, scaled_size.height); - return; - } - - NSOpenGLContext* context = [view_ openGLContext]; - [context makeCurrentContext]; - - RectList scaled_dirty_rects; - NSSize scaled_size = NSMakeSize(0, 0); - [view_ convertRects:dirtyRects - toBackingRects:&scaled_dirty_rects - andSize:NSMakeSize(width, height) - toBackingSize:&scaled_size]; - - view_->renderer_->OnPaint(browser, type, scaled_dirty_rects, buffer, - scaled_size.width, scaled_size.height); - - if (type == PET_VIEW && !view_->renderer_->popup_rect().IsEmpty()) { - painting_popup_ = true; - CefRect client_popup_rect(0, 0, - view_->renderer_->popup_rect().width, - view_->renderer_->popup_rect().height); - - CefRect scaled_popup_rect = - [view_ convertRectFromBackingInternal:client_popup_rect]; - - browser->GetHost()->Invalidate(scaled_popup_rect, PET_POPUP); - painting_popup_ = false; - } - - view_->renderer_->Render(); - [context flushBuffer]; -} - -void ClientOSRHandler::OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) { - REQUIRE_UI_THREAD(); - [cursor set]; -} - -void ClientOSRHandler::SetLoading(bool isLoading) { -} - -@implementation ClientOpenGLView - -@synthesize was_last_mouse_down_on_view = was_last_mouse_down_on_view_; - -- (id)initWithFrame:(NSRect)frame andTransparency:(bool)transparency { - NSOpenGLPixelFormat * pixelFormat = - [[NSOpenGLPixelFormat alloc] - initWithAttributes:(NSOpenGLPixelFormatAttribute[]) { - NSOpenGLPFAWindow, - NSOpenGLPFADoubleBuffer, - NSOpenGLPFADepthSize, - 32, - 0}]; - [pixelFormat autorelease]; - - self = [super initWithFrame:frame pixelFormat:pixelFormat]; - if (self) { - renderer_ = new ClientOSRenderer(transparency); - rotating_ = false; - endWheelMonitor_ = nil; - - tracking_area_ = - [[NSTrackingArea alloc] initWithRect:frame - options:NSTrackingMouseMoved | - NSTrackingActiveInActiveApp | - NSTrackingInVisibleRect - owner:self - userInfo:nil]; - [self addTrackingArea:tracking_area_]; - } - - if ([self respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) { - // enable HiDPI buffer - [self setWantsBestResolutionOpenGLSurface:YES]; - } - - return self; -} - -- (void)dealloc { - CefRefPtr browser = [self getBrowser]; - if (browser) { - static_cast( - browser->GetHost()->GetClient()->GetRenderHandler().get())->Disconnect(); - browser->GetHost()->CloseBrowser(true); - browser = NULL; - } - if (renderer_) - delete renderer_; - - [super dealloc]; -} - -- (CefRefPtr)getBrowser { - if (browser_provider_) - return browser_provider_->GetBrowser(); - return NULL; -} - -- (void)setFrame:(NSRect)frameRect { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - [super setFrame:frameRect]; - browser->GetHost()->WasResized(); -} - -- (void) sendMouseClick:(NSEvent *)event - button: (CefBrowserHost::MouseButtonType)type - isUp: (bool)isUp { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - CefMouseEvent mouseEvent; - [self getMouseEvent: mouseEvent forEvent: event]; - NSPoint point = [self getClickPointForEvent:event]; - if (!isUp) - self.was_last_mouse_down_on_view = ![self isOverPopupWidgetX: point.x - andY: point.y]; - else if (self.was_last_mouse_down_on_view && - [self isOverPopupWidgetX:point.x andY: point.y] && - ([self getPopupXOffset] || [self getPopupYOffset])) { - return; - } - - browser->GetHost()->SendMouseClickEvent(mouseEvent, - type, - isUp, - [event clickCount]); -} - -- (void)mouseDown:(NSEvent *)event { - [self sendMouseClick: event button:MBT_LEFT isUp:false]; -} - -- (void)rightMouseDown:(NSEvent *)event { - if ([event modifierFlags] & NSShiftKeyMask) { - // Start rotation effect. - last_mouse_pos_ = cur_mouse_pos_ = [self getClickPointForEvent:event]; - rotating_ = true; - return; - } - - [self sendMouseClick: event button:MBT_RIGHT isUp:false]; -} - -- (void)otherMouseDown:(NSEvent *)event { - [self sendMouseClick: event button:MBT_MIDDLE isUp:false]; -} - -- (void)mouseUp:(NSEvent *)event { - [self sendMouseClick: event button: MBT_LEFT isUp: true]; -} - -- (void)rightMouseUp:(NSEvent *)event { - if (rotating_) { - // End rotation effect. - renderer_->SetSpin(0, 0); - rotating_ = false; - [self setNeedsDisplay:YES]; - return; - } - [self sendMouseClick: event button: MBT_RIGHT isUp: true]; -} - -- (void)otherMouseUp:(NSEvent *)event { - [self sendMouseClick: event button: MBT_MIDDLE isUp: true]; -} - -- (void)mouseMoved:(NSEvent *)event { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - if (rotating_) { - // Apply rotation effect. - cur_mouse_pos_ = [self getClickPointForEvent:event];; - renderer_->IncrementSpin((cur_mouse_pos_.x - last_mouse_pos_.x), - (cur_mouse_pos_.y - last_mouse_pos_.y)); - last_mouse_pos_ = cur_mouse_pos_; - [self setNeedsDisplay:YES]; - return; - } - - CefMouseEvent mouseEvent; - [self getMouseEvent: mouseEvent forEvent: event]; - browser->GetHost()->SendMouseMoveEvent(mouseEvent, false); -} - -- (void)mouseDragged:(NSEvent *)event { - [self mouseMoved:event]; -} - -- (void)rightMouseDragged:(NSEvent *)event { - [self mouseMoved:event]; -} - -- (void)otherMouseDragged:(NSEvent *)event { - [self mouseMoved:event]; -} - -- (void)mouseEntered:(NSEvent *)event { - [self mouseMoved:event]; -} - -- (void)mouseExited:(NSEvent *)event { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - CefMouseEvent mouseEvent; - [self getMouseEvent: mouseEvent forEvent: event]; - browser->GetHost()->SendMouseMoveEvent(mouseEvent, true); -} - -- (void)keyDown:(NSEvent *)event { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - if ([event type] != NSFlagsChanged) { - browser->GetHost()->HandleKeyEventBeforeTextInputClient(event); - - // The return value of this method seems to always be set to YES, - // thus we ignore it and ask the host view whether IME is active - // or not. - [[self inputContext] handleEvent:event]; - - browser->GetHost()->HandleKeyEventAfterTextInputClient(event); - } -} - -- (void)keyUp:(NSEvent *)event { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - CefKeyEvent keyEvent; - [self getKeyEvent:keyEvent forEvent:event]; - - keyEvent.type = KEYEVENT_KEYUP; - browser->GetHost()->SendKeyEvent(keyEvent); -} - -- (void)flagsChanged:(NSEvent *)event { - if ([self isKeyUpEvent:event]) - [self keyUp:event]; - else - [self keyDown:event]; -} - -- (void)shortCircuitScrollWheelEvent:(NSEvent*)event { - // Phase is only supported in OS-X 10.7 and newer. - if ([event phase] != NSEventPhaseEnded && - [event phase] != NSEventPhaseCancelled) - return; - - [self sendScrollWheelEvet:event]; - - if (endWheelMonitor_) { - [NSEvent removeMonitor:endWheelMonitor_]; - endWheelMonitor_ = nil; - } -} - -- (void)scrollWheel:(NSEvent *)event { - // Phase is only supported in OS-X 10.7 and newer. - // Use an NSEvent monitor to listen for the wheel-end end. This ensures that - // the event is received even when the mouse cursor is no longer over the - // view when the scrolling ends. Also it avoids sending duplicate scroll - // events to the renderer. - if ([event respondsToSelector:@selector(phase)] && - [event phase] == NSEventPhaseBegan && !endWheelMonitor_) { - endWheelMonitor_ = - [NSEvent addLocalMonitorForEventsMatchingMask:NSScrollWheelMask - handler:^(NSEvent* blockEvent) { - [self shortCircuitScrollWheelEvent:blockEvent]; - return blockEvent; - }]; - } - - [self sendScrollWheelEvet:event]; -} - -- (void)sendScrollWheelEvet:(NSEvent *)event { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - CGEventRef cgEvent = [event CGEvent]; - ASSERT(cgEvent); - - int deltaX = - CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2); - int deltaY = - CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1); - - CefMouseEvent mouseEvent; - [self getMouseEvent: mouseEvent forEvent: event]; - browser->GetHost()->SendMouseWheelEvent(mouseEvent, deltaX, deltaY); -} - -- (BOOL)canBecomeKeyView { - CefRefPtr browser = [self getBrowser]; - return (browser != NULL); -} - -- (BOOL)acceptsFirstResponder { - CefRefPtr browser = [self getBrowser]; - return (browser != NULL); -} - -- (BOOL)becomeFirstResponder { - CefRefPtr browser = [self getBrowser]; - if (browser) { - browser->GetHost()->SendFocusEvent(true); - return [super becomeFirstResponder]; - } - - return NO; -} - -- (BOOL)resignFirstResponder { - CefRefPtr browser = [self getBrowser]; - if (browser) { - browser->GetHost()->SendFocusEvent(false); - return [super resignFirstResponder]; - } - - return NO; -} - -- (void)undo:(id)sender { - CefRefPtr browser = [self getBrowser]; - if (browser) - browser->GetFocusedFrame()->Undo(); -} - -- (void)redo:(id)sender { - CefRefPtr browser = [self getBrowser]; - if (browser) - browser->GetFocusedFrame()->Redo(); -} - -- (void)cut:(id)sender { - CefRefPtr browser = [self getBrowser]; - if (browser) - browser->GetFocusedFrame()->Cut(); -} - -- (void)copy:(id)sender { - CefRefPtr browser = [self getBrowser]; - if (browser) - browser->GetFocusedFrame()->Copy(); -} - -- (void)paste:(id)sender { - CefRefPtr browser = [self getBrowser]; - if (browser) - browser->GetFocusedFrame()->Paste(); -} - -- (void)delete:(id)sender { - CefRefPtr browser = [self getBrowser]; - if (browser) - browser->GetFocusedFrame()->Delete(); -} - -- (void)selectAll:(id)sender { - CefRefPtr browser = [self getBrowser]; - if (browser) - browser->GetFocusedFrame()->SelectAll(); -} - -- (NSPoint)getClickPointForEvent:(NSEvent*)event { - NSPoint windowLocal = [event locationInWindow]; - NSPoint contentLocal = [self convertPoint:windowLocal fromView:nil]; - - NSPoint point; - point.x = contentLocal.x; - point.y = [self frame].size.height - contentLocal.y; // Flip y. - return point; -} - -- (void)getKeyEvent:(CefKeyEvent &)keyEvent forEvent:(NSEvent *)event { - if ([event type] == NSKeyDown || [event type] == NSKeyUp) { - NSString* s = [event characters]; - if ([s length] > 0) - keyEvent.character = [s characterAtIndex:0]; - - s = [event charactersIgnoringModifiers]; - if ([s length] > 0) - keyEvent.unmodified_character = [s characterAtIndex:0]; - } - - if ([event type] == NSFlagsChanged) { - keyEvent.character = 0; - keyEvent.unmodified_character = 0; - } - - keyEvent.native_key_code = [event keyCode]; - - keyEvent.modifiers = [self getModifiersForEvent:event]; -} - -- (NSTextInputContext*)inputContext { - CefRefPtr browser = [self getBrowser]; - if (browser) - return browser->GetHost()->GetNSTextInputContext(); - return NULL; -} - -- (void)getMouseEvent:(CefMouseEvent&)mouseEvent forEvent:(NSEvent*)event { - NSPoint point = [self getClickPointForEvent:event]; - mouseEvent.x = point.x; - mouseEvent.y = point.y; - - if ([self isOverPopupWidgetX:mouseEvent.x andY: mouseEvent.y]) { - [self applyPopupOffsetToX:mouseEvent.x andY: mouseEvent.y]; - } - - mouseEvent.modifiers = [self getModifiersForEvent:event]; -} - -- (int)getModifiersForEvent:(NSEvent*)event { - int modifiers = 0; - - if ([event modifierFlags] & NSControlKeyMask) - modifiers |= EVENTFLAG_CONTROL_DOWN; - if ([event modifierFlags] & NSShiftKeyMask) - modifiers |= EVENTFLAG_SHIFT_DOWN; - if ([event modifierFlags] & NSAlternateKeyMask) - modifiers |= EVENTFLAG_ALT_DOWN; - if ([event modifierFlags] & NSCommandKeyMask) - modifiers |= EVENTFLAG_COMMAND_DOWN; - if ([event modifierFlags] & NSAlphaShiftKeyMask) - modifiers |= EVENTFLAG_CAPS_LOCK_ON; - - if ([event type] == NSKeyUp || - [event type] == NSKeyDown || - [event type] == NSFlagsChanged) { - // Only perform this check for key events - if ([self isKeyPadEvent:event]) - modifiers |= EVENTFLAG_IS_KEY_PAD; - } - - // OS X does not have a modifier for NumLock, so I'm not entirely sure how to - // set EVENTFLAG_NUM_LOCK_ON; - // - // There is no EVENTFLAG for the function key either. - - // Mouse buttons - switch ([event type]) { - case NSLeftMouseDragged: - case NSLeftMouseDown: - case NSLeftMouseUp: - modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON; - break; - case NSRightMouseDragged: - case NSRightMouseDown: - case NSRightMouseUp: - modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON; - break; - case NSOtherMouseDragged: - case NSOtherMouseDown: - case NSOtherMouseUp: - modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON; - break; - } - - return modifiers; -} - -- (BOOL)isKeyUpEvent:(NSEvent*)event { - if ([event type] != NSFlagsChanged) - return [event type] == NSKeyUp; - - // FIXME: This logic fails if the user presses both Shift keys at once, for - // example: we treat releasing one of them as keyDown. - switch ([event keyCode]) { - case 54: // Right Command - case 55: // Left Command - return ([event modifierFlags] & NSCommandKeyMask) == 0; - - case 57: // Capslock - return ([event modifierFlags] & NSAlphaShiftKeyMask) == 0; - - case 56: // Left Shift - case 60: // Right Shift - return ([event modifierFlags] & NSShiftKeyMask) == 0; - - case 58: // Left Alt - case 61: // Right Alt - return ([event modifierFlags] & NSAlternateKeyMask) == 0; - - case 59: // Left Ctrl - case 62: // Right Ctrl - return ([event modifierFlags] & NSControlKeyMask) == 0; - - case 63: // Function - return ([event modifierFlags] & NSFunctionKeyMask) == 0; - } - return false; -} - -- (BOOL)isKeyPadEvent:(NSEvent*)event { - if ([event modifierFlags] & NSNumericPadKeyMask) - return true; - - switch ([event keyCode]) { - case 71: // Clear - case 81: // = - case 75: // / - case 67: // * - case 78: // - - case 69: // + - case 76: // Enter - case 65: // . - case 82: // 0 - case 83: // 1 - case 84: // 2 - case 85: // 3 - case 86: // 4 - case 87: // 5 - case 88: // 6 - case 89: // 7 - case 91: // 8 - case 92: // 9 - return true; - } - - return false; -} - -- (void)windowDidChangeBackingProperties:(NSNotification*)notification { - // This delegate method is only called on 10.7 and later, so don't worry about - // other backing changes calling it on 10.6 or earlier - CGFloat newBackingScaleFactor = [self getDeviceScaleFactor]; - NSNumber* oldBackingScaleFactor = - [[notification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey]; - if (newBackingScaleFactor != [oldBackingScaleFactor doubleValue]) { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - browser->GetHost()->NotifyScreenInfoChanged(); - } -} - -- (void)drawRect: (NSRect) dirtyRect { - // The Invalidate below fixes flicker when resizing - if ([self inLiveResize]) { - CefRefPtr browser = [self getBrowser]; - if (!browser) - return; - - NSRect b = [self bounds]; - CefRect boundsRect = CefRect((int)b.origin.x, - (int)b.origin.y, - (int)b.size.width, - (int)b.size.height); - browser->GetHost()->Invalidate(boundsRect, PET_VIEW); - } -} - -// Utility - private -- (float)getDeviceScaleFactor { - float deviceScaleFactor = 1; - NSWindow* window = [self window]; - if (!window) - return deviceScaleFactor; - - if ([window respondsToSelector:@selector(backingScaleFactor)]) - deviceScaleFactor = [window backingScaleFactor]; - else - deviceScaleFactor = [window userSpaceScaleFactor]; - - return deviceScaleFactor; -} - -- (bool) isOverPopupWidgetX: (int) x andY: (int) y { - CefRect rc = [self convertRectFromBackingInternal:renderer_->popup_rect()]; - int popup_right = rc.x + rc.width; - int popup_bottom = rc.y + rc.height; - return (x >= rc.x) && (x < popup_right) && - (y >= rc.y) && (y < popup_bottom); -} - -- (int) getPopupXOffset { - int original_x = - [self convertRectFromBackingInternal:renderer_->original_popup_rect()].x; - int popup_x = - [self convertRectFromBackingInternal:renderer_->popup_rect()].x; - - return original_x - popup_x; -} - -- (int) getPopupYOffset { - int original_y = - [self convertRectFromBackingInternal:renderer_->original_popup_rect()].y; - int popup_y = - [self convertRectFromBackingInternal:renderer_->popup_rect()].y; - - return original_y - popup_y; -} - -- (void) applyPopupOffsetToX: (int&) x andY: (int&) y { - if ([self isOverPopupWidgetX:x andY:y]) { - x += [self getPopupXOffset]; - y += [self getPopupYOffset]; - } -} - -- (void) convertRects: (const CefRenderHandler::RectList&) rects - toBackingRects: (CefRenderHandler::RectList*) scaled_rects - andSize: (const NSSize) size - toBackingSize: (NSSize*) scaled_size { - *scaled_rects = rects; - *scaled_size = size; - - if ([self getDeviceScaleFactor] != 1 && - [self respondsToSelector:@selector(convertSizeToBacking:)] && - [self respondsToSelector:@selector(convertRectToBacking:)]) { - CefRenderHandler::RectList scaled_dirty_rects; - for (size_t i = 0; i < rects.size(); ++i) { - scaled_dirty_rects.push_back([self convertRectToBackingInternal:rects[i]]); - } - - *scaled_rects = scaled_dirty_rects; - *scaled_size = [self convertSizeToBacking:size]; - } -} - -- (CefRect) convertRectToBackingInternal: (const CefRect&) rect { - if ([self getDeviceScaleFactor] == 1) - return rect; - - if ([self respondsToSelector:@selector(convertRectToBacking:)]) { - NSRect old_rect = NSMakeRect(rect.x, rect.y, rect.width, rect.height); - NSRect scaled_rect = [self convertRectToBacking:old_rect]; - return CefRect((int)scaled_rect.origin.x, - (int)scaled_rect.origin.y, - (int)scaled_rect.size.width, - (int)scaled_rect.size.height); - } - - return rect; -} - -- (CefRect) convertRectFromBackingInternal: (const CefRect&) rect { - if ([self respondsToSelector:@selector(convertRectFromBacking:)]) { - NSRect old_rect = NSMakeRect(rect.x, rect.y, rect.width, rect.height); - NSRect scaled_rect = [self convertRectFromBacking:old_rect]; - return CefRect((int)scaled_rect.origin.x, - (int)scaled_rect.origin.y, - (int)scaled_rect.size.width, - (int)scaled_rect.size.height); - } - - return rect; -} - -@end - - -CefRefPtr OSRWindow::Create(OSRBrowserProvider* browser_provider, - bool transparent, - CefWindowHandle parentView, - const CefRect& frame) { - return new OSRWindow(browser_provider, transparent, parentView, frame); -} - -OSRWindow::OSRWindow(OSRBrowserProvider* browser_provider, - bool transparent, - CefWindowHandle parentView, - const CefRect& frame) { - NSRect window_rect = NSMakeRect(frame.x, frame.y, frame.width, frame.height); - ClientOpenGLView* view = [[ClientOpenGLView alloc] initWithFrame:window_rect - andTransparency:transparent]; - this->view_ = view; - [parentView addSubview:view]; - [view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [view setAutoresizesSubviews: true]; - - this->render_client = new ClientOSRHandler(view, browser_provider); -} - -OSRWindow::~OSRWindow() { -} diff --git a/tests/cefclient/cefclient_osr_widget_win.cpp b/tests/cefclient/cefclient_osr_widget_win.cpp deleted file mode 100644 index 8fd97e5c..00000000 --- a/tests/cefclient/cefclient_osr_widget_win.cpp +++ /dev/null @@ -1,659 +0,0 @@ -// Copyright (c) 2011 The Chromium Embedded Framework 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 "cefclient/cefclient_osr_widget_win.h" - -#include - -#include "include/cef_runnable.h" -#include "cefclient/resource.h" -#include "cefclient/util.h" - -// static -CefRefPtr OSRWindow::Create(OSRBrowserProvider* browser_provider, - bool transparent) { - ASSERT(browser_provider); - if (!browser_provider) - return NULL; - - return new OSRWindow(browser_provider, transparent); -} - -// static -CefRefPtr OSRWindow::From( - CefRefPtr renderHandler) { - return static_cast(renderHandler.get()); -} - -bool OSRWindow::CreateWidget(HWND hWndParent, const RECT& rect, - HINSTANCE hInst, LPCTSTR className) { - ASSERT(hWnd_ == NULL && hDC_ == NULL && hRC_ == NULL); - - RegisterOSRClass(hInst, className); - hWnd_ = ::CreateWindow(className, 0, - WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, - rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, - hWndParent, 0, hInst, 0); - - if (!hWnd_) - return false; - - SetWindowLongPtr(hWnd_, GWLP_USERDATA, reinterpret_cast(this)); - - // Reference released in OnDestroyed(). - AddRef(); - - return true; -} - -void OSRWindow::DestroyWidget() { - if (IsWindow(hWnd_)) - DestroyWindow(hWnd_); -} - -void OSRWindow::OnBeforeClose(CefRefPtr browser) { - DisableGL(); -} - -bool OSRWindow::GetRootScreenRect(CefRefPtr browser, - CefRect& rect) { - RECT window_rect = {0}; - HWND root_window = GetAncestor(hWnd_, GA_ROOT); - if (::GetWindowRect(root_window, &window_rect)) { - rect = CefRect(window_rect.left, - window_rect.top, - window_rect.right - window_rect.left, - window_rect.bottom - window_rect.top); - return true; - } - return false; -} - -bool OSRWindow::GetViewRect(CefRefPtr browser, - CefRect& rect) { - RECT clientRect; - if (!::GetClientRect(hWnd_, &clientRect)) - return false; - rect.x = rect.y = 0; - rect.width = clientRect.right; - rect.height = clientRect.bottom; - return true; -} - -bool OSRWindow::GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) { - if (!::IsWindow(hWnd_)) - return false; - - // Convert the point from view coordinates to actual screen coordinates. - POINT screen_pt = {viewX, viewY}; - ClientToScreen(hWnd_, &screen_pt); - screenX = screen_pt.x; - screenY = screen_pt.y; - return true; -} - -void OSRWindow::OnPopupShow(CefRefPtr browser, - bool show) { - if (!show) { - CefRect dirty_rect = renderer_.popup_rect(); - renderer_.ClearPopupRects(); - browser->GetHost()->Invalidate(dirty_rect, PET_VIEW); - } - renderer_.OnPopupShow(browser, show); -} - -void OSRWindow::OnPopupSize(CefRefPtr browser, - const CefRect& rect) { - renderer_.OnPopupSize(browser, rect); -} - -void OSRWindow::OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, int height) { - if (painting_popup_) { - renderer_.OnPaint(browser, type, dirtyRects, buffer, width, height); - return; - } - if (!hDC_) - EnableGL(); - - wglMakeCurrent(hDC_, hRC_); - renderer_.OnPaint(browser, type, dirtyRects, buffer, width, height); - if (type == PET_VIEW && !renderer_.popup_rect().IsEmpty()) { - painting_popup_ = true; - CefRect client_popup_rect(0, 0, - renderer_.popup_rect().width, - renderer_.popup_rect().height); - browser->GetHost()->Invalidate(client_popup_rect, PET_POPUP); - painting_popup_ = false; - } - renderer_.Render(); - SwapBuffers(hDC_); -} - -void OSRWindow::OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) { - if (!::IsWindow(hWnd_)) - return; - - // Change the plugin window's cursor. - SetClassLongPtr(hWnd_, GCLP_HCURSOR, - static_cast(reinterpret_cast(cursor))); - SetCursor(cursor); -} - -void OSRWindow::Invalidate() { - if (!CefCurrentlyOn(TID_UI)) { - CefPostTask(TID_UI, NewCefRunnableMethod(this, &OSRWindow::Invalidate)); - return; - } - - // Don't post another task if the previous task is still pending. - if (render_task_pending_) - return; - - render_task_pending_ = true; - - // Render at 30fps. - static const int kRenderDelay = 1000 / 30; - CefPostDelayedTask(TID_UI, NewCefRunnableMethod(this, &OSRWindow::Render), - kRenderDelay); -} - -OSRWindow::OSRWindow(OSRBrowserProvider* browser_provider, bool transparent) - : renderer_(transparent), - browser_provider_(browser_provider), - hWnd_(NULL), - hDC_(NULL), - hRC_(NULL), - painting_popup_(false), - render_task_pending_(false) { -} - -OSRWindow::~OSRWindow() { - DestroyWidget(); -} - -void OSRWindow::Render() { - ASSERT(CefCurrentlyOn(TID_UI)); - if (render_task_pending_) - render_task_pending_ = false; - - if (!hDC_) - EnableGL(); - - wglMakeCurrent(hDC_, hRC_); - renderer_.Render(); - SwapBuffers(hDC_); -} - -void OSRWindow::EnableGL() { - ASSERT(CefCurrentlyOn(TID_UI)); - - PIXELFORMATDESCRIPTOR pfd; - int format; - - // Get the device context. - hDC_ = GetDC(hWnd_); - - // Set the pixel format for the DC. - ZeroMemory(&pfd, sizeof(pfd)); - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 24; - pfd.cDepthBits = 16; - pfd.iLayerType = PFD_MAIN_PLANE; - format = ChoosePixelFormat(hDC_, &pfd); - SetPixelFormat(hDC_, format, &pfd); - - // Create and enable the render context. - hRC_ = wglCreateContext(hDC_); - wglMakeCurrent(hDC_, hRC_); - - renderer_.Initialize(); -} - -void OSRWindow::DisableGL() { - ASSERT(CefCurrentlyOn(TID_UI)); - - if (!hDC_) - return; - - renderer_.Cleanup(); - - if (IsWindow(hWnd_)) { - wglMakeCurrent(NULL, NULL); - wglDeleteContext(hRC_); - ReleaseDC(hWnd_, hDC_); - } - - hDC_ = NULL; - hRC_ = NULL; -} - -void OSRWindow::OnDestroyed() { - SetWindowLongPtr(hWnd_, GWLP_USERDATA, 0L); - hWnd_ = NULL; - Release(); -} - -ATOM OSRWindow::RegisterOSRClass(HINSTANCE hInstance, LPCTSTR className) { - WNDCLASSEX wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_OWNDC; - wcex.lpfnWndProc = &OSRWindow::WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = NULL; - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wcex.lpszMenuName = NULL; - wcex.lpszClassName = className; - wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); - return RegisterClassEx(&wcex); -} - -bool OSRWindow::isKeyDown(WPARAM wparam) { - return (GetKeyState(wparam) & 0x8000) != 0; -} - -int OSRWindow::GetCefMouseModifiers(WPARAM wparam) { - int modifiers = 0; - if (wparam & MK_CONTROL) - modifiers |= EVENTFLAG_CONTROL_DOWN; - if (wparam & MK_SHIFT) - modifiers |= EVENTFLAG_SHIFT_DOWN; - if (isKeyDown(VK_MENU)) - modifiers |= EVENTFLAG_ALT_DOWN; - if (wparam & MK_LBUTTON) - modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON; - if (wparam & MK_MBUTTON) - modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON; - if (wparam & MK_RBUTTON) - modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON; - - // Low bit set from GetKeyState indicates "toggled". - if (::GetKeyState(VK_NUMLOCK) & 1) - modifiers |= EVENTFLAG_NUM_LOCK_ON; - if (::GetKeyState(VK_CAPITAL) & 1) - modifiers |= EVENTFLAG_CAPS_LOCK_ON; - return modifiers; -} - -int OSRWindow::GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam) { - int modifiers = 0; - if (isKeyDown(VK_SHIFT)) - modifiers |= EVENTFLAG_SHIFT_DOWN; - if (isKeyDown(VK_CONTROL)) - modifiers |= EVENTFLAG_CONTROL_DOWN; - if (isKeyDown(VK_MENU)) - modifiers |= EVENTFLAG_ALT_DOWN; - - // Low bit set from GetKeyState indicates "toggled". - if (::GetKeyState(VK_NUMLOCK) & 1) - modifiers |= EVENTFLAG_NUM_LOCK_ON; - if (::GetKeyState(VK_CAPITAL) & 1) - modifiers |= EVENTFLAG_CAPS_LOCK_ON; - - switch (wparam) { - case VK_RETURN: - if ((lparam >> 16) & KF_EXTENDED) - modifiers |= EVENTFLAG_IS_KEY_PAD; - break; - case VK_INSERT: - case VK_DELETE: - case VK_HOME: - case VK_END: - case VK_PRIOR: - case VK_NEXT: - case VK_UP: - case VK_DOWN: - case VK_LEFT: - case VK_RIGHT: - if (!((lparam >> 16) & KF_EXTENDED)) - modifiers |= EVENTFLAG_IS_KEY_PAD; - break; - case VK_NUMLOCK: - case VK_NUMPAD0: - case VK_NUMPAD1: - case VK_NUMPAD2: - case VK_NUMPAD3: - case VK_NUMPAD4: - case VK_NUMPAD5: - case VK_NUMPAD6: - case VK_NUMPAD7: - case VK_NUMPAD8: - case VK_NUMPAD9: - case VK_DIVIDE: - case VK_MULTIPLY: - case VK_SUBTRACT: - case VK_ADD: - case VK_DECIMAL: - case VK_CLEAR: - modifiers |= EVENTFLAG_IS_KEY_PAD; - break; - case VK_SHIFT: - if (isKeyDown(VK_LSHIFT)) - modifiers |= EVENTFLAG_IS_LEFT; - else if (isKeyDown(VK_RSHIFT)) - modifiers |= EVENTFLAG_IS_RIGHT; - break; - case VK_CONTROL: - if (isKeyDown(VK_LCONTROL)) - modifiers |= EVENTFLAG_IS_LEFT; - else if (isKeyDown(VK_RCONTROL)) - modifiers |= EVENTFLAG_IS_RIGHT; - break; - case VK_MENU: - if (isKeyDown(VK_LMENU)) - modifiers |= EVENTFLAG_IS_LEFT; - else if (isKeyDown(VK_RMENU)) - modifiers |= EVENTFLAG_IS_RIGHT; - break; - case VK_LWIN: - modifiers |= EVENTFLAG_IS_LEFT; - break; - case VK_RWIN: - modifiers |= EVENTFLAG_IS_RIGHT; - break; - } - return modifiers; -} - -bool OSRWindow::IsOverPopupWidget(int x, int y) const { - const CefRect& rc = renderer_.popup_rect(); - int popup_right = rc.x + rc.width; - int popup_bottom = rc.y + rc.height; - return (x >= rc.x) && (x < popup_right) && - (y >= rc.y) && (y < popup_bottom); -} - -int OSRWindow::GetPopupXOffset() const { - return renderer_.original_popup_rect().x - renderer_.popup_rect().x; -} - -int OSRWindow::GetPopupYOffset() const { - return renderer_.original_popup_rect().y - renderer_.popup_rect().y; -} - -void OSRWindow::ApplyPopupOffset(int& x, int& y) const { - if (IsOverPopupWidget(x, y)) { - x += GetPopupXOffset(); - y += GetPopupYOffset(); - } -} - -// Plugin window procedure. -// static -LRESULT CALLBACK OSRWindow::WndProc(HWND hWnd, UINT message, - WPARAM wParam, LPARAM lParam) { - static POINT lastMousePos, curMousePos; - static bool mouseRotation = false; - static bool mouseTracking = false; - - static int lastClickX = 0; - static int lastClickY = 0; - static CefBrowserHost::MouseButtonType lastClickButton = MBT_LEFT; - static int gLastClickCount = 0; - static double gLastClickTime = 0; - - static bool gLastMouseDownOnView = false; - - OSRWindow* window = - reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); - CefRefPtr browser; - if (window && window->browser_provider_->GetBrowser().get()) - browser = window->browser_provider_->GetBrowser()->GetHost(); - - LONG currentTime = 0; - bool cancelPreviousClick = false; - - if (message == WM_LBUTTONDOWN || message == WM_RBUTTONDOWN || - message == WM_MBUTTONDOWN || message == WM_MOUSEMOVE || - message == WM_MOUSELEAVE) { - currentTime = GetMessageTime(); - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - cancelPreviousClick = - (abs(lastClickX - x) > (GetSystemMetrics(SM_CXDOUBLECLK) / 2)) - || (abs(lastClickY - y) > (GetSystemMetrics(SM_CYDOUBLECLK) / 2)) - || ((currentTime - gLastClickTime) > GetDoubleClickTime()); - if (cancelPreviousClick && - (message == WM_MOUSEMOVE || message == WM_MOUSELEAVE)) { - gLastClickCount = 0; - lastClickX = 0; - lastClickY = 0; - gLastClickTime = 0; - } - } - - switch (message) { - case WM_DESTROY: - if (window) - window->OnDestroyed(); - return 0; - - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: { - SetCapture(hWnd); - SetFocus(hWnd); - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - if (wParam & MK_SHIFT) { - // Start rotation effect. - lastMousePos.x = curMousePos.x = x; - lastMousePos.y = curMousePos.y = y; - mouseRotation = true; - } else { - CefBrowserHost::MouseButtonType btnType = - (message == WM_LBUTTONDOWN ? MBT_LEFT : ( - message == WM_RBUTTONDOWN ? MBT_RIGHT : MBT_MIDDLE)); - if (!cancelPreviousClick && (btnType == lastClickButton)) { - ++gLastClickCount; - } else { - gLastClickCount = 1; - lastClickX = x; - lastClickY = y; - } - gLastClickTime = currentTime; - lastClickButton = btnType; - - if (browser.get()) { - CefMouseEvent mouse_event; - mouse_event.x = x; - mouse_event.y = y; - gLastMouseDownOnView = !window->IsOverPopupWidget(x, y); - window->ApplyPopupOffset(mouse_event.x, mouse_event.y); - mouse_event.modifiers = GetCefMouseModifiers(wParam); - browser->SendMouseClickEvent(mouse_event, btnType, false, - gLastClickCount); - } - } - break; - } - - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MBUTTONUP: - if (GetCapture() == hWnd) - ReleaseCapture(); - if (mouseRotation) { - // End rotation effect. - mouseRotation = false; - window->renderer_.SetSpin(0, 0); - window->Invalidate(); - } else { - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - CefBrowserHost::MouseButtonType btnType = - (message == WM_LBUTTONUP ? MBT_LEFT : ( - message == WM_RBUTTONUP ? MBT_RIGHT : MBT_MIDDLE)); - if (browser.get()) { - CefMouseEvent mouse_event; - mouse_event.x = x; - mouse_event.y = y; - if (gLastMouseDownOnView && - window->IsOverPopupWidget(x, y) && - (window->GetPopupXOffset() || window->GetPopupYOffset())) { - break; - } - window->ApplyPopupOffset(mouse_event.x, mouse_event.y); - mouse_event.modifiers = GetCefMouseModifiers(wParam); - browser->SendMouseClickEvent(mouse_event, btnType, true, - gLastClickCount); - } - } - break; - - case WM_MOUSEMOVE: { - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - if (mouseRotation) { - // Apply rotation effect. - curMousePos.x = x; - curMousePos.y = y; - window->renderer_.IncrementSpin((curMousePos.x - lastMousePos.x), - (curMousePos.y - lastMousePos.y)); - lastMousePos.x = curMousePos.x; - lastMousePos.y = curMousePos.y; - window->Invalidate(); - } else { - if (!mouseTracking) { - // Start tracking mouse leave. Required for the WM_MOUSELEAVE event to - // be generated. - TRACKMOUSEEVENT tme; - tme.cbSize = sizeof(TRACKMOUSEEVENT); - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = hWnd; - TrackMouseEvent(&tme); - mouseTracking = true; - } - if (browser.get()) { - CefMouseEvent mouse_event; - mouse_event.x = x; - mouse_event.y = y; - window->ApplyPopupOffset(mouse_event.x, mouse_event.y); - mouse_event.modifiers = GetCefMouseModifiers(wParam); - browser->SendMouseMoveEvent(mouse_event, false); - } - } - break; - } - - case WM_MOUSELEAVE: - if (mouseTracking) { - // Stop tracking mouse leave. - TRACKMOUSEEVENT tme; - tme.cbSize = sizeof(TRACKMOUSEEVENT); - tme.dwFlags = TME_LEAVE & TME_CANCEL; - tme.hwndTrack = hWnd; - TrackMouseEvent(&tme); - mouseTracking = false; - } - if (browser.get()) { - CefMouseEvent mouse_event; - mouse_event.x = 0; - mouse_event.y = 0; - mouse_event.modifiers = GetCefMouseModifiers(wParam); - browser->SendMouseMoveEvent(mouse_event, true); - } - break; - - case WM_MOUSEWHEEL: - if (browser.get()) { - POINT screen_point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; - HWND scrolled_wnd = ::WindowFromPoint(screen_point); - if (scrolled_wnd != hWnd) { - break; - } - ScreenToClient(hWnd, &screen_point); - int delta = GET_WHEEL_DELTA_WPARAM(wParam); - - CefMouseEvent mouse_event; - mouse_event.x = screen_point.x; - mouse_event.y = screen_point.y; - window->ApplyPopupOffset(mouse_event.x, mouse_event.y); - mouse_event.modifiers = GetCefMouseModifiers(wParam); - - browser->SendMouseWheelEvent(mouse_event, - isKeyDown(VK_SHIFT) ? delta : 0, - !isKeyDown(VK_SHIFT) ? delta : 0); - } - break; - - case WM_SIZE: - if (browser.get()) - browser->WasResized(); - break; - - case WM_SETFOCUS: - case WM_KILLFOCUS: - if (browser.get()) - browser->SendFocusEvent(message == WM_SETFOCUS); - break; - - case WM_CAPTURECHANGED: - case WM_CANCELMODE: - if (!mouseRotation) { - if (browser.get()) - browser->SendCaptureLostEvent(); - } - break; - case WM_SYSCHAR: - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - case WM_KEYDOWN: - case WM_KEYUP: - case WM_CHAR: { - CefKeyEvent event; - event.windows_key_code = wParam; - event.native_key_code = lParam; - event.is_system_key = message == WM_SYSCHAR || - message == WM_SYSKEYDOWN || - message == WM_SYSKEYUP; - - if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN) - event.type = KEYEVENT_RAWKEYDOWN; - else if (message == WM_KEYUP || message == WM_SYSKEYUP) - event.type = KEYEVENT_KEYUP; - else - event.type = KEYEVENT_CHAR; - event.modifiers = GetCefKeyboardModifiers(wParam, lParam); - if (browser.get()) - browser->SendKeyEvent(event); - break; - } - - case WM_PAINT: { - PAINTSTRUCT ps; - RECT rc; - BeginPaint(hWnd, &ps); - rc = ps.rcPaint; - EndPaint(hWnd, &ps); - if (browser.get()) { - browser->Invalidate(CefRect(rc.left, - rc.top, - rc.right - rc.left, - rc.bottom - rc.top), PET_VIEW); - } - return 0; - } - - case WM_ERASEBKGND: - return 0; - } - - return DefWindowProc(hWnd, message, wParam, lParam); -} diff --git a/tests/cefclient/cefclient_osr_widget_win.h b/tests/cefclient/cefclient_osr_widget_win.h deleted file mode 100644 index 8b04541d..00000000 --- a/tests/cefclient/cefclient_osr_widget_win.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license that -// can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_WIN_H_ -#define CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_WIN_H_ -#pragma once - -#include "include/cef_render_handler.h" -#include "cefclient/client_handler.h" -#include "cefclient/osrenderer.h" - -class OSRBrowserProvider { - public: - virtual CefRefPtr GetBrowser() =0; - - protected: - virtual ~OSRBrowserProvider() {} -}; - -class OSRWindow : public ClientHandler::RenderHandler { - public: - // Create a new OSRWindow instance. |browser_provider| must outlive this - // object. - static CefRefPtr Create(OSRBrowserProvider* browser_provider, - bool transparent); - - static CefRefPtr From( - CefRefPtr renderHandler); - - // Create the underlying window. - bool CreateWidget(HWND hWndParent, const RECT& rect, - HINSTANCE hInst, LPCTSTR className); - - // Destroy the underlying window. - void DestroyWidget(); - - HWND hwnd() const { - return hWnd_; - } - - // ClientHandler::RenderHandler methods - virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; - - // CefRenderHandler methods - virtual bool GetRootScreenRect(CefRefPtr browser, - CefRect& rect) OVERRIDE; - virtual bool GetViewRect(CefRefPtr browser, - CefRect& rect) OVERRIDE; - virtual bool GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) OVERRIDE; - virtual void OnPopupShow(CefRefPtr browser, - bool show) OVERRIDE; - virtual void OnPopupSize(CefRefPtr browser, - const CefRect& rect) OVERRIDE; - virtual void OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, - int height) OVERRIDE; - virtual void OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) OVERRIDE; - - void Invalidate(); - - private: - OSRWindow(OSRBrowserProvider* browser_provider, bool transparent); - virtual ~OSRWindow(); - - void Render(); - void EnableGL(); - void DisableGL(); - void OnDestroyed(); - static ATOM RegisterOSRClass(HINSTANCE hInstance, LPCTSTR className); - static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, - LPARAM lParam); - static int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam); - static int GetCefMouseModifiers(WPARAM wparam); - static bool isKeyDown(WPARAM wparam); - bool IsOverPopupWidget(int x, int y) const; - int GetPopupXOffset() const; - int GetPopupYOffset() const; - void ApplyPopupOffset(int& x, int& y) const; - - ClientOSRenderer renderer_; - OSRBrowserProvider* browser_provider_; - HWND hWnd_; - HDC hDC_; - HGLRC hRC_; - - bool painting_popup_; - bool render_task_pending_; - - IMPLEMENT_REFCOUNTING(OSRWindow); -}; - -#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_OSR_WIDGET_WIN_H_ diff --git a/tests/cefclient/cefclient_win.cpp b/tests/cefclient/cefclient_win.cpp index 5320244e..4e11f54d 100644 --- a/tests/cefclient/cefclient_win.cpp +++ b/tests/cefclient/cefclient_win.cpp @@ -14,7 +14,6 @@ #include "include/cef_frame.h" #include "include/cef_runnable.h" #include "include/cef_sandbox_win.h" -#include "cefclient/cefclient_osr_widget_win.h" #include "cefclient/client_handler.h" #include "cefclient/client_switches.h" #include "cefclient/resource.h" @@ -61,15 +60,6 @@ LRESULT CALLBACK MessageWndProc(HWND, UINT, WPARAM, LPARAM); // The global ClientHandler reference. extern CefRefPtr g_handler; -class MainBrowserProvider : public OSRBrowserProvider { - virtual CefRefPtr GetBrowser() { - if (g_handler.get()) - return g_handler->GetBrowser(); - - return NULL; - } -} g_main_browser_provider; - // Program entry point function. int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -386,20 +376,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, CefWindowInfo info; CefBrowserSettings settings; - if (AppIsOffScreenRenderingEnabled()) { - CefRefPtr cmd_line = AppGetCommandLine(); - bool transparent = - cmd_line->HasSwitch(cefclient::kTransparentPaintingEnabled); - - CefRefPtr osr_window = - OSRWindow::Create(&g_main_browser_provider, transparent); - osr_window->CreateWidget(hWnd, rect, hInst, szOSRWindowClass); - info.SetAsWindowless(osr_window->hwnd(), transparent); - g_handler->SetOSRHandler(osr_window.get()); - } else { - // Initialize window info to the defaults for a child window. - info.SetAsChild(hWnd, rect); - } + // Initialize window info to the defaults for a child window. + info.SetAsChild(hWnd, rect); // Creat the new child browser window CefBrowserHost::CreateBrowser(info, g_handler.get(), diff --git a/tests/cefclient/client_handler.cpp b/tests/cefclient/client_handler.cpp index 4668bf7f..b1629df3 100644 --- a/tests/cefclient/client_handler.cpp +++ b/tests/cefclient/client_handler.cpp @@ -279,22 +279,6 @@ bool ClientHandler::OnPreKeyEvent(CefRefPtr browser, return false; } -bool ClientHandler::OnBeforePopup(CefRefPtr browser, - CefRefPtr frame, - const CefString& target_url, - const CefString& target_frame_name, - const CefPopupFeatures& popupFeatures, - CefWindowInfo& windowInfo, - CefRefPtr& client, - CefBrowserSettings& settings, - bool* no_javascript_access) { - if (browser->GetHost()->IsWindowRenderingDisabled()) { - // Cancel popups in off-screen rendering mode. - return true; - } - return false; -} - void ClientHandler::OnAfterCreated(CefRefPtr browser) { REQUIRE_UI_THREAD(); @@ -351,11 +335,6 @@ void ClientHandler::OnBeforeClose(CefRefPtr browser) { if (m_BrowserId == browser->GetIdentifier()) { // Free the browser pointer so that the browser can be destroyed m_Browser = NULL; - - if (m_OSRHandler.get()) { - m_OSRHandler->OnBeforeClose(browser); - m_OSRHandler = NULL; - } } else if (browser->IsPopup()) { // Remove from the browser popup list. BrowserList::iterator bit = m_PopupBrowsers.begin(); @@ -506,68 +485,6 @@ void ClientHandler::OnRenderProcessTerminated(CefRefPtr browser, } } -bool ClientHandler::GetRootScreenRect(CefRefPtr browser, - CefRect& rect) { - if (!m_OSRHandler.get()) - return false; - return m_OSRHandler->GetRootScreenRect(browser, rect); -} - -bool ClientHandler::GetViewRect(CefRefPtr browser, CefRect& rect) { - if (!m_OSRHandler.get()) - return false; - return m_OSRHandler->GetViewRect(browser, rect); -} - -bool ClientHandler::GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) { - if (!m_OSRHandler.get()) - return false; - return m_OSRHandler->GetScreenPoint(browser, viewX, viewY, screenX, screenY); -} - -bool ClientHandler::GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) { - if (!m_OSRHandler.get()) - return false; - return m_OSRHandler->GetScreenInfo(browser, screen_info); -} - -void ClientHandler::OnPopupShow(CefRefPtr browser, - bool show) { - if (!m_OSRHandler.get()) - return; - return m_OSRHandler->OnPopupShow(browser, show); -} - -void ClientHandler::OnPopupSize(CefRefPtr browser, - const CefRect& rect) { - if (!m_OSRHandler.get()) - return; - return m_OSRHandler->OnPopupSize(browser, rect); -} - -void ClientHandler::OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, - int height) { - if (!m_OSRHandler.get()) - return; - m_OSRHandler->OnPaint(browser, type, dirtyRects, buffer, width, height); -} - -void ClientHandler::OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) { - if (!m_OSRHandler.get()) - return; - m_OSRHandler->OnCursorChange(browser, cursor); -} - void ClientHandler::SetMainHwnd(CefWindowHandle hwnd) { AutoLock lock_scope(this); m_MainHwnd = hwnd; diff --git a/tests/cefclient/client_handler.h b/tests/cefclient/client_handler.h index c828e1ef..ee6d1f47 100644 --- a/tests/cefclient/client_handler.h +++ b/tests/cefclient/client_handler.h @@ -30,15 +30,8 @@ class ClientHandler : public CefClient, public CefKeyboardHandler, public CefLifeSpanHandler, public CefLoadHandler, - public CefRenderHandler, public CefRequestHandler { public: - // Interface implemented to handle off-screen rendering. - class RenderHandler : public CefRenderHandler { - public: - virtual void OnBeforeClose(CefRefPtr browser) =0; - }; - typedef std::set MessageHandlerSet; ClientHandler(); @@ -69,9 +62,6 @@ class ClientHandler : public CefClient, virtual CefRefPtr GetLoadHandler() OVERRIDE { return this; } - virtual CefRefPtr GetRenderHandler() OVERRIDE { - return this; - } virtual CefRefPtr GetRequestHandler() OVERRIDE { return this; } @@ -132,15 +122,6 @@ class ClientHandler : public CefClient, bool* is_keyboard_shortcut) OVERRIDE; // CefLifeSpanHandler methods - virtual bool OnBeforePopup(CefRefPtr browser, - CefRefPtr frame, - const CefString& target_url, - const CefString& target_frame_name, - const CefPopupFeatures& popupFeatures, - CefWindowInfo& windowInfo, - CefRefPtr& client, - CefBrowserSettings& settings, - bool* no_javascript_access) OVERRIDE; virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; virtual bool DoClose(CefRefPtr browser) OVERRIDE; virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; @@ -175,37 +156,9 @@ class ClientHandler : public CefClient, virtual void OnRenderProcessTerminated(CefRefPtr browser, TerminationStatus status) OVERRIDE; - // CefRenderHandler methods - virtual bool GetRootScreenRect(CefRefPtr browser, - CefRect& rect) OVERRIDE; - virtual bool GetViewRect(CefRefPtr browser, - CefRect& rect) OVERRIDE; - virtual bool GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) OVERRIDE; - virtual bool GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) OVERRIDE; - virtual void OnPopupShow(CefRefPtr browser, bool show) OVERRIDE; - virtual void OnPopupSize(CefRefPtr browser, - const CefRect& rect) OVERRIDE; - virtual void OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, - int height) OVERRIDE; - virtual void OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) OVERRIDE; - void SetMainHwnd(CefWindowHandle hwnd); CefWindowHandle GetMainHwnd() { return m_MainHwnd; } void SetEditHwnd(CefWindowHandle hwnd); - void SetOSRHandler(CefRefPtr handler) { - m_OSRHandler = handler; - } - CefRefPtr GetOSRHandler() { return m_OSRHandler; } void SetButtonHwnds(CefWindowHandle backHwnd, CefWindowHandle forwardHwnd, CefWindowHandle reloadHwnd, @@ -293,8 +246,6 @@ class ClientHandler : public CefClient, CefWindowHandle m_StopHwnd; CefWindowHandle m_ReloadHwnd; - CefRefPtr m_OSRHandler; - // Support for logging. std::string m_LogFile; diff --git a/tests/cefclient/client_switches.cpp b/tests/cefclient/client_switches.cpp index 2a946cd9..ea1e39cc 100644 --- a/tests/cefclient/client_switches.cpp +++ b/tests/cefclient/client_switches.cpp @@ -21,8 +21,6 @@ namespace cefclient { const char kMultiThreadedMessageLoop[] = "multi-threaded-message-loop"; const char kCachePath[] = "cache-path"; const char kUrl[] = "url"; -const char kOffScreenRenderingEnabled[] = "off-screen-rendering-enabled"; -const char kTransparentPaintingEnabled[] = "transparent-painting-enabled"; const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled"; } // namespace cefclient diff --git a/tests/cefclient/client_switches.h b/tests/cefclient/client_switches.h index 2bd4b768..3ec370a1 100644 --- a/tests/cefclient/client_switches.h +++ b/tests/cefclient/client_switches.h @@ -13,8 +13,6 @@ namespace cefclient { extern const char kMultiThreadedMessageLoop[]; extern const char kCachePath[]; extern const char kUrl[]; -extern const char kOffScreenRenderingEnabled[]; -extern const char kTransparentPaintingEnabled[]; extern const char kMouseCursorChangeDisabled[]; } // namespace cefclient diff --git a/tests/cefclient/osrenderer.cpp b/tests/cefclient/osrenderer.cpp deleted file mode 100644 index a8c0dda3..00000000 --- a/tests/cefclient/osrenderer.cpp +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework 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 "cefclient/osrenderer.h" - -#if defined(OS_WIN) -#include -#include -#elif defined(OS_MACOSX) -#include -#elif defined(OS_LINUX) -#include -#include -#else -#error Platform is not supported. -#endif - -#include "cefclient/util.h" - -#ifndef GL_BGR -#define GL_BGR 0x80E0 -#endif -#ifndef GL_BGRA -#define GL_BGRA 0x80E1 -#endif -#ifndef GL_UNSIGNED_INT_8_8_8_8_REV -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#endif - - -ClientOSRenderer::ClientOSRenderer(bool transparent) - : transparent_(transparent), - initialized_(false), - texture_id_(0), - view_width_(0), - view_height_(0), - spin_x_(0), - spin_y_(0) { -} - -ClientOSRenderer::~ClientOSRenderer() { - Cleanup(); -} - -void ClientOSRenderer::Initialize() { - if (initialized_) - return; - - glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); - - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - - // Necessary for non-power-of-2 textures to render correctly. - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - // Create the texture. - glGenTextures(1, &texture_id_); - ASSERT(texture_id_ != 0); - - glBindTexture(GL_TEXTURE_2D, texture_id_); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - initialized_ = true; -} - -void ClientOSRenderer::Cleanup() { - if (texture_id_ != 0) - glDeleteTextures(1, &texture_id_); -} - -void ClientOSRenderer::Render() { - if (view_width_ == 0 || view_height_ == 0) - return; - - ASSERT(initialized_); - - struct { - float tu, tv; - float x, y, z; - } static vertices[] = { - {0.0f, 1.0f, -1.0f, -1.0f, 0.0f}, - {1.0f, 1.0f, 1.0f, -1.0f, 0.0f}, - {1.0f, 0.0f, 1.0f, 1.0f, 0.0f}, - {0.0f, 0.0f, -1.0f, 1.0f, 0.0f} - }; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - // Match GL units to screen coordinates. - glViewport(0, 0, view_width_, view_height_); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 0, view_width_, view_height_, 0.1, 100.0); - - // Draw the background gradient. - glPushAttrib(GL_ALL_ATTRIB_BITS); - glBegin(GL_QUADS); - glColor4f(1.0, 0.0, 0.0, 1.0); // red - glVertex2f(-1.0, -1.0); - glVertex2f(1.0, -1.0); - glColor4f(0.0, 0.0, 1.0, 1.0); // blue - glVertex2f(1.0, 1.0); - glVertex2f(-1.0, 1.0); - glEnd(); - glPopAttrib(); - - // Rotate the view based on the mouse spin. - if (spin_x_ != 0) - glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f); - if (spin_y_ != 0) - glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f); - - if (transparent_) { - // Alpha blending style. Texture values have premultiplied alpha. - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - - // Enable alpha blending. - glEnable(GL_BLEND); - } - - // Enable 2D textures. - glEnable(GL_TEXTURE_2D); - - // Draw the facets with the texture. - ASSERT(texture_id_ != 0); - glBindTexture(GL_TEXTURE_2D, texture_id_); - glInterleavedArrays(GL_T2F_V3F, 0, vertices); - glDrawArrays(GL_QUADS, 0, 4); - - // Disable 2D textures. - glDisable(GL_TEXTURE_2D); - - if (transparent_) { - // Disable alpha blending. - glDisable(GL_BLEND); - } -} - -void ClientOSRenderer::OnPopupShow(CefRefPtr browser, - bool show) { - if (!show) { - // Clear the popup rectangle. - ClearPopupRects(); - } -} - -void ClientOSRenderer::OnPopupSize(CefRefPtr browser, - const CefRect& rect) { - if (rect.width <= 0 || rect.height <= 0) - return; - original_popup_rect_ = rect; - popup_rect_ = GetPopupRectInWebView(original_popup_rect_); -} - -CefRect ClientOSRenderer::GetPopupRectInWebView(const CefRect& original_rect) { - CefRect rc(original_rect); - // if x or y are negative, move them to 0. - if (rc.x < 0) - rc.x = 0; - if (rc.y < 0) - rc.y = 0; - // if popup goes outside the view, try to reposition origin - if (rc.x + rc.width > view_width_) - rc.x = view_width_ - rc.width; - if (rc.y + rc.height > view_height_) - rc.y = view_height_ - rc.height; - // if x or y became negative, move them to 0 again. - if (rc.x < 0) - rc.x = 0; - if (rc.y < 0) - rc.y = 0; - return rc; -} - -void ClientOSRenderer::ClearPopupRects() { - popup_rect_.Set(0, 0, 0, 0); - original_popup_rect_.Set(0, 0, 0, 0); -} - -void ClientOSRenderer::OnPaint(CefRefPtr browser, - CefRenderHandler::PaintElementType type, - const CefRenderHandler::RectList& dirtyRects, - const void* buffer, int width, int height) { - if (!initialized_) - Initialize(); - - if (transparent_) { - // Enable alpha blending. - glEnable(GL_BLEND); - } - - // Enable 2D textures. - glEnable(GL_TEXTURE_2D); - - ASSERT(texture_id_ != 0); - glBindTexture(GL_TEXTURE_2D, texture_id_); - - if (type == PET_VIEW) { - int old_width = view_width_; - int old_height = view_height_; - - view_width_ = width; - view_height_ = height; - - glPixelStorei(GL_UNPACK_ROW_LENGTH, view_width_); - - if (old_width != view_width_ || old_height != view_height_) { - // Update/resize the whole texture. - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, view_width_, view_height_, 0, - GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); - } else { - // Update just the dirty rectangles. - CefRenderHandler::RectList::const_iterator i = dirtyRects.begin(); - for (; i != dirtyRects.end(); ++i) { - const CefRect& rect = *i; - glPixelStorei(GL_UNPACK_SKIP_PIXELS, rect.x); - glPixelStorei(GL_UNPACK_SKIP_ROWS, rect.y); - glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x, rect.y, rect.width, - rect.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, - buffer); - } - } - } else if (type == PET_POPUP && popup_rect_.width > 0 && - popup_rect_.height > 0) { - int skip_pixels = 0, x = popup_rect_.x; - int skip_rows = 0, y = popup_rect_.y; - int w = width; - int h = height; - - // Adjust the popup to fit inside the view. - if (x < 0) { - skip_pixels = -x; - x = 0; - } - if (y < 0) { - skip_rows = -y; - y = 0; - } - if (x + w > view_width_) - w -= x + w - view_width_; - if (y + h > view_height_) - h -= y + h - view_height_; - - // Update the popup rectangle. - glPixelStorei(GL_UNPACK_ROW_LENGTH, width); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_BGRA, - GL_UNSIGNED_INT_8_8_8_8_REV, buffer); - } - - // Disable 2D textures. - glDisable(GL_TEXTURE_2D); - - if (transparent_) { - // Disable alpha blending. - glDisable(GL_BLEND); - } -} - -void ClientOSRenderer::SetSpin(float spinX, float spinY) { - spin_x_ = spinX; - spin_y_ = spinY; -} - -void ClientOSRenderer::IncrementSpin(float spinDX, float spinDY) { - spin_x_ -= spinDX; - spin_y_ -= spinDY; -} diff --git a/tests/cefclient/osrenderer.h b/tests/cefclient/osrenderer.h deleted file mode 100644 index 7bf585a3..00000000 --- a/tests/cefclient/osrenderer.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file. - -#ifndef CEF_TESTS_CEFCLIENT_OSRENDERER_H_ -#define CEF_TESTS_CEFCLIENT_OSRENDERER_H_ -#pragma once - -#include "include/cef_browser.h" -#include "include/cef_render_handler.h" - -class ClientOSRenderer { - public: - // The context must outlive this object. - explicit ClientOSRenderer(bool transparent); - virtual ~ClientOSRenderer(); - - // Initialize the OpenGL environment. - void Initialize(); - - // Clean up the OpenGL environment. - void Cleanup(); - - // Render to the screen. - void Render(); - - // Forwarded from CefRenderHandler callbacks. - void OnPopupShow(CefRefPtr browser, - bool show); - void OnPopupSize(CefRefPtr browser, - const CefRect& rect); - void OnPaint(CefRefPtr browser, - CefRenderHandler::PaintElementType type, - const CefRenderHandler::RectList& dirtyRects, - const void* buffer, int width, int height); - - // Apply spin. - void SetSpin(float spinX, float spinY); - void IncrementSpin(float spinDX, float spinDY); - - bool IsTransparent() { return transparent_; } - - int GetViewWidth() { return view_width_; } - int GetViewHeight() { return view_height_; } - - const CefRect& popup_rect() const { return popup_rect_; } - const CefRect& original_popup_rect() const { return original_popup_rect_; } - - CefRect GetPopupRectInWebView(const CefRect& original_rect); - void ClearPopupRects(); - - private: - bool transparent_; - bool initialized_; - unsigned int texture_id_; - int view_width_; - int view_height_; - CefRect popup_rect_; - CefRect original_popup_rect_; - float spin_x_; - float spin_y_; -}; - -#endif // CEF_TESTS_CEFCLIENT_OSRENDERER_H_ - diff --git a/tests/cefclient/res/osr_test.html b/tests/cefclient/res/osr_test.html deleted file mode 100644 index 4347fadb..00000000 --- a/tests/cefclient/res/osr_test.html +++ /dev/null @@ -1,66 +0,0 @@ - - OSR Test - - - -

- OSR Testing h1 - Focus and blur - - this page and will get this red black -

-
    -
  1. OnPaint should be called each time a page loads
  2. -
  3. Move mouse - to require an OnCursorChange call
  4. -
  5. Hover will color this with - red. Will trigger OnPaint once on enter and once on leave
  6. -
  7. Right clicking will show contextual menu and will request - GetScreenPoint
  8. -
  9. IsWindowRenderingDisabled should be true
  10. -
  11. WasResized should trigger full repaint if size changes. -
  12. -
  13. Invalidate should trigger OnPaint once
  14. -
  15. Click and write here with SendKeyEvent to trigger repaints: -
  16. -
  17. Click here with SendMouseClickEvent to navigate: -
  18. -
  19. Mouse over this element will - trigger show a tooltip
  20. -
-
-
-
-
-
-
- - diff --git a/tests/cefclient/resource.h b/tests/cefclient/resource.h index d7a19f12..827e1900 100644 --- a/tests/cefclient/resource.h +++ b/tests/cefclient/resource.h @@ -46,13 +46,12 @@ #define IDS_LOCALSTORAGE 1003 #define IDS_LOGO 1004 #define IDS_LOGOBALL 1005 -#define IDS_OSRTEST 1006 -#define IDS_OTHER_TESTS 1007 -#define IDS_PERFORMANCE 1008 -#define IDS_TRANSPARENCY 1009 -#define IDS_WINDOW 1010 -#define IDS_XMLHTTPREQUEST 1011 -#define IDS_PERFORMANCE2 1012 +#define IDS_OTHER_TESTS 1006 +#define IDS_PERFORMANCE 1007 +#define IDS_TRANSPARENCY 1008 +#define IDS_WINDOW 1009 +#define IDS_XMLHTTPREQUEST 1010 +#define IDS_PERFORMANCE2 1011 // Avoid files associated with MacOS #define _X86_ diff --git a/tests/cefclient/resource_util_win.cpp b/tests/cefclient/resource_util_win.cpp index 114ca4bc..0a80acc5 100644 --- a/tests/cefclient/resource_util_win.cpp +++ b/tests/cefclient/resource_util_win.cpp @@ -38,7 +38,6 @@ int GetResourceId(const char* resource_name) { {"domaccess.html", IDS_DOMACCESS}, {"localstorage.html", IDS_LOCALSTORAGE}, {"logo.png", IDS_LOGO}, - {"osr_test.html", IDS_OSRTEST}, {"other_tests.html", IDS_OTHER_TESTS}, {"performance.html", IDS_PERFORMANCE}, {"performance2.html", IDS_PERFORMANCE2}, diff --git a/tests/unittests/os_rendering_unittest.cc b/tests/unittests/os_rendering_unittest.cc deleted file mode 100644 index 0b8ac799..00000000 --- a/tests/unittests/os_rendering_unittest.cc +++ /dev/null @@ -1,950 +0,0 @@ -// Copyright (c) 2012 The Chromium Embedded Framework 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 "include/cef_runnable.h" -#include "include/cef_v8.h" -#include "include/wrapper/cef_stream_resource_handler.h" - -#include "tests/cefclient/client_app.h" -#include "tests/cefclient/resource_util.h" -#include "tests/unittests/routing_test_handler.h" - -#include "base/logging.h" -#include "ui/events/keycodes/keyboard_codes.h" -#include "ui/events/keycodes/keyboard_code_conversion.h" - -#if defined(OS_MACOSX) -#include "tests/unittests/os_rendering_unittest_mac.h" -#elif defined(OS_LINUX) -#include -#elif defined(OS_WIN) -// Required for resource_util_win, which uses this as an extern -HINSTANCE hInst = ::GetModuleHandle(NULL); -#endif - -namespace { - -const char kTestUrl[] = "http://tests/osrtest"; - -// this html should render on a 600 x 400 window with a little vertical -// offset with scrollbar. - -// #define DEBUGGER_ATTACHED - -// default osr widget size -const int kOsrWidth = 600; -const int kOsrHeight = 400; - -// precomputed bounding client rects for html elements (h1 and li). -#if defined(OS_WIN) || defined(OS_LINUX) -const CefRect kExpectedRectLI[] = { - CefRect(8, 8, 567, 74), // LI00 - CefRect(27, 103, 548, 20), // LI01 - CefRect(27, 123, 548, 20), // LI02 - CefRect(27, 143, 548, 20), // LI03 - CefRect(27, 163, 548, 20), // LI04 - CefRect(27, 183, 548, 20), // LI05 - CefRect(27, 203, 548, 20), // LI06 - CefRect(27, 223, 548, 20), // LI07 - CefRect(27, 243, 548, 26), // LI08 - CefRect(27, 269, 548, 26), // LI09 - CefRect(27, 295, 548, 20), // LI10 -}; -#elif defined(OS_MACOSX) -const CefRect kExpectedRectLI[] = { - CefRect(8, 8, 584, 74), // LI00 - CefRect(28, 103, 564, 18), // LI01 - CefRect(28, 121, 564, 18), // LI02 - CefRect(28, 139, 564, 18), // LI03 - CefRect(28, 157, 564, 18), // LI04 - CefRect(28, 175, 564, 18), // LI05 - CefRect(28, 193, 564, 18), // LI06 - CefRect(28, 211, 564, 18), // LI07 - CefRect(28, 229, 564, 23), // LI08 - CefRect(28, 252, 564, 26), // LI09 - CefRect(20, 278, 572, 18), // LI10 -}; -#else -#error "Unsupported platform" -#endif // defined(OS_WIN) - -// bounding client rects for edit box and navigate button -#if defined(OS_WIN) -const CefRect kEditBoxRect(412, 245, 60, 22); -const CefRect kNavigateButtonRect(360, 271, 140, 22); -const CefRect kSelectRect(467, 22, 75, 20); -const CefRect kExpandedSelectRect(467, 42, 81, 322); -const int kDefaultVerticalScrollbarWidth = 17; -const int kVerticalScrollbarWidth = GetSystemMetrics(SM_CXVSCROLL); -const int kHorizontalScrollbarWidth = GetSystemMetrics(SM_CXHSCROLL); -#elif defined(OS_MACOSX) -const CefRect kEditBoxRect(429, 228, 60, 25); -const CefRect kNavigateButtonRect(375, 251, 138, 28); -const CefRect kSelectRect(461, 21, 87, 26); -const CefRect kExpandedSelectRect(467, 42, 80, 262); -#elif defined(OS_LINUX) -const CefRect kEditBoxRect(434, 246, 60, 20); -const CefRect kNavigateButtonRect(380, 271, 140, 22); -const CefRect kSelectRect(467, 22, 75, 20); -const CefRect kExpandedSelectRect(467, 42, 79, 322); -const int kDefaultVerticalScrollbarWidth = 14; -const int kVerticalScrollbarWidth = 14; -const int kHorizontalScrollbarWidth = 14; -#else -#error "Unsupported platform" -#endif // defined(OS_WIN) - -// adjusted expected rect regarding system vertical scrollbar width -CefRect ExpectedRect(int index) { -#if defined(OS_WIN) || defined(OS_LINUX) - // this is the scrollbar width for all the kExpectedRectLI - if (kDefaultVerticalScrollbarWidth == kVerticalScrollbarWidth) - return kExpectedRectLI[index]; - - CefRect adjustedRect(kExpectedRectLI[index]); - adjustedRect.width += kDefaultVerticalScrollbarWidth - - kVerticalScrollbarWidth; - return adjustedRect; -#elif defined(OS_MACOSX) - return kExpectedRectLI[index]; -#else -#error "Unsupported platform" -#endif -} - -// word to be written into edit box -const char kKeyTestWord[] = "done"; - -#if defined(OS_MACOSX) -const ui::KeyboardCode kKeyTestCodes[] = { - ui::VKEY_D, - ui::VKEY_O, - ui::VKEY_N, - ui::VKEY_E -}; -#elif defined(OS_LINUX) -const unsigned int kKeyTestCodes[] = { - XK_d, - XK_o, - XK_n, - XK_e -}; -#endif - -// width for the icon that appear on the screen when pressing -// middle mouse button -const int kMiddleButtonIconWidth = 16; - -// test type -enum OSRTestType { - // IsWindowRenderingDisabled should be true - OSR_TEST_IS_WINDOWLESS, - // focusing webview, LI00 will get red & repainted - OSR_TEST_FOCUS, - // loading webview should trigger a full paint (L01) - OSR_TEST_PAINT, - // same as OSR_TEST_PAINT but with alpha values - OSR_TEST_TRANSPARENCY, - // moving mouse over L02, OnCursorChange will be called - OSR_TEST_CURSOR, - // moving mouse on L03, OnPaint will be called for its bounding rectangle - OSR_TEST_MOUSE_MOVE, - // right clicking an element (L04), OnBeforeContextMenu should be called - OSR_TEST_CLICK_RIGHT, - // right clicking an element (L04), context menu will query screen point - OSR_TEST_SCREEN_POINT, - // left click in text box should query repainting edit box area - OSR_TEST_CLICK_LEFT, - // clicking middle mouse button, will draw the scroll icon - OSR_TEST_CLICK_MIDDLE, - // Resize should trigger a full repaint with the new given size - OSR_TEST_RESIZE, - // Invalidate should trigger repaint synchronously - OSR_TEST_INVALIDATE, - // write into editbox LI08, click to navigate on LI09 - OSR_TEST_KEY_EVENTS, - // mouse over LI10 will show a tooltip - OSR_TEST_TOOLTIP, - // mouse wheel will trigger a scroll event - OSR_TEST_SCROLLING, - // Right click will trigger a context menu, and on destroying the test, it - // should not crash - OSR_TEST_CONTEXT_MENU, - // clicking on dropdown box, PET_POPUP OnPaint is triggered - OSR_TEST_POPUP_PAINT, - // clicking on dropdown box, a popup will show up - OSR_TEST_POPUP_SHOW, - // clicking on dropdown box, OnPopupSize should be called - OSR_TEST_POPUP_SIZE, - // taking focus away from the webview, will close popup - OSR_TEST_POPUP_HIDE_ON_BLUR, - // clicking outside the popup widget will close popup - OSR_TEST_POPUP_HIDE_ON_CLICK, - // scrolling outside the popup widget will close popup - OSR_TEST_POPUP_HIDE_ON_SCROLL, - // pressing ESC will close popup - OSR_TEST_POPUP_HIDE_ON_ESC, - // scrolling inside the popup should trigger repaint for popup area - OSR_TEST_POPUP_SCROLL_INSIDE, -}; - -// Used in the browser process. -class OSRTestHandler : public RoutingTestHandler, - public CefRenderHandler, - public CefContextMenuHandler { - public: - explicit OSRTestHandler(OSRTestType test) - : test_type_(test), - event_count_(0), - event_total_(1), - started_(false) { - if (test == OSR_TEST_SCROLLING) { - // Wait for both the paint event and the scroll offset event. - event_total_ = 2; - } - } - - virtual ~OSRTestHandler() {} - - // TestHandler methods - virtual void RunTest() OVERRIDE { - CreateOSRBrowser(kTestUrl); -#if !defined(DEBUGGER_ATTACHED) - // Each test has a 5 second timeout. After this timeout it will be destroyed - // and the test will fail. DestroyTest will be called at the timeout even - // if the test is already destroyed and this is fine. - CefPostDelayedTask(TID_UI, NewCefRunnableMethod(this, - &OSRTestHandler::DestroyTest), 5000); -#endif // DEBUGGER_ATTACHED - } - - virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE { - if (test_type_ == OSR_TEST_IS_WINDOWLESS) { - EXPECT_TRUE(browser->GetHost()->IsWindowRenderingDisabled()); - DestroySucceededTestSoon(); - } - RoutingTestHandler::OnAfterCreated(browser); - } - - virtual void OnLoadEnd(CefRefPtr browser, - CefRefPtr frame, - int httpStatusCode) OVERRIDE { - if (!started()) - return; - - switch(test_type_) { - case OSR_TEST_KEY_EVENTS: { - const std::string& expected_url = - std::string(kTestUrl) + "?k=" + kKeyTestWord; - EXPECT_STREQ(expected_url.c_str(), - frame->GetURL().ToString().c_str()); - DestroySucceededTestSoon(); - } break; - default: - // Intentionally left blank - break; - } - } - - virtual bool OnQuery(CefRefPtr browser, - CefRefPtr frame, - int64 query_id, - const CefString& request, - bool persistent, - CefRefPtr callback) OVERRIDE { - EXPECT_TRUE(browser.get()); - - if (!started()) - return false; - - const std::string& messageStr = request; - switch(test_type_) { - case OSR_TEST_FOCUS: - EXPECT_STREQ(messageStr.c_str(), "osrfocus"); - DestroySucceededTestSoon(); - break; - case OSR_TEST_CLICK_LEFT: - EXPECT_STREQ(messageStr.c_str(), "osrclick0"); - DestroySucceededTestSoon(); - break; - case OSR_TEST_CLICK_MIDDLE: - EXPECT_STREQ(messageStr.c_str(), "osrclick1"); - DestroySucceededTestSoon(); - break; - case OSR_TEST_MOUSE_MOVE: - EXPECT_STREQ(messageStr.c_str(), "osrmousemove"); - DestroySucceededTestSoon(); - break; - default: - // Intentionally left blank - break; - } - - callback->Success(""); - return true; - } - - // CefClient methods, providing handlers - virtual CefRefPtr GetRenderHandler() OVERRIDE { - return this; - } - - virtual CefRefPtr GetContextMenuHandler() OVERRIDE { - return this; - } - - virtual CefRefPtr GetRequestHandler() OVERRIDE { - return this; - } - - virtual CefRefPtr GetResourceHandler( - CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request) OVERRIDE { - std::string url = request->GetURL(); - - if (url.find("http://tests/osrtest") == 0) { - // Show the osr test contents - CefRefPtr stream = - GetBinaryResourceReader("osr_test.html"); - return new CefStreamResourceHandler("text/html", stream); - } - - return NULL; - } - - // CefRenderHandler methods - virtual bool GetViewRect(CefRefPtr browser, - CefRect& rect) OVERRIDE { - if (test_type_ == OSR_TEST_RESIZE && started()) { - rect = CefRect(0, 0, kOsrWidth * 2, kOsrHeight * 2); - return true; - } - rect = CefRect(0, 0, kOsrWidth, kOsrHeight); - return true; - } - - virtual bool GetScreenPoint(CefRefPtr browser, - int viewX, - int viewY, - int& screenX, - int& screenY) OVERRIDE { - if (test_type_ == OSR_TEST_SCREEN_POINT && started()) { - EXPECT_EQ(viewX, MiddleX(ExpectedRect(4))); - EXPECT_EQ(viewY, MiddleY(ExpectedRect(4))); - DestroySucceededTestSoon(); - } else if (test_type_ == OSR_TEST_CONTEXT_MENU && started()){ - screenX = 0; - screenY = 0; - return true; - } - // we don't want to see a contextual menu. stop here. - return false; - } - - virtual bool GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) { - screen_info.device_scale_factor = 1; - - // The screen info rectangles are used by the renderer to create and - // position popups. If not overwritten in this function, the rectangle from - // returned GetViewRect will be used to popuplate them. - // The popup in the test fits without modifications in the test window, so - // setting the screen to the test window size does not affect its rectangle. - screen_info.rect = CefRect(0, 0, kOsrWidth, kOsrHeight); - screen_info.available_rect = CefRect(0, 0, kOsrWidth, kOsrHeight); - return true; - } - - virtual void OnPopupShow(CefRefPtr browser, - bool show) OVERRIDE { - if (show && started()) { - switch (test_type_) { - case OSR_TEST_POPUP_SHOW: - if (!succeeded()) { - EXPECT_TRUE(show); - DestroySucceededTestSoon(); - } - break; - default: - break; - } - } - if (!show && started()) { - switch (test_type_) { - case OSR_TEST_POPUP_HIDE_ON_BLUR: - case OSR_TEST_POPUP_HIDE_ON_CLICK: - case OSR_TEST_POPUP_HIDE_ON_ESC: - case OSR_TEST_POPUP_HIDE_ON_SCROLL: - DestroySucceededTestSoon(); - break; - default: - break; - } - } - } - - virtual void OnPopupSize(CefRefPtr browser, - const CefRect& rect) OVERRIDE { - if (started()) { - switch (test_type_) { - case OSR_TEST_POPUP_SIZE: - EXPECT_EQ(kExpandedSelectRect, rect); - DestroySucceededTestSoon(); - break; - default: - break; - } - } - } - - virtual void OnPaint(CefRefPtr browser, - PaintElementType type, - const RectList& dirtyRects, - const void* buffer, - int width, int height) OVERRIDE { - // bitmap must as big as GetViewRect said - if (test_type_ != OSR_TEST_RESIZE && type == PET_VIEW) { - EXPECT_EQ(kOsrWidth, width); - EXPECT_EQ(kOsrHeight, height); - } else if (type == PET_POPUP) { - EXPECT_EQ(kExpandedSelectRect.width, width); - EXPECT_EQ(kExpandedSelectRect.height, height); - } - - EXPECT_TRUE(browser->GetHost()->IsWindowRenderingDisabled()); - - // start test only when painting something else then background - if (IsBackgroundInBuffer(reinterpret_cast(buffer), - width * height, - test_type_ == OSR_TEST_TRANSPARENCY ? - 0x00000000 : - 0xFFFFFFFF)) - return; - - // Send events after the first full repaint - switch (test_type_) { - case OSR_TEST_PAINT: - // test that we have a full repaint - EXPECT_EQ(dirtyRects.size(), 1U); - EXPECT_TRUE(IsFullRepaint(dirtyRects[0])); - EXPECT_EQ(*(reinterpret_cast(buffer)), 0xffff8080); - DestroySucceededTestSoon(); - break; - case OSR_TEST_TRANSPARENCY: - // test that we have a full repaint - EXPECT_EQ(dirtyRects.size(), 1U); - EXPECT_TRUE(IsFullRepaint(dirtyRects[0])); - EXPECT_EQ(*(reinterpret_cast(buffer)), 0x7f7f0000U); - DestroySucceededTestSoon(); - break; - case OSR_TEST_FOCUS: - if (StartTest()) { - // body.onfocus will make LI00 red - browser->GetHost()->SendFocusEvent(true); - } - break; - case OSR_TEST_CURSOR: - if (StartTest()) { - // make mouse leave first - CefMouseEvent mouse_event; - mouse_event.x = 0; - mouse_event.y = 0; - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseMoveEvent(mouse_event, true); - // enter mouse in the LI2 element having hand cursor - mouse_event.x = MiddleX(ExpectedRect(2)); - mouse_event.y = MiddleY(ExpectedRect(2)); - browser->GetHost()->SendMouseMoveEvent(mouse_event, false); - } - break; - case OSR_TEST_MOUSE_MOVE: - if (StartTest()) { - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(ExpectedRect(3)); - mouse_event.y = MiddleY(ExpectedRect(3)); - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseMoveEvent(mouse_event, false); - } - break; - case OSR_TEST_CLICK_RIGHT: - case OSR_TEST_SCREEN_POINT: - case OSR_TEST_CONTEXT_MENU: - if (StartTest()) { - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(ExpectedRect(4)); - mouse_event.y = MiddleY(ExpectedRect(4)); - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_RIGHT, false, 1); - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_RIGHT, true, 1); - } - break; - case OSR_TEST_CLICK_LEFT: - if (StartTest()) { - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(ExpectedRect(0)); - mouse_event.y = MiddleY(ExpectedRect(0)); - - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_LEFT, false, 1); - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_LEFT, true, 1); - } - break; - case OSR_TEST_CLICK_MIDDLE: - if (StartTest()) { - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(ExpectedRect(0)); - mouse_event.y = MiddleY(ExpectedRect(0)); - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_MIDDLE, false, 1); - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_MIDDLE, true, 1); - } else { - EXPECT_EQ(dirtyRects.size(), 1U); - CefRect expectedRect( - MiddleX(ExpectedRect(0)) - kMiddleButtonIconWidth / 2, - MiddleY(ExpectedRect(0)) - kMiddleButtonIconWidth / 2, - kMiddleButtonIconWidth, kMiddleButtonIconWidth); - EXPECT_EQ(dirtyRects[0], expectedRect); - DestroySucceededTestSoon(); - } - break; - case OSR_TEST_RESIZE: - if (StartTest()) { - browser->GetHost()->WasResized(); - } else { - EXPECT_EQ(kOsrWidth * 2, width); - EXPECT_EQ(kOsrHeight * 2, height); - EXPECT_EQ(dirtyRects.size(), 1U); - EXPECT_TRUE(IsFullRepaint(dirtyRects[0], width, height)); - DestroySucceededTestSoon(); - } - break; - case OSR_TEST_INVALIDATE: { - static bool invalidating = false; - static const CefRect invalidate_rect(0, 0, 1, 1); - if (StartTest()) { - invalidating = true; - browser->GetHost()->Invalidate(invalidate_rect, PET_VIEW); - invalidating = false; - } else { - EXPECT_TRUE(invalidating); - EXPECT_EQ(dirtyRects.size(), 1U); - EXPECT_EQ(dirtyRects[0], invalidate_rect); - DestroySucceededTestSoon(); - } - break; - } - case OSR_TEST_KEY_EVENTS: - if (StartTest()) { - // click inside edit box - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(kEditBoxRect); - mouse_event.y = MiddleY(kEditBoxRect); - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_LEFT, false, 1); - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_LEFT, true, 1); - - // write "done" word - CefKeyEvent event; - event.is_system_key = false; - event.modifiers = 0; - - size_t word_length = strlen(kKeyTestWord); - for (size_t i = 0; i < word_length; ++i) { -#if defined(OS_WIN) - BYTE VkCode = LOBYTE(VkKeyScanA(kKeyTestWord[i])); - UINT scanCode = MapVirtualKey(VkCode, MAPVK_VK_TO_VSC); - event.native_key_code = (scanCode << 16) | // key scan code - 1; // key repeat count - event.windows_key_code = VkCode; -#elif defined(OS_MACOSX) - osr_unittests::GetKeyEvent(event, kKeyTestCodes[i], 0); -#elif defined(OS_LINUX) - event.native_key_code = kKeyTestCodes[i]; -#else - NOTREACHED(); -#endif - event.type = KEYEVENT_RAWKEYDOWN; - browser->GetHost()->SendKeyEvent(event); -#if defined(OS_WIN) - event.windows_key_code = kKeyTestWord[i]; -#elif defined(OS_MACOSX) - osr_unittests::GetKeyEvent(event, kKeyTestCodes[i], 0); -#elif defined(OS_LINUX) - event.native_key_code = kKeyTestCodes[i]; -#endif - event.type = KEYEVENT_CHAR; - browser->GetHost()->SendKeyEvent(event); -#if defined(OS_WIN) - event.windows_key_code = VkCode; - // bits 30 and 31 should be always 1 for WM_KEYUP - event.native_key_code |= 0xC0000000; -#elif defined(OS_MACOSX) - osr_unittests::GetKeyEvent(event, kKeyTestCodes[i], 0); -#elif defined(OS_LINUX) - event.native_key_code = kKeyTestCodes[i]; -#endif - event.type = KEYEVENT_KEYUP; - browser->GetHost()->SendKeyEvent(event); - } - // click button to navigate - mouse_event.x = MiddleX(kNavigateButtonRect); - mouse_event.y = MiddleY(kNavigateButtonRect); - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_LEFT, false, 1); - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_LEFT, true, 1); - } - break; - case OSR_TEST_TOOLTIP: - if (StartTest()) { - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(ExpectedRect(10)); - mouse_event.y = MiddleY(ExpectedRect(10)); - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseMoveEvent(mouse_event, false); - } - break; - case OSR_TEST_SCROLLING: { - static const int deltaY = 10; - if (StartTest()) { - // scroll down once - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(ExpectedRect(0)); - mouse_event.y = MiddleY(ExpectedRect(0)); - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseWheelEvent(mouse_event, 0, - deltaY); - } else { -#if defined(OS_WIN) - // there should be 3 update areas: - // 1) vertical scrollbar - // 2) discovered new area (bottom side) - // 3) the whole visible rect. - EXPECT_EQ(dirtyRects.size(), 3U); - EXPECT_EQ(dirtyRects[0], CefRect(0, 0, - kOsrWidth - kVerticalScrollbarWidth, kHorizontalScrollbarWidth)); - - EXPECT_EQ(dirtyRects[1], CefRect(0, kHorizontalScrollbarWidth, - kOsrWidth, kOsrHeight - 2 * kHorizontalScrollbarWidth)); - - EXPECT_EQ(dirtyRects[2], - CefRect(0, kOsrHeight - kHorizontalScrollbarWidth, - kOsrWidth - kVerticalScrollbarWidth, - kHorizontalScrollbarWidth)); -#elif defined(OS_MACOSX) - // On Mac, when scrollbars are Always on, there is a single update of - // the whole view - // When scrollbars are set to appear 'When scrolling', the first - // rectangle is of the whole view, and next comes a longer sequence of - // updates, each with one rectangle update for the whole scrollbar - // rectangle(584,0,16,400) - // Validating the first, full update passes in both cases - EXPECT_EQ(dirtyRects.size(), 1U); - EXPECT_EQ(dirtyRects[0], CefRect(0, 0, - kOsrWidth, kOsrHeight)); -#elif defined(OS_LINUX) - EXPECT_EQ(dirtyRects.size(), 1U); - EXPECT_EQ(dirtyRects[0], CefRect(0, 0, - kOsrWidth, kOsrHeight)); -#else -#error "Unsupported platform" -#endif // defined(OS_WIN) - DestroySucceededTestSoon(); - } - break; - } - case OSR_TEST_POPUP_HIDE_ON_CLICK: - if (StartTest()) { - ExpandDropDown(); - // Wait for the first popup paint to occur - } else if (type == PET_POPUP) { - CefMouseEvent mouse_event; - mouse_event.x = 1; - mouse_event.y = 1; - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseClickEvent( - mouse_event, MBT_LEFT, false, 1); - } - break; - case OSR_TEST_POPUP_HIDE_ON_SCROLL: - if (StartTest()) { - ExpandDropDown(); - // Wait for the first popup paint to occur - } else if (type == PET_POPUP) { - CefMouseEvent mouse_event; - mouse_event.x = mouse_event.y = 1; - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseWheelEvent(mouse_event, 0, -10); - } - break; - case OSR_TEST_POPUP_HIDE_ON_BLUR: - if (StartTest()) { - ExpandDropDown(); - // Wait for the first popup paint to occur - } else if (type == PET_POPUP) { - browser->GetHost()->SendFocusEvent(false); - } - break; - case OSR_TEST_POPUP_HIDE_ON_ESC: - if (StartTest()) { - ExpandDropDown(); - // Wait for the first popup paint to occur - } else if (type == PET_POPUP) { - CefKeyEvent event; - event.is_system_key = false; -#if defined(OS_WIN) - BYTE VkCode = LOBYTE(VK_ESCAPE); - UINT scanCode = MapVirtualKey(VkCode, MAPVK_VK_TO_VSC); - event.native_key_code = (scanCode << 16) | // key scan code - 1; // key repeat count - event.windows_key_code = VkCode; -#elif defined(OS_MACOSX) - osr_unittests::GetKeyEvent(event, ui::VKEY_ESCAPE, 0); -#elif defined(OS_LINUX) - event.native_key_code = XK_Escape; -#else -#error "Unsupported platform" -#endif // defined(OS_WIN) - event.type = KEYEVENT_CHAR; - browser->GetHost()->SendKeyEvent(event); - } - break; - case OSR_TEST_POPUP_SHOW: - case OSR_TEST_POPUP_SIZE: - if (StartTest()) { - ExpandDropDown(); - } - break; - case OSR_TEST_POPUP_PAINT: - if (StartTest()) { - ExpandDropDown(); - } else if (type == PET_POPUP) { - EXPECT_EQ(dirtyRects.size(), 1U); - EXPECT_EQ(dirtyRects[0], - CefRect(0, 0, - kExpandedSelectRect.width, - kExpandedSelectRect.height)); - // first pixel of border - EXPECT_EQ(*(reinterpret_cast(buffer)), 0xff7f9db9); - EXPECT_EQ(kExpandedSelectRect.width, width); - EXPECT_EQ(kExpandedSelectRect.height, height); - DestroySucceededTestSoon(); - } - break; - case OSR_TEST_POPUP_SCROLL_INSIDE: - { - static enum {NotStarted, Started, Scrolled} - scroll_inside_state = NotStarted; - if (StartTest()) { - ExpandDropDown(); - scroll_inside_state = Started; - } else if (type == PET_POPUP) { - if (scroll_inside_state == Started) { - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(kExpandedSelectRect); - mouse_event.y = MiddleY(kExpandedSelectRect); - mouse_event.modifiers = 0; - browser->GetHost()->SendMouseWheelEvent(mouse_event, 0, -10); - scroll_inside_state = Scrolled; - } else if (scroll_inside_state == Scrolled) { - EXPECT_EQ(dirtyRects.size(), 1U); -#if defined(OS_WIN) - // border is not redrawn - EXPECT_EQ(dirtyRects[0], - CefRect(1, - 1, - kExpandedSelectRect.width - 3, - kExpandedSelectRect.height - 2)); -#elif defined(OS_MACOSX) || defined(OS_LINUX) - EXPECT_EQ(dirtyRects[0], - CefRect(1, - 0, - kExpandedSelectRect.width - 3, - kExpandedSelectRect.height - 1)); -#else -#error "Unsupported platform" -#endif // defined(OS_WIN) - - DestroySucceededTestSoon(); - } - } - } - break; - default: - break; - } - } - - virtual void OnCursorChange(CefRefPtr browser, - CefCursorHandle cursor) OVERRIDE { - if (test_type_ == OSR_TEST_CURSOR && started()) { - DestroySucceededTestSoon(); - } - } - - virtual void OnScrollOffsetChanged(CefRefPtr browser) OVERRIDE { - if (test_type_ == OSR_TEST_SCROLLING && started()) { - DestroySucceededTestSoon(); - } - } - - virtual bool OnTooltip(CefRefPtr browser, - CefString& text) OVERRIDE { - if (test_type_ == OSR_TEST_TOOLTIP && started()) { - EXPECT_STREQ("EXPECTED_TOOLTIP", text.ToString().c_str()); - DestroySucceededTestSoon(); - } - return false; - } - - virtual void OnBeforeContextMenu(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr params, - CefRefPtr model) OVERRIDE { - if (!started()) - return; - if (test_type_ == OSR_TEST_CLICK_RIGHT) { - EXPECT_EQ(params->GetXCoord(), MiddleX(ExpectedRect(4))); - EXPECT_EQ(params->GetYCoord(), MiddleY(ExpectedRect(4))); - DestroySucceededTestSoon(); - } else if (test_type_ == OSR_TEST_CONTEXT_MENU) { - // This test will pass if it does not crash on destruction - DestroySucceededTestSoon(); - } - } - - // OSRTestHandler functions - void CreateOSRBrowser(const CefString& url) { - CefWindowInfo windowInfo; - CefBrowserSettings settings; - - const bool transparent = (test_type_ == OSR_TEST_TRANSPARENCY); - -#if defined(OS_WIN) - windowInfo.SetAsWindowless(GetDesktopWindow(), transparent); -#elif defined(OS_MACOSX) - // An actual vies is needed only for the ContextMenu test. The menu runner - // checks if the view is not nil before showing the context menu. - if (test_type_ == OSR_TEST_CONTEXT_MENU) - windowInfo.SetAsWindowless(osr_unittests::GetFakeView(), transparent); - else - windowInfo.SetAsWindowless(NULL, transparent); -#elif defined(OS_LINUX) - windowInfo.SetAsWindowless(NULL, transparent); -#else -#error "Unsupported platform" -#endif - CefBrowserHost::CreateBrowser(windowInfo, this, url, settings, NULL); - } - - bool IsFullRepaint(const CefRect& rc, int width = kOsrWidth, - int height = kOsrHeight) { - return rc.width == width && rc.height == height; - } - - static - bool IsBackgroundInBuffer(const uint32* buffer, size_t size, uint32 rgba) { - for (size_t i = 0; i < size; i++) { - if (buffer[i] != rgba) { - return false; - } - } - return true; - } - - static inline int MiddleX(const CefRect& rect) { - return rect.x + rect.width / 2; - } - - static inline int MiddleY(const CefRect& rect) { - return rect.y + rect.height / 2; - } - - void DestroySucceededTestSoon() { - if (succeeded()) - return; - if (++event_count_ == event_total_) { - CefPostTask(TID_UI, NewCefRunnableMethod(this, - &OSRTestHandler::DestroyTest)); - } - } - - void ExpandDropDown() { - GetBrowser()->GetHost()->SendFocusEvent(true); - CefMouseEvent mouse_event; - mouse_event.x = MiddleX(kSelectRect); - mouse_event.y = MiddleY(kSelectRect); - mouse_event.modifiers = 0; - GetBrowser()->GetHost()->SendMouseClickEvent( - mouse_event, MBT_LEFT, false, 1); - } - - // true if the events for this test are already sent - bool started() { return started_; } - - // true if the exit point was reached, even the result is not - // the expected one - bool succeeded() { return (event_count_ == event_total_); } - - // will mark test as started and will return true only the first time - // it is called - bool StartTest() { - if (started_) - return false; - started_ = true; - return true; - } - - private: - OSRTestType test_type_; - int event_count_; - int event_total_; - bool started_; - IMPLEMENT_REFCOUNTING(OSRTestHandler); -}; - -} // namespace - -// generic test -#define OSR_TEST(name, test_mode)\ -TEST(OSRTest, name) {\ - CefRefPtr handler = \ - new OSRTestHandler(test_mode);\ - handler->ExecuteTest();\ - EXPECT_TRUE(handler->succeeded());\ -} - -// tests -OSR_TEST(Windowless, OSR_TEST_IS_WINDOWLESS); -OSR_TEST(Focus, OSR_TEST_FOCUS); -OSR_TEST(Paint, OSR_TEST_PAINT); -OSR_TEST(TransparentPaint, OSR_TEST_TRANSPARENCY); -OSR_TEST(Cursor, OSR_TEST_CURSOR); -OSR_TEST(MouseMove, OSR_TEST_MOUSE_MOVE); -OSR_TEST(MouseRightClick, OSR_TEST_CLICK_RIGHT); -OSR_TEST(MouseLeftClick, OSR_TEST_CLICK_LEFT); -OSR_TEST(MouseMiddleClick, OSR_TEST_CLICK_MIDDLE); -OSR_TEST(ScreenPoint, OSR_TEST_SCREEN_POINT); -OSR_TEST(Resize, OSR_TEST_RESIZE); -OSR_TEST(Invalidate, OSR_TEST_INVALIDATE); -OSR_TEST(KeyEvents, OSR_TEST_KEY_EVENTS); -OSR_TEST(Tooltip, OSR_TEST_TOOLTIP); -OSR_TEST(Scrolling, OSR_TEST_SCROLLING); -OSR_TEST(ContextMenu, OSR_TEST_CONTEXT_MENU); -OSR_TEST(PopupPaint, OSR_TEST_POPUP_PAINT); -OSR_TEST(PopupShow, OSR_TEST_POPUP_SHOW); -OSR_TEST(PopupSize, OSR_TEST_POPUP_SIZE); -OSR_TEST(PopupHideOnBlur, OSR_TEST_POPUP_HIDE_ON_BLUR); -OSR_TEST(PopupHideOnClick, OSR_TEST_POPUP_HIDE_ON_CLICK); -OSR_TEST(PopupHideOnScroll, OSR_TEST_POPUP_HIDE_ON_SCROLL); -OSR_TEST(PopupHideOnEsc, OSR_TEST_POPUP_HIDE_ON_ESC); -OSR_TEST(PopupScrollInside, OSR_TEST_POPUP_SCROLL_INSIDE); diff --git a/tests/unittests/os_rendering_unittest_mac.h b/tests/unittests/os_rendering_unittest_mac.h deleted file mode 100644 index e1df01d1..00000000 --- a/tests/unittests/os_rendering_unittest_mac.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file. - -#ifndef CEF_TESTS_UNITTESTS_OS_RENDERING_UNITTEST_MAC_H_ -#define CEF_TESTS_UNITTESTS_OS_RENDERING_UNITTEST_MAC_H_ - -#include "include/cef_base.h" -#include "ui/events/keycodes/keyboard_codes.h" - -namespace osr_unittests { - -CefWindowHandle GetFakeView(); -void GetKeyEvent(CefKeyEvent& event, ui::KeyboardCode keyCode, int modifiers); - -} // namespace osr_unittests - -#endif diff --git a/tests/unittests/os_rendering_unittest_mac.mm b/tests/unittests/os_rendering_unittest_mac.mm deleted file mode 100644 index 1b39bf09..00000000 --- a/tests/unittests/os_rendering_unittest_mac.mm +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights -// reserved. Use of this source code is governed by a BSD-style license -// that can be found in the LICENSE file. - -#import -#import - -#include "os_rendering_unittest_mac.h" - -#include "ui/events/keycodes/keyboard_code_conversion_mac.h" - -#include "include/cef_base.h" - -namespace osr_unittests { - -CefWindowHandle GetFakeView() { - NSScreen *mainScreen = [NSScreen mainScreen]; - NSRect screenRect = [mainScreen visibleFrame]; - NSView* fakeView = [[NSView alloc] initWithFrame: screenRect]; - return fakeView; -} - -void GetKeyEvent(CefKeyEvent& event, ui::KeyboardCode keyCode, int modifiers) { - unichar character; - unichar unmodified_character; - - // TODO(port): translate modifiers from the input format to NSFlags - // MacKeyCodeForWindowsKeyCode takes a NSUinteger as flags. - int macKeyCode = ui::MacKeyCodeForWindowsKeyCode(keyCode, - modifiers, - &character, - &unmodified_character); - - event.native_key_code = macKeyCode; - event.character = character; - event.unmodified_character = unmodified_character; -} - -} // namespace osr_unittests diff --git a/tests/unittests/test_suite.cc b/tests/unittests/test_suite.cc index d10cc068..67997657 100644 --- a/tests/unittests/test_suite.cc +++ b/tests/unittests/test_suite.cc @@ -61,9 +61,6 @@ void CefTestSuite::GetSettings(CefSettings& settings) { // Necessary for V8Test.OnUncaughtException tests. settings.uncaught_exception_stack_size = 10; - - // Necessary for the OSRTest tests. - settings.windowless_rendering_enabled = true; } // static