Commit ad382725 authored by aroben@apple.com's avatar aroben@apple.com

Make WebNodeHighlightView use InspectorController to do its painting

 WebCore:

         Export InspectorController::drawNodeHighlight

         Reviewed by Tim Hatcher.

         * WebCore.base.exp: Also sorted this file.

 WebKit:

         Mark WebNodeHighlight.m and WebNodeHighlightView.m Obj-C++

         Reviewed by Tim Hatcher.

         * WebKit.xcodeproj/project.pbxproj:

 WebKit/mac:

         Make WebNodeHighlightView use InspectorController to do its painting

         Reviewed by Tim Hatcher.

         * WebCoreSupport/WebInspectorClient.mm:
         (-[WebInspectorWindowController highlightNode:]): Pass the
         InspectorController to the WebNodeHighlight, and don't call
         setHighlightedNode: (which has been removed).
         (-[WebInspectorWindowController hideHighlight]): Removed call to
         setHighlightedNode:.
         * WebInspector/WebNodeHighlight.h:
           - Replaced _highlightNode with _inspectorController
           - Removed _highlightedNode accessors
           - Added -inspectorController method
         * WebInspector/WebNodeHighlight.m:
         (-[WebNodeHighlight initWithTargetView:inspectorController:]): Now
         takes an InspectorController* and stores it in _inspectorController.
         (-[WebNodeHighlight dealloc]): Removed code dealing with
         _highlightedNode.
         (-[WebNodeHighlight inspectorController]): Added.
         * WebInspector/WebNodeHighlightView.m: Removed FileInternal category.
         (-[WebNodeHighlightView isFlipped]): Added. WebCore expects all
         GraphicsContexts to be based on a flipped CGContext, so we have to
         specify that this view is flipped.
         (-[WebNodeHighlightView drawRect:]): Changed to create a
         GraphicsContext and pass it to InspectorController::drawNodeHighlight.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31177 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4da39a1a
