Commit c1036c00 authored by bsep's avatar bsep Committed by Commit bot

Update conditional in BrowserNonClientFrameView::DoesIntersectRect.

As per crrev.com/2283253002#msg37 this patch updates one of the
conditional branches BrowserNonClientFrameView::DoesIntersectRect to
return true if a large hit-test rectangle overlaps both the tabstrip and
the client area.

Review-Url: https://codereview.chromium.org/2775083002
Cr-Commit-Position: refs/heads/master@{#460511}
parent 325508e9
...@@ -209,7 +209,7 @@ bool BrowserNonClientFrameView::DoesIntersectRect(const views::View* target, ...@@ -209,7 +209,7 @@ bool BrowserNonClientFrameView::DoesIntersectRect(const views::View* target,
View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f);
gfx::Rect rect_in_tabstrip_coords = gfx::Rect rect_in_tabstrip_coords =
gfx::ToEnclosingRect(rect_in_tabstrip_coords_f); gfx::ToEnclosingRect(rect_in_tabstrip_coords_f);
if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { if (rect_in_tabstrip_coords.y() >= tabstrip->GetLocalBounds().bottom()) {
// |rect| is below the tabstrip. // |rect| is below the tabstrip.
return false; return false;
} }
......
...@@ -7,13 +7,14 @@ ...@@ -7,13 +7,14 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/test_with_browser_view.h" #include "chrome/browser/ui/views/frame/test_with_browser_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "url/gurl.h" #include "url/gurl.h"
class BrowserNonClientFrameViewTest : public TestWithBrowserView { class BrowserNonClientFrameViewTest : public TestWithBrowserView {
public: public:
BrowserNonClientFrameViewTest() explicit BrowserNonClientFrameViewTest(Browser::Type type)
: TestWithBrowserView(Browser::TYPE_POPUP, false), frame_view_(nullptr) {} : TestWithBrowserView(type, false), frame_view_(nullptr) {}
// TestWithBrowserView override: // TestWithBrowserView override:
void SetUp() override { void SetUp() override {
...@@ -36,7 +37,14 @@ class BrowserNonClientFrameViewTest : public TestWithBrowserView { ...@@ -36,7 +37,14 @@ class BrowserNonClientFrameViewTest : public TestWithBrowserView {
DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewTest); DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewTest);
}; };
TEST_F(BrowserNonClientFrameViewTest, HitTestTopChrome) { class BrowserNonClientFrameViewPopupTest
: public BrowserNonClientFrameViewTest {
public:
BrowserNonClientFrameViewPopupTest()
: BrowserNonClientFrameViewTest(Browser::TYPE_POPUP) {}
};
TEST_F(BrowserNonClientFrameViewPopupTest, HitTestPopupTopChrome) {
EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(-1, 4, 1, 1))); EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(-1, 4, 1, 1)));
EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(4, -1, 1, 1))); EXPECT_FALSE(frame_view_->HitTestRect(gfx::Rect(4, -1, 1, 1)));
const int top_inset = frame_view_->GetTopInset(false); const int top_inset = frame_view_->GetTopInset(false);
...@@ -44,3 +52,30 @@ TEST_F(BrowserNonClientFrameViewTest, HitTestTopChrome) { ...@@ -44,3 +52,30 @@ TEST_F(BrowserNonClientFrameViewTest, HitTestTopChrome) {
if (top_inset > 0) if (top_inset > 0)
EXPECT_TRUE(frame_view_->HitTestRect(gfx::Rect(4, top_inset - 1, 1, 1))); EXPECT_TRUE(frame_view_->HitTestRect(gfx::Rect(4, top_inset - 1, 1, 1)));
} }
class BrowserNonClientFrameViewTabbedTest
: public BrowserNonClientFrameViewTest {
public:
BrowserNonClientFrameViewTabbedTest()
: BrowserNonClientFrameViewTest(Browser::TYPE_TABBED) {}
};
TEST_F(BrowserNonClientFrameViewTabbedTest, HitTestTabstrip) {
gfx::Rect tabstrip_bounds =
frame_view_->browser_view()->tabstrip()->GetLocalBounds();
EXPECT_FALSE(tabstrip_bounds.IsEmpty());
// Completely outside bounds.
EXPECT_FALSE(frame_view_->HitTestRect(
gfx::Rect(tabstrip_bounds.x() - 1, tabstrip_bounds.y() + 1, 1, 1)));
EXPECT_FALSE(frame_view_->HitTestRect(
gfx::Rect(tabstrip_bounds.x() + 1, tabstrip_bounds.y() - 1, 1, 1)));
// Hits tab strip but not client area.
EXPECT_TRUE(frame_view_->HitTestRect(
gfx::Rect(tabstrip_bounds.x() + 1, tabstrip_bounds.bottom() - 1, 1, 1)));
// Hits tab strip and client area.
EXPECT_TRUE(frame_view_->HitTestRect(gfx::Rect(
tabstrip_bounds.x() + 1, tabstrip_bounds.bottom() - 1, 100, 100)));
}
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