Update source files for bracket style

This commit is contained in:
Marshall Greenblatt
2023-01-02 17:59:03 -05:00
parent d84b07a5cb
commit 3af3eab3e4
366 changed files with 7275 additions and 3834 deletions

View File

@@ -21,8 +21,9 @@ CefRefPtr<CefBasicLabelButtonImpl> CefBasicLabelButtonImpl::Create(
CefRefPtr<CefBasicLabelButtonImpl> label_button =
new CefBasicLabelButtonImpl(delegate);
label_button->Initialize();
if (!text.empty())
if (!text.empty()) {
label_button->SetText(text);
}
return label_button;
}

View File

@@ -20,17 +20,20 @@ CefRefPtr<CefBoxLayoutImpl> CefBoxLayoutImpl::Create(
void CefBoxLayoutImpl::SetFlexForView(CefRefPtr<CefView> view, int flex) {
CEF_REQUIRE_VALID_RETURN_VOID();
DCHECK_GE(flex, 0);
if (flex < 0)
if (flex < 0) {
return;
}
DCHECK(view && view->IsValid() && view->IsAttached());
if (!view || !view->IsValid() || !view->IsAttached())
if (!view || !view->IsValid() || !view->IsAttached()) {
return;
}
views::View* view_ptr = view_util::GetFor(view);
DCHECK_EQ(view_ptr->parent(), owner_view());
if (view_ptr->parent() != owner_view())
if (view_ptr->parent() != owner_view()) {
return;
}
layout()->SetFlexForView(view_ptr, flex);
}
@@ -38,13 +41,15 @@ void CefBoxLayoutImpl::SetFlexForView(CefRefPtr<CefView> view, int flex) {
void CefBoxLayoutImpl::ClearFlexForView(CefRefPtr<CefView> view) {
CEF_REQUIRE_VALID_RETURN_VOID();
DCHECK(view && view->IsValid() && view->IsAttached());
if (!view || !view->IsValid() || !view->IsAttached())
if (!view || !view->IsValid() || !view->IsAttached()) {
return;
}
views::View* view_ptr = view_util::GetFor(view);
DCHECK_EQ(view_ptr->parent(), owner_view());
if (view_ptr->parent() != owner_view())
if (view_ptr->parent() != owner_view()) {
return;
}
layout()->ClearFlexForView(view_ptr);
}
@@ -70,7 +75,8 @@ views::BoxLayout* CefBoxLayoutImpl::CreateLayout() {
settings_.inside_border_insets.bottom,
settings_.inside_border_insets.right));
layout->set_minimum_cross_axis_size(settings_.minimum_cross_axis_size);
if (settings_.default_flex > 0)
if (settings_.default_flex > 0) {
layout->SetDefaultFlex(settings_.default_flex);
}
return layout;
}

View File

