mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-04-11 17:41:08 +02:00
Clean up CefStructBase inheritance
- Use C++11 using directive for constructor/operator= inheritance. This is a behavioral no-op. - Remove CefStructBase virtual destructor to reduce object size. This is safe because CefStructBase is not deleted polymorphically.
This commit is contained in:
parent
a242ee518a
commit
2d8b6b06f2
@ -79,14 +79,9 @@ struct CefWindowInfoTraits {
|
|||||||
///
|
///
|
||||||
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||||
public:
|
public:
|
||||||
typedef CefStructBase<CefWindowInfoTraits> parent;
|
using base_type = CefStructBase<CefWindowInfoTraits>;
|
||||||
|
using base_type::CefStructBase;
|
||||||
CefWindowInfo() : parent() {}
|
using base_type::operator=;
|
||||||
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
|
|
||||||
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
|
|
||||||
|
|
||||||
CefWindowInfo& operator=(const CefWindowInfo&) = default;
|
|
||||||
CefWindowInfo& operator=(CefWindowInfo&&) = default;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create the browser as a child window.
|
/// Create the browser as a child window.
|
||||||
|
@ -80,14 +80,9 @@ struct CefWindowInfoTraits {
|
|||||||
///
|
///
|
||||||
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||||
public:
|
public:
|
||||||
typedef CefStructBase<CefWindowInfoTraits> parent;
|
using base_type = CefStructBase<CefWindowInfoTraits>;
|
||||||
|
using base_type::CefStructBase;
|
||||||
CefWindowInfo() : parent() {}
|
using base_type::operator=;
|
||||||
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
|
|
||||||
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
|
|
||||||
|
|
||||||
CefWindowInfo& operator=(const CefWindowInfo&) = default;
|
|
||||||
CefWindowInfo& operator=(CefWindowInfo&&) = default;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create the browser as a child view.
|
/// Create the browser as a child view.
|
||||||
|
@ -49,7 +49,7 @@ class CefStructBase : public traits::struct_type {
|
|||||||
using struct_type = typename traits::struct_type;
|
using struct_type = typename traits::struct_type;
|
||||||
|
|
||||||
CefStructBase() { Init(); }
|
CefStructBase() { Init(); }
|
||||||
virtual ~CefStructBase() {
|
~CefStructBase() {
|
||||||
// Only clear this object's data if it isn't currently attached to a
|
// Only clear this object's data if it isn't currently attached to a
|
||||||
// structure.
|
// structure.
|
||||||
if (!attached_to_) {
|
if (!attached_to_) {
|
||||||
@ -153,7 +153,7 @@ class CefStructBase : public traits::struct_type {
|
|||||||
/// wrapping. Use only with POD types that begin with a `size_t size` member.
|
/// wrapping. Use only with POD types that begin with a `size_t size` member.
|
||||||
///
|
///
|
||||||
template <class struct_type>
|
template <class struct_type>
|
||||||
class CefStructBaseSimple final : public struct_type {
|
class CefStructBaseSimple : public struct_type {
|
||||||
public:
|
public:
|
||||||
CefStructBaseSimple() : struct_type{sizeof(struct_type)} {}
|
CefStructBaseSimple() : struct_type{sizeof(struct_type)} {}
|
||||||
CefStructBaseSimple(const struct_type& r) { *this = r; }
|
CefStructBaseSimple(const struct_type& r) { *this = r; }
|
||||||
@ -326,31 +326,21 @@ inline bool operator!=(const CefDraggableRegion& a,
|
|||||||
/// Class representing the virtual screen information for use when window
|
/// Class representing the virtual screen information for use when window
|
||||||
/// rendering is disabled.
|
/// rendering is disabled.
|
||||||
///
|
///
|
||||||
class CefScreenInfo : public cef_screen_info_t {
|
class CefScreenInfo : public CefStructBaseSimple<cef_screen_info_t> {
|
||||||
public:
|
public:
|
||||||
CefScreenInfo() : cef_screen_info_t{sizeof(cef_screen_info_t)} {}
|
using base_type = CefStructBaseSimple<cef_screen_info_t>;
|
||||||
CefScreenInfo(const cef_screen_info_t& r) { *this = r; }
|
using base_type::CefStructBaseSimple;
|
||||||
|
using base_type::operator=;
|
||||||
CefScreenInfo& operator=(const cef_screen_info_t& r) {
|
|
||||||
memcpy(static_cast<cef_screen_info_t*>(this), &r,
|
|
||||||
std::min(r.size, sizeof(cef_screen_info_t)));
|
|
||||||
this->size = sizeof(cef_screen_info_t);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefScreenInfo(float device_scale_factor,
|
CefScreenInfo(float device_scale_factor,
|
||||||
int depth,
|
int depth,
|
||||||
int depth_per_component,
|
int depth_per_component,
|
||||||
bool is_monochrome,
|
bool is_monochrome,
|
||||||
const cef_rect_t& rect,
|
const cef_rect_t& rect,
|
||||||
const cef_rect_t& available_rect)
|
const cef_rect_t& available_rect) {
|
||||||
: cef_screen_info_t{sizeof(cef_screen_info_t),
|
Set(device_scale_factor, depth, depth_per_component, is_monochrome, rect,
|
||||||
device_scale_factor,
|
available_rect);
|
||||||
depth,
|
}
|
||||||
depth_per_component,
|
|
||||||
is_monochrome,
|
|
||||||
rect,
|
|
||||||
available_rect} {}
|
|
||||||
|
|
||||||
void Set(float device_scale_factor_val,
|
void Set(float device_scale_factor_val,
|
||||||
int depth_val,
|
int depth_val,
|
||||||
@ -732,20 +722,14 @@ using CefPdfPrintSettings = CefStructBase<CefPdfPrintSettingsTraits>;
|
|||||||
///
|
///
|
||||||
/// Class representing CefBoxLayout settings.
|
/// Class representing CefBoxLayout settings.
|
||||||
///
|
///
|
||||||
class CefBoxLayoutSettings : public cef_box_layout_settings_t {
|
class CefBoxLayoutSettings
|
||||||
|
: public CefStructBaseSimple<cef_box_layout_settings_t> {
|
||||||
public:
|
public:
|
||||||
CefBoxLayoutSettings()
|
using base_type = CefStructBaseSimple<cef_box_layout_settings_t>;
|
||||||
: cef_box_layout_settings_t{sizeof(cef_box_layout_settings_t)} {
|
using base_type::CefStructBaseSimple;
|
||||||
cross_axis_alignment = CEF_AXIS_ALIGNMENT_STRETCH;
|
using base_type::operator=;
|
||||||
}
|
|
||||||
CefBoxLayoutSettings(const cef_box_layout_settings_t& r) { *this = r; }
|
|
||||||
|
|
||||||
CefBoxLayoutSettings& operator=(const cef_box_layout_settings_t& r) {
|
CefBoxLayoutSettings() { cross_axis_alignment = CEF_AXIS_ALIGNMENT_STRETCH; }
|
||||||
memcpy(static_cast<cef_box_layout_settings_t*>(this), &r,
|
|
||||||
std::min(r.size, sizeof(cef_box_layout_settings_t)));
|
|
||||||
this->size = sizeof(cef_box_layout_settings_t);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -82,14 +82,9 @@ struct CefWindowInfoTraits {
|
|||||||
///
|
///
|
||||||
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
|
||||||
public:
|
public:
|
||||||
typedef CefStructBase<CefWindowInfoTraits> parent;
|
using base_type = CefStructBase<CefWindowInfoTraits>;
|
||||||
|
using base_type::CefStructBase;
|
||||||
CefWindowInfo() : parent() {}
|
using base_type::operator=;
|
||||||
explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
|
|
||||||
explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
|
|
||||||
|
|
||||||
CefWindowInfo& operator=(const CefWindowInfo&) = default;
|
|
||||||
CefWindowInfo& operator=(CefWindowInfo&&) = default;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Create the browser as a child window.
|
/// Create the browser as a child window.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user