Plugins/WebKit Message View/AIWebKitMessageViewController.m
changeset 2728 bb4935318350
parent 2532 700469827eee
child 2729 2b6390521141
     1.1 --- a/Plugins/WebKit Message View/AIWebKitMessageViewController.m	Sun Jun 28 21:09:24 2009 -0700
     1.2 +++ b/Plugins/WebKit Message View/AIWebKitMessageViewController.m	Mon Nov 02 18:30:22 2009 -0500
     1.3 @@ -94,6 +94,7 @@
     1.4  
     1.5  @interface DOMDocument (FutureWebKitPublicMethodsIKnow)
     1.6  - (DOMNodeList *)getElementsByClassName:(NSString *)className;
     1.7 +- (DOMNodeList *)querySelectorAll:(NSString *)selectors; // We require 10.5.8/Safari 4, all is well!
     1.8  @end
     1.9  
    1.10  static NSArray *draggedTypes = nil;
    1.11 @@ -472,6 +473,7 @@
    1.12  	[self.markedScroller removeAllMarks];
    1.13  	[previousContent release];
    1.14  	previousContent = nil;
    1.15 +	nextMessageFocus = NO;
    1.16  	[chat clearUnviewedContentCount];
    1.17  }
    1.18  
    1.19 @@ -679,6 +681,12 @@
    1.20  			[self markCurrentLocation];
    1.21  		}
    1.22  		
    1.23 +		// Set it as a focus if appropriate.
    1.24 +		if (nextMessageFocus && [content.type isEqualToString:CONTENT_MESSAGE_TYPE]) {
    1.25 +			[content addDisplayClass:@"focus"];
    1.26 +			nextMessageFocus = NO;
    1.27 +		}
    1.28 +		
    1.29  		//Add the content object
    1.30  		[self _appendContent:content 
    1.31  					 similar:similar
    1.32 @@ -1451,18 +1459,23 @@
    1.33  	[scroller removeMarkWithIdentifier:@"focus"];
    1.34  	[scroller addMarkAt:[self.currentOffsetHeight integerValue] withIdentifier:@"focus" withColor:[NSColor redColor]];	
    1.35  	
    1.36 -	DOMElement *element = (DOMElement *)[webView.mainFrameDocument getElementById:@"focus"];
    1.37 -	if (element) {
    1.38 -		[element.parentNode removeChild:element];
    1.39 +	nextMessageFocus = YES;
    1.40 +	
    1.41 +	DOMNodeList *nodeList = [webView.mainFrameDocument querySelectorAll:@".focus"];
    1.42 +	DOMHTMLElement *node = nil; NSMutableArray *classes = nil;
    1.43 +	for (NSUInteger i = 0; i < nodeList.length; i++)
    1.44 +	{
    1.45 +		node = (DOMHTMLElement *)[nodeList item:i];
    1.46 +		classes = [[node.className componentsSeparatedByString:@" "] mutableCopy];
    1.47 +		
    1.48 +		[classes removeObject:@"focus"];
    1.49 +		
    1.50 +		node.className = [classes componentsJoinedByString:@" "];
    1.51 +		
    1.52 +		[classes release];
    1.53  	}
    1.54  	
    1.55 -	if ([[adium.preferenceController preferenceForKey:PREF_KEY_FOCUS_LINE group:PREF_GROUP_GENERAL] boolValue]) {
    1.56 -		element = [webView.mainFrameDocument createElement:@"hr"];
    1.57 -		[element setAttribute:@"id" value:@"focus"];
    1.58 -
    1.59 -		[element setAttribute:@"style" value:[NSString stringWithFormat:@"position: absolute; top: %dpx;", self.currentOffsetHeight.integerValue - 1]];
    1.60 -		[[(DOMHTMLDocument *)webView.mainFrameDocument body] appendChild:element];
    1.61 -	}
    1.62 +	nextMessageFocus = YES;
    1.63  }
    1.64  
    1.65  - (void)addMark