@@ -38,8 +38,9 @@ class PopupWindowDelegate : public CefWindowDelegate {
bool CanClose(CefRefPtr<CefWindow> window) override {
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
if (browser)
if (browser) {
return browser->GetHost()->TryCloseBrowser();
}
return true;
}
@@ -55,8 +56,9 @@ CefBrowserPlatformDelegateViews::CefBrowserPlatformDelegateViews(
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate,
CefRefPtr<CefBrowserViewImpl> browser_view)
: native_delegate_(std::move(native_delegate)) {
if (browser_view)
if (browser_view) {
SetBrowserView(browser_view);
}
native_delegate_->set_windowless_handler(this);
}
@@ -92,15 +94,17 @@ void CefBrowserPlatformDelegateViews::BrowserCreated(
void CefBrowserPlatformDelegateViews::NotifyBrowserCreated() {
DCHECK(browser_view_);
DCHECK(browser_);
if (browser_view_->delegate())
if (browser_view_->delegate()) {
browser_view_->delegate()->OnBrowserCreated(browser_view_, browser_);
}
}
void CefBrowserPlatformDelegateViews::NotifyBrowserDestroyed() {
DCHECK(browser_view_);
DCHECK(browser_);
if (browser_view_->delegate())
if (browser_view_->delegate()) {
browser_view_->delegate()->OnBrowserDestroyed(browser_view_, browser_);
}
}
void CefBrowserPlatformDelegateViews::BrowserDestroyed(
@@ -119,8 +123,9 @@ bool CefBrowserPlatformDelegateViews::CreateHostWindow() {
void CefBrowserPlatformDelegateViews::CloseHostWindow() {
views::Widget* widget = GetWindowWidget();
if (widget && !widget->IsClosed())
if (widget && !widget->IsClosed()) {
widget->Close();
}
}
CefWindowHandle CefBrowserPlatformDelegateViews::GetHostWindowHandle() const {
@@ -128,8 +133,9 @@ CefWindowHandle CefBrowserPlatformDelegateViews::GetHostWindowHandle() const {
}
views::Widget* CefBrowserPlatformDelegateViews::GetWindowWidget() const {
if (browser_view_->root_view())
if (browser_view_->root_view()) {
return browser_view_->root_view()->GetWidget();
}
return nullptr;
}
@@ -224,8 +230,9 @@ void CefBrowserPlatformDelegateViews::SetFocus(bool setFocus) {
if (setFocus && browser_view_->root_view()) {
if (auto widget = GetWindowWidget()) {
// Don't activate a minimized Widget, or it will be shown.
if (widget->IsMinimized())
if (widget->IsMinimized()) {
return;
}
}
browser_view_->root_view()->RequestFocus();
}
@@ -234,8 +241,9 @@ void CefBrowserPlatformDelegateViews::SetFocus(bool setFocus) {
gfx::Point CefBrowserPlatformDelegateViews::GetScreenPoint(
const gfx::Point& view_pt,
bool want_dip_coords) const {
if (!browser_view_->root_view())
if (!browser_view_->root_view()) {
return view_pt;
}
gfx::Point screen_point = view_pt;
view_util::ConvertPointToScreen(browser_view_->root_view(), &screen_point,

View File

@@ -34,8 +34,9 @@ CefRefPtr<CefBrowserView> CefBrowserView::GetForBrowser(
CefBrowserHostBase* browser_impl =
static_cast<CefBrowserHostBase*>(browser.get());
if (browser_impl && browser_impl->is_views_hosted())
if (browser_impl && browser_impl->is_views_hosted()) {
return browser_impl->GetBrowserView();
}
return nullptr;
}
@@ -84,8 +85,9 @@ CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::CreateForPopup(
void CefBrowserViewImpl::WebContentsCreated(
content::WebContents* web_contents) {
if (web_view())
if (web_view()) {
web_view()->SetWebContents(web_contents);
}
}
void CefBrowserViewImpl::BrowserCreated(
@@ -99,21 +101,25 @@ void CefBrowserViewImpl::BrowserDestroyed(CefBrowserHostBase* browser) {
DCHECK_EQ(browser, browser_);
browser_ = nullptr;
if (web_view())
if (web_view()) {
web_view()->SetWebContents(nullptr);
}
}
bool CefBrowserViewImpl::HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
if (!root_view())
if (!root_view()) {
return false;
}
views::FocusManager* focus_manager = root_view()->GetFocusManager();
if (!focus_manager)
if (!focus_manager) {
return false;
}
if (HandleAccelerator(event, focus_manager))
if (HandleAccelerator(event, focus_manager)) {
return true;
}
// Give the CefWindowDelegate a chance to handle the event.
CefRefPtr<CefWindow> window =
@@ -148,8 +154,9 @@ CefRefPtr<CefView> CefBrowserViewImpl::GetChromeToolbar() {
void CefBrowserViewImpl::SetPreferAccelerators(bool prefer_accelerators) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (web_view())
if (web_view()) {
web_view()->set_allow_accelerators(prefer_accelerators);
}
}
void CefBrowserViewImpl::RequestFocus() {
@@ -163,8 +170,9 @@ void CefBrowserViewImpl::RequestFocus() {
void CefBrowserViewImpl::SetBackgroundColor(cef_color_t color) {
CEF_REQUIRE_VALID_RETURN_VOID();
ParentClass::SetBackgroundColor(color);
if (web_view())
if (web_view()) {
web_view()->SetResizeBackgroundColor(color);
}
}
void CefBrowserViewImpl::Detach() {
@@ -186,8 +194,9 @@ void CefBrowserViewImpl::Detach() {
void CefBrowserViewImpl::GetDebugInfo(base::DictionaryValue* info,
bool include_children) {
ParentClass::GetDebugInfo(info, include_children);
if (browser_)
if (browser_) {
info->SetString("url", browser_->GetMainFrame()->GetURL().ToString());
}
}
void CefBrowserViewImpl::OnBrowserViewAdded() {
@@ -204,8 +213,9 @@ void CefBrowserViewImpl::OnBrowserViewAdded() {
}
void CefBrowserViewImpl::OnBoundsChanged() {
if (!on_bounds_changed_.is_null())
if (!on_bounds_changed_.is_null()) {
on_bounds_changed_.Run();
}
}
CefBrowserViewImpl::CefBrowserViewImpl(
@@ -251,8 +261,9 @@ void CefBrowserViewImpl::InitializeRootView() {
}
views::WebView* CefBrowserViewImpl::web_view() const {
if (!root_view())
if (!root_view()) {
return nullptr;
}
if (cef::IsChromeRuntimeEnabled()) {
return static_cast<ChromeBrowserView*>(root_view())->contents_web_view();
@@ -287,8 +298,9 @@ bool CefBrowserViewImpl::HandleAccelerator(
// set the flag and fix it if no event was handled.
ignore_next_char_event_ = true;
if (focus_manager->ProcessAccelerator(accelerator))
if (focus_manager->ProcessAccelerator(accelerator)) {
return true;
}
// ProcessAccelerator didn't handle the accelerator, so we know both
// that |this| is still valid, and that we didn't want to set the flag.

View File

@@ -25,8 +25,9 @@ void CefBrowserViewView::ViewHierarchyChanged(
// this View to a CefWindow with FillLayout and then calling
// CefWindow::Show() without first resizing the CefWindow.
size = details.parent->GetPreferredSize();
if (!size.IsEmpty())
if (!size.IsEmpty()) {
SetSize(size);
}
}
browser_view_delegate_->OnBrowserViewAdded();

View File

@@ -51,15 +51,17 @@ CEF_BUTTON_VIEW_T class CefButtonView : public CEF_VIEW_VIEW_D {
CEF_BUTTON_VIEW_T void CEF_BUTTON_VIEW_D::StateChanged(
views::Button::ButtonState old_state) {
ParentClass::StateChanged(old_state);
if (ParentClass::cef_delegate())
if (ParentClass::cef_delegate()) {
ParentClass::cef_delegate()->OnButtonStateChanged(GetCefButton());
}
}
CEF_BUTTON_VIEW_T void CEF_BUTTON_VIEW_D::ButtonPressed(
const ui::Event& event) {
// Callback may trigger new animation state.
if (ParentClass::cef_delegate())
if (ParentClass::cef_delegate()) {
ParentClass::cef_delegate()->OnButtonPressed(GetCefButton());
}
if (views::InkDrop::Get(this)->ink_drop_mode() !=
views::InkDropHost::InkDropMode::OFF &&
!ParentClass::IsFocusable() &&

View File

@@ -47,8 +47,9 @@ void CefDisplay::GetAllDisplays(std::vector<CefRefPtr<CefDisplay>>& displays) {
using DisplayVector = std::vector<display::Display>;
DisplayVector vec = display::Screen::GetScreen()->GetAllDisplays();
for (size_t i = 0; i < vec.size(); ++i)
for (size_t i = 0; i < vec.size(); ++i) {
displays.push_back(new CefDisplayImpl(vec[i]));
}
}
// static

View File

@@ -78,8 +78,9 @@ CEF_LABEL_BUTTON_IMPL_T void CEF_LABEL_BUTTON_IMPL_D::SetImage(
CefRefPtr<CefImage> image) {
CEF_REQUIRE_VALID_RETURN_VOID();
gfx::ImageSkia image_skia;
if (image)
if (image) {
image_skia = static_cast<CefImageImpl*>(image.get())->AsImageSkia();
}
ParentClass::root_view()->SetImage(
static_cast<views::Button::ButtonState>(button_state), image_skia);
}
@@ -89,8 +90,9 @@ CEF_LABEL_BUTTON_IMPL_T CefRefPtr<CefImage> CEF_LABEL_BUTTON_IMPL_D::GetImage(
CEF_REQUIRE_VALID_RETURN(nullptr);
const gfx::ImageSkia& image_skia = ParentClass::root_view()->GetImage(
static_cast<views::Button::ButtonState>(button_state));
if (image_skia.isNull())
if (image_skia.isNull()) {
return nullptr;
}
return new CefImageImpl(image_skia);
}

View File

@@ -19,8 +19,9 @@ class UserData : public base::SupportsUserData::Data {
public:
static CefRefPtr<CefLayout> GetFor(const views::View* view) {
UserData* data = static_cast<UserData*>(view->GetUserData(UserDataKey()));
if (data)
if (data) {
return data->layout_;
}
return nullptr;
}

View File

@@ -22,12 +22,14 @@ CefRefPtr<CefMenuButtonImpl> CefMenuButtonImpl::Create(
const CefString& text) {
CEF_REQUIRE_UIT_RETURN(nullptr);
DCHECK(delegate);
if (!delegate)
if (!delegate) {
return nullptr;
}
CefRefPtr<CefMenuButtonImpl> menu_button = new CefMenuButtonImpl(delegate);
menu_button->Initialize();
if (!text.empty())
if (!text.empty()) {
menu_button->SetText(text);
}
return menu_button;
}

View File

@@ -15,8 +15,9 @@ bool CefMenuRunnerViews::RunContextMenu(
CefMenuModelImpl* model,
const content::ContextMenuParams& params) {
CefRefPtr<CefWindow> window = browser_view_->GetWindow();
if (!window)
if (!window) {
return false;
}
CefPoint screen_point(params.x, params.y);
browser_view_->ConvertPointToScreen(screen_point);
@@ -27,8 +28,9 @@ bool CefMenuRunnerViews::RunContextMenu(
void CefMenuRunnerViews::CancelContextMenu() {
CefRefPtr<CefWindow> window = browser_view_->GetWindow();
if (window)
if (window) {
window->CancelMenu();
}
}
bool CefMenuRunnerViews::FormatLabel(std::u16string& label) {

View File

@@ -263,16 +263,18 @@ void CefOverlayViewHost::MoveIfNecessary() {
void CefOverlayViewHost::SetOverlayBounds(const gfx::Rect& bounds) {
// Avoid re-entrancy of this method.
if (bounds_changing_)
if (bounds_changing_) {
return;
}
gfx::Rect new_bounds = bounds;
// Keep the result inside the widget.
new_bounds.Intersect(window_view_->bounds());
if (new_bounds == bounds_)
if (new_bounds == bounds_) {
return;
}
bounds_changing_ = true;
@@ -286,8 +288,9 @@ void CefOverlayViewHost::SetOverlayBounds(const gfx::Rect& bounds) {
}
void CefOverlayViewHost::SetOverlayInsets(const CefInsets& insets) {
if (insets == insets_)
if (insets == insets_) {
return;
}
insets_ = insets;
MoveIfNecessary();
}

View File

@@ -112,8 +112,9 @@ CEF_PANEL_IMPL_T void CEF_PANEL_IMPL_D::AddChildView(CefRefPtr<CefView> view) {
CEF_REQUIRE_VALID_RETURN_VOID();
DCHECK(view.get());
DCHECK(view->IsValid());
if (!view.get() || !view->IsValid())
if (!view.get() || !view->IsValid()) {
return;
}
auto* view_ptr = view->IsAttached()
? view_util::GetFor(view)
@@ -150,14 +151,16 @@ CEF_PANEL_IMPL_T void CEF_PANEL_IMPL_D::ReorderChildView(
DCHECK(view.get());
DCHECK(view->IsValid());
DCHECK(view->IsAttached());
if (!view.get() || !view->IsValid() || !view->IsAttached())
if (!view.get() || !view->IsValid() || !view->IsAttached()) {
return;
}
views::View* view_ptr = view_util::GetFor(view);
DCHECK(view_ptr);
DCHECK_EQ(view_ptr->parent(), ParentClass::content_view());
if (!view_ptr || view_ptr->parent() != ParentClass::content_view())
if (!view_ptr || view_ptr->parent() != ParentClass::content_view()) {
return;
}
ParentClass::content_view()->ReorderChildView(view_ptr, index);
}
@@ -168,14 +171,16 @@ CEF_PANEL_IMPL_T void CEF_PANEL_IMPL_D::RemoveChildView(
DCHECK(view.get());
DCHECK(view->IsValid());
DCHECK(view->IsAttached());
if (!view.get() || !view->IsValid() || !view->IsAttached())
if (!view.get() || !view->IsValid() || !view->IsAttached()) {
return;
}
views::View* view_ptr = view_util::GetFor(view);
DCHECK(view_ptr);
DCHECK_EQ(view_ptr->parent(), ParentClass::content_view());
if (!view_ptr || view_ptr->parent() != ParentClass::content_view())
if (!view_ptr || view_ptr->parent() != ParentClass::content_view()) {
return;
}
ParentClass::content_view()->RemoveChildView(view_ptr);
view_util::ResumeOwnership(view);
@@ -202,8 +207,9 @@ CEF_PANEL_IMPL_T CefRefPtr<CefView> CEF_PANEL_IMPL_D::GetChildViewAt(
DCHECK_LT(static_cast<unsigned int>(index),
ParentClass::content_view()->children().size());
if (index < 0 || (static_cast<unsigned int>(index) >=
ParentClass::content_view()->children().size()))
ParentClass::content_view()->children().size())) {
return nullptr;
}
CefRefPtr<CefView> view =
view_util::GetFor(ParentClass::content_view()->children()[index], false);

View File

@@ -24,8 +24,9 @@ void CefScrollViewImpl::SetContentView(CefRefPtr<CefView> view) {
DCHECK(view.get());
DCHECK(view->IsValid());
DCHECK(!view->IsAttached());
if (!view.get() || !view->IsValid() || view->IsAttached())
if (!view.get() || !view->IsValid() || view->IsAttached()) {
return;
}
root_view()->SetContents(view_util::PassOwnership(view));
}

View File

@@ -155,10 +155,11 @@ void CefTextfieldImpl::SetFontList(const CefString& font_list) {
void CefTextfieldImpl::ApplyTextColor(cef_color_t color,
const CefRange& range) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (range.from == range.to)
if (range.from == range.to) {
root_view()->SetColor(color);
else
} else {
root_view()->ApplyColor(color, gfx::Range(range.from, range.to));
}
}
void CefTextfieldImpl::ApplyTextStyle(cef_text_style_t style,
@@ -180,9 +181,10 @@ bool CefTextfieldImpl::IsCommandEnabled(cef_text_field_commands_t command_id) {
void CefTextfieldImpl::ExecuteCommand(cef_text_field_commands_t command_id) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view()->IsCommandIdEnabled(CefCommandIdToChromeId(command_id)))
if (root_view()->IsCommandIdEnabled(CefCommandIdToChromeId(command_id))) {
root_view()->ExecuteCommand(CefCommandIdToChromeId(command_id),
ui::EF_NONE);
}
}
void CefTextfieldImpl::ClearEditHistory() {

View File

@@ -22,18 +22,21 @@ bool CefTextfieldView::HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) {
DCHECK_EQ(sender, this);
if (!cef_delegate())
if (!cef_delegate()) {
return false;
}
CefKeyEvent cef_key_event;
if (!browser_util::GetCefKeyEvent(key_event, cef_key_event))
if (!browser_util::GetCefKeyEvent(key_event, cef_key_event)) {
return false;
}
return cef_delegate()->OnKeyEvent(GetCefTextfield(), cef_key_event);
}
void CefTextfieldView::OnAfterUserAction(views::Textfield* sender) {
DCHECK_EQ(sender, this);
if (cef_delegate())
if (cef_delegate()) {
cef_delegate()->OnAfterUserAction(GetCefTextfield());
}
}

View File

@@ -53,7 +53,8 @@ CefViewAdapter* CefViewAdapter::GetFor(CefRefPtr<CefView> view) {
// static
CefViewAdapter* CefViewAdapter::GetFor(views::View* view) {
CefRefPtr<CefView> cef_view = view_util::GetFor(view, false);
if (cef_view)
if (cef_view) {
return GetFor(cef_view);
}
return nullptr;
}

View File

@@ -338,8 +338,9 @@ CEF_VIEW_IMPL_T class CefViewImpl : public CefViewAdapter, public CefViewClass {
root_view_.reset(root_view_ref_);
}
void Detach() override {
if (root_view_)
if (root_view_) {
root_view_.reset();
}
root_view_ref_ = nullptr;
}
void GetDebugInfo(base::DictionaryValue* info,
@@ -454,10 +455,11 @@ CEF_VIEW_IMPL_T CefString CEF_VIEW_IMPL_D::GetTypeString() {
CEF_VIEW_IMPL_T CefString CEF_VIEW_IMPL_D::ToString(bool include_children) {
CEF_REQUIRE_UIT_RETURN(CefString());
std::unique_ptr<base::DictionaryValue> info(new base::DictionaryValue());
if (IsValid())
if (IsValid()) {
GetDebugInfo(info.get(), include_children);
else
} else {
info->SetString("type", GetDebugType());
}
std::string json_string;
base::JSONWriter::WriteWithOptions(*info, 0, &json_string);
@@ -477,8 +479,9 @@ CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::IsAttached() {
CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::IsSame(CefRefPtr<CefView> that) {
CEF_REQUIRE_UIT_RETURN(false);
CefViewImpl* that_impl = static_cast<CefViewImpl*>(that.get());
if (!that_impl)
if (!that_impl) {
return false;
}
return this == that_impl;
}
@@ -489,8 +492,9 @@ CEF_VIEW_IMPL_T CefRefPtr<CefViewDelegate> CEF_VIEW_IMPL_D::GetDelegate() {
CEF_VIEW_IMPL_T CefRefPtr<CefWindow> CEF_VIEW_IMPL_D::GetWindow() {
CEF_REQUIRE_UIT_RETURN(nullptr);
if (root_view())
if (root_view()) {
return view_util::GetWindowFor(root_view()->GetWidget());
}
return nullptr;
}
@@ -511,24 +515,27 @@ CEF_VIEW_IMPL_T int CEF_VIEW_IMPL_D::GetGroupID() {
CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::SetGroupID(int group_id) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view()->GetGroup() != -1)
if (root_view()->GetGroup() != -1) {
return;
}
root_view()->SetGroup(group_id);
}
CEF_VIEW_IMPL_T CefRefPtr<CefView> CEF_VIEW_IMPL_D::GetParentView() {
CEF_REQUIRE_VALID_RETURN(nullptr);
views::View* view = root_view()->parent();
if (!view)
if (!view) {
return nullptr;
}
return view_util::GetFor(view, true);
}
CEF_VIEW_IMPL_T CefRefPtr<CefView> CEF_VIEW_IMPL_D::GetViewForID(int id) {
CEF_REQUIRE_VALID_RETURN(nullptr);
views::View* view = root_view()->GetViewByID(id);
if (!view)
if (!view) {
return nullptr;
}
return view_util::GetFor(view, true);
}
@@ -681,8 +688,9 @@ CEF_VIEW_IMPL_T cef_color_t CEF_VIEW_IMPL_D::GetBackgroundColor() {
CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointToScreen(CefPoint& point) {
CEF_REQUIRE_VALID_RETURN(false);
gfx::Point gfx_point = gfx::Point(point.x, point.y);
if (!view_util::ConvertPointToScreen(root_view(), &gfx_point, false))
if (!view_util::ConvertPointToScreen(root_view(), &gfx_point, false)) {
return false;
}
point = CefPoint(gfx_point.x(), gfx_point.y());
return true;
}
@@ -690,8 +698,9 @@ CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointToScreen(CefPoint& point) {
CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointFromScreen(CefPoint& point) {
CEF_REQUIRE_VALID_RETURN(false);
gfx::Point gfx_point = gfx::Point(point.x, point.y);
if (!view_util::ConvertPointFromScreen(root_view(), &gfx_point, false))
if (!view_util::ConvertPointFromScreen(root_view(), &gfx_point, false)) {
return false;
}
point = CefPoint(gfx_point.x(), gfx_point.y());
return true;
}
@@ -699,8 +708,9 @@ CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointFromScreen(CefPoint& point) {
CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointToWindow(CefPoint& point) {
CEF_REQUIRE_VALID_RETURN(false);
gfx::Point gfx_point = gfx::Point(point.x, point.y);
if (!view_util::ConvertPointToWindow(root_view(), &gfx_point))
if (!view_util::ConvertPointToWindow(root_view(), &gfx_point)) {
return false;
}
point = CefPoint(gfx_point.x(), gfx_point.y());
return true;
}
@@ -708,8 +718,9 @@ CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointToWindow(CefPoint& point) {
CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointFromWindow(CefPoint& point) {
CEF_REQUIRE_VALID_RETURN(false);
gfx::Point gfx_point = gfx::Point(point.x, point.y);
if (!view_util::ConvertPointFromWindow(root_view(), &gfx_point))
if (!view_util::ConvertPointFromWindow(root_view(), &gfx_point)) {
return false;
}
point = CefPoint(gfx_point.x(), gfx_point.y());
return true;
}
@@ -718,11 +729,13 @@ CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointToView(
CefRefPtr<CefView> view,
CefPoint& point) {
CEF_REQUIRE_VALID_RETURN(false);
if (!root_view()->GetWidget())
if (!root_view()->GetWidget()) {
return false;
}
views::View* target_view = view_util::GetFor(view);
if (!target_view || target_view->GetWidget() != root_view()->GetWidget())
if (!target_view || target_view->GetWidget() != root_view()->GetWidget()) {
return false;
}
gfx::Point gfx_point = gfx::Point(point.x, point.y);
views::View::ConvertPointToTarget(root_view(), target_view, &gfx_point);
point = CefPoint(gfx_point.x(), gfx_point.y());
@@ -733,11 +746,13 @@ CEF_VIEW_IMPL_T bool CEF_VIEW_IMPL_D::ConvertPointFromView(
CefRefPtr<CefView> view,
CefPoint& point) {
CEF_REQUIRE_VALID_RETURN(false);
if (!root_view()->GetWidget())
if (!root_view()->GetWidget()) {
return false;
}
views::View* target_view = view_util::GetFor(view);
if (!target_view || target_view->GetWidget() != root_view()->GetWidget())
if (!target_view || target_view->GetWidget() != root_view()->GetWidget()) {
return false;
}
gfx::Point gfx_point = gfx::Point(point.x, point.y);
views::View::ConvertPointToTarget(target_view, root_view(), &gfx_point);
point = CefPoint(gfx_point.x(), gfx_point.y());

View File

@@ -50,8 +50,9 @@ class UserData : public base::SupportsUserData::Data {
static CefRefPtr<CefView> GetFor(const views::View* view) {
DCHECK(view);
UserData* data = static_cast<UserData*>(view->GetUserData(UserDataKey()));
if (data)
if (data) {
return data->view_ref_;
}
return nullptr;
}
@@ -132,18 +133,21 @@ void Register(CefRefPtr<CefView> view) {
}
CefRefPtr<CefView> GetFor(const views::View* view, bool find_known_parent) {
if (!view)
if (!view) {
return nullptr;
}
if (!find_known_parent)
if (!find_known_parent) {
return UserData::GetFor(view);
}
CefRefPtr<CefView> cef_view;
const views::View* current_view = view;
do {
cef_view = UserData::GetFor(current_view);
if (cef_view)
if (cef_view) {
break;
}
current_view = current_view->parent();
} while (current_view);
@@ -183,8 +187,9 @@ CefRefPtr<CefWindow> GetWindowFor(views::Widget* widget) {
// was created by something else let's go about this the safer way.
views::View* content_view = widget->widget_delegate()->GetContentsView();
CefRefPtr<CefView> cef_view = GetFor(content_view, false);
if (cef_view && cef_view->AsPanel())
if (cef_view && cef_view->AsPanel()) {
window = cef_view->AsPanel()->AsWindow();
}
// The Window should always exist if we created the views::Widget.
DCHECK(window);
@@ -249,8 +254,9 @@ gfx::Rect ConvertRectToPixels(const gfx::Rect& rect) {
bool ConvertPointToScreen(views::View* view,
gfx::Point* point,
bool output_pixel_coords) {
if (!view->GetWidget())
if (!view->GetWidget()) {
return false;
}
views::View::ConvertPointToScreen(view, point);
@@ -265,8 +271,9 @@ bool ConvertPointToScreen(views::View* view,
bool ConvertPointFromScreen(views::View* view,
gfx::Point* point,
bool input_pixel_coords) {
if (!view->GetWidget())
if (!view->GetWidget()) {
return false;
}
if (input_pixel_coords) {
const display::Display& display = GetDisplayNearestPoint(*point, true);
@@ -280,8 +287,9 @@ bool ConvertPointFromScreen(views::View* view,
bool ConvertPointToWindow(views::View* view, gfx::Point* point) {
views::Widget* widget = view->GetWidget();
if (!widget)
if (!widget) {
return false;
}
views::View::ConvertPointToWidget(view, point);
@@ -303,8 +311,9 @@ bool ConvertPointToWindow(views::View* view, gfx::Point* point) {
bool ConvertPointFromWindow(views::View* view, gfx::Point* point) {
views::Widget* widget = view->GetWidget();
if (!widget)
if (!widget) {
return false;
}
if (widget->non_client_view()) {
views::NonClientFrameView* non_client_frame_view =

View File

@@ -13,8 +13,9 @@ namespace view_util {
gfx::NativeWindow GetNativeWindow(views::Widget* widget) {
if (widget) {
aura::Window* window = widget->GetNativeWindow();
if (window)
if (window) {
return window->GetRootWindow();
}
}
return nullptr;
}

View File

@@ -13,22 +13,25 @@
namespace view_util {
gfx::NativeWindow GetNativeWindow(views::Widget* widget) {
if (widget)
if (widget) {
return widget->GetNativeWindow();
}
return gfx::NativeWindow();
}
gfx::NativeView GetNativeView(views::Widget* widget) {
if (widget)
if (widget) {
return widget->GetNativeView();
}
return gfx::NativeView();
}
CefWindowHandle GetWindowHandle(views::Widget* widget) {
// |view| is a wrapper type from native_widget_types.h.
auto view = GetNativeView(widget);
if (view)
if (view) {
return CAST_NSVIEW_TO_CEF_WINDOW_HANDLE(view.GetNativeNSView());
}
return kNullWindowHandle;
}

View File

@@ -99,11 +99,13 @@ CEF_VIEW_VIEW_T gfx::Size CEF_VIEW_VIEW_D::CalculatePreferredSize() const {
gfx::Size result;
if (cef_delegate()) {
CefSize cef_size = cef_delegate()->GetPreferredSize(GetCefView());
if (!cef_size.IsEmpty())
if (!cef_size.IsEmpty()) {
result = gfx::Size(cef_size.width, cef_size.height);
}
}
if (result.IsEmpty())
if (result.IsEmpty()) {
result = ParentClass::CalculatePreferredSize();
}
if (result.IsEmpty()) {
// Some layouts like BoxLayout expect the preferred size to be non-empty.
// The user may have set the size explicitly. Therefore return the current
@@ -117,14 +119,16 @@ CEF_VIEW_VIEW_T gfx::Size CEF_VIEW_VIEW_D::GetMinimumSize() const {
gfx::Size result;
if (cef_delegate()) {
CefSize cef_size = cef_delegate()->GetMinimumSize(GetCefView());
if (!cef_size.IsEmpty())
if (!cef_size.IsEmpty()) {
result = gfx::Size(cef_size.width, cef_size.height);
}
}
// We don't want to call ParentClass::GetMinimumSize() in all cases because
// the default views::View implementation will call GetPreferredSize(). That
// may result in size() being returned which keeps the View from shrinking.
if (result.IsEmpty() && HasMinimumSize())
if (result.IsEmpty() && HasMinimumSize()) {
result = ParentClass::GetMinimumSize();
}
return result;
}
@@ -132,20 +136,24 @@ CEF_VIEW_VIEW_T gfx::Size CEF_VIEW_VIEW_D::GetMaximumSize() const {
gfx::Size result;
if (cef_delegate()) {
CefSize cef_size = cef_delegate()->GetMaximumSize(GetCefView());
if (!cef_size.IsEmpty())
if (!cef_size.IsEmpty()) {
result = gfx::Size(cef_size.width, cef_size.height);
}
}
if (result.IsEmpty())
if (result.IsEmpty()) {
result = ParentClass::GetMaximumSize();
}
return result;
}
CEF_VIEW_VIEW_T int CEF_VIEW_VIEW_D::GetHeightForWidth(int w) const {
int result = 0;
if (cef_delegate())
if (cef_delegate()) {
result = cef_delegate()->GetHeightForWidth(GetCefView(), w);
if (result == 0)
}
if (result == 0) {
result = ParentClass::GetHeightForWidth(w);
}
if (result == 0) {
// Some layouts like FillLayout will ignore the preferred size if this view
// has no children. We want to use the preferred size if not otherwise
@@ -159,8 +167,9 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::Layout() {
ParentClass::Layout();
// If Layout() did not provide a size then use the preferred size.
if (ParentClass::size().IsEmpty())
if (ParentClass::size().IsEmpty()) {
ParentClass::SizeToPreferredSize();
}
if (cef_delegate()) {
const auto new_bounds = ParentClass::bounds();
@@ -179,37 +188,43 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::ViewHierarchyChanged(
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::AddedToWidget() {
ParentClass::AddedToWidget();
if (cef_delegate())
if (cef_delegate()) {
cef_delegate()->OnWindowChanged(GetCefView(), /*added=*/true);
}
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::RemovedFromWidget() {
if (cef_delegate())
if (cef_delegate()) {
cef_delegate()->OnWindowChanged(GetCefView(), /*added=*/false);
}
ParentClass::RemovedFromWidget();
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnFocus() {
if (cef_delegate())
if (cef_delegate()) {
cef_delegate()->OnFocus(GetCefView());
}
ParentClass::OnFocus();
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnBlur() {
if (cef_delegate())
if (cef_delegate()) {
cef_delegate()->OnBlur(GetCefView());
}
ParentClass::OnBlur();
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyChildViewChanged(
const views::ViewHierarchyChangedDetails& details) {
if (!cef_delegate())
if (!cef_delegate()) {
return;
}
// Only interested with the parent is |this| object and the notification is
// about an immediate child (notifications are also sent for grandchildren).
if (details.parent != this || details.child->parent() != this)
if (details.parent != this || details.child->parent() != this) {
return;
}
// Only notify for children that have a known CEF root view. For example,
// don't notify when ScrollView adds child scroll bars.
@@ -221,13 +236,15 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyChildViewChanged(
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyParentViewChanged(
const views::ViewHierarchyChangedDetails& details) {
if (!cef_delegate())
if (!cef_delegate()) {
return;
}
// Only interested when the child is |this| object and notification is about
// the immediate parent (notifications are sent for all parents).
if (details.child != this || details.parent != ParentClass::parent())
if (details.child != this || details.parent != ParentClass::parent()) {
return;
}
// The immediate parent might be an intermediate view so find the closest
// known CEF root view. |parent| might be nullptr for overlays.

View File

@@ -123,33 +123,38 @@ CefRefPtr<CefWindowImpl> CefWindowImpl::Create(
CefRefPtr<CefWindowImpl> window = new CefWindowImpl(delegate);
window->Initialize();
window->CreateWidget(parent_widget);
if (delegate)
if (delegate) {
delegate->OnWindowCreated(window.get());
}
return window;
}
void CefWindowImpl::Show() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_)
if (widget_) {
widget_->Show();
}
}
void CefWindowImpl::Hide() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_)
if (widget_) {
widget_->Hide();
}
}
void CefWindowImpl::CenterWindow(const CefSize& size) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_)
if (widget_) {
widget_->CenterWindow(gfx::Size(size.width, size.height));
}
}
void CefWindowImpl::Close() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_ && !widget_->IsClosed())
if (widget_ && !widget_->IsClosed()) {
widget_->Close();
}
}
bool CefWindowImpl::IsClosed() {
@@ -159,27 +164,31 @@ bool CefWindowImpl::IsClosed() {
void CefWindowImpl::Activate() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_ && widget_->CanActivate() && !widget_->IsActive())
if (widget_ && widget_->CanActivate() && !widget_->IsActive()) {
widget_->Activate();
}
}
void CefWindowImpl::Deactivate() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_ && widget_->CanActivate() && widget_->IsActive())
if (widget_ && widget_->CanActivate() && widget_->IsActive()) {
widget_->Deactivate();
}
}
bool CefWindowImpl::IsActive() {
CEF_REQUIRE_VALID_RETURN(false);
if (widget_)
if (widget_) {
return widget_->IsActive();
}
return false;
}
void CefWindowImpl::BringToTop() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_)
if (widget_) {
widget_->StackAtTop();
}
}
void CefWindowImpl::SetAlwaysOnTop(bool on_top) {
@@ -193,92 +202,106 @@ void CefWindowImpl::SetAlwaysOnTop(bool on_top) {
bool CefWindowImpl::IsAlwaysOnTop() {
CEF_REQUIRE_VALID_RETURN(false);
if (widget_)
if (widget_) {
return widget_->GetZOrderLevel() == ui::ZOrderLevel::kFloatingWindow;
}
return false;
}
void CefWindowImpl::Maximize() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_ && !widget_->IsMaximized())
if (widget_ && !widget_->IsMaximized()) {
widget_->Maximize();
}
}
void CefWindowImpl::Minimize() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_ && !widget_->IsMinimized())
if (widget_ && !widget_->IsMinimized()) {
widget_->Minimize();
}
}
void CefWindowImpl::Restore() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_ && (widget_->IsMaximized() || widget_->IsMinimized()))
if (widget_ && (widget_->IsMaximized() || widget_->IsMinimized())) {
widget_->Restore();
}
}
void CefWindowImpl::SetFullscreen(bool fullscreen) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_ && fullscreen != widget_->IsFullscreen())
if (widget_ && fullscreen != widget_->IsFullscreen()) {
widget_->SetFullscreen(fullscreen);
}
}
bool CefWindowImpl::IsMaximized() {
CEF_REQUIRE_VALID_RETURN(false);
if (widget_)
if (widget_) {
return widget_->IsMaximized();
}
return false;
}
bool CefWindowImpl::IsMinimized() {
CEF_REQUIRE_VALID_RETURN(false);
if (widget_)
if (widget_) {
return widget_->IsMinimized();
}
return false;
}
bool CefWindowImpl::IsFullscreen() {
CEF_REQUIRE_VALID_RETURN(false);
if (widget_)
if (widget_) {
return widget_->IsFullscreen();
}
return false;
}
void CefWindowImpl::SetTitle(const CefString& title) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view())
if (root_view()) {
root_view()->SetTitle(title);
}
}
CefString CefWindowImpl::GetTitle() {
CEF_REQUIRE_VALID_RETURN(CefString());
if (root_view())
if (root_view()) {
return root_view()->title();
}
return CefString();
}
void CefWindowImpl::SetWindowIcon(CefRefPtr<CefImage> image) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view())
if (root_view()) {
root_view()->SetWindowIcon(image);
}
}
CefRefPtr<CefImage> CefWindowImpl::GetWindowIcon() {
CEF_REQUIRE_VALID_RETURN(nullptr);
if (root_view())
if (root_view()) {
return root_view()->window_icon();
}
return nullptr;
}
void CefWindowImpl::SetWindowAppIcon(CefRefPtr<CefImage> image) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view())
if (root_view()) {
root_view()->SetWindowAppIcon(image);
}
}
CefRefPtr<CefImage> CefWindowImpl::GetWindowAppIcon() {
CEF_REQUIRE_VALID_RETURN(nullptr);
if (root_view())
if (root_view()) {
return root_view()->window_app_icon();
}
return nullptr;
}
@@ -286,16 +309,18 @@ CefRefPtr<CefOverlayController> CefWindowImpl::AddOverlayView(
CefRefPtr<CefView> view,
cef_docking_mode_t docking_mode) {
CEF_REQUIRE_VALID_RETURN(nullptr);
if (root_view())
if (root_view()) {
return root_view()->AddOverlayView(view, docking_mode);
}
return nullptr;
}
void CefWindowImpl::GetDebugInfo(base::DictionaryValue* info,
bool include_children) {
ParentClass::GetDebugInfo(info, include_children);
if (root_view())
if (root_view()) {
info->SetString("title", root_view()->title());
}
}
void CefWindowImpl::ShowMenu(CefRefPtr<CefMenuModel> menu_model,
@@ -322,8 +347,9 @@ void CefWindowImpl::SetBounds(const CefRect& bounds) {
CefRect CefWindowImpl::GetBounds() {
CEF_REQUIRE_VALID_RETURN(CefRect());
gfx::Rect bounds;
if (widget_)
if (widget_) {
bounds = widget_->GetWindowBoundsInScreen();
}
return CefRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
}
@@ -333,8 +359,9 @@ CefRect CefWindowImpl::GetBoundsInScreen() {
void CefWindowImpl::SetSize(const CefSize& size) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_)
if (widget_) {
widget_->SetSize(gfx::Size(size.width, size.height));
}
}
void CefWindowImpl::SetPosition(const CefPoint& position) {
@@ -349,24 +376,27 @@ void CefWindowImpl::SetPosition(const CefPoint& position) {
void CefWindowImpl::SizeToPreferredSize() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (widget_) {
if (widget_->non_client_view())
if (widget_->non_client_view()) {
widget_->SetSize(widget_->non_client_view()->GetPreferredSize());
else
} else {
widget_->SetSize(root_view()->GetPreferredSize());
}
}
}
void CefWindowImpl::SetVisible(bool visible) {
if (visible)
if (visible) {
Show();
else
} else {
Hide();
}
}
bool CefWindowImpl::IsVisible() {
CEF_REQUIRE_VALID_RETURN(false);
if (widget_)
if (widget_) {
return widget_->IsVisible();
}
return false;
}
@@ -377,13 +407,15 @@ bool CefWindowImpl::IsDrawn() {
void CefWindowImpl::SetBackgroundColor(cef_color_t color) {
CEF_REQUIRE_VALID_RETURN_VOID();
ParentClass::SetBackgroundColor(color);
if (widget_ && widget_->GetCompositor())
if (widget_ && widget_->GetCompositor()) {
widget_->GetCompositor()->SetBackgroundColor(color);
}
}
bool CefWindowImpl::CanWidgetClose() {
if (delegate())
if (delegate()) {
return delegate()->CanClose(this);
}
return true;
}
@@ -392,8 +424,9 @@ void CefWindowImpl::OnWindowClosing() {
unhandled_key_event_handler_.reset();
#endif
if (delegate())
if (delegate()) {
delegate()->OnWindowClosing(this);
}
}
void CefWindowImpl::OnWindowViewDeleted() {
@@ -402,8 +435,9 @@ void CefWindowImpl::OnWindowViewDeleted() {
destroyed_ = true;
widget_ = nullptr;
if (delegate())
if (delegate()) {
delegate()->OnWindowDestroyed(this);
}
// Call Detach() here instead of waiting for the root View to be deleted so
// that any following attempts to call CefWindow methods from the delegate
@@ -414,21 +448,24 @@ void CefWindowImpl::OnWindowViewDeleted() {
// Will only be called if CanHandleAccelerators() returns true.
bool CefWindowImpl::AcceleratorPressed(const ui::Accelerator& accelerator) {
for (const auto& entry : accelerator_map_) {
if (entry.second == accelerator)
if (entry.second == accelerator) {
return delegate()->OnAccelerator(this, entry.first);
}
}
return false;
}
bool CefWindowImpl::CanHandleAccelerators() const {
if (delegate() && widget_)
if (delegate() && widget_) {
return widget_->IsActive();
}
return false;
}
bool CefWindowImpl::OnKeyEvent(const CefKeyEvent& event) {
if (delegate())
if (delegate()) {
return delegate()->OnKeyEvent(this, event);
}
return false;
}
@@ -438,13 +475,15 @@ void CefWindowImpl::ShowMenu(views::MenuButton* menu_button,
cef_menu_anchor_position_t anchor_position) {
CancelMenu();
if (!widget_)
if (!widget_) {
return;
}
CefMenuModelImpl* menu_model_impl =
static_cast<CefMenuModelImpl*>(menu_model.get());
if (!menu_model_impl || !menu_model_impl->model())
if (!menu_model_impl || !menu_model_impl->model()) {
return;
}
menu_model_ = menu_model_impl;
@@ -472,8 +511,9 @@ void CefWindowImpl::MenuClosed() {
void CefWindowImpl::CancelMenu() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (menu_runner_)
if (menu_runner_) {
menu_runner_->Cancel();
}
DCHECK(!menu_model_);
DCHECK(!menu_runner_);
}
@@ -482,8 +522,9 @@ CefRefPtr<CefDisplay> CefWindowImpl::GetDisplay() {
CEF_REQUIRE_VALID_RETURN(nullptr);
if (widget_ && root_view()) {
const display::Display& display = root_view()->GetDisplay();
if (display.is_valid())
if (display.is_valid()) {
return new CefDisplayImpl(display);
}
}
return nullptr;
}
@@ -513,8 +554,9 @@ CefRect CefWindowImpl::GetClientAreaBoundsInScreen() {
void CefWindowImpl::SetDraggableRegions(
const std::vector<CefDraggableRegion>& regions) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view())
if (root_view()) {
root_view()->SetDraggableRegions(regions);
}
}
CefWindowHandle CefWindowImpl::GetWindowHandle() {
@@ -527,8 +569,9 @@ void CefWindowImpl::SendKeyPress(int key_code, uint32 event_flags) {
InitializeUITesting();
gfx::NativeWindow native_window = view_util::GetNativeWindow(widget_);
if (!native_window)
if (!native_window) {
return;
}
ui_controls::SendKeyPress(native_window,
static_cast<ui::KeyboardCode>(key_code),
@@ -551,22 +594,26 @@ void CefWindowImpl::SendMouseEvents(cef_mouse_button_type_t button,
bool mouse_down,
bool mouse_up) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (!mouse_down && !mouse_up)
if (!mouse_down && !mouse_up) {
return;
}
InitializeUITesting();
ui_controls::MouseButton type = ui_controls::LEFT;
if (button == MBT_MIDDLE)
if (button == MBT_MIDDLE) {
type = ui_controls::MIDDLE;
else if (button == MBT_RIGHT)
} else if (button == MBT_RIGHT) {
type = ui_controls::RIGHT;
}
int state = 0;
if (mouse_down)
if (mouse_down) {
state |= ui_controls::DOWN;
if (mouse_up)
}
if (mouse_up) {
state |= ui_controls::UP;
}
ui_controls::SendMouseEvents(type, state);
}
@@ -577,20 +624,25 @@ void CefWindowImpl::SetAccelerator(int command_id,
bool ctrl_pressed,
bool alt_pressed) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (!widget_)
if (!widget_) {
return;
}
AcceleratorMap::const_iterator it = accelerator_map_.find(command_id);
if (it != accelerator_map_.end())
if (it != accelerator_map_.end()) {
RemoveAccelerator(command_id);
}
int modifiers = 0;
if (shift_pressed)
if (shift_pressed) {
modifiers |= ui::EF_SHIFT_DOWN;
if (ctrl_pressed)
}
if (ctrl_pressed) {
modifiers |= ui::EF_CONTROL_DOWN;
if (alt_pressed)
}
if (alt_pressed) {
modifiers |= ui::EF_ALT_DOWN;
}
ui::Accelerator accelerator(static_cast<ui::KeyboardCode>(key_code),
modifiers);
@@ -604,12 +656,14 @@ void CefWindowImpl::SetAccelerator(int command_id,
void CefWindowImpl::RemoveAccelerator(int command_id) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (!widget_)
if (!widget_) {
return;
}
AcceleratorMap::iterator it = accelerator_map_.find(command_id);
if (it == accelerator_map_.end())
if (it == accelerator_map_.end()) {
return;
}
ui::Accelerator accelerator = it->second;
@@ -622,8 +676,9 @@ void CefWindowImpl::RemoveAccelerator(int command_id) {
void CefWindowImpl::RemoveAllAccelerators() {
CEF_REQUIRE_VALID_RETURN_VOID();
if (!widget_)
if (!widget_) {
return;
}
accelerator_map_.clear();

View File

@@ -85,13 +85,15 @@ class NativeFrameViewEx : public views::NativeFrameView {
}
int NonClientHitTest(const gfx::Point& point) override {
if (widget_->IsFullscreen())
if (widget_->IsFullscreen()) {
return HTCLIENT;
}
// Test for mouse clicks that fall within the draggable region.
SkRegion* draggable_region = view_->draggable_region();
if (draggable_region && draggable_region->contains(point.x(), point.y()))
if (draggable_region && draggable_region->contains(point.x(), point.y())) {
return HTCAPTION;
}
return views::NativeFrameView::NonClientHitTest(point);
}
@@ -130,12 +132,14 @@ class CaptionlessFrameView : public views::NonClientFrameView {
}
int NonClientHitTest(const gfx::Point& point) override {
if (widget_->IsFullscreen())
if (widget_->IsFullscreen()) {
return HTCLIENT;
}
// Sanity check.
if (!bounds().Contains(point))
if (!bounds().Contains(point)) {
return HTNOWHERE;
}
// Check the frame first, as we allow a small area overlapping the contents
// to be used for resize handles.
@@ -149,17 +153,20 @@ class CaptionlessFrameView : public views::NonClientFrameView {
point,
gfx::Insets::VH(resize_border_thickness, resize_border_thickness),
kResizeAreaCornerSize, kResizeAreaCornerSize, can_ever_resize);
if (frame_component != HTNOWHERE)
if (frame_component != HTNOWHERE) {
return frame_component;
}
// Test for mouse clicks that fall within the draggable region.
SkRegion* draggable_region = view_->draggable_region();
if (draggable_region && draggable_region->contains(point.x(), point.y()))
if (draggable_region && draggable_region->contains(point.x(), point.y())) {
return HTCAPTION;
}
int client_component = widget_->client_view()->NonClientHitTest(point);
if (client_component != HTNOWHERE)
if (client_component != HTNOWHERE) {
return client_component;
}
// Caption is a safe default.
return HTCAPTION;
@@ -407,14 +414,16 @@ void CefWindowView::DeleteDelegate() {
}
bool CefWindowView::CanMinimize() const {
if (!cef_delegate())
if (!cef_delegate()) {
return true;
}
return cef_delegate()->CanMinimize(GetCefWindow());
}
bool CefWindowView::CanMaximize() const {
if (!cef_delegate())
if (!cef_delegate()) {
return true;
}
return cef_delegate()->CanMaximize(GetCefWindow());
}
@@ -423,8 +432,9 @@ std::u16string CefWindowView::GetWindowTitle() const {
}
ui::ImageModel CefWindowView::GetWindowIcon() {
if (!window_icon_)
if (!window_icon_) {
return ParentClass::GetWindowIcon();
}
auto image_skia =
static_cast<CefImageImpl*>(window_icon_.get())
->GetForced1xScaleRepresentation(GetDisplay().device_scale_factor());
@@ -432,8 +442,9 @@ ui::ImageModel CefWindowView::GetWindowIcon() {
}
ui::ImageModel CefWindowView::GetWindowAppIcon() {
if (!window_app_icon_)
if (!window_app_icon_) {
return ParentClass::GetWindowAppIcon();
}
auto image_skia =
static_cast<CefImageImpl*>(window_app_icon_.get())
->GetForced1xScaleRepresentation(GetDisplay().device_scale_factor());
@@ -479,8 +490,9 @@ bool CefWindowView::ShouldDescendIntoChildForEventHandling(
views::NonClientFrameView* ncfv = GetNonClientFrameView();
if (ncfv) {
int result = ncfv->NonClientHitTest(location);
if (IsWindowBorderHit(result))
if (IsWindowBorderHit(result)) {
return false;
}
}
}
@@ -555,8 +567,9 @@ display::Display CefWindowView::GetDisplay() const {
void CefWindowView::SetTitle(const std::u16string& title) {
title_ = title;
views::Widget* widget = GetWidget();
if (widget)
if (widget) {
widget->UpdateWindowTitle();
}
}
void CefWindowView::SetWindowIcon(CefRefPtr<CefImage> window_icon) {
@@ -567,15 +580,17 @@ void CefWindowView::SetWindowIcon(CefRefPtr<CefImage> window_icon) {
window_icon_ = window_icon;
views::Widget* widget = GetWidget();
if (widget)
if (widget) {
widget->UpdateWindowIcon();
}
}
void CefWindowView::SetWindowAppIcon(CefRefPtr<CefImage> window_app_icon) {
window_app_icon_ = window_app_icon;
views::Widget* widget = GetWidget();
if (widget)
if (widget) {
widget->UpdateWindowIcon();
}
}
CefRefPtr<CefOverlayController> CefWindowView::AddOverlayView(
@@ -583,8 +598,9 @@ CefRefPtr<CefOverlayController> CefWindowView::AddOverlayView(
cef_docking_mode_t docking_mode) {
DCHECK(view.get());
DCHECK(view->IsValid());
if (!view.get() || !view->IsValid())
if (!view.get() || !view->IsValid()) {
return nullptr;
}
views::Widget* widget = GetWidget();
if (widget) {
@@ -604,8 +620,9 @@ CefRefPtr<CefOverlayController> CefWindowView::AddOverlayView(
}
void CefWindowView::MoveOverlaysIfNecessary() {
if (overlay_hosts_.empty())
if (overlay_hosts_.empty()) {
return;
}
for (auto& overlay_host : overlay_hosts_) {
overlay_host->MoveIfNecessary();
}
@@ -614,8 +631,9 @@ void CefWindowView::MoveOverlaysIfNecessary() {
void CefWindowView::SetDraggableRegions(
const std::vector<CefDraggableRegion>& regions) {
if (regions.empty()) {
if (draggable_region_)
if (draggable_region_) {
draggable_region_.reset(nullptr);
}
return;
}
@@ -631,9 +649,11 @@ void CefWindowView::SetDraggableRegions(
views::NonClientFrameView* CefWindowView::GetNonClientFrameView() const {
const views::Widget* widget = GetWidget();
if (!widget)
if (!widget) {
return nullptr;
if (!widget->non_client_view())
}
if (!widget->non_client_view()) {
return nullptr;
}
return widget->non_client_view()->frame_view();
}