From 3ff4846c1a7d1b85624f5c1ced2df8637b0bd1e3 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 21 Nov 2014 11:48:43 +0000 Subject: Remove usage of browser private interfaces The cocoa frontend was directly acessing browser internals instead of using the API. In the case of gui.m there was a check for the browser window not being root (browser->parent != NULL) . As gui windows can only ever be associated with the root brower window (i.e. its parent will always be NULL) this was completely redundant. --- cocoa/BrowserView.m | 19 ++++++++++--------- cocoa/gui.m | 4 +--- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'cocoa') diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m index e8567f056..e9d6ddd28 100644 --- a/cocoa/BrowserView.m +++ b/cocoa/BrowserView.m @@ -23,7 +23,7 @@ #import "cocoa/LocalHistoryController.h" #import "cocoa/BrowserWindowController.h" -#import "desktop/browser_private.h" +#import "desktop/browser.h" #import "desktop/plotters.h" #import "desktop/textinput.h" #import "utils/nsoption.h" @@ -94,9 +94,11 @@ static const NSTimeInterval CaretBlinkTime = 0.8; static inline NSRect cocoa_get_caret_rect( BrowserView *view ) { + float bscale = browser_window_get_scale(view->browser); + NSRect caretRect = { - .origin = NSMakePoint( view->caretPoint.x * view->browser->scale, view->caretPoint.y * view->browser->scale ), - .size = NSMakeSize( CaretWidth, view->caretHeight * view->browser->scale ) + .origin = NSMakePoint( view->caretPoint.x * bscale, view->caretPoint.y * bscale ), + .size = NSMakeSize( CaretWidth, view->caretHeight * bscale ) }; return caretRect; @@ -202,10 +204,11 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) - (NSPoint) convertMousePoint: (NSEvent *)event; { NSPoint location = [self convertPoint: [event locationInWindow] fromView: nil]; - if (NULL != browser) { - location.x /= browser->scale; - location.y /= browser->scale; - } + float bscale = browser_window_get_scale(browser); + + location.x /= bscale; + location.y /= bscale; + location.x = cocoa_pt_to_px( location.x ); location.y = cocoa_pt_to_px( location.y ); return location; @@ -485,8 +488,6 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt ) - (void) popUpContextMenuForEvent: (NSEvent *) event; { - if (content_get_type( browser->current_content ) != CONTENT_HTML) return; - NSMenu *popupMenu = [[NSMenu alloc] initWithTitle: @""]; NSPoint point = [self convertMousePoint: event]; diff --git a/cocoa/gui.m b/cocoa/gui.m index 2bce0cd2b..162d831a4 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -33,7 +33,7 @@ #import "desktop/mouse.h" #import "desktop/gui_window.h" #import "desktop/gui_misc.h" -#import "desktop/browser_private.h" +#import "desktop/browser.h" #import "desktop/textinput.h" #import "image/ico.h" #import "content/fetchers/resource.h" @@ -78,8 +78,6 @@ gui_window_create(struct browser_window *bw, static void gui_window_destroy(struct gui_window *g) { BrowserViewController *vc = (BrowserViewController *)g; - - if ([vc browser]->parent != NULL) [[vc view] removeFromSuperview]; [vc release]; } -- cgit v1.2.3