Cocoa front end (credit: Sven Weidauer)

svn path=/trunk/netsurf/; revision=11292
This commit is contained in:
John Mark Bell 2011-01-12 20:21:17 +00:00
parent 8c09af5568
commit b58dcc351f
33 changed files with 5640 additions and 0 deletions

47
cocoa/BrowserView.h Normal file
View File

@ -0,0 +1,47 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
@interface BrowserView : NSView {
struct browser_window *browser;
BOOL spinning;
NSString *status;
NSPoint caretPoint;
CGFloat caretHeight;
BOOL caretVisible;
BOOL hasCaret;
NSTimer *caretTimer;
}
@property (readwrite, assign, nonatomic) struct browser_window *browser;
@property (readwrite, assign, nonatomic) BOOL spinning;
@property (readwrite, copy, nonatomic) NSString *status;
@property (readwrite, retain, nonatomic) NSTimer *caretTimer;
- (void) removeCaret;
- (void) addCaretAt: (NSPoint) point height: (CGFloat) height;
- (IBAction) goBack: (id) sender;
- (IBAction) goForward: (id) sender;
- (IBAction) showHistory: (id) sender;
- (IBAction) reloadPage: (id) sender;
@end

289
cocoa/BrowserView.m Normal file
View File

@ -0,0 +1,289 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "BrowserView.h"
#import "desktop/browser.h"
#import "desktop/history_core.h"
#import "desktop/plotters.h"
#import "desktop/textinput.h"
@implementation BrowserView
@synthesize browser;
@synthesize spinning;
@synthesize status;
@synthesize caretTimer;
static const CGFloat CaretWidth = 1.0;
static const NSTimeInterval CaretBlinkTime = 0.8;
static inline NSRect cocoa_get_caret_rect( BrowserView *view )
{
NSRect caretRect = {
.origin = view->caretPoint,
.size = NSMakeSize( CaretWidth, view->caretHeight )
};
return caretRect;
}
- (void) removeCaret;
{
hasCaret = NO;
[self setNeedsDisplayInRect: cocoa_get_caret_rect( self )];
[caretTimer invalidate];
[self setCaretTimer: nil];
}
- (void) addCaretAt: (NSPoint) point height: (CGFloat) height;
{
if (hasCaret) {
[self setNeedsDisplayInRect: cocoa_get_caret_rect( self )];
}
caretPoint = point;
caretHeight = height;
hasCaret = YES;
caretVisible = YES;
if (nil == caretTimer) {
[self setCaretTimer: [NSTimer scheduledTimerWithTimeInterval: CaretBlinkTime target: self selector: @selector(caretBlink:) userInfo: nil repeats: YES]];
} else {
[caretTimer setFireDate: [NSDate dateWithTimeIntervalSinceNow: CaretBlinkTime]];
}
[self setNeedsDisplayInRect: cocoa_get_caret_rect( self )];
}
- (void) caretBlink: (NSTimer *)timer;
{
if (hasCaret) {
caretVisible = !caretVisible;
[self setNeedsDisplayInRect: cocoa_get_caret_rect( self )];
}
}
- (void)drawRect:(NSRect)dirtyRect;
{
if (NULL == browser->current_content) return;
NSRect frame = [self bounds];
plot.clip(0, 0, frame.size.width, frame.size.height);
content_redraw(browser->current_content,
0,
0,
NSWidth( frame ),
NSHeight( frame ),
NSMinX( dirtyRect ),
NSMinY( dirtyRect ),
NSMaxX( dirtyRect ),
NSMaxY( dirtyRect ),
browser->scale,
0xFFFFFF);
NSRect caretRect = cocoa_get_caret_rect( self );
if (hasCaret && caretVisible && [self needsToDrawRect: caretRect]) {
[[NSColor blackColor] set];
[NSBezierPath fillRect: caretRect];
}
}
- (BOOL) isFlipped;
{
return YES;
}
- (void) mouseDown: (NSEvent *)theEvent;
{
NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
browser_window_mouse_click( browser, BROWSER_MOUSE_PRESS_1, location.x, location.y );
}
- (void) mouseUp: (NSEvent *)theEvent;
{
NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
browser_window_mouse_click( browser, BROWSER_MOUSE_CLICK_1, location.x, location.y );
}
- (void) mouseDragged: (NSEvent *)theEvent;
{
}
- (void) mouseMoved: (NSEvent *)theEvent;
{
NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
browser_window_mouse_click( browser, 0, location.x, location.y );
}
- (void) keyDown: (NSEvent *)theEvent;
{
[self interpretKeyEvents: [NSArray arrayWithObject: theEvent]];
}
- (void) insertText: (id)string;
{
for (NSUInteger i = 0, length = [string length]; i < length; i++) {
unichar ch = [string characterAtIndex: i];
browser_window_key_press( browser, ch );
}
}
- (void) moveLeft: (id)sender;
{
browser_window_key_press( browser, KEY_LEFT );
}
- (void) moveRight: (id)sender;
{
browser_window_key_press( browser, KEY_RIGHT );
}
- (void) moveUp: (id)sender;
{
browser_window_key_press( browser, KEY_UP );
}
- (void) moveDown: (id)sender;
{
browser_window_key_press( browser, KEY_DOWN );
}
- (void) deleteBackward: (id)sender;
{
browser_window_key_press( browser, KEY_DELETE_LEFT );
}
- (void) deleteForward: (id)sender;
{
browser_window_key_press( browser, KEY_DELETE_RIGHT );
}
- (void) cancelOperation: (id)sender;
{
browser_window_key_press( browser, KEY_ESCAPE );
}
- (void) scrollPageUp: (id)sender;
{
browser_window_key_press( browser, KEY_PAGE_UP );
}
- (void) scrollPageDown: (id)sender;
{
browser_window_key_press( browser, KEY_PAGE_DOWN );
}
- (void) insertTab: (id)sender;
{
browser_window_key_press( browser, KEY_TAB );
}
- (void) insertBacktab: (id)sender;
{
browser_window_key_press( browser, KEY_SHIFT_TAB );
}
- (void) moveToBeginningOfLine: (id)sender;
{
browser_window_key_press( browser, KEY_LINE_START );
}
- (void) moveToEndOfLine: (id)sender;
{
browser_window_key_press( browser, KEY_LINE_END );
}
- (void) moveToBeginningOfDocument: (id)sender;
{
browser_window_key_press( browser, KEY_TEXT_START );
}
- (void) moveToEndOfDocument: (id)sender;
{
browser_window_key_press( browser, KEY_TEXT_END );
}
- (void) insertNewline: (id)sender;
{
browser_window_key_press( browser, KEY_NL );
}
- (void) setFrame: (NSRect)frameRect;
{
[super setFrame: frameRect];
browser_window_reformat( browser, [self bounds].size.width, [self bounds].size.height );
}
- (IBAction) goBack: (id) sender;
{
if (browser && history_back_available( browser->history )) {
history_back(browser, browser->history);
}
}
- (IBAction) goForward: (id) sender;
{
if (browser && history_forward_available( browser->history )) {
history_forward(browser, browser->history);
}
}
- (IBAction) showHistory: (id) sender;
{
}
- (IBAction) reloadPage: (id) sender;
{
browser_window_reload( browser, true );
}
- (BOOL) validateToolbarItem: (NSToolbarItem *)theItem;
{
SEL action = [theItem action];
if (action == @selector( goBack: )) {
return browser != NULL && history_back_available( browser->history );
}
if (action == @selector( goForward: )) {
return browser != NULL && history_forward_available( browser->history );
}
if (action == @selector( reloadPage: )) {
return browser_window_reload_available( browser );
}
return YES;
}
- (BOOL) acceptsFirstResponder;
{
return YES;
}
@end

