Commit 2d6e80e8 authored by Santosh Mahto's avatar Santosh Mahto
Browse files

Enable ozone build

parent 2e39487a
......@@ -46,5 +46,6 @@ Thumbs.db
/binary_distrib
/docs
# CEF generated files
/include/cef_config.h
/include/cef_version.h
.ccls-cache/
\ No newline at end of file
.ccls-cache/
......@@ -196,10 +196,13 @@ gypi_paths2 = exec_script("//cef/tools/gypi_to_gn.py",
group("cef") {
testonly = true
deps = [
":cefclient",
":cefsimple",
":ceftests",
]
if (!is_linux || use_x11) {
deps += [ ":cefclient" ]
}
}
......@@ -781,10 +784,15 @@ static_library("libcef_static") {
"libcef/browser/osr/render_widget_host_view_osr_linux.cc",
"libcef/browser/printing/print_dialog_linux.cc",
"libcef/browser/printing/print_dialog_linux.h",
"libcef/browser/native/window_x11.cc",
"libcef/browser/native/window_x11.h",
]
if (use_x11) {
sources += [
"libcef/browser/native/window_x11.cc",
"libcef/browser/native/window_x11.h",
]
}
deps += [
"//build/config/freetype",
"//third_party/fontconfig",
......@@ -906,6 +914,15 @@ static_library("libcef_static") {
"//ui/aura/test/ui_controls_factory_aura.h",
]
if (is_linux && !use_x11) {
sources += [
"//ui/aura/test/mus/window_tree_client_test_api.h",
"//ui/aura/test/mus/window_tree_client_test_api.cc",
"//ui/aura/test/ui_controls_factory_ozone.cc",
"//ui/events/test/events_test_utils.cc"
]
}
deps += [
"//ui/aura",
"//ui/events",
......@@ -943,16 +960,23 @@ static_library("libcef_static") {
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h",
"//ui/aura/test/ui_controls_factory_aurax11.cc",
"//ui/aura/test/x11_event_sender.cc",
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/events:test_support which is testingonly.
"//ui/events/test/platform_event_waiter.cc",
"//ui/events/test/platform_event_waiter.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
if (use_x11) {
sources += [
# Support for UI input events.
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_aurax11.cc",
"//ui/aura/test/x11_event_sender.cc",
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
}
}
} else {
sources += [
......@@ -1964,6 +1988,12 @@ if (is_mac) {
# The cefclient target depends on packages that are not available in the
# default sysroot environment.
if (is_linux && !use_sysroot) {
pkg_config("glib") {
packages = [
"glib-2.0",
]
}
pkg_config("gtk") {
packages = [
"gmodule-2.0",
......@@ -2123,9 +2153,11 @@ if (is_mac) {
sources += gypi_paths2.includes_linux +
gypi_paths2.cefsimple_sources_linux
libs = [
"X11",
]
if (use_x11) {
libs = [
"X11",
]
}
if (!is_component_build) {
# Set rpath to find our own libfreetype even in a non-component build.
......@@ -2182,9 +2214,15 @@ if (is_mac) {
sources += gypi_paths2.shared_sources_linux +
gypi_paths2.ceftests_sources_linux
libs = [
"X11",
]
if (use_x11) {
libs = [
"X11",
]
} else {
if (!use_sysroot) {
configs += [ ":glib" ]
}
}
deps += [
":copy_ceftests_files",
......
......@@ -36,6 +36,7 @@
'include/base/internal/cef_thread_checker_impl.h',
'include/cef_api_hash.h',
'include/cef_base.h',
'include/cef_config.h',
'include/cef_version.h',
'include/internal/cef_export.h',
'include/internal/cef_logging_internal.h',
......
......@@ -32,18 +32,27 @@
#pragma once
#include "include/base/cef_build.h"
#include "include/cef_config.h"
#if defined(OS_LINUX)
#if defined(CEF_X11)
typedef union _XEvent XEvent;
typedef struct _XDisplay XDisplay;
#endif
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
// Handle types.
#if defined(CEF_X11)
#define cef_cursor_handle_t unsigned long
#define cef_event_handle_t XEvent*
#else
#define cef_cursor_handle_t void*
#define cef_event_handle_t void*
#endif
#define cef_window_handle_t unsigned long
#define kNullCursorHandle 0
......@@ -58,7 +67,9 @@ extern "C" {
// Return the singleton X11 display shared with Chromium. The display is not
// thread-safe and must only be accessed on the browser process UI thread.
///
#if defined(CEF_X11)
CEF_EXPORT XDisplay* cef_get_xdisplay();
#endif
///
// Structure representing CefExecuteProcess arguments.
......
......@@ -10,7 +10,6 @@
#include "libcef/browser/context.h"
#include "libcef/browser/native/menu_runner_linux.h"
#include "libcef/browser/native/window_delegate_view.h"
#include "libcef/browser/native/window_x11.h"
#include "libcef/browser/thread_util.h"
#include "base/no_destructor.h"
......@@ -23,10 +22,14 @@
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
#include "ui/events/keycodes/keysym_to_unicode.h"
#include "ui/gfx/font_render_params.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#include "ui/views/widget/widget.h"
#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
#if defined(USE_X11)
#include "libcef/browser/native/window_x11.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#endif
namespace {
// Returns the number of seconds since system boot.
......@@ -48,8 +51,7 @@ CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
false,
use_external_begin_frame),
host_window_created_(false),
window_widget_(nullptr),
window_x11_(nullptr) {}
window_widget_(nullptr) {}
void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
CefBrowserHostImpl* browser) {
......@@ -62,7 +64,6 @@ void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
}
bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
DCHECK(!window_x11_);
DCHECK(!window_widget_);
if (window_info_.width == 0)
......@@ -73,6 +74,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
gfx::Rect rect(window_info_.x, window_info_.y, window_info_.width,
window_info_.height);
#if defined(USE_X11)
DCHECK(!window_x11_);
// Create a new window object. It will delete itself when the associated X11
// window is destroyed.
window_x11_ = new CefWindowX11(browser_, window_info_.parent_window, rect,
......@@ -93,6 +96,7 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
window_widget_->Show();
window_x11_->Show();
#endif // defined(USE_X11)
// As an additional requirement on Linux, we must set the colors for the
// render widgets in webkit.
......@@ -121,8 +125,10 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
}
void CefBrowserPlatformDelegateNativeLinux::CloseHostWindow() {
#if defined(USE_X11)
if (window_x11_)
window_x11_->Close();
#endif
}
CefWindowHandle CefBrowserPlatformDelegateNativeLinux::GetHostWindowHandle()
......@@ -146,18 +152,21 @@ void CefBrowserPlatformDelegateNativeLinux::SendFocusEvent(bool setFocus) {
browser_->web_contents()->Focus();
}
#if defined(USE_X11)
if (window_x11_) {
// Give native focus to the DesktopNativeWidgetAura for the root window.
// Needs to be done via the ::Window so that keyboard focus is assigned
// correctly.
window_x11_->Focus();
}
#endif // defined(USE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
// Call the parent method to dismiss any existing popups.
CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted();
#if defined(USE_X11)
if (!window_x11_)
return;
......@@ -175,13 +184,16 @@ void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
content::RenderWidgetHostImpl::From(
browser_->web_contents()->GetRenderViewHost()->GetWidget())
->SendScreenRects();
#endif // defined(USE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::SizeTo(int width, int height) {
#if defined(USE_X11)
if (window_x11_) {
window_x11_->SetBounds(
gfx::Rect(window_x11_->bounds().origin(), gfx::Size(width, height)));
}
#endif // defined(USE_X11)
}
gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
......@@ -189,6 +201,7 @@ gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
if (windowless_handler_)
return windowless_handler_->GetParentScreenPoint(view);
#if defined(USE_X11)
if (!window_x11_)
return view;
......@@ -198,6 +211,8 @@ gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
const gfx::Rect& bounds_in_screen = window_x11_->GetBoundsInScreen();
return gfx::Point(bounds_in_screen.x() + view.x(),
bounds_in_screen.y() + view.y());
#endif // defined(USE_X11)
return gfx::Point();
}
void CefBrowserPlatformDelegateNativeLinux::ViewText(const std::string& text) {
......@@ -260,6 +275,7 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
NOTREACHED();
}
#if defined(USE_X11)
// Populate DOM values that will be passed to JavaScript handlers via
// KeyboardEvent.
result.dom_code = static_cast<int>(
......@@ -275,6 +291,7 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
result.SetModifiers(result.GetModifiers() |
TranslateModifiers(key_event.modifiers));
#endif // defined(USE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent(
......@@ -363,7 +380,8 @@ CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const {
if (!event.os_event)
return NULL;
return const_cast<CefEventHandle>(event.os_event->native_event());
return const_cast<CefEventHandle>(
static_cast<CefEventHandle>(event.os_event->native_event()));
}
std::unique_ptr<CefMenuRunner>
......
......@@ -7,7 +7,9 @@
#include "libcef/browser/native/browser_platform_delegate_native.h"
#if defined(USE_X11)
class CefWindowX11;
#endif
// Windowed browser implementation for Linux.
class CefBrowserPlatformDelegateNativeLinux
......@@ -60,7 +62,9 @@ class CefBrowserPlatformDelegateNativeLinux
// associated root window is destroyed.
views::Widget* window_widget_;
CefWindowX11* window_x11_;
#if defined(USE_X11)
CefWindowX11* window_x11_ = nullptr;
#endif
};
#endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_LINUX_H_
......@@ -9,7 +9,6 @@
#include <utility>
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/osr/software_output_device_osr.h"
#include "libcef/browser/osr/synthetic_gesture_target_osr.h"
......
......@@ -13,7 +13,7 @@
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/osr/motion_event_osr.h"
#include "base/memory/weak_ptr.h"
......@@ -60,7 +60,6 @@ class CursorManager;
} // namespace content
class CefBeginFrameTimer;
class CefBrowserHostImpl;
class CefCopyFrameGenerator;
class CefSoftwareOutputDeviceOSR;
class CefWebContentsViewOSR;
......
......@@ -5,16 +5,20 @@
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "third_party/blink/public/platform/web_cursor_info.h"
#if defined(USE_X11)
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#undef Status // Avoid conflicts with url_request_status.h
#include "libcef/browser/native/window_x11.h"
#include "third_party/blink/public/platform/web_cursor_info.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h"
#endif // defined(USE_X11)
#if defined(USE_X11)
namespace {
// Based on ui/base/cursor/cursor_loader_x11.cc.
......@@ -163,25 +167,31 @@ XCursorCache* cursor_cache = nullptr;
}
} // namespace
#endif // defined(USE_X11)
void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
bool is_guest_view_hack) {
#if defined(USE_X11)
// Create a hidden 1x1 window. It will delete itself on close.
window_ = new CefWindowX11(NULL, None, gfx::Rect(0, 0, 1, 1), "");
compositor_widget_ = window_->xwindow();
#endif
}
void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget(
const gfx::Size&) {}
void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {
#if defined(USE_X11)
DCHECK(window_);
window_->Close();
#endif
compositor_widget_ = gfx::kNullAcceleratedWidget;
}
ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
blink::WebCursorInfo::Type type) {
#if defined(USE_X11)
if (type == WebCursorInfo::kTypeNone) {
if (!invisible_cursor_) {
invisible_cursor_.reset(new ui::XScopedCursor(ui::CreateInvisibleCursor(),
......@@ -191,4 +201,6 @@ ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
} else {
return GetXCursor(ToCursorID(type));
}
#endif // defined(USE_X11)
return 0;
}
......@@ -20,7 +20,7 @@
#include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/aura/window.h"
#include "ui/base/test/ui_controls_aura.h"
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(USE_X11)
#include "ui/views/test/ui_controls_factory_desktop_aurax11.h"
#endif
#endif
......@@ -37,8 +37,9 @@ void InitializeUITesting() {
if (!initialized) {
ui_controls::EnableUIControls();
#if defined(USE_AURA)
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(USE_X11)
ui_controls::InstallUIControlsAura(
views::test::CreateUIControlsDesktopAura());
#else
......
......@@ -13,7 +13,7 @@
#include "ui/views/widget/widget.h"
#include "ui/views/window/native_frame_view.h"
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(USE_X11)
#include <X11/Xlib.h>
#include "ui/gfx/x/x11_types.h"
#endif
......@@ -250,6 +250,7 @@ void CefWindowView::CreateWidget() {
views::Widget::InitParams params;
params.delegate = this;
params.type = views::Widget::InitParams::TYPE_WINDOW;
params.bounds = gfx::Rect(CalculatePreferredSize());
bool can_activate = true;
if (cef_delegate()) {
......@@ -294,7 +295,7 @@ void CefWindowView::CreateWidget() {
DCHECK(widget->widget_delegate()->CanActivate());
}
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(USE_X11)
if (is_frameless_) {
::Window window = view_util::GetWindowHandle(widget);
DCHECK(window);
......@@ -329,7 +330,7 @@ void CefWindowView::CreateWidget() {
XChangeProperty(display, window, mwmHintsProperty, mwmHintsProperty, 32,
PropModeReplace, (unsigned char*)&hints, 5);
}
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) && defined(USE_X11)
}
CefRefPtr<CefWindow> CefWindowView::GetCefWindow() const {
......
......@@ -4,10 +4,13 @@
#include "tests/cefsimple/simple_app.h"
#if defined(CEF_X11)
#include <X11/Xlib.h>
#endif
#include "include/base/cef_logging.h"
#if defined(CEF_X11)
namespace {
int XErrorHandlerImpl(Display* display, XErrorEvent* event) {
......@@ -26,6 +29,7 @@ int XIOErrorHandlerImpl(Display* display) {
}
} // namespace
#endif // defined(CEF_X11)
// Entry point function for all processes.
int main(int argc, char* argv[]) {
......@@ -41,10 +45,12 @@ int main(int argc, char* argv[]) {
return exit_code;
}
#if defined(CEF_X11)
// Install xlib error handlers so that the application won't be terminated
// on non-fatal errors.
XSetErrorHandler(XErrorHandlerImpl);
XSetIOErrorHandler(XIOErrorHandlerImpl);
#endif
// Specify CEF global settings here.
CefSettings settings;
......
......@@ -43,6 +43,10 @@ class SimpleWindowDelegate : public CefWindowDelegate {
return true;
}
CefSize GetPreferredSize(CefRefPtr<CefView> view) OVERRIDE {
return CefSize(800, 600);
}
private:
CefRefPtr<CefBrowserView> browser_view_;
......
......@@ -4,8 +4,11 @@
#include "tests/cefsimple/simple_handler.h"
#if defined(CEF_X11)
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#endif
#include <string>
#include "include/base/cef_logging.h"
......@@ -15,6 +18,7 @@ void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
std::string titleStr(title);
#if defined(CEF_X11)
// Retrieve the X11 display shared with Chromium.
::Display* display = cef_get_xdisplay();
DCHECK(display);
......@@ -41,4 +45,5 @@ void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
// is Compound Text. This shouldn't matter 90% of the time since this is the
// fallback to the UTF8 property above.
XStoreName(display, browser->GetHost()->GetWindowHandle(), titleStr.c_str());
#endif // defined(CEF_X11)
}
......@@ -4,7 +4,7 @@
#include "include/base/cef_build.h"
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(CEF_X11)
#include <X11/Xlib.h>
// Definitions conflict with gtest.
#undef None
......@@ -84,7 +84,7 @@ void ContinueOnUIThread(CefRefPtr<CefTaskRunner> test_task_runner) {
CefCreateClosureTask(base::Bind(&RunTestsOnTestThread)));
}
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(CEF_X11)
int XErrorHandlerImpl(Display* display, XErrorEvent* event) {
LOG(WARNING) << "X error received: "
<< "type " << event->type << ", "
......@@ -99,7 +99,7 @@ int XErrorHandlerImpl(Display* display, XErrorEvent* event) {
int XIOErrorHandlerImpl(Display* display) {
return 0;
}
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) && defined(CEF_X11)
} // namespace
......@@ -173,7 +173,7 @@ int main(int argc, char* argv[]) {
PlatformInit();
#endif
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(CEF_X11)
// Install xlib error handlers so that the application won't be terminated
// on non-fatal errors.
XSetErrorHandler(XErrorHandlerImpl);
......
......@@ -132,3 +132,14 @@ for dir, config in configs.items():
RunAction(src_dir, cmd)
if platform == 'windows':
issue_1999.apply(out_path)
gn_dir = configs.keys()[0]
out_gn_path = os.path.join(src_dir, 'out', gn_dir)
gn_path = os.path.join(out_gn_path, 'args.gn')
print "\nGenerating CEF buildinfo header file..."
cmd = [
'python', 'tools/make_config_header.py', '--header', 'include/cef_config.h',
'--cef_gn_config', gn_path
]
RunAction(cef_dir, cmd)
# Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
from date_util import *
from file_util import *
from optparse import OptionParser
import sys
# cannot be loaded as a module
if __name__ != "__main__":
sys.stderr.write('This file cannot be loaded as a module!')
sys.exit()
# parse command-line options
disc = """
This utility creates the config header file.
"""
parser = OptionParser(description=disc)
parser.add_option(
'--header',
dest='header',
metavar='FILE',
help='output config header file [required]')
parser.add_option(
'--cef_gn_config',
dest='cef_gn_config',