summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/WebCoreSupport/WebInspectorClient.mm')
-rw-r--r--WebKit/mac/WebCoreSupport/WebInspectorClient.mm54
1 files changed, 30 insertions, 24 deletions
diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
index cc4cfdb..3f0b43d 100644
--- a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
@@ -28,6 +28,8 @@
#import "WebInspectorClient.h"
+#import "DOMNodeInternal.h"
+#import "WebDelegateImplementationCaching.h"
#import "WebFrameInternal.h"
#import "WebFrameView.h"
#import "WebInspector.h"
@@ -35,16 +37,15 @@
#import "WebNodeHighlight.h"
#import "WebUIDelegate.h"
#import "WebViewInternal.h"
-
#import <WebCore/InspectorController.h>
#import <WebCore/Page.h>
-
#import <WebKit/DOMExtensions.h>
-
#import <WebKitSystemInterface.h>
using namespace WebCore;
+static const char* const inspectorStartsAttachedName = "inspectorStartsAttached";
+
@interface WebInspectorWindowController : NSWindowController <NSWindowDelegate> {
@private
WebView *_inspectedWebView;
@@ -150,10 +151,17 @@ void WebInspectorClient::updateWindowTitle() const
[[m_windowController.get() window] setTitle:title];
}
-#pragma mark -
+void WebInspectorClient::inspectorWindowObjectCleared()
+{
+ WebFrame *frame = [m_webView mainFrame];
+
+ WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(m_webView);
+ if (implementations->didClearInspectorWindowObjectForFrameFunc)
+ CallFrameLoadDelegate(implementations->didClearInspectorWindowObjectForFrameFunc, m_webView,
+ @selector(webView:didClearInspectorWindowObject:forFrame:), [frame windowObject], frame);
+}
-#define WebKitInspectorAttachedKey @"WebKitInspectorAttached"
-#define WebKitInspectorAttachedViewHeightKey @"WebKitInspectorAttachedViewHeight"
+#pragma mark -
@implementation WebInspectorWindowController
- (id)init
@@ -177,6 +185,13 @@ void WebInspectorClient::updateWindowTitle() const
[preferences setTabsToLinks:NO];
[preferences setMinimumFontSize:0];
[preferences setMinimumLogicalFontSize:9];
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+ [preferences setFixedFontFamily:@"Menlo"];
+ [preferences setDefaultFixedFontSize:11];
+#else
+ [preferences setFixedFontFamily:@"Monaco"];
+ [preferences setDefaultFixedFontSize:10];
+#endif
_webView = [[WebView alloc] init];
[_webView setPreferences:preferences];
@@ -186,10 +201,6 @@ void WebInspectorClient::updateWindowTitle() const
[preferences release];
- NSNumber *attached = [[NSUserDefaults standardUserDefaults] objectForKey:WebKitInspectorAttachedKey];
- ASSERT(!attached || [attached isKindOfClass:[NSNumber class]]);
- _shouldAttach = attached ? [attached boolValue] : YES;
-
NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL fileURLWithPath:path]];
[[_webView mainFrame] loadRequest:request];
@@ -313,6 +324,10 @@ void WebInspectorClient::updateWindowTitle() const
}
_visible = YES;
+
+ // If no preference is set - default to an attached window
+ InspectorController::Setting shouldAttach = [_inspectedWebView page]->inspectorController()->setting(inspectorStartsAttachedName);
+ _shouldAttach = (shouldAttach.type() == InspectorController::Setting::BooleanType) ? shouldAttach.booleanValue() : true;
if (_shouldAttach) {
WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView];
@@ -324,8 +339,6 @@ void WebInspectorClient::updateWindowTitle() const
[frameView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable | NSViewMinYMargin)];
_attachedToInspectedWebView = YES;
-
- [self setAttachedWindowHeight:[[NSUserDefaults standardUserDefaults] integerForKey:WebKitInspectorAttachedViewHeightKey]];
} else {
_attachedToInspectedWebView = NO;
@@ -348,15 +361,13 @@ void WebInspectorClient::updateWindowTitle() const
if (_attachedToInspectedWebView)
return;
- _shouldAttach = YES;
+ [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(true));
_movingWindows = YES;
[self close];
[self showWindow:nil];
_movingWindows = NO;
-
- [[NSUserDefaults standardUserDefaults] setBool:YES forKey:WebKitInspectorAttachedKey];
}
- (void)detach
@@ -364,7 +375,7 @@ void WebInspectorClient::updateWindowTitle() const
if (!_attachedToInspectedWebView)
return;
- _shouldAttach = NO;
+ [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, InspectorController::Setting(false));
_movingWindows = YES;
[self close];
@@ -372,28 +383,23 @@ void WebInspectorClient::updateWindowTitle() const
_movingWindows = NO;
- [[NSUserDefaults standardUserDefaults] setBool:NO forKey:WebKitInspectorAttachedKey];
}
- (void)setAttachedWindowHeight:(unsigned)height
{
- [[NSUserDefaults standardUserDefaults] setInteger:height forKey:WebKitInspectorAttachedViewHeightKey];
-
if (!_attachedToInspectedWebView)
return;
WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView];
NSRect frameViewRect = [frameView frame];
- CGFloat attachedHeight = round(MAX(250.0, MIN(height, (NSHeight([_inspectedWebView frame]) * 0.75))));
-
// Setting the height based on the difference is done to work with
// Safari's find banner. This assumes the previous height is the Y origin.
- CGFloat heightDifference = (NSMinY(frameViewRect) - attachedHeight);
+ CGFloat heightDifference = (NSMinY(frameViewRect) - height);
frameViewRect.size.height += heightDifference;
- frameViewRect.origin.y = attachedHeight;
+ frameViewRect.origin.y = height;
- [_webView setFrame:NSMakeRect(0.0, 0.0, NSWidth(frameViewRect), attachedHeight)];
+ [_webView setFrame:NSMakeRect(0.0, 0.0, NSWidth(frameViewRect), height)];
[frameView setFrame:frameViewRect];
}