Skip to content

Commit

Permalink
Remove mirror_{arrows,client}_in_rtl
Browse files Browse the repository at this point in the history
AFAICT, post-Mac views this is always true.

This is cleanup for removing the MacRTL flag.

Change-Id: I35de9ddf6dd8f89ec90d427915917945a2164347
Reviewed-on: https://chromium-review.googlesource.com/c/1344191
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611285}
  • Loading branch information
speednoisemovement authored and Commit Bot committed Nov 27, 2018
1 parent 94853e6 commit d603432
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 63 deletions.
4 changes: 0 additions & 4 deletions chrome/browser/ui/views/chrome_views_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ class ChromeViewsDelegate : public views::ViewsDelegate {
ui::ContextFactoryPrivate* GetContextFactoryPrivate() override;
std::string GetApplicationName() override;

#if defined(OS_MACOSX)
bool ShouldMirrorArrowsInRTL() const override;
#endif

private:
#if defined(OS_WIN)
typedef std::map<HMONITOR, int> AppbarAutohideEdgeMap;
Expand Down
4 changes: 0 additions & 4 deletions chrome/browser/ui/views/chrome_views_delegate_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ views::NativeWidget* ChromeViewsDelegate::CreateNativeWidget(
// By returning null Widget creates the default NativeWidget implementation.
return nullptr;
}

bool ChromeViewsDelegate::ShouldMirrorArrowsInRTL() const {
return base::FeatureList::IsEnabled(features::kMacRTL);
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView(

set_close_on_deactivate(false);

#if defined(OS_MACOSX)
// On Mac, the browser UI flips depending on a runtime feature. TODO(tapted):
// Change the default in views::PlatformStyle when features::kMacRTL launches,
// and remove the following.
if (base::FeatureList::IsEnabled(features::kMacRTL))
set_mirror_arrow_in_rtl(true);
#endif

ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::kVertical, gfx::Insets(),
Expand Down
6 changes: 1 addition & 5 deletions ui/views/bubble/bubble_dialog_delegate_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "ui/views/layout/layout_manager.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/view_properties.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/views/window/dialog_client_view.h"
Expand Down Expand Up @@ -134,7 +133,6 @@ bool BubbleDialogDelegateView::ShouldShowCloseButton() const {

ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) {
DialogClientView* client = new DialogClientView(widget, GetContentsView());
widget->non_client_view()->set_mirror_client_in_rtl(mirror_arrow_in_rtl_);
return client;
}

Expand All @@ -148,7 +146,7 @@ NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView(
frame->SetFootnoteView(CreateFootnoteView());

BubbleBorder::Arrow adjusted_arrow = arrow();
if (base::i18n::IsRTL() && mirror_arrow_in_rtl_)
if (base::i18n::IsRTL())
adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow);
std::unique_ptr<BubbleBorder> border =
std::make_unique<BubbleBorder>(adjusted_arrow, GetShadow(), color());
Expand Down Expand Up @@ -275,8 +273,6 @@ BubbleDialogDelegateView::BubbleDialogDelegateView(View* anchor_view,
anchor_view_tracker_(std::make_unique<ViewTracker>()),
anchor_widget_(nullptr),
arrow_(arrow),
mirror_arrow_in_rtl_(
ViewsDelegate::GetInstance()->ShouldMirrorArrowsInRTL()),
shadow_(shadow),
color_explicitly_set_(false),
accept_events_(true),
Expand Down
5 changes: 0 additions & 5 deletions ui/views/bubble/bubble_dialog_delegate_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView,
BubbleBorder::Arrow arrow() const { return arrow_; }
void SetArrow(BubbleBorder::Arrow arrow);

void set_mirror_arrow_in_rtl(bool mirror) { mirror_arrow_in_rtl_ = mirror; }

BubbleBorder::Shadow GetShadow() const;
void set_shadow(BubbleBorder::Shadow shadow) { shadow_ = shadow; }

Expand Down Expand Up @@ -205,9 +203,6 @@ class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView,
// The arrow's location on the bubble.
BubbleBorder::Arrow arrow_;

// Automatically mirror the arrow in RTL layout.
bool mirror_arrow_in_rtl_;

// Bubble border shadow to use.
BubbleBorder::Shadow shadow_;

Expand Down
19 changes: 0 additions & 19 deletions ui/views/bubble/bubble_dialog_delegate_view_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,6 @@ TEST_F(BubbleDialogDelegateViewTest, CreateDelegate) {
EXPECT_TRUE(bubble_observer.widget_closed());
}

TEST_F(BubbleDialogDelegateViewTest, MirrorArrowInRtl) {
std::string default_locale = base::i18n::GetConfiguredLocale();
std::unique_ptr<Widget> anchor_widget(CreateTestWidget());
for (bool rtl : {false, true}) {
base::i18n::SetICUDefaultLocale(rtl ? "he" : "en");
EXPECT_EQ(rtl, base::i18n::IsRTL());
for (bool mirror : {false, true}) {
TestBubbleDialogDelegateView* bubble =
new TestBubbleDialogDelegateView(anchor_widget->GetContentsView());
bubble->set_mirror_arrow_in_rtl(mirror);
BubbleDialogDelegateView::CreateBubble(bubble);
EXPECT_EQ(rtl && mirror ? BubbleBorder::horizontal_mirror(bubble->arrow())
: bubble->arrow(),
bubble->GetBubbleFrameView()->bubble_border()->arrow());
}
}
base::i18n::SetICUDefaultLocale(default_locale);
}

TEST_F(BubbleDialogDelegateViewTest, CloseAnchorWidget) {
std::unique_ptr<Widget> anchor_widget(CreateTestWidget());
BubbleDialogDelegateView* bubble_delegate =
Expand Down
4 changes: 0 additions & 4 deletions ui/views/views_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ int ViewsDelegate::GetAppbarAutohideEdges(HMONITOR monitor,
}
#endif

bool ViewsDelegate::ShouldMirrorArrowsInRTL() const {
return true;
}

#if defined(USE_AURA)
void ViewsDelegate::SetTouchSelectionMenuRunner(
std::unique_ptr<TouchSelectionMenuRunnerViews> menu_runner) {
Expand Down
4 changes: 0 additions & 4 deletions ui/views/views_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@ class VIEWS_EXPORT ViewsDelegate {
const base::Closure& callback);
#endif

// Whether to mirror the arrow of bubble dialogs in RTL, such that the bubble
// opens in the opposite direction.
virtual bool ShouldMirrorArrowsInRTL() const;

protected:
ViewsDelegate();

Expand Down
5 changes: 0 additions & 5 deletions ui/views/window/non_client_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ bool NonClientFrameView::GetClientMask(const gfx::Size& size,

NonClientView::NonClientView()
: client_view_(nullptr),
mirror_client_in_rtl_(true),
overlay_view_(nullptr) {
SetEventTargeter(
std::unique_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
Expand Down Expand Up @@ -166,10 +165,6 @@ void NonClientView::Layout() {
// Then layout the ClientView, using those bounds.
gfx::Rect client_bounds = frame_view_->GetBoundsForClientView();

// RTL code will mirror the ClientView in the frame by default. If this isn't
// desired, do a second mirror here to get the standard LTR position.
if (base::i18n::IsRTL() && !mirror_client_in_rtl_)
client_bounds.set_x(GetMirroredXForRect(client_bounds));

if (client_bounds != client_view_->bounds()) {
client_view_->SetBoundsRect(client_bounds);
Expand Down
5 changes: 0 additions & 5 deletions ui/views/window/non_client_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ class VIEWS_EXPORT NonClientView : public View, public ViewTargeterDelegate {
client_view_ = client_view;
}

void set_mirror_client_in_rtl(bool mirror) { mirror_client_in_rtl_ = mirror; }

// Layout just the frame view. This is necessary on Windows when non-client
// metrics such as the position of the window controls changes independently
// of a window resize message.
Expand Down Expand Up @@ -251,9 +249,6 @@ class VIEWS_EXPORT NonClientView : public View, public ViewTargeterDelegate {
// implementation.
ClientView* client_view_;

// Set to false if client_view_ position shouldn't be mirrored in RTL.
bool mirror_client_in_rtl_;

// The NonClientFrameView that renders the non-client portions of the window.
// This object is not owned by the view hierarchy because it can be replaced
// dynamically as the system settings change.
Expand Down

0 comments on commit d603432

Please sign in to comment.