From ae91d8f4e5549fcdd13215eaa4edadf03b7818ca Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 9 Apr 2015 16:59:34 +0200 Subject: [PATCH] - cefclient: Add `background-color` command-line argument (issue #1161). - Rename cef_url.h to cef_parser.h. - Add new CefParseCSSColor function. --- cef.gyp | 4 +- cef_paths.gypi | 4 +- .../{cef_url_capi.h => cef_parser_capi.h} | 15 +- include/{cef_url.h => cef_parser.h} | 17 +- libcef/common/{url_impl.cc => parser_impl.cc} | 12 +- libcef/renderer/webkit_glue.cc | 15 + libcef/renderer/webkit_glue.h | 3 + libcef_dll/libcef_dll.cc | 344 ++++++++++-------- libcef_dll/wrapper/libcef_dll_wrapper.cc | 315 ++++++++-------- .../browser/browser_window_osr_gtk.cc | 5 +- .../browser/browser_window_osr_gtk.h | 3 +- .../browser/browser_window_osr_mac.h | 3 +- .../browser/browser_window_osr_mac.mm | 27 +- .../browser/browser_window_osr_win.cc | 7 +- .../browser/browser_window_osr_win.h | 3 +- tests/cefclient/browser/client_handler.cc | 2 +- tests/cefclient/browser/dialog_handler_gtk.cc | 2 +- tests/cefclient/browser/main_context.h | 7 +- tests/cefclient/browser/main_context_impl.cc | 24 +- tests/cefclient/browser/main_context_impl.h | 3 + tests/cefclient/browser/osr_renderer.cc | 29 +- tests/cefclient/browser/osr_renderer.h | 26 +- tests/cefclient/browser/osr_window_win.cc | 45 ++- tests/cefclient/browser/osr_window_win.h | 7 +- tests/cefclient/browser/root_window_gtk.cc | 20 +- tests/cefclient/browser/root_window_mac.mm | 20 +- tests/cefclient/browser/root_window_win.cc | 35 +- tests/cefclient/browser/root_window_win.h | 4 +- tests/cefclient/browser/test_runner.cc | 2 +- tests/cefclient/common/client_switches.cc | 1 + tests/cefclient/common/client_switches.h | 1 + .../{url_unittest.cc => parser_unittest.cc} | 73 +++- tools/cef_parser.py | 1 + 33 files changed, 645 insertions(+), 434 deletions(-) rename include/capi/{cef_url_capi.h => cef_parser_capi.h} (90%) rename include/{cef_url.h => cef_parser.h} (89%) rename libcef/common/{url_impl.cc => parser_impl.cc} (91%) rename tests/unittests/{url_unittest.cc => parser_unittest.cc} (85%) diff --git a/cef.gyp b/cef.gyp index d6b860f4b..02b6967cd 100644 --- a/cef.gyp +++ b/cef.gyp @@ -422,6 +422,7 @@ 'tests/unittests/message_router_unittest.cc', 'tests/unittests/navigation_unittest.cc', 'tests/unittests/os_rendering_unittest.cc', + 'tests/unittests/parser_unittest.cc', 'tests/unittests/print_unittest.cc', 'tests/unittests/process_message_unittest.cc', 'tests/unittests/request_context_unittest.cc', @@ -443,7 +444,6 @@ 'tests/unittests/test_util.cc', 'tests/unittests/test_util.h', 'tests/unittests/tracing_unittest.cc', - 'tests/unittests/url_unittest.cc', 'tests/unittests/urlrequest_unittest.cc', 'tests/unittests/v8_unittest.cc', 'tests/unittests/values_unittest.cc', @@ -1060,6 +1060,7 @@ 'libcef/common/main_delegate.h', 'libcef/common/net_resource_provider.cc', 'libcef/common/net_resource_provider.h', + 'libcef/common/parser_impl.cc', 'libcef/common/process_message_impl.cc', 'libcef/common/process_message_impl.h', 'libcef/common/request_impl.cc', @@ -1083,7 +1084,6 @@ 'libcef/common/time_util.h', 'libcef/common/tracker.cc', 'libcef/common/tracker.h', - 'libcef/common/url_impl.cc', 'libcef/common/urlrequest_impl.cc', 'libcef/common/value_base.cc', 'libcef/common/value_base.h', diff --git a/cef_paths.gypi b/cef_paths.gypi index 7a76a38c2..3f088d0b3 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -40,6 +40,7 @@ 'include/cef_menu_model.h', 'include/cef_navigation_entry.h', 'include/cef_origin_whitelist.h', + 'include/cef_parser.h', 'include/cef_path_util.h', 'include/cef_print_handler.h', 'include/cef_print_settings.h', @@ -60,7 +61,6 @@ 'include/cef_string_visitor.h', 'include/cef_task.h', 'include/cef_trace.h', - 'include/cef_url.h', 'include/cef_urlrequest.h', 'include/cef_v8.h', 'include/cef_values.h', @@ -97,6 +97,7 @@ 'include/capi/cef_menu_model_capi.h', 'include/capi/cef_navigation_entry_capi.h', 'include/capi/cef_origin_whitelist_capi.h', + 'include/capi/cef_parser_capi.h', 'include/capi/cef_path_util_capi.h', 'include/capi/cef_print_handler_capi.h', 'include/capi/cef_print_settings_capi.h', @@ -117,7 +118,6 @@ 'include/capi/cef_string_visitor_capi.h', 'include/capi/cef_task_capi.h', 'include/capi/cef_trace_capi.h', - 'include/capi/cef_url_capi.h', 'include/capi/cef_urlrequest_capi.h', 'include/capi/cef_v8_capi.h', 'include/capi/cef_values_capi.h', diff --git a/include/capi/cef_url_capi.h b/include/capi/cef_parser_capi.h similarity index 90% rename from include/capi/cef_url_capi.h rename to include/capi/cef_parser_capi.h index 62a669d0b..e6af4e949 100644 --- a/include/capi/cef_url_capi.h +++ b/include/capi/cef_parser_capi.h @@ -34,8 +34,8 @@ // more information. // -#ifndef CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ -#define CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ +#ifndef CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ #pragma once #include "include/capi/cef_base_capi.h" @@ -113,8 +113,17 @@ CEF_EXPORT cef_string_userfree_t cef_uriencode(const cef_string_t* text, CEF_EXPORT cef_string_userfree_t cef_uridecode(const cef_string_t* text, int convert_to_utf8, cef_uri_unescape_rule_t unescape_rule); +/// +// Parses |string| which represents a CSS color value. If |strict| is true (1) +// strict parsing rules will be applied. Returns true (1) on success or false +// (0) on error. If parsing succeeds |color| will be set to the color value +// otherwise |color| will remain unchanged. +/// +CEF_EXPORT int cef_parse_csscolor(const cef_string_t* string, int strict, + cef_color_t* color); + #ifdef __cplusplus } #endif -#endif // CEF_INCLUDE_CAPI_CEF_URL_CAPI_H_ +#endif // CEF_INCLUDE_CAPI_CEF_PARSER_CAPI_H_ diff --git a/include/cef_url.h b/include/cef_parser.h similarity index 89% rename from include/cef_url.h rename to include/cef_parser.h index 023e5896f..92f46c6ab 100644 --- a/include/cef_url.h +++ b/include/cef_parser.h @@ -34,8 +34,8 @@ // tools directory for more information. // -#ifndef CEF_INCLUDE_CEF_URL_H_ -#define CEF_INCLUDE_CEF_URL_H_ +#ifndef CEF_INCLUDE_CEF_PARSER_H_ +#define CEF_INCLUDE_CEF_PARSER_H_ #pragma once #include @@ -112,4 +112,15 @@ CefString CefURIDecode(const CefString& text, bool convert_to_utf8, cef_uri_unescape_rule_t unescape_rule); -#endif // CEF_INCLUDE_CEF_URL_H_ +/// +// Parses |string| which represents a CSS color value. If |strict| is true +// strict parsing rules will be applied. Returns true on success or false on +// error. If parsing succeeds |color| will be set to the color value otherwise +// |color| will remain unchanged. +/// +/*--cef()--*/ +bool CefParseCSSColor(const CefString& string, + bool strict, + cef_color_t& color); + +#endif // CEF_INCLUDE_CEF_PARSER_H_ diff --git a/libcef/common/url_impl.cc b/libcef/common/parser_impl.cc similarity index 91% rename from libcef/common/url_impl.cc rename to libcef/common/parser_impl.cc index c09052980..473b4b400 100644 --- a/libcef/common/url_impl.cc +++ b/libcef/common/parser_impl.cc @@ -3,11 +3,14 @@ // be found in the LICENSE file. #include -#include "include/cef_url.h" + +#include "include/cef_parser.h" +#include "libcef/renderer/webkit_glue.h" #include "base/base64.h" #include "net/base/escape.h" #include "net/base/mime_util.h" +#include "third_party/WebKit/public/platform/WebString.h" #include "url/gurl.h" bool CefParseURL(const CefString& url, @@ -124,3 +127,10 @@ CefString CefURIDecode(const CefString& text, else return net::UnescapeURLComponent(text.ToString(), type); } + +bool CefParseCSSColor(const CefString& string, + bool strict, + cef_color_t& color) { + return webkit_glue::ParseCSSColor( + blink::WebString::fromUTF8(string.ToString().data()), strict, color); +} diff --git a/libcef/renderer/webkit_glue.cc b/libcef/renderer/webkit_glue.cc index e1cbbc676..34fd3a416 100644 --- a/libcef/renderer/webkit_glue.cc +++ b/libcef/renderer/webkit_glue.cc @@ -25,6 +25,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "third_party/WebKit/public/web/WebNode.h" #include "third_party/WebKit/public/web/WebViewClient.h" +#include "third_party/WebKit/Source/core/css/parser/CSSParser.h" #include "third_party/WebKit/Source/core/dom/Node.h" #include "third_party/WebKit/Source/web/WebLocalFrameImpl.h" #include "third_party/WebKit/Source/web/WebViewImpl.h" @@ -121,4 +122,18 @@ blink::WebFrame* FindFrameByUniqueName(const blink::WebString& unique_name, return NULL; } +bool ParseCSSColor(const blink::WebString& string, bool strict, SkColor& color) { + blink::RGBA32 rgba_color = + blink::makeRGBA(SkColorGetR(color), SkColorGetG(color), + SkColorGetB(color), SkColorGetA(color)); + if (!blink::CSSParser::parseColor(rgba_color, string, strict)) + return false; + + color = SkColorSetARGB(blink::alphaChannel(rgba_color), + blink::redChannel(rgba_color), + blink::greenChannel(rgba_color), + blink::blueChannel(rgba_color)); + return true; +} + } // webkit_glue diff --git a/libcef/renderer/webkit_glue.h b/libcef/renderer/webkit_glue.h index ae6be4e0a..b7d8a427c 100644 --- a/libcef/renderer/webkit_glue.h +++ b/libcef/renderer/webkit_glue.h @@ -8,6 +8,7 @@ #include #include "base/basictypes.h" +#include "third_party/skia/include/core/SkColor.h" namespace v8 { class Context; @@ -43,6 +44,8 @@ int64 GetIdentifier(blink::WebFrame* frame); blink::WebFrame* FindFrameByUniqueName(const blink::WebString& unique_name, blink::WebFrame* relative_to_frame); +bool ParseCSSColor(const blink::WebString& string, bool strict, SkColor& color); + } // webkit_glue #endif // CEF_LIBCEF_RENDERER_WEBKIT_GLUE_H_ diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index cc84a271a..3b8e99071 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -16,6 +16,8 @@ #include "include/capi/cef_geolocation_capi.h" #include "include/cef_origin_whitelist.h" #include "include/capi/cef_origin_whitelist_capi.h" +#include "include/cef_parser.h" +#include "include/capi/cef_parser_capi.h" #include "include/cef_path_util.h" #include "include/capi/cef_path_util_capi.h" #include "include/cef_process_util.h" @@ -26,8 +28,6 @@ #include "include/capi/cef_task_capi.h" #include "include/cef_trace.h" #include "include/capi/cef_trace_capi.h" -#include "include/cef_url.h" -#include "include/capi/cef_url_capi.h" #include "include/cef_v8.h" #include "include/capi/cef_v8_capi.h" #include "include/cef_web_plugin.h" @@ -386,161 +386,6 @@ CEF_EXPORT int cef_clear_cross_origin_whitelist() { return _retval; } -CEF_EXPORT int cef_get_path(cef_path_key_t key, cef_string_t* path) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: path; type: string_byref - DCHECK(path); - if (!path) - return 0; - - // Translate param: path; type: string_byref - CefString pathStr(path); - - // Execute - bool _retval = CefGetPath( - key, - pathStr); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int cef_launch_process(struct _cef_command_line_t* command_line) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: command_line; type: refptr_same - DCHECK(command_line); - if (!command_line) - return 0; - - // Execute - bool _retval = CefLaunchProcess( - CefCommandLineCppToC::Unwrap(command_line)); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int cef_register_scheme_handler_factory( - const cef_string_t* scheme_name, const cef_string_t* domain_name, - struct _cef_scheme_handler_factory_t* factory) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: scheme_name; type: string_byref_const - DCHECK(scheme_name); - if (!scheme_name) - return 0; - // Unverified params: domain_name, factory - - // Execute - bool _retval = CefRegisterSchemeHandlerFactory( - CefString(scheme_name), - CefString(domain_name), - CefSchemeHandlerFactoryCToCpp::Wrap(factory)); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int cef_clear_scheme_handler_factories() { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - bool _retval = CefClearSchemeHandlerFactories(); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - bool _retval = CefCurrentlyOn( - threadId); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int cef_post_task(cef_thread_id_t threadId, - struct _cef_task_t* task) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: task; type: refptr_diff - DCHECK(task); - if (!task) - return 0; - - // Execute - bool _retval = CefPostTask( - threadId, - CefTaskCToCpp::Wrap(task)); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId, - struct _cef_task_t* task, int64 delay_ms) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: task; type: refptr_diff - DCHECK(task); - if (!task) - return 0; - - // Execute - bool _retval = CefPostDelayedTask( - threadId, - CefTaskCToCpp::Wrap(task), - delay_ms); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int cef_begin_tracing(const cef_string_t* categories, - struct _cef_completion_callback_t* callback) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Unverified params: categories, callback - - // Execute - bool _retval = CefBeginTracing( - CefString(categories), - CefCompletionCallbackCToCpp::Wrap(callback)); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int cef_end_tracing(const cef_string_t* tracing_file, - struct _cef_end_tracing_callback_t* callback) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Unverified params: tracing_file, callback - - // Execute - bool _retval = CefEndTracing( - CefString(tracing_file), - CefEndTracingCallbackCToCpp::Wrap(callback)); - - // Return type: bool - return _retval; -} - -CEF_EXPORT int64 cef_now_from_system_trace_time() { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int64 _retval = CefNowFromSystemTraceTime(); - - // Return type: simple - return _retval; -} - CEF_EXPORT int cef_parse_url(const cef_string_t* url, struct _cef_urlparts_t* parts) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -717,6 +562,191 @@ CEF_EXPORT cef_string_userfree_t cef_uridecode(const cef_string_t* text, return _retval.DetachToUserFree(); } +CEF_EXPORT int cef_parse_csscolor(const cef_string_t* string, int strict, + cef_color_t* color) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: string; type: string_byref_const + DCHECK(string); + if (!string) + return 0; + // Verify param: color; type: simple_byref + DCHECK(color); + if (!color) + return 0; + + // Translate param: color; type: simple_byref + cef_color_t colorVal = color?*color:0; + + // Execute + bool _retval = CefParseCSSColor( + CefString(string), + strict?true:false, + colorVal); + + // Restore param: color; type: simple_byref + if (color) + *color = colorVal; + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_get_path(cef_path_key_t key, cef_string_t* path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: path; type: string_byref + DCHECK(path); + if (!path) + return 0; + + // Translate param: path; type: string_byref + CefString pathStr(path); + + // Execute + bool _retval = CefGetPath( + key, + pathStr); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_launch_process(struct _cef_command_line_t* command_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: refptr_same + DCHECK(command_line); + if (!command_line) + return 0; + + // Execute + bool _retval = CefLaunchProcess( + CefCommandLineCppToC::Unwrap(command_line)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_register_scheme_handler_factory( + const cef_string_t* scheme_name, const cef_string_t* domain_name, + struct _cef_scheme_handler_factory_t* factory) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: scheme_name; type: string_byref_const + DCHECK(scheme_name); + if (!scheme_name) + return 0; + // Unverified params: domain_name, factory + + // Execute + bool _retval = CefRegisterSchemeHandlerFactory( + CefString(scheme_name), + CefString(domain_name), + CefSchemeHandlerFactoryCToCpp::Wrap(factory)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_clear_scheme_handler_factories() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefClearSchemeHandlerFactories(); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefCurrentlyOn( + threadId); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_post_task(cef_thread_id_t threadId, + struct _cef_task_t* task) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task); + if (!task) + return 0; + + // Execute + bool _retval = CefPostTask( + threadId, + CefTaskCToCpp::Wrap(task)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_post_delayed_task(cef_thread_id_t threadId, + struct _cef_task_t* task, int64 delay_ms) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task); + if (!task) + return 0; + + // Execute + bool _retval = CefPostDelayedTask( + threadId, + CefTaskCToCpp::Wrap(task), + delay_ms); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_begin_tracing(const cef_string_t* categories, + struct _cef_completion_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: categories, callback + + // Execute + bool _retval = CefBeginTracing( + CefString(categories), + CefCompletionCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_end_tracing(const cef_string_t* tracing_file, + struct _cef_end_tracing_callback_t* callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: tracing_file, callback + + // Execute + bool _retval = CefEndTracing( + CefString(tracing_file), + CefEndTracingCallbackCToCpp::Wrap(callback)); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int64 cef_now_from_system_trace_time() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = CefNowFromSystemTraceTime(); + + // Return type: simple + return _retval; +} + CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name, const cef_string_t* javascript_code, struct _cef_v8handler_t* handler) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index ed142a673..a72bc6dca 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -16,6 +16,8 @@ #include "include/capi/cef_geolocation_capi.h" #include "include/cef_origin_whitelist.h" #include "include/capi/cef_origin_whitelist_capi.h" +#include "include/cef_parser.h" +#include "include/capi/cef_parser_capi.h" #include "include/cef_path_util.h" #include "include/capi/cef_path_util_capi.h" #include "include/cef_process_util.h" @@ -26,8 +28,6 @@ #include "include/capi/cef_task_capi.h" #include "include/cef_trace.h" #include "include/capi/cef_trace_capi.h" -#include "include/cef_url.h" -#include "include/capi/cef_url_capi.h" #include "include/cef_v8.h" #include "include/capi/cef_v8_capi.h" #include "include/cef_web_plugin.h" @@ -378,152 +378,6 @@ CEF_GLOBAL bool CefClearCrossOriginWhitelist() { return _retval?true:false; } -CEF_GLOBAL bool CefGetPath(PathKey key, CefString& path) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = cef_get_path( - key, - path.GetWritableStruct()); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL bool CefLaunchProcess(CefRefPtr command_line) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: command_line; type: refptr_same - DCHECK(command_line.get()); - if (!command_line.get()) - return false; - - // Execute - int _retval = cef_launch_process( - CefCommandLineCToCpp::Unwrap(command_line)); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL bool CefRegisterSchemeHandlerFactory(const CefString& scheme_name, - const CefString& domain_name, - CefRefPtr factory) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: scheme_name; type: string_byref_const - DCHECK(!scheme_name.empty()); - if (scheme_name.empty()) - return false; - // Unverified params: domain_name, factory - - // Execute - int _retval = cef_register_scheme_handler_factory( - scheme_name.GetStruct(), - domain_name.GetStruct(), - CefSchemeHandlerFactoryCppToC::Wrap(factory)); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL bool CefClearSchemeHandlerFactories() { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = cef_clear_scheme_handler_factories(); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL bool CefCurrentlyOn(CefThreadId threadId) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = cef_currently_on( - threadId); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL bool CefPostTask(CefThreadId threadId, CefRefPtr task) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: task; type: refptr_diff - DCHECK(task.get()); - if (!task.get()) - return false; - - // Execute - int _retval = cef_post_task( - threadId, - CefTaskCppToC::Wrap(task)); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL bool CefPostDelayedTask(CefThreadId threadId, - CefRefPtr task, int64 delay_ms) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Verify param: task; type: refptr_diff - DCHECK(task.get()); - if (!task.get()) - return false; - - // Execute - int _retval = cef_post_delayed_task( - threadId, - CefTaskCppToC::Wrap(task), - delay_ms); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL bool CefBeginTracing(const CefString& categories, - CefRefPtr callback) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Unverified params: categories, callback - - // Execute - int _retval = cef_begin_tracing( - categories.GetStruct(), - CefCompletionCallbackCppToC::Wrap(callback)); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL bool CefEndTracing(const CefString& tracing_file, - CefRefPtr callback) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Unverified params: tracing_file, callback - - // Execute - int _retval = cef_end_tracing( - tracing_file.GetStruct(), - CefEndTracingCallbackCppToC::Wrap(callback)); - - // Return type: bool - return _retval?true:false; -} - -CEF_GLOBAL int64 CefNowFromSystemTraceTime() { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int64 _retval = cef_now_from_system_trace_time(); - - // Return type: simple - return _retval; -} - CEF_GLOBAL bool CefParseURL(const CefString& url, CefURLParts& parts) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -674,6 +528,171 @@ CEF_GLOBAL CefString CefURIDecode(const CefString& text, bool convert_to_utf8, return _retvalStr; } +CEF_GLOBAL bool CefParseCSSColor(const CefString& string, bool strict, + cef_color_t& color) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: string; type: string_byref_const + DCHECK(!string.empty()); + if (string.empty()) + return false; + + // Execute + int _retval = cef_parse_csscolor( + string.GetStruct(), + strict, + &color); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefGetPath(PathKey key, CefString& path) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_get_path( + key, + path.GetWritableStruct()); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefLaunchProcess(CefRefPtr command_line) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: command_line; type: refptr_same + DCHECK(command_line.get()); + if (!command_line.get()) + return false; + + // Execute + int _retval = cef_launch_process( + CefCommandLineCToCpp::Unwrap(command_line)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefRegisterSchemeHandlerFactory(const CefString& scheme_name, + const CefString& domain_name, + CefRefPtr factory) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: scheme_name; type: string_byref_const + DCHECK(!scheme_name.empty()); + if (scheme_name.empty()) + return false; + // Unverified params: domain_name, factory + + // Execute + int _retval = cef_register_scheme_handler_factory( + scheme_name.GetStruct(), + domain_name.GetStruct(), + CefSchemeHandlerFactoryCppToC::Wrap(factory)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefClearSchemeHandlerFactories() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_clear_scheme_handler_factories(); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefCurrentlyOn(CefThreadId threadId) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_currently_on( + threadId); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefPostTask(CefThreadId threadId, CefRefPtr task) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task.get()); + if (!task.get()) + return false; + + // Execute + int _retval = cef_post_task( + threadId, + CefTaskCppToC::Wrap(task)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefPostDelayedTask(CefThreadId threadId, + CefRefPtr task, int64 delay_ms) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: task; type: refptr_diff + DCHECK(task.get()); + if (!task.get()) + return false; + + // Execute + int _retval = cef_post_delayed_task( + threadId, + CefTaskCppToC::Wrap(task), + delay_ms); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefBeginTracing(const CefString& categories, + CefRefPtr callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: categories, callback + + // Execute + int _retval = cef_begin_tracing( + categories.GetStruct(), + CefCompletionCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefEndTracing(const CefString& tracing_file, + CefRefPtr callback) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Unverified params: tracing_file, callback + + // Execute + int _retval = cef_end_tracing( + tracing_file.GetStruct(), + CefEndTracingCallbackCppToC::Wrap(callback)); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL int64 CefNowFromSystemTraceTime() { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int64 _retval = cef_now_from_system_trace_time(); + + // Return type: simple + return _retval; +} + CEF_GLOBAL bool CefRegisterExtension(const CefString& extension_name, const CefString& javascript_code, CefRefPtr handler) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING diff --git a/tests/cefclient/browser/browser_window_osr_gtk.cc b/tests/cefclient/browser/browser_window_osr_gtk.cc index 3f9179a1a..bedda3c91 100644 --- a/tests/cefclient/browser/browser_window_osr_gtk.cc +++ b/tests/cefclient/browser/browser_window_osr_gtk.cc @@ -913,10 +913,9 @@ class ScopedGLContext { BrowserWindowOsrGtk::BrowserWindowOsrGtk(BrowserWindow::Delegate* delegate, const std::string& startup_url, - bool transparent, - bool show_update_rect) + const OsrRenderer::Settings& settings) : BrowserWindow(delegate), - renderer_(transparent, show_update_rect), + renderer_(settings), glarea_(NULL), hidden_(false), gl_enabled_(false), diff --git a/tests/cefclient/browser/browser_window_osr_gtk.h b/tests/cefclient/browser/browser_window_osr_gtk.h index 96bfcc4ff..20b7f9394 100644 --- a/tests/cefclient/browser/browser_window_osr_gtk.h +++ b/tests/cefclient/browser/browser_window_osr_gtk.h @@ -22,8 +22,7 @@ class BrowserWindowOsrGtk : public BrowserWindow, // |delegate| must outlive this object. BrowserWindowOsrGtk(BrowserWindow::Delegate* delegate, const std::string& startup_url, - bool transparent, - bool show_update_rect); + const OsrRenderer::Settings& settings); // BrowserWindow methods. void CreateBrowser(ClientWindowHandle parent_handle, diff --git a/tests/cefclient/browser/browser_window_osr_mac.h b/tests/cefclient/browser/browser_window_osr_mac.h index 9a25cc10d..876c5fa51 100644 --- a/tests/cefclient/browser/browser_window_osr_mac.h +++ b/tests/cefclient/browser/browser_window_osr_mac.h @@ -22,8 +22,7 @@ class BrowserWindowOsrMac : public BrowserWindow, // |delegate| must outlive this object. BrowserWindowOsrMac(BrowserWindow::Delegate* delegate, const std::string& startup_url, - bool transparent, - bool show_update_rect); + const OsrRenderer::Settings& settings); ~BrowserWindowOsrMac(); // BrowserWindow methods. diff --git a/tests/cefclient/browser/browser_window_osr_mac.mm b/tests/cefclient/browser/browser_window_osr_mac.mm index c8d8de0d4..ffb755500 100644 --- a/tests/cefclient/browser/browser_window_osr_mac.mm +++ b/tests/cefclient/browser/browser_window_osr_mac.mm @@ -9,7 +9,7 @@ #include #include "include/base/cef_logging.h" -#include "include/cef_url.h" +#include "include/cef_parser.h" #include "include/wrapper/cef_closure_task.h" #include "cefclient/browser/bytes_write_handler.h" #include "cefclient/browser/main_message_loop.h" @@ -662,12 +662,22 @@ BrowserOpenGLView* GLView(NSView* view) { } - (void)drawRect: (NSRect) dirtyRect { - // The Invalidate below fixes flicker when resizing - if ([self inLiveResize]) { - CefRefPtr browser = [self getBrowser]; - if (browser.get()) - browser->GetHost()->Invalidate(PET_VIEW); + CefRefPtr browser = [self getBrowser]; + if ([self inLiveResize] || !browser.get()) { + // Fill with the background color. + const cef_color_t background_color = renderer_->GetBackgroundColor(); + NSColor* color = + [NSColor colorWithRed:float(CefColorGetR(background_color)) / 255.0f + green:float(CefColorGetG(background_color)) / 255.0f + blue:float(CefColorGetB(background_color)) / 255.0f + alpha:1.f]; + [color setFill]; + NSRectFill(dirtyRect); } + + // The Invalidate below fixes flicker when resizing. + if ([self inLiveResize] && browser.get()) + browser->GetHost()->Invalidate(PET_VIEW); } // Drag and drop @@ -1083,10 +1093,9 @@ namespace client { BrowserWindowOsrMac::BrowserWindowOsrMac(BrowserWindow::Delegate* delegate, const std::string& startup_url, - bool transparent, - bool show_update_rect) + const OsrRenderer::Settings& settings) : BrowserWindow(delegate), - renderer_(transparent, show_update_rect), + renderer_(settings), nsview_(NULL), hidden_(false), painting_popup_(false) { diff --git a/tests/cefclient/browser/browser_window_osr_win.cc b/tests/cefclient/browser/browser_window_osr_win.cc index fa1930058..e4ee5d500 100644 --- a/tests/cefclient/browser/browser_window_osr_win.cc +++ b/tests/cefclient/browser/browser_window_osr_win.cc @@ -10,12 +10,11 @@ namespace client { BrowserWindowOsrWin::BrowserWindowOsrWin(BrowserWindow::Delegate* delegate, const std::string& startup_url, - bool transparent, - bool show_update_rect) + const OsrRenderer::Settings& settings) : BrowserWindow(delegate), - transparent_(transparent), + transparent_(settings.transparent), osr_hwnd_(NULL) { - osr_window_ = new OsrWindowWin(this, transparent, show_update_rect); + osr_window_ = new OsrWindowWin(this, settings); client_handler_ = new ClientHandlerOsr(this, osr_window_.get(), startup_url); } diff --git a/tests/cefclient/browser/browser_window_osr_win.h b/tests/cefclient/browser/browser_window_osr_win.h index b0f1ff3b3..9abe17ea8 100644 --- a/tests/cefclient/browser/browser_window_osr_win.h +++ b/tests/cefclient/browser/browser_window_osr_win.h @@ -21,8 +21,7 @@ class BrowserWindowOsrWin : public BrowserWindow, // |delegate| must outlive this object. BrowserWindowOsrWin(BrowserWindow::Delegate* delegate, const std::string& startup_url, - bool transparent, - bool show_update_rect); + const OsrRenderer::Settings& settings); // BrowserWindow methods. void CreateBrowser(ClientWindowHandle parent_handle, diff --git a/tests/cefclient/browser/client_handler.cc b/tests/cefclient/browser/client_handler.cc index 7a07fc381..3162771ff 100644 --- a/tests/cefclient/browser/client_handler.cc +++ b/tests/cefclient/browser/client_handler.cc @@ -13,7 +13,7 @@ #include "include/base/cef_bind.h" #include "include/cef_browser.h" #include "include/cef_frame.h" -#include "include/cef_url.h" +#include "include/cef_parser.h" #include "include/wrapper/cef_closure_task.h" #include "cefclient/browser/main_context.h" #include "cefclient/browser/resource_util.h" diff --git a/tests/cefclient/browser/dialog_handler_gtk.cc b/tests/cefclient/browser/dialog_handler_gtk.cc index e4fdcbcd4..329cc5726 100644 --- a/tests/cefclient/browser/dialog_handler_gtk.cc +++ b/tests/cefclient/browser/dialog_handler_gtk.cc @@ -8,7 +8,7 @@ #include #include "include/cef_browser.h" -#include "include/cef_url.h" +#include "include/cef_parser.h" #include "include/wrapper/cef_helpers.h" #include "cefclient/browser/root_window.h" diff --git a/tests/cefclient/browser/main_context.h b/tests/cefclient/browser/main_context.h index a2772ecee..196738b1d 100644 --- a/tests/cefclient/browser/main_context.h +++ b/tests/cefclient/browser/main_context.h @@ -10,6 +10,7 @@ #include "include/base/cef_ref_counted.h" #include "include/internal/cef_types_wrappers.h" +#include "cefclient/browser/osr_renderer.h" namespace client { @@ -33,10 +34,14 @@ class MainContext { // Returns the main application URL. virtual std::string GetMainURL() = 0; - + + // Returns the background color. + virtual cef_color_t GetBackgroundColor() = 0; + // Populate |settings| based on command-line arguments. virtual void PopulateSettings(CefSettings* settings) = 0; virtual void PopulateBrowserSettings(CefBrowserSettings* settings) = 0; + virtual void PopulateOsrSettings(OsrRenderer::Settings* settings) = 0; // Returns the object used to create/manage RootWindow instances. virtual RootWindowManager* GetRootWindowManager() = 0; diff --git a/tests/cefclient/browser/main_context_impl.cc b/tests/cefclient/browser/main_context_impl.cc index ee77996e6..bdc06defb 100644 --- a/tests/cefclient/browser/main_context_impl.cc +++ b/tests/cefclient/browser/main_context_impl.cc @@ -4,6 +4,7 @@ #include "cefclient/browser/main_context_impl.h" +#include "include/cef_parser.h" #include "cefclient/common/client_switches.h" namespace client { @@ -20,7 +21,8 @@ MainContextImpl::MainContextImpl(CefRefPtr command_line, : command_line_(command_line), terminate_when_all_windows_closed_(terminate_when_all_windows_closed), initialized_(false), - shutdown_(false) { + shutdown_(false), + background_color_(CefColorSetARGB(255, 255, 255, 255)) { DCHECK(command_line_.get()); // Set the main URL. @@ -28,6 +30,12 @@ MainContextImpl::MainContextImpl(CefRefPtr command_line, main_url_ = command_line_->GetSwitchValue(switches::kUrl); if (main_url_.empty()) main_url_ = kDefaultUrl; + + if (command_line_->HasSwitch(switches::kBackgroundColor)) { + // Parse the background color value. + CefParseCSSColor(command_line_->GetSwitchValue(switches::kBackgroundColor), + false, background_color_); + } } MainContextImpl::~MainContextImpl() { @@ -44,6 +52,10 @@ std::string MainContextImpl::GetMainURL() { return main_url_; } +cef_color_t MainContextImpl::GetBackgroundColor() { + return background_color_; +} + void MainContextImpl::PopulateSettings(CefSettings* settings) { #if defined(OS_WIN) settings->multi_threaded_message_loop = @@ -55,6 +67,8 @@ void MainContextImpl::PopulateSettings(CefSettings* settings) { if (command_line_->HasSwitch(switches::kOffScreenRenderingEnabled)) settings->windowless_rendering_enabled = true; + + settings->background_color = background_color_; } void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) { @@ -64,6 +78,14 @@ void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) { } } +void MainContextImpl::PopulateOsrSettings(OsrRenderer::Settings* settings) { + settings->transparent = + command_line_->HasSwitch(switches::kTransparentPaintingEnabled); + settings->show_update_rect = + command_line_->HasSwitch(switches::kShowUpdateRect); + settings->background_color = background_color_; +} + RootWindowManager* MainContextImpl::GetRootWindowManager() { DCHECK(InValidState()); return root_window_manager_.get(); diff --git a/tests/cefclient/browser/main_context_impl.h b/tests/cefclient/browser/main_context_impl.h index ebfb59a40..09b66c17d 100644 --- a/tests/cefclient/browser/main_context_impl.h +++ b/tests/cefclient/browser/main_context_impl.h @@ -26,8 +26,10 @@ class MainContextImpl : public MainContext { std::string GetDownloadPath(const std::string& file_name) OVERRIDE; std::string GetAppWorkingDirectory() OVERRIDE; std::string GetMainURL() OVERRIDE; + cef_color_t GetBackgroundColor() OVERRIDE; void PopulateSettings(CefSettings* settings) OVERRIDE; void PopulateBrowserSettings(CefBrowserSettings* settings) OVERRIDE; + void PopulateOsrSettings(OsrRenderer::Settings* settings) OVERRIDE; RootWindowManager* GetRootWindowManager() OVERRIDE; // Initialize CEF and associated main context state. This method must be @@ -63,6 +65,7 @@ class MainContextImpl : public MainContext { bool shutdown_; std::string main_url_; + cef_color_t background_color_; scoped_ptr root_window_manager_; diff --git a/tests/cefclient/browser/osr_renderer.cc b/tests/cefclient/browser/osr_renderer.cc index 2484b7dd4..9c0433028 100644 --- a/tests/cefclient/browser/osr_renderer.cc +++ b/tests/cefclient/browser/osr_renderer.cc @@ -41,10 +41,14 @@ namespace client { -OsrRenderer::OsrRenderer(bool transparent, - bool show_update_rect) - : transparent_(transparent), - show_update_rect_(show_update_rect), +OsrRenderer::Settings::Settings() + : transparent(false), + show_update_rect(false), + background_color(CefColorSetARGB(255, 255, 255, 255)) { +} + +OsrRenderer::OsrRenderer(const Settings& settings) + : settings_(settings), initialized_(false), texture_id_(0), view_width_(0), @@ -63,7 +67,10 @@ void OsrRenderer::Initialize() { glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); VERIFY_NO_ERROR; - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); VERIFY_NO_ERROR; + glClearColor(float(CefColorGetR(settings_.background_color)) / 255.0f, + float(CefColorGetG(settings_.background_color)) / 255.0f, + float(CefColorGetB(settings_.background_color)) / 255.0f, + 1.0f); VERIFY_NO_ERROR; // Necessary for non-power-of-2 textures to render correctly. glPixelStorei(GL_UNPACK_ALIGNMENT, 1); VERIFY_NO_ERROR; @@ -134,7 +141,7 @@ void OsrRenderer::Render() { glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f); VERIFY_NO_ERROR; } - if (transparent_) { + if (settings_.transparent) { // Alpha blending style. Texture values have premultiplied alpha. glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); VERIFY_NO_ERROR; @@ -154,13 +161,13 @@ void OsrRenderer::Render() { // Disable 2D textures. glDisable(GL_TEXTURE_2D); VERIFY_NO_ERROR; - if (transparent_) { + if (settings_.transparent) { // Disable alpha blending. glDisable(GL_BLEND); VERIFY_NO_ERROR; } // Draw a rectangle around the update region. - if (show_update_rect_ && !update_rect_.IsEmpty()) { + if (settings_.show_update_rect && !update_rect_.IsEmpty()) { int left = update_rect_.x; int right = update_rect_.x + update_rect_.width; int top = update_rect_.y; @@ -246,7 +253,7 @@ void OsrRenderer::OnPaint(CefRefPtr browser, if (!initialized_) Initialize(); - if (transparent_) { + if (settings_.transparent) { // Enable alpha blending. glEnable(GL_BLEND); VERIFY_NO_ERROR; } @@ -264,7 +271,7 @@ void OsrRenderer::OnPaint(CefRefPtr browser, view_width_ = width; view_height_ = height; - if (show_update_rect_) + if (settings_.show_update_rect) update_rect_ = dirtyRects[0]; glPixelStorei(GL_UNPACK_ROW_LENGTH, view_width_); VERIFY_NO_ERROR; @@ -324,7 +331,7 @@ void OsrRenderer::OnPaint(CefRefPtr browser, // Disable 2D textures. glDisable(GL_TEXTURE_2D); VERIFY_NO_ERROR; - if (transparent_) { + if (settings_.transparent) { // Disable alpha blending. glDisable(GL_BLEND); VERIFY_NO_ERROR; } diff --git a/tests/cefclient/browser/osr_renderer.h b/tests/cefclient/browser/osr_renderer.h index a41bee8a1..881da0e9e 100644 --- a/tests/cefclient/browser/osr_renderer.h +++ b/tests/cefclient/browser/osr_renderer.h @@ -13,8 +13,20 @@ namespace client { class OsrRenderer { public: - OsrRenderer(bool transparent, - bool show_update_rect); + struct Settings { + Settings(); + + // If true use transparent rendering. + bool transparent; + + // If true draw a border around update rectangles. + bool show_update_rect; + + // Background color. + cef_color_t background_color; + }; + + explicit OsrRenderer(const Settings& settings); ~OsrRenderer(); // Initialize the OpenGL environment. @@ -41,10 +53,11 @@ class OsrRenderer { void SetSpin(float spinX, float spinY); void IncrementSpin(float spinDX, float spinDY); - bool IsTransparent() { return transparent_; } + bool IsTransparent() const { return settings_.transparent; } + cef_color_t GetBackgroundColor() const { return settings_.background_color; } - int GetViewWidth() { return view_width_; } - int GetViewHeight() { return view_height_; } + int GetViewWidth() const { return view_width_; } + int GetViewHeight() const { return view_height_; } const CefRect& popup_rect() const { return popup_rect_; } const CefRect& original_popup_rect() const { return original_popup_rect_; } @@ -53,8 +66,7 @@ class OsrRenderer { void ClearPopupRects(); private: - const bool transparent_; - const bool show_update_rect_; + const Settings settings_; bool initialized_; unsigned int texture_id_; int view_width_; diff --git a/tests/cefclient/browser/osr_window_win.cc b/tests/cefclient/browser/osr_window_win.cc index b8bbeb945..11ed5fd47 100644 --- a/tests/cefclient/browser/osr_window_win.cc +++ b/tests/cefclient/browser/osr_window_win.cc @@ -48,10 +48,9 @@ class ScopedGLContext { OsrWindowWin::OsrWindowWin(Delegate* delegate, - bool transparent, - bool show_update_rect) + const OsrRenderer::Settings& settings) : delegate_(delegate), - renderer_(transparent, show_update_rect), + renderer_(settings), hwnd_(NULL), hdc_(NULL), hrc_(NULL), @@ -208,7 +207,13 @@ void OsrWindowWin::Create(HWND parent_hwnd, const RECT& rect) { HINSTANCE hInst = ::GetModuleHandle(NULL); - RegisterOsrClass(hInst); + const cef_color_t background_color = renderer_.GetBackgroundColor(); + const HBRUSH background_brush = CreateSolidBrush( + RGB(CefColorGetR(background_color), + CefColorGetG(background_color), + CefColorGetB(background_color))); + + RegisterOsrClass(hInst, background_brush); // Create the native window with a border so it's easier to visually identify // OSR windows. @@ -339,7 +344,8 @@ void OsrWindowWin::NotifyNativeWindowCreated(HWND hwnd) { } // static -void OsrWindowWin::RegisterOsrClass(HINSTANCE hInstance) { +void OsrWindowWin::RegisterOsrClass(HINSTANCE hInstance, + HBRUSH background_brush) { // Only register the class one time. static bool class_registered = false; if (class_registered) @@ -356,7 +362,7 @@ void OsrWindowWin::RegisterOsrClass(HINSTANCE hInstance) { wcex.hInstance = hInstance; wcex.hIcon = NULL; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.hbrBackground = background_brush; wcex.lpszMenuName = NULL; wcex.lpszClassName = kWndClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); @@ -383,25 +389,21 @@ LRESULT CALLBACK OsrWindowWin::OsrWndProc(HWND hWnd, UINT message, case WM_MOUSEMOVE: case WM_MOUSELEAVE: case WM_MOUSEWHEEL: - if (self) - self->OnMouseEvent(message, wParam, lParam); + self->OnMouseEvent(message, wParam, lParam); break; case WM_SIZE: - if (self) - self->OnSize(); + self->OnSize(); break; case WM_SETFOCUS: case WM_KILLFOCUS: - if (self) - self->OnFocus(message == WM_SETFOCUS); + self->OnFocus(message == WM_SETFOCUS); break; case WM_CAPTURECHANGED: case WM_CANCELMODE: - if (self) - self->OnCaptureLost(); + self->OnCaptureLost(); break; case WM_SYSCHAR: @@ -410,17 +412,17 @@ LRESULT CALLBACK OsrWindowWin::OsrWndProc(HWND hWnd, UINT message, case WM_KEYDOWN: case WM_KEYUP: case WM_CHAR: - if (self) - self->OnKeyEvent(message, wParam, lParam); + self->OnKeyEvent(message, wParam, lParam); break; case WM_PAINT: - if (self) - self->OnPaint(); + self->OnPaint(); return 0; case WM_ERASEBKGND: - // Never erase the background. + if (self->OnEraseBkgnd()) + break; + // Don't erase the background. return 0; case WM_NCDESTROY: @@ -674,6 +676,11 @@ void OsrWindowWin::OnPaint() { browser_->GetHost()->Invalidate(PET_VIEW); } +bool OsrWindowWin::OnEraseBkgnd() { + // Erase the background when the browser does not exist. + return (browser_ == NULL); +} + bool OsrWindowWin::IsOverPopupWidget(int x, int y) const { CEF_REQUIRE_UI_THREAD(); const CefRect& rc = renderer_.popup_rect(); diff --git a/tests/cefclient/browser/osr_window_win.h b/tests/cefclient/browser/osr_window_win.h index a7cbe7795..4006f958c 100644 --- a/tests/cefclient/browser/osr_window_win.h +++ b/tests/cefclient/browser/osr_window_win.h @@ -40,8 +40,7 @@ class OsrWindowWin : // |delegate| must outlive this object. OsrWindowWin(Delegate* delegate, - bool transparent, - bool show_update_rect); + const OsrRenderer::Settings& settings); // Create a new browser and native window. void CreateBrowser(HWND parent_hwnd, @@ -80,7 +79,8 @@ class OsrWindowWin : void NotifyNativeWindowCreated(HWND hwnd); - static void RegisterOsrClass(HINSTANCE hInstance); + static void RegisterOsrClass(HINSTANCE hInstance, + HBRUSH background_brush); static LRESULT CALLBACK OsrWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); @@ -91,6 +91,7 @@ class OsrWindowWin : void OnCaptureLost(); void OnKeyEvent(UINT message, WPARAM wParam, LPARAM lParam); void OnPaint(); + bool OnEraseBkgnd(); // Manage popup bounds. bool IsOverPopupWidget(int x, int y) const; diff --git a/tests/cefclient/browser/root_window_gtk.cc b/tests/cefclient/browser/root_window_gtk.cc index cd57909dc..5d23c71ea 100644 --- a/tests/cefclient/browser/root_window_gtk.cc +++ b/tests/cefclient/browser/root_window_gtk.cc @@ -15,6 +15,7 @@ #include "include/cef_app.h" #include "cefclient/browser/browser_window_osr_gtk.h" #include "cefclient/browser/browser_window_std_gtk.h" +#include "cefclient/browser/main_context.h" #include "cefclient/browser/main_message_loop.h" #include "cefclient/browser/resource.h" #include "cefclient/browser/temp_window.h" @@ -205,15 +206,9 @@ ClientWindowHandle RootWindowGtk::GetWindowHandle() const { void RootWindowGtk::CreateBrowserWindow(const std::string& startup_url) { if (with_osr_) { - CefRefPtr command_line = - CefCommandLine::GetGlobalCommandLine(); - const bool transparent = - command_line->HasSwitch(switches::kTransparentPaintingEnabled); - const bool show_update_rect = - command_line->HasSwitch(switches::kShowUpdateRect); - browser_window_.reset(new BrowserWindowOsrGtk(this, startup_url, - transparent, - show_update_rect)); + OsrRenderer::Settings settings; + MainContext::Get()->PopulateOsrSettings(&settings); + browser_window_.reset(new BrowserWindowOsrGtk(this, startup_url, settings)); } else { browser_window_.reset(new BrowserWindowStdGtk(this, startup_url)); } @@ -250,6 +245,13 @@ void RootWindowGtk::CreateRootWindow(const CefBrowserSettings& settings) { g_signal_connect(G_OBJECT(window_), "delete_event", G_CALLBACK(&RootWindowGtk::WindowDelete), this); + const cef_color_t background_color = MainContext::Get()->GetBackgroundColor(); + GdkColor color = {0}; + color.red = CefColorGetR(background_color) * 65535 / 255; + color.green = CefColorGetG(background_color) * 65535 / 255; + color.blue = CefColorGetB(background_color) * 65535 / 255; + gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, &color); + GtkWidget* vbox = gtk_vbox_new(FALSE, 0); g_signal_connect(vbox, "size-allocate", G_CALLBACK(&RootWindowGtk::VboxSizeAllocated), this); diff --git a/tests/cefclient/browser/root_window_mac.mm b/tests/cefclient/browser/root_window_mac.mm index e740f3264..e7dc0da35 100644 --- a/tests/cefclient/browser/root_window_mac.mm +++ b/tests/cefclient/browser/root_window_mac.mm @@ -9,6 +9,7 @@ #include "include/cef_application_mac.h" #include "cefclient/browser/browser_window_osr_mac.h" #include "cefclient/browser/browser_window_std_mac.h" +#include "cefclient/browser/main_context.h" #include "cefclient/browser/main_message_loop.h" #include "cefclient/browser/temp_window.h" #include "cefclient/common/client_switches.h" @@ -414,15 +415,9 @@ void RootWindowMac::WindowDestroyed() { void RootWindowMac::CreateBrowserWindow(const std::string& startup_url) { if (with_osr_) { - CefRefPtr command_line = - CefCommandLine::GetGlobalCommandLine(); - const bool transparent = - command_line->HasSwitch(switches::kTransparentPaintingEnabled); - const bool show_update_rect = - command_line->HasSwitch(switches::kShowUpdateRect); - browser_window_.reset(new BrowserWindowOsrMac(this, startup_url, - transparent, - show_update_rect)); + OsrRenderer::Settings settings; + MainContext::Get()->PopulateOsrSettings(&settings); + browser_window_.reset(new BrowserWindowOsrMac(this, startup_url, settings)); } else { browser_window_.reset(new BrowserWindowStdMac(this, startup_url)); } @@ -470,6 +465,13 @@ void RootWindowMac::CreateRootWindow(const CefBrowserSettings& settings) { // during cleanup (ie, a window close from javascript). [window_ setReleasedWhenClosed:NO]; + const cef_color_t background_color = MainContext::Get()->GetBackgroundColor(); + [window_ setBackgroundColor: + [NSColor colorWithRed:float(CefColorGetR(background_color)) / 255.0f + green:float(CefColorGetG(background_color)) / 255.0f + blue:float(CefColorGetB(background_color)) / 255.0f + alpha:1.f]]; + NSView* contentView = [window_ contentView]; NSRect contentBounds = [contentView bounds]; diff --git a/tests/cefclient/browser/root_window_win.cc b/tests/cefclient/browser/root_window_win.cc index 8f08aad20..d45c09abf 100644 --- a/tests/cefclient/browser/root_window_win.cc +++ b/tests/cefclient/browser/root_window_win.cc @@ -8,6 +8,7 @@ #include "include/cef_app.h" #include "cefclient/browser/browser_window_osr_win.h" #include "cefclient/browser/browser_window_std_win.h" +#include "cefclient/browser/main_context.h" #include "cefclient/browser/main_message_loop.h" #include "cefclient/browser/resource.h" #include "cefclient/browser/temp_window.h" @@ -201,15 +202,9 @@ ClientWindowHandle RootWindowWin::GetWindowHandle() const { void RootWindowWin::CreateBrowserWindow(bool with_osr, const std::string& startup_url) { if (with_osr) { - CefRefPtr command_line = - CefCommandLine::GetGlobalCommandLine(); - const bool transparent = - command_line->HasSwitch(switches::kTransparentPaintingEnabled); - const bool show_update_rect = - command_line->HasSwitch(switches::kShowUpdateRect); - browser_window_.reset(new BrowserWindowOsrWin(this, startup_url, - transparent, - show_update_rect)); + OsrRenderer::Settings settings; + MainContext::Get()->PopulateOsrSettings(&settings); + browser_window_.reset(new BrowserWindowOsrWin(this, startup_url, settings)); } else { browser_window_.reset(new BrowserWindowStdWin(this, startup_url)); } @@ -225,8 +220,14 @@ void RootWindowWin::CreateRootWindow(const CefBrowserSettings& settings) { const std::wstring& window_title = GetResourceString(IDS_APP_TITLE); const std::wstring& window_class = GetResourceString(IDC_CEFCLIENT); + const cef_color_t background_color = MainContext::Get()->GetBackgroundColor(); + const HBRUSH background_brush = CreateSolidBrush( + RGB(CefColorGetR(background_color), + CefColorGetG(background_color), + CefColorGetB(background_color))); + // Register the window class. - RegisterRootClass(hInstance, window_class); + RegisterRootClass(hInstance, window_class, background_brush); // Register the message used with the find dialog. find_message_id_ = RegisterWindowMessage(FINDMSGSTRING); @@ -342,7 +343,8 @@ void RootWindowWin::CreateRootWindow(const CefBrowserSettings& settings) { // static void RootWindowWin::RegisterRootClass(HINSTANCE hInstance, - const std::wstring& window_class) { + const std::wstring& window_class, + HBRUSH background_brush) { // Only register the class one time. static bool class_registered = false; if (class_registered) @@ -360,7 +362,7 @@ void RootWindowWin::RegisterRootClass(HINSTANCE hInstance, wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CEFCLIENT)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.hbrBackground = background_brush; wcex.lpszMenuName = MAKEINTRESOURCE(IDC_CEFCLIENT); wcex.lpszClassName = window_class.c_str(); wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); @@ -472,7 +474,9 @@ LRESULT CALLBACK RootWindowWin::RootWndProc(HWND hWnd, UINT message, return 0; case WM_ERASEBKGND: - // Never erase the background. + if (self->OnEraseBkgnd()) + break; + // Don't erase the background. return 0; case WM_ENTERMENULOOP: @@ -563,6 +567,11 @@ void RootWindowWin::OnMove() { browser->GetHost()->NotifyMoveOrResizeStarted(); } +bool RootWindowWin::OnEraseBkgnd() { + // Erase the background when the browser does not exist. + return (GetBrowser() == NULL); +} + bool RootWindowWin::OnCommand(UINT id) { if (id >= ID_TESTS_FIRST && id <= ID_TESTS_LAST) { delegate_->OnTest(this, id); diff --git a/tests/cefclient/browser/root_window_win.h b/tests/cefclient/browser/root_window_win.h index 34c615ea3..96e004049 100644 --- a/tests/cefclient/browser/root_window_win.h +++ b/tests/cefclient/browser/root_window_win.h @@ -54,7 +54,8 @@ class RootWindowWin : public RootWindow, // Register the root window class. static void RegisterRootClass(HINSTANCE hInstance, - const std::wstring& window_class); + const std::wstring& window_class, + HBRUSH background_brush); // Window procedure for the edit field. static LRESULT CALLBACK EditWndProc(HWND hWnd, UINT message, WPARAM wParam, @@ -73,6 +74,7 @@ class RootWindowWin : public RootWindow, void OnFocus(); void OnSize(bool minimized); void OnMove(); + bool OnEraseBkgnd(); bool OnCommand(UINT id); void OnFind(); void OnFindEvent(); diff --git a/tests/cefclient/browser/test_runner.cc b/tests/cefclient/browser/test_runner.cc index 9d5ac617f..abdde9dda 100644 --- a/tests/cefclient/browser/test_runner.cc +++ b/tests/cefclient/browser/test_runner.cc @@ -7,9 +7,9 @@ #include #include "include/base/cef_bind.h" +#include "include/cef_parser.h" #include "include/cef_task.h" #include "include/cef_trace.h" -#include "include/cef_url.h" #include "include/cef_web_plugin.h" #include "include/wrapper/cef_closure_task.h" #include "include/wrapper/cef_stream_resource_handler.h" diff --git a/tests/cefclient/common/client_switches.cc b/tests/cefclient/common/client_switches.cc index 4a309f7d0..0de1de39a 100644 --- a/tests/cefclient/common/client_switches.cc +++ b/tests/cefclient/common/client_switches.cc @@ -26,6 +26,7 @@ const char kTransparentPaintingEnabled[] = "transparent-painting-enabled"; const char kShowUpdateRect[] = "show-update-rect"; const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled"; const char kRequestContextPerBrowser[] = "request-context-per-browser"; +const char kBackgroundColor[] = "background-color"; } // namespace switches } // namespace client diff --git a/tests/cefclient/common/client_switches.h b/tests/cefclient/common/client_switches.h index 3b7278d5a..d52e1cdb3 100644 --- a/tests/cefclient/common/client_switches.h +++ b/tests/cefclient/common/client_switches.h @@ -20,6 +20,7 @@ extern const char kTransparentPaintingEnabled[]; extern const char kShowUpdateRect[]; extern const char kMouseCursorChangeDisabled[]; extern const char kRequestContextPerBrowser[]; +extern const char kBackgroundColor[]; } // namespace switches } // namespace client diff --git a/tests/unittests/url_unittest.cc b/tests/unittests/parser_unittest.cc similarity index 85% rename from tests/unittests/url_unittest.cc rename to tests/unittests/parser_unittest.cc index 490c99842..951c6bf59 100644 --- a/tests/unittests/url_unittest.cc +++ b/tests/unittests/parser_unittest.cc @@ -5,11 +5,11 @@ // Include this first to avoid type conflicts with CEF headers. #include "tests/unittests/chromium_includes.h" -#include "include/cef_url.h" +#include "include/cef_parser.h" #include "testing/gtest/include/gtest/gtest.h" // Create the URL using the spec. -TEST(URLTest, CreateURLSpec) { +TEST(ParserTest, CreateURLSpec) { CefURLParts parts; CefString url; CefString(&parts.spec).FromASCII( @@ -21,7 +21,7 @@ TEST(URLTest, CreateURLSpec) { } // Test that host is required. -TEST(URLTest, CreateURLHostRequired) { +TEST(ParserTest, CreateURLHostRequired) { CefURLParts parts; CefString url; CefString(&parts.scheme).FromASCII("http"); @@ -29,7 +29,7 @@ TEST(URLTest, CreateURLHostRequired) { } // Test that scheme is required. -TEST(URLTest, CreateURLSchemeRequired) { +TEST(ParserTest, CreateURLSchemeRequired) { CefURLParts parts; CefString url; CefString(&parts.host).FromASCII("www.example.com"); @@ -37,7 +37,7 @@ TEST(URLTest, CreateURLSchemeRequired) { } // Create the URL using scheme and host. -TEST(URLTest, CreateURLSchemeHost) { +TEST(ParserTest, CreateURLSchemeHost) { CefURLParts parts; CefString url; CefString(&parts.scheme).FromASCII("http"); @@ -47,7 +47,7 @@ TEST(URLTest, CreateURLSchemeHost) { } // Create the URL using scheme, host and path. -TEST(URLTest, CreateURLSchemeHostPath) { +TEST(ParserTest, CreateURLSchemeHostPath) { CefURLParts parts; CefString url; CefString(&parts.scheme).FromASCII("http"); @@ -58,7 +58,7 @@ TEST(URLTest, CreateURLSchemeHostPath) { } // Create the URL using scheme, host, path and query. -TEST(URLTest, CreateURLSchemeHostPathQuery) { +TEST(ParserTest, CreateURLSchemeHostPathQuery) { CefURLParts parts; CefString url; CefString(&parts.scheme).FromASCII("http"); @@ -71,7 +71,7 @@ TEST(URLTest, CreateURLSchemeHostPathQuery) { } // Create the URL using all the various components. -TEST(URLTest, CreateURLAll) { +TEST(ParserTest, CreateURLAll) { CefURLParts parts; CefString url; CefString(&parts.scheme).FromASCII("http"); @@ -88,7 +88,7 @@ TEST(URLTest, CreateURLAll) { } // Parse the URL using scheme and host. -TEST(URLTest, ParseURLSchemeHost) { +TEST(ParserTest, ParseURLSchemeHost) { CefURLParts parts; CefString url; url.FromASCII("http://www.example.com"); @@ -111,7 +111,7 @@ TEST(URLTest, ParseURLSchemeHost) { } // Parse the URL using scheme, host and path. -TEST(URLTest, ParseURLSchemeHostPath) { +TEST(ParserTest, ParseURLSchemeHostPath) { CefURLParts parts; CefString url; url.FromASCII("http://www.example.com/path/to.html"); @@ -135,7 +135,7 @@ TEST(URLTest, ParseURLSchemeHostPath) { } // Parse the URL using scheme, host, path and query. -TEST(URLTest, ParseURLSchemeHostPathQuery) { +TEST(ParserTest, ParseURLSchemeHostPathQuery) { CefURLParts parts; CefString url; url.FromASCII("http://www.example.com/path/to.html?foo=test&bar=test2"); @@ -160,7 +160,7 @@ TEST(URLTest, ParseURLSchemeHostPathQuery) { } // Parse the URL using all the various components. -TEST(URLTest, ParseURLAll) { +TEST(ParserTest, ParseURLAll) { CefURLParts parts; CefString url; url.FromASCII( @@ -190,7 +190,7 @@ TEST(URLTest, ParseURLAll) { } // Parse an invalid URL. -TEST(URLTest, ParseURLInvalid) { +TEST(ParserTest, ParseURLInvalid) { CefURLParts parts; CefString url; url.FromASCII("www.example.com"); @@ -198,7 +198,7 @@ TEST(URLTest, ParseURLInvalid) { } // Parse a non-standard scheme. -TEST(URLTest, ParseURLNonStandard) { +TEST(ParserTest, ParseURLNonStandard) { CefURLParts parts; CefString url; url.FromASCII("custom:something%20else?foo"); @@ -219,7 +219,7 @@ TEST(URLTest, ParseURLNonStandard) { EXPECT_STREQ("foo", query.ToString().c_str()); } -TEST(URLTest, GetMimeType) { +TEST(ParserTest, GetMimeType) { CefString mime_type; mime_type = CefGetMimeType("html"); @@ -232,7 +232,7 @@ TEST(URLTest, GetMimeType) { EXPECT_STREQ("image/gif", mime_type.ToString().c_str()); } -TEST(URLTest, Base64Encode) { +TEST(ParserTest, Base64Encode) { const std::string& test_str_decoded = "A test string"; const std::string& test_str_encoded = "QSB0ZXN0IHN0cmluZw=="; const CefString& encoded_value = @@ -240,7 +240,7 @@ TEST(URLTest, Base64Encode) { EXPECT_STREQ(test_str_encoded.c_str(), encoded_value.ToString().c_str()); } -TEST(URLTest, Base64Decode) { +TEST(ParserTest, Base64Decode) { const std::string& test_str_decoded = "A test string"; const std::string& test_str_encoded = "QSB0ZXN0IHN0cmluZw=="; CefRefPtr decoded_value = CefBase64Decode(test_str_encoded); @@ -258,14 +258,14 @@ TEST(URLTest, Base64Decode) { EXPECT_STREQ(test_str_decoded.c_str(), decoded_str.c_str()); } -TEST(URLTest, URIEncode) { +TEST(ParserTest, URIEncode) { const std::string& test_str_decoded = "A test string="; const std::string& test_str_encoded = "A%20test%20string%3D"; const CefString& encoded_value = CefURIEncode(test_str_decoded, false); EXPECT_STREQ(test_str_encoded.c_str(), encoded_value.ToString().c_str()); } -TEST(URLTest, URIDecode) { +TEST(ParserTest, URIDecode) { const std::string& test_str_decoded = "A test string="; const std::string& test_str_encoded = "A%20test%20string%3D"; const CefString& decoded_value = @@ -274,3 +274,38 @@ TEST(URLTest, URIDecode) { UU_SPACES | UU_URL_SPECIAL_CHARS)); EXPECT_STREQ(test_str_decoded.c_str(), decoded_value.ToString().c_str()); } + +TEST(ParserTest, ParseCSSColor) { + std::string value; + cef_color_t color; + + // Color by name. + value = "red"; + color = 0; + EXPECT_TRUE(CefParseCSSColor(value, false, color)); + EXPECT_EQ(CefColorSetARGB(255, 255, 0, 0), color); + + // Color by RGB. + value = "rgb(1,2,3)"; + color = 0; + EXPECT_TRUE(CefParseCSSColor(value, false, color)); + EXPECT_EQ(CefColorSetARGB(255, 1, 2, 3), color); + + // Color by RGBA. + value = "rgba(1,2,3,0.0)"; + color = 0; + EXPECT_TRUE(CefParseCSSColor(value, false, color)); + EXPECT_EQ(CefColorSetARGB(0, 1, 2, 3), color); + + // Color by hex code. + value = "#FFAACC"; + color = 0; + EXPECT_TRUE(CefParseCSSColor(value, false, color)); + EXPECT_EQ(CefColorSetARGB(255, 0xFF, 0xAA, 0xCC), color); + + // Invalid color. + value = "not_a_color"; + color = 0; + EXPECT_FALSE(CefParseCSSColor(value, false, color)); + EXPECT_EQ(0U, color); +} diff --git a/tools/cef_parser.py b/tools/cef_parser.py index 80c83fcc9..71bbcedc6 100644 --- a/tools/cef_parser.py +++ b/tools/cef_parser.py @@ -377,6 +377,7 @@ _simpletypes = { 'bool' : ['int', '0'], 'char': ['char', '0'], 'char* const': ['char* const', 'NULL'], + 'cef_color_t': ['cef_color_t', '0'], 'CefCursorHandle' : ['cef_cursor_handle_t', 'kNullCursorHandle'], 'CefEventHandle' : ['cef_event_handle_t', 'kNullEventHandle'], 'CefWindowHandle' : ['cef_window_handle_t', 'kNullWindowHandle'],