Make CEF compliant with Google/Chromium style (issue #473).

- Add a new check_style tool based on Google's cpplint that can be used to verify compliance of pending changes and specific files/directories.
- Update existing CEF source code to be compliant with the style requirements.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@463 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-01-09 23:46:23 +00:00
parent 9cc61f448b
commit 1073577d03
558 changed files with 9002 additions and 10977 deletions

View File

@@ -28,14 +28,15 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_BUILD_H
#define _CEF_BUILD_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_BUILD_H_
#define CEF_INCLUDE_INTERNAL_CEF_BUILD_H_
#pragma once
#if defined(BUILDING_CEF_SHARED)
#include "base/compiler_specific.h"
#else // !BUILDING_CEF_SHARED
#else // !BUILDING_CEF_SHARED
#if defined(_WIN32)
#ifndef OS_WIN
@@ -116,13 +117,13 @@
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \
code \
MSVC_POP_WARNING()
#else // !COMPILER_MSVC
#else // !COMPILER_MSVC
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code
#endif // !COMPILER_MSVC
#endif // !COMPILER_MSVC
#endif
#endif // !BUILDING_CEF_SHARED
#endif // !BUILDING_CEF_SHARED
#endif // _CEF_BUILD_H
#endif // CEF_INCLUDE_INTERNAL_CEF_BUILD_H_

View File

@@ -28,10 +28,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_EXPORT_H
#define _CEF_EXPORT_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
#define CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_
#pragma once
#include "cef_build.h"
#include "include/internal/cef_build.h"
#if defined(COMPILER_MSVC)
@@ -51,4 +52,4 @@
#endif // COMPILER_GCC
#endif // _CEF_EXPORT_H
#endif // CEF_INCLUDE_INTERNAL_CEF_EXPORT_H_

View File

@@ -28,45 +28,39 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_LINUX_H
#define _CEF_LINUX_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
#define CEF_INCLUDE_INTERNAL_CEF_LINUX_H_
#pragma once
#if defined(OS_LINUX)
#include <pthread.h>
#include "cef_types_linux.h"
#include "cef_types_wrappers.h"
#include "include/internal/cef_types_linux.h"
#include "include/internal/cef_types_wrappers.h"
// Atomic increment and decrement.
inline long CefAtomicIncrement(long volatile *pDest)
{
inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_add_and_fetch(pDest, 1);
}
inline long CefAtomicDecrement(long volatile *pDest)
{
inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_sub_and_fetch(pDest, 1);
}
// Critical section wrapper.
class CefCriticalSection
{
public:
CefCriticalSection()
{
class CefCriticalSection {
public:
CefCriticalSection() {
pthread_mutexattr_init(&attr_);
pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&lock_, &attr_);
}
virtual ~CefCriticalSection()
{
virtual ~CefCriticalSection() {
pthread_mutex_destroy(&lock_);
pthread_mutexattr_destroy(&attr_);
}
void Lock()
{
void Lock() {
pthread_mutex_lock(&lock_);
}
void Unlock()
{
void Unlock() {
pthread_mutex_unlock(&lock_);
}
@@ -84,25 +78,23 @@ struct CefWindowInfoTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->m_Widget = src->m_Widget;
target->m_ParentWidget = src->m_ParentWidget;
}
};
// Class representing window information.
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits>
{
public:
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
void SetAsChild(CefWindowHandle ParentWidget)
{
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
void SetAsChild(CefWindowHandle ParentWidget) {
m_ParentWidget = ParentWidget;
}
};
@@ -113,8 +105,8 @@ struct CefPrintInfoTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->m_Scale = src->m_Scale;
}
};
@@ -122,6 +114,6 @@ struct CefPrintInfoTraits {
// Class representing print context information.
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
#endif // OS_LINUX
#endif // OS_LINUX
#endif // _CEF_LINUX_H
#endif // CEF_INCLUDE_INTERNAL_CEF_LINUX_H_

View File

@@ -28,21 +28,20 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_MAC_H
#define _CEF_MAC_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_MAC_H_
#define CEF_INCLUDE_INTERNAL_CEF_MAC_H_
#pragma once
#if defined(OS_MACOSX)
#include <pthread.h>
#include "cef_types_mac.h"
#include "cef_types_wrappers.h"
#include "include/internal/cef_types_mac.h"
#include "include/internal/cef_types_wrappers.h"
// Atomic increment and decrement.
inline long CefAtomicIncrement(long volatile *pDest)
{
inline long CefAtomicIncrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_add_and_fetch(pDest, 1);
}
inline long CefAtomicDecrement(long volatile *pDest)
{
inline long CefAtomicDecrement(long volatile *pDest) { // NOLINT(runtime/int)
return __sync_sub_and_fetch(pDest, 1);
}
@@ -51,26 +50,21 @@ inline long CefAtomicDecrement(long volatile *pDest)
#define CefCursorHandle cef_cursor_handle_t
// Critical section wrapper.
class CefCriticalSection
{
public:
CefCriticalSection()
{
class CefCriticalSection {
public:
CefCriticalSection() {
pthread_mutexattr_init(&attr_);
pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&lock_, &attr_);
}
virtual ~CefCriticalSection()
{
virtual ~CefCriticalSection() {
pthread_mutex_destroy(&lock_);
pthread_mutexattr_destroy(&attr_);
}
void Lock()
{
void Lock() {
pthread_mutex_lock(&lock_);
}
void Unlock()
{
void Unlock() {
pthread_mutex_unlock(&lock_);
}
@@ -83,13 +77,12 @@ struct CefWindowInfoTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s)
{
static inline void clear(struct_type* s) {
cef_string_clear(&s->m_windowName);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->m_View = src->m_View;
target->m_ParentView = src->m_ParentView;
cef_string_set(src->m_windowName.str, src->m_windowName.length,
@@ -103,18 +96,16 @@ struct CefWindowInfoTraits {
};
// Class representing window information.
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits>
{
public:
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
void SetAsChild(CefWindowHandle ParentView, int x, int y, int width,
int height)
{
int height) {
m_ParentView = ParentView;
m_x = x;
m_y = y;
@@ -130,8 +121,8 @@ struct CefPrintInfoTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->m_Scale = src->m_Scale;
}
};
@@ -139,6 +130,6 @@ struct CefPrintInfoTraits {
// Class representing print context information.
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
#endif // OS_MACOSX
#endif // OS_MACOSX
#endif // _CEF_MAC_H
#endif // CEF_INCLUDE_INTERNAL_CEF_MAC_H_

View File

@@ -28,11 +28,12 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_NPLUGIN_TYPES_H
#define _CEF_NPLUGIN_TYPES_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_NPLUGIN_TYPES_H_
#define CEF_INCLUDE_INTERNAL_CEF_NPLUGIN_TYPES_H_
#pragma once
#include "cef_export.h"
#include "cef_string.h"
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/nphostapi.h"
@@ -61,15 +62,15 @@ typedef struct _cef_plugin_info_t {
// A description of the plugin.
cef_string_t description;
// A pipe (|) delimited list of mime type values that the plugin supports.
cef_string_t mime_types;
// A pipe (|) delimited list of extension values. Each value is associated
// with the mime type value at the same position. Multiple file extensions
// for the same mime type may be delimited with commas (,).
cef_string_t file_extensions;
// A pipe (|) delimited list of description values. Each value is associated
// with the mime type value at the same position.
cef_string_t type_descriptions;
@@ -86,4 +87,4 @@ typedef struct _cef_plugin_info_t {
}
#endif
#endif // _CEF_NPLUGIN_TYPES_H
#endif // CEF_INCLUDE_INTERNAL_CEF_NPLUGIN_TYPES_H_

View File

@@ -29,8 +29,9 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_PTR_H
#define _CEF_PTR_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_PTR_H_
#define CEF_INCLUDE_INTERNAL_CEF_PTR_H_
#pragma once
#include <stddef.h>
@@ -148,7 +149,7 @@ class CefRefPtr {
CefRefPtr() : ptr_(NULL) {
}
CefRefPtr(T* p) : ptr_(p) {
CefRefPtr(T* p) : ptr_(p) { // NOLINT(runtime/explicit)
if (ptr_)
ptr_->AddRef();
}
@@ -188,11 +189,11 @@ class CefRefPtr {
}
void swap(CefRefPtr<T>& r) {
swap(&r.ptr_);
swap(&r.ptr_); // NOLINT(build/include_what_you_use)
}
private:
T* ptr_;
};
#endif // _CEF_PTR_H
#endif // CEF_INCLUDE_INTERNAL_CEF_PTR_H_

View File

@@ -27,27 +27,28 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_H
#define _CEF_STRING_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_H_
#pragma once
// The CEF interface is built with one string type as the default. Comment out
// all but one of the CEF_STRING_TYPE_* defines below to specify the default.
// If you change the default you MUST recompile all of CEF.
// Build with the UTF8 string type as default.
//#define CEF_STRING_TYPE_UTF8 1
// #define CEF_STRING_TYPE_UTF8 1
// Build with the UTF16 string type as default.
#define CEF_STRING_TYPE_UTF16 1
// Build with the wide string type as default.
//#define CEF_STRING_TYPE_WIDE 1
// #define CEF_STRING_TYPE_WIDE 1
#include "cef_string_types.h"
#include "include/internal/cef_string_types.h"
#ifdef __cplusplus
#include "cef_string_wrappers.h"
#include "include/internal/cef_string_wrappers.h"
#if defined(CEF_STRING_TYPE_UTF16)
typedef CefStringUTF16 CefString;
#elif defined(CEF_STRING_TYPE_UTF8)
@@ -55,7 +56,7 @@ typedef CefStringUTF8 CefString;
#elif defined(CEF_STRING_TYPE_WIDE)
typedef CefStringWide CefString;
#endif
#endif // __cplusplus
#endif // __cplusplus
#if defined(CEF_STRING_TYPE_UTF8)
typedef char cef_char_t;
@@ -109,4 +110,4 @@ typedef cef_string_userfree_wide_t cef_string_userfree_t;
#error Please choose a string type.
#endif
#endif // _CEF_STRING_H
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_H_

View File

@@ -27,11 +27,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_LIST_H
#define _CEF_STRING_LIST_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_
#pragma once
#include "cef_export.h"
#include "cef_string.h"
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
@@ -84,4 +85,4 @@ CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list);
}
#endif
#endif // _CEF_STRING_LIST_H
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_LIST_H_

View File

@@ -27,11 +27,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_MAP_H
#define _CEF_STRING_MAP_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_
#pragma once
#include "cef_export.h"
#include "cef_string.h"
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
@@ -93,4 +94,4 @@ CEF_EXPORT void cef_string_map_free(cef_string_map_t map);
}
#endif
#endif // _CEF_STRING_MAP_H
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_MAP_H_

View File

@@ -27,11 +27,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_MULTIMAP_H
#define _CEF_STRING_MULTIMAP_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_
#pragma once
#include "cef_export.h"
#include "cef_string.h"
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
@@ -101,4 +102,4 @@ CEF_EXPORT void cef_string_multimap_free(cef_string_multimap_t map);
}
#endif
#endif // _CEF_STRING_MULTIMAP_H
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_MULTIMAP_H_

View File

@@ -27,8 +27,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_TYPES_T
#define _CEF_STRING_TYPES_T
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_
#pragma once
// CEF provides functions for converting between UTF-8, -16 and -32 strings.
// CEF string types are safe for reading from multiple threads but not for
@@ -39,8 +40,8 @@
extern "C" {
#endif
#include "cef_build.h"
#include "cef_export.h"
#include "include/internal/cef_build.h"
#include "include/internal/cef_export.h"
#include <stddef.h>
// CEF character type definitions. wchar_t is 2 bytes on Windows and 4 bytes on
@@ -48,12 +49,12 @@ extern "C" {
#if defined(OS_WIN)
typedef wchar_t char16;
#else // !OS_WIN
typedef unsigned short char16;
#else // !OS_WIN
typedef unsigned short char16; // NOLINT (runtime/int)
#ifndef WCHAR_T_IS_UTF32
#define WCHAR_T_IS_UTF32
#endif // WCHAR_T_IS_UTF32
#endif // !OS_WIN
#endif // WCHAR_T_IS_UTF32
#endif // !OS_WIN
// CEF string type definitions. Whomever allocates |str| is responsible for
@@ -200,4 +201,4 @@ CEF_EXPORT void cef_string_userfree_utf16_free(cef_string_userfree_utf16_t str);
}
#endif
#endif // _CEF_STRING_TYPES_T
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_TYPES_H_

View File

@@ -27,15 +27,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_STRING_WRAPPERS_H
#define _CEF_STRING_WRAPPERS_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_
#define CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_
#pragma once
#include <memory.h>
#include <string>
#include "include/internal/cef_string_types.h"
#include "cef_string_types.h"
#ifdef BUILDING_CEF_SHARED
#include "base/string16.h"
#endif
#include <memory.h>
#include <string>
///
// Traits implementation for wide character strings.
@@ -44,25 +47,27 @@ struct CefStringTraitsWide {
typedef wchar_t char_type;
typedef cef_string_wide_t struct_type;
typedef cef_string_userfree_wide_t userfree_struct_type;
static inline void clear(struct_type *s) { cef_string_wide_clear(s); }
static inline int set(const char_type* src, size_t src_size,
struct_type *output, int copy)
{ return cef_string_wide_set(src, src_size, output, copy); }
static inline int compare(const struct_type* s1, const struct_type* s2)
{ return cef_string_wide_cmp(s1, s2); }
static inline userfree_struct_type userfree_alloc()
{ return cef_string_userfree_wide_alloc(); }
static inline void userfree_free(userfree_struct_type ufs)
{ return cef_string_userfree_wide_free(ufs); }
struct_type* output, int copy) {
return cef_string_wide_set(src, src_size, output, copy);
}
static inline int compare(const struct_type* s1, const struct_type* s2) {
return cef_string_wide_cmp(s1, s2);
}
static inline userfree_struct_type userfree_alloc() {
return cef_string_userfree_wide_alloc();
}
static inline void userfree_free(userfree_struct_type ufs) {
return cef_string_userfree_wide_free(ufs);
}
// Conversion methods.
static inline bool from_ascii(const char* str, size_t len, struct_type *s)
{
static inline bool from_ascii(const char* str, size_t len, struct_type *s) {
return cef_string_ascii_to_wide(str, len, s) ? true : false;
}
static inline std::string to_string(const struct_type *s)
{
static inline std::string to_string(const struct_type *s) {
cef_string_utf8_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_wide_to_utf8(s->str, s->length, &cstr);
@@ -72,23 +77,19 @@ struct CefStringTraitsWide {
cef_string_utf8_clear(&cstr);
return str;
}
static inline bool from_string(const std::string& str, struct_type *s)
{
static inline bool from_string(const std::string& str, struct_type *s) {
return cef_string_utf8_to_wide(str.c_str(), str.length(), s) ? true : false;
}
static inline std::wstring to_wstring(const struct_type *s)
{
static inline std::wstring to_wstring(const struct_type *s) {
return std::wstring(s->str, s->length);
}
static inline bool from_wstring(const std::wstring& str, struct_type *s)
{
static inline bool from_wstring(const std::wstring& str, struct_type *s) {
return cef_string_wide_set(str.c_str(), str.length(), s, true) ?
true : false;
}
#if defined(BUILDING_CEF_SHARED)
#if defined(WCHAR_T_IS_UTF32)
static inline string16 to_string16(const struct_type *s)
{
static inline string16 to_string16(const struct_type *s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_wide_to_utf16(s->str, s->length, &cstr);
@@ -98,23 +99,20 @@ struct CefStringTraitsWide {
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const string16& str, struct_type *s)
{
static inline bool from_string16(const string16& str, struct_type *s) {
return cef_string_utf16_to_wide(str.c_str(), str.length(), s) ?
true : false;
}
#else // WCHAR_T_IS_UTF32
static inline string16 to_string16(const struct_type *s)
{
#else // WCHAR_T_IS_UTF32
static inline string16 to_string16(const struct_type *s) {
return string16(s->str, s->length);
}
static inline bool from_string16(const string16& str, struct_type *s)
{
static inline bool from_string16(const string16& str, struct_type *s) {
return cef_string_wide_set(str.c_str(), str.length(), s, true) ?
true : false;
}
#endif // WCHAR_T_IS_UTF32
#endif // BUILDING_CEF_SHARED
#endif // WCHAR_T_IS_UTF32
#endif // BUILDING_CEF_SHARED
};
///
@@ -124,33 +122,33 @@ struct CefStringTraitsUTF8 {
typedef char char_type;
typedef cef_string_utf8_t struct_type;
typedef cef_string_userfree_utf8_t userfree_struct_type;
static inline void clear(struct_type *s) { cef_string_utf8_clear(s); }
static inline int set(const char_type* src, size_t src_size,
struct_type *output, int copy)
{ return cef_string_utf8_set(src, src_size, output, copy); }
static inline int compare(const struct_type* s1, const struct_type* s2)
{ return cef_string_utf8_cmp(s1, s2); }
static inline userfree_struct_type userfree_alloc()
{ return cef_string_userfree_utf8_alloc(); }
static inline void userfree_free(userfree_struct_type ufs)
{ return cef_string_userfree_utf8_free(ufs); }
struct_type* output, int copy) {
return cef_string_utf8_set(src, src_size, output, copy);
}
static inline int compare(const struct_type* s1, const struct_type* s2) {
return cef_string_utf8_cmp(s1, s2);
}
static inline userfree_struct_type userfree_alloc() {
return cef_string_userfree_utf8_alloc();
}
static inline void userfree_free(userfree_struct_type ufs) {
return cef_string_userfree_utf8_free(ufs);
}
// Conversion methods.
static inline bool from_ascii(const char* str, size_t len, struct_type* s)
{
static inline bool from_ascii(const char* str, size_t len, struct_type* s) {
return cef_string_utf8_copy(str, len, s) ? true : false;
}
static inline std::string to_string(const struct_type* s)
{
static inline std::string to_string(const struct_type* s) {
return std::string(s->str, s->length);
}
static inline bool from_string(const std::string& str, struct_type* s)
{
static inline bool from_string(const std::string& str, struct_type* s) {
return cef_string_utf8_copy(str.c_str(), str.length(), s) ? true : false;
}
static inline std::wstring to_wstring(const struct_type* s)
{
static inline std::wstring to_wstring(const struct_type* s) {
cef_string_wide_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf8_to_wide(s->str, s->length, &cstr);
@@ -160,13 +158,11 @@ struct CefStringTraitsUTF8 {
cef_string_wide_clear(&cstr);
return str;
}
static inline bool from_wstring(const std::wstring& str, struct_type* s)
{
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return cef_string_wide_to_utf8(str.c_str(), str.length(), s) ? true : false;
}
#if defined(BUILDING_CEF_SHARED)
static inline string16 to_string16(const struct_type* s)
{
static inline string16 to_string16(const struct_type* s) {
cef_string_utf16_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf8_to_utf16(s->str, s->length, &cstr);
@@ -176,12 +172,11 @@ struct CefStringTraitsUTF8 {
cef_string_utf16_clear(&cstr);
return str;
}
static inline bool from_string16(const string16& str, struct_type* s)
{
static inline bool from_string16(const string16& str, struct_type* s) {
return cef_string_utf16_to_utf8(str.c_str(), str.length(), s) ?
true : false;
}
#endif // BUILDING_CEF_SHARED
#endif // BUILDING_CEF_SHARED
};
///
@@ -191,25 +186,27 @@ struct CefStringTraitsUTF16 {
typedef char16 char_type;
typedef cef_string_utf16_t struct_type;
typedef cef_string_userfree_utf16_t userfree_struct_type;
static inline void clear(struct_type *s) { cef_string_utf16_clear(s); }
static inline int set(const char_type* src, size_t src_size,
struct_type *output, int copy)
{ return cef_string_utf16_set(src, src_size, output, copy); }
static inline int compare(const struct_type* s1, const struct_type* s2)
{ return cef_string_utf16_cmp(s1, s2); }
static inline userfree_struct_type userfree_alloc()
{ return cef_string_userfree_utf16_alloc(); }
static inline void userfree_free(userfree_struct_type ufs)
{ return cef_string_userfree_utf16_free(ufs); }
struct_type* output, int copy) {
return cef_string_utf16_set(src, src_size, output, copy);
}
static inline int compare(const struct_type* s1, const struct_type* s2) {
return cef_string_utf16_cmp(s1, s2);
}
static inline userfree_struct_type userfree_alloc() {
return cef_string_userfree_utf16_alloc();
}
static inline void userfree_free(userfree_struct_type ufs) {
return cef_string_userfree_utf16_free(ufs);
}
// Conversion methods.
static inline bool from_ascii(const char* str, size_t len, struct_type* s)
{
static inline bool from_ascii(const char* str, size_t len, struct_type* s) {
return cef_string_ascii_to_utf16(str, len, s) ? true : false;
}
static inline std::string to_string(const struct_type* s)
{
static inline std::string to_string(const struct_type* s) {
cef_string_utf8_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf16_to_utf8(s->str, s->length, &cstr);
@@ -219,14 +216,12 @@ struct CefStringTraitsUTF16 {
cef_string_utf8_clear(&cstr);
return str;
}
static inline bool from_string(const std::string& str, struct_type* s)
{
static inline bool from_string(const std::string& str, struct_type* s) {
return cef_string_utf8_to_utf16(str.c_str(), str.length(), s) ?
true : false;
}
#if defined(WCHAR_T_IS_UTF32)
static inline std::wstring to_wstring(const struct_type* s)
{
static inline std::wstring to_wstring(const struct_type* s) {
cef_string_wide_t cstr;
memset(&cstr, 0, sizeof(cstr));
cef_string_utf16_to_wide(s->str, s->length, &cstr);
@@ -236,33 +231,28 @@ struct CefStringTraitsUTF16 {
cef_string_wide_clear(&cstr);
return str;
}
static inline bool from_wstring(const std::wstring& str, struct_type* s)
{
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return cef_string_wide_to_utf16(str.c_str(), str.length(), s) ?
true : false;
}
#else // WCHAR_T_IS_UTF32
static inline std::wstring to_wstring(const struct_type* s)
{
#else // WCHAR_T_IS_UTF32
static inline std::wstring to_wstring(const struct_type* s) {
return std::wstring(s->str, s->length);
}
static inline bool from_wstring(const std::wstring& str, struct_type* s)
{
static inline bool from_wstring(const std::wstring& str, struct_type* s) {
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ?
true : false;
}
#endif // WCHAR_T_IS_UTF32
#endif // WCHAR_T_IS_UTF32
#if defined(BUILDING_CEF_SHARED)
static inline string16 to_string16(const struct_type* s)
{
static inline string16 to_string16(const struct_type* s) {
return string16(s->str, s->length);
}
static inline bool from_string16(const string16& str, struct_type* s)
{
static inline bool from_string16(const string16& str, struct_type* s) {
return cef_string_utf16_set(str.c_str(), str.length(), s, true) ?
true : false;
}
#endif // BUILDING_CEF_SHARED
#endif // BUILDING_CEF_SHARED
};
///
@@ -295,7 +285,7 @@ struct CefStringTraitsUTF16 {
///
template <class traits>
class CefStringBase {
public:
public:
typedef typename traits::char_type char_type;
typedef typename traits::struct_type struct_type;
typedef typename traits::userfree_struct_type userfree_struct_type;
@@ -304,32 +294,42 @@ public:
// Default constructor.
///
CefStringBase() : string_(NULL), owner_(false) {}
///
// Create a new string from an existing string. Data will always be copied.
///
CefStringBase(const CefStringBase& str) : string_(NULL), owner_(false)
{ FromString(str.c_str(), str.length(), true); }
CefStringBase(const CefStringBase& str)
: string_(NULL), owner_(false) {
FromString(str.c_str(), str.length(), true);
}
///
// Create a new string from an existing std::string. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
CefStringBase(const std::string& src) : string_(NULL), owner_(false)
{ FromString(src); }
CefStringBase(const char* src) : string_(NULL), owner_(false)
{ FromString(std::string(src)); }
CefStringBase(const std::string& src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString(src);
}
CefStringBase(const char* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString(std::string(src));
}
///
// Create a new string from an existing std::wstring. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
CefStringBase(const std::wstring& src) : string_(NULL), owner_(false)
{ FromWString(src); }
CefStringBase(const wchar_t* src) : string_(NULL), owner_(false)
{ FromWString(std::wstring(src)); }
CefStringBase(const std::wstring& src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromWString(src);
}
CefStringBase(const wchar_t* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromWString(std::wstring(src));
}
#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32))
///
@@ -337,12 +337,16 @@ public:
// copied. Translation will occur if necessary based on the underlying string
// type.
///
CefStringBase(const string16& src) : string_(NULL), owner_(false)
{ FromString16(src); }
CefStringBase(const char16* src) : string_(NULL), owner_(false)
{ FromString16(string16(src)); }
#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
CefStringBase(const string16& src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString16(src);
}
CefStringBase(const char16* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
FromString16(string16(src));
}
#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
///
// Create a new string from an existing character array. If |copy| is true
// this class will copy the data. Otherwise, this class will reference the
@@ -350,16 +354,17 @@ public:
// and will not be freed by this class.
///
CefStringBase(const char_type* src, size_t src_len, bool copy)
: string_(NULL), owner_(false)
{ FromString(src, src_len, copy); }
: string_(NULL), owner_(false) {
FromString(src, src_len, copy);
}
///
// Create a new string referencing an existing string structure without taking
// ownership. Referenced structures must exist for the lifetime of this class
// and will not be freed by this class.
///
CefStringBase(const struct_type* src) : string_(NULL), owner_(false)
{
CefStringBase(const struct_type* src) // NOLINT(runtime/explicit)
: string_(NULL), owner_(false) {
if (!src)
return;
// Reference the existing structure without taking ownership.
@@ -376,17 +381,17 @@ public:
// Return a read-only pointer to the string data.
///
const char_type* c_str() const { return (string_ ? string_->str : NULL); }
///
// Return the length of the string data.
///
size_t length() const { return (string_ ? string_->length : 0); }
///
// Return the length of the string data.
///
inline size_t size() const { return length(); }
///
// Returns true if the string is empty.
///
@@ -395,8 +400,7 @@ public:
///
// Compare this string to the specified string.
///
int compare(const CefStringBase& str) const
{
int compare(const CefStringBase& str) const {
if (empty() && str.empty())
return 0;
if (empty())
@@ -405,12 +409,11 @@ public:
return 1;
return traits::compare(string_, str.GetStruct());
}
///
// Clear the string data.
///
void clear()
{
void clear() {
if (!empty())
traits::clear(string_);
}
@@ -422,29 +425,27 @@ public:
// Returns true if this class owns the underlying string structure.
///
bool IsOwner() const { return owner_; }
///
// Returns a read-only pointer to the underlying string structure. May return
// NULL if no structure is currently allocated.
///
const struct_type* GetStruct() const { return string_; }
///
// Returns a writable pointer to the underlying string structure. Will never
// return NULL.
///
struct_type* GetWritableStruct()
{
struct_type* GetWritableStruct() {
AllocIfNeeded();
return string_;
}
///
// Clear the state of this class. The underlying string structure and data
// will be freed if this class owns the structure.
///
void ClearAndFree()
{
void ClearAndFree() {
if (!string_)
return;
if (owner_) {
@@ -459,11 +460,10 @@ public:
// Attach to the specified string structure. If |owner| is true this class
// will take ownership of the structure.
///
void Attach(struct_type* str, bool owner)
{
void Attach(struct_type* str, bool owner) {
// Free the previous structure and data, if any.
ClearAndFree();
string_ = str;
owner_ = owner;
}
@@ -473,8 +473,7 @@ public:
// userfree structure itself will be freed. Only use this method with userfree
// structures.
///
void AttachToUserFree(userfree_struct_type str)
{
void AttachToUserFree(userfree_struct_type str) {
// Free the previous structure and data, if any.
ClearAndFree();
@@ -484,7 +483,7 @@ public:
AllocIfNeeded();
owner_ = true;
memcpy(string_, str, sizeof(struct_type));
// Free the |str| structure but not the data.
memset(str, 0, sizeof(struct_type));
traits::userfree_free(str);
@@ -495,8 +494,7 @@ public:
// this method if you already hold a pointer to the underlying string
// structure.
///
void Detach()
{
void Detach() {
string_ = NULL;
owner_ = false;
}
@@ -506,14 +504,13 @@ public:
// data. This class will be disassociated from the data. May return NULL if
// this string class currently contains no data.
///
userfree_struct_type DetachToUserFree()
{
userfree_struct_type DetachToUserFree() {
if (empty())
return NULL;
userfree_struct_type str = traits::userfree_alloc();
memcpy(str, string_, sizeof(struct_type));
// Free this class' structure but not the data.
memset(string_, 0, sizeof(struct_type));
ClearAndFree();
@@ -527,8 +524,7 @@ public:
// existing data. Referenced data must exist for the lifetime of this class
// and will not be freed by this class.
///
bool FromString(const char_type* src, size_t src_len, bool copy)
{
bool FromString(const char_type* src, size_t src_len, bool copy) {
if (src == NULL || src_len == 0) {
clear();
return true;
@@ -536,14 +532,13 @@ public:
AllocIfNeeded();
return traits::set(src, src_len, string_, copy) ? true : false;
}
///
// Set this string's data from an existing ASCII string. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromASCII(const char* str)
{
bool FromASCII(const char* str) {
size_t len = str ? strlen(str) : 0;
if (len == 0) {
clear();
@@ -552,25 +547,23 @@ public:
AllocIfNeeded();
return traits::from_ascii(str, len, string_);
}
///
// Return this string's data as a std::string. Translation will occur if
// necessary based on the underlying string type.
///
std::string ToString() const
{
std::string ToString() const {
if (empty())
return std::string();
return traits::to_string(string_);
}
///
// Set this string's data from an existing std::string. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromString(const std::string& str)
{
bool FromString(const std::string& str) {
if (str.empty()) {
clear();
return true;
@@ -578,25 +571,23 @@ public:
AllocIfNeeded();
return traits::from_string(str, string_);
}
///
// Return this string's data as a std::wstring. Translation will occur if
// necessary based on the underlying string type.
///
std::wstring ToWString() const
{
std::wstring ToWString() const {
if (empty())
return std::wstring();
return traits::to_wstring(string_);
}
///
// Set this string's data from an existing std::wstring. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromWString(const std::wstring& str)
{
bool FromWString(const std::wstring& str) {
if (str.empty()) {
clear();
return true;
@@ -609,20 +600,18 @@ public:
// Return this string's data as a string16. Translation will occur if
// necessary based on the underlying string type.
///
string16 ToString16() const
{
string16 ToString16() const {
if (empty())
return string16();
return traits::to_string16(string_);
}
///
// Set this string's data from an existing string16. Data will be always
// copied. Translation will occur if necessary based on the underlying string
// type.
///
bool FromString16(const string16& str)
{
bool FromString16(const string16& str) {
if (str.empty()) {
clear();
return true;
@@ -630,51 +619,76 @@ public:
AllocIfNeeded();
return traits::from_string16(str, string_);
}
#endif // BUILDING_CEF_SHARED
#endif // BUILDING_CEF_SHARED
///
// Comparison operator overloads.
///
bool operator<(const CefStringBase& str) const
{ return (compare(str) < 0); }
bool operator<=(const CefStringBase& str) const
{ return (compare(str) <= 0); }
bool operator>(const CefStringBase& str) const
{ return (compare(str) > 0); }
bool operator>=(const CefStringBase& str) const
{ return (compare(str) >= 0); }
bool operator==(const CefStringBase& str) const
{ return (compare(str) == 0); }
bool operator!=(const CefStringBase& str) const
{ return (compare(str) != 0); }
bool operator<(const CefStringBase& str) const {
return (compare(str) < 0);
}
bool operator<=(const CefStringBase& str) const {
return (compare(str) <= 0);
}
bool operator>(const CefStringBase& str) const {
return (compare(str) > 0);
}
bool operator>=(const CefStringBase& str) const {
return (compare(str) >= 0);
}
bool operator==(const CefStringBase& str) const {
return (compare(str) == 0);
}
bool operator!=(const CefStringBase& str) const {
return (compare(str) != 0);
}
///
// Assignment operator overloads.
///
CefStringBase& operator=(const CefStringBase& str)
{ FromString(str.c_str(), str.length(), true); return *this; }
operator std::string() const { return ToString(); }
CefStringBase& operator=(const std::string& str)
{ FromString(str); return *this; }
CefStringBase& operator=(const char* str)
{ FromString(std::string(str)); return *this; }
operator std::wstring() const { return ToWString(); }
CefStringBase& operator=(const std::wstring& str)
{ FromWString(str); return *this; }
CefStringBase& operator=(const wchar_t* str)
{ FromWString(std::wstring(str)); return *this; }
CefStringBase& operator=(const CefStringBase& str) {
FromString(str.c_str(), str.length(), true);
return *this;
}
operator std::string() const {
return ToString();
}
CefStringBase& operator=(const std::string& str) {
FromString(str);
return *this;
}
CefStringBase& operator=(const char* str) {
FromString(std::string(str));
return *this;
}
operator std::wstring() const {
return ToWString();
}
CefStringBase& operator=(const std::wstring& str) {
FromWString(str);
return *this;
}
CefStringBase& operator=(const wchar_t* str) {
FromWString(std::wstring(str));
return *this;
}
#if (defined(BUILDING_CEF_SHARED) && defined(WCHAR_T_IS_UTF32))
operator string16() const { return ToString16(); }
CefStringBase& operator=(const string16& str)
{ FromString16(str); return *this; }
CefStringBase& operator=(const char16* str)
{ FromString16(string16(str)); return *this; }
#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
operator string16() const {
return ToString16();
}
CefStringBase& operator=(const string16& str) {
FromString16(str);
return *this;
}
CefStringBase& operator=(const char16* str) {
FromString16(string16(str));
return *this;
}
#endif // BUILDING_CEF_SHARED && WCHAR_T_IS_UTF32
private:
private:
// Allocate the string structure if it doesn't already exist.
void AllocIfNeeded()
{
void AllocIfNeeded() {
if (string_ == NULL) {
string_ = new struct_type;
memset(string_, 0, sizeof(struct_type));
@@ -691,4 +705,4 @@ typedef CefStringBase<CefStringTraitsWide> CefStringWide;
typedef CefStringBase<CefStringTraitsUTF8> CefStringUTF8;
typedef CefStringBase<CefStringTraitsUTF16> CefStringUTF16;
#endif // _CEF_STRING_WRAPPERS_H
#endif // CEF_INCLUDE_INTERNAL_CEF_STRING_WRAPPERS_H_

View File

@@ -27,21 +27,21 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TIME_H
#define _CEF_TIME_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_TIME_H_
#define CEF_INCLUDE_INTERNAL_CEF_TIME_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "cef_export.h"
#include "include/internal/cef_export.h"
#include <time.h>
///
// Time information. Values should always be in UTC.
///
typedef struct _cef_time_t
{
typedef struct _cef_time_t {
int year; // Four digit year "2007"
int month; // 1-based month (values 1 = January, etc.)
#if !defined(OS_MACOSX)
@@ -75,4 +75,4 @@ CEF_EXPORT int cef_time_from_doublet(double time, cef_time_t* cef_time);
}
#endif
#endif // _CEF_TIME_H
#endif // CEF_INCLUDE_INTERNAL_CEF_TIME_H_

View File

@@ -53,8 +53,8 @@
// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3));
// // foo->SomeMeth(1, 2, 3);
#ifndef BASE_TUPLE_H__
#define BASE_TUPLE_H__
#ifndef CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_
#define CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_
#pragma once
#if defined(OS_CHROMEOS)
@@ -144,7 +144,7 @@ struct Tuple3 {
Tuple3(typename TupleTraits<A>::ParamType a,
typename TupleTraits<B>::ParamType b,
typename TupleTraits<C>::ParamType c)
: a(a), b(b), c(c){
: a(a), b(b), c(c) {
}
A a;
@@ -575,7 +575,6 @@ inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
template <class ObjT, class Method, class A>
inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
#if defined(OS_CHROMEOS)
// To troubleshoot crosbug.com/7327.
CHECK(obj);
@@ -1080,4 +1079,4 @@ inline void DispatchToMethod(ObjT* obj, Method method,
&out->a, &out->b, &out->c, &out->d, &out->e);
}
#endif // BASE_TUPLE_H__
#endif // CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_

View File

@@ -28,31 +28,37 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TYPES_H
#define _CEF_TYPES_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_H_
#pragma once
#include "cef_build.h"
#include "cef_string.h"
#include "cef_string_list.h"
#include "cef_time.h"
#include "include/internal/cef_build.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_string_list.h"
#include "include/internal/cef_time.h"
// Bring in platform-specific definitions.
#if defined(OS_WIN)
#include "cef_types_win.h"
#include "include/internal/cef_types_win.h"
#elif defined(OS_MACOSX)
#include "cef_types_mac.h"
#include "include/internal/cef_types_mac.h"
#elif defined(OS_LINUX)
#include "cef_types_linux.h"
#include "include/internal/cef_types_linux.h"
#endif
// The NSPR system headers define 64-bit as |long| when possible. In order to
// not have typedef mismatches, we do the same on LP64.
#if __LP64__
typedef long int64;
typedef unsigned long uint64;
#include <stddef.h> // For size_t
// The NSPR system headers define 64-bit as |long| when possible, except on
// Mac OS X. In order to not have typedef mismatches, we do the same on LP64.
//
// On Mac OS X, |long long| is used for 64-bit types for compatibility with
// <inttypes.h> format macros even in the LP64 model.
#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
typedef long int64; // NOLINT(runtime/int)
typedef unsigned long uint64; // NOLINT(runtime/int)
#else
typedef long long int64;
typedef unsigned long long uint64;
typedef long long int64; // NOLINT(runtime/int)
typedef unsigned long long uint64; // NOLINT(runtime/int)
#endif
#ifdef __cplusplus
@@ -62,8 +68,7 @@ extern "C" {
///
// Log severity levels.
///
enum cef_log_severity_t
{
enum cef_log_severity_t {
LOGSEVERITY_VERBOSE = -1,
LOGSEVERITY_INFO,
LOGSEVERITY_WARNING,
@@ -77,8 +82,7 @@ enum cef_log_severity_t
// Initialization settings. Specify NULL or 0 to get the recommended default
// values.
///
typedef struct _cef_settings_t
{
typedef struct _cef_settings_t {
///
// Size of this structure.
///
@@ -90,14 +94,14 @@ typedef struct _cef_settings_t
// your application message loop.
///
bool multi_threaded_message_loop;
///
// The location where cache data will be stored on disk. If empty an
// in-memory cache will be used. HTML5 databases such as localStorage will
// only persist across sessions if a cache path is specified.
///
cef_string_t cache_path;
///
// Value that will be returned as the User-Agent HTTP header. If empty the
// default User-Agent string will be used.
@@ -160,7 +164,7 @@ typedef struct _cef_settings_t
#if defined(OS_WIN)
///
// Set to true (1) to use the system proxy resolver on Windows when
// Set to true (1) to use the system proxy resolver on Windows when
// "Automatically detect settings" is checked. This setting is disabled
// by default for performance reasons.
///
@@ -173,8 +177,7 @@ typedef struct _cef_settings_t
// default values. The consequences of using custom values may not be well
// tested.
///
typedef struct _cef_browser_settings_t
{
typedef struct _cef_browser_settings_t {
///
// Size of this structure.
///
@@ -328,7 +331,7 @@ typedef struct _cef_browser_settings_t
// Set to true (1) to enable the user style sheet for all pages.
///
bool user_style_sheet_enabled;
///
// Location of the user style sheet. This must be a data URL of the form
// "data:text/css;charset=utf-8;base64,csscontent" where "csscontent" is the
@@ -419,8 +422,7 @@ typedef struct _cef_browser_settings_t
///
// URL component parts.
///
typedef struct _cef_urlparts_t
{
typedef struct _cef_urlparts_t {
///
// The complete URL specification.
///
@@ -466,8 +468,7 @@ typedef struct _cef_urlparts_t
///
// Cookie information.
///
typedef struct _cef_cookie_t
{
typedef struct _cef_cookie_t {
///
// The cookie name.
///
@@ -506,7 +507,7 @@ typedef struct _cef_cookie_t
// cookie creation.
///
cef_time_t creation;
///
// The cookie last access date. This is automatically populated by the system
// on access.
@@ -523,8 +524,7 @@ typedef struct _cef_cookie_t
///
// Storage types.
///
enum cef_storage_type_t
{
enum cef_storage_type_t {
ST_LOCALSTORAGE = 0,
ST_SESSIONSTORAGE,
};
@@ -532,8 +532,7 @@ enum cef_storage_type_t
///
// Mouse button types.
///
enum cef_mouse_button_type_t
{
enum cef_mouse_button_type_t {
MBT_LEFT = 0,
MBT_MIDDLE,
MBT_RIGHT,
@@ -542,8 +541,7 @@ enum cef_mouse_button_type_t
///
// Key types.
///
enum cef_key_type_t
{
enum cef_key_type_t {
KT_KEYUP = 0,
KT_KEYDOWN,
KT_CHAR,
@@ -552,8 +550,7 @@ enum cef_key_type_t
///
// Various browser navigation types supported by chrome.
///
enum cef_handler_navtype_t
{
enum cef_handler_navtype_t {
NAVTYPE_LINKCLICKED = 0,
NAVTYPE_FORMSUBMITTED,
NAVTYPE_BACKFORWARD,
@@ -567,8 +564,7 @@ enum cef_handler_navtype_t
// Supported error code values. See net\base\net_error_list.h for complete
// descriptions of the error codes.
///
enum cef_handler_errorcode_t
{
enum cef_handler_errorcode_t {
ERR_FAILED = -2,
ERR_ABORTED = -3,
ERR_INVALID_ARGUMENT = -4,
@@ -624,8 +620,7 @@ enum cef_handler_errorcode_t
// destination. These constants match their equivalents in WebCore's
// DragActions.h and should not be renumbered.
///
enum cef_drag_operations_mask_t
{
enum cef_drag_operations_mask_t {
DRAG_OPERATION_NONE = 0,
DRAG_OPERATION_COPY = 1,
DRAG_OPERATION_LINK = 2,
@@ -639,8 +634,7 @@ enum cef_drag_operations_mask_t
///
// V8 access control values.
///
enum cef_v8_accesscontrol_t
{
enum cef_v8_accesscontrol_t {
V8_ACCESS_CONTROL_DEFAULT = 0,
V8_ACCESS_CONTROL_ALL_CAN_READ = 1,
V8_ACCESS_CONTROL_ALL_CAN_WRITE = 1 << 1,
@@ -650,9 +644,8 @@ enum cef_v8_accesscontrol_t
///
// V8 property attribute values.
///
enum cef_v8_propertyattribute_t
{
V8_PROPERTY_ATTRIBUTE_NONE = 0, // Writeable, Enumerable,
enum cef_v8_propertyattribute_t {
V8_PROPERTY_ATTRIBUTE_NONE = 0, // Writeable, Enumerable,
// Configurable
V8_PROPERTY_ATTRIBUTE_READONLY = 1 << 0, // Not writeable
V8_PROPERTY_ATTRIBUTE_DONTENUM = 1 << 1, // Not enumerable
@@ -662,8 +655,7 @@ enum cef_v8_propertyattribute_t
///
// Structure representing menu information.
///
typedef struct _cef_menu_info_t
{
typedef struct _cef_menu_info_t {
///
// Values from the cef_handler_menutypebits_t enumeration.
///
@@ -695,8 +687,7 @@ typedef struct _cef_menu_info_t
// The cef_menu_info_t typeFlags value will be a combination of the
// following values.
///
enum cef_menu_typebits_t
{
enum cef_menu_typebits_t {
///
// No node is selected
///
@@ -743,8 +734,7 @@ enum cef_menu_typebits_t
// The cef_menu_info_t editFlags value will be a combination of the
// following values.
///
enum cef_menu_capabilitybits_t
{
enum cef_menu_capabilitybits_t {
// Values from WebContextMenuData::EditFlags in WebContextMenuData.h
MENU_CAN_DO_NONE = 0x0,
MENU_CAN_UNDO = 0x1,
@@ -763,8 +753,7 @@ enum cef_menu_capabilitybits_t
///
// Supported menu ID values.
///
enum cef_menu_id_t
{
enum cef_menu_id_t {
MENU_ID_NAV_BACK = 10,
MENU_ID_NAV_FORWARD = 11,
MENU_ID_NAV_RELOAD = 12,
@@ -781,8 +770,7 @@ enum cef_menu_id_t
MENU_ID_VIEWSOURCE = 31,
};
enum cef_paint_element_type_t
{
enum cef_paint_element_type_t {
PET_VIEW = 0,
PET_POPUP,
};
@@ -790,15 +778,13 @@ enum cef_paint_element_type_t
///
// Post data elements may represent either bytes or files.
///
enum cef_postdataelement_type_t
{
enum cef_postdataelement_type_t {
PDE_TYPE_EMPTY = 0,
PDE_TYPE_BYTES,
PDE_TYPE_FILE,
};
enum cef_weburlrequest_flags_t
{
enum cef_weburlrequest_flags_t {
WUR_FLAG_NONE = 0,
WUR_FLAG_SKIP_CACHE = 0x1,
WUR_FLAG_ALLOW_CACHED_CREDENTIALS = 0x2,
@@ -808,8 +794,7 @@ enum cef_weburlrequest_flags_t
WUR_FLAG_REPORT_RAW_HEADERS = 0x20
};
enum cef_weburlrequest_state_t
{
enum cef_weburlrequest_state_t {
WUR_STATE_UNSENT = 0,
WUR_STATE_STARTED = 1,
WUR_STATE_HEADERS_RECEIVED = 2,
@@ -822,8 +807,7 @@ enum cef_weburlrequest_state_t
///
// Focus sources.
///
enum cef_handler_focus_source_t
{
enum cef_handler_focus_source_t {
///
// The source is explicit navigation via the API (LoadURL(), etc).
///
@@ -841,8 +825,7 @@ enum cef_handler_focus_source_t
///
// Key event types.
///
enum cef_handler_keyevent_type_t
{
enum cef_handler_keyevent_type_t {
KEYEVENT_RAWKEYDOWN = 0,
KEYEVENT_KEYDOWN,
KEYEVENT_KEYUP,
@@ -852,8 +835,7 @@ enum cef_handler_keyevent_type_t
///
// Key event modifiers.
///
enum cef_handler_keyevent_modifiers_t
{
enum cef_handler_keyevent_modifiers_t {
KEY_SHIFT = 1 << 0,
KEY_CTRL = 1 << 1,
KEY_ALT = 1 << 2,
@@ -863,8 +845,7 @@ enum cef_handler_keyevent_modifiers_t
///
// Structure representing a rectangle.
///
typedef struct _cef_rect_t
{
typedef struct _cef_rect_t {
int x;
int y;
int width;
@@ -874,8 +855,7 @@ typedef struct _cef_rect_t
///
// Existing thread IDs.
///
enum cef_thread_id_t
{
enum cef_thread_id_t {
TID_UI = 0,
TID_IO = 1,
TID_FILE = 2,
@@ -884,8 +864,7 @@ enum cef_thread_id_t
///
// Paper type for printing.
///
enum cef_paper_type_t
{
enum cef_paper_type_t {
PT_LETTER = 0,
PT_LEGAL,
PT_EXECUTIVE,
@@ -897,11 +876,10 @@ enum cef_paper_type_t
///
// Paper metric information for printing.
///
struct cef_paper_metrics
{
struct cef_paper_metrics {
enum cef_paper_type_t paper_type;
//Length and width needed if paper_type is custom_size
//Units are in inches.
// Length and width needed if paper_type is custom_size
// Units are in inches.
double length;
double width;
};
@@ -909,14 +887,13 @@ struct cef_paper_metrics
///
// Paper print margins.
///
struct cef_print_margins
{
//Margin size in inches for left/right/top/bottom (this is content margins).
struct cef_print_margins {
// Margin size in inches for left/right/top/bottom (this is content margins).
double left;
double right;
double top;
double bottom;
//Margin size (top/bottom) in inches for header/footer.
// Margin size (top/bottom) in inches for header/footer.
double header;
double footer;
};
@@ -924,8 +901,7 @@ struct cef_print_margins
///
// Page orientation for printing.
///
enum cef_page_orientation
{
enum cef_page_orientation {
PORTRAIT = 0,
LANDSCAPE
};
@@ -933,8 +909,7 @@ enum cef_page_orientation
///
// Printing options.
///
typedef struct _cef_print_options_t
{
typedef struct _cef_print_options_t {
enum cef_page_orientation page_orientation;
struct cef_paper_metrics paper_metrics;
struct cef_print_margins paper_margins;
@@ -946,8 +921,7 @@ typedef struct _cef_print_options_t
// before being passed to the parser. If a BOM is detected and the correct
// decoder is available then that decoder will be used automatically.
///
enum cef_xml_encoding_type_t
{
enum cef_xml_encoding_type_t {
XML_ENCODING_NONE = 0,
XML_ENCODING_UTF8,
XML_ENCODING_UTF16LE,
@@ -958,8 +932,7 @@ enum cef_xml_encoding_type_t
///
// XML node types.
///
enum cef_xml_node_type_t
{
enum cef_xml_node_type_t {
XML_NODE_UNSUPPORTED = 0,
XML_NODE_PROCESSING_INSTRUCTION,
XML_NODE_DOCUMENT_TYPE,
@@ -976,8 +949,7 @@ enum cef_xml_node_type_t
///
// Status message types.
///
enum cef_handler_statustype_t
{
enum cef_handler_statustype_t {
STATUSTYPE_TEXT = 0,
STATUSTYPE_MOUSEOVER_URL,
STATUSTYPE_KEYBOARD_FOCUS_URL,
@@ -986,8 +958,7 @@ enum cef_handler_statustype_t
///
// Popup window features.
///
typedef struct _cef_popup_features_t
{
typedef struct _cef_popup_features_t {
int x;
bool xSet;
int y;
@@ -1012,8 +983,7 @@ typedef struct _cef_popup_features_t
///
// DOM document types.
///
enum cef_dom_document_type_t
{
enum cef_dom_document_type_t {
DOM_DOCUMENT_TYPE_UNKNOWN = 0,
DOM_DOCUMENT_TYPE_HTML,
DOM_DOCUMENT_TYPE_XHTML,
@@ -1023,8 +993,7 @@ enum cef_dom_document_type_t
///
// DOM event category flags.
///
enum cef_dom_event_category_t
{
enum cef_dom_event_category_t {
DOM_EVENT_CATEGORY_UNKNOWN = 0x0,
DOM_EVENT_CATEGORY_UI = 0x1,
DOM_EVENT_CATEGORY_MOUSE = 0x2,
@@ -1050,8 +1019,7 @@ enum cef_dom_event_category_t
///
// DOM event processing phases.
///
enum cef_dom_event_phase_t
{
enum cef_dom_event_phase_t {
DOM_EVENT_PHASE_UNKNOWN = 0,
DOM_EVENT_PHASE_CAPTURING,
DOM_EVENT_PHASE_AT_TARGET,
@@ -1061,8 +1029,7 @@ enum cef_dom_event_phase_t
///
// DOM node types.
///
enum cef_dom_node_type_t
{
enum cef_dom_node_type_t {
DOM_NODE_TYPE_UNSUPPORTED = 0,
DOM_NODE_TYPE_ELEMENT,
DOM_NODE_TYPE_ATTRIBUTE,
@@ -1082,8 +1049,7 @@ enum cef_dom_node_type_t
///
// Proxy types.
///
enum cef_proxy_type_t
{
enum cef_proxy_type_t {
PROXY_TYPE_DIRECT = 0,
PROXY_TYPE_NAMED,
PROXY_TYPE_PAC_STRING,
@@ -1092,8 +1058,7 @@ enum cef_proxy_type_t
///
// Proxy information.
///
typedef struct _cef_proxy_info_t
{
typedef struct _cef_proxy_info_t {
enum cef_proxy_type_t proxyType;
cef_string_t proxyList;
} cef_proxy_info_t;
@@ -1102,4 +1067,4 @@ typedef struct _cef_proxy_info_t
}
#endif
#endif // _CEF_TYPES_H
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_H_

View File

@@ -28,12 +28,15 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TYPES_LINUX_H
#define _CEF_TYPES_LINUX_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_
#pragma once
#include "include/internal/cef_build.h"
#if defined(OS_LINUX)
#include <gtk/gtk.h>
#include "cef_string.h"
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
@@ -46,8 +49,7 @@ extern "C" {
///
// Supported graphics implementations.
///
enum cef_graphics_implementation_t
{
enum cef_graphics_implementation_t {
DESKTOP_IN_PROCESS = 0,
DESKTOP_IN_PROCESS_COMMAND_BUFFER,
};
@@ -55,11 +57,10 @@ enum cef_graphics_implementation_t
///
// Class representing window information.
///
typedef struct _cef_window_info_t
{
typedef struct _cef_window_info_t {
// Pointer for the parent GtkBox widget.
cef_window_handle_t m_ParentWidget;
// Pointer for the new browser widget.
cef_window_handle_t m_Widget;
} cef_window_info_t;
@@ -67,8 +68,7 @@ typedef struct _cef_window_info_t
///
// Class representing print context information.
///
typedef struct _cef_print_info_t
{
typedef struct _cef_print_info_t {
double m_Scale;
} cef_print_info_t;
@@ -76,6 +76,6 @@ typedef struct _cef_print_info_t
}
#endif
#endif // OS_LINUX
#endif // OS_LINUX
#endif // _CEF_TYPES_LINUX_H
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_LINUX_H_

View File

@@ -28,11 +28,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TYPES_MAC_H
#define _CEF_TYPES_MAC_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_
#pragma once
#include "include/internal/cef_build.h"
#if defined(OS_MACOSX)
#include "cef_string.h"
#include "include/internal/cef_string.h"
// Window handle.
#ifdef __cplusplus
@@ -54,8 +57,7 @@ extern "C" {
///
// Supported graphics implementations.
///
enum cef_graphics_implementation_t
{
enum cef_graphics_implementation_t {
DESKTOP_IN_PROCESS = 0,
DESKTOP_IN_PROCESS_COMMAND_BUFFER,
};
@@ -63,8 +65,7 @@ enum cef_graphics_implementation_t
///
// Class representing window information.
///
typedef struct _cef_window_info_t
{
typedef struct _cef_window_info_t {
cef_string_t m_windowName;
int m_x;
int m_y;
@@ -74,7 +75,7 @@ typedef struct _cef_window_info_t
// NSView pointer for the parent view.
cef_window_handle_t m_ParentView;
// NSView pointer for the new browser view.
cef_window_handle_t m_View;
} cef_window_info_t;
@@ -82,8 +83,7 @@ typedef struct _cef_window_info_t
///
// Class representing print context information.
///
typedef struct _cef_print_info_t
{
typedef struct _cef_print_info_t {
double m_Scale;
} cef_print_info_t;
@@ -91,6 +91,6 @@ typedef struct _cef_print_info_t
}
#endif
#endif // OS_MACOSX
#endif // OS_MACOSX
#endif // _CEF_TYPES_MAC_H
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_MAC_H_

View File

@@ -28,12 +28,15 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TYPES_WIN_H
#define _CEF_TYPES_WIN_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_
#pragma once
#include "include/internal/cef_build.h"
#if defined(OS_WIN)
#include <windows.h>
#include "cef_string.h"
#include "include/internal/cef_string.h"
#ifdef __cplusplus
extern "C" {
@@ -46,8 +49,7 @@ extern "C" {
///
// Supported graphics implementations.
///
enum cef_graphics_implementation_t
{
enum cef_graphics_implementation_t {
ANGLE_IN_PROCESS = 0,
ANGLE_IN_PROCESS_COMMAND_BUFFER,
DESKTOP_IN_PROCESS,
@@ -57,8 +59,7 @@ enum cef_graphics_implementation_t
///
// Class representing window information.
///
typedef struct _cef_window_info_t
{
typedef struct _cef_window_info_t {
// Standard parameters required by CreateWindowEx()
DWORD m_dwExStyle;
cef_string_t m_windowName;
@@ -77,7 +78,7 @@ typedef struct _cef_window_info_t
// Set to true to enable transparent painting.
BOOL m_bTransparentPainting;
// Handle for the new browser window.
cef_window_handle_t m_hWnd;
} cef_window_info_t;
@@ -85,8 +86,7 @@ typedef struct _cef_window_info_t
///
// Class representing print context information.
///
typedef struct _cef_print_info_t
{
typedef struct _cef_print_info_t {
HDC m_hDC;
RECT m_Rect;
double m_Scale;
@@ -96,6 +96,6 @@ typedef struct _cef_print_info_t
}
#endif
#endif // OS_WIN
#endif // OS_WIN
#endif // _CEF_TYPES_WIN_H
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WIN_H_

View File

@@ -27,40 +27,37 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_TYPES_WRAPPERS_H
#define _CEF_TYPES_WRAPPERS_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
#pragma once
#include "cef_string.h"
#include "cef_string_list.h"
#include "cef_types.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_string_list.h"
#include "include/internal/cef_types.h"
///
// Template class that provides common functionality for CEF structure wrapping.
///
template <class traits>
class CefStructBase : public traits::struct_type {
public:
public:
typedef typename traits::struct_type struct_type;
CefStructBase() : attached_to_(NULL)
{
CefStructBase() : attached_to_(NULL) {
Init();
}
virtual ~CefStructBase()
{
virtual ~CefStructBase() {
// Only clear this object's data if it isn't currently attached to a
// structure.
if (!attached_to_)
Clear(this);
Clear(this);
}
CefStructBase(const CefStructBase& r)
{
CefStructBase(const CefStructBase& r) {
Init();
*this = r;
}
CefStructBase(const struct_type& r)
{
CefStructBase(const struct_type& r) { // NOLINT(runtime/explicit)
Init();
*this = r;
}
@@ -68,8 +65,7 @@ public:
///
// Clear this object's values.
///
void Reset()
{
void Reset() {
Clear(this);
Init();
}
@@ -78,16 +74,15 @@ public:
// Attach to the source structure's existing values. DetachTo() can be called
// to insert the values back into the existing structure.
///
void AttachTo(struct_type& source)
{
void AttachTo(struct_type& source) {
// Only clear this object's data if it isn't currently attached to a
// structure.
if (!attached_to_)
Clear(this);
// This object is now attached to the new structure.
attached_to_ = &source;
// Transfer ownership of the values from the source structure.
memcpy(static_cast<struct_type*>(this), &source, sizeof(struct_type));
}
@@ -95,8 +90,7 @@ public:
///
// Relinquish ownership of values to the target structure.
///
void DetachTo(struct_type& target)
{
void DetachTo(struct_type& target) {
if (attached_to_ != &target) {
// Clear the target structure's values only if we are not currently
// attached to that structure.
@@ -114,25 +108,21 @@ public:
// Set this object's values. If |copy| is true the source structure's values
// will be copied instead of referenced.
///
void Set(const struct_type& source, bool copy)
{
void Set(const struct_type& source, bool copy) {
traits::set(&source, this, copy);
}
CefStructBase& operator=(const CefStructBase& s)
{
CefStructBase& operator=(const CefStructBase& s) {
return operator=(static_cast<const struct_type&>(s));
}
CefStructBase& operator=(const struct_type& s)
{
CefStructBase& operator=(const struct_type& s) {
Set(s, true);
return *this;
}
protected:
void Init()
{
protected:
void Init() {
memset(static_cast<struct_type*>(this), 0, sizeof(struct_type));
attached_to_ = NULL;
traits::init(this);
@@ -150,8 +140,8 @@ struct CefRectTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
*target = *src;
}
};
@@ -159,33 +149,28 @@ struct CefRectTraits {
///
// Class representing a rectangle.
///
class CefRect : public CefStructBase<CefRectTraits>
{
public:
class CefRect : public CefStructBase<CefRectTraits> {
public:
typedef CefStructBase<CefRectTraits> parent;
CefRect() : parent() {}
CefRect(const cef_rect_t& r) : parent(r) {}
CefRect(const CefRect& r) : parent(r) {}
CefRect(int x, int y, int width, int height) : parent()
{
CefRect(const cef_rect_t& r) : parent(r) {} // NOLINT(runtime/explicit)
CefRect(const CefRect& r) : parent(r) {} // NOLINT(runtime/explicit)
CefRect(int x, int y, int width, int height) : parent() {
Set(x, y, width, height);
}
bool IsEmpty() const { return width <= 0 || height <= 0; }
void Set(int x, int y, int width, int height)
{
void Set(int x, int y, int width, int height) {
this->x = x, this->y = y, this->width = width, this->height = height;
}
};
inline bool operator==(const CefRect& a, const CefRect& b)
{
inline bool operator==(const CefRect& a, const CefRect& b) {
return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
}
inline bool operator!=(const CefRect& a, const CefRect& b)
{
inline bool operator!=(const CefRect& a, const CefRect& b) {
return !(a == b);
}
@@ -196,8 +181,8 @@ struct CefPrintOptionsTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
*target = *src;
}
};
@@ -212,8 +197,7 @@ typedef CefStructBase<CefPrintOptionsTraits> CefPrintOptions;
struct CefPopupFeaturesTraits {
typedef cef_popup_features_t struct_type;
static inline void init(struct_type* s)
{
static inline void init(struct_type* s) {
s->menuBarVisible = true;
s->statusBarVisible = true;
s->toolBarVisible = true;
@@ -221,16 +205,15 @@ struct CefPopupFeaturesTraits {
s->scrollbarsVisible = true;
s->resizable = true;
}
static inline void clear(struct_type* s)
{
if(s->additionalFeatures)
static inline void clear(struct_type* s) {
if (s->additionalFeatures)
cef_string_list_free(s->additionalFeatures);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
if(target->additionalFeatures)
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
if (target->additionalFeatures)
cef_string_list_free(target->additionalFeatures);
target->additionalFeatures = src->additionalFeatures ?
cef_string_list_copy(src->additionalFeatures) : NULL;
@@ -263,25 +246,23 @@ typedef CefStructBase<CefPopupFeaturesTraits> CefPopupFeatures;
struct CefSettingsTraits {
typedef cef_settings_t struct_type;
static inline void init(struct_type* s)
{
static inline void init(struct_type* s) {
s->size = sizeof(struct_type);
}
static inline void clear(struct_type* s)
{
static inline void clear(struct_type* s) {
cef_string_clear(&s->cache_path);
cef_string_clear(&s->user_agent);
cef_string_clear(&s->product_version);
cef_string_clear(&s->locale);
if(s->extra_plugin_paths)
if (s->extra_plugin_paths)
cef_string_list_free(s->extra_plugin_paths);
cef_string_clear(&s->log_file);
cef_string_clear(&s->javascript_flags);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->multi_threaded_message_loop = src->multi_threaded_message_loop;
cef_string_set(src->cache_path.str, src->cache_path.length,
@@ -292,7 +273,7 @@ struct CefSettingsTraits {
&target->product_version, copy);
cef_string_set(src->locale.str, src->locale.length, &target->locale, copy);
if(target->extra_plugin_paths)
if (target->extra_plugin_paths)
cef_string_list_free(target->extra_plugin_paths);
target->extra_plugin_paths = src->extra_plugin_paths ?
cef_string_list_copy(src->extra_plugin_paths) : NULL;
@@ -322,13 +303,11 @@ typedef CefStructBase<CefSettingsTraits> CefSettings;
struct CefBrowserSettingsTraits {
typedef cef_browser_settings_t struct_type;
static inline void init(struct_type* s)
{
static inline void init(struct_type* s) {
s->size = sizeof(struct_type);
}
static inline void clear(struct_type* s)
{
static inline void clear(struct_type* s) {
cef_string_clear(&s->standard_font_family);
cef_string_clear(&s->fixed_font_family);
cef_string_clear(&s->serif_font_family);
@@ -339,8 +318,8 @@ struct CefBrowserSettingsTraits {
cef_string_clear(&s->user_style_sheet_location);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->drag_drop_disabled = src->drag_drop_disabled;
target->load_drops_disabled = src->load_drops_disabled;
target->history_disabled = src->history_disabled;
@@ -431,9 +410,8 @@ struct CefURLPartsTraits {
typedef cef_urlparts_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s)
{
static inline void clear(struct_type* s) {
cef_string_clear(&s->spec);
cef_string_clear(&s->scheme);
cef_string_clear(&s->username);
@@ -444,8 +422,8 @@ struct CefURLPartsTraits {
cef_string_clear(&s->query);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
cef_string_set(src->spec.str, src->spec.length, &target->spec, copy);
cef_string_set(src->scheme.str, src->scheme.length, &target->scheme, copy);
cef_string_set(src->username.str, src->username.length, &target->username,
@@ -469,11 +447,11 @@ struct CefTimeTraits {
typedef cef_time_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
*target = *src;
}
};
@@ -481,15 +459,15 @@ struct CefTimeTraits {
///
// Class representing a time.
///
class CefTime : public CefStructBase<CefTimeTraits>
{
public:
class CefTime : public CefStructBase<CefTimeTraits> {
public:
typedef CefStructBase<CefTimeTraits> parent;
CefTime() : parent() {}
CefTime(const cef_time_t& r) : parent(r) {}
CefTime(time_t r) : parent() { SetTimeT(r); }
CefTime(double r) : parent() { SetDoubleT(r); }
CefTime(const cef_time_t& r) : parent(r) {} // NOLINT(runtime/explicit)
CefTime(const CefTime& r) : parent(r) {} // NOLINT(runtime/explicit)
explicit CefTime(time_t r) : parent() { SetTimeT(r); }
explicit CefTime(double r) : parent() { SetDoubleT(r); }
// Converts to/from time_t.
void SetTimeT(time_t r) {
@@ -519,17 +497,16 @@ struct CefCookieTraits {
typedef cef_cookie_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s)
{
static inline void clear(struct_type* s) {
cef_string_clear(&s->name);
cef_string_clear(&s->value);
cef_string_clear(&s->domain);
cef_string_clear(&s->path);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
cef_string_set(src->name.str, src->name.length, &target->name, copy);
cef_string_set(src->value.str, src->value.length, &target->value, copy);
cef_string_set(src->domain.str, src->domain.length, &target->domain, copy);
@@ -554,8 +531,7 @@ struct CefMenuInfoTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s)
{
static inline void clear(struct_type* s) {
cef_string_clear(&s->linkUrl);
cef_string_clear(&s->imageUrl);
cef_string_clear(&s->pageUrl);
@@ -565,8 +541,8 @@ struct CefMenuInfoTraits {
cef_string_clear(&s->securityInfo);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->typeFlags = src->typeFlags;
target->x = src->x;
target->y = src->y;
@@ -600,14 +576,13 @@ struct CefProxyInfoTraits {
typedef cef_proxy_info_t struct_type;
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s)
{
static inline void clear(struct_type* s) {
cef_string_clear(&s->proxyList);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->proxyType = src->proxyType;
cef_string_set(src->proxyList.str, src->proxyList.length,
&target->proxyList, copy);
@@ -617,14 +592,12 @@ struct CefProxyInfoTraits {
///
// Class representing the results of proxy resolution.
///
class CefProxyInfo : public CefStructBase<CefProxyInfoTraits>
{
public:
class CefProxyInfo : public CefStructBase<CefProxyInfoTraits> {
public:
///
// Use a direction connection instead of a proxy.
///
void UseDirect()
{
void UseDirect() {
proxyType = PROXY_TYPE_DIRECT;
}
@@ -637,8 +610,7 @@ public:
// Multiple values may be separated by semicolons or whitespace. For example,
// "foo1:80;foo2:80".
///
void UseNamedProxy(const CefString& proxy_uri_list)
{
void UseNamedProxy(const CefString& proxy_uri_list) {
proxyType = PROXY_TYPE_NAMED;
(CefString(&proxyList)) = proxy_uri_list;
}
@@ -647,8 +619,7 @@ public:
// Use one or more named proxy servers specified in PAC script format. For
// example, "PROXY foobar:99; SOCKS fml:2; DIRECT".
///
void UsePacString(const CefString& pac_string)
{
void UsePacString(const CefString& pac_string) {
proxyType = PROXY_TYPE_PAC_STRING;
(CefString(&proxyList)) = pac_string;
}
@@ -660,4 +631,4 @@ public:
CefString ProxyList() const { return CefString(&proxyList); }
};
#endif // _CEF_TYPES_WRAPPERS_H
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_

View File

@@ -28,13 +28,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _CEF_WIN_H
#define _CEF_WIN_H
#ifndef CEF_INCLUDE_INTERNAL_CEF_WIN_H_
#define CEF_INCLUDE_INTERNAL_CEF_WIN_H_
#pragma once
#if defined(OS_WIN)
#include <windows.h>
#include "cef_types_win.h"
#include "cef_types_wrappers.h"
#include "include/internal/cef_types_win.h"
#include "include/internal/cef_types_wrappers.h"
///
// Atomic increment and decrement.
@@ -45,24 +46,19 @@
///
// Critical section wrapper.
///
class CefCriticalSection
{
public:
CefCriticalSection()
{
class CefCriticalSection {
public:
CefCriticalSection() {
memset(&m_sec, 0, sizeof(CRITICAL_SECTION));
InitializeCriticalSection(&m_sec);
}
virtual ~CefCriticalSection()
{
virtual ~CefCriticalSection() {
DeleteCriticalSection(&m_sec);
}
void Lock()
{
void Lock() {
EnterCriticalSection(&m_sec);
}
void Unlock()
{
void Unlock() {
LeaveCriticalSection(&m_sec);
}
@@ -81,13 +77,12 @@ struct CefWindowInfoTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s)
{
static inline void clear(struct_type* s) {
cef_string_clear(&s->m_windowName);
}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->m_dwExStyle = src->m_dwExStyle;
cef_string_set(src->m_windowName.str, src->m_windowName.length,
&target->m_windowName, copy);
@@ -107,17 +102,15 @@ struct CefWindowInfoTraits {
///
// Class representing window information.
///
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits>
{
public:
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
public:
typedef CefStructBase<CefWindowInfoTraits> parent;
CefWindowInfo() : parent() {}
CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
void SetAsChild(HWND hWndParent, RECT windowRect)
{
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
void SetAsChild(HWND hWndParent, RECT windowRect) {
m_dwStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP |
WS_VISIBLE;
m_hWndParent = hWndParent;
@@ -127,8 +120,7 @@ public:
m_nHeight = windowRect.bottom - windowRect.top;
}
void SetAsPopup(HWND hWndParent, const CefString& windowName)
{
void SetAsPopup(HWND hWndParent, const CefString& windowName) {
m_dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
WS_VISIBLE;
m_hWndParent = hWndParent;
@@ -140,14 +132,12 @@ public:
cef_string_copy(windowName.c_str(), windowName.length(), &m_windowName);
}
void SetAsOffScreen(HWND hWndParent)
{
void SetAsOffScreen(HWND hWndParent) {
m_bWindowRenderingDisabled = TRUE;
m_hWndParent = hWndParent;
}
void SetTransparentPainting(BOOL transparentPainting)
{
void SetTransparentPainting(BOOL transparentPainting) {
m_bTransparentPainting = transparentPainting;
}
};
@@ -159,8 +149,8 @@ struct CefPrintInfoTraits {
static inline void init(struct_type* s) {}
static inline void clear(struct_type* s) {}
static inline void set(const struct_type* src, struct_type* target, bool copy)
{
static inline void set(const struct_type* src, struct_type* target,
bool copy) {
target->m_hDC = src->m_hDC;
target->m_Rect = src->m_Rect;
target->m_Scale = src->m_Scale;
@@ -172,6 +162,6 @@ struct CefPrintInfoTraits {
///
typedef CefStructBase<CefPrintInfoTraits> CefPrintInfo;
#endif // OS_WIN
#endif // OS_WIN
#endif // _CEF_WIN_H
#endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_