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:
@@ -35,32 +35,40 @@ PopupLayer::PopupLayer(const std::shared_ptr<d3d11::Device>& device)
|
||||
|
||||
void PopupLayer::set_bounds(const CefRect& bounds) {
|
||||
const auto comp = composition();
|
||||
if (!comp)
|
||||
if (!comp) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto outer_width = comp->width();
|
||||
const auto outer_height = comp->height();
|
||||
if (outer_width == 0 || outer_height == 0)
|
||||
if (outer_width == 0 || outer_height == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
original_bounds_ = bounds;
|
||||
bounds_ = bounds;
|
||||
|
||||
// If x or y are negative, move them to 0.
|
||||
if (bounds_.x < 0)
|
||||
if (bounds_.x < 0) {
|
||||
bounds_.x = 0;
|
||||
if (bounds_.y < 0)
|
||||
}
|
||||
if (bounds_.y < 0) {
|
||||
bounds_.y = 0;
|
||||
}
|
||||
// If popup goes outside the view, try to reposition origin
|
||||
if (bounds_.x + bounds_.width > outer_width)
|
||||
if (bounds_.x + bounds_.width > outer_width) {
|
||||
bounds_.x = outer_width - bounds_.width;
|
||||
if (bounds_.y + bounds_.height > outer_height)
|
||||
}
|
||||
if (bounds_.y + bounds_.height > outer_height) {
|
||||
bounds_.y = outer_height - bounds_.height;
|
||||
}
|
||||
// If x or y became negative, move them to 0 again.
|
||||
if (bounds_.x < 0)
|
||||
if (bounds_.x < 0) {
|
||||
bounds_.x = 0;
|
||||
if (bounds_.y < 0)
|
||||
}
|
||||
if (bounds_.y < 0) {
|
||||
bounds_.y = 0;
|
||||
}
|
||||
|
||||
const auto x = bounds_.x / float(outer_width);
|
||||
const auto y = bounds_.y / float(outer_height);
|
||||
@@ -82,14 +90,16 @@ bool OsrRenderHandlerWinD3D11::Initialize(CefRefPtr<CefBrowser> browser,
|
||||
// Create a D3D11 device instance.
|
||||
device_ = d3d11::Device::create();
|
||||
DCHECK(device_);
|
||||
if (!device_)
|
||||
if (!device_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a D3D11 swapchain for the window.
|
||||
swap_chain_ = device_->create_swapchain(hwnd());
|
||||
DCHECK(swap_chain_);
|
||||
if (!swap_chain_)
|
||||
if (!swap_chain_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the browser layer.
|
||||
browser_layer_ = std::make_shared<BrowserLayer>(device_);
|
||||
@@ -124,15 +134,17 @@ bool OsrRenderHandlerWinD3D11::IsOverPopupWidget(int x, int y) const {
|
||||
|
||||
int OsrRenderHandlerWinD3D11::GetPopupXOffset() const {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
if (popup_layer_)
|
||||
if (popup_layer_) {
|
||||
return popup_layer_->xoffset();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OsrRenderHandlerWinD3D11::GetPopupYOffset() const {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
if (popup_layer_)
|
||||
if (popup_layer_) {
|
||||
return popup_layer_->yoffset();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user