mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update source files for bracket style
This commit is contained in:
@@ -23,8 +23,9 @@ CefBrowserPlatformDelegateNativeAura::CefBrowserPlatformDelegateNativeAura(
|
||||
void CefBrowserPlatformDelegateNativeAura::SendKeyEvent(
|
||||
const CefKeyEvent& event) {
|
||||
auto view = GetHostView();
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui::KeyEvent ui_event = TranslateUiKeyEvent(event);
|
||||
view->OnKeyEvent(&ui_event);
|
||||
@@ -36,8 +37,9 @@ void CefBrowserPlatformDelegateNativeAura::SendMouseClickEvent(
|
||||
bool mouseUp,
|
||||
int clickCount) {
|
||||
auto view = GetHostView();
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui::MouseEvent ui_event =
|
||||
TranslateUiClickEvent(event, type, mouseUp, clickCount);
|
||||
@@ -48,8 +50,9 @@ void CefBrowserPlatformDelegateNativeAura::SendMouseMoveEvent(
|
||||
const CefMouseEvent& event,
|
||||
bool mouseLeave) {
|
||||
auto view = GetHostView();
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui::MouseEvent ui_event = TranslateUiMoveEvent(event, mouseLeave);
|
||||
view->OnMouseEvent(&ui_event);
|
||||
@@ -60,8 +63,9 @@ void CefBrowserPlatformDelegateNativeAura::SendMouseWheelEvent(
|
||||
int deltaX,
|
||||
int deltaY) {
|
||||
auto view = GetHostView();
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui::MouseWheelEvent ui_event = TranslateUiWheelEvent(event, deltaX, deltaY);
|
||||
view->OnMouseEvent(&ui_event);
|
||||
@@ -80,11 +84,13 @@ CefBrowserPlatformDelegateNativeAura::CreateMenuRunner() {
|
||||
gfx::Point CefBrowserPlatformDelegateNativeAura::GetScreenPoint(
|
||||
const gfx::Point& view,
|
||||
bool want_dip_coords) const {
|
||||
if (windowless_handler_)
|
||||
if (windowless_handler_) {
|
||||
return windowless_handler_->GetParentScreenPoint(view, want_dip_coords);
|
||||
}
|
||||
|
||||
if (!window_widget_)
|
||||
if (!window_widget_) {
|
||||
return view;
|
||||
}
|
||||
|
||||
gfx::Point screen_pt(view);
|
||||
if (!view_util::ConvertPointToScreen(
|
||||
@@ -220,30 +226,42 @@ int CefBrowserPlatformDelegateNativeAura::TranslateUiEventModifiers(
|
||||
uint32 cef_modifiers) {
|
||||
int result = 0;
|
||||
// Set modifiers based on key state.
|
||||
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
|
||||
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) {
|
||||
result |= ui::EF_CAPS_LOCK_ON;
|
||||
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) {
|
||||
result |= ui::EF_SHIFT_DOWN;
|
||||
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) {
|
||||
result |= ui::EF_CONTROL_DOWN;
|
||||
if (cef_modifiers & EVENTFLAG_ALT_DOWN)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_ALT_DOWN) {
|
||||
result |= ui::EF_ALT_DOWN;
|
||||
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) {
|
||||
result |= ui::EF_LEFT_MOUSE_BUTTON;
|
||||
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) {
|
||||
result |= ui::EF_MIDDLE_MOUSE_BUTTON;
|
||||
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) {
|
||||
result |= ui::EF_RIGHT_MOUSE_BUTTON;
|
||||
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) {
|
||||
result |= ui::EF_COMMAND_DOWN;
|
||||
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) {
|
||||
result |= ui::EF_NUM_LOCK_ON;
|
||||
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_IS_KEY_PAD) {
|
||||
result |= ui::EF_IS_EXTENDED_KEY;
|
||||
if (cef_modifiers & EVENTFLAG_ALTGR_DOWN)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_ALTGR_DOWN) {
|
||||
result |= ui::EF_ALTGR_DOWN;
|
||||
if (cef_modifiers & EVENTFLAG_IS_REPEAT)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_IS_REPEAT) {
|
||||
result |= ui::EF_IS_REPEAT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -251,19 +269,21 @@ int CefBrowserPlatformDelegateNativeAura::TranslateUiEventModifiers(
|
||||
int CefBrowserPlatformDelegateNativeAura::TranslateUiChangedButtonFlags(
|
||||
uint32 cef_modifiers) {
|
||||
int result = 0;
|
||||
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
|
||||
if (cef_modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) {
|
||||
result |= ui::EF_LEFT_MOUSE_BUTTON;
|
||||
else if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
|
||||
} else if (cef_modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) {
|
||||
result |= ui::EF_MIDDLE_MOUSE_BUTTON;
|
||||
else if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
|
||||
} else if (cef_modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) {
|
||||
result |= ui::EF_RIGHT_MOUSE_BUTTON;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
content::RenderWidgetHostViewAura*
|
||||
CefBrowserPlatformDelegateNativeAura::GetHostView() const {
|
||||
if (!web_contents_)
|
||||
if (!web_contents_) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<content::RenderWidgetHostViewAura*>(
|
||||
web_contents_->GetRenderWidgetHostView());
|
||||
}
|
||||
|
@@ -45,10 +45,12 @@ void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
|
||||
bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
DCHECK(!window_widget_);
|
||||
|
||||
if (window_info_.bounds.width == 0)
|
||||
if (window_info_.bounds.width == 0) {
|
||||
window_info_.bounds.width = 800;
|
||||
if (window_info_.bounds.height == 0)
|
||||
}
|
||||
if (window_info_.bounds.height == 0) {
|
||||
window_info_.bounds.height = 600;
|
||||
}
|
||||
|
||||
gfx::Rect rect(window_info_.bounds.x, window_info_.bounds.y,
|
||||
window_info_.bounds.width, window_info_.bounds.height);
|
||||
@@ -114,15 +116,17 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::CloseHostWindow() {
|
||||
#if BUILDFLAG(OZONE_PLATFORM_X11)
|
||||
if (window_x11_)
|
||||
if (window_x11_) {
|
||||
window_x11_->Close();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeLinux::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
if (windowless_handler_) {
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
}
|
||||
return window_info_.window;
|
||||
}
|
||||
|
||||
@@ -131,8 +135,9 @@ views::Widget* CefBrowserPlatformDelegateNativeLinux::GetWindowWidget() const {
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::SetFocus(bool setFocus) {
|
||||
if (!setFocus)
|
||||
if (!setFocus) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (web_contents_) {
|
||||
// Give logical focus to the RenderWidgetHostViewAura in the views
|
||||
@@ -154,16 +159,19 @@ void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
|
||||
// Call the parent method to dismiss any existing popups.
|
||||
CefBrowserPlatformDelegateNativeAura::NotifyMoveOrResizeStarted();
|
||||
|
||||
if (!web_contents_)
|
||||
if (!web_contents_) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(OZONE_PLATFORM_X11)
|
||||
if (!window_x11_)
|
||||
if (!window_x11_) {
|
||||
return;
|
||||
}
|
||||
|
||||
views::DesktopWindowTreeHostLinux* tree_host = window_x11_->GetHost();
|
||||
if (!tree_host)
|
||||
if (!tree_host) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Explicitly set the screen bounds so that WindowTreeHost::*Screen()
|
||||
// methods return the correct results.
|
||||
@@ -191,12 +199,14 @@ void CefBrowserPlatformDelegateNativeLinux::ViewText(const std::string& text) {
|
||||
char buff[] = "/tmp/CEFSourceXXXXXX";
|
||||
int fd = mkstemp(buff);
|
||||
|
||||
if (fd == -1)
|
||||
if (fd == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* srcOutput = fdopen(fd, "w+");
|
||||
if (!srcOutput)
|
||||
if (!srcOutput) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fputs(text.c_str(), srcOutput) < 0) {
|
||||
fclose(srcOutput);
|
||||
@@ -207,8 +217,9 @@ void CefBrowserPlatformDelegateNativeLinux::ViewText(const std::string& text) {
|
||||
|
||||
std::string newName(buff);
|
||||
newName.append(".txt");
|
||||
if (rename(buff, newName.c_str()) != 0)
|
||||
if (rename(buff, newName.c_str()) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string openCommand("xdg-open ");
|
||||
openCommand += newName;
|
||||
|
@@ -111,9 +111,9 @@ namespace {
|
||||
|
||||
NSTimeInterval currentEventTimestamp() {
|
||||
NSEvent* currentEvent = [NSApp currentEvent];
|
||||
if (currentEvent)
|
||||
if (currentEvent) {
|
||||
return [currentEvent timestamp];
|
||||
else {
|
||||
} else {
|
||||
// FIXME(API): In case there is no current event, the timestamp could be
|
||||
// obtained by getting the time since the application started. This involves
|
||||
// taking some more static functions from Chromium code.
|
||||
@@ -125,18 +125,24 @@ NSTimeInterval currentEventTimestamp() {
|
||||
|
||||
NSUInteger NativeModifiers(int cef_modifiers) {
|
||||
NSUInteger native_modifiers = 0;
|
||||
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN)
|
||||
if (cef_modifiers & EVENTFLAG_SHIFT_DOWN) {
|
||||
native_modifiers |= NSEventModifierFlagShift;
|
||||
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_CONTROL_DOWN) {
|
||||
native_modifiers |= NSEventModifierFlagControl;
|
||||
if (cef_modifiers & EVENTFLAG_ALT_DOWN)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_ALT_DOWN) {
|
||||
native_modifiers |= NSEventModifierFlagOption;
|
||||
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_COMMAND_DOWN) {
|
||||
native_modifiers |= NSEventModifierFlagCommand;
|
||||
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_CAPS_LOCK_ON) {
|
||||
native_modifiers |= NSEventModifierFlagCapsLock;
|
||||
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON)
|
||||
}
|
||||
if (cef_modifiers & EVENTFLAG_NUM_LOCK_ON) {
|
||||
native_modifiers |= NSEventModifierFlagNumericPad;
|
||||
}
|
||||
|
||||
return native_modifiers;
|
||||
}
|
||||
@@ -342,16 +348,18 @@ void CefBrowserPlatformDelegateNativeMac::CloseHostWindow() {
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeMac::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
if (windowless_handler_) {
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
}
|
||||
return window_info_.view;
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeMac::SendKeyEvent(
|
||||
const CefKeyEvent& event) {
|
||||
auto view = GetHostView();
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
content::NativeWebKeyboardEvent web_event = TranslateWebKeyEvent(event);
|
||||
view->ForwardKeyboardEvent(web_event, ui::LatencyInfo());
|
||||
@@ -363,8 +371,9 @@ void CefBrowserPlatformDelegateNativeMac::SendMouseClickEvent(
|
||||
bool mouseUp,
|
||||
int clickCount) {
|
||||
auto view = GetHostView();
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
blink::WebMouseEvent web_event =
|
||||
TranslateWebClickEvent(event, type, mouseUp, clickCount);
|
||||
@@ -375,8 +384,9 @@ void CefBrowserPlatformDelegateNativeMac::SendMouseMoveEvent(
|
||||
const CefMouseEvent& event,
|
||||
bool mouseLeave) {
|
||||
auto view = GetHostView();
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
blink::WebMouseEvent web_event = TranslateWebMoveEvent(event, mouseLeave);
|
||||
view->RouteOrProcessMouseEvent(web_event);
|
||||
@@ -387,8 +397,9 @@ void CefBrowserPlatformDelegateNativeMac::SendMouseWheelEvent(
|
||||
int deltaX,
|
||||
int deltaY) {
|
||||
auto view = GetHostView();
|
||||
if (!view)
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
blink::WebMouseWheelEvent web_event =
|
||||
TranslateWebWheelEvent(event, deltaX, deltaY);
|
||||
@@ -418,8 +429,9 @@ gfx::Point CefBrowserPlatformDelegateNativeMac::GetScreenPoint(
|
||||
const gfx::Point& view,
|
||||
bool want_dip_coords) const {
|
||||
// Mac always operates in DIP coordinates so |want_dip_coords| is ignored.
|
||||
if (windowless_handler_)
|
||||
if (windowless_handler_) {
|
||||
return windowless_handler_->GetParentScreenPoint(view, want_dip_coords);
|
||||
}
|
||||
|
||||
NSView* nsview = CAST_CEF_WINDOW_HANDLE_TO_NSVIEW(window_info_.parent_view);
|
||||
if (nsview) {
|
||||
@@ -442,8 +454,9 @@ void CefBrowserPlatformDelegateNativeMac::ViewText(const std::string& text) {
|
||||
bool CefBrowserPlatformDelegateNativeMac::HandleKeyboardEvent(
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
// Give the top level menu equivalents a chance to handle the event.
|
||||
if ([event.os_event type] == NSEventTypeKeyDown)
|
||||
if ([event.os_event type] == NSEventTypeKeyDown) {
|
||||
return [[NSApp mainMenu] performKeyEquivalent:event.os_event];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -517,8 +530,9 @@ CefBrowserPlatformDelegateNativeMac::TranslateWebKeyEvent(
|
||||
keyCode:key_event.native_key_code];
|
||||
|
||||
result = content::NativeWebKeyboardEvent(synthetic_event);
|
||||
if (key_event.type == KEYEVENT_CHAR)
|
||||
if (key_event.type == KEYEVENT_CHAR) {
|
||||
result.SetType(blink::WebInputEvent::Type::kChar);
|
||||
}
|
||||
|
||||
result.is_system_key = key_event.is_system_key;
|
||||
|
||||
@@ -567,14 +581,15 @@ blink::WebMouseEvent CefBrowserPlatformDelegateNativeMac::TranslateWebMoveEvent(
|
||||
|
||||
if (!mouseLeave) {
|
||||
result.SetType(blink::WebInputEvent::Type::kMouseMove);
|
||||
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
|
||||
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) {
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
|
||||
} else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) {
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
|
||||
} else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) {
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
else
|
||||
} else {
|
||||
result.button = blink::WebMouseEvent::Button::kNoButton;
|
||||
}
|
||||
} else {
|
||||
result.SetType(blink::WebInputEvent::Type::kMouseLeave);
|
||||
result.button = blink::WebMouseEvent::Button::kNoButton;
|
||||
@@ -602,14 +617,15 @@ CefBrowserPlatformDelegateNativeMac::TranslateWebWheelEvent(
|
||||
result.wheel_ticks_y = deltaY / scrollbarPixelsPerCocoaTick;
|
||||
result.delta_units = ui::ScrollGranularity::kScrollByPrecisePixel;
|
||||
|
||||
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON)
|
||||
if (mouse_event.modifiers & EVENTFLAG_LEFT_MOUSE_BUTTON) {
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON)
|
||||
} else if (mouse_event.modifiers & EVENTFLAG_MIDDLE_MOUSE_BUTTON) {
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON)
|
||||
} else if (mouse_event.modifiers & EVENTFLAG_RIGHT_MOUSE_BUTTON) {
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
else
|
||||
} else {
|
||||
result.button = blink::WebMouseEvent::Button::kNoButton;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -637,8 +653,9 @@ void CefBrowserPlatformDelegateNativeMac::TranslateWebMouseEvent(
|
||||
|
||||
content::RenderWidgetHostViewMac*
|
||||
CefBrowserPlatformDelegateNativeMac::GetHostView() const {
|
||||
if (!web_contents_)
|
||||
if (!web_contents_) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<content::RenderWidgetHostViewMac*>(
|
||||
web_contents_->GetRenderWidgetHostView());
|
||||
}
|
||||
|
@@ -46,8 +46,9 @@ void WriteTempFileAndView(const std::string& data) {
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
|
||||
base::FilePath tmp_file;
|
||||
if (!base::CreateTemporaryFile(&tmp_file))
|
||||
if (!base::CreateTemporaryFile(&tmp_file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The shell command will look at the file extension to identify the correct
|
||||
// program to open.
|
||||
@@ -82,8 +83,9 @@ bool HasExternalHandler(const std::string& scheme) {
|
||||
void ExecuteExternalProtocol(const GURL& url) {
|
||||
CEF_REQUIRE_BLOCKING();
|
||||
|
||||
if (!HasExternalHandler(url.scheme()))
|
||||
if (!HasExternalHandler(url.scheme())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Quote the input scheme to be sure that the command does not have
|
||||
// parameters unexpected by the external program. This url should already
|
||||
@@ -99,8 +101,9 @@ void ExecuteExternalProtocol(const GURL& url) {
|
||||
//
|
||||
// It may be possible to increase this. https://crbug.com/727909
|
||||
const size_t kMaxUrlLength = 2048;
|
||||
if (escaped_url.length() > kMaxUrlLength)
|
||||
if (escaped_url.length() > kMaxUrlLength) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Specify %windir%\system32 as the CWD so that any new proc spawned does not
|
||||
// inherit this proc's CWD. Without this, uninstalls may be broken by a
|
||||
@@ -239,8 +242,9 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
// It's possible for CreateWindowEx to fail if the parent window was
|
||||
// destroyed between the call to CreateBrowser and the above one.
|
||||
DCHECK(window_info_.window);
|
||||
if (!window_info_.window)
|
||||
if (!window_info_.window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
host_window_created_ = true;
|
||||
|
||||
@@ -257,8 +261,9 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
return reinterpret_cast<EnableChildWindowDpiMessagePtr>(GetProcAddress(
|
||||
GetModuleHandle(L"user32.dll"), "EnableChildWindowDpiMessage"));
|
||||
}();
|
||||
if (enable_child_window_dpi_message_func)
|
||||
if (enable_child_window_dpi_message_func) {
|
||||
enable_child_window_dpi_message_func(window_info_.window, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
DCHECK(!window_widget_);
|
||||
@@ -317,8 +322,9 @@ void CefBrowserPlatformDelegateNativeWin::CloseHostWindow() {
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeWin::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
if (windowless_handler_) {
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
}
|
||||
return window_info_.window;
|
||||
}
|
||||
|
||||
@@ -327,8 +333,9 @@ views::Widget* CefBrowserPlatformDelegateNativeWin::GetWindowWidget() const {
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::SetFocus(bool setFocus) {
|
||||
if (!setFocus)
|
||||
if (!setFocus) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window_widget_) {
|
||||
// Give native focus to the DesktopWindowTreeHostWin ("Chrome_WidgetWin_0")
|
||||
@@ -397,8 +404,9 @@ void CefBrowserPlatformDelegateNativeWin::NotifyMoveOrResizeStarted() {
|
||||
// Call the parent method to dismiss any existing popups.
|
||||
CefBrowserPlatformDelegateNativeAura::NotifyMoveOrResizeStarted();
|
||||
|
||||
if (!window_widget_)
|
||||
if (!window_widget_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify DesktopWindowTreeHostWin of move events so that screen rectangle
|
||||
// information is communicated to the renderer process and popups are
|
||||
@@ -444,8 +452,9 @@ bool CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
MSG msg = {};
|
||||
|
||||
msg.hwnd = GetHostWindowHandle();
|
||||
if (!msg.hwnd)
|
||||
if (!msg.hwnd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (event.GetType()) {
|
||||
case blink::WebInputEvent::Type::kRawKeyDown:
|
||||
@@ -467,8 +476,9 @@ bool CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
UINT scan_code = ::MapVirtualKeyW(event.windows_key_code, MAPVK_VK_TO_VSC);
|
||||
msg.lParam = (scan_code << 16) | // key scan code
|
||||
1; // key repeat count
|
||||
if (event.GetModifiers() & content::NativeWebKeyboardEvent::kAltKey)
|
||||
if (event.GetModifiers() & content::NativeWebKeyboardEvent::kAltKey) {
|
||||
msg.lParam |= (1 << 29);
|
||||
}
|
||||
|
||||
return !DefWindowProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
|
||||
}
|
||||
@@ -481,8 +491,9 @@ void CefBrowserPlatformDelegate::HandleExternalProtocol(const GURL& url) {
|
||||
|
||||
CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const {
|
||||
if (!event.os_event)
|
||||
if (!event.os_event) {
|
||||
return NULL;
|
||||
}
|
||||
return ChromeToWindowsType(
|
||||
const_cast<CHROME_MSG*>(&event.os_event->native_event()));
|
||||
}
|
||||
@@ -545,8 +556,9 @@ gfx::Vector2d CefBrowserPlatformDelegateNativeWin::GetUiWheelEventOffset(
|
||||
// static
|
||||
void CefBrowserPlatformDelegateNativeWin::RegisterWindowClass() {
|
||||
static bool registered = false;
|
||||
if (registered)
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Register the window class
|
||||
WNDCLASSEX wcex = {
|
||||
@@ -651,16 +663,18 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
|
||||
|
||||
case WM_MOVING:
|
||||
case WM_MOVE:
|
||||
if (browser)
|
||||
if (browser) {
|
||||
browser->NotifyMoveOrResizeStarted();
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
// Selecting "Close window" from the task bar menu may send a focus
|
||||
// notification even though the window is currently disabled (e.g. while
|
||||
// a modal JS dialog is displayed).
|
||||
if (browser && ::IsWindowEnabled(hwnd))
|
||||
if (browser && ::IsWindowEnabled(hwnd)) {
|
||||
browser->SetFocus(true);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
|
@@ -50,14 +50,18 @@ display::Display::Rotation OrientationAngleToRotation(
|
||||
// angle. The former is the physical display rotation while the later is the
|
||||
// rotation required by the content to be shown properly on the screen, in
|
||||
// other words, relative to the physical display.
|
||||
if (orientation_angle == 0)
|
||||
if (orientation_angle == 0) {
|
||||
return display::Display::ROTATE_0;
|
||||
if (orientation_angle == 90)
|
||||
}
|
||||
if (orientation_angle == 90) {
|
||||
return display::Display::ROTATE_270;
|
||||
if (orientation_angle == 180)
|
||||
}
|
||||
if (orientation_angle == 180) {
|
||||
return display::Display::ROTATE_180;
|
||||
if (orientation_angle == 270)
|
||||
}
|
||||
if (orientation_angle == 270) {
|
||||
return display::Display::ROTATE_90;
|
||||
}
|
||||
NOTREACHED();
|
||||
return display::Display::ROTATE_0;
|
||||
}
|
||||
@@ -69,11 +73,13 @@ display::Display::Rotation OrientationAngleToRotation(
|
||||
bool OnCursorChange(CefRefPtr<CefBrowser> browser,
|
||||
const ui::Cursor& ui_cursor) {
|
||||
auto client = browser->GetHost()->GetClient();
|
||||
if (!client)
|
||||
if (!client) {
|
||||
return false;
|
||||
}
|
||||
auto handler = client->GetDisplayHandler();
|
||||
if (!handler)
|
||||
if (!handler) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const cef_cursor_type_t cursor_type =
|
||||
static_cast<cef_cursor_type_t>(ui_cursor.type());
|
||||
|
@@ -38,8 +38,9 @@
|
||||
|
||||
- (id)initHelperWithCallback:
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback {
|
||||
if (self = [super init])
|
||||
if (self = [super init]) {
|
||||
callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -62,13 +63,15 @@
|
||||
- (void)alertDidEnd:(NSAlert*)alert
|
||||
returnCode:(int)returnCode
|
||||
contextInfo:(void*)contextInfo {
|
||||
if (returnCode == NSModalResponseStop)
|
||||
if (returnCode == NSModalResponseStop) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool success = returnCode == NSAlertFirstButtonReturn;
|
||||
std::u16string input;
|
||||
if (textField_)
|
||||
if (textField_) {
|
||||
input = base::SysNSStringToUTF16([textField_ stringValue]);
|
||||
}
|
||||
|
||||
std::move(callback_).Run(success, input);
|
||||
}
|
||||
@@ -130,8 +133,9 @@ void CefJavaScriptDialogRunnerMac::Run(
|
||||
|
||||
const std::u16string& display_url =
|
||||
url_formatter::FormatUrlForSecurityDisplay(origin_url);
|
||||
if (!display_url.empty())
|
||||
if (!display_url.empty()) {
|
||||
label += u" - " + display_url;
|
||||
}
|
||||
|
||||
[alert setMessageText:base::SysUTF16ToNSString(label)];
|
||||
|
||||
@@ -156,8 +160,9 @@ void CefJavaScriptDialogRunnerMac::Run(
|
||||
contextInfo:this];
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
if ([alert accessoryView])
|
||||
if ([alert accessoryView]) {
|
||||
[[alert window] makeFirstResponder:[alert accessoryView]];
|
||||
}
|
||||
}
|
||||
|
||||
void CefJavaScriptDialogRunnerMac::Handle(
|
||||
|
@@ -45,8 +45,9 @@ bool CefMenuRunnerMac::RunContextMenu(
|
||||
// Show the menu. Blocks until the menu is dismissed.
|
||||
if (browser->IsWindowless()) {
|
||||
// Don't show the menu unless a native window handle exists.
|
||||
if (!browser->GetWindowHandle())
|
||||
if (!browser->GetWindowHandle()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const gfx::Point& screen_point = browser->GetScreenPoint(
|
||||
gfx::Point(params.x, params.y), /*want_dip_coords=*/true);
|
||||
@@ -85,6 +86,7 @@ bool CefMenuRunnerMac::RunContextMenu(
|
||||
}
|
||||
|
||||
void CefMenuRunnerMac::CancelContextMenu() {
|
||||
if (menu_controller_.get())
|
||||
if (menu_controller_.get()) {
|
||||
[menu_controller_ cancel];
|
||||
}
|
||||
}
|
||||
|
@@ -41,8 +41,9 @@ bool CefMenuRunnerViewsAura::RunContextMenu(
|
||||
}
|
||||
|
||||
void CefMenuRunnerViewsAura::CancelContextMenu() {
|
||||
if (menu_)
|
||||
if (menu_) {
|
||||
menu_->Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
bool CefMenuRunnerViewsAura::FormatLabel(std::u16string& label) {
|
||||
|
@@ -74,12 +74,14 @@ void CefWindowDelegateView::InitContent() {
|
||||
|
||||
void CefWindowDelegateView::ViewHierarchyChanged(
|
||||
const views::ViewHierarchyChangedDetails& details) {
|
||||
if (details.is_add && details.child == this)
|
||||
if (details.is_add && details.child == this) {
|
||||
InitContent();
|
||||
}
|
||||
}
|
||||
|
||||
void CefWindowDelegateView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
|
||||
views::WidgetDelegateView::OnBoundsChanged(previous_bounds);
|
||||
if (!on_bounds_changed_.is_null())
|
||||
if (!on_bounds_changed_.is_null()) {
|
||||
on_bounds_changed_.Run();
|
||||
}
|
||||
}
|
||||
|
@@ -46,16 +46,18 @@ bool PropertyExists(x11::Window window, x11::Atom property) {
|
||||
// Deleted from ui/base/x/x11_util.h in https://crrev.com/62fc260067.
|
||||
bool IsWindowVisible(x11::Window window) {
|
||||
auto response = x11::Connection::Get()->GetWindowAttributes({window}).Sync();
|
||||
if (!response || response->map_state != x11::MapState::Viewable)
|
||||
if (!response || response->map_state != x11::MapState::Viewable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Minimized windows are not visible.
|
||||
std::vector<x11::Atom> wm_states;
|
||||
if (x11::GetArrayProperty(window, x11::GetAtom("_NET_WM_STATE"),
|
||||
&wm_states)) {
|
||||
x11::Atom hidden_atom = x11::GetAtom("_NET_WM_STATE_HIDDEN");
|
||||
if (base::Contains(wm_states, hidden_atom))
|
||||
if (base::Contains(wm_states, hidden_atom)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Do not check _NET_CURRENT_DESKTOP/_NET_WM_DESKTOP since some
|
||||
@@ -79,8 +81,9 @@ x11::Window FindToplevelParent(x11::Window window) {
|
||||
|
||||
do {
|
||||
auto query_tree = x11::Connection::Get()->QueryTree({window}).Sync();
|
||||
if (!query_tree)
|
||||
if (!query_tree) {
|
||||
break;
|
||||
}
|
||||
|
||||
top_level_window = window;
|
||||
if (!PropertyExists(query_tree->parent, x11::GetAtom(kNetWMPid)) ||
|
||||
@@ -97,8 +100,9 @@ x11::Window FindToplevelParent(x11::Window window) {
|
||||
} // namespace
|
||||
|
||||
CEF_EXPORT XDisplay* cef_get_xdisplay() {
|
||||
if (!CEF_CURRENTLY_ON(CEF_UIT))
|
||||
if (!CEF_CURRENTLY_ON(CEF_UIT)) {
|
||||
return nullptr;
|
||||
}
|
||||
return x11::Connection::Get()->GetXlibDisplay();
|
||||
}
|
||||
|
||||
@@ -111,8 +115,9 @@ CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostBase> browser,
|
||||
parent_xwindow_(parent_xwindow),
|
||||
bounds_(bounds),
|
||||
weak_ptr_factory_(this) {
|
||||
if (parent_xwindow_ == x11::Window::None)
|
||||
if (parent_xwindow_ == x11::Window::None) {
|
||||
parent_xwindow_ = ui::GetX11RootWindow();
|
||||
}
|
||||
|
||||
x11::VisualId visual;
|
||||
uint8_t depth;
|
||||
@@ -184,8 +189,9 @@ CefWindowX11::~CefWindowX11() {
|
||||
}
|
||||
|
||||
void CefWindowX11::Close() {
|
||||
if (xwindow_ == x11::Window::None)
|
||||
if (xwindow_ == x11::Window::None) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui::SendClientMessage(
|
||||
xwindow_, xwindow_, x11::GetAtom(kWMProtocols),
|
||||
@@ -194,13 +200,15 @@ void CefWindowX11::Close() {
|
||||
x11::EventMask::NoEvent);
|
||||
|
||||
auto host = GetHost();
|
||||
if (host)
|
||||
if (host) {
|
||||
host->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void CefWindowX11::Show() {
|
||||
if (xwindow_ == x11::Window::None)
|
||||
if (xwindow_ == x11::Window::None) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!window_mapped_) {
|
||||
// Before we map the window, set size hints. Otherwise, some window managers
|
||||
@@ -245,8 +253,9 @@ void CefWindowX11::Show() {
|
||||
}
|
||||
|
||||
void CefWindowX11::Hide() {
|
||||
if (xwindow_ == x11::Window::None)
|
||||
if (xwindow_ == x11::Window::None) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window_mapped_) {
|
||||
ui::WithdrawWindow(xwindow_);
|
||||
@@ -255,8 +264,9 @@ void CefWindowX11::Hide() {
|
||||
}
|
||||
|
||||
void CefWindowX11::Focus() {
|
||||
if (xwindow_ == x11::Window::None || !window_mapped_)
|
||||
if (xwindow_ == x11::Window::None || !window_mapped_) {
|
||||
return;
|
||||
}
|
||||
|
||||
x11::Window focus_target = xwindow_;
|
||||
|
||||
@@ -277,8 +287,9 @@ void CefWindowX11::Focus() {
|
||||
}
|
||||
|
||||
void CefWindowX11::SetBounds(const gfx::Rect& bounds) {
|
||||
if (xwindow_ == x11::Window::None)
|
||||
if (xwindow_ == x11::Window::None) {
|
||||
return;
|
||||
}
|
||||
|
||||
x11::ConfigureWindowRequest req{.window = xwindow_};
|
||||
|
||||
@@ -338,30 +349,35 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
|
||||
}
|
||||
|
||||
void CefWindowX11::OnEvent(const x11::Event& event) {
|
||||
if (event.window() != xwindow_)
|
||||
if (event.window() != xwindow_) {
|
||||
return;
|
||||
}
|
||||
ProcessXEvent(event);
|
||||
}
|
||||
|
||||
void CefWindowX11::ContinueFocus() {
|
||||
if (!focus_pending_)
|
||||
if (!focus_pending_) {
|
||||
return;
|
||||
if (browser_.get())
|
||||
}
|
||||
if (browser_.get()) {
|
||||
browser_->SetFocus(true);
|
||||
}
|
||||
focus_pending_ = false;
|
||||
}
|
||||
|
||||
bool CefWindowX11::TopLevelAlwaysOnTop() const {
|
||||
auto toplevel_window = FindToplevelParent(xwindow_);
|
||||
if (toplevel_window == x11::Window::None)
|
||||
if (toplevel_window == x11::Window::None) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<x11::Atom> wm_states;
|
||||
if (x11::GetArrayProperty(toplevel_window, x11::GetAtom(kNetWMState),
|
||||
&wm_states)) {
|
||||
x11::Atom keep_above_atom = x11::GetAtom(kNetWMStateKeepAbove);
|
||||
if (base::Contains(wm_states, keep_above_atom))
|
||||
if (base::Contains(wm_states, keep_above_atom)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -434,8 +450,9 @@ void CefWindowX11::ProcessXEvent(const x11::Event& event) {
|
||||
// Cancel the pending focus change if some other window has gained focus
|
||||
// while waiting for the async task to run. Otherwise we can get stuck in
|
||||
// a focus change loop.
|
||||
if (focus_pending_)
|
||||
if (focus_pending_) {
|
||||
focus_pending_ = false;
|
||||
}
|
||||
}
|
||||
} else if (auto* property = event.As<x11::PropertyNotifyEvent>()) {
|
||||
const auto& wm_state_atom = x11::GetAtom(kNetWMState);
|
||||
|
Reference in New Issue
Block a user