Commit a0966b4c authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

Revert "Ensure that devtools stays visible when window is made smaller."

This reverts commit bb86e3cd.

Reason for revert: <crbug.com/1135885>

Original change's description:
> Ensure that devtools stays visible when window is made smaller.
>
> Original CL - https://chromium-review.googlesource.com/c/chromium/src/+/1665550
>
> Bug: 974178
> Change-Id: I5792cbd065d1437de2fa44d43407eb70e7b22960
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2447094
> Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
> Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#814196}

TBR=caseq@chromium.org,davidbienvenu@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 974178
Change-Id: Idbfcdf1170a60d940d3989d2b0f9bc8e84f74129
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462639Reviewed-by: default avatarDavid Bienvenu <davidbienvenu@chromium.org>
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815631}
parent 15eae87d
...@@ -6,30 +6,28 @@ ...@@ -6,30 +6,28 @@
#include <algorithm> #include <algorithm>
#include "base/check_op.h" DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy()
: hide_inspected_contents_(false) {
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy() = default; }
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy( DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy(
const gfx::Rect& bounds, const gfx::Rect& bounds)
bool is_docked)
: bounds_(bounds), : bounds_(bounds),
hide_inspected_contents_(bounds_.IsEmpty() && !bounds_.x() && hide_inspected_contents_(bounds_.IsEmpty() && !bounds_.x() &&
!bounds_.y()), !bounds_.y()) {
is_docked_(is_docked) {} }
void DevToolsContentsResizingStrategy::CopyFrom( void DevToolsContentsResizingStrategy::CopyFrom(
const DevToolsContentsResizingStrategy& strategy) { const DevToolsContentsResizingStrategy& strategy) {
bounds_ = strategy.bounds(); bounds_ = strategy.bounds();
hide_inspected_contents_ = strategy.hide_inspected_contents(); hide_inspected_contents_ = strategy.hide_inspected_contents();
is_docked_ = strategy.is_docked();
} }
bool DevToolsContentsResizingStrategy::Equals( bool DevToolsContentsResizingStrategy::Equals(
const DevToolsContentsResizingStrategy& strategy) { const DevToolsContentsResizingStrategy& strategy) {
return bounds_ == strategy.bounds() && return bounds_ == strategy.bounds() &&
hide_inspected_contents_ == strategy.hide_inspected_contents() && hide_inspected_contents_ == strategy.hide_inspected_contents();
is_docked_ == strategy.is_docked();
} }
void ApplyDevToolsContentsResizingStrategy( void ApplyDevToolsContentsResizingStrategy(
...@@ -41,7 +39,6 @@ void ApplyDevToolsContentsResizingStrategy( ...@@ -41,7 +39,6 @@ void ApplyDevToolsContentsResizingStrategy(
0, 0, container_size.width(), container_size.height()); 0, 0, container_size.width(), container_size.height());
const gfx::Rect& bounds = strategy.bounds(); const gfx::Rect& bounds = strategy.bounds();
if (bounds.size().IsEmpty() && !strategy.hide_inspected_contents()) { if (bounds.size().IsEmpty() && !strategy.hide_inspected_contents()) {
new_contents_bounds->SetRect( new_contents_bounds->SetRect(
0, 0, container_size.width(), container_size.height()); 0, 0, container_size.width(), container_size.height());
...@@ -52,17 +49,5 @@ void ApplyDevToolsContentsResizingStrategy( ...@@ -52,17 +49,5 @@ void ApplyDevToolsContentsResizingStrategy(
int top = std::min(bounds.y(), container_size.height()); int top = std::min(bounds.y(), container_size.height());
int width = std::min(bounds.width(), container_size.width() - left); int width = std::min(bounds.width(), container_size.width() - left);
int height = std::min(bounds.height(), container_size.height() - top); int height = std::min(bounds.height(), container_size.height() - top);
if (strategy.is_docked()) {
// Devtools console requires at least 240 pixels when docked.
// https://cs.chromium.org/chromium/src/third_party/blink/renderer/devtools/front_end/ui/InspectorView.js?l=38&rcl=f8763532a3fe4f7d028f4cb23f56b289efbb70c0
constexpr int kDevtoolsMinWidth = 240;
const int available_width = container_size.width() - left - width;
DCHECK_GE(available_width, 0);
if (available_width < kDevtoolsMinWidth) {
const int width_adjustment = kDevtoolsMinWidth - available_width;
width -= width_adjustment;
}
}
new_contents_bounds->SetRect(left, top, width, height); new_contents_bounds->SetRect(left, top, width, height);
} }
...@@ -15,24 +15,21 @@ ...@@ -15,24 +15,21 @@
class DevToolsContentsResizingStrategy { class DevToolsContentsResizingStrategy {
public: public:
DevToolsContentsResizingStrategy(); DevToolsContentsResizingStrategy();
DevToolsContentsResizingStrategy(const gfx::Rect& bounds, bool is_docked); explicit DevToolsContentsResizingStrategy(
const gfx::Rect& bounds);
void CopyFrom(const DevToolsContentsResizingStrategy& strategy); void CopyFrom(const DevToolsContentsResizingStrategy& strategy);
bool Equals(const DevToolsContentsResizingStrategy& strategy); bool Equals(const DevToolsContentsResizingStrategy& strategy);
const gfx::Rect& bounds() const { return bounds_; } const gfx::Rect& bounds() const { return bounds_; }
bool hide_inspected_contents() const { return hide_inspected_contents_; } bool hide_inspected_contents() const { return hide_inspected_contents_; }
bool is_docked() const { return is_docked_; }
private: private:
// Contents bounds. When non-empty, used instead of insets. // Contents bounds. When non-empty, used instead of insets.
gfx::Rect bounds_; gfx::Rect bounds_;
// Whether inspected contents is hidden. // Determines whether inspected contents is visible.
bool hide_inspected_contents_ = false; bool hide_inspected_contents_;
// Whether devtools is docked.
bool is_docked_ = false;
DISALLOW_COPY_AND_ASSIGN(DevToolsContentsResizingStrategy); DISALLOW_COPY_AND_ASSIGN(DevToolsContentsResizingStrategy);
}; };
......
...@@ -1360,7 +1360,7 @@ void DevToolsWindow::Inspect(scoped_refptr<content::DevToolsAgentHost> host) { ...@@ -1360,7 +1360,7 @@ void DevToolsWindow::Inspect(scoped_refptr<content::DevToolsAgentHost> host) {
} }
void DevToolsWindow::SetInspectedPageBounds(const gfx::Rect& rect) { void DevToolsWindow::SetInspectedPageBounds(const gfx::Rect& rect) {
DevToolsContentsResizingStrategy strategy(rect, is_docked_); DevToolsContentsResizingStrategy strategy(rect);
if (contents_resizing_strategy_.Equals(strategy)) if (contents_resizing_strategy_.Equals(strategy))
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment