summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-17 22:04:50 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-17 22:04:50 +0000
commit98f8d9c1248dc678ef09af9436976ca5af72f42a (patch)
tree81bc7d0de54f586d15cdb978270b43c53afb64cf /chrome/browser/renderer_host
parent401efff5d553c57124790696503f0f06fff31344 (diff)
downloadchromium_src-98f8d9c1248dc678ef09af9436976ca5af72f42a.zip
chromium_src-98f8d9c1248dc678ef09af9436976ca5af72f42a.tar.gz
chromium_src-98f8d9c1248dc678ef09af9436976ca5af72f42a.tar.bz2
Significantly rework coordinate handling for the Cocoa views. Fixes tons of redraw and scrolling issues.
Review URL: http://codereview.chromium.org/20435 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h6
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm29
2 files changed, 20 insertions, 15 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index 073573d..a9221c9 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -8,18 +8,18 @@
#import <Cocoa/Cocoa.h>
#include "base/time.h"
-#include "chrome/browser/cocoa/event_view.h"
+#include "chrome/browser/cocoa/base_view.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "webkit/glue/webcursor.h"
class RenderWidgetHostViewMac;
-// This is the NSView that lives in the Cocoa view hierarchy. In Windows-land,
+// This is the view that lives in the Cocoa view hierarchy. In Windows-land,
// RenderWidgetHostViewWin is both the view and the delegate. We split the roles
// but that means that the view needs to own the delegate and will dispose of it
// when it's removed from the view system.
-@interface RenderWidgetHostViewCocoa : EventView {
+@interface RenderWidgetHostViewCocoa : BaseView {
@private
RenderWidgetHostViewMac* renderWidgetHostView_;
}
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 968f5e0..fd782e7 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -80,9 +80,7 @@ void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) {
if (is_hidden_)
return;
- NSRect rect = [cocoa_view_ frame];
- rect.size = NSSizeFromCGSize(size.ToCGSize());
- [cocoa_view_ setFrame:rect];
+ NOTIMPLEMENTED(); // Who is trying to force a size? We're a Cocoa view.
}
gfx::NativeView RenderWidgetHostViewMac::GetPluginNativeView() {
@@ -121,7 +119,7 @@ void RenderWidgetHostViewMac::Hide() {
}
gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const {
- return gfx::Rect(NSRectToCGRect([cocoa_view_ frame]));
+ return [cocoa_view_ NSRectToRect:[cocoa_view_ bounds]];
}
void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) {
@@ -159,7 +157,7 @@ void RenderWidgetHostViewMac::IMEUpdateStatus(int control,
}
void RenderWidgetHostViewMac::Redraw(const gfx::Rect& rect) {
- [cocoa_view_ setNeedsDisplayInRect:NSRectFromCGRect(rect.ToCGRect())];
+ [cocoa_view_ setNeedsDisplayInRect:[cocoa_view_ RectToNSRect:rect]];
}
void RenderWidgetHostViewMac::DidPaintRect(const gfx::Rect& rect) {
@@ -173,9 +171,14 @@ void RenderWidgetHostViewMac::DidScrollRect(
const gfx::Rect& rect, int dx, int dy) {
if (is_hidden_)
return;
+
+ [cocoa_view_ scrollRect:[cocoa_view_ RectToNSRect:rect]
+ by:NSMakeSize(dx, -dy)];
- [cocoa_view_ scrollRect:NSRectFromCGRect(rect.ToCGRect())
- by:NSMakeSize(dx, dy)];
+ gfx::Rect new_rect = rect;
+ new_rect.Offset(dx, dy);
+ gfx::Rect dirty_rect = rect.Subtract(new_rect);
+ [cocoa_view_ setNeedsDisplayInRect:[cocoa_view_ RectToNSRect:dirty_rect]];
}
void RenderWidgetHostViewMac::RendererGone() {
@@ -257,20 +260,22 @@ void RenderWidgetHostViewMac::ShutdownHost() {
skia::PlatformCanvas* canvas = backing_store->canvas();
if (backing_store) {
- gfx::Rect damaged_rect(NSRectToCGRect(dirtyRect));
+ gfx::Rect damaged_rect([self NSRectToRect:dirtyRect]);
- gfx::Rect bitmap_rect(
- 0, 0, backing_store->size().width(), backing_store->size().height());
+ gfx::Rect bitmap_rect(0, 0,
+ backing_store->size().width(),
+ backing_store->size().height());
gfx::Rect paint_rect = bitmap_rect.Intersect(damaged_rect);
if (!paint_rect.IsEmpty()) {
if ([self lockFocusIfCanDraw]) {
CGContextRef context = static_cast<CGContextRef>(
[[NSGraphicsContext currentContext] graphicsPort]);
-
+
CGRect damaged_rect_cg = damaged_rect.ToCGRect();
+ NSRect damaged_rect_ns = [self RectToNSRect:damaged_rect];
canvas->getTopPlatformDevice().DrawToContext(
- context, damaged_rect.x(), damaged_rect.y(),
+ context, damaged_rect_ns.origin.x, damaged_rect_ns.origin.y,
&damaged_rect_cg);
[self unlockFocus];