Changeset 3606
- Timestamp:
- 03/09/07 03:07:48 (2 years ago)
- Files:
-
- trunk/Resources/Styles/Bland.colloquyStyle/Contents/Resources/genericTemplate.html (modified) (1 diff)
- trunk/Resources/Styles/Fiat.colloquyStyle/Contents/Resources/genericTemplate.html (modified) (1 diff)
- trunk/Resources/Styles/Standard.colloquyStyle/Contents/Resources/genericTemplate.html (modified) (1 diff)
- trunk/Resources/template.html (modified) (1 diff)
- trunk/Views/JVStyleView.m (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Resources/Styles/Bland.colloquyStyle/Contents/Resources/genericTemplate.html
r3372 r3606 17 17 bottomAlignChat(); 18 18 </script> 19 <div id="contents"></div> trunk/Resources/Styles/Fiat.colloquyStyle/Contents/Resources/genericTemplate.html
r3370 r3606 4 4 } 5 5 </script> 6 <div id="contents"></div> trunk/Resources/Styles/Standard.colloquyStyle/Contents/Resources/genericTemplate.html
r3375 r3606 37 37 } 38 38 </script> 39 <div id="contents"></div> trunk/Resources/template.html
r3560 r3606 15 15 <base href="%@" /> 16 16 </head> 17 <body> 18 %@ 19 </body> 17 <body>%@</body> 20 18 </html> trunk/Views/JVStyleView.m
r3605 r3606 28 28 @end 29 29 30 #pragma mark - 31 30 32 @interface WebView (WebViewPrivate) 31 33 - (WebFrame *) _frameForCurrentSelection; 32 34 @end 35 36 #pragma mark - 33 37 34 38 @interface DOMHTMLElement (DOMHTMLElementLeopard) … … 42 46 @interface NSScrollView (NSScrollViewWebKitPrivate) 43 47 - (void) setAllowsHorizontalScrolling:(BOOL) allow; 48 @end 49 50 #pragma mark - 51 52 @interface DOMHTMLElement (DOMHTMLElementExtras) 53 - (unsigned) childElementLength; 54 - (DOMNode *) childElementAtIndex:(unsigned) index; 55 @end 56 57 #pragma mark - 58 59 @implementation DOMHTMLElement (DOMHTMLElementExtras) 60 - (unsigned) childElementLength { 61 unsigned length = 0; 62 63 DOMNode *node = [self firstChild]; 64 while (node) { 65 if( [node nodeType] == DOM_ELEMENT_NODE ) ++length; 66 node = [node nextSibling]; 67 } 68 69 return length; 70 } 71 72 - (DOMNode *) childElementAtIndex:(unsigned) index { 73 unsigned count = 0; 74 DOMNode *node = [self firstChild]; 75 while (node) { 76 if( [node nodeType] == DOM_ELEMENT_NODE && count++ == index ) 77 return node; 78 node = [node nextSibling]; 79 } 80 81 return nil; 82 } 44 83 @end 45 84 … … 589 628 long shift = [scroller shiftAmountToCenterAlign]; 590 629 [scroller setLocationOfCurrentMark:loc]; 591 [ _bodysetValue:[NSNumber numberWithUnsignedLong:( loc - shift )] forKey:@"scrollTop"];630 [[_domDocument body] setValue:[NSNumber numberWithUnsignedLong:( loc - shift )] forKey:@"scrollTop"]; 592 631 } 593 632 } … … 599 638 } 600 639 601 if( [_body respondsToSelector:@selector( scrollHeight )] ) 602 [_body setValue:[NSNumber numberWithUnsignedInt:[_body scrollHeight]] forKey:@"scrollTop"]; 603 else [_body setValue:[_body valueForKey:@"scrollHeight"] forKey:@"scrollTop"]; 640 DOMHTMLElement *body = [_domDocument body]; 641 if( [body respondsToSelector:@selector( scrollHeight )] ) 642 [body setValue:[NSNumber numberWithUnsignedInt:[body scrollHeight]] forKey:@"scrollTop"]; 643 else [body setValue:[body valueForKey:@"scrollHeight"] forKey:@"scrollTop"]; 604 644 } 605 645 … … 613 653 614 654 unsigned int scrollHeight = 0; 615 if( [_body respondsToSelector:@selector( scrollHeight )] ) 616 scrollHeight = [_body scrollHeight]; 617 else scrollHeight = [[_body valueForKey:@"scrollHeight"] unsignedIntValue]; 618 619 unsigned int scrollTop = [[_body valueForKey:@"scrollTop"] unsignedIntValue]; 655 DOMHTMLElement *body = [_domDocument body]; 656 if( [body respondsToSelector:@selector( scrollHeight )] ) 657 scrollHeight = [body scrollHeight]; 658 else scrollHeight = [[body valueForKey:@"scrollHeight"] unsignedIntValue]; 659 660 unsigned int scrollTop = [[body valueForKey:@"scrollTop"] unsignedIntValue]; 620 661 621 662 // check if we are near the bottom 10 pixels of the chat area … … 661 702 _contentFrameReady = NO; 662 703 if( _rememberScrollPosition ) { 663 _lastScrollPosition = [[ _bodyvalueForKey:@"scrollTop"] longValue];704 _lastScrollPosition = [[[_domDocument body] valueForKey:@"scrollTop"] longValue]; 664 705 } else _lastScrollPosition = 0; 665 706 … … 736 777 if( _rememberScrollPosition ) { 737 778 _rememberScrollPosition = NO; 738 [ _bodysetValue:[NSNumber numberWithUnsignedLong:_lastScrollPosition] forKey:@"scrollTop"];779 [[_domDocument body] setValue:[NSNumber numberWithUnsignedLong:_lastScrollPosition] forKey:@"scrollTop"]; 739 780 } 740 781 } … … 743 784 if( ! _body ) return; 744 785 745 long shiftAmount = 0;746 786 unsigned int messageCount = [self _visibleMessageCount] + 1; 747 787 unsigned int scrollbackLimit = [self scrollbackLimit]; … … 751 791 752 792 // check if we are near the bottom of the chat area, and if we should scroll down later 753 BOOL scrollNeeded = [self scrolledNearBottom]; 754 755 // check how much we need to shift the scrollbar marks 756 if( ! consecutive && messageCount > scrollbackLimit ) { 757 shiftAmount = [self _locationOfElementAtIndex:( messageCount - scrollbackLimit )]; 758 if( shiftAmount > 0 && shiftAmount != NSNotFound ) 759 [scroller shiftMarksAndShadedAreasBy:( shiftAmount * -1 )]; 760 } 793 BOOL scrollToBottomNeeded = [self scrolledNearBottom]; 761 794 762 795 NSMutableString *transformedMessage = [message mutableCopyWithZone:nil]; … … 782 815 transformedMessage = nil; 783 816 817 long shiftAmount = 0; 818 // check how much we need to shift the scrollbar marks 819 if( ! consecutive && messageCount > scrollbackLimit ) 820 shiftAmount = [self _locationOfElementAtIndex:( messageCount - scrollbackLimit )]; 821 784 822 // enforce the scrollback limit 785 if( scroll backLimit > 0 && messageCount > scrollbackLimit ) {823 if( scrollToBottomNeeded && scrollbackLimit > 0 && messageCount > scrollbackLimit ) { 786 824 for( unsigned int i = 0; messageCount > scrollbackLimit && i < ( messageCount - scrollbackLimit ); i++ ) { 787 825 [_body removeChild:[_body firstChild]]; … … 790 828 } 791 829 792 if( ! scrollNeeded && shiftAmount > 0 ) { 793 unsigned long scrollTop = [[_body valueForKey:@"scrollTop"] longValue]; 794 [_body setValue:[NSNumber numberWithUnsignedLong:( scrollTop - shiftAmount )] forKey:@"scrollTop"]; 830 if( scrollToBottomNeeded && shiftAmount > 0 && shiftAmount != NSNotFound ) { 831 DOMHTMLElement *body = [_domDocument body]; 832 unsigned long scrollTop = [[body valueForKey:@"scrollTop"] longValue]; 833 [body setValue:[NSNumber numberWithUnsignedLong:( scrollTop - shiftAmount )] forKey:@"scrollTop"]; 834 [scroller shiftMarksAndShadedAreasBy:( shiftAmount * -1 )]; 795 835 } 796 836 797 837 [[self verticalMarkedScroller] setNeedsDisplay:YES]; 798 838 799 if( scroll Needed ) [self scrollToBottom];839 if( scrollToBottomNeeded ) [self scrollToBottom]; 800 840 } 801 841 … … 906 946 907 947 - (long) _locationOfElementAtIndex:(unsigned long) index { 908 if( ! _contentFrameReady || index >= [[_body childNodes] length])948 if( ! _contentFrameReady ) 909 949 return NSNotFound; 910 DOMNode *node = [ [_body childNodes] item:index];911 if( ! [node isKindOfClass:[DOMHTMLElement class]] )950 DOMNode *node = [_body childElementAtIndex:index]; 951 if( ! node || ! [node isKindOfClass:[DOMHTMLElement class]] ) 912 952 return NSNotFound; 913 953 if( [node respondsToSelector:@selector( offsetTop )] ) … … 921 961 - (unsigned long) _visibleMessageCount { 922 962 if( ! _contentFrameReady ) return 0; 923 return [ [_body childNodes] length];924 } 925 @end 963 return [_body childElementLength]; 964 } 965 @end