39
cocoa/BrowserWindow.h Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
struct browser_window;
@class BrowserView;
@interface BrowserWindow : NSWindowController {
struct browser_window *browser;
NSString *url;
BrowserView *view;
}
@property (readwrite, assign, nonatomic) struct browser_window *browser;
@property (readwrite, copy, nonatomic) NSString *url;
@property (readwrite, retain, nonatomic) IBOutlet BrowserView *view;
- initWithBrowser: (struct browser_window *) bw;
- (IBAction) navigate: (id) sender;
@end

53
cocoa/BrowserWindow.m Normal file
View File

@ -0,0 +1,53 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "BrowserWindow.h"
#import "BrowserView.h"
#import "desktop/browser.h"
@implementation BrowserWindow
@synthesize browser;
@synthesize url;
@synthesize view;
- initWithBrowser: (struct browser_window *) bw;
{
if ((self = [super initWithWindowNibName: @"Browser"]) == nil) return nil;
browser = bw;
NSWindow *win = [self window];
[win setAcceptsMouseMovedEvents: YES];
[win makeKeyAndOrderFront: self];
return self;
}
- (IBAction) navigate: (id) sender;
{
browser_window_go( browser, [url UTF8String], NULL, true );
}
- (void) awakeFromNib;
{
[view setBrowser: browser];
}
@end

File diff suppressed because it is too large Load Diff

26
cocoa/NetsurfApp.h Normal file
View File

@ -0,0 +1,26 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
@interface NetSurfApp : NSApplication {
}
@end

59
cocoa/NetsurfApp.m Normal file
View File

@ -0,0 +1,59 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "NetSurfApp.h"
#import "desktop/gui.h"
#include "content/urldb.h"
#include "content/fetch.h"
#include "css/utils.h"
#include "desktop/gui.h"
#include "desktop/history_core.h"
#include "desktop/mouse.h"
#include "desktop/netsurf.h"
#include "desktop/options.h"
#include "desktop/plotters.h"
#include "desktop/save_complete.h"
#include "desktop/selection.h"
#include "desktop/textinput.h"
#include "render/html.h"
#include "utils/url.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
@implementation NetSurfApp
- (void) run;
{
[self finishLaunching];
browser_window_create( "http://netsurf-browser.org/", NULL, NULL, true, false );
netsurf_main_loop();
}
-(void) terminate: (id)sender;
{
netsurf_quit = true;
[self postEvent: [NSEvent otherEventWithType: NSApplicationDefined location: NSZeroPoint
modifierFlags: 0 timestamp: 0 windowNumber: 0 context: NULL
subtype: 0 data1: 0 data2: 0]
atStart: YES];
}
@end

24
cocoa/bitmap.h Normal file
View File

@ -0,0 +1,24 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COCOA_BITMAP_H
#define COCOA_BITMAP_H
CGImageRef cocoa_get_cgimage( void *bitmap );
#endif

223
cocoa/bitmap.m Normal file
View File

@ -0,0 +1,223 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
#import "image/bitmap.h"
#import "cocoa/bitmap.h"
#define BITS_PER_SAMPLE (8)
#define SAMPLES_PER_PIXEL (4)
#define BITS_PER_PIXEL (BITS_PER_SAMPLE * SAMPLES_PER_PIXEL)
#define BYTES_PER_PIXEL (BITS_PER_PIXEL / 8)
#define RED_OFFSET (0)
#define GREEN_OFFSET (1)
#define BLUE_OFFSET (2)
#define ALPHA_OFFSET (3)
static CGImageRef cocoa_prepare_bitmap( void *bitmap );
static NSMapTable *cocoa_get_bitmap_cache();
int bitmap_get_width(void *bitmap)
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
return [bmp pixelsWide];
}
int bitmap_get_height(void *bitmap)
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
return [bmp pixelsHigh];
}
bool bitmap_get_opaque(void *bitmap)
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
return [bmp isOpaque];
}
void bitmap_destroy(void *bitmap)
{
NSCParameterAssert( NULL != bitmap );
NSMapTable *cache = cocoa_get_bitmap_cache();
CGImageRef image = NSMapGet( cache, bitmap );
if (NULL != image) {
CGImageRelease( image );
NSMapRemove( cache, bitmap );
}
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
[bmp release];
}
void *bitmap_create(int width, int height, unsigned int state)
{
NSBitmapImageRep *bmp = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
pixelsWide: width
pixelsHigh: height
bitsPerSample: BITS_PER_SAMPLE
samplesPerPixel: SAMPLES_PER_PIXEL
hasAlpha: YES
isPlanar: NO
colorSpaceName: NSDeviceRGBColorSpace
bitmapFormat: NSAlphaNonpremultipliedBitmapFormat
bytesPerRow: BYTES_PER_PIXEL * width
bitsPerPixel: BITS_PER_PIXEL];
return bmp;
}
void bitmap_set_opaque(void *bitmap, bool opaque)
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
[bmp setOpaque: opaque ? YES : NO];
}
bool bitmap_test_opaque(void *bitmap)
{
NSCParameterAssert( bitmap_get_bpp( bitmap ) == BITS_PER_PIXEL );
unsigned char *buf = bitmap_get_buffer( bitmap );
const size_t height = bitmap_get_height( bitmap );
const size_t width = bitmap_get_width( bitmap );
const size_t line_step = bitmap_get_rowstride( bitmap ) - BYTES_PER_PIXEL * width;
for (size_t y = 0; y < height; y++) {
for (size_t x = 0; x < height; x++) {
if (buf[ALPHA_OFFSET] != 0xFF) return false;
buf += BYTES_PER_PIXEL;
}
buf += line_step;
}
return true;
}
unsigned char *bitmap_get_buffer(void *bitmap)
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
return [bmp bitmapData];
}
size_t bitmap_get_rowstride(void *bitmap)
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
return [bmp bytesPerRow];
}
size_t bitmap_get_bpp(void *bitmap)
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
return [bmp bitsPerPixel];
}
bool bitmap_save(void *bitmap, const char *path, unsigned flags)
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
NSData *tiff = [bmp TIFFRepresentation];
return [tiff writeToFile: [NSString stringWithUTF8String: path] atomically: YES];
}
void bitmap_modified(void *bitmap)
{
NSMapTable *cache = cocoa_get_bitmap_cache();
CGImageRef image = NSMapGet( cache, bitmap );
if (NULL != image) {
CGImageRelease( image );
NSMapRemove( cache, bitmap );
}
}
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word))
{
// nothing to do
}
CGImageRef cocoa_get_cgimage( void *bitmap )
{
NSMapTable *cache = cocoa_get_bitmap_cache();
CGImageRef result = NSMapGet( cache, bitmap );
if (NULL == result) {
result = cocoa_prepare_bitmap( bitmap );
NSMapInsertKnownAbsent( cache, bitmap, result );
}
return result;
}
static inline NSMapTable *cocoa_get_bitmap_cache()
{
static NSMapTable *cache = nil;
if (cache == nil) {
cache = NSCreateMapTable( NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0 );
}
return cache;
}
static CGImageRef cocoa_prepare_bitmap( void *bitmap )
{
NSCParameterAssert( NULL != bitmap );
NSBitmapImageRep *bmp = (NSBitmapImageRep *)bitmap;
size_t w = [bmp pixelsWide];
size_t h = [bmp pixelsHigh];
CGImageRef original = [bmp CGImage];
if (h <= 1) return CGImageRetain( original );
void *data = malloc( 4 * w * h );
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate( data, w, h, BITS_PER_SAMPLE,
BYTES_PER_PIXEL * w, colorSpace,
[bmp isOpaque] ? kCGImageAlphaNoneSkipLast
: kCGImageAlphaPremultipliedLast );
CGColorSpaceRelease( colorSpace );
CGContextTranslateCTM( context, 0.0, h );
CGContextScaleCTM( context, 1.0, -1.0 );
CGRect rect = CGRectMake( 0, 0, w, h );
CGContextClearRect( context, rect );
CGContextDrawImage( context, rect, original );
CGImageRef result = CGBitmapContextCreateImage( context );
CGContextRelease( context );
free( data );
return result;
}

