forked from ViennaRSS/vienna-rss
-
Notifications
You must be signed in to change notification settings - Fork 1
/
BrowserPane.m
771 lines (685 loc) · 21.3 KB
/
BrowserPane.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
//
// BrowserPane.m
// Vienna
//
// Created by Steve on 9/7/05.
// Copyright (c) 2004-2005 Steve Palmer. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "ViennaApp.h"
#import "BrowserPane.h"
#import "TabbedWebView.h"
#import "Constants.h"
#import "AppController.h"
#import "Preferences.h"
#import "HelperFunctions.h"
#import "StringExtensions.h"
#import "AddressBarCell.h"
#import <WebKit/WebKit.h>
#import "RichXMLParser.h"
@implementation BrowserPaneButtonCell
-(BOOL)isOpaque
{
return NO;
}
-(NSColor *)highlightColorInView:(NSView *)controlView
{
return nil;
}
@end
@implementation BrowserPaneButton
-(BOOL)isOpaque
{
return NO;
}
+(Class)cellClass
{
return [BrowserPaneButtonCell class];
}
-(NSColor *)highlightColorInView:(NSView *)controlView
{
return nil;
}
@end
@interface BrowserPane (Private)
-(void)endFrameLoad;
-(void)showRssPageButton:(BOOL)showButton;
-(void)setError:(NSError *)newError;
@end
@implementation BrowserPane
@synthesize webPane;
+ (void)load
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (self == [BrowserPane class]) {
//These are synonyms
[self exposeBinding:@"isLoading"];
[self exposeBinding:@"isProcessing"];
}
[pool release];
}
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
{
NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
if ([key isEqualToString:@"isProcessing"]) {
NSSet *affectingKeys = [NSSet setWithObjects:@"isLoading", nil];
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKeys];
}
return keyPaths;
}
/* initWithFrame
* Initialise our view.
*/
-(id)initWithFrame:(NSRect)frame
{
if (([super initWithFrame:frame]) != nil)
{
controller = nil;
[self willChangeValueForKey:@"isLoading"];
isLoading = NO;
[self didChangeValueForKey:@"isLoading"];
isLocalFile = NO;
viewTitle = nil;
openURLInBackground = NO;
pageFilename = nil;
lastError = nil;
rssPageURL = nil;
}
return self;
}
/* awakeFromNib
* Do things that only make sense once the NIB is loaded.
*/
-(void)awakeFromNib
{
// Create our webview
[self.webPane initTabbedWebView];
[self.webPane retain];
[self.webPane setUIDelegate:self];
[self.webPane setFrameLoadDelegate:self];
NSString * safariVersion = [[[NSBundle bundleWithPath:@"/Applications/Safari.app"] infoDictionary] objectForKey:@"CFBundleVersion"];
if (safariVersion)
safariVersion = [safariVersion substringFromIndex:1];
else
safariVersion = @"532.22";
[self.webPane setApplicationNameForUserAgent:[NSString stringWithFormat:MA_DefaultUserAgentString, [((ViennaApp *)NSApp) applicationVersion], safariVersion]];
// Make web preferences 16pt Arial to match Safari
[[self.webPane preferences] setStandardFontFamily:@"Arial"];
[[self.webPane preferences] setDefaultFontSize:16];
// Use an AddressBarCell for the address field which allows space for the
// web page image and an optional lock icon for secure pages.
AddressBarCell * cell = [[[AddressBarCell alloc] init] autorelease];
[cell setEditable:YES];
[cell setDrawsBackground:YES];
[cell setBordered:YES];
[cell setBezeled:YES];
[cell setScrollable:YES];
[cell setTarget:self];
[cell setAction:@selector(handleAddress:)];
[cell setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
[addressField setCell:cell];
// Initialise address field
[addressField setStringValue:@""];
// The RSS page button is hidden by default
[self showRssPageButton:NO];
// Set tooltips
[addressField setToolTip:NSLocalizedString(@"Enter the URL here", nil)];
[[addressField cell] accessibilitySetOverrideValue:NSLocalizedString(@"Enter the URL here", nil) forAttribute:NSAccessibilityTitleAttribute];
[refreshButton setToolTip:NSLocalizedString(@"Refresh the current page", nil)];
[[refreshButton cell] accessibilitySetOverrideValue:NSLocalizedString(@"Refresh the current page", nil) forAttribute:NSAccessibilityTitleAttribute];
[backButton setToolTip:NSLocalizedString(@"Return to the previous page", nil)];
[[backButton cell] accessibilitySetOverrideValue:NSLocalizedString(@"Return to the previous page", nil) forAttribute:NSAccessibilityTitleAttribute];
[forwardButton setToolTip:NSLocalizedString(@"Go forward to the next page", nil)];
[[forwardButton cell] accessibilitySetOverrideValue:NSLocalizedString(@"Go forward to the next page", nil) forAttribute:NSAccessibilityTitleAttribute];
[rssPageButton setToolTip:NSLocalizedString(@"Subscribe to the feed for this page", nil)];
[[rssPageButton cell] accessibilitySetOverrideValue:NSLocalizedString(@"Subscribe to the feed for this page", nil) forAttribute:NSAccessibilityTitleAttribute];
}
/* setController
* Sets the controller used by this view.
*/
-(void)setController:(AppController *)theController
{
controller = theController;
[self.webPane setController:controller];
}
/* viewLink
* Return the URL being displayed as a string.
*/
-(NSString *)viewLink
{
if ([[[self.webPane mainFrame] dataSource] unreachableURL])
return [[[[self.webPane mainFrame] dataSource] unreachableURL] absoluteString];
return [[self url] absoluteString];
}
/* showRssPageButton
* Conditionally show or hide the RSS page button.
*/
-(void)showRssPageButton:(BOOL)showButton
{
[rssPageButton setEnabled:showButton];
}
/* setError
* Save the most recent error instance.
*/
-(void)setError:(NSError *)newError
{
[newError retain];
[lastError release];
lastError = newError;
}
/* handleAddress
* Called when the user hits Enter on the address bar.
*/
-(IBAction)handleAddress:(id)sender
{
NSString * theURL = [addressField stringValue];
// If no '.' appears in the string, wrap it with 'www' and 'com'
if (![theURL hasCharacter:'.'])
theURL = [NSString stringWithFormat:@"www.%@.com", theURL];
// If no schema, prefix http://
if ([theURL rangeOfString:@"://"].location == NSNotFound)
theURL = [NSString stringWithFormat:@"http://%@", theURL];
// cleanUpUrl is a hack to handle Internationalized Domain Names. WebKit handles them automatically, so we tap into that.
NSURL *urlToLoad = cleanedUpAndEscapedUrlFromString(theURL);
if (urlToLoad != nil)
[self loadURL:urlToLoad inBackground:NO];
else
[self activateAddressBar];
}
-(void)setViewTitle:(NSString *) newTitle
{
[newTitle retain];
[viewTitle release];
viewTitle = newTitle;
}
/* activateAddressBar
* Put the focus on the address bar.
*/
-(void)activateAddressBar
{
[[NSApp mainWindow] makeFirstResponder:addressField];
}
/* loadURL
* Load the specified URL into the web frame.
*/
-(void)loadURL:(NSURL *)url inBackground:(BOOL)openInBackgroundFlag
{
[self setViewTitle:@""];
openURLInBackground = openInBackgroundFlag;
isLocalFile = [url isFileURL];
[pageFilename release];
pageFilename = [[[[url path] lastPathComponent] stringByDeletingPathExtension] retain];
[addressField setStringValue:[url absoluteString]];
[self retain];
if ([self.webPane isLoading])
{
[self willChangeValueForKey:@"isLoading"];
[self.webPane stopLoading:self];
[self didChangeValueForKey:@"isLoading"];
}
[[self.webPane mainFrame] loadRequest:[NSURLRequest requestWithURL:url]];
[self release];
}
/* setStatusText
* Called from the webview when some JavaScript writes status text. Echo this to
* our status bar.
*/
-(void)webView:(WebView *)sender setStatusText:(NSString *)text
{
if ([[controller browserView] activeTabItemView] == self)
[controller setStatusMessage:text persist:NO];
}
/* mouseDidMoveOverElement
* Called from the webview when the user positions the mouse over an element. If it's a link
* then echo the URL to the status bar like Safari does.
*/
-(void)webView:(WebView *)sender mouseDidMoveOverElement:(NSDictionary *)elementInformation modifierFlags:(NSUInteger )modifierFlags
{
NSURL * url = [elementInformation valueForKey:@"WebElementLinkURL"];
[controller setStatusMessage:(url ? [url absoluteString] : @"") persist:NO];
}
/* didStartProvisionalLoadForFrame
* Invoked when a new client request is made by sender to load a provisional data source for frame.
*/
-(void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame
{
if (frame == [self.webPane mainFrame])
{
[[controller browserView] setTabItemViewTitle:self title:NSLocalizedString(@"Loading...", nil)];
[self showRssPageButton:NO];
[self setError:nil];
[self setViewTitle:@""];
[self retain];
}
}
/* didCommitLoadForFrame
* Invoked when data source of frame has started to receive data.
*/
-(void)webView:(WebView *)sender didCommitLoadForFrame:(WebFrame *)frame
{
if (frame == [self.webPane mainFrame])
{
if (!isLoading)
{
[self willChangeValueForKey:@"isLoading"];
isLoading = YES;
[self didChangeValueForKey:@"isLoading"];
}
if (!openURLInBackground)
[[sender window] makeFirstResponder:sender];
// Show or hide the lock icon depending on whether this is a secure
// web page. Also shade the address bar a nice light yellow colour as
// Camino does.
NSURL * theURL = [[[frame dataSource] request] URL];
if ([[theURL scheme] isEqualToString:@"https"])
{
[[addressField cell] setHasSecureImage:YES];
[addressField setBackgroundColor:[NSColor colorWithDeviceRed:1.0 green:1.0 blue:0.777 alpha:1.0]];
[lockIconImage setHidden:NO];
}
else
{
[[addressField cell] setHasSecureImage:NO];
[addressField setBackgroundColor:[NSColor whiteColor]];
[lockIconImage setHidden:YES];
}
if (![[frame dataSource] unreachableURL])
[addressField setStringValue:[theURL absoluteString]];
else
[addressField setStringValue:[[[frame dataSource] unreachableURL] absoluteString]];
}
}
/* didFailProvisionalLoadWithError
* Invoked when a location request for frame has failed to load.
*/
-(void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
{
if (frame == [self.webPane mainFrame])
{
// Was this a feed redirect? If so, this isn't an error:
if (![self.webPane isFeedRedirect] && ![self.webPane isDownload])
{
[self setError:error];
// Use a warning sign as favicon
[iconImage setImage:[NSImage imageNamed:@"folderError.tiff"]];
// Load the localized verion of the error page
NSString * pathToErrorPage = [[NSBundle bundleForClass:[self class]] pathForResource:@"errorpage" ofType:@"html"];
if (pathToErrorPage != nil)
{
NSString *errorMessage = [NSString stringWithContentsOfFile:pathToErrorPage encoding:NSUTF8StringEncoding error:NULL];
errorMessage = [errorMessage stringByReplacingOccurrencesOfString: @"$ErrorInformation" withString: [error localizedDescription]];
if (errorMessage != nil)
{
[frame loadAlternateHTMLString:errorMessage baseURL:[NSURL fileURLWithPath:pathToErrorPage isDirectory:NO] forUnreachableURL:[[[frame provisionalDataSource] request] URL]];
}
NSString *unreachableURL = [[[frame provisionalDataSource] unreachableURL] absoluteString];
if (unreachableURL != nil)
[addressField setStringValue: [[[frame provisionalDataSource] unreachableURL] absoluteString]];
}
}
[self endFrameLoad];
}
}
/* endFrameLoad
* Handle the end of a load whether or not it completed and whether or not an error
* occurred. The error variable is nil for no error or it contains the most recent
* NSError incident.
*/
-(void)endFrameLoad
{
if ([viewTitle isEqualToString:@""])
{
if (lastError == nil)
[[controller browserView] setTabItemViewTitle:self title:pageFilename];
}
[self willChangeValueForKey:@"isLoading"];
isLoading = NO;
[self didChangeValueForKey:@"isLoading"];
openURLInBackground = NO;
[self release];
}
/* didFailLoadWithError
* Invoked when a location request for frame has failed to load.
*/
-(void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame
{
if (frame == [self.webPane mainFrame])
{
// Not really an error. A plugin is grabbing the URL and will handle it
// by itself.
if (!([[error domain] isEqualToString:WebKitErrorDomain] && [error code] == WebKitErrorPlugInWillHandleLoad))
{
[self setError:error];
// Use a warning sign as favicon
[iconImage setImage:[NSImage imageNamed:@"folderError.tiff"]];
// Load the localized verion of the error page
NSString * pathToErrorPage = [[NSBundle bundleForClass:[self class]] pathForResource:@"errorpage" ofType:@"html"];
if (pathToErrorPage != nil)
{
NSString *errorMessage = [NSString stringWithContentsOfFile:pathToErrorPage encoding:NSUTF8StringEncoding error:NULL];
errorMessage = [errorMessage stringByReplacingOccurrencesOfString: @"$ErrorInformation" withString: [error localizedDescription]];
if (errorMessage != nil)
{
[frame loadAlternateHTMLString:errorMessage baseURL:[NSURL fileURLWithPath:pathToErrorPage isDirectory:NO] forUnreachableURL:[[[frame dataSource] request] URL]];
}
}
}
[self endFrameLoad];
}
}
/* didFinishLoadForFrame
* Invoked when a location request for frame has successfully; that is, when all the resources are done loading.
*/
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
if (frame == [self.webPane mainFrame])
{
// Once the frame is loaded, trawl the source for possible links to RSS
// pages.
NSData * webSrc = [[frame dataSource] data];
NSMutableArray * arrayOfLinks = [NSMutableArray array];
if ([RichXMLParser extractFeeds:webSrc toArray:arrayOfLinks])
{
[rssPageURL release];
rssPageURL = [arrayOfLinks objectAtIndex:0];
if (![rssPageURL hasPrefix:@"http:"])
rssPageURL = [[self viewLink] stringByAppendingString:rssPageURL];
[rssPageURL retain];
[self showRssPageButton:YES];
}
[self endFrameLoad];
}
}
/* didReceiveTitle
* Invoked when the page title arrives. We use this to set the tab title.
*/
-(void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame
{
if (frame == [self.webPane mainFrame])
{
[[controller browserView] setTabItemViewTitle:self title:title];
[self setViewTitle:title];
}
}
/* didReceiveIcon
* Invoked when we get the page icon.
*/
-(void)webView:(WebView *)sender didReceiveIcon:(NSImage *)image forFrame:(WebFrame *)frame
{
if (frame == [self.webPane mainFrame])
{
[image setScalesWhenResized:YES];
[image setSize:NSMakeSize(14, 14)];
[iconImage setImage:image];
}
}
/* createWebViewWithRequest
* Called when the browser wants to create a new webview.
*/
-(WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request
{
[controller openURL:[request URL] inPreferredBrowser:YES];
// Change this to handle modifier key?
// Is this covered by the webView policy?
return nil;
}
/* runJavaScriptAlertPanelWithMessage
* Called when the browser wants to display a JavaScript alert panel containing the specified message.
*/
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
NSRunInformationalAlertPanel(NSLocalizedString(@"JavaScript", @""), // title
message, // message
NSLocalizedString(@"OK", @""), // default button
nil, // alt button
nil); // other button
}
/* runJavaScriptConfirmPanelWithMessage
* Called when the browser wants to display a JavaScript confirmation panel with the specified message.
*/
- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
NSInteger result = NSRunInformationalAlertPanel(NSLocalizedString(@"JavaScript", @""), // title
message, // message
NSLocalizedString(@"OK", @""), // default button
NSLocalizedString(@"Cancel", @""), // alt button
nil);
return NSAlertDefaultReturn == result;
}
/* setFrame
* Trap this to stop scripts from resizing the main Vienna window.
*/
-(void)webView:(WebView *)sender setFrame:(NSRect)frame
{
}
/* webViewClose
* Handle scripting closing a window by just closing the tab.
*/
-(void)webViewClose:(WebView *)sender
{
[[controller browserView] closeTabItemView:self];
}
/* contextMenuItemsForElement
* Creates a new context menu for our web pane.
*/
-(NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems
{
NSURL * urlLink = [element valueForKey:WebElementLinkURLKey];
if (urlLink != nil)
return [controller contextMenuItemsForElement:element defaultMenuItems:defaultMenuItems];
WebFrame * frameKey = [element valueForKey:WebElementFrameKey];
if (frameKey != nil && !isLocalFile)
return [controller contextMenuItemsForElement:element defaultMenuItems:defaultMenuItems];
return defaultMenuItems;
}
/* printDocument
* Print the web page.
*/
-(void)printDocument:(id)sender
{
[self.webPane printDocument:sender];
}
/* mainView
* Return the view that typically receives focus
*/
-(NSView *)mainView
{
return self.webPane;
}
/* webView
* Return the web view of this view.
*/
-(WebView *)webView
{
return self.webPane;
}
/* performFindPanelAction
* Implement the search action. Search the web page for the specified
* text.
*/
-(void)performFindPanelAction:(int)actionTag
{
switch (actionTag)
{
case NSFindPanelActionSetFindString:
{
[self.webPane searchFor:[controller searchString] direction:YES caseSensitive:NO wrap:YES];
break;
}
case NSFindPanelActionNext:
[self.webPane searchFor:[controller searchString] direction:YES caseSensitive:NO wrap:YES];
break;
case NSFindPanelActionPrevious:
[self.webPane searchFor:[controller searchString] direction:NO caseSensitive:NO wrap:YES];
break;
}
}
/* url
* Return the URL of the page being displayed.
*/
-(NSURL *)url
{
NSURL * theURL = nil;
WebDataSource * dataSource = [[self.webPane mainFrame] dataSource];
if (dataSource != nil)
{
theURL = [[dataSource request] URL];
}
else
{
NSString * urlString = [addressField stringValue];
if (urlString != nil)
theURL = [NSURL URLWithString:urlString];
}
return theURL;
}
-(NSString *)viewTitle
{
return viewTitle;
}
/* canGoForward
* Return TRUE if we can go forward to a web page.
*/
-(BOOL)canGoForward
{
return [self.webPane canGoForward];
}
/* canGoBack
* Return TRUE if we can go to a previous web page.
*/
-(BOOL)canGoBack
{
return [self.webPane canGoBack];
}
/* handleGoForward
* Go to the next web page.
*/
-(IBAction)handleGoForward:(id)sender
{
[self.webPane goForward];
}
/* handleGoBack
* Go to the previous web page.
*/
-(IBAction)handleGoBack:(id)sender
{
[self.webPane goBack];
}
/* swipeWithEvent
* Enables "back"/"forward" and "scroll to top"/"scroll to bottom" via three-finger swipes as in Safari and other applications.
*/
-(void)swipeWithEvent:(NSEvent *)event
{
CGFloat deltaX = [event deltaX];
CGFloat deltaY = [event deltaY];
// If the horizontal component of the swipe is larger, the user wants to go back or forward...
if (fabsf(deltaX) > fabsf(deltaY))
{
if (deltaX != 0)
{
if (deltaX > 0)
[self handleGoBack:self];
else
[self handleGoForward:self];
}
}
// Otherwise, she wants to go to the top/bottom of the page.
else
{
if (deltaY != 0)
{
if (deltaY > 0)
[self.webPane scrollToTop];
else
[self.webPane scrollToBottom];
}
}
}
/* handleReload
* Reload the current web page.
*/
-(IBAction)handleReload:(id)sender
{
if ([[self.webPane mainFrame] dataSource] != nil)
[self.webPane reload:self];
else
[self handleAddress:self];
}
/* handleStopLoading webview
* Stop loading the current web page.
*/
-(void)handleStopLoading:(id)sender
{
[self willChangeValueForKey:@"isLoading"];
[self.webPane stopLoading:self];
[self didChangeValueForKey:@"isLoading"];
}
/* handleRSSPage
* Open the RSS feed for the current page.
*/
-(IBAction)handleRSSPage:(id)sender
{
if (rssPageURL != nil)
{
Folder * currentFolder = [NSApp currentFolder];
int currentFolderId = [currentFolder itemId];
int parentFolderId = [currentFolder parentId];
if ([currentFolder firstChildId] > 0)
{
parentFolderId = currentFolderId;
currentFolderId = 0;
}
[[NSApp delegate] createNewSubscription:rssPageURL underFolder:parentFolderId afterChild:currentFolderId];
}
}
/* isLoading
* Returns whether the current web page is in the process of being loaded.
*/
-(BOOL)isLoading
{
return isLoading;
}
/* isProcessing
* Synonymous function that enables the progress indicator on the active tab.
*/
-(BOOL)isProcessing
{
return [self isLoading];
}
/* handleKeyDown [delegate]
* Support special key codes. If we handle the key, return YES otherwise
* return NO to allow the framework to pass it on for default processing.
*/
-(BOOL)handleKeyDown:(unichar)keyChar withFlags:(NSUInteger )flags
{
return NO;
}
/* dealloc
* Clean up when the view is being deleted.
*/
-(void)dealloc
{
[viewTitle release];
[rssPageURL release];
[self.webPane setFrameLoadDelegate:nil];
[self.webPane setUIDelegate:nil];
[self willChangeValueForKey:@"isLoading"];
[self.webPane stopLoading:self];
[self didChangeValueForKey:@"isLoading"];
[self.webPane removeFromSuperviewWithoutNeedingDisplay];
[self.webPane close];
[lastError release];
[pageFilename release];
self.webPane = nil;
[super dealloc];
}
@end