2008-03-20 Adam Roben <aroben@apple.com>
Export InspectorController::drawNodeHighlight
Reviewed by Tim Hatcher.
* WebCore.base.exp: Also sorted this file.
2008-03-19 Stephanie Lewis <slewis@apple.com>
Rubber-stamped by Anders.
......@@ -665,12 +665,12 @@ __ZNK7WebCore13ResourceErrorcvP7NSErrorEv
__ZNK7WebCore14DocumentLoader10requestURLEv
__ZNK7WebCore14DocumentLoader11frameLoaderEv
__ZNK7WebCore14DocumentLoader14unreachableURLEv
__ZNK7WebCore14DocumentLoader15originalRequestEv
__ZNK7WebCore14DocumentLoader16mainResourceDataEv
__ZNK7WebCore14DocumentLoader19isLoadingInAPISenseEv
__ZNK7WebCore14DocumentLoader19originalRequestCopyEv
__ZNK7WebCore14DocumentLoader21isLoadingMainResourceEv
__ZNK7WebCore14DocumentLoader3urlEv
__ZNK7WebCore14DocumentLoader15originalRequestEv
__ZNK7WebCore14RenderListItem10markerTextEv
__ZNK7WebCore14ResourceHandle10connectionEv
__ZNK7WebCore14ResourceLoader11frameLoaderEv
......@@ -681,6 +681,7 @@ __ZNK7WebCore15VisiblePosition4nextEb
__ZNK7WebCore15VisiblePosition8previousEb
__ZNK7WebCore16ResourceResponse13nsURLResponseEv
__ZNK7WebCore17ResourceErrorBase8lazyInitEv
__ZNK7WebCore19InspectorController17drawNodeHighlightERNS_15GraphicsContextE
__ZNK7WebCore19ResourceRequestBase3urlEv
__ZNK7WebCore19ResourceRequestBase7isEmptyEv
__ZNK7WebCore19SelectionController17isInPasswordFieldEv
......
2008-03-20 Adam Roben <aroben@apple.com>
Mark WebNodeHighlight.m and WebNodeHighlightView.m Obj-C++
Reviewed by Tim Hatcher.
* WebKit.xcodeproj/project.pbxproj:
2008-03-12 Darin Adler <darin@apple.com>
Reviewed by Anders.
......
......@@ -328,9 +328,9 @@
1C0D40850AC1C8F40009C113 /* WebKitVersionChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitVersionChecks.h; sourceTree = "<group>"; };
1C0D40860AC1C8F40009C113 /* WebKitVersionChecks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebKitVersionChecks.m; sourceTree = "<group>"; };
1C68F663095B5FC100C2984E /* WebNodeHighlight.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNodeHighlight.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; wrapsLines = 0; };
1C68F664095B5FC100C2984E /* WebNodeHighlight.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNodeHighlight.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C68F664095B5FC100C2984E /* WebNodeHighlight.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; indentWidth = 4; path = WebNodeHighlight.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C68F665095B5FC100C2984E /* WebNodeHighlightView.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNodeHighlightView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C68F666095B5FC100C2984E /* WebNodeHighlightView.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNodeHighlightView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C68F666095B5FC100C2984E /* WebNodeHighlightView.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; indentWidth = 4; path = WebNodeHighlightView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
1C6CB03E0AA6391D00D23BFD /* MigrateHeaders.make */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = MigrateHeaders.make; path = mac/MigrateHeaders.make; sourceTree = "<group>"; };
1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebEditingDelegatePrivate.h; sourceTree = "<group>"; };
1C904FD20BA9DD0F0081E9D0 /* WebKit.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebKit.xcconfig; sourceTree = "<group>"; };
......
2008-03-20 Adam Roben <aroben@apple.com>
Make WebNodeHighlightView use InspectorController to do its painting
Reviewed by Tim Hatcher.
* WebCoreSupport/WebInspectorClient.mm:
(-[WebInspectorWindowController highlightNode:]): Pass the
InspectorController to the WebNodeHighlight, and don't call
setHighlightedNode: (which has been removed).
(-[WebInspectorWindowController hideHighlight]): Removed call to
setHighlightedNode:.
* WebInspector/WebNodeHighlight.h:
- Replaced _highlightNode with _inspectorController
- Removed _highlightedNode accessors
- Added -inspectorController method
* WebInspector/WebNodeHighlight.m:
(-[WebNodeHighlight initWithTargetView:inspectorController:]): Now
takes an InspectorController* and stores it in _inspectorController.
(-[WebNodeHighlight dealloc]): Removed code dealing with
_highlightedNode.
(-[WebNodeHighlight inspectorController]): Added.
* WebInspector/WebNodeHighlightView.m: Removed FileInternal category.
(-[WebNodeHighlightView isFlipped]): Added. WebCore expects all
GraphicsContexts to be based on a flipped CGContext, so we have to
specify that this view is flipped.
(-[WebNodeHighlightView drawRect:]): Changed to create a
GraphicsContext and pass it to InspectorController::drawNodeHighlight.
2008-03-18 David Hyatt <hyatt@apple.com>
Add support for a preference in WebKit that can be used in nightly builds to test full page
......
......@@ -468,15 +468,13 @@ void WebInspectorClient::updateWindowTitle() const
return; // skip the highlight if we have no window (e.g. hidden tab)
if (!_currentHighlight) {
_currentHighlight = [[WebNodeHighlight alloc] initWithTargetView:view];
_currentHighlight = [[WebNodeHighlight alloc] initWithTargetView:view inspectorController:[_inspectedWebView page]->inspectorController()];
[_currentHighlight setDelegate:self];
[_currentHighlight attachHighlight];
}
[_currentHighlight show];
[_currentHighlight setHighlightedNode:node];
// FIXME: this is a hack until we hook up a didDraw and didScroll call in WebHTMLView
[[_currentHighlight highlightView] setNeedsDisplay:YES];
}
......@@ -486,7 +484,6 @@ void WebInspectorClient::updateWindowTitle() const
if (!_currentHighlight)
return;
[_currentHighlight hide];
[_currentHighlight setHighlightedNode:nil];
}
#pragma mark -
......
......@@ -27,17 +27,20 @@
*/
@class WebNodeHighlightView;
@class DOMNode;
namespace WebCore {
class InspectorController;
}
@interface WebNodeHighlight : NSObject {
NSView *_targetView;
NSWindow *_highlightWindow;
WebNodeHighlightView *_highlightView;
NSAnimation *_fadeInAnimation;
DOMNode *_highlightNode;
WebCore::InspectorController* _inspectorController;
id _delegate;
}
- (id)initWithTargetView:(NSView *)targetView;
- (id)initWithTargetView:(NSView *)targetView inspectorController:(WebCore::InspectorController*)inspectorController;
- (void)setDelegate:(id)delegate;
- (id)delegate;
......@@ -51,8 +54,7 @@
- (NSView *)targetView;
- (WebNodeHighlightView *)highlightView;
- (void)setHighlightedNode:(DOMNode *)node;
- (DOMNode *)highlightedNode;
- (WebCore::InspectorController*)inspectorController;
// Controls whether mouse events are ignored (passed to underlying view). By default mouse events are ignored.
- (BOOL)ignoresMouseEvents;
......
......@@ -31,6 +31,9 @@
#import "WebNSViewExtras.h"
#import <JavaScriptCore/Assertions.h>
#import <WebCore/InspectorController.h>
using namespace WebCore;
#define FADE_ANIMATION_DURATION 0.2
......@@ -55,13 +58,14 @@ - (void)setCurrentProgress:(NSAnimationProgress)progress
@implementation WebNodeHighlight
- (id)initWithTargetView:(NSView *)targetView
- (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];
......@@ -79,18 +83,6 @@ - (id)initWithTargetView:(NSView *)targetView
return self;
}
- (void)setHighlightedNode:(DOMNode *)node
{
id old = _highlightNode;
_highlightNode = [node retain];
[old release];
}
- (DOMNode *)highlightedNode
{
return _highlightNode;
}
- (void)dealloc
{
// FIXME: Bad to do all this work in dealloc. What about under GC?
......@@ -104,8 +96,6 @@ - (void)dealloc
[_fadeInAnimation stopAnimation];
[_fadeInAnimation release];
[_highlightNode release];
[super dealloc];
}
......@@ -233,6 +223,11 @@ - (NSView *)targetView
return _targetView;
}
- (InspectorController*)inspectorController
{
return _inspectorController;
}
@end
@implementation WebNodeHighlight (FileInternal)
......
......@@ -34,16 +34,16 @@
#import <WebKit/DOMExtensions.h>
#import <JavaScriptCore/Assertions.h>
#import <WebCore/GraphicsContext.h>
#import <WebCore/InspectorController.h>
using namespace WebCore;
#define OVERLAY_MAX_ALPHA 0.7
#define OVERLAY_WHITE_VALUE 0.1
#define WHITE_FRAME_THICKNESS 1.0
@interface WebNodeHighlightView (FileInternal)
- (NSArray *)_holes;
@end
@implementation WebNodeHighlightView
- (id)initWithWebNodeHighlight:(WebNodeHighlight *)webNodeHighlight
......@@ -69,35 +69,19 @@ - (void)detachFromWebNodeHighlight
_webNodeHighlight = nil;
}
- (BOOL)isFlipped
{
return YES;
}
- (void)drawRect:(NSRect)rect
{
[NSGraphicsContext saveGraphicsState];
// draw translucent gray fill, out of which we will cut holes
[[NSColor colorWithCalibratedWhite:OVERLAY_WHITE_VALUE alpha:(_fractionFadedIn * OVERLAY_MAX_ALPHA)] set];
NSRectFill(rect);
// determine set of holes
NSArray *holes = [self _holes];
int holeCount = [holes count];
int holeIndex;
// Draw white frames around holes in first pass, so they will be erased in
// places where holes overlap or abut.
[[NSColor colorWithCalibratedWhite:1.0 alpha:_fractionFadedIn] set];
ASSERT([[NSGraphicsContext currentContext] isFlipped]);
// white frame is just outside of the hole that the delegate returned
for (holeIndex = 0; holeIndex < holeCount; ++holeIndex) {
NSRect hole = [[holes objectAtIndex:holeIndex] rectValue];
hole = NSInsetRect(hole, -WHITE_FRAME_THICKNESS, -WHITE_FRAME_THICKNESS);
NSRectFill(hole);
}
[[NSColor clearColor] set];
// Erase holes in second pass.
for (holeIndex = 0; holeIndex < holeCount; ++holeIndex)
NSRectFill([[holes objectAtIndex:holeIndex] rectValue]);
GraphicsContext context((PlatformGraphicsContext*)[[NSGraphicsContext currentContext] graphicsPort]);
[_webNodeHighlight inspectorController]->drawNodeHighlight(context);
[NSGraphicsContext restoreGraphicsState];
}
......@@ -134,42 +118,3 @@ - (void)setHolesNeedUpdateInRect:(NSRect)rect
@end
@implementation WebNodeHighlightView (FileInternal)
- (NSArray *)_holes
{
DOMNode *node = [_webNodeHighlight highlightedNode];
// FIXME: node view needs to be the correct frame document view, it isn't always the main frame
NSView *nodeView = [_webNodeHighlight targetView];
NSArray *lineBoxRects = nil;
if ([node isKindOfClass:[DOMElement class]]) {
DOMCSSStyleDeclaration *style = [[node ownerDocument] getComputedStyle:(DOMElement *)node pseudoElement:@""];
if ([[style getPropertyValue:@"display"] isEqualToString:@"inline"])
lineBoxRects = [node lineBoxRects];
} else if ([node isKindOfClass:[DOMText class]]) {
#if ENABLE(SVG)
if (![[node parentNode] isKindOfClass:NSClassFromString(@"DOMSVGElement")])
#endif
lineBoxRects = [node lineBoxRects];
}
if (![lineBoxRects count]) {
NSRect boundingBox = [nodeView _web_convertRect:[node boundingBox] toView:self];
return [NSArray arrayWithObject:[NSValue valueWithRect:boundingBox]];
}
NSMutableArray *rects = [[NSMutableArray alloc] initWithCapacity:[lineBoxRects count]];
unsigned lineBoxRectCount = [lineBoxRects count];
for (unsigned lineBoxRectIndex = 0; lineBoxRectIndex < lineBoxRectCount; ++lineBoxRectIndex) {
NSRect r = [[lineBoxRects objectAtIndex:lineBoxRectIndex] rectValue];
NSRect overlayViewRect = [nodeView _web_convertRect:r toView:self];
[rects addObject:[NSValue valueWithRect:overlayViewRect]];
}
return [rects autorelease];
}
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment