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.
This commit is contained in:
Vincent Sanders 2014-11-21 11:48:43 +00:00
parent 0f0c3b02d7
commit 3ff4846c1a
3 changed files with 15 additions and 12 deletions

View File

@ -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];

View File

@ -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];
}

View File

@ -2568,6 +2568,10 @@ void browser_window_set_scale(struct browser_window *bw, float scale, bool all)
/* exported interface documented in desktop/browser.h */
float browser_window_get_scale(struct browser_window *bw)
{
if (bw == NULL) {
return 1.0;
}
return bw->scale;
}