diff options
-rw-r--r-- | chrome/browser/cocoa/base_view.h | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/base_view.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/base_view_unittest.mm | 6 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_mac.mm | 25 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_view_mac.mm | 4 |
5 files changed, 22 insertions, 21 deletions
diff --git a/chrome/browser/cocoa/base_view.h b/chrome/browser/cocoa/base_view.h index 552af75..c3d49fd 100644 --- a/chrome/browser/cocoa/base_view.h +++ b/chrome/browser/cocoa/base_view.h @@ -30,8 +30,8 @@ - (void)keyEvent:(NSEvent *)theEvent; // Useful rect conversions (doing coordinate flipping) -- (gfx::Rect)NSRectToRect:(NSRect)rect; -- (NSRect)RectToNSRect:(gfx::Rect)rect; +- (gfx::Rect)flipNSRectToRect:(NSRect)rect; +- (NSRect)flipRectToNSRect:(gfx::Rect)rect; @end diff --git a/chrome/browser/cocoa/base_view.mm b/chrome/browser/cocoa/base_view.mm index cee8951..4c9f999 100644 --- a/chrome/browser/cocoa/base_view.mm +++ b/chrome/browser/cocoa/base_view.mm @@ -127,13 +127,13 @@ [self keyEvent:theEvent]; } -- (gfx::Rect)NSRectToRect:(NSRect)rect { +- (gfx::Rect)flipNSRectToRect:(NSRect)rect { gfx::Rect new_rect(NSRectToCGRect(rect)); new_rect.set_y([self bounds].size.height - new_rect.y() - new_rect.height()); return new_rect; } -- (NSRect)RectToNSRect:(gfx::Rect)rect { +- (NSRect)flipRectToNSRect:(gfx::Rect)rect { NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); new_rect.origin.y = [self bounds].size.height - new_rect.origin.y - new_rect.size.height; diff --git a/chrome/browser/cocoa/base_view_unittest.mm b/chrome/browser/cocoa/base_view_unittest.mm index bbfc75e..ff97571 100644 --- a/chrome/browser/cocoa/base_view_unittest.mm +++ b/chrome/browser/cocoa/base_view_unittest.mm @@ -29,16 +29,16 @@ TEST_VIEW(BaseViewTest, view_) // Convert a rect in |view_|'s Cocoa coordinate system to gfx::Rect's top-left // coordinate system. Repeat the process in reverse and make sure we come out // with the original rect. -TEST_F(BaseViewTest, NSRectToRect) { +TEST_F(BaseViewTest, flipNSRectToRect) { NSRect convert = NSMakeRect(10, 10, 50, 50); - gfx::Rect converted = [view_ NSRectToRect:convert]; + gfx::Rect converted = [view_ flipNSRectToRect:convert]; EXPECT_EQ(converted.x(), 10); EXPECT_EQ(converted.y(), 40); // Due to view being 100px tall. EXPECT_EQ(converted.width(), convert.size.width); EXPECT_EQ(converted.height(), convert.size.height); // Go back the other way. - NSRect back_again = [view_ RectToNSRect:converted]; + NSRect back_again = [view_ flipRectToNSRect:converted]; EXPECT_EQ(back_again.origin.x, convert.origin.x); EXPECT_EQ(back_again.origin.y, convert.origin.y); EXPECT_EQ(back_again.size.width, convert.size.width); diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index fd7fea8..d788899 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -454,10 +454,11 @@ void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) { // superview is another RenderWidgetHostViewCocoa, but even if it's directly // in a TabContentsViewCocoa, they're both BaseViews. gfx::Rect rect = - [(BaseView*)[cocoa_view_ superview] NSRectToRect:[cocoa_view_ frame]]; + [(BaseView*)[cocoa_view_ superview] flipNSRectToRect:[cocoa_view_ frame]]; rect.set_width(size.width()); rect.set_height(size.height()); - [cocoa_view_ setFrame:[(BaseView*)[cocoa_view_ superview] RectToNSRect:rect]]; + [cocoa_view_ setFrame: + [(BaseView*)[cocoa_view_ superview] flipRectToNSRect:rect]]; } gfx::NativeView RenderWidgetHostViewMac::GetNativeView() { @@ -495,7 +496,7 @@ void RenderWidgetHostViewMac::MovePluginWindows( if (plugin_views_.end() == it) { continue; } - NSRect new_rect([cocoa_view_ RectToNSRect:rect]); + NSRect new_rect([cocoa_view_ flipRectToNSRect:rect]); [it->second setFrame:new_rect]; [it->second setNeedsDisplay:YES]; @@ -536,7 +537,7 @@ bool RenderWidgetHostViewMac::IsShowing() { } gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const { - return [cocoa_view_ NSRectToRect:[cocoa_view_ bounds]]; + return [cocoa_view_ flipNSRectToRect:[cocoa_view_ bounds]]; } void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) { @@ -582,7 +583,7 @@ void RenderWidgetHostViewMac::ImeUpdateTextInputState( // whose origin is the upper-left corner of this view. On the other hand, // Cocoa uses a coordinate system whose origin is the lower-left corner of // this view. So, we convert the cursor rectangle and save it. - [cocoa_view_ setCaretRect:[cocoa_view_ RectToNSRect:caret_rect]]; + [cocoa_view_ setCaretRect:[cocoa_view_ flipRectToNSRect:caret_rect]]; } void RenderWidgetHostViewMac::ImeCancelComposition() { @@ -603,7 +604,7 @@ void RenderWidgetHostViewMac::DidUpdateBackingStore( rects.push_back(scroll_rect); for (size_t i = 0; i < rects.size(); ++i) { - NSRect ns_rect = [cocoa_view_ RectToNSRect:rects[i]]; + NSRect ns_rect = [cocoa_view_ flipRectToNSRect:rects[i]]; if (about_to_validate_and_paint_) { // As much as we'd like to use -setNeedsDisplayInRect: here, we can't. @@ -960,7 +961,7 @@ namespace { // Adjusts an NSRect in Cocoa screen coordinates to have an origin in the upper // left of the primary screen (Carbon coordinates), and stuffs it into a // gfx::Rect. -gfx::Rect NSRectToRect(const NSRect rect) { +gfx::Rect flipNSRectToRect(const NSRect rect) { gfx::Rect new_rect(NSRectToCGRect(rect)); if ([[NSScreen screens] count] > 0) { new_rect.set_y([[[NSScreen screens] objectAtIndex:0] frame].size.height - @@ -1003,7 +1004,7 @@ gfx::Rect RenderWidgetHostViewMac::GetWindowRect() { NSRect bounds = [cocoa_view_ bounds]; bounds = [cocoa_view_ convertRect:bounds toView:nil]; bounds.origin = [enclosing_window convertBaseToScreen:bounds.origin]; - return NSRectToRect(bounds); + return flipNSRectToRect(bounds); } gfx::Rect RenderWidgetHostViewMac::GetRootWindowRect() { @@ -1015,7 +1016,7 @@ gfx::Rect RenderWidgetHostViewMac::GetRootWindowRect() { return gfx::Rect(); NSRect bounds = [enclosing_window frame]; - return NSRectToRect(bounds); + return flipNSRectToRect(bounds); } void RenderWidgetHostViewMac::SetActive(bool active) { @@ -1458,7 +1459,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { if (backing_store) { NSRect view_bounds = [self bounds]; - gfx::Rect damaged_rect([self NSRectToRect:dirtyRect]); + gfx::Rect damaged_rect([self flipNSRectToRect:dirtyRect]); gfx::Rect bitmap_rect(0, 0, backing_store->size().width(), @@ -1511,7 +1512,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { height = -height; } - NSRect r = [self RectToNSRect:gfx::Rect(x, y, width, height)]; + NSRect r = [self flipRectToNSRect:gfx::Rect(x, y, width, height)]; [[NSColor whiteColor] set]; NSRectFill(r); } @@ -1532,7 +1533,7 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { height = -height; } - NSRect r = [self RectToNSRect:gfx::Rect(x, y, width, height)]; + NSRect r = [self flipRectToNSRect:gfx::Rect(x, y, width, height)]; [[NSColor whiteColor] set]; NSRectFill(r); } diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm index 6d3b158..c4af811 100644 --- a/chrome/browser/tab_contents/tab_contents_view_mac.mm +++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm @@ -127,7 +127,7 @@ gfx::NativeWindow TabContentsViewMac::GetTopLevelNativeWindow() const { } void TabContentsViewMac::GetContainerBounds(gfx::Rect* out) const { - *out = [cocoa_view_.get() NSRectToRect:[cocoa_view_.get() bounds]]; + *out = [cocoa_view_.get() flipNSRectToRect:[cocoa_view_.get() bounds]]; } void TabContentsViewMac::StartDragging( @@ -182,7 +182,7 @@ void TabContentsViewMac::SizeContents(const gfx::Size& size) { // See tab_contents_view.h. gfx::Rect rect(gfx::Point(), size); TabContentsViewCocoa* view = cocoa_view_.get(); - [view setFrame:[view RectToNSRect:rect]]; + [view setFrame:[view flipRectToNSRect:rect]]; } void TabContentsViewMac::Focus() { |