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

@@ -57,8 +57,9 @@ void CefBrowserPlatformDelegateOsr::WebContentsCreated(
void CefBrowserPlatformDelegateOsr::RenderViewCreated(
content::RenderViewHost* render_view_host) {
if (view_osr_)
if (view_osr_) {
view_osr_->RenderViewCreated();
}
}
void CefBrowserPlatformDelegateOsr::BrowserCreated(
@@ -105,14 +106,16 @@ SkColor CefBrowserPlatformDelegateOsr::GetBackgroundColor() const {
void CefBrowserPlatformDelegateOsr::WasResized() {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->WasResized();
}
}
void CefBrowserPlatformDelegateOsr::SendKeyEvent(const CefKeyEvent& event) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (!view)
if (!view) {
return;
}
content::NativeWebKeyboardEvent web_event =
native_delegate_->TranslateWebKeyEvent(event);
@@ -125,8 +128,9 @@ void CefBrowserPlatformDelegateOsr::SendMouseClickEvent(
bool mouseUp,
int clickCount) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (!view)
if (!view) {
return;
}
blink::WebMouseEvent web_event = native_delegate_->TranslateWebClickEvent(
event, type, mouseUp, clickCount);
@@ -137,8 +141,9 @@ void CefBrowserPlatformDelegateOsr::SendMouseMoveEvent(
const CefMouseEvent& event,
bool mouseLeave) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (!view)
if (!view) {
return;
}
blink::WebMouseEvent web_event =
native_delegate_->TranslateWebMoveEvent(event, mouseLeave);
@@ -150,8 +155,9 @@ void CefBrowserPlatformDelegateOsr::SendMouseWheelEvent(
int deltaX,
int deltaY) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (!view)
if (!view) {
return;
}
blink::WebMouseWheelEvent web_event =
native_delegate_->TranslateWebWheelEvent(event, deltaX, deltaY);
@@ -160,14 +166,16 @@ void CefBrowserPlatformDelegateOsr::SendMouseWheelEvent(
void CefBrowserPlatformDelegateOsr::SendTouchEvent(const CefTouchEvent& event) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->SendTouchEvent(event);
}
}
void CefBrowserPlatformDelegateOsr::SetFocus(bool setFocus) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->SetFocus(setFocus);
}
}
gfx::Point CefBrowserPlatformDelegateOsr::GetScreenPoint(
@@ -228,42 +236,48 @@ void CefBrowserPlatformDelegateOsr::WasHidden(bool hidden) {
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(web_contents_);
if (web_contents) {
if (hidden)
if (hidden) {
web_contents->WasHidden();
else
} else {
web_contents->WasShown();
}
}
}
bool CefBrowserPlatformDelegateOsr::IsHidden() const {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
return view->is_hidden();
}
return true;
}
void CefBrowserPlatformDelegateOsr::NotifyScreenInfoChanged() {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->OnScreenInfoChanged();
}
}
void CefBrowserPlatformDelegateOsr::Invalidate(cef_paint_element_type_t type) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->Invalidate(type);
}
}
void CefBrowserPlatformDelegateOsr::SendExternalBeginFrame() {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->SendExternalBeginFrame();
}
}
void CefBrowserPlatformDelegateOsr::SetWindowlessFrameRate(int frame_rate) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->UpdateFrameRate();
}
}
void CefBrowserPlatformDelegateOsr::ImeSetComposition(
@@ -283,21 +297,24 @@ void CefBrowserPlatformDelegateOsr::ImeCommitText(
const CefRange& replacement_range,
int relative_cursor_pos) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->ImeCommitText(text, replacement_range, relative_cursor_pos);
}
}
void CefBrowserPlatformDelegateOsr::ImeFinishComposingText(
bool keep_selection) {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->ImeFinishComposingText(keep_selection);
}
}
void CefBrowserPlatformDelegateOsr::ImeCancelComposition() {
CefRenderWidgetHostViewOSR* view = GetOSRHostView();
if (view)
if (view) {
view->ImeCancelComposition();
}
}
void CefBrowserPlatformDelegateOsr::DragTargetDragEnter(
@@ -306,11 +323,13 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragEnter(
cef_drag_operations_mask_t allowed_ops) {
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents)
if (!web_contents) {
return;
}
if (current_rvh_for_drag_)
if (current_rvh_for_drag_) {
DragTargetDragLeave();
}
const gfx::Point client_pt(event.x, event.y);
gfx::PointF transformed_pt;
@@ -351,13 +370,15 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragEnter(
void CefBrowserPlatformDelegateOsr::DragTargetDragOver(
const CefMouseEvent& event,
cef_drag_operations_mask_t allowed_ops) {
if (!drag_data_)
if (!drag_data_) {
return;
}
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents)
if (!web_contents) {
return;
}
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt =
@@ -393,8 +414,9 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragOver(
DragTargetDragEnter(drag_data_, event, drag_allowed_ops_);
}
if (!drag_data_)
if (!drag_data_) {
return;
}
blink::DragOperationsMask ops =
static_cast<blink::DragOperationsMask>(allowed_ops);
@@ -419,13 +441,15 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragLeave() {
}
void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
if (!drag_data_)
if (!drag_data_) {
return;
}
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents)
if (!web_contents) {
return;
}
gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt =
@@ -461,8 +485,9 @@ void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
DragTargetDragEnter(drag_data_, event, drag_allowed_ops_);
}
if (!drag_data_)
if (!drag_data_) {
return;
}
{
CefDragDataImpl* data_impl =
@@ -505,8 +530,9 @@ void CefBrowserPlatformDelegateOsr::StartDragging(
event_info.location.x(), event_info.location.y());
}
if (!handled)
if (!handled) {
DragSourceSystemDragEnded();
}
}
void CefBrowserPlatformDelegateOsr::UpdateDragCursor(
@@ -523,13 +549,15 @@ void CefBrowserPlatformDelegateOsr::DragSourceEndedAt(
int x,
int y,
cef_drag_operations_mask_t op) {
if (!drag_start_rwh_)
if (!drag_start_rwh_) {
return;
}
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents)
if (!web_contents) {
return;
}
content::RenderWidgetHostImpl* source_rwh = drag_start_rwh_.get();
const gfx::Point client_loc(gfx::Point(x, y));
@@ -565,13 +593,15 @@ void CefBrowserPlatformDelegateOsr::DragSourceEndedAt(
}
void CefBrowserPlatformDelegateOsr::DragSourceSystemDragEnded() {
if (!drag_start_rwh_)
if (!drag_start_rwh_) {
return;
}
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(web_contents_);
if (!web_contents)
if (!web_contents) {
return;
}
web_contents->SystemDragEnded(drag_start_rwh_.get());

View File

@@ -78,8 +78,9 @@ void CefLayeredWindowUpdaterOSR::OnAllocatedSharedMemory(
size_t expected_bytes;
bool size_result = viz::ResourceSizes::MaybeSizeInBytes(
pixel_size, viz::ResourceFormat::RGBA_8888, &expected_bytes);
if (!size_result)
if (!size_result) {
return;
}
pixel_size_ = pixel_size;
shared_memory_ = region.Map();

View File

@@ -39,10 +39,11 @@ CefMotionEventOSR::CefMotionEventOSR() {
CefMotionEventOSR::~CefMotionEventOSR() {}
int CefMotionEventOSR::GetSourceDeviceId(size_t pointer_index) const {
if (IsValidIndex(pointer_index))
if (IsValidIndex(pointer_index)) {
return pointer(pointer_index).source_device_id;
else
} else {
return -1;
}
}
// Returns true if the touch was valid.
@@ -63,10 +64,12 @@ bool CefMotionEventOSR::OnTouch(const CefTouchEvent& touch) {
switch (touch.type) {
case CEF_TET_PRESSED:
id = AddId(touch.id);
if (id == -1)
if (id == -1) {
return false;
if (!AddTouch(touch, id))
}
if (!AddTouch(touch, id)) {
return false;
}
break;
case CEF_TET_MOVED: {
@@ -126,15 +129,17 @@ void CefMotionEventOSR::MarkUnchangedTouchPointsAsStationary(
if (event->GetType() == blink::WebInputEvent::Type::kTouchMove ||
event->GetType() == blink::WebInputEvent::Type::kTouchCancel) {
for (size_t i = 0; i < event->touches_length; ++i) {
if (event->touches[i].id != id)
if (event->touches[i].id != id) {
event->touches[i].state = blink::WebTouchPoint::State::kStateStationary;
}
}
}
}
int CefMotionEventOSR::LookupId(int id) {
if (id == -1)
if (id == -1) {
return -1;
}
for (int i = 0; i < blink::WebTouchEvent::kTouchesLengthCap; i++) {
if (id_map_[i] == id) {
@@ -145,8 +150,9 @@ int CefMotionEventOSR::LookupId(int id) {
}
int CefMotionEventOSR::AddId(int id) {
if (id == -1 || LookupId(id) >= 0)
if (id == -1 || LookupId(id) >= 0) {
return -1;
}
for (int i = 0; i < blink::WebTouchEvent::kTouchesLengthCap; i++) {
if (id_map_[i] == -1) {
@@ -167,8 +173,9 @@ void CefMotionEventOSR::RemoveId(int id) {
}
bool CefMotionEventOSR::AddTouch(const CefTouchEvent& touch, int id) {
if (GetPointerCount() == MotionEvent::MAX_TOUCH_POINT_COUNT)
if (GetPointerCount() == MotionEvent::MAX_TOUCH_POINT_COUNT) {
return false;
}
PushPointer(GetPointerPropertiesFromTouchEvent(touch, id));
return true;
@@ -176,8 +183,9 @@ bool CefMotionEventOSR::AddTouch(const CefTouchEvent& touch, int id) {
void CefMotionEventOSR::UpdateTouch(const CefTouchEvent& touch, int id) {
int index_to_update = FindPointerIndexOfId(id);
if (IsValidIndex(index_to_update))
if (IsValidIndex(index_to_update)) {
pointer(index_to_update) = GetPointerPropertiesFromTouchEvent(touch, id);
}
}
void CefMotionEventOSR::UpdateCachedAction(const CefTouchEvent& touch, int id) {

View File

@@ -28,8 +28,9 @@ CefRefPtr<CefListValue> ToCefValue(const std::vector<T>& vecData);
template <>
CefRefPtr<CefListValue> ToCefValue<int>(const std::vector<int>& vecData) {
CefRefPtr<CefListValue> value = CefListValue::Create();
for (size_t i = 0; i < vecData.size(); i++)
for (size_t i = 0; i < vecData.size(); i++) {
value->SetInt(i, vecData[i]);
}
return value;
}
@@ -43,8 +44,9 @@ CefRefPtr<CefListValue> ToCefValue(uint32_t state) {
// Iterate and find which states are set.
for (unsigned i = static_cast<unsigned>(ax::mojom::Role::kMinValue) + 1;
i <= static_cast<unsigned>(ax::mojom::Role::kMaxValue); i++) {
if (state & (1 << i))
if (state & (1 << i)) {
value->SetString(index++, ToString(static_cast<ax::mojom::State>(i)));
}
}
return value;
}
@@ -69,8 +71,9 @@ struct PopulateAxNodeAttributes {
// Int Attributes
void operator()(const std::pair<ax::mojom::IntAttribute, int32_t> attr) {
if (attr.first == ax::mojom::IntAttribute::kNone)
if (attr.first == ax::mojom::IntAttribute::kNone) {
return;
}
switch (attr.first) {
case ax::mojom::IntAttribute::kNone:
@@ -201,8 +204,9 @@ struct PopulateAxNodeAttributes {
int index = 0;
// Iterate and find which states are set.
for (unsigned i = 0; i < std::size(textStyleArr); i++) {
if (attr.second & static_cast<int>(textStyleArr[i]))
if (attr.second & static_cast<int>(textStyleArr[i])) {
list->SetString(index++, ToString(textStyleArr[i]));
}
}
attributes->SetList(ToString(attr.first), list);
} break;
@@ -225,19 +229,22 @@ struct PopulateAxNodeAttributes {
// Set Bool Attributes.
void operator()(const std::pair<ax::mojom::BoolAttribute, bool> attr) {
if (attr.first != ax::mojom::BoolAttribute::kNone)
if (attr.first != ax::mojom::BoolAttribute::kNone) {
attributes->SetBool(ToString(attr.first), attr.second);
}
}
// Set String Attributes.
void operator()(
const std::pair<ax::mojom::StringAttribute, std::string>& attr) {
if (attr.first != ax::mojom::StringAttribute::kNone)
if (attr.first != ax::mojom::StringAttribute::kNone) {
attributes->SetString(ToString(attr.first), attr.second);
}
}
// Set Float attributes.
void operator()(const std::pair<ax::mojom::FloatAttribute, float>& attr) {
if (attr.first != ax::mojom::FloatAttribute::kNone)
if (attr.first != ax::mojom::FloatAttribute::kNone) {
attributes->SetDouble(ToString(attr.first), attr.second);
}
}
// Set Int list attributes.
@@ -252,8 +259,9 @@ struct PopulateAxNodeAttributes {
for (size_t i = 0; i < attr.second.size(); ++i) {
auto type = static_cast<ax::mojom::MarkerType>(attr.second[i]);
if (type == ax::mojom::MarkerType::kNone)
if (type == ax::mojom::MarkerType::kNone) {
continue;
}
static ax::mojom::MarkerType marktypeArr[] = {
ax::mojom::MarkerType::kSpelling, ax::mojom::MarkerType::kGrammar,
@@ -261,8 +269,9 @@ struct PopulateAxNodeAttributes {
// Iterate and find which markers are set.
for (unsigned j = 0; j < std::size(marktypeArr); j++) {
if (attr.second[i] & static_cast<int>(marktypeArr[j]))
if (attr.second[i] & static_cast<int>(marktypeArr[j])) {
list->SetString(index++, ToString(marktypeArr[j]));
}
}
}
} else {
@@ -277,8 +286,9 @@ struct PopulateAxNodeAttributes {
CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXNodeData& node) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
if (node.id != -1)
if (node.id != -1) {
value->SetInt("id", node.id);
}
value->SetString("role", ToString(node.role));
value->SetList("state", ToCefValue(node.state));
@@ -308,13 +318,15 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXNodeData& node) {
++action_index) {
auto action = static_cast<ax::mojom::Action>(action_index);
if (node.HasAction(action)) {
if (!actions_strings)
if (!actions_strings) {
actions_strings = CefListValue::Create();
}
actions_strings->SetString(actions_idx++, ToString(action));
}
}
if (actions_strings)
if (actions_strings) {
value->SetList("actions", actions_strings);
}
CefRefPtr<CefDictionaryValue> attributes = CefDictionaryValue::Create();
PopulateAxNodeAttributes func(attributes);
@@ -346,29 +358,37 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXNodeData& node) {
CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXTreeData& treeData) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
if (!treeData.tree_id.ToString().empty())
if (!treeData.tree_id.ToString().empty()) {
value->SetString("tree_id", treeData.tree_id.ToString());
}
if (!treeData.parent_tree_id.ToString().empty())
if (!treeData.parent_tree_id.ToString().empty()) {
value->SetString("parent_tree_id", treeData.parent_tree_id.ToString());
}
if (!treeData.focused_tree_id.ToString().empty())
if (!treeData.focused_tree_id.ToString().empty()) {
value->SetString("focused_tree_id", treeData.focused_tree_id.ToString());
}
if (!treeData.doctype.empty())
if (!treeData.doctype.empty()) {
value->SetString("doctype", treeData.doctype);
}
value->SetBool("loaded", treeData.loaded);
if (treeData.loading_progress != 0.0)
if (treeData.loading_progress != 0.0) {
value->SetDouble("loading_progress", treeData.loading_progress);
}
if (!treeData.mimetype.empty())
if (!treeData.mimetype.empty()) {
value->SetString("mimetype", treeData.mimetype);
if (!treeData.url.empty())
}
if (!treeData.url.empty()) {
value->SetString("url", treeData.url);
if (!treeData.title.empty())
}
if (!treeData.title.empty()) {
value->SetString("title", treeData.title);
}
if (treeData.sel_anchor_object_id != -1) {
value->SetInt("sel_anchor_object_id", treeData.sel_anchor_object_id);
@@ -383,8 +403,9 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXTreeData& treeData) {
ToString(treeData.sel_anchor_affinity));
}
if (treeData.focus_id != -1)
if (treeData.focus_id != -1) {
value->SetInt("focus_id", treeData.focus_id);
}
return value;
}
@@ -398,11 +419,13 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXTreeUpdate& update) {
value->SetDictionary("tree_data", ToCefValue(update.tree_data));
}
if (update.node_id_to_clear != 0)
if (update.node_id_to_clear != 0) {
value->SetInt("node_id_to_clear", update.node_id_to_clear);
}
if (update.root_id != 0)
if (update.root_id != 0) {
value->SetInt("root_id", update.root_id);
}
value->SetList("nodes", ToCefValue(update.nodes));
@@ -413,17 +436,21 @@ CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXTreeUpdate& update) {
CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXEvent& event) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
if (event.event_type != ax::mojom::Event::kNone)
if (event.event_type != ax::mojom::Event::kNone) {
value->SetString("event_type", ToString(event.event_type));
}
if (event.id != -1)
if (event.id != -1) {
value->SetInt("id", event.id);
}
if (event.event_from != ax::mojom::EventFrom::kNone)
if (event.event_from != ax::mojom::EventFrom::kNone) {
value->SetString("event_from", ToString(event.event_from));
}
if (event.action_request_id != -1)
if (event.action_request_id != -1) {
value->SetInt("action_request_id", event.action_request_id);
}
return value;
}
@@ -433,8 +460,9 @@ CefRefPtr<CefDictionaryValue> ToCefValue(
const content::AXEventNotificationDetails& eventData) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
if (!eventData.ax_tree_id.ToString().empty())
if (!eventData.ax_tree_id.ToString().empty()) {
value->SetString("ax_tree_id", eventData.ax_tree_id.ToString());
}
if (eventData.updates.size() > 0) {
CefRefPtr<CefListValue> updates = CefListValue::Create();
@@ -464,15 +492,17 @@ CefRefPtr<CefDictionaryValue> ToCefValue(
CefRefPtr<CefDictionaryValue> ToCefValue(const ui::AXRelativeBounds& location) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
if (location.offset_container_id != -1)
if (location.offset_container_id != -1) {
value->SetInt("offset_container_id", location.offset_container_id);
}
value->SetDictionary("bounds", ToCefValue(location.bounds));
// Transform matrix is private, so we set the string that Clients can parse
// and use if needed.
if (location.transform && !location.transform->IsIdentity())
if (location.transform && !location.transform->IsIdentity()) {
value->SetString("transform", location.transform->ToString());
}
return value;
}
@@ -482,11 +512,13 @@ CefRefPtr<CefDictionaryValue> ToCefValue(
const content::AXLocationChangeNotificationDetails& locData) {
CefRefPtr<CefDictionaryValue> value = CefDictionaryValue::Create();
if (locData.id != -1)
if (locData.id != -1) {
value->SetInt("id", locData.id);
}
if (!locData.ax_tree_id.ToString().empty())
if (!locData.ax_tree_id.ToString().empty()) {
value->SetString("ax_tree_id", locData.ax_tree_id.ToString());
}
value->SetDictionary("new_location", ToCefValue(locData.new_location));
@@ -497,8 +529,9 @@ template <typename T>
CefRefPtr<CefListValue> ToCefValue(const std::vector<T>& vecData) {
CefRefPtr<CefListValue> value = CefListValue::Create();
for (size_t i = 0; i < vecData.size(); i++)
for (size_t i = 0; i < vecData.size(); i++) {
value->SetDictionary(i, ToCefValue(vecData[i]));
}
return value;
}

View File

@@ -14,8 +14,9 @@ const int kDefaultFrameRate = 30;
} // namespace
int ClampFrameRate(int frame_rate) {
if (frame_rate < 1)
if (frame_rate < 1) {
return kDefaultFrameRate;
}
return frame_rate;
}

View File

@@ -146,8 +146,9 @@ ui::LatencyInfo CreateLatencyInfo(const blink::WebInputEvent& event) {
}
gfx::Rect GetViewBounds(AlloyBrowserHostImpl* browser) {
if (!browser)
if (!browser) {
return gfx::Rect();
}
CefRect rc;
CefRefPtr<CefRenderHandler> handler =
@@ -249,16 +250,18 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
content::RenderWidgetHostImpl* render_widget_host_impl =
content::RenderWidgetHostImpl::From(render_widget_host_);
if (render_widget_host_impl)
if (render_widget_host_impl) {
render_widget_host_impl->SetCompositorForFlingScheduler(compositor_.get());
}
cursor_manager_.reset(new content::CursorManager(this));
// This may result in a call to GetFrameSinkId().
render_widget_host_->SetView(this);
if (GetTextInputManager())
if (GetTextInputManager()) {
GetTextInputManager()->AddObserver(this);
}
if (render_widget_host_->delegate() &&
render_widget_host_->delegate()->GetInputEventRouter()) {
@@ -270,8 +273,9 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
// For child/popup views this will be called from the associated InitAs*()
// method.
SetRootLayerSize(false /* force */);
if (!render_widget_host_->is_hidden())
if (!render_widget_host_->is_hidden()) {
Show();
}
}
selection_controller_client_ =
@@ -288,8 +292,9 @@ CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() {
DCHECK(!child_host_view_);
DCHECK(guest_host_views_.empty());
if (text_input_manager_)
if (text_input_manager_) {
text_input_manager_->RemoveObserver(this);
}
}
void CefRenderWidgetHostViewOSR::ReleaseCompositor() {
@@ -355,8 +360,9 @@ bool CefRenderWidgetHostViewOSR::IsSurfaceAvailableForCopy() {
void CefRenderWidgetHostViewOSR::ShowWithVisibility(
content::PageVisibilityState) {
if (is_showing_)
if (is_showing_) {
return;
}
if (!content::GpuDataManagerImpl::GetInstance()->IsGpuCompositingDisabled() &&
!browser_impl_ &&
@@ -404,8 +410,9 @@ void CefRenderWidgetHostViewOSR::ShowWithVisibility(
}
void CefRenderWidgetHostViewOSR::Hide() {
if (!is_showing_)
if (!is_showing_) {
return;
}
is_showing_ = false;
@@ -452,8 +459,9 @@ CefRenderWidgetHostViewOSR::GetTouchSelectionControllerClientManager() {
}
gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() {
if (IsPopupWidget())
if (IsPopupWidget()) {
return popup_position_;
}
return current_view_bounds_;
}
@@ -552,14 +560,16 @@ void CefRenderWidgetHostViewOSR::UpdateLocalSurfaceIdFromEmbeddedClient(
const viz::LocalSurfaceId&
CefRenderWidgetHostViewOSR::GetOrCreateLocalSurfaceId() {
if (!parent_local_surface_id_allocator_)
if (!parent_local_surface_id_allocator_) {
AllocateLocalSurfaceId();
}
return GetCurrentLocalSurfaceId();
}
void CefRenderWidgetHostViewOSR::InvalidateLocalSurfaceId() {
if (!parent_local_surface_id_allocator_)
if (!parent_local_surface_id_allocator_) {
return;
}
parent_local_surface_id_allocator_->Invalidate();
}
@@ -615,8 +625,9 @@ void CefRenderWidgetHostViewOSR::InitAsPopup(
CefRect widget_pos(client_pos.x(), client_pos.y(), client_pos.width(),
client_pos.height());
if (handler.get())
if (handler.get()) {
handler->OnPopupSize(browser_impl_.get(), widget_pos);
}
// The size doesn't change for popups so we need to force the
// initialization.
@@ -632,8 +643,9 @@ content::CursorManager* CefRenderWidgetHostViewOSR::GetCursorManager() {
}
void CefRenderWidgetHostViewOSR::SetIsLoading(bool is_loading) {
if (!is_loading)
if (!is_loading) {
return;
}
// Make sure gesture detection is fresh.
gesture_provider_.ResetDetection();
forward_touch_to_popup_ = false;
@@ -650,16 +662,19 @@ void CefRenderWidgetHostViewOSR::Destroy() {
if (has_parent_) {
CancelWidget();
} else {
if (popup_host_view_)
if (popup_host_view_) {
popup_host_view_->CancelWidget();
if (child_host_view_)
}
if (child_host_view_) {
child_host_view_->CancelWidget();
}
if (!guest_host_views_.empty()) {
// Guest RWHVs will be destroyed when the associated RWHVGuest is
// destroyed. This parent RWHV may be destroyed first, so disassociate
// the guest RWHVs here without destroying them.
for (auto guest_host_view : guest_host_views_)
for (auto guest_host_view : guest_host_views_) {
guest_host_view->parent_host_view_ = nullptr;
}
guest_host_views_.clear();
}
Hide();
@@ -671,8 +686,9 @@ void CefRenderWidgetHostViewOSR::Destroy() {
void CefRenderWidgetHostViewOSR::UpdateTooltipUnderCursor(
const std::u16string& tooltip_text) {
if (!browser_impl_.get())
if (!browser_impl_.get()) {
return;
}
CefString tooltip(tooltip_text);
CefRefPtr<CefDisplayHandler> handler =
@@ -743,15 +759,17 @@ void CefRenderWidgetHostViewOSR::TransformPointToRootSurface(
gfx::PointF* point) {}
gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() {
if (!browser_impl_.get())
if (!browser_impl_.get()) {
return gfx::Rect();
}
CefRect rc;
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
CHECK(handler);
if (handler->GetRootScreenRect(browser_impl_.get(), rc))
if (handler->GetRootScreenRect(browser_impl_.get(), rc)) {
return gfx::Rect(rc.x, rc.y, rc.width, rc.height);
}
return GetViewBounds();
}
@@ -777,8 +795,9 @@ void CefRenderWidgetHostViewOSR::ImeSetComposition(
const CefRange& replacement_range,
const CefRange& selection_range) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::ImeSetComposition");
if (!render_widget_host_)
if (!render_widget_host_) {
return;
}
std::vector<ui::ImeTextSpan> web_underlines;
web_underlines.reserve(underlines.size());
@@ -804,8 +823,9 @@ void CefRenderWidgetHostViewOSR::ImeCommitText(
const CefRange& replacement_range,
int relative_cursor_pos) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::ImeCommitText");
if (!render_widget_host_)
if (!render_widget_host_) {
return;
}
gfx::Range range(replacement_range.from, replacement_range.to);
render_widget_host_->ImeCommitText(text, std::vector<ui::ImeTextSpan>(),
@@ -817,8 +837,9 @@ void CefRenderWidgetHostViewOSR::ImeCommitText(
void CefRenderWidgetHostViewOSR::ImeFinishComposingText(bool keep_selection) {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::ImeFinishComposingText");
if (!render_widget_host_)
if (!render_widget_host_) {
return;
}
render_widget_host_->ImeFinishComposingText(keep_selection);
@@ -828,8 +849,9 @@ void CefRenderWidgetHostViewOSR::ImeFinishComposingText(bool keep_selection) {
void CefRenderWidgetHostViewOSR::ImeCancelComposition() {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::ImeCancelComposition");
if (!render_widget_host_)
if (!render_widget_host_) {
return;
}
render_widget_host_->ImeCancelComposition();
@@ -842,15 +864,17 @@ void CefRenderWidgetHostViewOSR::SelectionChanged(const std::u16string& text,
const gfx::Range& range) {
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
if (!browser_impl_.get())
if (!browser_impl_.get()) {
return;
}
CefString selected_text;
if (!range.is_empty() && !text.empty()) {
size_t pos = range.GetMin() - offset;
size_t n = range.length();
if (pos + n <= text.length())
if (pos + n <= text.length()) {
selected_text = text.substr(pos, n);
}
}
CefRefPtr<CefRenderHandler> handler =
@@ -934,8 +958,9 @@ void CefRenderWidgetHostViewOSR::DidNavigate() {
absl::nullopt);
}
}
if (delegated_frame_host_)
if (delegated_frame_host_) {
delegated_frame_host_->DidNavigate();
}
is_first_navigation_ = false;
}
@@ -1007,8 +1032,9 @@ bool CefRenderWidgetHostViewOSR::InstallTransparency() {
void CefRenderWidgetHostViewOSR::WasResized() {
// Only one resize will be in-flight at a time.
if (hold_resize_) {
if (!pending_resize_)
if (!pending_resize_) {
pending_resize_ = true;
}
return;
}
@@ -1053,16 +1079,18 @@ void CefRenderWidgetHostViewOSR::SynchronizeVisualProperties(
void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
TRACE_EVENT0("cef", "CefRenderWidgetHostViewOSR::OnScreenInfoChanged");
if (!render_widget_host_)
if (!render_widget_host_) {
return;
}
SynchronizeVisualProperties(cc::DeadlinePolicy::UseDefaultDeadline(),
absl::nullopt);
if (render_widget_host_->delegate())
if (render_widget_host_->delegate()) {
render_widget_host_->delegate()->SendScreenRects();
else
} else {
render_widget_host_->SendScreenRects();
}
render_widget_host_->NotifyScreenInfoChanged();
@@ -1071,16 +1099,18 @@ void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
// renderer in the rwhv_aura (current_cursor_.SetScaleFactor)
// Notify the guest hosts if any.
for (auto guest_host_view : guest_host_views_)
for (auto guest_host_view : guest_host_views_) {
guest_host_view->OnScreenInfoChanged();
}
}
void CefRenderWidgetHostViewOSR::Invalidate(
CefBrowserHost::PaintElementType type) {
TRACE_EVENT1("cef", "CefRenderWidgetHostViewOSR::Invalidate", "type", type);
if (!IsPopupWidget() && type == PET_POPUP) {
if (popup_host_view_)
if (popup_host_view_) {
popup_host_view_->Invalidate(type);
}
return;
}
InvalidateInternal(gfx::Rect(SizeInPixels()));
@@ -1089,8 +1119,9 @@ void CefRenderWidgetHostViewOSR::Invalidate(
void CefRenderWidgetHostViewOSR::SendExternalBeginFrame() {
DCHECK(external_begin_frame_enabled_);
if (begin_frame_pending_)
if (begin_frame_pending_) {
return;
}
begin_frame_pending_ = true;
base::TimeTicks frame_time = base::TimeTicks::Now();
@@ -1104,8 +1135,9 @@ void CefRenderWidgetHostViewOSR::SendExternalBeginFrame() {
DCHECK(begin_frame_args.IsValid());
if (render_widget_host_)
if (render_widget_host_) {
render_widget_host_->ProgressFlingIfNeeded(frame_time);
}
if (compositor_) {
compositor_->IssueExternalBeginFrame(
@@ -1319,8 +1351,9 @@ void CefRenderWidgetHostViewOSR::SendTouchEvent(const CefTouchEvent& event) {
}
// Update the touch event first.
if (!pointer_state_.OnTouch(event))
if (!pointer_state_.OnTouch(event)) {
return;
}
if (selection_controller_->WillHandleTouchEvent(pointer_state_)) {
pointer_state_.CleanupRemovedTouchPoints(event);
@@ -1337,11 +1370,13 @@ void CefRenderWidgetHostViewOSR::SendTouchEvent(const CefTouchEvent& event) {
// Set unchanged touch point to StateStationary for touchmove and
// touchcancel to make sure only send one ack per WebTouchEvent.
if (!result.succeeded)
if (!result.succeeded) {
pointer_state_.MarkUnchangedTouchPointsAsStationary(&touch_event, event);
}
if (!render_widget_host_)
if (!render_widget_host_) {
return;
}
ui::LatencyInfo latency_info = CreateLatencyInfo(touch_event);
if (ShouldRouteEvents()) {
@@ -1363,8 +1398,9 @@ void CefRenderWidgetHostViewOSR::SendTouchEvent(const CefTouchEvent& event) {
}
bool CefRenderWidgetHostViewOSR::ShouldRouteEvents() const {
if (!render_widget_host_->delegate())
if (!render_widget_host_->delegate()) {
return false;
}
// Do not route events that are currently targeted to page popups such as
// <select> element drop-downs, since these cannot contain cross-process
@@ -1378,8 +1414,9 @@ bool CefRenderWidgetHostViewOSR::ShouldRouteEvents() const {
}
void CefRenderWidgetHostViewOSR::SetFocus(bool focus) {
if (!render_widget_host_)
if (!render_widget_host_) {
return;
}
content::RenderWidgetHostImpl* widget =
content::RenderWidgetHostImpl::From(render_widget_host_);
@@ -1405,8 +1442,9 @@ void CefRenderWidgetHostViewOSR::OnUpdateTextInputStateCalled(
content::RenderWidgetHostViewBase* updated_view,
bool did_update_state) {
const auto state = text_input_manager->GetTextInputState();
if (state && !state->show_ime_if_needed)
if (state && !state->show_ime_if_needed) {
return;
}
CefRenderHandler::TextInputMode mode = CEF_TEXT_INPUT_MODE_NONE;
if (state && state->type != ui::TEXT_INPUT_TYPE_NONE) {
@@ -1446,8 +1484,9 @@ void CefRenderWidgetHostViewOSR::OnGestureEvent(
ui::CreateWebGestureEventFromGestureEventData(gesture);
// without this check, forwarding gestures does not work!
if (web_event.GetType() == blink::WebInputEvent::Type::kUndefined)
if (web_event.GetType() == blink::WebInputEvent::Type::kUndefined) {
return;
}
ui::LatencyInfo latency_info = CreateLatencyInfo(web_event);
if (ShouldRouteEvents()) {
@@ -1468,8 +1507,9 @@ void CefRenderWidgetHostViewOSR::UpdateFrameRate() {
}
// Notify the guest hosts if any.
for (auto guest_host_view : guest_host_views_)
for (auto guest_host_view : guest_host_views_) {
guest_host_view->UpdateFrameRate();
}
}
gfx::Size CefRenderWidgetHostViewOSR::SizeInPixels() {
@@ -1529,8 +1569,9 @@ void CefRenderWidgetHostViewOSR::OnPaint(const gfx::Rect& damage_rect,
DCHECK_GT(cached_scale_factor_, 0);
gfx::Size expected_size =
gfx::ScaleToCeiledSize(GetViewBounds().size(), cached_scale_factor_);
if (pixel_size == expected_size)
if (pixel_size == expected_size) {
ReleaseResizeHold();
}
}
}
@@ -1539,8 +1580,9 @@ ui::Layer* CefRenderWidgetHostViewOSR::GetRootLayer() const {
}
ui::TextInputType CefRenderWidgetHostViewOSR::GetTextInputType() {
if (text_input_manager_ && text_input_manager_->GetTextInputState())
if (text_input_manager_ && text_input_manager_->GetTextInputState()) {
return text_input_manager_->GetTextInputState()->type;
}
return ui::TEXT_INPUT_TYPE_NONE;
}
@@ -1556,8 +1598,9 @@ void CefRenderWidgetHostViewOSR::SetFrameRate() {
CHECK(browser);
// Only set the frame rate one time.
if (frame_rate_threshold_us_ != 0)
if (frame_rate_threshold_us_ != 0) {
return;
}
int frame_rate =
osr_util::ClampFrameRate(browser->settings().windowless_frame_rate);
@@ -1590,8 +1633,9 @@ bool CefRenderWidgetHostViewOSR::SetScreenInfo() {
// Notify the guest hosts if any.
for (auto guest_host_view : guest_host_views_) {
content::RenderWidgetHostImpl* rwhi = guest_host_view->render_widget_host();
if (!rwhi)
if (!rwhi) {
continue;
}
auto guest_view_osr =
static_cast<CefRenderWidgetHostViewOSR*>(rwhi->GetView());
if (guest_view_osr) {
@@ -1607,12 +1651,14 @@ bool CefRenderWidgetHostViewOSR::SetViewBounds() {
DCHECK(!hold_resize_);
// Popup bounds are set in InitAsPopup.
if (IsPopupWidget())
if (IsPopupWidget()) {
return false;
}
const gfx::Rect& new_bounds = ::GetViewBounds(browser_impl_.get());
if (new_bounds == current_view_bounds_)
if (new_bounds == current_view_bounds_) {
return false;
}
current_view_bounds_ = new_bounds;
return true;
@@ -1621,8 +1667,9 @@ bool CefRenderWidgetHostViewOSR::SetViewBounds() {
bool CefRenderWidgetHostViewOSR::SetRootLayerSize(bool force) {
const bool screen_info_changed = SetScreenInfo();
const bool view_bounds_changed = SetViewBounds();
if (!force && !screen_info_changed && !view_bounds_changed)
if (!force && !screen_info_changed && !view_bounds_changed) {
return false;
}
GetRootLayer()->SetBounds(gfx::Rect(GetViewBounds().size()));
@@ -1667,8 +1714,9 @@ void CefRenderWidgetHostViewOSR::ReleaseResizeHold() {
}
void CefRenderWidgetHostViewOSR::CancelWidget() {
if (render_widget_host_)
if (render_widget_host_) {
render_widget_host_->LostCapture();
}
Hide();
@@ -1739,8 +1787,9 @@ void CefRenderWidgetHostViewOSR::InvalidateInternal(
void CefRenderWidgetHostViewOSR::RequestImeCompositionUpdate(
bool start_monitoring) {
if (!render_widget_host_)
if (!render_widget_host_) {
return;
}
render_widget_host_->RequestCompositionUpdates(false, start_monitoring);
}
@@ -1771,8 +1820,9 @@ viz::FrameSinkId CefRenderWidgetHostViewOSR::AllocateFrameSinkId() {
void CefRenderWidgetHostViewOSR::UpdateBackgroundColorFromRenderer(
SkColor color) {
if (color == background_color_)
if (color == background_color_) {
return;
}
background_color_ = color;
bool opaque = SkColorGetA(color) == SK_AlphaOPAQUE;

View File

@@ -273,8 +273,9 @@ class CefRenderWidgetHostViewOSR
}
void set_popup_host_view(CefRenderWidgetHostViewOSR* popup_view) {
if (popup_view != popup_host_view_)
if (popup_view != popup_host_view_) {
forward_touch_to_popup_ = false;
}
popup_host_view_ = popup_view;
}
void set_child_host_view(CefRenderWidgetHostViewOSR* popup_view) {

View File

@@ -52,8 +52,9 @@ void SoftwareOutputDeviceProxy::Resize(const gfx::Size& viewport_pixel_size,
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!in_paint_);
if (viewport_pixel_size_ == viewport_pixel_size)
if (viewport_pixel_size_ == viewport_pixel_size) {
return;
}
viewport_pixel_size_ = viewport_pixel_size;
@@ -119,11 +120,13 @@ void SoftwareOutputDeviceProxy::EndPaint() {
gfx::Rect intersected_damage_rect = damage_rect_;
intersected_damage_rect.Intersect(gfx::Rect(viewport_pixel_size_));
if (intersected_damage_rect.IsEmpty())
if (intersected_damage_rect.IsEmpty()) {
return;
}
if (!canvas_)
if (!canvas_) {
return;
}
layered_window_updater_->Draw(
damage_rect_, base::BindOnce(&SoftwareOutputDeviceProxy::DrawAck,

View File

@@ -33,8 +33,9 @@ CefTouchHandleDrawableOSR::CefTouchHandleDrawableOSR(
: rwhv_(rwhv), id_(counter_++) {}
void CefTouchHandleDrawableOSR::SetEnabled(bool enabled) {
if (enabled == enabled_)
if (enabled == enabled_) {
return;
}
enabled_ = enabled;
@@ -49,8 +50,9 @@ void CefTouchHandleDrawableOSR::SetOrientation(
ui::TouchHandleOrientation orientation,
bool mirror_vertical,
bool mirror_horizontal) {
if (orientation == orientation_)
if (orientation == orientation_) {
return;
}
orientation_ = orientation;
@@ -80,8 +82,9 @@ void CefTouchHandleDrawableOSR::SetOrientation(
}
void CefTouchHandleDrawableOSR::SetOrigin(const gfx::PointF& position) {
if (position == origin_position_)
if (position == origin_position_) {
return;
}
origin_position_ = position;
@@ -94,8 +97,9 @@ void CefTouchHandleDrawableOSR::SetOrigin(const gfx::PointF& position) {
}
void CefTouchHandleDrawableOSR::SetAlpha(float alpha) {
if (alpha == alpha_)
if (alpha == alpha_) {
return;
}
alpha_ = alpha;

View File

@@ -108,8 +108,9 @@ CefTouchSelectionControllerClientOSR::CefTouchSelectionControllerClientOSR(
}
CefTouchSelectionControllerClientOSR::~CefTouchSelectionControllerClientOSR() {
for (auto& observer : observers_)
for (auto& observer : observers_) {
observer.OnManagerWillDestroy(this);
}
}
void CefTouchSelectionControllerClientOSR::CloseQuickMenuAndHideHandles() {
@@ -158,8 +159,9 @@ bool CefTouchSelectionControllerClientOSR::HandleContextMenu(
const bool from_touch = params.source_type == ui::MENU_SOURCE_LONG_PRESS ||
params.source_type == ui::MENU_SOURCE_LONG_TAP ||
params.source_type == ui::MENU_SOURCE_TOUCH;
if (from_touch && !params.selection_text.empty())
if (from_touch && !params.selection_text.empty()) {
return true;
}
rwhv_->selection_controller()->HideAndDisallowShowingAutomatically();
return false;
@@ -234,8 +236,9 @@ bool CefTouchSelectionControllerClientOSR::IsQuickMenuAvailable() const {
}
void CefTouchSelectionControllerClientOSR::CloseQuickMenu() {
if (!quick_menu_running_)
if (!quick_menu_running_) {
return;
}
quick_menu_running_ = false;
@@ -256,8 +259,9 @@ void CefTouchSelectionControllerClientOSR::ShowQuickMenu() {
auto client_bounds = gfx::RectF(rwhv_->GetViewBounds());
origin.SetToMax(client_bounds.origin());
bottom_right.SetToMin(client_bounds.bottom_right());
if (origin.x() > bottom_right.x() || origin.y() > bottom_right.y())
if (origin.x() > bottom_right.x() || origin.y() > bottom_right.y()) {
return;
}
gfx::Vector2dF diagonal = bottom_right - origin;
gfx::SizeF size(diagonal.x(), diagonal.y());

View File

@@ -56,8 +56,9 @@ void CefVideoConsumerOSR::SetFrameRate(base::TimeDelta frame_rate) {
}
void CefVideoConsumerOSR::SizeChanged(const gfx::Size& size_in_pixels) {
if (size_in_pixels_ == size_in_pixels)
if (size_in_pixels_ == size_in_pixels) {
return;
}
size_in_pixels_ = size_in_pixels;
// Capture resolution will be held constant.

View File

@@ -38,8 +38,9 @@ void CefWebContentsViewOSR::RenderViewCreated() {
auto host = web_contents_->GetRenderViewHost();
CefRenderWidgetHostViewOSR* view =
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
if (view)
if (view) {
view->InstallTransparency();
}
}
}
@@ -74,8 +75,9 @@ void CefWebContentsViewOSR::GotFocus(
if (web_contents_) {
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
if (web_contents_impl)
if (web_contents_impl) {
web_contents_impl->NotifyWebContentsFocused(render_widget_host);
}
}
}
@@ -84,14 +86,16 @@ void CefWebContentsViewOSR::LostFocus(
if (web_contents_) {
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
if (web_contents_impl)
if (web_contents_impl) {
web_contents_impl->NotifyWebContentsLostFocus(render_widget_host);
}
}
}
void CefWebContentsViewOSR::TakeFocus(bool reverse) {
if (web_contents_->GetDelegate())
if (web_contents_->GetDelegate()) {
web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse);
}
}
void CefWebContentsViewOSR::FullscreenStateChanged(bool is_fullscreen) {}
@@ -188,8 +192,9 @@ void CefWebContentsViewOSR::StartDragging(
void CefWebContentsViewOSR::UpdateDragCursor(
ui::mojom::DragOperation operation) {
CefRefPtr<AlloyBrowserHostImpl> browser = GetBrowser();
if (browser.get())
if (browser.get()) {
browser->UpdateDragCursor(operation);
}
}
CefRenderWidgetHostViewOSR* CefWebContentsViewOSR::GetView() const {
@@ -202,8 +207,9 @@ CefRenderWidgetHostViewOSR* CefWebContentsViewOSR::GetView() const {
AlloyBrowserHostImpl* CefWebContentsViewOSR::GetBrowser() const {
CefRenderWidgetHostViewOSR* view = GetView();
if (view)
if (view) {
return view->browser_impl().get();
}
return nullptr;
}