Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm

Issue 2622613002: Revert of [Mac] Flip toolbar in RTL (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm
index 3bf1e041fff697b21e4642510cff311f42c2135f..97ed1a6ea1085fd73592af01ce133792e3657b81 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm
@@ -7,7 +7,6 @@
#include <algorithm>
#include <utility>
-#import "chrome/browser/ui/cocoa/l10n_util.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
#include "ui/base/cocoa/appkit_utils.h"
#include "ui/events/keycodes/keyboard_code_conversion_mac.h"
@@ -59,9 +58,6 @@
- (id)initWithFrame:(NSRect)frameRect {
if ((self = [super initWithFrame:frameRect])) {
grippyRect_ = NSMakeRect(0.0, 0.0, kGrippyWidth, NSHeight([self bounds]));
- if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout())
- grippyRect_.origin.x = NSWidth(frameRect) - NSWidth(grippyRect_);
-
canDragLeft_ = YES;
canDragRight_ = YES;
resizable_ = YES;
@@ -166,8 +162,6 @@
}
- (void)resetCursorRects {
- if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout())
- grippyRect_.origin.x = NSWidth([self frame]) - NSWidth(grippyRect_);
[self addCursorRect:grippyRect_ cursor:[self appropriateCursorForGrippy]];
}
@@ -220,29 +214,23 @@
NSRect containerFrame = [self frame];
CGFloat dX = [theEvent deltaX];
CGFloat withDelta = location.x - dX;
- BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout();
-
+ canDragRight_ = (withDelta >= initialDragPoint_.x) &&
+ (NSWidth(containerFrame) > kMinimumContainerWidth);
CGFloat maxAllowedWidth = [self maxAllowedWidth];
-
- const CGFloat maxWidth = std::min(maxAllowedWidth, maxDesiredWidth_);
- CGFloat newWidth = NSWidth(containerFrame) + (isRTL ? dX : -dX);
- newWidth = std::min(std::max(newWidth, kMinimumContainerWidth), maxWidth);
-
- BOOL canGrow = NSWidth(containerFrame) < maxWidth;
- BOOL canShrink = NSWidth(containerFrame) > kMinimumContainerWidth;
-
- canDragLeft_ =
- withDelta <= initialDragPoint_.x && (isRTL ? canShrink : canGrow);
- canDragRight_ =
- (withDelta >= initialDragPoint_.x) && (isRTL ? canGrow : canShrink);
- if ((dX < 0.0 && !canDragLeft_) || (dX > 0.0 && !canDragRight_) ||
- fabs(dX) < FLT_EPSILON)
- return;
-
- grippyPinned_ = newWidth >= maxAllowedWidth;
- if (!isRTL)
- containerFrame.origin.x += dX;
- containerFrame.size.width = newWidth;
+ containerFrame.size.width =
+ std::max(NSWidth(containerFrame) - dX, kMinimumContainerWidth);
+ canDragLeft_ = withDelta <= initialDragPoint_.x &&
+ NSWidth(containerFrame) < maxDesiredWidth_ &&
+ NSWidth(containerFrame) < maxAllowedWidth;
+
+ if ((dX < 0.0 && !canDragLeft_) || (dX > 0.0 && !canDragRight_))
+ return;
+
+ if (NSWidth(containerFrame) <= kMinimumContainerWidth)
+ return;
+
+ grippyPinned_ = NSWidth(containerFrame) >= maxAllowedWidth;
+ containerFrame.origin.x += dX;
[self setFrame:containerFrame];
[self setNeedsDisplay:YES];
@@ -283,18 +271,14 @@
- (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate {
width = std::max(width, kMinimumContainerWidth);
- NSRect newFrame = [self frame];
+ NSRect frame = [self frame];
CGFloat maxAllowedWidth = [self maxAllowedWidth];
width = std::min(maxAllowedWidth, width);
- if (cocoa_l10n_util::ShouldDoExperimentalRTLLayout()) {
- newFrame.size.width = width;
- } else {
- CGFloat dX = NSWidth(newFrame) - width;
- newFrame.size.width = width;
- newFrame.origin.x += dX;
- }
+ CGFloat dX = frame.size.width - width;
+ frame.size.width = width;
+ NSRect newFrame = NSOffsetRect(frame, dX, 0);
grippyPinned_ = width == maxAllowedWidth;
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698