summaryrefslogtreecommitdiff
path: root/cocoa
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-06-30 16:40:56 +0100
committerVincent Sanders <vince@kyllikki.org>2014-07-01 09:27:20 +0100
commit18aefabd20a16dda9ed5363088f0da5ada0d4431 (patch)
tree9447e1e0edb1d93b8ad575472e67bf7f844c5ca3 /cocoa
parent06eb81235d975bc7721719d25ac114b4ab2c94da (diff)
downloadnetsurf-18aefabd20a16dda9ed5363088f0da5ada0d4431.tar.gz
netsurf-18aefabd20a16dda9ed5363088f0da5ada0d4431.tar.bz2
change reformat to be driven from the scheduler like redraw
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/BrowserView.m29
-rw-r--r--cocoa/gui.m17
2 files changed, 16 insertions, 30 deletions
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index b0042f760..2a3382c8c 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -38,7 +38,6 @@
- (void) scrollVertical: (CGFloat) amount;
- (CGFloat) pageScroll;
-+ (void)reformatTimerFired: (NSTimer *) timer;
- (void) reformat;
- (void) popUpContextMenuForEvent: (NSEvent *) event;
@@ -60,8 +59,6 @@
static const CGFloat CaretWidth = 1.0;
static const NSTimeInterval CaretBlinkTime = 0.8;
-static NSMutableArray *cocoa_reformat_pending = nil;
-
- initWithFrame: (NSRect) frame;
{
@@ -438,13 +435,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
- (void) adjustFrame;
{
- browser->reformat_pending = true;
- browser_reformat_pending = true;
-
- if (cocoa_reformat_pending == nil) {
- cocoa_reformat_pending = [[NSMutableArray alloc] init];
- }
- [cocoa_reformat_pending addObject: self];
+ browser_window_schedule_reformat(browser);
[super adjustFrame];
}
@@ -492,24 +483,6 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
browser_window_reformat( browser, false, cocoa_pt_to_px( NSWidth( size ) ), cocoa_pt_to_px( NSHeight( size ) ) );
}
-+ (void)reformatTimerFired: (NSTimer *) timer;
-{
- if (browser_reformat_pending) {
- [cocoa_reformat_pending makeObjectsPerformSelector: @selector( reformat )];
- [cocoa_reformat_pending removeAllObjects];
- browser_reformat_pending = false;
- }
-}
-
-+ (void) initialize;
-{
- NSTimer *timer = [[NSTimer alloc] initWithFireDate: nil interval: 0.02
- target: self selector: @selector(reformatTimerFired:)
- userInfo: nil repeats: YES];
- [[NSRunLoop currentRunLoop] addTimer: timer forMode: NSRunLoopCommonModes];
- [timer release];
-}
-
- (void) popUpContextMenuForEvent: (NSEvent *) event;
{
if (content_get_type( browser->current_content ) != CONTENT_HTML) return;
diff --git a/cocoa/gui.m b/cocoa/gui.m
index 713f456cd..405dab9c2 100644
--- a/cocoa/gui.m
+++ b/cocoa/gui.m
@@ -129,8 +129,20 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
[[(BrowserViewController *)g browserView] scrollPoint: cocoa_point( sx, sy )];
}
-static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
- bool scaled)
+/**
+ * callback from core to reformat a window.
+ */
+static void cocoa_window_reformat(struct gui_window *gw)
+{
+ if (gw != NULL) {
+ [[(BrowserViewController *)g browserView] reformat ];
+ }
+}
+
+
+static void gui_window_get_dimensions(struct gui_window *g,
+ int *width, int *height,
+ bool scaled)
{
NSCParameterAssert( width != NULL && height != NULL );
@@ -278,6 +290,7 @@ static struct gui_window_table window_table = {
.set_scroll = gui_window_set_scroll,
.get_dimensions = gui_window_get_dimensions,
.update_extent = gui_window_update_extent,
+ .reformat = cocoa_window_reformat,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,