57
cocoa/fetch.m Normal file
View File

@ -0,0 +1,57 @@
/*
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include "content/fetch.h"
#include "utils/log.h"
#include "utils/utils.h"
/**
* filetype -- determine the MIME type of a local file
*/
const char *fetch_filetype(const char *unix_path)
{
int l;
LOG(("unix path %s", unix_path));
l = strlen(unix_path);
if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
return "text/css";
if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
return "image/jpeg";
if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
return "image/jpeg";
if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
return "image/gif";
if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
return "image/png";
if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
return "image/jng";
if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
return "image/svg";
if (2 < l && strcasecmp(unix_path + l - 3, "bmp") == 0)
return "image/x-ms-bmp";
return "text/html";
}
char *fetch_mimetype(const char *ro_path)
{
return strdup("text/plain");
}

24
cocoa/font.h Normal file
View File

@ -0,0 +1,24 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COCOA_FONT_H
#define COCOA_FONT_H
void cocoa_draw_string( int x, int y, const char *bytes, size_t length, const plot_font_style_t *style );
#endif

177
cocoa/font.m Normal file
View File

@ -0,0 +1,177 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
#include <inttypes.h>
#include <assert.h>
#include "css/css.h"
#include "render/font.h"
#include "desktop/options.h"
#import "font.h"
#import "plotter.h"
static NSLayoutManager *cocoa_prepare_layout_manager( const char *string, size_t length,
const plot_font_style_t *style );
static NSTextStorage *cocoa_text_storage = nil;
static NSTextContainer *cocoa_text_container = nil;
static bool nsfont_width(const plot_font_style_t *style,
const char *string, size_t length,
int *width)
{
NSCParameterAssert( NULL != width );
NSLayoutManager *layout = cocoa_prepare_layout_manager( string, length, style );
*width = NULL != layout ? NSWidth( [layout usedRectForTextContainer: cocoa_text_container] ) : 0;
return true;
}
static bool nsfont_position_in_string(const plot_font_style_t *style,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
NSLayoutManager *layout = cocoa_prepare_layout_manager( string, length, style );
NSUInteger glyphIndex = [layout glyphIndexForPoint: NSMakePoint( x, 0 )
inTextContainer: cocoa_text_container
fractionOfDistanceThroughGlyph: NULL];
NSUInteger chars = [layout characterIndexForGlyphAtIndex: glyphIndex];
size_t offset = 0;
while (chars > 0) {
uint8_t ch = ((uint8_t *)string)[offset];
if (0xC2 <= ch && ch <= 0xDF) offset += 2;
else if (0xE0 <= ch && ch <= 0xEF) offset += 3;
else if (0xF0 <= ch && ch <= 0xF4) offset += 4;
else offset++;
--chars;
}
*char_offset = offset;
*actual_x = [layout locationForGlyphAtIndex: glyphIndex].x;
return true;
}
static bool nsfont_split(const plot_font_style_t *style,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
nsfont_position_in_string(style, string, length, x, char_offset,
actual_x);
if (*char_offset == length) return true;
while ((string[*char_offset] != ' ') && (*char_offset > 0))
(*char_offset)--;
return true;
}
static NSString *cocoa_font_family_name( plot_font_generic_family_t family )
{
switch (family) {
case PLOT_FONT_FAMILY_SERIF: return @"Times";
case PLOT_FONT_FAMILY_SANS_SERIF: return @"Helvetica";
case PLOT_FONT_FAMILY_MONOSPACE: return @"Courier";
case PLOT_FONT_FAMILY_CURSIVE: return @"Apple Chancery";
case PLOT_FONT_FAMILY_FANTASY: return @"Marker Felt";
default: return nil;
}
}
static NSFont *cocoa_font_get_nsfont( const plot_font_style_t *style )
{
return [NSFont fontWithName: cocoa_font_family_name( style->family )
size: (CGFloat)style->size / FONT_SIZE_SCALE];
}
NSDictionary *cocoa_font_attributes( const plot_font_style_t *style )
{
return [NSDictionary dictionaryWithObjectsAndKeys:
cocoa_font_get_nsfont( style ), NSFontAttributeName,
cocoa_convert_colour( style->foreground ), NSForegroundColorAttributeName,
nil];
}
static NSString *cocoa_string_from_utf8_characters( const char *string, size_t characters )
{
if (NULL == string || 0 == characters) return nil;
return [[[NSString alloc] initWithBytes: string length:characters encoding:NSUTF8StringEncoding] autorelease];
}
static NSLayoutManager *cocoa_prepare_layout_manager( const char *bytes, size_t length,
const plot_font_style_t *style )
{
if (NULL == bytes || 0 == length) return nil;
static NSLayoutManager *layout = nil;
if (nil == layout) {
cocoa_text_container = [[NSTextContainer alloc] initWithContainerSize: NSMakeSize( CGFLOAT_MAX, CGFLOAT_MAX )];
[cocoa_text_container setLineFragmentPadding: 0];
layout = [[NSLayoutManager alloc] init];
[layout addTextContainer: cocoa_text_container];
cocoa_text_storage = [[NSTextStorage alloc] init];
[cocoa_text_storage addLayoutManager: layout];
}
NSString *string = cocoa_string_from_utf8_characters( bytes, length );
if (nil == string) return nil;
NSDictionary *attributes = cocoa_font_attributes( style );
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString: string attributes: attributes];
if (![attributedString isEqualToAttributedString: cocoa_text_storage]) {
[cocoa_text_storage setAttributedString: attributedString];
[layout ensureLayoutForTextContainer: cocoa_text_container];
}
[attributedString release];
return layout;
}
void cocoa_draw_string( int x, int y, const char *bytes, size_t length, const plot_font_style_t *style )
{
NSLayoutManager *layout = cocoa_prepare_layout_manager( bytes, length, style );
if ([cocoa_text_storage length] > 0) {
NSFont *font = [cocoa_text_storage attribute: NSFontAttributeName atIndex: 0 effectiveRange: NULL];
CGFloat baseline = [layout defaultBaselineOffsetForFont: font];
NSRange glyphRange = [layout glyphRangeForTextContainer: cocoa_text_container];
[layout drawGlyphsForGlyphRange: glyphRange atPoint: NSMakePoint( x, y - baseline )];
}
}
const struct font_functions nsfont = {
nsfont_width,
nsfont_position_in_string,
nsfont_split
};

391
cocoa/gui.m Normal file
View File

