+2006-10-08 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej.
+
+ - fix two recently introduced leaks: one of an NSString, the other of a WebDataSource
+
+ * Loader/WebDocumentLoadState.m: (-[WebDocumentLoadState setTitle:]):
+ Rearranged code to avoid storage leak in case of identical title.
+
+ * Loader/WebFrameLoader.h: Removed _setPolicyDocumentLoadState: method
+ from the header.
+ * Loader/WebFrameLoader.m:
+ (-[WebFrameLoader _setPolicyDocumentLoadState:]): Added logic to call detachFromFrameLoader
+ as needed if this load state is going away rather than moving on to become the provisional
+ load state.
+ (-[WebFrameLoader shouldReloadToHandleUnreachableURLFromRequest:]): Tweaked formatting.
+ (-[WebFrameLoader _loadRequest:archive:]): Added an assertion.
+ (-[WebFrameLoader _loadRequest:triggeringAction:loadType:formState:]): Added an assertion.
+ (-[WebFrameLoader _reloadAllowingStaleDataWithOverrideEncoding:]): Added an assertion.
+ (-[WebFrameLoader reload]): Added an assertion.
+ (-[WebFrameLoader loadDataSource:withLoadType:formState:]): Added a local variable to avoid
+ calling _documentLoadState over and over again.
+
2006-10-07 Don Gibson <dgibson77@gmail.com>
Reviewed/landed by Adam.
- (void)setTitle:(NSString *)title
{
- NSString *trimmed = nil;
- if (title) {
- trimmed = [title mutableCopy];
- CFStringTrimWhitespace((CFMutableStringRef)trimmed);
- if ([trimmed length] == 0) {
- [trimmed release];
- trimmed = nil;
- }
- }
-
- if (!trimmed)
- return;
-
- if ([pageTitle isEqualToString:trimmed])
+ if (!title)
return;
- [frameLoader willChangeTitleForDocumentLoadState:self];
+ NSString *trimmed = [title mutableCopy];
+ CFStringTrimWhitespace((CFMutableStringRef)trimmed);
- [pageTitle release];
- pageTitle = [trimmed copy];
+ if ([trimmed length] != 0 && ![pageTitle isEqualToString:trimmed]) {
+ [frameLoader willChangeTitleForDocumentLoadState:self];
+ [pageTitle release];
+ pageTitle = [trimmed copy];
+ [frameLoader didChangeTitleForDocumentLoadState:self];
+ }
[trimmed release];
-
- [frameLoader didChangeTitleForDocumentLoadState:self];
}
@end
#import "WebDataProtocol.h"
#import "WebDataSourceInternal.h"
+#import "WebDocumentLoadStateMac.h"
#import "WebDownloadInternal.h"
#import "WebFrameBridge.h"
#import "WebFrameInternal.h"
- (void)_setPolicyDocumentLoadState:(WebDocumentLoadState *)loadState
{
- [loadState retain];
+ if (policyDocumentLoadState == loadState)
+ return;
+
+ if (policyDocumentLoadState != provisionalDocumentLoadState && policyDocumentLoadState != documentLoadState)
+ [policyDocumentLoadState detachFromFrameLoader];
+
[policyDocumentLoadState release];
- policyDocumentLoadState = loadState;
+ [loadState retain];
+ policyDocumentLoadState = nil;
}
- (void)clearDataSource
// case handles malformed URLs and unknown schemes. Loading alternate content
// at other times behaves like a standard load.
WebDataSource *compareDataSource = nil;
- if (delegateIsDecidingNavigationPolicy || delegateIsHandlingUnimplementablePolicy) {
+ if (delegateIsDecidingNavigationPolicy || delegateIsHandlingUnimplementablePolicy)
compareDataSource = [self policyDataSource];
- } else if (delegateIsHandlingProvisionalLoadError) {
+ else if (delegateIsHandlingProvisionalLoadError)
compareDataSource = [self provisionalDataSource];
- }
return compareDataSource != nil && [unreachableURL isEqual:[[compareDataSource request] URL]];
}
{
WebFrameLoadType type;
+ ASSERT(!policyDocumentLoadState);
policyDocumentLoadState = [client _createDocumentLoadStateWithRequest:request];
WebDataSource *newDataSource = [client _dataSourceForDocumentLoadState:policyDocumentLoadState];
- (void)_loadRequest:(NSURLRequest *)request triggeringAction:(NSDictionary *)action loadType:(WebFrameLoadType)type formState:(WebFormState *)formState
{
+ ASSERT(!policyDocumentLoadState);
policyDocumentLoadState = [client _createDocumentLoadStateWithRequest:request];
WebDataSource *newDataSource = [client _dataSourceForDocumentLoadState:policyDocumentLoadState];
[policyDocumentLoadState setTriggeringAction:action];
-
[policyDocumentLoadState setOverrideEncoding:[[self documentLoadState] overrideEncoding]];
[self loadDataSource:newDataSource withLoadType:type formState:formState];
[request setURL:unreachableURL];
[request setCachePolicy:NSURLRequestReturnCacheDataElseLoad];
+ ASSERT(!policyDocumentLoadState);
policyDocumentLoadState = [client _createDocumentLoadStateWithRequest:request];
WebDataSource *newDataSource = [client _dataSourceForDocumentLoadState:policyDocumentLoadState];
[request release];
if (unreachableURL != nil)
initialRequest = [NSURLRequest requestWithURL:unreachableURL];
+ ASSERT(!policyDocumentLoadState);
policyDocumentLoadState = [client _createDocumentLoadStateWithRequest:initialRequest];
WebDataSource *newDataSource = [client _dataSourceForDocumentLoadState:policyDocumentLoadState];
NSMutableURLRequest *request = [newDataSource request];
[decisionListener release];
}
--(void)_continueAfterNewWindowPolicy:(WebPolicyAction)policy
+- (void)_continueAfterNewWindowPolicy:(WebPolicyAction)policy
{
NSURLRequest *request = [[policyRequest retain] autorelease];
NSString *frameName = [[policyFrameName retain] autorelease];
policyLoadType = type;
+ WebDocumentLoadStateMac *loadState = (WebDocumentLoadStateMac *)[newDataSource _documentLoadState];
+
WebFrame *parentFrame = [client parentFrame];
if (parentFrame)
- [[newDataSource _documentLoadState] setOverrideEncoding:[[[parentFrame dataSource] _documentLoadState] overrideEncoding]];
+ [loadState setOverrideEncoding:[[[parentFrame dataSource] _documentLoadState] overrideEncoding]];
- WebDocumentLoadStateMac *loadState = (WebDocumentLoadStateMac *)[newDataSource _documentLoadState];
[loadState setFrameLoader:self];
[loadState setDataSource:newDataSource];
[self invalidatePendingPolicyDecisionCallingDefaultAction:YES];
- [self _setPolicyDocumentLoadState:[newDataSource _documentLoadState]];
+ [self _setPolicyDocumentLoadState:loadState];
[self checkNavigationPolicyForRequest:[newDataSource request]
dataSource:newDataSource