Changeset 37046 in webkit


Ignore:
Timestamp:
Sep 28, 2008 4:31:25 PM (16 years ago)
Author:
timothy@apple.com
Message:

Improves the Web Inspector node highlight so it does not scroll to reveal the node in the page.

WebCore:

2008-09-28 Timothy Hatcher <timothy@apple.com>

Remove the scrollIntoViewIfNeeded() call when drawing the
Inspector node highlight.

<rdar://problem/6115804> Don't scroll when highlighting (21000)
https://bugs.webkit.org/show_bug.cgi?id=21000

Reviewed by Dan Bernstein.

  • page/InspectorController.cpp: (WebCore::InspectorController::drawNodeHighlight):

WebKit/mac:

2008-09-28 Timothy Hatcher <timothy@apple.com>

Improves the Web Inspector node highlight so it does not scroll
to reveal the node in the page. This makes the highlight less
invasive and causes less things to change on screen. Also makes
the highlight redraw when the WebView draws, so it stays current
if the node changes on the page for any reason.

<rdar://problem/6115804> Don't scroll when highlighting (21000)
https://bugs.webkit.org/show_bug.cgi?id=21000

Reviewed by Dan Bernstein.

  • WebCoreSupport/WebInspectorClient.mm: (-[WebInspectorWindowController highlightNode:]): Call setNeedsDisplay:YES if there is an existing highlight. (-[WebInspectorWindowController didAttachWebNodeHighlight:]): Set the current highlight node on the inspected WebView. (-[WebInspectorWindowController willDetachWebNodeHighlight:]): Set the current highlight node on the inspected WebView to nil.
  • WebInspector/WebNodeHighlight.m: (-[WebNodeHighlight setNeedsUpdateInTargetViewRect:]): Disable screen updates until flush for the inspected window. Invalidate the whole highlight view since we don't know the rect that needs updated since the highlight can be larger than the highlighted element due to the margins and other factors.
  • WebInspector/WebNodeHighlightView.m:
  • WebView/WebHTMLView.mm: (-[WebHTMLView drawSingleRect:]): Call setNeedsUpdateInTargetViewRect: on the current highlight node.
  • WebView/WebView.mm: (-[WebViewPrivate dealloc]): Release the current highlight node. (-[WebView setCurrentNodeHighlight:]): Set the current highlight node. (-[WebView currentNodeHighlight]): Return the current highlight node.
  • WebView/WebViewInternal.h:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r37045 r37046  
     12008-09-28  Timothy Hatcher  <timothy@apple.com>
     2
     3        Remove the scrollIntoViewIfNeeded() call when drawing the
     4        Inspector node highlight.
     5
     6        <rdar://problem/6115804> Don't scroll when highlighting (21000)
     7        https://bugs.webkit.org/show_bug.cgi?id=21000
     8
     9        Reviewed by Dan Bernstein.
     10
     11        * page/InspectorController.cpp:
     12        (WebCore::InspectorController::drawNodeHighlight):
     13
    1142008-09-28  David Hyatt  <hyatt@apple.com>
    215
  • trunk/WebCore/page/InspectorController.cpp

    r36960 r37046  
    25002500        else
    25012501            element = static_cast<Element*>(m_highlightedNode->parent());
    2502         element->scrollIntoViewIfNeeded();
    25032502        overlayRect = view->visibleContentRect();
    25042503    }
  • trunk/WebKit/mac/ChangeLog

    r37039 r37046  
     12008-09-28  Timothy Hatcher  <timothy@apple.com>
     2
     3        Improves the Web Inspector node highlight so it does not scroll
     4        to reveal the node in the page. This makes the highlight less
     5        invasive and causes less things to change on screen. Also makes
     6        the highlight redraw when the WebView draws, so it stays current
     7        if the node changes on the page for any reason.
     8
     9        <rdar://problem/6115804> Don't scroll when highlighting (21000)
     10        https://bugs.webkit.org/show_bug.cgi?id=21000
     11
     12        Reviewed by Dan Bernstein.
     13
     14        * WebCoreSupport/WebInspectorClient.mm:
     15        (-[WebInspectorWindowController highlightNode:]): Call setNeedsDisplay:YES
     16        if there is an existing highlight.
     17        (-[WebInspectorWindowController didAttachWebNodeHighlight:]): Set the current
     18        highlight node on the inspected WebView.
     19        (-[WebInspectorWindowController willDetachWebNodeHighlight:]): Set the current
     20        highlight node on the inspected WebView to nil.
     21        * WebInspector/WebNodeHighlight.m:
     22        (-[WebNodeHighlight setNeedsUpdateInTargetViewRect:]): Disable screen updates
     23        until flush for the inspected window. Invalidate the whole highlight view since
     24        we don't know the rect that needs updated since the highlight can be larger than
     25        the highlighted element due to the margins and other factors.
     26        * WebInspector/WebNodeHighlightView.m:
     27        * WebView/WebHTMLView.mm:
     28        (-[WebHTMLView drawSingleRect:]): Call setNeedsUpdateInTargetViewRect: on the
     29        current highlight node.
     30        * WebView/WebView.mm:
     31        (-[WebViewPrivate dealloc]): Release the current highlight node.
     32        (-[WebView setCurrentNodeHighlight:]): Set the current highlight node.
     33        (-[WebView currentNodeHighlight]): Return the current highlight node.
     34        * WebView/WebViewInternal.h:
     35
    1362008-09-28  David Kilzer  <ddkilzer@apple.com>
    237
  • trunk/WebKit/mac/WebCoreSupport/WebInspectorClient.mm

    r36714 r37046  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6262- (void)detach;
    6363- (void)setAttachedWindowHeight:(unsigned)height;
    64 - (void)highlightAndScrollToNode:(DOMNode *)node;
    6564- (void)highlightNode:(DOMNode *)node;
    6665- (void)hideHighlight;
     
    124123void WebInspectorClient::highlight(Node* node)
    125124{
    126     [m_windowController.get() highlightAndScrollToNode:kit(node)];
     125    [m_windowController.get() highlightNode:kit(node)];
    127126}
    128127
     
    393392#pragma mark -
    394393
    395 - (void)highlightAndScrollToNode:(DOMNode *)node
    396 {
    397     NSRect bounds = [node boundingBox];
    398     if (!NSIsEmptyRect(bounds)) {
    399         // FIXME: this needs to use the frame the node coordinates are in
    400         NSRect visible = [[[[_inspectedWebView mainFrame] frameView] documentView] visibleRect];
    401         BOOL needsScroll = !NSContainsRect(visible, bounds) && !NSContainsRect(bounds, visible);
    402 
    403         // only scroll if the bounds isn't in the visible rect and dosen't contain the visible rect
    404         if (needsScroll) {
    405             // scroll to the parent element if we aren't focused on an element
    406             DOMElement *element;
    407             if ([node isKindOfClass:[DOMElement class]])
    408                 element = (DOMElement *)node;
    409             else
    410                 element = (DOMElement *)[node parentNode];
    411             [element scrollIntoViewIfNeeded:YES];
    412 
    413             // give time for the scroll to happen
    414             [self performSelector:@selector(highlightNode:) withObject:node afterDelay:0.25];
    415         } else
    416             [self highlightNode:node];
    417     }
    418 }
    419 
    420394- (void)highlightNode:(DOMNode *)node
    421395{
     
    429403        [_currentHighlight setDelegate:self];
    430404        [_currentHighlight attach];
    431     }
    432 
    433     // FIXME: this is a hack until we hook up a didDraw and didScroll call in WebHTMLView
    434     [[_currentHighlight highlightView] setNeedsDisplay:YES];
     405    } else
     406        [[_currentHighlight highlightView] setNeedsDisplay:YES];
    435407}
    436408
     
    441413    [_currentHighlight release];
    442414    _currentHighlight = nil;
     415}
     416
     417#pragma mark -
     418#pragma mark WebNodeHighlight delegate
     419
     420- (void)didAttachWebNodeHighlight:(WebNodeHighlight *)highlight
     421{
     422    [_inspectedWebView setCurrentNodeHighlight:highlight];
     423}
     424
     425- (void)willDetachWebNodeHighlight:(WebNodeHighlight *)highlight
     426{
     427    [_inspectedWebView setCurrentNodeHighlight:nil];
    443428}
    444429
  • trunk/WebKit/mac/WebInspector/WebNodeHighlight.m

    r35850 r37046  
    11/*
    2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2007, 2008 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    149149    ASSERT(_targetView);
    150150
    151     [_highlightView setNeedsDisplayInRect:[_targetView _web_convertRect:rect toView:_highlightView]];
    152 
    153     // Redraw highlight view immediately so it updates in sync with the target view
    154     // if we called disableScreenUpdatesUntilFlush on the target view earlier. This
    155     // is especially visible when resizing the window.
     151    [[_targetView window] disableScreenUpdatesUntilFlush];
     152
     153    // Mark the whole highlight view as needing display since we don't know what areas
     154    // need updated, since the highlight can be larger than the element to show margins.
     155    [_highlightView setNeedsDisplay:YES];
     156
     157    // Redraw highlight view immediately so it updates in sync with the target view.
     158    // This is especially visible when resizing the window, scrolling or with DHTML.
    156159    [_highlightView displayIfNeeded];
    157160}
  • trunk/WebKit/mac/WebInspector/WebNodeHighlightView.m

    r35689 r37046  
    11/*
    2  * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
     2 * Copyright (C) 2006, 2008 Apple Computer, Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535
    3636using namespace WebCore;
    37 
    38 #define OVERLAY_MAX_ALPHA 0.7
    39 #define OVERLAY_WHITE_VALUE 0.1
    40 
    41 #define BORDER_THICKNESS 1.0
    4237
    4338@implementation WebNodeHighlightView
     
    8883}
    8984
    90 - (void)setNeedsDisplayInRect:(NSRect)rect
    91 {
    92     // Redisplay a slightly larger rect to account for the border
    93     rect = NSInsetRect(rect, -1 * BORDER_THICKNESS, -1 * BORDER_THICKNESS);
    94     [super setNeedsDisplayInRect:rect];
    95 }
    96 
    9785@end
  • trunk/WebKit/mac/WebView/WebHTMLView.mm

    r36919 r37046  
    5252#import "WebKitVersionChecks.h"
    5353#import "WebLocalizableStrings.h"
     54#import "WebNodeHighlight.h"
    5455#import "WebNSAttributedStringExtras.h"
    5556#import "WebNSEventExtras.h"
     
    29382939        [[self _frame] _drawRect:rect];
    29392940
     2941        WebView *webView = [self _webView];
     2942
    29402943        // This hack is needed for <rdar://problem/5023545>. We can hit a race condition where drawRect will be
    29412944        // called after the WebView has closed. If the client did not properly close the WebView and set the
    29422945        // UIDelegate to nil, then the UIDelegate will be stale and this code will crash.
    29432946        static BOOL version3OrLaterClient = WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITHOUT_QUICKBOOKS_QUIRK);
    2944         if (version3OrLaterClient) {
    2945             WebView *webView = [self _webView];
     2947        if (version3OrLaterClient)
    29462948            [[webView _UIDelegateForwarder] webView:webView didDrawRect:[webView convertRect:rect fromView:self]];
    2947         }
     2949
     2950        if (WebNodeHighlight *currentHighlight = [webView currentNodeHighlight])
     2951            [currentHighlight setNeedsUpdateInTargetViewRect:[self convertRect:rect toView:[currentHighlight targetView]]];
    29482952
    29492953        [(WebClipView *)[self superview] resetAdditionalClip];
  • trunk/WebKit/mac/WebView/WebView.mm

    r36962 r37046  
    6666#import "WebKitVersionChecks.h"
    6767#import "WebLocalizableStrings.h"
     68#import "WebNodeHighlight.h"
    6869#import "WebNSDataExtras.h"
    6970#import "WebNSDataExtrasPrivate.h"
     
    329330
    330331    WebInspector *inspector;
     332    WebNodeHighlight *currentNodeHighlight;
    331333
    332334    BOOL allowsUndo;
     
    512514   
    513515    [inspector release];
     516    [currentNodeHighlight release];
     517
    514518    [hostWindow release];
    515519
     
    29422946}
    29432947
     2948- (void)setCurrentNodeHighlight:(WebNodeHighlight *)nodeHighlight
     2949{
     2950    id old = _private->currentNodeHighlight;
     2951    _private->currentNodeHighlight = [nodeHighlight retain];
     2952    [old release];
     2953}
     2954
     2955- (WebNodeHighlight *)currentNodeHighlight
     2956{
     2957    return _private->currentNodeHighlight;
     2958}
     2959
    29442960@end
    29452961
  • trunk/WebKit/mac/WebView/WebViewInternal.h

    r36880 r37046  
    5353@class WebBasePluginPackage;
    5454@class WebDownload;
     55@class WebNodeHighlight;
    5556
    5657@interface WebView (WebViewEditingExtras)
     
    114115- (BOOL)_isMIMETypeRegisteredAsPlugin:(NSString *)MIMEType;
    115116
     117- (void)setCurrentNodeHighlight:(WebNodeHighlight *)nodeHighlight;
     118- (WebNodeHighlight *)currentNodeHighlight;
     119
    116120- (void)addPluginInstanceView:(NSView *)view;
    117121- (void)removePluginInstanceView:(NSView *)view;
Note: See TracChangeset for help on using the changeset viewer.