@ -0,0 +1,391 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
#import "BrowserWindow.h"
#import "BrowserView.h"
#import "desktop/gui.h"
#import "desktop/netsurf.h"
#import "desktop/browser.h"
char *default_stylesheet_url;
char *adblock_stylesheet_url;
char *quirks_stylesheet_url;
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
void gui_multitask(void)
{
// nothing to do
}
static NSAutoreleasePool *gui_pool = nil;
void gui_poll(bool active)
{
[gui_pool release];
gui_pool = [[NSAutoreleasePool alloc] init];
NSEvent *event = [NSApp nextEventMatchingMask: NSAnyEventMask untilDate: active ? nil : [NSDate distantFuture]
inMode: NSDefaultRunLoopMode dequeue: YES];
if (nil != event) [NSApp sendEvent: event];
[NSApp updateWindows];
}
void gui_quit(void)
{
// nothing to do
}
struct browser_window;
struct gui_window *gui_create_browser_window(struct browser_window *bw,
struct browser_window *clone, bool new_tab)
{
return (struct gui_window *)[[BrowserWindow alloc] initWithBrowser: bw];
}
struct browser_window *gui_window_get_browser_window(struct gui_window *g)
{
return [(BrowserWindow *)g browser];
}
void gui_window_destroy(struct gui_window *g)
{
[(BrowserWindow *)g release];
}
void gui_window_set_title(struct gui_window *g, const char *title)
{
[[(BrowserWindow *)g window] setTitle: [NSString stringWithUTF8String: title]];
}
void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
{
NSRect rect = NSMakeRect( x0, y0, x1 - x0, y1 - y0 );
[[(BrowserWindow *)g view] setNeedsDisplayInRect: rect];
}
void gui_window_redraw_window(struct gui_window *g)
{
[[(BrowserWindow *)g view] setNeedsDisplay: YES];
}
void gui_window_update_box(struct gui_window *g,
const union content_msg_data *data)
{
gui_window_redraw( g, data->redraw.x, data->redraw.y,
data->redraw.x + data->redraw.width,
data->redraw.y + data->redraw.height );
}
bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
NSCParameterAssert( g != NULL && sx != NULL && sy != NULL );
NSRect visible = [[(BrowserWindow *)g view] visibleRect];
*sx = NSMinX( visible );
*sy = NSMinY( visible );
return true;
}
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
{
[[(BrowserWindow *)g view] scrollPoint: NSMakePoint( sx, sy )];
}
void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
int x1, int y1)
{
gui_window_set_scroll( g, x0, y0 );
}
void gui_window_position_frame(struct gui_window *g, int x0, int y0,
int x1, int y1)
{
UNIMPL();
}
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
bool scaled)
{
NSCParameterAssert( width != NULL && height != NULL );
NSRect frame = [[(BrowserWindow *)g view] frame];
*width = NSWidth( frame );
*height = NSHeight( frame );
}
void gui_window_update_extent(struct gui_window *g)
{
BrowserWindow * const window = (BrowserWindow *)g;
struct browser_window *browser = [window browser];
int width = content_get_width( browser->current_content ) * browser->scale;
int height = content_get_height( browser->current_content ) * browser->scale;
[[window view] setFrameSize: NSMakeSize( width, height )];
}
void gui_window_set_status(struct gui_window *g, const char *text)
{
[[(BrowserWindow *)g view] setStatus: [NSString stringWithUTF8String: text]];
}
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
switch (shape) {
case GUI_POINTER_DEFAULT:
case GUI_POINTER_WAIT:
case GUI_POINTER_PROGRESS:
[[NSCursor arrowCursor] set];
break;
case GUI_POINTER_CROSS:
[[NSCursor crosshairCursor] set];
break;
case GUI_POINTER_POINT:
[[NSCursor pointingHandCursor] set];
break;
case GUI_POINTER_CARET:
[[NSCursor IBeamCursor] set];
break;
default:
NSLog( @"Other cursor %d requested", shape );
[[NSCursor arrowCursor] set];
break;
}
}
void gui_window_hide_pointer(struct gui_window *g)
{
}
void gui_window_set_url(struct gui_window *g, const char *url)
{
[(BrowserWindow *)g setUrl: [NSString stringWithUTF8String: url]];
}
void gui_window_start_throbber(struct gui_window *g)
{
[[(BrowserWindow *)g view] setSpinning: YES];
}
void gui_window_stop_throbber(struct gui_window *g)
{
[[(BrowserWindow *)g view] setSpinning: NO];
}
void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
// ignore
}
void gui_window_set_search_ico(hlcache_handle *ico)
{
UNIMPL();
}
void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
{
[[(BrowserWindow *)g view] addCaretAt: NSMakePoint( x, y ) height: height];
}
void gui_window_remove_caret(struct gui_window *g)
{
[[(BrowserWindow *)g view] removeCaret];
}
void gui_window_new_content(struct gui_window *g)
{
}
bool gui_window_scroll_start(struct gui_window *g)
{
return true;
}
bool gui_window_box_scroll_start(struct gui_window *g,
int x0, int y0, int x1, int y1)
{
return true;
}
bool gui_window_frame_resize_start(struct gui_window *g)
{
UNIMPL();
return false;
}
void gui_window_save_link(struct gui_window *g, const char *url,
const char *title)
{
UNIMPL();
}
void gui_window_set_scale(struct gui_window *g, float scale)
{
UNIMPL();
}
struct gui_download_window *gui_download_window_create(download_context *ctx,
struct gui_window *parent)
{
UNIMPL();
return NULL;
}
nserror gui_download_window_data(struct gui_download_window *dw,
const char *data, unsigned int size)
{
UNIMPL();
return 0;
}
void gui_download_window_error(struct gui_download_window *dw,
const char *error_msg)
{
UNIMPL();
}
void gui_download_window_done(struct gui_download_window *dw)
{
UNIMPL();
}
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
{
}
void gui_drag_save_selection(struct selection *s, struct gui_window *g)
{
}
void gui_start_selection(struct gui_window *g)
{
}
void gui_clear_selection(struct gui_window *g)
{
}
void gui_paste_from_clipboard(struct gui_window *g, int x, int y)
{
UNIMPL();
}
bool gui_empty_clipboard(void)
{
return false;
}
bool gui_add_to_clipboard(const char *text, size_t length, bool space)
{
UNIMPL();
return false;
}
bool gui_commit_clipboard(void)
{
UNIMPL();
return false;
}
bool gui_copy_to_clipboard(struct selection *s)
{
UNIMPL();
return false;
}
void gui_create_form_select_menu(struct browser_window *bw,
struct form_control *control)
{
UNIMPL();
}
void gui_launch_url(const char *url)
{
UNIMPL();
}
struct ssl_cert_info;
void gui_cert_verify(const char *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
cb( false, cbpw );
}
void gui_401login_open(const char *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
cb( false, cbpw );
}
static char *gui_get_resource_url( NSString *name, NSString *type )
{
NSString *path = [[NSBundle mainBundle] pathForResource: name ofType: type];
return strdup( [[[NSURL fileURLWithPath: path] absoluteString] UTF8String] );
}
int main( int argc, char **argv )
{
char options[PATH_MAX];
gui_pool = [[NSAutoreleasePool alloc] init];
const char * const messages = [[[NSBundle mainBundle] pathForResource: @"messages" ofType: nil] UTF8String];
default_stylesheet_url = gui_get_resource_url( @"default", @"css" );
quirks_stylesheet_url = gui_get_resource_url( @"quirks", @"css" );
adblock_stylesheet_url = gui_get_resource_url( @"adblock", @"css" );
/* initialise netsurf */
netsurf_init(&argc, &argv, options, messages);
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
Class principalClass = NSClassFromString([infoDictionary objectForKey:@"NSPrincipalClass"]);
NSCAssert([principalClass respondsToSelector:@selector(sharedApplication)], @"Principal class must implement sharedApplication.");
[principalClass sharedApplication];
NSString *mainNibName = [infoDictionary objectForKey:@"NSMainNibFile"];
NSNib *mainNib = [[NSNib alloc] initWithNibNamed:mainNibName bundle:[NSBundle mainBundle]];
[mainNib instantiateNibWithOwner:NSApp topLevelObjects:nil];
[mainNib release];
[NSApp performSelectorOnMainThread:@selector(run) withObject:nil waitUntilDone:YES];
netsurf_exit();
return 0;
}

37
cocoa/history.m Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "desktop/browser.h"
#import <Cocoa/Cocoa.h>
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
void global_history_add_recent(const char *url)
{
UNIMPL();
}
char **global_history_get_recent(int *count)
{
UNIMPL();
return NULL;
}

24
cocoa/plotter.h Normal file
View File

@ -0,0 +1,24 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COCOA_PLOTTER_H
#define COCOA_PLOTTER_H
NSColor *cocoa_convert_colour( colour clr );
#endif

223
cocoa/plotter.m Normal file
View File

