Implement Views framework on Windows and Linux (issue #1749).

- Add Views header files in a new include/views directory.
- Add initial top-level window (CefWindow), control (CefBrowserView,
  CefLabelButton, CefMenuButton, CefPanel, CefScrollView,
  CefTextfield) and layout (CefBoxLayout, CefFlowLayout) support.
  See libcef/browser/views/view_impl.h comments for implementation
  details.
- Add Views example usage in cefclient and cefsimple and Views unit
  tests in cef_unittests. Pass the `--use-views` command-line flag to
  cefclient, cefsimple and cef_unittests to run using the Views
  framework instead of platform APIs. For cefclient and cefsimple
  this will create the browser window and all related functionality
  using the Views framework. For cef_unittests this will run all
  tests (except OSR tests) in a Views-based browser window. Views-
  specific unit tests (`--gtest_filter=Views*`) will be run even if
  the the `--use-views` flag is not specified.
- Pass the `--hide-frame` command-line flag to cefclient to demo a
  frameless Views-based browser window.
- Pass the `--hide-controls` command-line flag to cefclient to demo a
  browser window without top controls. This also works in non-Views
  mode.
- Pass the `--enable-high-dpi-support` command-line flag to
  cef_unittests on Windows to test high-DPI support on a display
  that supports it.
- Add CefImage for reading/writing image file formats.
- Add CefBrowser::DownloadImage() for downloading image URLs as a
  CefImage representation. This is primarily for loading favicons.
- Add CefMenuModel::CreateMenuModel() and CefMenuModelDelegate for
  creating custom menus. This is primarily for use with
  CefMenuButton.
- Add CefBrowser::TryCloseBrowser() helper for closing a browser.
  Also improve related documentation in cef_life_span_handler.h.
- Rename cef_page_range_t to cef_range_t. It is now also used by
  CefTextfield.
- Remove CefLifeSpanHandler::RunModal() which is never called.
- Add draggable regions example to cefclient.
This commit is contained in:
Marshall Greenblatt
2016-01-19 15:09:01 -05:00
parent 84fe790035
commit 06e73fff15
333 changed files with 46716 additions and 656 deletions

View File

@@ -205,6 +205,17 @@ class CefRect : public CefStructBase<CefRectTraits> {
void Set(int x_val, int y_val, int width_val, int height_val) {
x = x_val, y = y_val, width = width_val, height = height_val;
}
// Returns true if the point identified by point_x and point_y falls inside
// this rectangle. The point (x, y) is inside the rectangle, but the
// point (x + width, y + height) is not.
bool Contains(int point_x, int point_y) const {
return (point_x >= x) && (point_x < x + width) && (point_y >= y) &&
(point_y < y + height);
}
bool Contains(const CefPoint& point) const {
return Contains(point.x, point.y);
}
};
inline bool operator==(const CefRect& a, const CefRect& b) {
@@ -257,6 +268,89 @@ inline bool operator!=(const CefSize& a, const CefSize& b) {
}
struct CefRangeTraits {
typedef cef_range_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) {
*target = *src;
}
};
///
// Class representing a range.
///
class CefRange : public CefStructBase<CefRangeTraits> {
public:
typedef CefStructBase<CefRangeTraits> parent;
CefRange() : parent() {}
CefRange(const cef_range_t& r) // NOLINT(runtime/explicit)
: parent(r) {}
CefRange(const CefRange& r) // NOLINT(runtime/explicit)
: parent(r) {}
CefRange(int from, int to) : parent() {
Set(from, to);
}
void Set(int from_val, int to_val) {
from = from_val, to = to_val;
}
};
inline bool operator==(const CefRange& a, const CefRange& b) {
return a.from == b.from && a.to == b.to;
}
inline bool operator!=(const CefRange& a, const CefRange& b) {
return !(a == b);
}
struct CefInsetsTraits {
typedef cef_insets_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) {
*target = *src;
}
};
///
// Class representing insets.
///
class CefInsets : public CefStructBase<CefInsetsTraits> {
public:
typedef CefStructBase<CefInsetsTraits> parent;
CefInsets() : parent() {}
CefInsets(const cef_insets_t& r) : parent(r) {} // NOLINT(runtime/explicit)
CefInsets(const CefInsets& r) : parent(r) {} // NOLINT(runtime/explicit)
CefInsets(int top, int left, int bottom, int right) : parent() {
Set(top, left, bottom, right);
}
void Set(int top_val, int left_val, int bottom_val, int right_val) {
top = top_val, left = left_val, bottom = bottom_val, right = right_val;
}
};
inline bool operator==(const CefInsets& a, const CefInsets& b) {
return a.top == b.top && a.left == b.left && a.bottom == b.bottom &&
a.right == b.right;
}
inline bool operator!=(const CefInsets& a, const CefInsets& b) {
return !(a == b);
}
struct CefDraggableRegionTraits {
typedef cef_draggable_region_t struct_type;
@@ -800,48 +894,6 @@ struct CefGeopositionTraits {
typedef CefStructBase<CefGeopositionTraits> CefGeoposition;
struct CefPageRangeTraits {
typedef cef_page_range_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) {
*target = *src;
}
};
///
// Class representing a print job page range.
///
class CefPageRange : public CefStructBase<CefPageRangeTraits> {
public:
typedef CefStructBase<CefPageRangeTraits> parent;
CefPageRange() : parent() {}
CefPageRange(const cef_page_range_t& r) // NOLINT(runtime/explicit)
: parent(r) {}
CefPageRange(const CefPageRange& r) // NOLINT(runtime/explicit)
: parent(r) {}
CefPageRange(int from, int to) : parent() {
Set(from, to);
}
void Set(int from_val, int to_val) {
from = from_val, to = to_val;
}
};
inline bool operator==(const CefPageRange& a, const CefPageRange& b) {
return a.from == b.from && a.to == b.to;
}
inline bool operator!=(const CefPageRange& a, const CefPageRange& b) {
return !(a == b);
}
struct CefCursorInfoTraits {
typedef cef_cursor_info_t struct_type;
@@ -903,4 +955,23 @@ struct CefPdfPrintSettingsTraits {
///
typedef CefStructBase<CefPdfPrintSettingsTraits> CefPdfPrintSettings;
struct CefBoxLayoutSettingsTraits {
typedef cef_box_layout_settings_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) {
*target = *src;
}
};
///
// Class representing CefBoxLayout settings.
///
typedef CefStructBase<CefBoxLayoutSettingsTraits> CefBoxLayoutSettings;
#endif // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_