Changeset 3333
- Timestamp:
- 08/19/06 23:42:01 (2 years ago)
- Files:
-
- trunk/Colloquy.xcodeproj/project.pbxproj (modified) (2 diffs)
- trunk/Panels/JVChatTranscriptPanel.m (modified) (2 diffs)
- trunk/Preferences/JVAppearancePreferences.m (modified) (1 diff)
- trunk/Resources/base.html (modified) (1 diff)
- trunk/Resources/template.html (modified) (1 diff)
- trunk/Views/JVStyleView.h (modified) (1 diff)
- trunk/Views/JVStyleView.m (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Colloquy.xcodeproj/project.pbxproj
r3332 r3333 1911 1911 isa = PBXProject; 1912 1912 buildConfigurationList = 1C041A700854E97700A5A5BA /* Build configuration list for PBXProject "Colloquy" */; 1913 compatibilityVersion = "Xcode 2.4"; 1913 1914 hasScannedForEncodings = 1; 1914 1915 knownRegions = ( … … 1960 1961 ); 1961 1962 projectRoot = ""; 1963 shouldCheckCompatibility = 1; 1962 1964 targets = ( 1963 1965 1CB2CCF5052DDC560094AAA4 /* Colloquy (Application) */, trunk/Panels/JVChatTranscriptPanel.m
r3252 r3333 670 670 } 671 671 672 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2673 #define NSWorkspaceLaunchWithoutActivation 0x00000200674 #endif675 676 672 - (void) webView:(WebView *) sender decidePolicyForNavigationAction:(NSDictionary *) actionInformation request:(NSURLRequest *) request frame:(WebFrame *) frame decisionListener:(id <WebPolicyDecisionListener>) listener { 677 673 NSURL *url = [actionInformation objectForKey:WebActionOriginalURLKey]; … … 680 676 if( [[[url standardizedURL] path] length] ) [listener ignore]; 681 677 else [listener use]; 678 } else if( [url isFileURL] && [[url path] hasPrefix:[[NSBundle mainBundle] resourcePath]] ) { 679 [listener use]; 682 680 } else if( [[url scheme] isEqualToString:@"self"] ) { 683 681 NSString *resource = [url resourceSpecifier]; trunk/Preferences/JVAppearancePreferences.m
r3072 r3333 312 312 313 313 - (void) webView:(WebView *) sender decidePolicyForNavigationAction:(NSDictionary *) actionInformation request:(NSURLRequest *) request frame:(WebFrame *) frame decisionListener:(id <WebPolicyDecisionListener>) listener { 314 if( [[[actionInformation objectForKey:WebActionOriginalURLKey] scheme] isEqualToString:@"about"] ) { 314 NSURL *url = [actionInformation objectForKey:WebActionOriginalURLKey]; 315 316 if( [[url scheme] isEqualToString:@"about"] ) { 317 if( [[[url standardizedURL] path] length] ) [listener ignore]; 318 else [listener use]; 319 } else if( [url isFileURL] && [[url path] hasPrefix:[[NSBundle mainBundle] resourcePath]] ) { 315 320 [listener use]; 316 321 } else { 317 NSURL *url = [actionInformation objectForKey:WebActionOriginalURLKey];318 322 [[NSWorkspace sharedWorkspace] openURL:url]; 319 323 [listener ignore]; trunk/Resources/base.html
r3152 r3333 4 4 <head> 5 5 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 6 <title>%@</title>7 <base href="%@" />8 6 <script type="text/ecmascript" defer="defer" encoding="utf-8" src="roomTopicBanner.js" /> 9 7 <style type="text/css"> trunk/Resources/template.html
r3014 r3333 4 4 <head> 5 5 <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 6 <meta name="generator" content="Colloquy 2. 0.1" />6 <meta name="generator" content="Colloquy 2.1" /> 7 7 <meta name="formatter" content="libxslt 1.1.11" /> 8 8 <title>%@</title> 9 9 %@ 10 <script id="defaultScript" type="text/ecmascript" defer="defer" src=" %@/default.js" encoding="utf-8" />11 <link id="defaultStyle" rel="stylesheet" type="text/css" href=" %3$@/default.css" />10 <script id="defaultScript" type="text/ecmascript" defer="defer" src="default.js" encoding="utf-8"></script> 11 <link id="defaultStyle" rel="stylesheet" type="text/css" href="default.css" /> 12 12 <link id="emoticonStyle" rel="stylesheet" type="text/css" href="%@" /> 13 13 <link id="mainStyle" rel="stylesheet" type="text/css" href="%@" /> 14 14 <link id="variantStyle" rel="stylesheet" type="text/css" href="%@" /> 15 <base href="%@" />16 15 </head> 17 16 <body> trunk/Views/JVStyleView.h
r3259 r3333 83 83 - (void) jumpToMessage:(JVChatMessage *) message; 84 84 - (void) scrollToBottom; 85 - (BOOL) scrolledNearBottom; 85 86 86 87 - (NSTextView *) nextTextView; trunk/Views/JVStyleView.m
r3332 r3333 16 16 #pragma mark - 17 17 18 @interface WebView (WebView Private) // WebKit 1.3/2.0 pending public API19 - (void) setDrawsBackground:(BOOL) draws; 20 - (BOOL) drawsBackground; 18 @interface WebView (WebViewLeopard) 19 - (void) setDrawsBackground:(BOOL) draws; // supported in 10.3.9/Tiger 20 - (BOOL) drawsBackground; // supported in 10.3.9/Tiger 21 21 - (WebFrame *) selectedFrame; 22 @end 23 24 @interface WebView (WebViewPrivate) 22 25 - (WebFrame *) _frameForCurrentSelection; 23 26 @end 24 27 25 @interface DOMHTMLElement (DOMHTMLElement Private)28 @interface DOMHTMLElement (DOMHTMLElementLeopard) 26 29 - (int) offsetTop; 30 - (int) offsetHeight; 27 31 - (int) scrollHeight; 28 32 @end … … 42 46 - (void) _prependMessages:(NSString *) messages; 43 47 - (void) _styleError; 44 - (NSString *) _baseHTML;45 48 - (NSString *) _contentHTMLWithBody:(NSString *) html; 49 - (NSURL *) _baseURL; 46 50 - (unsigned long) _visibleMessageCount; 47 51 - (long) _locationOfMessage:(JVChatMessage *) message; … … 307 311 308 312 unsigned int location = 0; 309 if( [elt respondsToSelector:@selector( scrollTop )] )313 if( [elt respondsToSelector:@selector( offsetTop )] ) 310 314 location = [elt offsetTop]; 311 315 else location = [[elt valueForKey:@"offsetTop"] longValue]; … … 475 479 476 480 WebFrame *contentFrame = [[self mainFrame] findFrameNamed:@"content"]; 477 [contentFrame loadHTMLString:[self _contentHTMLWithBody:@""] baseURL: nil];478 } else if( _mainFrameReady ) {481 [contentFrame loadHTMLString:[self _contentHTMLWithBody:@""] baseURL:[self _baseURL]]; 482 } else if( _mainFrameReady ) { 479 483 if( [[[[[frame dataSource] response] URL] absoluteString] isEqualToString:@"about:blank"] ) { 480 484 // this was a false content frame load, try again 481 [frame loadHTMLString:[self _contentHTMLWithBody:@""] baseURL: nil];485 [frame loadHTMLString:[self _contentHTMLWithBody:@""] baseURL:[self _baseURL]]; 482 486 return; 483 487 } … … 579 583 else [_body setValue:[_body valueForKey:@"scrollHeight"] forKey:@"scrollTop"]; 580 584 } 585 586 - (BOOL) scrolledNearBottom { 587 WebFrame *contentFrame = [[self mainFrame] findFrameNamed:@"content"]; 588 DOMHTMLElement *contentFrameElement = [contentFrame frameElement]; 589 unsigned int frameHeight = 0; 590 if( [contentFrameElement respondsToSelector:@selector( offsetHeight )] ) 591 frameHeight = [contentFrameElement offsetHeight]; 592 else frameHeight = [[contentFrameElement valueForKey:@"offsetHeight"] unsignedIntValue]; 593 594 unsigned int scrollHeight = 0; 595 if( [_body respondsToSelector:@selector( scrollHeight )] ) 596 scrollHeight = [_body scrollHeight]; 597 else scrollHeight = [[_body valueForKey:@"scrollHeight"] unsignedIntValue]; 598 599 unsigned int scrollTop = [[_body valueForKey:@"scrollTop"] unsignedIntValue]; 600 601 // check if we are near the bottom 10 pixels of the chat area 602 return ( ( frameHeight + scrollTop ) >= ( scrollHeight - 15 ) ); 603 } 581 604 @end 582 605 … … 617 640 _contentFrameReady = NO; 618 641 if( _rememberScrollPosition ) { 619 if( [_body respondsToSelector:@selector( scrollTop )] ) 620 _lastScrollPosition = [_body offsetTop]; 621 else _lastScrollPosition = [[_body valueForKey:@"scrollTop"] longValue]; 642 _lastScrollPosition = [[_body valueForKey:@"scrollTop"] longValue]; 622 643 } else _lastScrollPosition = 0; 623 644 … … 626 647 if( _mainFrameReady ) { 627 648 WebFrame *contentFrame = [[self mainFrame] findFrameNamed:@"content"]; 628 [contentFrame loadHTMLString:[self _contentHTMLWithBody:@""] baseURL:nil]; 629 } else [[self mainFrame] loadHTMLString:[self _baseHTML] baseURL:nil]; 649 [contentFrame loadHTMLString:[self _contentHTMLWithBody:@""] baseURL:[self _baseURL]]; 650 } else { 651 NSString *path = [[NSBundle mainBundle] pathForResource:@"base" ofType:@"html"]; 652 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:path] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:5.]; 653 [[self mainFrame] loadRequest:request]; 654 } 630 655 } 631 656 … … 701 726 702 727 // check if we are near the bottom of the chat area, and if we should scroll down later 703 BOOL scrollNeeded = ( ! [(NSScrollView *)[scroller superview] hasVerticalScroller] || [scroller floatValue] >= 0.990 );728 BOOL scrollNeeded = [self scrolledNearBottom]; 704 729 705 730 // check how much we need to shift the scrollbar marks … … 741 766 742 767 if( ! scrollNeeded && shiftAmount > 0 ) { 743 unsigned long scrollTop = 0; 744 if( [_body respondsToSelector:@selector( scrollTop )] ) 745 scrollTop = [_body offsetTop]; 746 else scrollTop = [[_body valueForKey:@"scrollTop"] longValue]; 768 unsigned long scrollTop = [[_body valueForKey:@"scrollTop"] longValue]; 747 769 [_body setValue:[NSNumber numberWithUnsignedLong:( scrollTop - shiftAmount )] forKey:@"scrollTop"]; 748 770 } … … 760 782 761 783 // check if we are near the bottom of the chat area, and if we should scroll down later 762 JVMarkedScroller *scroller = [self verticalMarkedScroller]; 763 BOOL scrollNeeded = ( ! scroller || [scroller floatValue] >= 0.985 ); 784 BOOL scrollNeeded = [self scrolledNearBottom]; 764 785 765 786 // parses the message so we can get the DOM tree … … 813 834 #pragma mark - 814 835 815 - (NSString *) _baseHTML {816 NSURL *resources = [NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]];817 818 NSString *shell = nil;819 if( floor( NSAppKitVersionNumber ) <= NSAppKitVersionNumber10_3 ) // test for 10.3820 shell = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"base" ofType:@"html"]];821 else shell = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"base" ofType:@"html"] encoding:NSUTF8StringEncoding error:NULL];822 823 return [NSString stringWithFormat:shell, @"", [resources absoluteString]];824 }825 826 836 - (NSString *) _contentHTMLWithBody:(NSString *) html { 827 NSURL *resources = [NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]];828 837 NSString *variantStyleSheetLocation = [[[self style] variantStyleSheetLocationWithName:[self styleVariant]] absoluteString]; 829 838 if( ! variantStyleSheetLocation ) variantStyleSheetLocation = @""; … … 834 843 else shell = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"template" ofType:@"html"] encoding:NSUTF8StringEncoding error:NULL]; 835 844 836 return [NSString stringWithFormat:shell, @"", @"", [resources absoluteString], [[[self emoticons] styleSheetLocation] absoluteString], [[[self style] mainStyleSheetLocation] absoluteString], variantStyleSheetLocation, [[[self style] baseLocation] absoluteString], [[self style] contentsOfBodyTemplateWithName:[self bodyTemplate]]]; 845 return [NSString stringWithFormat:shell, @"", @"", [[[self emoticons] styleSheetLocation] absoluteString], [[[self style] mainStyleSheetLocation] absoluteString], variantStyleSheetLocation, [[[self style] baseLocation] absoluteString], [[self style] contentsOfBodyTemplateWithName:[self bodyTemplate]]]; 846 } 847 848 - (NSURL *) _baseURL { 849 return [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"template" ofType:@"html"]]; 837 850 } 838 851