@ -0,0 +1,223 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Cocoa/Cocoa.h>
#include "desktop/plotters.h"
#import "desktop/plot_style.h"
#import "cocoa/font.h"
#import "cocoa/plotter.h"
#import "cocoa/bitmap.h"
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
static void cocoa_plot_render_path(NSBezierPath *path,const plot_style_t *pstyle);
static void cocoa_plot_path_set_stroke_pattern(NSBezierPath *path,const plot_style_t *pstyle);
static NSRect cocoa_plot_clip_rect;
#define colour_red_component( c ) (((c) >> 0) & 0xFF)
#define colour_green_component( c ) (((c) >> 8) & 0xFF)
#define colour_blue_component( c ) (((c) >> 16) & 0xFF)
#define colour_alpha_component( c ) (((c) >> 24) & 0xFF)
#define colour_from_rgba( r, g, b, a) ((((colour)(r)) << 0) | \
(((colour)(g)) << 8) | \
(((colour)(b)) << 16) | \
(((colour)(a)) << 24))
#define colour_from_rgb( r, g, b ) colour_from_rgba( (r), (g), (b), 0xFF )
NSColor *cocoa_convert_colour( colour clr )
{
return [NSColor colorWithDeviceRed: (float)colour_red_component( clr ) / 0xFF
green: (float)colour_green_component( clr ) / 0xFF
blue: (float)colour_blue_component( clr ) / 0xFF
alpha: 1.0];
}
static void cocoa_plot_path_set_stroke_pattern(NSBezierPath *path,const plot_style_t *pstyle)
{
static const CGFloat dashed_pattern[2] = { 5.0, 2.0 };
static const CGFloat dotted_pattern[2] = { 2.0, 2.0 };
switch (pstyle->stroke_type) {
case PLOT_OP_TYPE_DASH:
[path setLineDash: dashed_pattern count: 2 phase: 0];
break;
case PLOT_OP_TYPE_DOT:
[path setLineDash: dotted_pattern count: 2 phase: 0];
break;
default:
// ignore
break;
}
[path setLineWidth: pstyle->stroke_width];
}
static bool plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
{
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint: NSMakePoint( x0, y0 )];
[path lineToPoint: NSMakePoint( x1, y1 )];
cocoa_plot_render_path( path, pstyle );
return true;
}
static bool plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *pstyle)
{
NSBezierPath *path = [NSBezierPath bezierPathWithRect: NSMakeRect( x0, y0, x1-x0, y1-y0 )];
cocoa_plot_render_path( path, pstyle );
return true;
}
static bool plot_text(int x, int y, const char *text, size_t length,
const plot_font_style_t *fstyle)
{
[NSGraphicsContext saveGraphicsState];
[NSBezierPath clipRect: cocoa_plot_clip_rect];
cocoa_draw_string( x, y, text, length, fstyle );
[NSGraphicsContext restoreGraphicsState];
return true;
}
static bool plot_clip(int x0, int y0, int x1, int y1)
{
cocoa_plot_clip_rect = NSMakeRect( x0, y0, abs(x1-x0), abs(y1-y0) );
return true;
}
void cocoa_plot_render_path(NSBezierPath *path,const plot_style_t *pstyle)
{
[NSGraphicsContext saveGraphicsState];
[NSBezierPath clipRect: cocoa_plot_clip_rect];
if (pstyle->fill_type != PLOT_OP_TYPE_NONE) {
[cocoa_convert_colour( pstyle->fill_colour ) setFill];
[path fill];
}
if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) {
cocoa_plot_path_set_stroke_pattern(path,pstyle);
[cocoa_convert_colour( pstyle->stroke_colour ) set];
[path stroke];
}
[NSGraphicsContext restoreGraphicsState];
}
static bool plot_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *pstyle)
{
NSBezierPath *path = [NSBezierPath bezierPath];
[path appendBezierPathWithArcWithCenter: NSMakePoint( x, y ) radius: radius
startAngle: angle1 endAngle: angle2
clockwise: NO];
cocoa_plot_render_path( path, pstyle);
return true;
}
static bool plot_disc(int x, int y, int radius, const plot_style_t *pstyle)
{
NSBezierPath *path = [NSBezierPath bezierPathWithOvalInRect:
NSMakeRect( x - radius, y-radius, 2*radius, 2*radius )];
cocoa_plot_render_path( path, pstyle );
return true;
}
static bool plot_polygon(const int *p, unsigned int n, const plot_style_t *pstyle)
{
if (n <= 1) return true;
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint: NSMakePoint( p[0], p[1] )];
for (int i = 1; i < n; i++) {
[path lineToPoint: NSMakePoint( p[2*i], p[2*i+1] )];
}
[path closePath];
cocoa_plot_render_path( path, pstyle );
return true;
}
/* complex path (for SVG) */
static bool plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6])
{
UNIMPL();
return true;
}
/* Image */
static bool plot_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,
bitmap_flags_t flags)
{
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSaveGState( context );
CGContextClipToRect( context, NSRectToCGRect( cocoa_plot_clip_rect ) );
const bool tileX = flags & BITMAPF_REPEAT_X;
const bool tileY = flags & BITMAPF_REPEAT_Y;
CGImageRef img = cocoa_get_cgimage( bitmap );
CGRect rect = CGRectMake( x, y, width, height );
if (tileX || tileY) {
CGContextDrawTiledImage( context, rect, img );
} else {
CGContextDrawImage( context, rect, img );
}
CGContextRestoreGState( context );
return true;
}
struct plotter_table plot = {
.clip = plot_clip,
.arc = plot_arc,
.disc = plot_disc,
.rectangle = plot_rectangle,
.line = plot_line,
.polygon = plot_polygon,
.path = plot_path,
.bitmap = plot_bitmap,
.text = plot_text,
.option_knockout = true
};

989
cocoa/res/Browser.xib Normal file
View File

