Changeset 3321

Show
Ignore:
Timestamp:
08/05/06 14:11:53 (2 years ago)
Author:
timothy
Message:

Fixes to work better with WebKit? TOT.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Views/JVStyleView.m

    r3291 r3321  
    292292- (void) mark { 
    293293        if( _contentFrameReady ) { 
    294                 unsigned int location = 0; 
    295  
    296                 DOMElement *elt = [_domDocument getElementById:@"mark"]; 
     294                DOMHTMLElement *elt = (DOMHTMLElement *)[_domDocument getElementById:@"mark"]; 
    297295                if( elt ) [[elt parentNode] removeChild:elt]; 
    298                 elt = [_domDocument createElement:@"hr"]; 
     296                elt = (DOMHTMLElement *)[_domDocument createElement:@"hr"]; 
    299297                [elt setAttribute:@"id" :@"mark"]; 
    300298                [_body appendChild:elt]; 
    301299                [self scrollToBottom]; 
    302                 location = [[elt valueForKey:@"offsetTop"] longValue]; 
     300 
     301                unsigned int location = 0; 
     302                if( [elt respondsToSelector:@selector( scrollTop )] ) 
     303                        location = [elt offsetTop]; 
     304                else location = [[elt valueForKey:@"offsetTop"] longValue]; 
    303305 
    304306                JVMarkedScroller *scroller = [self verticalMarkedScroller]; 
     
    548550        } 
    549551 
    550         [_body setValue:[_body valueForKey:@"scrollHeight"] forKey:@"scrollTop"]; 
     552        if( [_body respondsToSelector:@selector( scrollHeight )] ) 
     553                [_body setValue:[NSNumber numberWithUnsignedInt:[_body scrollHeight]] forKey:@"scrollTop"]; 
     554        else [_body setValue:[_body valueForKey:@"scrollHeight"] forKey:@"scrollTop"]; 
    551555} 
    552556@end 
     
    588592        _contentFrameReady = NO; 
    589593        if( _rememberScrollPosition ) { 
    590                 _lastScrollPosition = [[_body valueForKey:@"scrollTop"] longValue]; 
     594                if( [_body respondsToSelector:@selector( scrollTop )] ) 
     595                        _lastScrollPosition = [_body offsetTop]; 
     596                else _lastScrollPosition = [[_body valueForKey:@"scrollTop"] longValue]; 
    591597        } else _lastScrollPosition = 0; 
    592598 
     
    714720 
    715721        if( ! scrollNeeded && shiftAmount > 0 ) { 
    716                 unsigned long scrollTop = [[_body valueForKey:@"scrollTop"] longValue]; 
     722                unsigned long scrollTop = 0; 
     723                if( [_body respondsToSelector:@selector( scrollTop )] ) 
     724                        scrollTop = [_body offsetTop]; 
     725                else scrollTop = [[_body valueForKey:@"scrollTop"] longValue]; 
    717726                [_body setValue:[NSNumber numberWithUnsignedLong:( scrollTop - shiftAmount )] forKey:@"scrollTop"]; 
    718727        } 
     
    810819 
    811820- (long) _locationOfMessageWithIdentifier:(NSString *) identifier { 
    812         if( ! _contentFrameReady ) return 0; 
    813         if( ! [identifier length] ) return 0; 
    814  
    815         DOMElement *element = [_domDocument getElementById:identifier]; 
     821        if( ! _contentFrameReady ) return NSNotFound; 
     822        if( ! [identifier length] ) return NSNotFound; 
     823 
     824        DOMHTMLElement *element = (DOMHTMLElement *)[_domDocument getElementById:identifier]; 
     825        if( [element respondsToSelector:@selector( offsetTop )] ) 
     826                return [element offsetTop]; 
    816827        id value = [element valueForKey:@"offsetTop"]; 
    817828        if( [value respondsToSelector:@selector( longValue )] ) 
     
    825836 
    826837- (long) _locationOfElementAtIndex:(unsigned long) index { 
    827         if( ! _contentFrameReady ) return NSNotFound; 
    828         id value = [[[_body childNodes] item:index] valueForKey:@"offsetTop"]; 
    829         if( index < [[_body childNodes] length] && [value respondsToSelector:@selector( longValue )] ) 
     838        if( ! _contentFrameReady || index >= [[_body childNodes] length] ) 
     839                return NSNotFound; 
     840        DOMNode *node = [[_body childNodes] item:index]; 
     841        if( ! [node isKindOfClass:[DOMHTMLElement class]] ) 
     842                return NSNotFound; 
     843        if( [node respondsToSelector:@selector( offsetTop )] ) 
     844                return [(DOMHTMLElement *)node offsetTop]; 
     845        id value = [node valueForKey:@"offsetTop"]; 
     846        if( [value respondsToSelector:@selector( longValue )] ) 
    830847                return [value longValue]; 
    831848        return NSNotFound;