+2006-10-30 Darin Adler <darin@apple.com>
+
+ Reviewed by John Sullivan.
+
+ - work toward removing Objective-C data types from FrameLoader.h:
+ removed NSDate, NSString, WebCorePageState, WebCoreResourceLoader,
+ and WebCoreResourceHandle
+ - moved bodyBackgroundColor function from Frame to WebFrame in WebKit
+
+ * page/PageState.h:
+ * page/PageState.cpp: Added, C++ class with much of what WebCorePageState had.
+
+ * bridge/mac/FrameMac.h: Removed uneeeded declarations and bodyBackgroundColor().
+ * bridge/mac/FrameMac.mm: (WebCore::FrameMac::startRedirectionTimer): Use a
+ double for the date instead of an NSDate.
+
+ * bridge/mac/WebCoreFrameBridge.h:
+ * bridge/mac/WebCoreFrameBridge.mm: Removed invalidatePageCache and
+ saveDocumentToPageCache methods.
+
+ * bridge/mac/WebCorePageState.h:
+ * bridge/mac/WebCorePageState.mm: Removed most of the class and turned it into
+ an Objective-C wrapper for PageState.
+
+ * loader/FrameLoader.h: Removed unused Objective-C types, eliminated use of
+ NSDate and WebCorePageState.
+ * loader/FrameLoaderClient.h: Changed NSDate to double.
+ * loader/mac/FrameLoaderMac.mm:
+ (WebCore::FrameLoader::receivedMainResourceError): Moved call to setInPageCache
+ here that used to be in invalidateCurrentItemPageCache on the WebKit side.
+ (WebCore::FrameLoader::clientRedirected): Changed NSDate to double for date.
+ (WebCore::FrameLoader::open): Moved one of the open functions that was part of
+ commitProvisionalLoad inside the commitProvisionalLoad function, so that it can
+ extract the parameters from the response. Changed the open function that takes
+ a PageState to use the new C++ PageState.
+ (WebCore::FrameLoader::commitProvisionalLoad): Added the code from the open
+ function; tightened up logic, removing a few cases that could never happen, as
+ well as the unused reload boolean.
+
+ * ForwardingHeaders/kjs/property_map.h: Added.
+
+ * WebCore.exp: Updated.
+ * WebCore.xcodeproj/project.pbxproj: Updated.
+
2006-10-29 Maciej Stachowiak <mjs@apple.com>
Reviewed by Anders.
--- /dev/null
+#import <JavaScriptCore/property_map.h>
.objc_class_name_WebCoreJavaScript
.objc_class_name_WebCoreKeyGenerator
.objc_class_name_WebCorePageBridge
+.objc_class_name_WebCorePageState
.objc_class_name_WebCoreScriptDebugger
.objc_class_name_WebCoreSettings
.objc_class_name_WebCoreStringTruncator
__ZN7WebCore26NetscapePlugInStreamLoader6createEPNS_5FrameEP11objc_object
__ZN7WebCore4KURLC1EP5NSURL
__ZN7WebCore4Page16setDefersLoadingEb
+__ZN7WebCore5Frame11clearTimersEv
__ZN7WebCore5Frame11setSettingsEPNS_8SettingsE
__ZN7WebCore5Frame12canCachePageEv
__ZN7WebCore5Frame12ownerElementEv
+__ZN7WebCore5Frame13pauseTimeoutsEv
__ZN7WebCore5Frame14scrollToAnchorERKNS_4KURLE
__ZN7WebCore5Frame17setWindowHasFocusEb
__ZN7WebCore5Frame20hitTestResultAtPointERKNS_8IntPointEb
+__ZN7WebCore5Frame20saveWindowPropertiesEPN3KJS15SavedPropertiesE
__ZN7WebCore5Frame20setSelectionFromNoneEv
__ZN7WebCore5Frame21setProhibitsScrollingEb
+__ZN7WebCore5Frame22saveLocationPropertiesEPN3KJS15SavedPropertiesE
+__ZN7WebCore5Frame23saveInterpreterBuiltinsERN3KJS13SavedBuiltinsE
__ZN7WebCore5Frame26isSelectionInPasswordFieldEv
__ZN7WebCore5Frame6indentEv
__ZN7WebCore5Frame7outdentEv
__ZN7WebCore6StringC1EP8NSString
__ZN7WebCore6StringC1EP8NSString
__ZN7WebCore6StringC1EPKc
+__ZN7WebCore7nsColorERKNS_5ColorE
__ZN7WebCore8Document13removeMarkersENS_14DocumentMarker10MarkerTypeE
+__ZN7WebCore8Document4bodyEv
__ZN7WebCore8FrameMac10mouseMovedEP7NSEvent
__ZN7WebCore8FrameMac10wheelEventEP7NSEvent
__ZN7WebCore8FrameMac11mayDHTMLCutEv
__ZN7WebCore8IntPointC1ERK8_NSPoint
__ZN7WebCore9FrameTree11appendChildEN3WTF10PassRefPtrINS_5FrameEEE
__ZN7WebCore9FrameTree7setNameERKNS_12AtomicStringE
+__ZN7WebCore9PageState5clearEv
__ZN7WebCore9TimerBase4stopEv
__ZN7WebCore9TimerBase5startEdd
__ZN7WebCore9TimerBaseC2Ev
__ZNK7WebCore5Frame20visibleSelectionRectEv
__ZNK7WebCore5Frame30applyEditingStyleToBodyElementEv
__ZNK7WebCore5Frame33removeEditingStyleFromBodyElementEv
+__ZNK7WebCore5Frame3urlEv
__ZNK7WebCore5Frame4pageEv
__ZNK7WebCore5Frame4treeEv
__ZNK7WebCore5Frame6loaderEv
__ZNK7WebCore7IntRectcv7_NSRectEv
__ZNK7WebCore8FrameMac14selectionImageEb
__ZNK7WebCore8FrameMac17eventMayStartDragEP7NSEvent
-__ZNK7WebCore8FrameMac19bodyBackgroundColorEv
__ZNK7WebCore8FrameMac31fontAttributesForSelectionStartEv
__ZNK7WebCore9FloatRectcv6CGRectEv
__ZNK7WebCore9FloatRectcv7_NSRectEv
93E227E20AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DD0AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp */; };
93E227E30AF589AD00D48324 /* ResourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */; };
93E227E40AF589AD00D48324 /* SubresourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */; };
+ 93E22A6F0AF5E94100D48324 /* PageState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E22A6E0AF5E94100D48324 /* PageState.cpp */; };
+ 93E22A730AF5E94C00D48324 /* PageState.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E22A720AF5E94C00D48324 /* PageState.h */; settings = {ATTRIBUTES = (Private, ); }; };
93E47C5C09BE2BBB0019C5C1 /* PageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93E47C5B09BE2BBB0019C5C1 /* PageMac.mm */; };
93E62D9B0985F41600E1B5E3 /* SystemTime.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E62D990985F41600E1B5E3 /* SystemTime.h */; };
93EB169509F880B00091F8FF /* WebCoreSystemInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93EB169409F880B00091F8FF /* WebCoreSystemInterface.mm */; };
93F1996C08245E59001E9ABC /* ListBox.h in Headers */ = {isa = PBXBuildFile; fileRef = F587851302DE375901EA4122 /* ListBox.h */; };
93F1996D08245E59001E9ABC /* DeprecatedPtrListImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = F587851502DE375901EA4122 /* DeprecatedPtrListImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
93F1996E08245E59001E9ABC /* LoaderFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = F587851702DE375901EA4122 /* LoaderFunctions.h */; };
- 93F1997708245E59001E9ABC /* WebCorePageState.h in Headers */ = {isa = PBXBuildFile; fileRef = 9394E0A403AA5BBE008635CE /* WebCorePageState.h */; };
+ 93F1997708245E59001E9ABC /* WebCorePageState.h in Headers */ = {isa = PBXBuildFile; fileRef = 9394E0A403AA5BBE008635CE /* WebCorePageState.h */; settings = {ATTRIBUTES = (Private, ); }; };
93F1998208245E59001E9ABC /* DeprecatedPtrList.h in Headers */ = {isa = PBXBuildFile; fileRef = F587869902DE3B8601EA4122 /* DeprecatedPtrList.h */; settings = {ATTRIBUTES = (Private, ); }; };
93F1998308245E59001E9ABC /* DeprecatedPtrQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = F58786AD02DE3B8601EA4122 /* DeprecatedPtrQueue.h */; };
93F1998A08245E59001E9ABC /* RegularExpression.h in Headers */ = {isa = PBXBuildFile; fileRef = F58786B302DE3B8601EA4122 /* RegularExpression.h */; };
93E227DD0AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePlugInStreamLoader.cpp; sourceTree = "<group>"; };
93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoader.cpp; sourceTree = "<group>"; };
93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubresourceLoader.cpp; sourceTree = "<group>"; };
+ 93E22A6E0AF5E94100D48324 /* PageState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageState.cpp; sourceTree = "<group>"; };
+ 93E22A720AF5E94C00D48324 /* PageState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageState.h; sourceTree = "<group>"; };
93E47C5B09BE2BBB0019C5C1 /* PageMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PageMac.mm; sourceTree = "<group>"; };
93E62D990985F41600E1B5E3 /* SystemTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemTime.h; sourceTree = "<group>"; };
93EB169409F880B00091F8FF /* WebCoreSystemInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreSystemInterface.mm; sourceTree = "<group>"; };
935C476209AC4CE600A6AAB4 /* MouseEventWithHitTestResults.h */,
65FEA86809833ADE00BED4AB /* Page.cpp */,
65A21467097A329100B9050A /* Page.h */,
+ 93E22A720AF5E94C00D48324 /* PageState.h */,
+ 93E22A6E0AF5E94100D48324 /* PageState.cpp */,
65D1C1C909932B22000CB324 /* Plugin.h */,
F587863A02DE3A1401EA4122 /* Settings.h */,
);
655A81BE0AEF67E6000975F0 /* HTTPHeaderMap.h in Headers */,
930500200AF025D300FFF491 /* ClipboardAccessPolicy.h in Headers */,
9307F1D80AF2D59000DBA31A /* HitTestResult.h in Headers */,
+ 93E22A730AF5E94C00D48324 /* PageState.h in Headers */,
658821660AF4CDF700F01D1F /* ResourceResponse.h in Headers */,
6588216B0AF4CE1200F01D1F /* ResourceResponseMac.h in Headers */,
);
853CA9F00AEEC657002372DC /* RenderPath.cpp in Sources */,
654F68880AF1B7C50065BDD6 /* CachedResourceMac.mm in Sources */,
9307F1D70AF2D59000DBA31A /* HitTestResult.cpp in Sources */,
- 6588216C0AF4CE1200F01D1F /* ResourceResponseMac.mm in Sources */,
+ 6588216C0AF4CE1200F01D1F /* ResourceResponseMac.mm in Sources */,
932E16090AF578340025F408 /* FrameLoader.cpp in Sources */,
93E227E00AF589AD00D48324 /* DocumentLoader.cpp in Sources */,
93E227E10AF589AD00D48324 /* MainResourceLoader.cpp in Sources */,
93E227E20AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp in Sources */,
93E227E30AF589AD00D48324 /* ResourceLoader.cpp in Sources */,
93E227E40AF589AD00D48324 /* SubresourceLoader.cpp in Sources */,
+ 93E22A6F0AF5E94100D48324 /* PageState.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#import "DOMInternal.h"
#import "DOMPrivate.h"
#import "DocumentFragment.h"
-#import "FoundationExtras.h"
#import "FrameView.h"
#import "HTMLDocument.h"
#import "HTMLInputElement.h"
#import "ClipboardAccessPolicy.h"
#import "Frame.h"
-#import "IntRect.h"
#import "PlatformMouseEvent.h"
#import "StringHash.h"
#import "WebCoreKeyboardAccess.h"
class NPObject;
namespace KJS {
- class PausedTimeouts;
- class SavedProperties;
- class SavedBuiltins;
- class ScheduledAction;
namespace Bindings {
class Instance;
class RootObject;
#ifdef __OBJC__
-@class WebCorePageState;
@class NSArray;
@class NSAttributedString;
-@class NSColor;
@class NSDictionary;
@class NSEvent;
@class NSFileWrapper;
@class NSImage;
@class NSMenu;
@class NSMutableDictionary;
-@class NSResponder;
@class NSString;
@class NSView;
@class WebCoreFrameBridge;
#else
-class WebCorePageState;
class NSArray;
class NSAttributedString;
-class NSColor;
class NSDictionary;
class NSEvent;
class NSFileWrapper;
class NSImage;
class NSMenu;
class NSMutableDictionary;
-class NSResponder;
class NSString;
class NSView;
class WebCoreFrameBridge;
namespace WebCore {
class ClipboardMac;
-class DocumentFragment;
class EditorClient;
-class FramePrivate;
class HTMLTableCellElement;
-class RenderObject;
-class RenderStyle;
class VisiblePosition;
-struct DashboardRegionValue;
-
enum SelectionDirection {
SelectingNext,
SelectingPrevious
virtual String overrideMediaType() const;
- NSColor* bodyBackgroundColor() const;
-
WebCoreKeyboardUIMode keyboardUIMode() const;
void didTellBridgeAboutLoad(const String& URL);
#import "Cursor.h"
#import "DOMInternal.h"
#import "DOMWindow.h"
-#import "TextResourceDecoder.h"
+#import "DocumentLoader.h"
#import "Event.h"
#import "EventNames.h"
#import "FloatRect.h"
#import "RenderTheme.h"
#import "RenderView.h"
#import "ResourceHandle.h"
+#import "SystemTime.h"
#import "TextIterator.h"
+#import "TextResourceDecoder.h"
#import "WebCoreEditCommand.h"
#import "WebCoreFrameBridge.h"
-#import "WebCorePageState.h"
#import "WebCoreSystemInterface.h"
#import "WebCoreViewFactory.h"
#import "WebDashboardRegion.h"
-#import "DocumentLoader.h"
#import "WebScriptObjectPrivate.h"
#import "csshelper.h"
#import "htmlediting.h"
// Don't report history navigations, just actual redirection.
if (d->m_scheduledRedirection != historyNavigationScheduled) {
- NSTimeInterval interval = d->m_redirectionTimer.nextFireInterval();
- NSDate *fireDate = [[NSDate alloc] initWithTimeIntervalSinceNow:interval];
+ double fireDate = currentTime() + d->m_redirectionTimer.nextFireInterval();
loader()->clientRedirected(KURL(d->m_redirectURL).getNSURL(),
d->m_delayRedirect, fireDate, d->m_redirectLockHistory, d->m_executingJavaScriptFormAction);
- [fireDate release];
}
}
return String();
}
-NSColor *FrameMac::bodyBackgroundColor() const
-{
- if (document() && document()->body() && document()->body()->renderer()) {
- Color bgColor = document()->body()->renderer()->style()->backgroundColor();
- if (bgColor.isValid())
- return nsColor(bgColor);
- }
- return nil;
-}
-
WebCoreKeyboardUIMode FrameMac::keyboardUIMode() const
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
#import "Document.h"
#import "EventNames.h"
#import "FontData.h"
-#import "FoundationExtras.h"
#import "FrameMac.h"
#import "HTMLAreaElement.h"
#import "HTMLCollection.h"
- (void)addData:(NSData *)data;
-- (void)invalidatePageCache:(NSDictionary *)pageCache;
-
- (void)saveDocumentState;
- (void)restoreDocumentState;
-- (BOOL)saveDocumentToPageCache;
-
- (void)clearFrame;
- (NSURL *)baseURL;
DOMElement:(DOMElement *)element;
- (void)redirectDataToPlugin:(NSView *)pluginView;
-- (BOOL)saveDocumentToPageCache:(id)documentInfo;
-
- (int)getObjectCacheSize;
- (ObjectElementType)determineObjectFromMIMEType:(NSString*)MIMEType URL:(NSURL*)URL;
#import "DocumentType.h"
#import "EditorClient.h"
#import "FloatRect.h"
-#import "FoundationExtras.h"
#import "FrameLoader.h"
#import "FrameLoaderClient.h"
#import "FrameMac.h"
#import "TypingCommand.h"
#import "WebCoreEditCommand.h"
#import "WebCorePageBridge.h"
-#import "WebCorePageState.h"
#import "WebCoreSettings.h"
#import "WebCoreSystemInterface.h"
#import "WebCoreViewFactory.h"
#import <JavaScriptCore/array_instance.h>
#import <JavaScriptCore/date_object.h>
#import <JavaScriptCore/runtime_root.h>
-#import <kjs/SavedBuiltins.h>
@class NSView;
}
}
-- (void)invalidatePageCache:(NSDictionary *)pageCache
-{
- // We might have made a page cache item, but now we're bailing out due to an error before we ever
- // transitioned to the new page (before WebFrameState==commit). The goal here is to restore any state
- // so that the existing view (that wenever got far enough to replace) can continue being used.
- Document *doc = m_frame->document();
- if (doc)
- doc->setInPageCache(NO);
-
- WebCorePageState *state = [pageCache objectForKey:WebCorePageCacheStateKey];
-
- // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in RenderFlow::detach
- // Somehow the WebCorePageState object is not properly updated, and is holding onto a stale document
- // both Xcode and FileMaker see this crash, Safari does not.
- // This if check MUST be removed as part of re-writing the loader down in WebCore
- ASSERT(!state || ([state document] == doc));
- if ([state document] == doc)
- [state invalidate];
-}
-
- (void)saveDocumentState
{
Vector<String> stateVector;
return m_frame->scrollOverflow((ScrollDirection)direction, (ScrollGranularity)granularity);
}
-- (BOOL)saveDocumentToPageCache
-{
- Document *doc = m_frame->document();
- if (!doc)
- return NO;
- if (!doc->view())
- return NO;
-
- m_frame->clearTimers();
-
- JSLock lock;
-
- SavedProperties *windowProperties = new SavedProperties;
- m_frame->saveWindowProperties(windowProperties);
-
- SavedProperties *locationProperties = new SavedProperties;
- m_frame->saveLocationProperties(locationProperties);
-
- SavedBuiltins *interpreterBuiltins = new SavedBuiltins;
- m_frame->saveInterpreterBuiltins(*interpreterBuiltins);
-
- WebCorePageState *pageState = [[WebCorePageState alloc] initWithDocument:doc
- URL:m_frame->url()
- windowProperties:windowProperties
- locationProperties:locationProperties
- interpreterBuiltins:interpreterBuiltins
- pausedTimeouts:m_frame->pauseTimeouts()];
-
- BOOL result = [self saveDocumentToPageCache:pageState];
-
- [pageState release];
-
- return result;
-}
-
- (void)clearFrame
{
m_frame = 0;
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-namespace KJS {
- class SavedBuiltins;
- class SavedProperties;
- class PausedTimeouts;
-}
-
namespace WebCore {
- class Document;
- class KURL;
- class Node;
+ class Page;
+ class PageState;
}
@interface WebCorePageState : NSObject
{
- WebCore::Document *document;
- WebCore::Node *mousePressNode;
- WebCore::KURL *URL;
- KJS::SavedProperties *windowProperties;
- KJS::SavedProperties *locationProperties;
- KJS::SavedBuiltins *interpreterBuiltins;
- KJS::PausedTimeouts *pausedTimeouts;
- BOOL closed;
+ WebCore::PageState* m_impl;
}
-
-- initWithDocument:(WebCore::Document *)doc URL:(const WebCore::KURL &)u windowProperties:(KJS::SavedProperties *)wp locationProperties:(KJS::SavedProperties *)lp interpreterBuiltins:(KJS::SavedBuiltins *)ib pausedTimeouts:(KJS::PausedTimeouts *)pt;
-
-- (WebCore::Document *)document;
-- (WebCore::Node *)mousePressNode;
-- (WebCore::KURL *)URL;
-- (KJS::SavedProperties *)windowProperties;
-- (KJS::SavedProperties *)locationProperties;
-- (KJS::SavedBuiltins *)interpreterBuiltins;
-- (KJS::PausedTimeouts *)pausedTimeouts;
-- (void)invalidate;
-
+- (id)initWithPage:(WebCore::Page*)page;
+- (WebCore::PageState*)impl;
@end
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#import "WebCorePageState.h"
#import "Document.h"
-#import "FoundationExtras.h"
-#import "FrameMac.h"
-#import "kjs_window.h"
-#import <kjs/SavedBuiltins.h>
+#import "Frame.h"
+#import "Page.h"
+#import "PageState.h"
using namespace WebCore;
-using namespace KJS;
@implementation WebCorePageState
-- (id)initWithDocument:(Document *)doc URL:(const KURL &)u windowProperties:(SavedProperties *)wp locationProperties:(SavedProperties *)lp interpreterBuiltins:(SavedBuiltins *)ib pausedTimeouts:(PausedTimeouts *)pt
+- (id)initWithPage:(Page*)page
{
- [super init];
-
- doc->ref();
- document = doc;
- doc->setInPageCache(YES);
-
- FrameMac *frame = static_cast<FrameMac *>(doc->frame());
- mousePressNode = frame ? frame->mousePressNode() : 0;
- if (mousePressNode)
- mousePressNode->ref();
-
- URL = new KURL(u);
- windowProperties = wp;
- locationProperties = lp;
- interpreterBuiltins = ib;
- pausedTimeouts = pt;
-
- doc->view()->ref();
-
- return self;
-}
-
-- (PausedTimeouts *)pausedTimeouts
-{
- return pausedTimeouts;
-}
-
-- (void)clear
-{
- if (mousePressNode)
- mousePressNode->deref();
- mousePressNode = 0;
-
- delete URL;
- URL = 0;
-
- JSLock lock;
-
- delete windowProperties;
- windowProperties = 0;
- delete locationProperties;
- locationProperties = 0;
- delete interpreterBuiltins;
- interpreterBuiltins = 0;
-
- delete pausedTimeouts;
- pausedTimeouts = 0;
-
- Collector::collect();
-}
-
-- (void)invalidate
-{
- // Should only ever invalidate once.
- ASSERT(document);
- ASSERT(document->view());
- ASSERT(!document->inPageCache());
-
- if (document) {
- FrameView *view = document->view();
- if (view)
- view->deref();
- document->deref();
- document = 0;
+ self = [super init];
+ if (!self)
+ return nil;
+
+ Document* document = page->mainFrame()->document();
+ if (!document || !document->view()) {
+ [self release];
+ return nil;
}
- [self clear];
+ m_impl = WebCore::PageState::create(page).releaseRef();
+ return self;
}
- (void)dealloc
{
- ASSERT(closed);
+ m_impl->deref();
[super dealloc];
}
- (void)finalize
{
- ASSERT(closed);
+ m_impl->deref();
[super finalize];
}
-- (void)close
-{
- if (closed)
- return;
- if (document) {
- ASSERT(document->inPageCache());
- ASSERT(document->view());
-
- FrameView *view = document->view();
-
- FrameMac::clearTimers(view);
-
- bool detached = document->renderer() == 0;
- document->setInPageCache(NO);
- if (detached) {
- document->detach();
- document->removeAllEventListenersFromAllNodes();
- }
- document->deref();
- document = 0;
-
- if (view) {
- view->clearPart();
- view->deref();
- }
- }
-
- [self clear];
- closed = YES;
-}
-
-- (Document *)document
-{
- return document;
-}
-
-- (WebCore::Node *)mousePressNode
-{
- return mousePressNode;
-}
-
-- (KURL *)URL
-{
- return URL;
-}
-
-- (SavedProperties *)windowProperties
-{
- return windowProperties;
-}
-
-- (SavedProperties *)locationProperties
-{
- return locationProperties;
-}
-
-- (SavedBuiltins *)interpreterBuiltins
+- (WebCore::PageState*)impl
{
- return interpreterBuiltins;
+ return m_impl;
}
@end
#import "config.h"
#import "WebCoreSettings.h"
-#import "FoundationExtras.h"
#import "Settings.h"
#import "Page.h"
#import "WebCoreFrameBridge.h"
#ifdef SVG_SUPPORT
#import "KRenderingDeviceQuartz.h"
-#import "FoundationExtras.h"
#import "GraphicsContext.h"
#include "KCanvasMarker.h"
#import "KCanvasFilterQuartz.h"
#ifdef __OBJC__
-@class WebCorePageState;
-
@class NSData;
-@class NSDate;
@class NSDictionary;
@class NSError;
@class NSEvent;
@class NSURLRequest;
@class NSURLResponse;
-@protocol WebCoreResourceLoader;
-@protocol WebCoreResourceHandle;
-
#else
-class WebCorePageState;
-
class NSData;
-class NSDate;
class NSDictionary;
class NSError;
class NSEvent;
class NSMutableURLRequest;
-class NSString;
class NSURL;
class NSURLAuthenticationChallenge;
class NSURLConnection;
class Frame;
class FrameLoadRequest;
class FrameLoaderClient;
+ class PageState;
class KURL;
class MainResourceLoader;
class ResourceRequest;
void clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress);
#if PLATFORM(MAC)
- void clientRedirected(NSURL *, double delay, NSDate *fireDate, bool lockHistory, bool isJavaScriptFormAction);
+ void clientRedirected(NSURL *, double delay, double fireDate, bool lockHistory, bool isJavaScriptFormAction);
void commitProvisionalLoad(NSDictionary *pageCache);
bool shouldReload(NSURL *currentURL, NSURL *destinationURL);
#endif
void setState(FrameState);
void closeOldDataSources();
-#if PLATFORM(MAC)
- void open(NSURL *, bool reload, NSString *contentType, NSString *refresh, NSDate *lastModified, NSDictionary *pageCache);
- void open(WebCorePageState *);
-#endif
+ void open(PageState&);
void opened();
#if PLATFORM(MAC)
virtual void dispatchDidHandleOnloadEvents() = 0;
virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0;
virtual void dispatchDidCancelClientRedirect() = 0;
- virtual void dispatchWillPerformClientRedirect(NSURL *URL, double, NSDate *) = 0;
+ virtual void dispatchWillPerformClientRedirect(NSURL *URL, double interval, double fireDate) = 0;
virtual void dispatchDidChangeLocationWithinPage() = 0;
virtual void dispatchWillClose() = 0;
virtual void dispatchDidReceiveIcon(NSImage *) = 0;
#import "Cache.h"
#import "DOMElementInternal.h"
#import "Document.h"
+#import "DocumentLoader.h"
#import "Element.h"
+#import "FormDataStream.h"
+#import "FormState.h"
#import "FrameLoadRequest.h"
#import "FrameLoaderClient.h"
#import "FrameMac.h"
#import "FramePrivate.h"
+#import "PageState.h"
#import "FrameTree.h"
#import "HTMLNames.h"
#import "LoaderNSURLExtras.h"
#import "LoaderNSURLRequestExtras.h"
+#import "MainResourceLoader.h"
#import "Page.h"
#import "Plugin.h"
#import "ResourceResponse.h"
#import "ResourceResponseMac.h"
+#import "SubresourceLoader.h"
#import "WebCoreFrameBridge.h"
#import "WebCoreIconDatabaseBridge.h"
#import "WebCorePageState.h"
#import "WebCoreSystemInterface.h"
#import "WebDataProtocol.h"
-#import "DocumentLoader.h"
-#import "FormDataStream.h"
-#import "FormState.h"
-#import "MainResourceLoader.h"
-#import "SubresourceLoader.h"
#import <kjs/JSLock.h>
#import <wtf/Assertions.h>
if (m_state == FrameStateProvisional) {
NSURL *failedURL = [m_provisionalDocumentLoader->originalRequestCopy() URL];
m_frame->didNotOpenURL(failedURL);
+
+ // We might have made a page cache item, but now we're bailing out due to an error before we ever
+ // transitioned to the new page (before WebFrameState == commit). The goal here is to restore any state
+ // so that the existing view (that wenever got far enough to replace) can continue being used.
+ Document* document = m_frame->document();
+ if (document)
+ document->setInPageCache(false);
m_client->invalidateCurrentItemPageCache();
// Call clientRedirectCancelledOrFinished here so that the frame load delegate is notified that the redirect's
m_sentRedirectNotification = false;
}
-void FrameLoader::clientRedirected(NSURL *URL, double seconds, NSDate *date, bool lockHistory, bool isJavaScriptFormAction)
+void FrameLoader::clientRedirected(NSURL *URL, double seconds, double fireDate, bool lockHistory, bool isJavaScriptFormAction)
{
- m_client->dispatchWillPerformClientRedirect(URL, seconds, date);
+ m_client->dispatchWillPerformClientRedirect(URL, seconds, fireDate);
// Remember that we sent a redirect notification to the frame load delegate so that when we commit
// the next provisional load, we can send a corresponding -webView:didCancelClientRedirectForFrame:
m_client->setMainFrameDocumentReady(false); // stop giving out the actual DOMDocument to observers
}
-void FrameLoader::open(NSURL *URL, bool reload, NSString *contentType, NSString *refresh, NSDate *lastModified, NSDictionary *pageCache)
+void FrameLoader::open(PageState& state)
{
- if (pageCache) {
- WebCorePageState *state = [pageCache objectForKey:WebCorePageCacheStateKey];
- open(state);
- [state invalidate];
- return;
- }
-
- m_frame->setResponseMIMEType(contentType);
-
- // opening the URL
- if (m_frame->didOpenURL(URL)) {
- // things we have to set up after calling didOpenURL
- if (refresh)
- m_frame->addMetaData("http-refresh", refresh);
- if (lastModified) {
- NSString *modifiedString = [lastModified descriptionWithCalendarFormat:@"%a %b %d %Y %H:%M:%S" timeZone:nil locale:nil];
- m_frame->addMetaData("modified", modifiedString);
- }
- }
-}
+ ASSERT(m_frame->page()->mainFrame() == m_frame);
-void FrameLoader::open(WebCorePageState *state)
-{
FramePrivate* d = m_frame->d;
- // It's safe to assume none of the WebCorePageState methods will raise
- // exceptions, since WebCorePageState is implemented by WebCore and
- // does not throw
-
- Document* doc = [state document];
- Node* mousePressNode = [state mousePressNode];
- KURL URL = *[state URL];
- SavedProperties* windowProperties = [state windowProperties];
- SavedProperties* locationProperties = [state locationProperties];
- SavedBuiltins* interpreterBuiltins = [state interpreterBuiltins];
- PausedTimeouts* timeouts = [state pausedTimeouts];
-
m_frame->cancelRedirection();
// We still have to close the previous part page.
d->m_kjsStatusBarText = String();
d->m_kjsDefaultStatusBarText = String();
}
-
+
+ KURL URL = state.URL();
+
if (URL.protocol().startsWith("http") && !URL.host().isEmpty() && URL.path().isEmpty())
URL.setPath("/");
m_frame->clear();
- doc->setInPageCache(false);
+ Document* document = state.document();
+ document->setInPageCache(false);
d->m_bCleared = false;
d->m_bComplete = false;
d->m_bLoadEventEmitted = false;
d->m_referrer = URL.url();
- m_frame->setView(doc->view());
+ m_frame->setView(document->view());
- d->m_doc = doc;
- d->m_mousePressNode = mousePressNode;
- d->m_decoder = doc->decoder();
+ d->m_doc = document;
+ d->m_mousePressNode = state.mousePressNode();
+ d->m_decoder = document->decoder();
m_frame->updatePolicyBaseURL();
- { // scope the lock
- JSLock lock;
- m_frame->restoreWindowProperties(windowProperties);
- m_frame->restoreLocationProperties(locationProperties);
- m_frame->restoreInterpreterBuiltins(*interpreterBuiltins);
- }
-
- m_frame->resumeTimeouts(timeouts);
+ state.restoreJavaScriptState(m_frame->page());
m_frame->checkCompleted();
}
void FrameLoader::commitProvisionalLoad(NSDictionary *pageCache)
{
- bool reload = m_loadType == FrameLoadTypeReload || m_loadType == FrameLoadTypeReloadAllowingStaleData;
-
RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
- NSURLResponse *response = pdl->response();
-
- NSDictionary *headers = [response isKindOfClass:[NSHTTPURLResponse class]]
- ? [(NSHTTPURLResponse *)response allHeaderFields] : nil;
-
if (m_loadType != FrameLoadTypeReplace)
closeOldDataSources();
if (m_sentRedirectNotification)
clientRedirectCancelledOrFinished(false);
- NSURL *baseURL = [pdl->request() _webDataRequestBaseURL];
- NSURL *URL = baseURL ? baseURL : [response URL];
-
- if (!URL || urlIsEmpty(URL))
- URL = [NSURL URLWithString:@"about:blank"];
-
- NSDate *lastModified = pageCache ? nil : wkGetNSURLResponseLastModifiedDate(response);
-
- open(URL, reload, [response MIMEType], [headers objectForKey:@"Refresh"], lastModified, pageCache);
+ WebCorePageState *pageState = [pageCache objectForKey:WebCorePageCacheStateKey];
+ if (PageState* frameState = [pageState impl]) {
+ open(*frameState);
+ frameState->clear();
+ } else {
+ NSURLResponse *response = pdl->response();
+
+ NSURL *URL = [pdl->request() _webDataRequestBaseURL];
+ if (!URL)
+ URL = [response URL];
+ if (!URL || urlIsEmpty(URL))
+ URL = [NSURL URLWithString:@"about:blank"];
+
+ m_frame->setResponseMIMEType([response MIMEType]);
+ if (m_frame->didOpenURL(URL)) {
+ if ([response isKindOfClass:[NSHTTPURLResponse class]])
+ if (NSString *refresh = [[(NSHTTPURLResponse *)response allHeaderFields] objectForKey:@"Refresh"])
+ m_frame->addMetaData("http-refresh", refresh);
+ m_frame->addMetaData("modified", [wkGetNSURLResponseLastModifiedDate(response)
+ descriptionWithCalendarFormat:@"%a %b %d %Y %H:%M:%S" timeZone:nil locale:nil]);
+ }
+ }
opened();
}
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PageState.h"
+
+#include "Document.h"
+#include "Frame.h"
+#include "Page.h"
+#include "kjs_window.h"
+#include <kjs/JSLock.h>
+#include <kjs/property_map.h>
+#include <kjs/SavedBuiltins.h>
+
+using KJS::Collector;
+using KJS::JSLock;
+using KJS::SavedBuiltins;
+using KJS::SavedProperties;
+
+namespace WebCore {
+
+PassRefPtr<PageState> PageState::create(Page* page)
+{
+ return new PageState(page);
+}
+
+PageState::PageState(Page* page)
+ : m_document(page->mainFrame()->document())
+ , m_view(page->mainFrame()->view())
+ , m_mousePressNode(page->mainFrame()->mousePressNode())
+ , m_URL(page->mainFrame()->url())
+ , m_windowProperties(new SavedProperties)
+ , m_locationProperties(new SavedProperties)
+ , m_interpreterBuiltins(new SavedBuiltins)
+{
+ Frame* mainFrame = page->mainFrame();
+
+ mainFrame->clearTimers();
+
+ JSLock lock;
+
+ mainFrame->saveWindowProperties(m_windowProperties.get());
+ mainFrame->saveLocationProperties(m_locationProperties.get());
+ mainFrame->saveInterpreterBuiltins(*m_interpreterBuiltins.get());
+ m_pausedTimeouts.set(mainFrame->pauseTimeouts());
+
+ m_document->setInPageCache(true);
+}
+
+PageState::~PageState()
+{
+ clear();
+}
+
+void PageState::restoreJavaScriptState(Page* page)
+{
+ Frame* mainFrame = page->mainFrame();
+
+ JSLock lock;
+ mainFrame->restoreWindowProperties(m_windowProperties.get());
+ mainFrame->restoreLocationProperties(m_locationProperties.get());
+ mainFrame->restoreInterpreterBuiltins(*m_interpreterBuiltins.get());
+ mainFrame->resumeTimeouts(m_pausedTimeouts.get());
+}
+
+void PageState::clear()
+{
+ if (!m_document)
+ return;
+
+ ASSERT(m_view);
+ ASSERT(m_document->view() == m_view);
+
+ if (m_document->inPageCache()) {
+ Frame::clearTimers(m_view.get());
+
+ bool detached = !m_document->renderer();
+ m_document->setInPageCache(false);
+ if (detached) {
+ m_document->detach();
+ m_document->removeAllEventListenersFromAllNodes();
+ }
+
+ m_view->clearPart();
+ }
+
+ ASSERT(!m_document->inPageCache());
+
+ m_document = 0;
+ m_view = 0;
+ m_mousePressNode = 0;
+ m_URL = KURL();
+
+ JSLock lock;
+
+ m_windowProperties.clear();
+ m_locationProperties.clear();
+ m_interpreterBuiltins.clear();
+ m_pausedTimeouts.clear();
+
+ Collector::collect();
+}
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "KURL.h"
+#include "Shared.h"
+#include <wtf/Forward.h>
+#include <wtf/OwnPtr.h>
+
+namespace KJS {
+ class PausedTimeouts;
+ class SavedBuiltins;
+ class SavedProperties;
+}
+
+namespace WebCore {
+
+ class Document;
+ class FrameView;
+ class Node;
+ class Page;
+
+ class PageState : public Shared<PageState> {
+ public:
+ static PassRefPtr<PageState> create(Page*);
+ ~PageState();
+
+ void clear();
+
+ Document* document() { return m_document.get(); }
+ Node* mousePressNode() { return m_mousePressNode.get(); }
+ const KURL& URL() { return m_URL; }
+
+ void restoreJavaScriptState(Page*);
+
+ private:
+ PageState(Page*);
+
+ RefPtr<Document> m_document;
+ RefPtr<FrameView> m_view;
+ RefPtr<Node> m_mousePressNode;
+ KURL m_URL;
+ OwnPtr<KJS::SavedProperties> m_windowProperties;
+ OwnPtr<KJS::SavedProperties> m_locationProperties;
+ OwnPtr<KJS::SavedBuiltins> m_interpreterBuiltins;
+ OwnPtr<KJS::PausedTimeouts> m_pausedTimeouts;
+ };
+
+}
#import "BlockExceptions.h"
#import "FontData.h"
#import "FontFallbackList.h"
-#import "FoundationExtras.h"
#import "GlyphBuffer.h"
#import "GraphicsContext.h"
#import "IntRect.h"
#import "Cursor.h"
#import "Font.h"
-#import "FoundationExtras.h"
#import "GraphicsContext.h"
#import "BlockExceptions.h"
#import "FrameMac.h"
#import "BlockExceptions.h"
#import "DocLoader.h"
-#import "FoundationExtras.h"
#import "FrameLoader.h"
#import "FrameMac.h"
#import "KURL.h"
+2006-10-30 Darin Adler <darin@apple.com>
+
+ Reviewed by John Sullivan.
+
+ - work toward removing Objective-C data types from FrameLoader.h:
+ removed NSDate, NSString, WebCorePageState, WebCoreResourceLoader,
+ and WebCoreResourceHandle
+ - moved bodyBackgroundColor function here from Frame
+
+ * History/WebHistoryItem.m: (+[WebHistoryItem _closeObjectsInPendingPageCaches]):
+ Updated for change in WebCorePageState.
+
+ * WebCoreSupport/WebFrameBridge.mm: Removed saveDocumentToPageCache method.
+
+ * WebCoreSupport/WebFrameLoaderClient.h: Changed NSDate to double.
+ * WebCoreSupport/WebFrameLoaderClient.mm:
+ (WebFrameLoaderClient::invalidateCurrentItemPageCache): Moved the code that was
+ formerly in invalidatePageCache: on the bridge here.
+ (WebFrameLoaderClient::dispatchWillPerformClientRedirect): Added code to make the
+ NSDate here.
+ (WebFrameLoaderClient::createPageCache): Restructured code to create the
+ WebCorePageState object directly instead of calling saveDocumentToPageCache on
+ the bridge.
+
+ * WebView/WebFrame.mm: (-[WebFrame _bodyBackgroundColor]): Rewrote this to work
+ directly with the DOM and renderers rather than using a function on Frame.
+
2006-10-29 Maciej Stachowiak <mjs@apple.com>
Reviewed by Anders.
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <WebKit/WebHistoryItemPrivate.h>
-
+#import "WebHistoryItemPrivate.h"
+
+#import "WebFrameBridge.h"
+#import "WebFrameInternal.h"
+#import "WebFrameView.h"
+#import "WebHTMLViewInternal.h"
+#import "WebIconDatabase.h"
+#import "WebKitLogging.h"
+#import "WebKitNSStringExtras.h"
+#import "WebNSDictionaryExtras.h"
+#import "WebNSObjectExtras.h"
+#import "WebNSURLExtras.h"
+#import "WebNSURLRequestExtras.h"
+#import "WebNSViewExtras.h"
+#import "WebPluginController.h"
#import <JavaScriptCore/Assertions.h>
-#import <WebKit/WebFrameBridge.h>
-#import <WebKit/WebFrameInternal.h>
-#import <WebKit/WebFrameView.h>
-#import <WebKit/WebHTMLViewInternal.h>
-#import <WebKit/WebIconDatabase.h>
-#import <WebKit/WebKitLogging.h>
-#import <WebKit/WebKitNSStringExtras.h>
-#import <WebKit/WebNSDictionaryExtras.h>
-#import <WebKit/WebNSObjectExtras.h>
-#import <WebKit/WebNSURLExtras.h>
-#import <WebKit/WebNSURLRequestExtras.h>
-#import <WebKit/WebNSViewExtras.h>
-#import <WebKit/WebPluginController.h>
+#import <WebCore/PageState.h>
+#import <WebCore/WebCorePageState.h>
#import <WebKitSystemInterface.h>
// Private keys used in the WebHistoryItem's dictionary representation.
[HTMLView close];
}
- id pageState = [pageCache objectForKey:WebCorePageCacheStateKey];
- if ([pageState respondsToSelector:@selector(close)])
- [pageState performSelector:@selector(close)];
+ if (WebCorePageState *pageState = [pageCache objectForKey:WebCorePageCacheStateKey])
+ [pageState impl]->clear();
}
}
return [[_frame _itemForRestoringDocState] documentState];
}
-- (BOOL)saveDocumentToPageCache:(id)documentInfo
-{
- WebHistoryItem *item = [_frame _itemForSavingDocState];
- if (![item hasPageCache]) {
- return NO;
- }
- [[item pageCache] setObject:documentInfo forKey:WebCorePageCacheStateKey];
- return YES;
-}
-
- (NSString *)userAgentForURL:(NSURL *)URL
{
return [[self webView] userAgentForURL:URL];
virtual void dispatchDidHandleOnloadEvents();
virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
virtual void dispatchDidCancelClientRedirect();
- virtual void dispatchWillPerformClientRedirect(NSURL *URL, NSTimeInterval, NSDate *);
+ virtual void dispatchWillPerformClientRedirect(NSURL *URL, double interval, double fireDate);
virtual void dispatchDidChangeLocationWithinPage();
virtual void dispatchWillClose();
virtual void dispatchDidReceiveIcon(NSImage *);
#import "WebBackForwardList.h"
#import "WebDataSourceInternal.h"
+#import "WebDefaultResourceLoadDelegate.h"
#import "WebDocumentInternal.h"
#import "WebDocumentLoaderMac.h"
#import "WebDownloadInternal.h"
#import "WebScriptDebugServerPrivate.h"
#import "WebUIDelegate.h"
#import "WebViewInternal.h"
+#import <WebCore/Document.h>
+#import <WebCore/DocumentLoader.h>
+#import <WebCore/FormState.h>
#import <WebCore/FrameLoader.h>
#import <WebCore/FrameLoaderTypes.h>
#import <WebCore/FrameMac.h>
+#import <WebCore/PageState.h>
#import <WebCore/FrameTree.h>
#import <WebCore/Page.h>
#import <WebCore/PlatformString.h>
+#import <WebCore/ResourceLoader.h>
#import <WebCore/WebCoreFrameBridge.h>
+#import <WebCore/WebCorePageState.h>
#import <WebCore/WebDataProtocol.h>
-#import <WebCore/DocumentLoader.h>
-#import <WebCore/FormState.h>
-#import <WebCore/ResourceLoader.h>
#import <WebKit/DOMElement.h>
-#import <WebKit/WebDefaultResourceLoadDelegate.h>
-#import <WebKit/WebDocumentLoaderMac.h>
-#import <WebKit/WebResourceLoadDelegate.h>
-#import <WebKit/WebViewInternal.h>
#import <WebKitSystemInterface.h>
-#import <objc/objc-runtime.h>
#import <wtf/PassRefPtr.h>
using namespace WebCore;
// When we are pre-commit, the currentItem is where the pageCache data resides
WebHistoryItem *currentItem = m_webFrame->_private->currentItem;
NSDictionary *pageCache = [currentItem pageCache];
- [m_webFrame->_private->bridge invalidatePageCache:pageCache];
+ WebCorePageState *state = [pageCache objectForKey:WebCorePageCacheStateKey];
+ WebCore::PageState* pageState = [state impl];
+
+ // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in RenderFlow::detach
+ // Somehow the WebCorePageState object is not properly updated, and is holding onto a stale document.
+ // Both Xcode and FileMaker see this crash, Safari does not.
+ ASSERT(!pageState || pageState->document() == core(m_webFrame.get())->document());
+ if (pageState && pageState->document() == core(m_webFrame.get())->document())
+ pageState->clear();
+
// We're assuming that WebCore invalidates its pageCache state in didNotOpen:pageCache:
[currentItem setHasPageCache:NO];
}
[[webView _frameLoadDelegateForwarder] webView:webView didCancelClientRedirectForFrame:m_webFrame.get()];
}
-void WebFrameLoaderClient::dispatchWillPerformClientRedirect(NSURL *URL, NSTimeInterval delay, NSDate *fireDate)
+void WebFrameLoaderClient::dispatchWillPerformClientRedirect(NSURL *URL, double delay, double fireDate)
{
- WebView *webView = getWebView(m_webFrame.get());
+ WebView *webView = getWebView(m_webFrame.get());
[[webView _frameLoadDelegateForwarder] webView:webView
willPerformClientRedirectToURL:URL
delay:delay
- fireDate:fireDate
+ fireDate:[NSDate dateWithTimeIntervalSince1970:fireDate]
forFrame:m_webFrame.get()];
}
bool WebFrameLoaderClient::createPageCache(WebHistoryItem *item)
{
- [item setHasPageCache:YES];
- if (![m_webFrame->_private->bridge saveDocumentToPageCache]) {
+ WebCorePageState *pageState = [[WebCorePageState alloc] initWithPage:core(m_webFrame.get())->page()];
+ if (!pageState) {
[item setHasPageCache:NO];
- return NO;
+ return false;
}
+
+ [item setHasPageCache:YES];
NSMutableDictionary *pageCache = [item pageCache];
- [pageCache setObject:[NSDate date] forKey: WebPageCacheEntryDateKey];
- [pageCache setObject:[m_webFrame.get() dataSource] forKey: WebPageCacheDataSourceKey];
- [pageCache setObject:[m_webFrame->_private->webFrameView documentView] forKey: WebPageCacheDocumentViewKey];
- return YES;
+
+ [pageCache setObject:pageState forKey:WebCorePageCacheStateKey];
+ [pageCache setObject:[NSDate date] forKey:WebPageCacheEntryDateKey];
+ [pageCache setObject:[m_webFrame.get() dataSource] forKey:WebPageCacheDataSourceKey];
+ [pageCache setObject:[m_webFrame->_private->webFrameView documentView] forKey:WebPageCacheDocumentViewKey];
+
+ [pageState release];
+
+ return true;
}
WebFramePolicyListener *WebFrameLoaderClient::setUpPolicyListener(FramePolicyFunction function)
- (NSColor *)_bodyBackgroundColor
{
- return core(self)->bodyBackgroundColor();
+ Document* document = core(self)->document();
+ if (!document)
+ return nil;
+ HTMLElement* body = document->body();
+ if (!body)
+ return nil;
+ RenderObject* bodyRenderer = body->renderer();
+ if (!bodyRenderer)
+ return nil;
+ Color color = bodyRenderer->style()->backgroundColor();
+ if (!color.isValid())
+ return nil;
+ return nsColor(color);
}
- (BOOL)_isFrameSet