summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/mac/WebInspector
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebKit/mac/WebInspector
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebKit/mac/WebInspector')
-rw-r--r--Source/WebKit/mac/WebInspector/WebInspector.h61
-rw-r--r--Source/WebKit/mac/WebInspector/WebInspector.mm253
-rw-r--r--Source/WebKit/mac/WebInspector/WebInspectorFrontend.h35
-rw-r--r--Source/WebKit/mac/WebInspector/WebInspectorFrontend.mm51
-rw-r--r--Source/WebKit/mac/WebInspector/WebInspectorPrivate.h38
-rw-r--r--Source/WebKit/mac/WebInspector/WebNodeHighlight.h61
-rw-r--r--Source/WebKit/mac/WebInspector/WebNodeHighlight.mm204
-rw-r--r--Source/WebKit/mac/WebInspector/WebNodeHighlightView.h38
-rw-r--r--Source/WebKit/mac/WebInspector/WebNodeHighlightView.mm86
9 files changed, 827 insertions, 0 deletions
diff --git a/Source/WebKit/mac/WebInspector/WebInspector.h b/Source/WebKit/mac/WebInspector/WebInspector.h
new file mode 100644
index 0000000..ed78ed7
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebInspector.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2007 Apple 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+#import <Foundation/NSObject.h>
+
+@class WebView;
+@class WebInspectorFrontend;
+
+@interface WebInspector : NSObject
+{
+ WebView *_webView;
+ WebInspectorFrontend *_frontend;
+}
+- (id)initWithWebView:(WebView *)webView;
+- (void)webViewClosed;
+- (void)show:(id)sender;
+- (void)showConsole:(id)sender;
+- (void)close:(id)sender;
+- (void)attach:(id)sender;
+- (void)detach:(id)sender;
+
+- (BOOL)isDebuggingJavaScript;
+- (void)toggleDebuggingJavaScript:(id)sender;
+- (void)startDebuggingJavaScript:(id)sender;
+- (void)stopDebuggingJavaScript:(id)sender;
+
+- (BOOL)isJavaScriptProfilingEnabled;
+- (void)setJavaScriptProfilingEnabled:(BOOL)enabled;
+- (BOOL)isTimelineProfilingEnabled;
+- (void)setTimelineProfilingEnabled:(BOOL)enabled;
+
+- (BOOL)isProfilingJavaScript;
+- (void)toggleProfilingJavaScript:(id)sender;
+- (void)startProfilingJavaScript:(id)sender;
+- (void)stopProfilingJavaScript:(id)sender;
+@end
diff --git a/Source/WebKit/mac/WebInspector/WebInspector.mm b/Source/WebKit/mac/WebInspector/WebInspector.mm
new file mode 100644
index 0000000..8ab049f
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebInspector.mm
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 2007 Apple 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+#import "WebInspector.h"
+
+#import "WebFrameInternal.h"
+#import "WebInspectorPrivate.h"
+#import "WebInspectorFrontend.h"
+
+#include <WebCore/Document.h>
+#include <WebCore/Frame.h>
+#include <WebCore/InspectorController.h>
+#include <WebCore/Page.h>
+
+using namespace WebCore;
+
+@implementation WebInspector
+- (id)initWithWebView:(WebView *)webView
+{
+ if (!(self = [super init]))
+ return nil;
+ _webView = webView; // not retained to prevent a cycle
+ return self;
+}
+
+- (void)dealloc
+{
+ [_frontend release];
+ [super dealloc];
+}
+
+- (void)webViewClosed
+{
+ _webView = nil;
+}
+
+- (void)show:(id)sender
+{
+ if (Page* page = core(_webView))
+ page->inspectorController()->show();
+}
+
+- (void)showConsole:(id)sender
+{
+ if (Page* page = core(_webView))
+ page->inspectorController()->showPanel(InspectorController::ConsolePanel);
+}
+
+- (void)showTimeline:(id)sender
+{
+ // Not used anymore. Remove when a release of Safari non-longer calls this.
+}
+
+- (BOOL)isDebuggingJavaScript
+{
+ if (Page* page = core(_webView))
+ return page->inspectorController()->debuggerEnabled();
+ return NO;
+}
+
+- (void)toggleDebuggingJavaScript:(id)sender
+{
+ if ([self isDebuggingJavaScript])
+ [self stopDebuggingJavaScript:sender];
+ else
+ [self startDebuggingJavaScript:sender];
+}
+
+- (void)startDebuggingJavaScript:(id)sender
+{
+ Page* page = core(_webView);
+ if (!page)
+ return;
+ page->inspectorController()->showAndEnableDebugger();
+}
+
+- (void)stopDebuggingJavaScript:(id)sender
+{
+ if (Page* page = core(_webView))
+ page->inspectorController()->disableDebugger();
+}
+
+- (BOOL)isProfilingJavaScript
+{
+ if (Page* page = core(_webView))
+ return page->inspectorController()->isRecordingUserInitiatedProfile();
+ return NO;
+}
+
+- (void)toggleProfilingJavaScript:(id)sender
+{
+ if ([self isProfilingJavaScript])
+ [self stopProfilingJavaScript:sender];
+ else
+ [self startProfilingJavaScript:sender];
+}
+
+- (void)startProfilingJavaScript:(id)sender
+{
+ if (Page* page = core(_webView))
+ page->inspectorController()->startUserInitiatedProfiling();
+}
+
+- (void)stopProfilingJavaScript:(id)sender
+{
+ Page* page = core(_webView);
+ if (!page)
+ return;
+ page->inspectorController()->stopUserInitiatedProfiling();
+ page->inspectorController()->showPanel(InspectorController::ProfilesPanel);
+}
+
+- (BOOL)isJavaScriptProfilingEnabled
+{
+ if (Page* page = core(_webView))
+ return page->inspectorController()->profilerEnabled();
+ return NO;
+}
+
+- (void)setJavaScriptProfilingEnabled:(BOOL)enabled
+{
+ Page* page = core(_webView);
+ if (!page)
+ return;
+
+ if (enabled)
+ page->inspectorController()->enableProfiler();
+ else
+ page->inspectorController()->disableProfiler();
+}
+
+- (BOOL)isTimelineProfilingEnabled
+{
+ if (Page* page = core(_webView))
+ return page->inspectorController()->timelineAgent() ? YES : NO;
+ return NO;
+}
+
+- (void)setTimelineProfilingEnabled:(BOOL)enabled
+{
+ Page* page = core(_webView);
+ if (!page)
+ return;
+
+ if (enabled)
+ page->inspectorController()->startTimelineProfiler();
+ else
+ page->inspectorController()->stopTimelineProfiler();
+}
+
+- (void)close:(id)sender
+{
+ if (Page* page = core(_webView))
+ page->inspectorController()->close();
+}
+
+- (void)attach:(id)sender
+{
+ [_frontend attach];
+}
+
+- (void)detach:(id)sender
+{
+ [_frontend detach];
+}
+
+- (void)evaluateInFrontend:(id)sender callId:(long)callId script:(NSString *)script
+{
+ if (Page* page = core(_webView))
+ page->inspectorController()->evaluateForTestInFrontend(callId, script);
+}
+
+- (void)setFrontend:(WebInspectorFrontend *)frontend
+{
+ [_frontend release];
+ _frontend = [frontend retain];
+}
+@end
+
+@implementation WebInspector (Obsolete)
++ (WebInspector *)webInspector
+{
+ // Safari 3.0 calls this method
+ static BOOL logged = NO;
+ if (!logged) {
+ NSLog(@"+[WebInspector webInspector]: this method is obsolete.");
+ logged = YES;
+ }
+
+ return [[[WebInspector alloc] init] autorelease];
+}
+
+- (void)setWebFrame:(WebFrame *)frame
+{
+ // Safari 3.0 calls this method
+ static BOOL logged = NO;
+ if (!logged) {
+ NSLog(@"-[WebInspector setWebFrame:]: this method is obsolete.");
+ logged = YES;
+ }
+
+ _webView = [frame webView];
+}
+
+- (NSWindow *)window
+{
+ // Shiira calls this internal method, return nil since we can't easily return the window
+ static BOOL logged = NO;
+ if (!logged) {
+ NSLog(@"-[WebInspector window]: this method is obsolete and now returns nil.");
+ logged = YES;
+ }
+
+ return nil;
+}
+
+- (void)showWindow:(id)sender
+{
+ // Safari 3.0 calls this method
+ static BOOL logged = NO;
+ if (!logged) {
+ NSLog(@"-[WebInspector showWindow:]: this method is obsolete.");
+ logged = YES;
+ }
+
+ [self show:sender];
+}
+@end
diff --git a/Source/WebKit/mac/WebInspector/WebInspectorFrontend.h b/Source/WebKit/mac/WebInspector/WebInspectorFrontend.h
new file mode 100644
index 0000000..93bed84
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebInspectorFrontend.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2010 Apple 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 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 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.
+ */
+
+class WebInspectorFrontendClient;
+
+@interface WebInspectorFrontend : NSObject {
+@private
+ WebInspectorFrontendClient *m_frontendClient;
+}
+- (id)initWithFrontendClient:(WebInspectorFrontendClient *)frontendClient;
+- (void)attach;
+- (void)detach;
+@end
diff --git a/Source/WebKit/mac/WebInspector/WebInspectorFrontend.mm b/Source/WebKit/mac/WebInspector/WebInspectorFrontend.mm
new file mode 100644
index 0000000..c285ef7
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebInspectorFrontend.mm
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 Apple 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 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 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.
+ */
+
+#import "WebInspectorFrontend.h"
+
+#import "WebInspectorClient.h"
+
+@implementation WebInspectorFrontend
+
+- (id)initWithFrontendClient:(WebInspectorFrontendClient *)frontendClient
+{
+ if (!(self = [super init]))
+ return nil;
+
+ m_frontendClient = frontendClient;
+ return self;
+}
+
+- (void)attach
+{
+ m_frontendClient->attachWindow();
+}
+
+- (void)detach
+{
+ m_frontendClient->detachWindow();
+}
+
+@end
diff --git a/Source/WebKit/mac/WebInspector/WebInspectorPrivate.h b/Source/WebKit/mac/WebInspector/WebInspectorPrivate.h
new file mode 100644
index 0000000..df1e286
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebInspectorPrivate.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2005 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+// This header contains the WebInspector SPI.
+
+#import <WebKit/WebInspector.h>
+
+@class WebInspectorFrontend;
+
+@interface WebInspector (WebPrivate)
+- (void)evaluateInFrontend:(id)sender callId:(long)callId script:(NSString *)script;
+- (void)setFrontend:(WebInspectorFrontend *)frontend;
+@end
diff --git a/Source/WebKit/mac/WebInspector/WebNodeHighlight.h b/Source/WebKit/mac/WebInspector/WebNodeHighlight.h
new file mode 100644
index 0000000..1eb277a
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebNodeHighlight.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2007 Apple 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+@class WebNodeHighlightView;
+
+namespace WebCore {
+ class InspectorController;
+}
+
+@interface WebNodeHighlight : NSObject {
+ NSView *_targetView;
+ NSWindow *_highlightWindow;
+ WebNodeHighlightView *_highlightView;
+ WebCore::InspectorController* _inspectorController;
+ id _delegate;
+}
+- (id)initWithTargetView:(NSView *)targetView inspectorController:(WebCore::InspectorController*)inspectorController;
+
+- (void)setDelegate:(id)delegate;
+- (id)delegate;
+
+- (void)attach;
+- (void)detach;
+
+- (NSView *)targetView;
+- (WebNodeHighlightView *)highlightView;
+
+- (WebCore::InspectorController*)inspectorController;
+
+- (void)setNeedsUpdateInTargetViewRect:(NSRect)rect;
+@end
+
+@interface NSObject (WebNodeHighlightDelegate)
+- (void)didAttachWebNodeHighlight:(WebNodeHighlight *)highlight;
+- (void)willDetachWebNodeHighlight:(WebNodeHighlight *)highlight;
+@end
diff --git a/Source/WebKit/mac/WebInspector/WebNodeHighlight.mm b/Source/WebKit/mac/WebInspector/WebNodeHighlight.mm
new file mode 100644
index 0000000..c918d2d
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebNodeHighlight.mm
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2007, 2008 Apple 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+#import "WebNodeHighlight.h"
+#import "WebNodeHighlightView.h"
+#import "WebNSViewExtras.h"
+
+#import <WebCore/InspectorController.h>
+#import <wtf/Assertions.h>
+
+using namespace WebCore;
+
+@interface WebNodeHighlight (FileInternal)
+- (NSRect)_computeHighlightWindowFrame;
+- (void)_repositionHighlightWindow;
+@end
+
+@implementation WebNodeHighlight
+
+- (id)initWithTargetView:(NSView *)targetView inspectorController:(InspectorController*)inspectorController
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _targetView = [targetView retain];
+ _inspectorController = inspectorController;
+
+ int styleMask = NSBorderlessWindowMask;
+ NSRect contentRect = [NSWindow contentRectForFrameRect:[self _computeHighlightWindowFrame] styleMask:styleMask];
+ _highlightWindow = [[NSWindow alloc] initWithContentRect:contentRect styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
+ [_highlightWindow setBackgroundColor:[NSColor clearColor]];
+ [_highlightWindow setOpaque:NO];
+ [_highlightWindow setIgnoresMouseEvents:YES];
+ [_highlightWindow setReleasedWhenClosed:NO];
+
+ _highlightView = [[WebNodeHighlightView alloc] initWithWebNodeHighlight:self];
+ [_highlightWindow setContentView:_highlightView];
+ [_highlightView release];
+
+ return self;
+}
+
+- (void)dealloc
+{
+ ASSERT(!_highlightWindow);
+ ASSERT(!_targetView);
+ ASSERT(!_highlightView);
+
+ [super dealloc];
+}
+
+- (void)attach
+{
+ ASSERT(_targetView);
+ ASSERT([_targetView window]);
+ ASSERT(_highlightWindow);
+
+ if (!_highlightWindow || !_targetView || ![_targetView window])
+ return;
+
+ [[_targetView window] addChildWindow:_highlightWindow ordered:NSWindowAbove];
+
+ // Observe both frame-changed and bounds-changed notifications because either one could leave
+ // the highlight incorrectly positioned with respect to the target view. We need to do this for
+ // the entire superview hierarchy to handle scrolling, bars coming and going, etc.
+ // (without making concrete assumptions about the view hierarchy).
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ for (NSView *v = _targetView; v; v = [v superview]) {
+ [notificationCenter addObserver:self selector:@selector(_repositionHighlightWindow) name:NSViewFrameDidChangeNotification object:v];
+ [notificationCenter addObserver:self selector:@selector(_repositionHighlightWindow) name:NSViewBoundsDidChangeNotification object:v];
+ }
+
+ if (_delegate && [_delegate respondsToSelector:@selector(didAttachWebNodeHighlight:)])
+ [_delegate didAttachWebNodeHighlight:self];
+}
+
+- (id)delegate
+{
+ return _delegate;
+}
+
+- (void)detach
+{
+ if (!_highlightWindow) {
+ ASSERT(!_targetView);
+ return;
+ }
+
+ if (_delegate && [_delegate respondsToSelector:@selector(willDetachWebNodeHighlight:)])
+ [_delegate willDetachWebNodeHighlight:self];
+
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ [notificationCenter removeObserver:self name:NSViewFrameDidChangeNotification object:nil];
+ [notificationCenter removeObserver:self name:NSViewBoundsDidChangeNotification object:nil];
+
+ [[_highlightWindow parentWindow] removeChildWindow:_highlightWindow];
+
+ [_highlightWindow release];
+ _highlightWindow = nil;
+
+ [_targetView release];
+ _targetView = nil;
+
+ // We didn't retain _highlightView, but we do need to tell it to forget about us, so it doesn't
+ // try to send our delegate messages after we've been dealloc'ed, e.g.
+ [_highlightView detachFromWebNodeHighlight];
+ _highlightView = nil;
+}
+
+- (WebNodeHighlightView *)highlightView
+{
+ return _highlightView;
+}
+
+- (void)setDelegate:(id)delegate
+{
+ // The delegate is not retained, as usual in Cocoa.
+ _delegate = delegate;
+}
+
+- (void)setNeedsUpdateInTargetViewRect:(NSRect)rect
+{
+ ASSERT(_targetView);
+
+ [[_targetView window] disableScreenUpdatesUntilFlush];
+
+ // Mark the whole highlight view as needing display since we don't know what areas
+ // need updated, since the highlight can be larger than the element to show margins.
+ [_highlightView setNeedsDisplay:YES];
+
+ // Redraw highlight view immediately so it updates in sync with the target view.
+ // This is especially visible when resizing the window, scrolling or with DHTML.
+ [_highlightView displayIfNeeded];
+}
+
+- (NSView *)targetView
+{
+ return _targetView;
+}
+
+- (InspectorController*)inspectorController
+{
+ return _inspectorController;
+}
+
+@end
+
+@implementation WebNodeHighlight (FileInternal)
+
+- (NSRect)_computeHighlightWindowFrame
+{
+ ASSERT(_targetView);
+ ASSERT([_targetView window]);
+
+ NSRect highlightWindowFrame = [_targetView convertRect:[_targetView visibleRect] toView:nil];
+ highlightWindowFrame.origin = [[_targetView window] convertBaseToScreen:highlightWindowFrame.origin];
+
+ return highlightWindowFrame;
+}
+
+- (void)_repositionHighlightWindow
+{
+ // This assertion fires in cases where a new tab is created while the highlight
+ // is showing (<http://bugs.webkit.org/show_bug.cgi?id=14254>)
+ ASSERT([_targetView window]);
+
+ // Until that bug is fixed, bail out to avoid worse problems where the highlight
+ // moves to a nonsense location.
+ if (![_targetView window])
+ return;
+
+ // Disable screen updates so the highlight moves in sync with the view.
+ [[_targetView window] disableScreenUpdatesUntilFlush];
+
+ [_highlightWindow setFrame:[self _computeHighlightWindowFrame] display:YES];
+}
+
+@end
diff --git a/Source/WebKit/mac/WebInspector/WebNodeHighlightView.h b/Source/WebKit/mac/WebInspector/WebNodeHighlightView.h
new file mode 100644
index 0000000..cb317b8
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebNodeHighlightView.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+@class WebNodeHighlight;
+
+@interface WebNodeHighlightView : NSView {
+ WebNodeHighlight *_webNodeHighlight;
+}
+- (id)initWithWebNodeHighlight:(WebNodeHighlight *)webNodeHighlight;
+
+- (WebNodeHighlight *)webNodeHighlight;
+- (void)detachFromWebNodeHighlight;
+@end
diff --git a/Source/WebKit/mac/WebInspector/WebNodeHighlightView.mm b/Source/WebKit/mac/WebInspector/WebNodeHighlightView.mm
new file mode 100644
index 0000000..7fc3cf4
--- /dev/null
+++ b/Source/WebKit/mac/WebInspector/WebNodeHighlightView.mm
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2006, 2008 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+#import "WebNodeHighlightView.h"
+#import "WebNodeHighlight.h"
+
+#import <WebCore/GraphicsContext.h>
+#import <WebCore/InspectorController.h>
+#import <wtf/Assertions.h>
+
+using namespace WebCore;
+
+@implementation WebNodeHighlightView
+
+- (id)initWithWebNodeHighlight:(WebNodeHighlight *)webNodeHighlight
+{
+ self = [self initWithFrame:NSZeroRect];
+ if (!self)
+ return nil;
+
+ _webNodeHighlight = [webNodeHighlight retain];
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [self detachFromWebNodeHighlight];
+ [super dealloc];
+}
+
+- (void)detachFromWebNodeHighlight
+{
+ [_webNodeHighlight release];
+ _webNodeHighlight = nil;
+}
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+- (void)drawRect:(NSRect)rect
+{
+ if (_webNodeHighlight) {
+ [NSGraphicsContext saveGraphicsState];
+
+ ASSERT([[NSGraphicsContext currentContext] isFlipped]);
+
+ GraphicsContext context((PlatformGraphicsContext*)[[NSGraphicsContext currentContext] graphicsPort]);
+ [_webNodeHighlight inspectorController]->drawNodeHighlight(context);
+ [NSGraphicsContext restoreGraphicsState];
+ }
+}
+
+- (WebNodeHighlight *)webNodeHighlight
+{
+ return _webNodeHighlight;
+}
+
+@end