@ -0,0 +1,989 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10J567</string>
<string key="IBDocument.InterfaceBuilderVersion">804</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">462.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">804</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="38"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">BrowserWindow</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="1005">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{135, 249}, {691, 632}}</string>
<int key="NSWTFlags">544735232</int>
<string key="NSWindowTitle">NetSurf</string>
<string key="NSWindowClass">NSWindow</string>
<object class="NSToolbar" key="NSViewClass" id="392415761">
<object class="NSMutableString" key="NSToolbarIdentifier">
<characters key="NS.bytes">10771526-5048-4EBE-984D-B6BEEB6455E1</characters>
</object>
<nil key="NSToolbarDelegate"/>
<bool key="NSToolbarPrefersToBeShown">YES</bool>
<bool key="NSToolbarShowsBaselineSeparator">YES</bool>
<bool key="NSToolbarAllowsUserCustomization">YES</bool>
<bool key="NSToolbarAutosavesConfiguration">NO</bool>
<int key="NSToolbarDisplayMode">2</int>
<int key="NSToolbarSizeMode">1</int>
<object class="NSMutableDictionary" key="NSToolbarIBIdentifiedItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>316FFEF7-FE4B-4054-A233-B48593490A7F</string>
<string>484FB8D5-6AD6-4E75-B60E-CA03FC98EFCD</string>
<string>7EEF129A-ED23-47F1-88E8-B60EAF53C80C</string>
<string>E2E89C48-DD3F-47A5-9E6C-25985A970F69</string>
<string>FA0D0D22-FE0D-4337-A543-E5BB13E4E088</string>
<string>NSToolbarCustomizeToolbarItem</string>
<string>NSToolbarFlexibleSpaceItem</string>
<string>NSToolbarSeparatorItem</string>
<string>NSToolbarSpaceItem</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSToolbarItem" id="702346074">
<object class="NSMutableString" key="NSToolbarItemIdentifier">
<characters key="NS.bytes">316FFEF7-FE4B-4054-A233-B48593490A7F</characters>
</object>
<string key="NSToolbarItemLabel">Go back</string>
<string key="NSToolbarItemPaletteLabel">Go back</string>
<string key="NSToolbarItemToolTip"/>
<nil key="NSToolbarItemView"/>
<object class="NSCustomResource" key="NSToolbarItemImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSGoLeftTemplate</string>
</object>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{0, 0}</string>
<string key="NSToolbarItemMaxSize">{0, 0}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
</object>
<object class="NSToolbarItem" id="525444158">
<object class="NSMutableString" key="NSToolbarItemIdentifier">
<characters key="NS.bytes">484FB8D5-6AD6-4E75-B60E-CA03FC98EFCD</characters>
</object>
<string key="NSToolbarItemLabel">Go forward</string>
<string key="NSToolbarItemPaletteLabel">Go forward</string>
<string key="NSToolbarItemToolTip"/>
<nil key="NSToolbarItemView"/>
<object class="NSCustomResource" key="NSToolbarItemImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSGoRightTemplate</string>
</object>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{0, 0}</string>
<string key="NSToolbarItemMaxSize">{0, 0}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
</object>
<object class="NSToolbarItem" id="734074974">
<object class="NSMutableString" key="NSToolbarItemIdentifier">
<characters key="NS.bytes">7EEF129A-ED23-47F1-88E8-B60EAF53C80C</characters>
</object>
<string key="NSToolbarItemLabel">Reload</string>
<string key="NSToolbarItemPaletteLabel">Reload</string>
<string key="NSToolbarItemToolTip"/>
<nil key="NSToolbarItemView"/>
<object class="NSCustomResource" key="NSToolbarItemImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSRefreshTemplate</string>
</object>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{0, 0}</string>
<string key="NSToolbarItemMaxSize">{0, 0}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
</object>
<object class="NSToolbarItem" id="784507185">
<object class="NSMutableString" key="NSToolbarItemIdentifier">
<characters key="NS.bytes">E2E89C48-DD3F-47A5-9E6C-25985A970F69</characters>
</object>
<string key="NSToolbarItemLabel"/>
<string key="NSToolbarItemPaletteLabel">URL</string>
<nil key="NSToolbarItemToolTip"/>
<object class="NSTextField" key="NSToolbarItemView" id="570769942">
<reference key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{0, 14}, {96, 22}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="465639940">
<int key="NSCellFlags">-1804468671</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="570769942"/>
<bool key="NSDrawsBackground">YES</bool>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textBackgroundColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textColor</string>
<object class="NSColor" key="NSColor" id="791352603">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
</object>
</object>
<nil key="NSToolbarItemImage"/>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{96, 22}</string>
<string key="NSToolbarItemMaxSize">{10000, 22}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">0</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
</object>
<object class="NSToolbarItem" id="955202223">
<object class="NSMutableString" key="NSToolbarItemIdentifier">
<characters key="NS.bytes">FA0D0D22-FE0D-4337-A543-E5BB13E4E088</characters>
</object>
<string key="NSToolbarItemLabel">History</string>
<string key="NSToolbarItemPaletteLabel">History</string>
<string key="NSToolbarItemToolTip"/>
<nil key="NSToolbarItemView"/>
<object class="NSCustomResource" key="NSToolbarItemImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMultipleDocuments</string>
</object>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{0, 0}</string>
<string key="NSToolbarItemMaxSize">{0, 0}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
</object>
<object class="NSToolbarItem" id="554531361">
<string key="NSToolbarItemIdentifier">NSToolbarCustomizeToolbarItem</string>
<string key="NSToolbarItemLabel">Customize</string>
<string key="NSToolbarItemPaletteLabel">Customize</string>
<string key="NSToolbarItemToolTip">Customize Toolbar</string>
<nil key="NSToolbarItemView"/>
<object class="NSCustomResource" key="NSToolbarItemImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSToolbarCustomizeToolbarItemImage</string>
</object>
<nil key="NSToolbarItemTarget"/>
<string key="NSToolbarItemAction">runToolbarCustomizationPalette:</string>
<string key="NSToolbarItemMinSize">{0, 0}</string>
<string key="NSToolbarItemMaxSize">{0, 0}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
</object>
<object class="NSToolbarFlexibleSpaceItem" id="481399099">
<string key="NSToolbarItemIdentifier">NSToolbarFlexibleSpaceItem</string>
<string key="NSToolbarItemLabel"/>
<string key="NSToolbarItemPaletteLabel">Flexible Space</string>
<nil key="NSToolbarItemToolTip"/>
<nil key="NSToolbarItemView"/>
<nil key="NSToolbarItemImage"/>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{1, 5}</string>
<string key="NSToolbarItemMaxSize">{20000, 32}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
<object class="NSMenuItem" key="NSToolbarItemMenuFormRepresentation">
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<object class="NSCustomResource" key="NSOnImage" id="437280079">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
<object class="NSCustomResource" key="NSMixedImage" id="563857027">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
</object>
</object>
<object class="NSToolbarSeparatorItem" id="1049725992">
<string key="NSToolbarItemIdentifier">NSToolbarSeparatorItem</string>
<string key="NSToolbarItemLabel"/>
<string key="NSToolbarItemPaletteLabel">Separator</string>
<nil key="NSToolbarItemToolTip"/>
<nil key="NSToolbarItemView"/>
<nil key="NSToolbarItemImage"/>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{12, 5}</string>
<string key="NSToolbarItemMaxSize">{12, 1000}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
<object class="NSMenuItem" key="NSToolbarItemMenuFormRepresentation">
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="437280079"/>
<reference key="NSMixedImage" ref="563857027"/>
</object>
</object>
<object class="NSToolbarSpaceItem" id="191318475">
<string key="NSToolbarItemIdentifier">NSToolbarSpaceItem</string>
<string key="NSToolbarItemLabel"/>
<string key="NSToolbarItemPaletteLabel">Space</string>
<nil key="NSToolbarItemToolTip"/>
<nil key="NSToolbarItemView"/>
<nil key="NSToolbarItemImage"/>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{32, 5}</string>
<string key="NSToolbarItemMaxSize">{32, 32}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">-1</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
<object class="NSMenuItem" key="NSToolbarItemMenuFormRepresentation">
<bool key="NSIsDisabled">YES</bool>
<bool key="NSIsSeparator">YES</bool>
<string key="NSTitle"/>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="437280079"/>
<reference key="NSMixedImage" ref="563857027"/>
</object>
</object>
</object>
</object>
<object class="NSArray" key="NSToolbarIBAllowedItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="702346074"/>
<reference ref="525444158"/>
<reference ref="784507185"/>
<reference ref="1049725992"/>
<reference ref="191318475"/>
<reference ref="481399099"/>
<reference ref="554531361"/>
<reference ref="955202223"/>
<reference ref="734074974"/>
</object>
<object class="NSMutableArray" key="NSToolbarIBDefaultItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="702346074"/>
<reference ref="734074974"/>
<reference ref="525444158"/>
<reference ref="1049725992"/>
<reference ref="784507185"/>
</object>
<object class="NSMutableArray" key="NSToolbarIBSelectableItems">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="1006">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSScrollView" id="299449310">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSClipView" id="230262136">
<reference key="NSNextResponder" ref="299449310"/>
<int key="NSvFlags">2304</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomView" id="947292612">
<reference key="NSNextResponder" ref="230262136"/>
<int key="NSvFlags">274</int>
<string key="NSFrameSize">{676, 597}</string>
<reference key="NSSuperview" ref="230262136"/>
<string key="NSClassName">BrowserView</string>
</object>
</object>
<string key="NSFrame">{{1, 1}, {676, 597}}</string>
<reference key="NSSuperview" ref="299449310"/>
<reference key="NSNextKeyView" ref="947292612"/>
<reference key="NSDocView" ref="947292612"/>
<object class="NSColor" key="NSBGColor" id="994333793">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<int key="NScvFlags">4</int>
</object>
<object class="NSScroller" id="217278618">
<reference key="NSNextResponder" ref="299449310"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{677, 1}, {15, 597}}</string>
<reference key="NSSuperview" ref="299449310"/>
<reference key="NSTarget" ref="299449310"/>
<string key="NSAction">_doScroller:</string>
<double key="NSCurValue">1</double>
<double key="NSPercent">0.96363627910614014</double>
</object>
<object class="NSScroller" id="837576252">
<reference key="NSNextResponder" ref="299449310"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{1, 598}, {676, 15}}</string>
<reference key="NSSuperview" ref="299449310"/>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="299449310"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.50602412223815918</double>
</object>
</object>
<string key="NSFrame">{{-1, 19}, {693, 614}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSNextKeyView" ref="230262136"/>
<int key="NSsFlags">50</int>
<reference key="NSVScroller" ref="217278618"/>
<reference key="NSHScroller" ref="837576252"/>
<reference key="NSContentView" ref="230262136"/>
</object>
<object class="NSTextField" id="1055532139">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">290</int>
<string key="NSFrame">{{27, 3}, {647, 14}}</string>
<reference key="NSSuperview" ref="1006"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="559666362">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272761856</int>
<string key="NSContents">NetSurf</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">11</double>
<int key="NSfFlags">3100</int>
</object>
<reference key="NSControlView" ref="1055532139"/>
<reference key="NSBackgroundColor" ref="994333793"/>
<object class="NSColor" key="NSTextColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlTextColor</string>
<reference key="NSColor" ref="791352603"/>
</object>
</object>
</object>
<object class="NSProgressIndicator" id="727691575">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">1316</int>
<object class="NSPSMatrix" key="NSDrawMatrix"/>
<string key="NSFrame">{{6, 2}, {16, 16}}</string>
<reference key="NSSuperview" ref="1006"/>
<int key="NSpiFlags">28938</int>
<double key="NSMaxValue">100</double>
</object>
</object>
<string key="NSFrameSize">{691, 632}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
<bool key="NSAutorecalculatesContentBorderThicknessMinY">NO</bool>
<double key="NSContentBorderThicknessMinY">20</double>
</object>
<object class="NSObjectController" id="374263046">
<object class="NSMutableArray" key="NSDeclaredKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>spinning</string>
<string>status</string>
</object>
<bool key="NSEditable">YES</bool>
<object class="_NSManagedProxy" key="_NSManagedProxy"/>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="1005"/>
</object>
<int key="connectionID">3</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: url</string>
<reference key="source" ref="570769942"/>
<reference key="destination" ref="1001"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="570769942"/>
<reference key="NSDestination" ref="1001"/>
<string key="NSLabel">value: url</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">url</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">19</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">navigate:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="570769942"/>
</object>
<int key="connectionID">20</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="947292612"/>
</object>
<int key="connectionID">21</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">reloadPage:</string>
<reference key="source" ref="947292612"/>
<reference key="destination" ref="734074974"/>
</object>
<int key="connectionID">28</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">goBack:</string>
<reference key="source" ref="947292612"/>
<reference key="destination" ref="702346074"/>
</object>
<int key="connectionID">29</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">goForward:</string>
<reference key="source" ref="947292612"/>
<reference key="destination" ref="525444158"/>
</object>
<int key="connectionID">30</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showHistory:</string>
<reference key="source" ref="947292612"/>
<reference key="destination" ref="955202223"/>
</object>
<int key="connectionID">31</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">content</string>
<reference key="source" ref="374263046"/>
<reference key="destination" ref="947292612"/>
</object>
<int key="connectionID">33</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: selection.status</string>
<reference key="source" ref="1055532139"/>
<reference key="destination" ref="374263046"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="1055532139"/>
<reference key="NSDestination" ref="374263046"/>
<string key="NSLabel">value: selection.status</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">selection.status</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">37</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">animate: selection.spinning</string>
<reference key="source" ref="727691575"/>
<reference key="destination" ref="374263046"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="727691575"/>
<reference key="NSDestination" ref="374263046"/>
<string key="NSLabel">animate: selection.spinning</string>
<string key="NSBinding">animate</string>
<string key="NSKeyPath">selection.spinning</string>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">39</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="1005"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1006"/>
<reference ref="392415761"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="1006"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="299449310"/>
<reference ref="1055532139"/>
<reference ref="727691575"/>
</object>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="299449310"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="217278618"/>
<reference ref="837576252"/>
<reference ref="947292612"/>
</object>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="217278618"/>
<reference key="parent" ref="299449310"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">6</int>
<reference key="object" ref="837576252"/>
<reference key="parent" ref="299449310"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">7</int>
<reference key="object" ref="947292612"/>
<reference key="parent" ref="299449310"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="392415761"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="191318475"/>
<reference ref="481399099"/>
<reference ref="554531361"/>
<reference ref="1049725992"/>
<reference ref="784507185"/>
<reference ref="702346074"/>
<reference ref="525444158"/>
<reference ref="955202223"/>
<reference ref="734074974"/>
</object>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="191318475"/>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="481399099"/>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">15</int>
<reference key="object" ref="554531361"/>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">11</int>
<reference key="object" ref="1049725992"/>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">18</int>
<reference key="object" ref="784507185"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="570769942"/>
</object>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">16</int>
<reference key="object" ref="570769942"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="465639940"/>
</object>
<reference key="parent" ref="784507185"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">17</int>
<reference key="object" ref="465639940"/>
<reference key="parent" ref="570769942"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">22</int>
<reference key="object" ref="702346074"/>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">23</int>
<reference key="object" ref="525444158"/>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">24</int>
<reference key="object" ref="955202223"/>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">25</int>
<reference key="object" ref="734074974"/>
<reference key="parent" ref="392415761"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">32</int>
<reference key="object" ref="374263046"/>
<reference key="parent" ref="0"/>
<string key="objectName">Browser View</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">35</int>
<reference key="object" ref="1055532139"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="559666362"/>
</object>
<reference key="parent" ref="1006"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">36</int>
<reference key="object" ref="559666362"/>
<reference key="parent" ref="1055532139"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">38</int>
<reference key="object" ref="727691575"/>
<reference key="parent" ref="1006"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
<string>1.IBWindowTemplateEditedContentRect</string>
<string>1.NSWindowTemplate.visibleAtLaunch</string>
<string>1.WindowOrigin</string>
<string>1.editorWindowContentRectSynchronizationRect</string>
<string>11.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
<string>15.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
<string>17.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
<string>22.IBPluginDependency</string>
<string>23.IBPluginDependency</string>
<string>24.IBPluginDependency</string>
<string>25.IBPluginDependency</string>
<string>32.IBPluginDependency</string>
<string>35.IBPluginDependency</string>
<string>35.IBViewBoundsToFrameTransform</string>
<string>36.IBPluginDependency</string>
<string>38.IBPluginDependency</string>
<string>38.IBViewBoundsToFrameTransform</string>
<string>4.IBPluginDependency</string>
<string>4.IBViewBoundsToFrameTransform</string>
<string>5.IBPluginDependency</string>
<string>6.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
<string>8.IBEditorWindowLastContentRect</string>
<string>8.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{{135, 249}, {691, 632}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{135, 249}, {691, 632}}</string>
<integer value="1"/>
<string>{196, 240}</string>
<string>{{202, 428}, {480, 270}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABAoAAAwXAAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABDQwAAwYgAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAAC/gAAAw5EAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{172, 881}, {617, 0}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">39</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">BrowserView</string>
<string key="superclassName">NSView</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>goBack:</string>
<string>goForward:</string>
<string>reloadPage:</string>
<string>showHistory:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>goBack:</string>
<string>goForward:</string>
<string>reloadPage:</string>
<string>showHistory:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">goBack:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">goForward:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">reloadPage:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showHistory:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">BrowserView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">BrowserWindow</string>
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">navigate:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">navigate:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">navigate:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">view</string>
<string key="NS.object.0">BrowserView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">view</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">view</string>
<string key="candidateClassName">BrowserView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">BrowserWindow.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../NetSurf.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSGoLeftTemplate</string>
<string>NSGoRightTemplate</string>
<string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string>
<string>NSMultipleDocuments</string>
<string>NSRefreshTemplate</string>
<string>NSToolbarCustomizeToolbarItemImage</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{9, 9}</string>
<string>{9, 9}</string>
<string>{9, 8}</string>
<string>{7, 2}</string>
<string>{32, 32}</string>
<string>{10, 12}</string>
<string>{32, 32}</string>
</object>
</object>
</data>
</archive>

1578
cocoa/res/MainMenu.xib Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NetSurfApp</string>
</dict>
</plist>

1
cocoa/res/adblock.css Symbolic link
View File

@ -0,0 +1 @@
../../!NetSurf/Resources/AdBlock,f79

1
cocoa/res/de.lproj/Messages Symbolic link
View File

@ -0,0 +1 @@
../../../!NetSurf/Resources/de/Messages

1
cocoa/res/default.css Symbolic link
View File

@ -0,0 +1 @@
../../!NetSurf/Resources/CSS,f79

1
cocoa/res/en.lproj/Messages Symbolic link
View File

@ -0,0 +1 @@
../../../!NetSurf/Resources/en/Messages

1
cocoa/res/fr.lproj/Messages Symbolic link
View File

@ -0,0 +1 @@
../../../!NetSurf/Resources/fr/Messages

1
cocoa/res/it.lproj/Messages Symbolic link
View File

@ -0,0 +1 @@
../../../!NetSurf/Resources/it/Messages

1
cocoa/res/nl.lproj/Messages Symbolic link
View File

@ -0,0 +1 @@
../../../!NetSurf/Resources/nl/Messages

1
cocoa/res/quirks.css Symbolic link
View File

@ -0,0 +1 @@
../../!NetSurf/Resources/Quirks,f79

37
cocoa/save.m Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
#import "desktop/save_complete.h"
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
bool save_complete_gui_save(const char *path, const char *filename,
size_t len, const char *sourcedata, content_type type)
{
UNIMPL();
return false;
}
int save_complete_htmlSaveFileFormat(const char *path, const char *filename,
xmlDocPtr cur, const char *encoding, int format)
{
UNIMPL();
return 0;
}

91
cocoa/schedule.m Normal file
View File

@ -0,0 +1,91 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "desktop/browser.h"
#import <Cocoa/Cocoa.h>
@interface ScheduledCallback : NSObject {
void (*callback)( void *userData );
void *userData;
}
- initWithCallback: (void (*)(void *))cb userData: (void *)ud;
- (void) schedule: (NSTimeInterval) ti;
@end
@implementation ScheduledCallback
- initWithCallback: (void (*)(void *))cb userData: (void *)ud;
{
callback = cb;
userData = ud;
return self;
}
static NSMutableSet *timerSet = nil;
- (void) schedule: (NSTimeInterval) ti;
{
if (nil == timerSet) {
timerSet = [[NSMutableSet alloc] init];
}
[self performSelector: @selector(timerFired) withObject: nil afterDelay: ti];
[timerSet addObject: self];
}
- (void) timerFired;
{
if ([timerSet containsObject: self]) {
[timerSet removeObject: self];
callback( userData );
}
}
- (BOOL) isEqual: (id)object
{
if (object == self) return YES;
if ([object class] != [self class]) return NO;
return ((ScheduledCallback *)object)->callback == callback && ((ScheduledCallback *)object)->userData == userData;
}
- (NSUInteger) hash;
{
return (NSUInteger)callback + (NSUInteger)userData;
}
@end
/* In platform specific schedule.c. */
void schedule(int t, void (*callback)(void *p), void *p)
{
ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p];
[cb schedule: (NSTimeInterval)t / 100];
[cb release];
}
void schedule_remove(void (*callback)(void *p), void *p)
{
ScheduledCallback *cb = [[ScheduledCallback alloc] initWithCallback: callback userData: p];
[timerSet removeObject: cb];
[cb release];
}

61
cocoa/thumbnail.m Normal file
View File

@ -0,0 +1,61 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "desktop/browser.h"
#import "desktop/plotters.h"
#import "content/urldb.h"
#import "image/bitmap.h"
#import <Cocoa/Cocoa.h>
/* In platform specific thumbnail.c. */
bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap,
const char *url)
{
CGColorSpaceRef cspace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
CGContextRef bitmapContext = CGBitmapContextCreate( bitmap_get_buffer( bitmap ),
bitmap_get_width( bitmap ), bitmap_get_height( bitmap ),
bitmap_get_bpp( bitmap ) / 4,
bitmap_get_rowstride( bitmap ),
cspace, kCGImageAlphaNoneSkipLast );
CGColorSpaceRelease( cspace );
size_t width = MIN( content_get_width( content ), 1024 );
size_t height = MIN( content_get_height( content ), 768 );
CGContextTranslateCTM( bitmapContext, 0, bitmap_get_height( bitmap ) );
CGContextScaleCTM( bitmapContext, (CGFloat)bitmap_get_width( bitmap ) / width, -(CGFloat)bitmap_get_height( bitmap ) / height );
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: bitmapContext flipped: YES]];
content_redraw( content, 0, 0, content_get_width( content ), content_get_height( content ),
0, 0, content_get_width( content ), content_get_height( content ),
1.0, 0xFFFFFFFF );
[NSGraphicsContext setCurrentContext: nil];
CGContextRelease( bitmapContext );
bitmap_modified( bitmap );
if (NULL != url) urldb_set_thumbnail( url, bitmap );
return true;
}

