Use CefRect for CefWindowInfo bounds (fixes issue #1515)

This commit is contained in:
Marshall Greenblatt
2021-09-27 11:48:30 +03:00
parent 41b64e428c
commit 23be17f693
16 changed files with 148 additions and 121 deletions

View File

@@ -81,10 +81,7 @@ struct CefWindowInfoTraits {
bool copy) {
cef_string_set(src->window_name.str, src->window_name.length,
&target->window_name, copy);
target->x = src->x;
target->y = src->y;
target->width = src->width;
target->height = src->height;
target->bounds = src->bounds;
target->parent_window = src->parent_window;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
target->shared_texture_enabled = src->shared_texture_enabled;
@@ -105,12 +102,9 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
///
// Create the browser as a child window.
///
void SetAsChild(CefWindowHandle parent, const CefRect& windowRect) {
void SetAsChild(CefWindowHandle parent, const CefRect& bounds) {
parent_window = parent;
x = windowRect.x;
y = windowRect.y;
width = windowRect.width;
height = windowRect.height;
this->bounds = bounds;
}
///

View File

@@ -81,10 +81,7 @@ struct CefWindowInfoTraits {
bool copy) {
cef_string_set(src->window_name.str, src->window_name.length,
&target->window_name, copy);
target->x = src->x;
target->y = src->y;
target->width = src->width;
target->height = src->height;
target->bounds = src->bounds;
target->hidden = src->hidden;
target->parent_view = src->parent_view;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
@@ -106,12 +103,9 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
///
// Create the browser as a child view.
///
void SetAsChild(CefWindowHandle parent, int x, int y, int width, int height) {
void SetAsChild(CefWindowHandle parent, const CefRect& bounds) {
parent_view = parent;
this->x = x;
this->y = y;
this->width = width;
this->height = height;
this->bounds = bounds;
hidden = false;
}

View File

@@ -35,6 +35,7 @@
#include "include/internal/cef_string.h"
#include "include/internal/cef_string_list.h"
#include "include/internal/cef_time.h"
#include "include/internal/cef_types_geometry.h"
// Bring in platform-specific definitions.
#if defined(OS_WIN)
@@ -1372,51 +1373,6 @@ typedef enum {
UR_FAILED,
} cef_urlrequest_status_t;
///
// Structure representing a point.
///
typedef struct _cef_point_t {
int x;
int y;
} cef_point_t;
///
// Structure representing a rectangle.
///
typedef struct _cef_rect_t {
int x;
int y;
int width;
int height;
} cef_rect_t;
///
// Structure representing a size.
///
typedef struct _cef_size_t {
int width;
int height;
} cef_size_t;
///
// Structure representing a range.
///
typedef struct _cef_range_t {
int from;
int to;
} cef_range_t;
///
// Structure representing insets.
///
typedef struct _cef_insets_t {
int top;
int left;
int bottom;
int right;
} cef_insets_t;
///
// Structure representing a draggable region.
///
typedef struct _cef_draggable_region_t {
@@ -2958,6 +2914,14 @@ typedef enum {
CEF_SCHEME_OPTION_FETCH_ENABLED = 1 << 6,
} cef_scheme_options_t;
///
// Structure representing a range.
///
typedef struct _cef_range_t {
int from;
int to;
} cef_range_t;
///
// Composition underline style.
///

View File

@@ -0,0 +1,78 @@
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_GEOMETRY_H_
#define CEF_INCLUDE_INTERNAL_CEF_TYPES_GEOMETRY_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
///
// Structure representing a point.
///
typedef struct _cef_point_t {
int x;
int y;
} cef_point_t;
///
// Structure representing a rectangle.
///
typedef struct _cef_rect_t {
int x;
int y;
int width;
int height;
} cef_rect_t;
///
// Structure representing a size.
///
typedef struct _cef_size_t {
int width;
int height;
} cef_size_t;
///
// Structure representing insets.
///
typedef struct _cef_insets_t {
int top;
int left;
int bottom;
int right;
} cef_insets_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_GEOMETRY_H_

View File

@@ -43,6 +43,7 @@ typedef struct _XDisplay XDisplay;
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_geometry.h"
// Handle types.
#if defined(CEF_X11)
@@ -93,10 +94,10 @@ typedef struct _cef_window_info_t {
///
cef_string_t window_name;
unsigned int x;
unsigned int y;
unsigned int width;
unsigned int height;
///
// Initial window bounds.
///
cef_rect_t bounds;
///
// Pointer for the parent window.

View File

@@ -35,6 +35,7 @@
#if defined(OS_MAC)
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_geometry.h"
// Handle types.
// Actually NSCursor*
@@ -85,10 +86,11 @@ typedef struct _cef_main_args_t {
///
typedef struct _cef_window_info_t {
cef_string_t window_name;
int x;
int y;
int width;
int height;
///
// Initial window bounds.
///
cef_rect_t bounds;
///
// Set to true (1) to create the view initially hidden.

View File

@@ -35,7 +35,9 @@
#if defined(OS_WIN)
#include <windows.h>
#include "include/internal/cef_string.h"
#include "include/internal/cef_types_geometry.h"
// Handle types.
#define cef_cursor_handle_t HCURSOR
@@ -53,7 +55,9 @@ extern "C" {
///
// Structure representing CefExecuteProcess arguments.
///
typedef struct _cef_main_args_t { HINSTANCE instance; } cef_main_args_t;
typedef struct _cef_main_args_t {
HINSTANCE instance;
} cef_main_args_t;
///
// Structure representing window information.
@@ -63,10 +67,7 @@ typedef struct _cef_window_info_t {
DWORD ex_style;
cef_string_t window_name;
DWORD style;
int x;
int y;
int width;
int height;
cef_rect_t bounds;
cef_window_handle_t parent_window;
HMENU menu;

View File

@@ -81,10 +81,7 @@ struct CefWindowInfoTraits {
cef_string_set(src->window_name.str, src->window_name.length,
&target->window_name, copy);
target->style = src->style;
target->x = src->x;
target->y = src->y;
target->width = src->width;
target->height = src->height;
target->bounds = src->bounds;
target->parent_window = src->parent_window;
target->menu = src->menu;
target->windowless_rendering_enabled = src->windowless_rendering_enabled;
@@ -108,14 +105,11 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
///
// Create the browser as a child window.
///
void SetAsChild(CefWindowHandle parent, RECT windowRect) {
void SetAsChild(CefWindowHandle parent, const CefRect& bounds) {
style =
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP | WS_VISIBLE;
parent_window = parent;
x = windowRect.left;
y = windowRect.top;
width = windowRect.right - windowRect.left;
height = windowRect.bottom - windowRect.top;
this->bounds = bounds;
}
///
@@ -125,10 +119,10 @@ class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
style =
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE;
parent_window = parent;
x = CW_USEDEFAULT;
y = CW_USEDEFAULT;
width = CW_USEDEFAULT;
height = CW_USEDEFAULT;
bounds.x = CW_USEDEFAULT;
bounds.y = CW_USEDEFAULT;
bounds.width = CW_USEDEFAULT;
bounds.height = CW_USEDEFAULT;
cef_string_copy(windowName.c_str(), windowName.length(), &window_name);
}