37
cocoa/url.m Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <stdbool.h>
#import <stdlib.h>
#import "utils/url.h"
#import <Cocoa/Cocoa.h>
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
char *url_to_path(const char *url)
{
NSURL *nsurl = [NSURL URLWithString: [NSString stringWithUTF8String: url]];
return strdup([[nsurl path] UTF8String]);
}
char *path_to_url(const char *path)
{
UNIMPL();
return NULL;
}

36
cocoa/utf8.m Normal file
View File

@ -0,0 +1,36 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
#import "utils/utf8.h"
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len,
char **result)
{
UNIMPL();
return -1;
}
utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len,
char **result)
{
UNIMPL();
return -1;
}

67
cocoa/utils.m Normal file
View File

@ -0,0 +1,67 @@
/*
* Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
* NetSurf is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* NetSurf is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Cocoa/Cocoa.h>
#import "utils/utils.h"
#import "desktop/tree_url_node.h"
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
void die(const char * const error)
{
[NSException raise: @"NetsurfDie" format: @"Error: %s", error];
}
void warn_user(const char *warning, const char *detail)
{
NSRunAlertPanel( @"Warning", @"Warning %s: %s", @"OK", nil, nil, warning, detail );
}
query_id query_user(const char *query, const char *detail,
const query_callback *cb, void *pw, const char *yes, const char *no)
{
UNIMPL();
return 0;
}
void query_close(query_id qid)
{
UNIMPL();
}
void PDF_Password(char **owner_pass, char **user_pass, char *path)
{
UNIMPL();
}
char *filename_from_path(char *path)
{
UNIMPL();
return NULL;
}
bool path_add_part(char *path, int length, const char *newpart)
{
UNIMPL();
return false;
}
void tree_icon_name_from_content_type(char *buffer, content_type type)
{
UNIMPL();
}