WebCore:
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Mar 2006 17:49:47 +0000 (17:49 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Mar 2006 17:49:47 +0000 (17:49 +0000)
        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=7450
        elementAtPoint is expensive and should return a smart dictionary

        Support for WebKit. This removes the old elementAtPoint: on the bridge.
        WebKit now uses the bridge method getInnerNonSharedNode:innerNode:URLElement:atPoint:

        * WebCore.exp: removes the WebCore* dictionary keys
        * bindings/objc/DOM.mm:
        (-[DOMElement image]): new method to get an NSImage if the element has an image renderer
        * bindings/objc/DOMHTML.mm:
        (-[DOMHTMLElement titleDisplayString]): new method that returns the title after doing the backslash as currency symbol conversion
        (-[DOMHTMLInputElement altDisplayString]): ditto for alt
        (-[DOMHTMLImageElement altDisplayString]): ditto
        (-[DOMHTMLAppletElement altDisplayString]): ditto
        (-[DOMHTMLAreaElement altDisplayString]): ditto
        (-[DOMHTMLAnchorElement absoluteLinkURL]): new method to get the absolute NSURL
        (-[DOMHTMLAreaElement absoluteLinkURL]): ditto
        (-[DOMHTMLLinkElement absoluteLinkURL]): ditto
        (-[DOMHTMLInputElement absoluteImageURL]): new method to get the absolute image location as an NSURL
        (-[DOMHTMLImageElement absoluteImageURL]): ditto
        (-[DOMHTMLObjectElement absoluteImageURL]): ditto
        * bindings/objc/DOMPrivate.h:
        * bridge/mac/WebCoreFrameBridge.h:
        * bridge/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge getInnerNonSharedNode:innerNode:URLElement:atPoint:]):
        (-[WebCoreFrameBridge isPointInsideSelection:]):
        * dom/DocumentImpl.cpp:
        (WebCore::DocumentImpl::prepareMouseEvent):
        (WebCore::DocumentImpl::backslashAsCurrencySymbol):
        * dom/DocumentImpl.h:
        * rendering/render_layer.cpp:
        (WebCore::RenderLayer::hitTest):
        * rendering/render_object.h:
        (WebCore::RenderObject::NodeInfo::URLElement):
        (WebCore::RenderObject::NodeInfo::setURLElement):

WebKit:

        Reviewed by Darin.

        http://bugzilla.opendarwin.org/show_bug.cgi?id=7450
        elementAtPoint is expensive and should return a smart dictionary

        elementAtPoint for WebHTMLView now returns a WebElementDictionary,
        when objectForKey is called it will lookup in the DOM, cache and return the value

        * Misc/WebElementDictionary.h: Added.
        * Misc/WebElementDictionary.m: Added.
        (addLookupKey):
        (cacheValueForKey):
        (+[WebElementDictionary initializeLookupTable]):
        (-[WebElementDictionary initWithInnerNonSharedNode:innerNode:URLElement:andPoint:]):
        (-[WebElementDictionary dealloc]):
        (-[WebElementDictionary _fillCache]):
        (-[WebElementDictionary count]):
        (-[WebElementDictionary keyEnumerator]):
        (-[WebElementDictionary objectForKey:]):
        (-[WebElementDictionary _domNode]):
        (-[WebElementDictionary _webFrame]):
        (-[WebElementDictionary _targetWebFrame]):
        (-[WebElementDictionary _title]):
        (-[WebElementDictionary _imageRect]):
        (-[WebElementDictionary _isSelected]):
        * Misc/WebNSViewExtras.m:
        (-[NSView _web_dragImage:element:rect:event:pasteboard:source:offset:]):
        * WebKit.xcodeproj/project.pbxproj:
        * WebView/WebHTMLView.m:
        (-[WebHTMLView _updateMouseoverWithEvent:]):
        (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
        (-[NSArray elementAtPoint:]):
        * WebView/WebView.m:
        * WebView/WebViewPrivate.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13070 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/bindings/objc/DOM.mm
WebCore/bindings/objc/DOMHTML.mm
WebCore/bindings/objc/DOMPrivate.h
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/dom/DocumentImpl.cpp
WebCore/dom/DocumentImpl.h
WebCore/rendering/render_layer.cpp
WebCore/rendering/render_object.h
WebKit/ChangeLog
WebKit/Misc/WebElementDictionary.h [new file with mode: 0644]
WebKit/Misc/WebElementDictionary.m [new file with mode: 0644]
WebKit/Misc/WebNSViewExtras.m
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebView.m
WebKit/WebView/WebViewPrivate.h

index 8dc13e8c23c4f0e567c81ef6e6edcf6f1929bc7f..bee7f9df41c89b6ef13bc998164277622ff07c78 100644 (file)
@@ -1,3 +1,43 @@
+2006-03-01  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Darin.
+        
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=7450
+        elementAtPoint is expensive and should return a smart dictionary
+
+        Support for WebKit. This removes the old elementAtPoint: on the bridge.
+        WebKit now uses the bridge method getInnerNonSharedNode:innerNode:URLElement:atPoint:
+
+        * WebCore.exp: removes the WebCore* dictionary keys
+        * bindings/objc/DOM.mm:
+        (-[DOMElement image]): new method to get an NSImage if the element has an image renderer
+        * bindings/objc/DOMHTML.mm:
+        (-[DOMHTMLElement titleDisplayString]): new method that returns the title after doing the backslash as currency symbol conversion
+        (-[DOMHTMLInputElement altDisplayString]): ditto for alt
+        (-[DOMHTMLImageElement altDisplayString]): ditto
+        (-[DOMHTMLAppletElement altDisplayString]): ditto
+        (-[DOMHTMLAreaElement altDisplayString]): ditto
+        (-[DOMHTMLAnchorElement absoluteLinkURL]): new method to get the absolute NSURL
+        (-[DOMHTMLAreaElement absoluteLinkURL]): ditto
+        (-[DOMHTMLLinkElement absoluteLinkURL]): ditto
+        (-[DOMHTMLInputElement absoluteImageURL]): new method to get the absolute image location as an NSURL
+        (-[DOMHTMLImageElement absoluteImageURL]): ditto
+        (-[DOMHTMLObjectElement absoluteImageURL]): ditto
+        * bindings/objc/DOMPrivate.h:
+        * bridge/mac/WebCoreFrameBridge.h:
+        * bridge/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge getInnerNonSharedNode:innerNode:URLElement:atPoint:]):
+        (-[WebCoreFrameBridge isPointInsideSelection:]):
+        * dom/DocumentImpl.cpp:
+        (WebCore::DocumentImpl::prepareMouseEvent):
+        (WebCore::DocumentImpl::backslashAsCurrencySymbol):
+        * dom/DocumentImpl.h:
+        * rendering/render_layer.cpp:
+        (WebCore::RenderLayer::hitTest):
+        * rendering/render_object.h:
+        (WebCore::RenderObject::NodeInfo::URLElement):
+        (WebCore::RenderObject::NodeInfo::setURLElement):
+
 2006-03-01  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Test: fast/css/hover-subselector.html
index 49c8d0b31c8d4536e744b23d310f18e652e21219..03f8c0b05e8f1b0e15373727be45d968eadebb8e 100644 (file)
 .objc_class_name_WebCoreTextRendererFactory
 .objc_class_name_WebCoreViewFactory
 .objc_class_name_WebDashboardRegion
-_WebCoreElementDOMNodeKey
-_WebCoreElementFrameKey
-_WebCoreElementImageAltStringKey
-_WebCoreElementImageRectKey
-_WebCoreElementImageURLKey
-_WebCoreElementIsSelectedKey
-_WebCoreElementLinkLabelKey
-_WebCoreElementLinkTargetFrameKey
-_WebCoreElementLinkTitleKey
-_WebCoreElementLinkURLKey
-_WebCoreElementTitleKey
 _WebCoreInitializeEmptyTextGeometry
 _WebCoreInitializeEmptyTextStyle
 _WebCoreInitializeFont
index 78494a7caa1d71340861e953576d0c9eb2039ba5..ba7baae23086a528a69ef55a8db13e65d0814695 100644 (file)
@@ -1451,6 +1451,17 @@ static ListenerMap *listenerMap;
 
 @implementation DOMElement (DOMElementExtensions)
 
+- (NSImage*)image
+{
+    RenderObject* renderer = [self _elementImpl]->renderer();
+    if (renderer && renderer->isImage()) {
+        RenderImage* img = static_cast<RenderImage*>(renderer);
+        if (img->cachedImage() && !img->cachedImage()->isErrorImage())
+            return img->cachedImage()->image()->getNSImage();
+    }
+    return nil;
+}
+
 - (void)focus
 {
     [self _elementImpl]->focus();
@@ -1498,17 +1509,6 @@ static ListenerMap *listenerMap;
     return nil;
 }
 
-- (NSImage*)_image
-{
-    RenderObject *renderer = [self _elementImpl]->renderer();
-    if (renderer && renderer->isImage()) {
-        RenderImage* img = static_cast<RenderImage*>(renderer);
-        if (img->cachedImage() && !img->cachedImage()->isErrorImage())
-            return img->cachedImage()->image()->getNSImage();
-    }
-    return nil;
-}
-
 - (NSData*)_imageTIFFRepresentation
 {
     RenderObject *renderer = [self _elementImpl]->renderer();
index 4bc972c9b85ce9460857be59c3f35b0f290306b8..5094aa7b10ef638a19dd74a647381b3414d2cdca 100644 (file)
@@ -58,6 +58,7 @@
 
 #import "DOMExtensions.h"
 #import "DOMInternal.h"
+#import "DOMPrivate.h"
 #import "DOMHTMLInternal.h"
 #import <kxmlcore/Assertions.h>
 #import "FoundationExtras.h"
@@ -259,6 +260,11 @@ using namespace DOM::HTMLNames;
     return [self _HTMLElementImpl]->title();
 }
 
+- (NSString *)titleDisplayString
+{
+    return [self _HTMLElementImpl]->title().replace('\\', [self _elementImpl]->getDocument()->backslashAsCurrencySymbol());
+}
+
 - (void)setTitle:(NSString *)title
 {
     [self _HTMLElementImpl]->setTitle(title);
@@ -580,6 +586,11 @@ using namespace DOM::HTMLNames;
     [self _linkElementImpl]->setCharset(charset);
 }
 
+- (NSURL *)absoluteLinkURL
+{
+    return [self _getURLAttribute:@"href"];
+}
+
 - (NSString *)href
 {
     return [self _linkElementImpl]->href();
@@ -1280,6 +1291,11 @@ using namespace DOM::HTMLNames;
     return [self _inputElementImpl]->alt();
 }
 
+- (NSString *)altDisplayString
+{
+    return [self _inputElementImpl]->alt().replace('\\', [self _elementImpl]->getDocument()->backslashAsCurrencySymbol());
+}
+
 - (void)setAlt:(NSString *)alt
 {
     [self _inputElementImpl]->setAlt(alt);
@@ -1345,6 +1361,13 @@ using namespace DOM::HTMLNames;
     [self _inputElementImpl]->setSize(size);
 }
 
+- (NSURL *)absoluteImageURL
+{
+    if (![self _inputElementImpl]->renderer() || ![self _inputElementImpl]->renderer()->isImage())
+        return nil;
+    return [self _getURLAttribute:@"src"];
+}
+
 - (NSString *)src
 {
     return [self _inputElementImpl]->src();
@@ -2165,6 +2188,11 @@ using namespace DOM::HTMLNames;
     [self _anchorElementImpl]->setAttribute(coordsAttr, coords);
 }
 
+- (NSURL *)absoluteLinkURL
+{
+    return [self _getURLAttribute:@"href"];
+}
+
 - (NSString *)href
 {
     return [self _anchorElementImpl]->href();
@@ -2302,6 +2330,12 @@ using namespace DOM::HTMLNames;
     return [self _imageElementImpl]->getAttribute(altAttr);
 }
 
+- (NSString *)altDisplayString
+{
+    String alt = [self _imageElementImpl]->getAttribute(altAttr);
+    return alt.replace('\\', [self _elementImpl]->getDocument()->backslashAsCurrencySymbol());
+}
+
 - (void)setAlt:(NSString *)alt
 {
     [self _imageElementImpl]->setAttribute(altAttr, alt);
@@ -2359,6 +2393,11 @@ using namespace DOM::HTMLNames;
     [self _imageElementImpl]->setAttribute(longdescAttr, longDesc);
 }
 
+- (NSURL *)absoluteImageURL
+{
+    return [self _getURLAttribute:@"src"];
+}
+
 - (NSString *)src
 {
     return [self _imageElementImpl]->src();
@@ -2475,6 +2514,13 @@ using namespace DOM::HTMLNames;
     [self _objectElementImpl]->setAttribute(codetypeAttr, codeType);
 }
 
+- (NSURL *)absoluteImageURL
+{
+    if (![self _objectElementImpl]->renderer() || ![self _objectElementImpl]->renderer()->isImage())
+        return nil;
+    return [self _getURLAttribute:@"data"];
+}
+
 - (NSString *)data
 {
     return [self _objectElementImpl]->getAttribute(dataAttr);
@@ -2666,6 +2712,12 @@ using namespace DOM::HTMLNames;
     return [self _appletElementImpl]->getAttribute(altAttr);
 }
 
+- (NSString *)altDisplayString
+{
+    String alt = [self _appletElementImpl]->getAttribute(altAttr);
+    return alt.replace('\\', [self _elementImpl]->getDocument()->backslashAsCurrencySymbol());
+}
+
 - (void)setAlt:(NSString *)alt
 {
     [self _appletElementImpl]->setAttribute(altAttr, alt);
@@ -2812,6 +2864,12 @@ using namespace DOM::HTMLNames;
     return [self _areaElementImpl]->getAttribute(altAttr);
 }
 
+- (NSString *)altDisplayString
+{
+    String alt = [self _areaElementImpl]->getAttribute(altAttr);
+    return alt.replace('\\', [self _elementImpl]->getDocument()->backslashAsCurrencySymbol());
+}
+
 - (void)setAlt:(NSString *)alt
 {
     [self _areaElementImpl]->setAttribute(altAttr, alt);
@@ -2827,6 +2885,11 @@ using namespace DOM::HTMLNames;
     [self _areaElementImpl]->setAttribute(coordsAttr, coords);
 }
 
+- (NSURL *)absoluteLinkURL
+{
+    return [self _getURLAttribute:@"href"];
+}
+
 - (NSString *)href
 {
     return [self _areaElementImpl]->href();
index 27912804f88cdee3e2dbb912cfc92a156616c509..3c0fb298579a4de4ea15aa6ada6fc8aaa31539a0 100644 (file)
@@ -39,7 +39,6 @@
 
 @interface DOMElement (WebPrivate)
 - (NSFont *)_font;
-- (NSImage *)_image;
 - (NSData *)_imageTIFFRepresentation;
 - (NSURL *)_getURLAttribute:(NSString *)name;
 @end
@@ -76,8 +75,8 @@
 - (void)_activateItemAtIndex:(int)index;
 @end
 
-// BEGIN PENDING PUBLIC WEB INSPECTOR APIS
-// These APIs are for the Web Inspector, and they will be made public eventually.
+// BEGIN PENDING PUBLIC APIS
+// These APIs will be made public eventually.
 @interface DOMAttr (DOMAttrExtensions)
 - (DOMCSSStyleDeclaration *)style;
 @end
 @end
 
 @interface DOMElement (DOMElementExtensions)
+- (NSImage *)image;
 - (void)focus;
 - (void)blur;
 - (void)scrollIntoView:(BOOL)alignTop;
 - (void)scrollIntoViewIfNeeded:(BOOL)centerIfNeeded;
 @end
+
+@interface DOMHTMLElement (DOMHTMLElementPendingPublic)
+- (NSString *)titleDisplayString;
+@end
+
+@interface DOMHTMLInputElement (DOMHTMLInputElementPendingPublic)
+- (NSString *)altDisplayString;
+- (NSURL *)absoluteImageURL;
+@end
+
+@interface DOMHTMLImageElement (DOMHTMLImageElementPendingPublic)
+- (NSString *)altDisplayString;
+- (NSURL *)absoluteImageURL;
+@end
+
+@interface DOMHTMLObjectElement (DOMHTMLObjectElementPendingPublic)
+- (NSURL *)absoluteImageURL;
+@end
+
+@interface DOMHTMLAnchorElement (DOMHTMLAnchorElementPendingPublic)
+- (NSURL *)absoluteLinkURL;
+@end
+
+@interface DOMHTMLAreaElement (DOMHTMLAreaElementPendingPublic)
+- (NSURL *)absoluteLinkURL;
+@end
+
+@interface DOMHTMLLinkElement (DOMHTMLLinkElementPendingPublic)
+- (NSURL *)absoluteLinkURL;
+@end
+
 // END
 
 // Pending DOM3 APIs
index dbdeffcec375b7002bef5591c45af1d2ea7b0c47..c8e031491e73d8370ea5e8474a9c2e0237b5083d 100644 (file)
@@ -69,18 +69,6 @@ typedef WebCore::RenderPart WebCoreRenderPart;
 @protocol WebCoreFileButton;
 @protocol WebCoreFileButtonDelegate;
 
-extern NSString *WebCoreElementDOMNodeKey;
-extern NSString *WebCoreElementFrameKey;
-extern NSString *WebCoreElementImageAltStringKey;
-extern NSString *WebCoreElementImageRectKey;
-extern NSString *WebCoreElementImageURLKey;
-extern NSString *WebCoreElementIsSelectedKey;
-extern NSString *WebCoreElementLinkURLKey;
-extern NSString *WebCoreElementLinkTargetFrameKey;
-extern NSString *WebCoreElementLinkLabelKey;
-extern NSString *WebCoreElementLinkTitleKey;
-extern NSString *WebCoreElementTitleKey;
-
 extern NSString *WebCorePageCacheStateKey;
 
 typedef enum {
@@ -302,7 +290,9 @@ typedef enum {
 - (NSObject *)copyRenderTree:(id <WebCoreRenderTreeCopier>)copier;
 - (NSString *)renderTreeAsExternalRepresentation;
 
-- (NSDictionary *)elementAtPoint:(NSPoint)point;
+- (void)getInnerNonSharedNode:(DOMNode **)innerNonSharedNode innerNode:(DOMNode **)innerNode URLElement:(DOMElement **)URLElement atPoint:(NSPoint)point;
+- (BOOL)isPointInsideSelection:(NSPoint)point;
+
 - (NSURL *)URLWithAttributeString:(NSString *)string;
 
 - (DOMElement *)elementWithName:(NSString *)name inForm:(DOMElement *)form;
index 3931331b1643f4bcbd2be1a962731c80e95587ab..ebff35dc807ad2a679814c973ff986bf4a7b3a39 100644 (file)
@@ -123,19 +123,6 @@ using KJS::Bindings::RootObject;
 
 using WebCore::RenderObject;
 
-NSString *WebCoreElementDOMNodeKey =            @"WebElementDOMNode";
-NSString *WebCoreElementFrameKey =              @"WebElementFrame";
-NSString *WebCoreElementImageAltStringKey =     @"WebElementImageAltString";
-NSString *WebCoreElementImageRectKey =          @"WebElementImageRect";
-NSString *WebCoreElementImageURLKey =           @"WebElementImageURL";
-NSString *WebCoreElementIsSelectedKey =         @"WebElementIsSelected";
-NSString *WebCoreElementLinkURLKey =            @"WebElementLinkURL";
-NSString *WebCoreElementLinkTargetFrameKey =    @"WebElementTargetFrame";
-NSString *WebCoreElementLinkLabelKey =          @"WebElementLinkLabel";
-NSString *WebCoreElementLinkTitleKey =          @"WebElementLinkTitle";
-NSString *WebCoreElementNameKey =               @"WebElementName";
-NSString *WebCoreElementTitleKey =              @"WebCoreElementTitle"; // not in WebKit API for now, could be in API some day
-
 NSString *WebCorePageCacheStateKey =            @"WebCorePageCacheState";
 
 @interface WebCoreFrameBridge (WebCoreBridgeInternal)
@@ -1276,107 +1263,25 @@ static HTMLFormElementImpl *formElementFromDOMElement(DOMElement *element)
     return m_frame->matchLabelsAgainstElement(labels, [element _elementImpl]);
 }
 
-- (NSDictionary *)elementAtPoint:(NSPoint)point
+- (void)getInnerNonSharedNode:(DOMNode **)innerNonSharedNode innerNode:(DOMNode **)innerNode URLElement:(DOMElement **)URLElement atPoint:(NSPoint)point
 {
     RenderObject *renderer = m_frame->renderer();
-    if (!renderer) 
-        return nil;
-    
-    RenderObject::NodeInfo nodeInfo = [self nodeInfoAtPoint:point];
-    
-    NSMutableDictionary *element = [NSMutableDictionary dictionary];
-    [element setObject:[NSNumber numberWithBool:m_frame->isPointInsideSelection((int)point.x, (int)point.y)]
-                forKey:WebCoreElementIsSelectedKey];
-
-    // Find the title in the nearest enclosing DOM node.
-    // For <area> tags in image maps, walk the tree for the <area>, not the <img> using it.
-    for (NodeImpl *titleNode = nodeInfo.innerNode(); titleNode; titleNode = titleNode->parentNode()) {
-        if (titleNode->isElementNode()) {
-            const AtomicString& title = static_cast<ElementImpl *>(titleNode)->getAttribute(titleAttr);
-            if (!title.isNull()) {
-                // We found a node with a title.
-                QString titleText = title.qstring();
-                titleText.replace(QChar('\\'), m_frame->backslashAsCurrencySymbol());
-                [element setObject:titleText.getNSString() forKey:WebCoreElementTitleKey];
-                break;
-            }
-        }
-    }
-
-    NodeImpl *URLNode = nodeInfo.URLElement();
-    if (URLNode) {
-        ElementImpl *e = static_cast<ElementImpl *>(URLNode);
-        DocumentImpl *doc = e->getDocument();
-        ASSERT(doc);
-        
-        const AtomicString& title = e->getAttribute(titleAttr);
-        if (!title.isEmpty()) {
-            QString titleText = title.qstring();
-            titleText.replace(QChar('\\'), m_frame->backslashAsCurrencySymbol());
-            [element setObject:titleText.getNSString() forKey:WebCoreElementLinkTitleKey];
-        }
-        
-        const AtomicString& link = e->getAttribute(hrefAttr);
-        if (!link.isNull()) {
-            QString t = plainText(rangeOfContents(e).get());
-            if (!t.isEmpty()) {
-                [element setObject:t.getNSString() forKey:WebCoreElementLinkLabelKey];
-            }
-            QString URLString = parseURL(link).qstring();
-            [element setObject:doc->completeURL(URLString).getNSString() forKey:WebCoreElementLinkURLKey];
-        }
-        
-        DOMString target = e->getAttribute(targetAttr);
-        if (target.isEmpty() && doc) { // FIXME: Take out this doc check when we're not just before a release.
-            target = doc->baseTarget();
-        }
-        if (!target.isEmpty()) {
-            [element setObject:target.qstring().getNSString() forKey:WebCoreElementLinkTargetFrameKey];
-        }
+    if (!renderer) {
+        *innerNonSharedNode = nil;
+        *innerNode = nil;
+        *URLElement = nil;
+        return;
     }
 
-    NodeImpl *node = nodeInfo.innerNonSharedNode();
-    if (node) {
-        [element setObject:[DOMNode _nodeWithImpl:node] forKey:WebCoreElementDOMNodeKey];
-    
-        // Only return image information if there is an image.
-        if (node->renderer() && node->renderer()->isImage()) {
-            RenderImage *r = static_cast<RenderImage *>(node->renderer());
-            int x, y;
-            if (r->absolutePosition(x, y)) {
-                NSValue *rect = [NSValue valueWithRect:NSMakeRect(x, y, r->contentWidth(), r->contentHeight())];
-                [element setObject:rect forKey:WebCoreElementImageRectKey];
-            }
+    RenderObject::NodeInfo nodeInfo = [self nodeInfoAtPoint:point];
+    *innerNonSharedNode = [DOMNode _nodeWithImpl:nodeInfo.innerNonSharedNode()];
+    *innerNode = [DOMNode _nodeWithImpl:nodeInfo.innerNode()];
+    *URLElement = [DOMElement _elementWithImpl:nodeInfo.URLElement()];
+}
 
-            ElementImpl *i = static_cast<ElementImpl*>(node);
-    
-            // FIXME: Code copied from RenderImage::updateFromElement; should share.
-            DOMString attr;
-            if (i->hasTagName(objectTag)) {
-                attr = i->getAttribute(dataAttr);
-            } else {
-                attr = i->getAttribute(srcAttr);
-            }
-            if (!attr.isEmpty()) {
-                QString URLString = parseURL(attr).qstring();
-                [element setObject:i->getDocument()->completeURL(URLString).getNSString() forKey:WebCoreElementImageURLKey];
-            }
-            
-            // FIXME: Code copied from RenderImage::updateFromElement; should share.
-            DOMString alt;
-            if (i->hasTagName(inputTag))
-                alt = static_cast<HTMLInputElementImpl *>(i)->altText();
-            else if (i->hasTagName(imgTag))
-                alt = static_cast<HTMLImageElementImpl *>(i)->altText();
-            if (!alt.isNull()) {
-                QString altText = alt.qstring();
-                altText.replace(QChar('\\'), m_frame->backslashAsCurrencySymbol());
-                [element setObject:altText.getNSString() forKey:WebCoreElementImageAltStringKey];
-            }
-        }
-    }
-    
-    return element;
+- (BOOL)isPointInsideSelection:(NSPoint)point
+{
+    return m_frame->isPointInsideSelection((int)point.x, (int)point.y);
 }
 
 - (NSURL *)URLWithAttributeString:(NSString *)string
index 869e192e247bcf38292203360c5dc6e9ce2e8910..1d20812cef5c05cdbd8b30654991475bf9149281 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "CDATASectionImpl.h"
 #include "CommentImpl.h"
+#include "decoder.h"
 #include "DOMImplementationImpl.h"
 #include "DocLoader.h"
 #include "DocumentFragmentImpl.h"
@@ -1644,8 +1645,7 @@ MouseEventWithHitTestResults DocumentImpl::prepareMouseEvent(bool readonly, bool
     String href;
     String target;
     if (renderInfo.URLElement()) {
-        assert(renderInfo.URLElement()->isElementNode());
-        ElementImpl* e = static_cast<ElementImpl*>(renderInfo.URLElement());
+        ElementImpl* e = renderInfo.URLElement();
         href = parseURL(e->getAttribute(hrefAttr));
         if (!href.isNull())
             target = e->getAttribute(targetAttr);
@@ -2492,6 +2492,13 @@ void DocumentImpl::setDecoder(Decoder *decoder)
     m_decoder = decoder;
 }
 
+QChar DocumentImpl::backslashAsCurrencySymbol() const
+{
+    if (!m_decoder)
+        return '\\';
+    return m_decoder->encoding().backslashAsCurrencySymbol();
+}
+
 QString DocumentImpl::completeURL(const QString &URL)
 {
     if (!m_decoder)
index d404d4cc8f0b0193fb6ef1781efb7714dc580a77..d2cc8ac95e6e0a0f4ab18b730d28225680506fba 100644 (file)
@@ -676,6 +676,8 @@ public:
     void setDecoder(Decoder*);
     Decoder* decoder() const { return m_decoder.get(); }
 
+    QChar backslashAsCurrencySymbol() const;
+
 #if __APPLE__
     void setDashboardRegionsDirty(bool f) { m_dashboardRegionsDirty = f; }
     bool dashboardRegionsDirty() const { return m_dashboardRegionsDirty; }
index da228564be0fde15bd49a2f19889e36c7a4c3019..0f76bee169661528045dbbe6182f3b723aaa51bf 100644 (file)
@@ -1120,7 +1120,7 @@ RenderLayer::hitTest(RenderObject::NodeInfo& info, int x, int y)
     NodeImpl* node = info.innerNode();
     while (node) {
         if (node->isLink() && !info.URLElement())
-            info.setURLElement(node);
+            info.setURLElement(static_cast<ElementImpl*>(node));
         node = node->parentNode();
     }
 
index dc3b3523a1b25006992b2c6cad986299845ec56e..0865bbbb1298be53d603432534b741da2f8317b6 100644 (file)
@@ -488,19 +488,19 @@ public:
 
         NodeImpl* innerNode() const { return m_innerNode; }
         NodeImpl* innerNonSharedNode() const { return m_innerNonSharedNode; }
-        NodeImpl* URLElement() const { return m_innerURLElement; }
+        ElementImpl* URLElement() const { return m_innerURLElement; }
         bool readonly() const { return m_readonly; }
         bool active() const { return m_active; }
         bool mouseMove() const { return m_mouseMove; }
         
         void setInnerNode(NodeImpl* n) { m_innerNode = n; }
         void setInnerNonSharedNode(NodeImpl* n) { m_innerNonSharedNode = n; }
-        void setURLElement(NodeImpl* n) { m_innerURLElement = n; }
+        void setURLElement(ElementImpl* n) { m_innerURLElement = n; }
 
     private:
         NodeImpl* m_innerNode;
         NodeImpl* m_innerNonSharedNode;
-        NodeImpl* m_innerURLElement;
+        ElementImpl* m_innerURLElement;
         bool m_readonly;
         bool m_active;
         bool m_mouseMove;
index ca42ff02b6021eb834af563d979fe653970e9772..3b17413c1097688c14705088a5448b6e201c5934 100644 (file)
@@ -1,3 +1,40 @@
+2006-03-01  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=7450
+        elementAtPoint is expensive and should return a smart dictionary
+        
+        elementAtPoint for WebHTMLView now returns a WebElementDictionary,
+        when objectForKey is called it will lookup in the DOM, cache and return the value
+
+        * Misc/WebElementDictionary.h: Added.
+        * Misc/WebElementDictionary.m: Added.
+        (addLookupKey):
+        (cacheValueForKey):
+        (+[WebElementDictionary initializeLookupTable]):
+        (-[WebElementDictionary initWithInnerNonSharedNode:innerNode:URLElement:andPoint:]):
+        (-[WebElementDictionary dealloc]):
+        (-[WebElementDictionary _fillCache]):
+        (-[WebElementDictionary count]):
+        (-[WebElementDictionary keyEnumerator]):
+        (-[WebElementDictionary objectForKey:]):
+        (-[WebElementDictionary _domNode]):
+        (-[WebElementDictionary _webFrame]):
+        (-[WebElementDictionary _targetWebFrame]):
+        (-[WebElementDictionary _title]):
+        (-[WebElementDictionary _imageRect]):
+        (-[WebElementDictionary _isSelected]):
+        * Misc/WebNSViewExtras.m:
+        (-[NSView _web_dragImage:element:rect:event:pasteboard:source:offset:]):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebView/WebHTMLView.m:
+        (-[WebHTMLView _updateMouseoverWithEvent:]):
+        (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
+        (-[NSArray elementAtPoint:]):
+        * WebView/WebView.m:
+        * WebView/WebViewPrivate.h:
+
 2006-02-28  Darin Adler  <darin@apple.com>
 
         Reviewed by Adele.
diff --git a/WebKit/Misc/WebElementDictionary.h b/WebKit/Misc/WebElementDictionary.h
new file mode 100644 (file)
index 0000000..54ef0df
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#import <Foundation/NSDictionary.h>
+
+@class DOMNode;
+@class DOMElement;
+
+@interface WebElementDictionary : NSDictionary {
+    DOMNode *_innerNode;
+    DOMNode *_innerNonSharedNode;
+    DOMElement *_URLElement;
+    NSMutableDictionary *_cache;
+    NSMutableSet *_nilValues;
+    NSPoint _point;
+    BOOL _cacheComplete;
+}
+- (id)initWithInnerNonSharedNode:(DOMNode *)innerNonSharedNode innerNode:(DOMNode *)innerNode URLElement:(DOMElement *)URLElement andPoint:(NSPoint)point;
+@end
diff --git a/WebKit/Misc/WebElementDictionary.m b/WebKit/Misc/WebElementDictionary.m
new file mode 100644 (file)
index 0000000..6692088
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * 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.
+ */
+
+#import "WebElementDictionary.h"
+
+#import "WebDOMOperations.h"
+#import "WebFrame.h"
+#import "WebFrameBridge.h"
+#import "WebView.h"
+#import "WebViewPrivate.h"
+
+#import <WebKit/DOMCore.h>
+#import <WebKit/DOMPrivate.h>
+
+typedef enum {
+    WebElementSelf,
+    WebElementInnerNode,
+    WebElementInnerNonSharedNode,
+    WebElementURLElement
+} WebElementTargetObject;
+
+typedef struct WebElementMethod {
+    WebElementTargetObject target;
+    SEL selector;
+} WebElementMethod;
+
+static CFMutableDictionaryRef lookupTable = NULL;
+
+static void addLookupKey(NSString *key, SEL selector, WebElementTargetObject target)
+{
+    WebElementMethod *elementMethod = malloc(sizeof(WebElementMethod));
+    elementMethod->target = target;
+    elementMethod->selector = selector;
+    CFDictionaryAddValue(lookupTable, key, elementMethod);
+}
+
+static void cacheValueForKey(const void *key, const void *value, void *self)
+{
+    // calling objectForKey will cache the value in our _cache dictionary
+    [(WebElementDictionary *)self objectForKey:(NSString *)key];
+}
+
+@implementation WebElementDictionary
++ (void)initializeLookupTable
+{
+    if (lookupTable)
+        return;
+
+    lookupTable = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFCopyStringDictionaryKeyCallBacks, NULL);
+
+    addLookupKey(WebElementDOMNodeKey, @selector(_domNode), WebElementSelf);
+    addLookupKey(WebElementFrameKey, @selector(_webFrame), WebElementSelf);
+    addLookupKey(WebElementImageAltStringKey, @selector(altDisplayString), WebElementInnerNonSharedNode);
+    addLookupKey(WebElementImageKey, @selector(image), WebElementInnerNonSharedNode);
+    addLookupKey(WebElementImageRectKey, @selector(_imageRect), WebElementSelf);
+    addLookupKey(WebElementImageURLKey, @selector(absoluteImageURL), WebElementInnerNonSharedNode);
+    addLookupKey(WebElementIsSelectedKey, @selector(_isSelected), WebElementSelf);
+    addLookupKey(WebElementTitleKey, @selector(_title), WebElementSelf);
+    addLookupKey(WebElementLinkURLKey, @selector(absoluteLinkURL), WebElementURLElement);
+    addLookupKey(WebElementLinkTargetFrameKey, @selector(_targetWebFrame), WebElementSelf);
+    addLookupKey(WebElementLinkTitleKey, @selector(titleDisplayString), WebElementURLElement);
+    addLookupKey(WebElementLinkLabelKey, @selector(textContent), WebElementURLElement);
+}
+
+- (id)initWithInnerNonSharedNode:(DOMNode *)innerNonSharedNode innerNode:(DOMNode *)innerNode URLElement:(DOMElement *)URLElement andPoint:(NSPoint)point
+{
+    [[self class] initializeLookupTable];
+    [super init];
+    _point = point;
+    _innerNode = [innerNode retain];
+    _innerNonSharedNode = [innerNonSharedNode retain];
+    _URLElement = [URLElement retain];
+    return self;
+}
+
+- (void)dealloc
+{
+    [_innerNode release];
+    [_innerNonSharedNode release];
+    [_URLElement release];
+    [_cache release];
+    [_nilValues release];
+    [super dealloc];
+}
+
+- (void)_fillCache
+{
+    CFDictionaryApplyFunction(lookupTable, cacheValueForKey, self);
+    _cacheComplete = YES;
+}
+
+- (unsigned)count
+{
+    if (!_cacheComplete)
+        [self _fillCache];
+    return [_cache count];
+}
+
+- (NSEnumerator *)keyEnumerator
+{
+    if (!_cacheComplete)
+        [self _fillCache];
+    return [_cache keyEnumerator];
+}
+
+- (id)objectForKey:(id)key
+{
+    id value = [_cache objectForKey:key];
+    if (value || _cacheComplete || [_nilValues containsObject:key])
+        return value;
+
+    WebElementMethod *elementMethod = (WebElementMethod *)CFDictionaryGetValue(lookupTable, key);
+    if (!elementMethod)
+        return nil;
+
+    id target = nil;
+    switch (elementMethod->target) {
+        case WebElementSelf:
+            target = self;
+            break;
+        case WebElementInnerNonSharedNode:
+            target = _innerNonSharedNode;
+            break;
+        case WebElementInnerNode:
+            target = _innerNode;
+            break;
+        case WebElementURLElement:
+            target = _URLElement;
+            break;
+    }
+
+    if (target && [target respondsToSelector:elementMethod->selector])
+        value = [target performSelector:elementMethod->selector];
+
+    unsigned lookupTableCount = CFDictionaryGetCount(lookupTable);
+
+    if (value) {
+        if (!_cache)
+            _cache = [[NSMutableDictionary alloc] initWithCapacity:lookupTableCount];
+        [_cache setObject:value forKey:key];
+    } else {
+        if (!_nilValues)
+            _nilValues = [[NSMutableSet alloc] initWithCapacity:lookupTableCount];
+        [_nilValues addObject:key];
+    }
+
+    _cacheComplete = ([_cache count] + [_nilValues count]) == lookupTableCount;
+
+    return value;
+}
+
+- (DOMNode *)_domNode
+{
+    return [[_innerNonSharedNode retain] autorelease];
+}
+
+- (WebFrame *)_webFrame
+{
+    return [[_innerNonSharedNode ownerDocument] webFrame];
+}
+
+- (WebFrame *)_targetWebFrame
+{
+    if (!_URLElement || ![_URLElement respondsToSelector:@selector(target)])
+        return nil;
+    WebFrame *webFrame = [[_innerNonSharedNode ownerDocument] webFrame];
+    NSString *targetName = [_URLElement performSelector:@selector(target)];
+    if ([targetName length])
+        return [webFrame findFrameNamed:targetName];
+    return webFrame;
+}
+
+- (NSString *)_title
+{
+    // Find the title in the nearest enclosing DOM node.
+    // For <area> tags in image maps, walk the tree for the <area>, not the <img> using it.
+    for (DOMNode *titleNode = _innerNode; titleNode; titleNode = [titleNode parentNode]) {
+        if ([titleNode isKindOfClass:[DOMHTMLElement class]]) {
+            NSString *title = [(DOMHTMLElement *)titleNode titleDisplayString];
+            if ([title length])
+                return title;
+        }
+    }
+    return nil;
+}
+
+- (NSValue *)_imageRect
+{
+    if ([self objectForKey:WebElementImageURLKey])
+        return [NSValue valueWithRect:[_innerNonSharedNode boundingBox]];
+    return nil;
+}
+
+- (NSNumber *)_isSelected
+{
+    return [NSNumber numberWithBool:[[[[_innerNonSharedNode ownerDocument] webFrame] _bridge] isPointInsideSelection:_point]];
+}
+@end
index ec946371bd067a3e22bb9a8b7c0215347e7bf5e7..b6575d844e8e108c0880b000875840794d85ba1b 100644 (file)
     NSImage *dragImage;
     NSPoint origin;
 
-    NSImage *image = (wir != nil) ? [wir image] : [element _image];
+    NSImage *image = (wir != nil) ? [wir image] : [element image];
     if (image != nil && [image size].height * [image size].width <= WebMaxOriginalImageArea) {
         NSSize originalSize = rect.size;
         origin = rect.origin;
index 0cf9508dbf2d0a8e05629b94fd9bdd55c4c98591..37d13e5d96fffe3551276429051fed25dca3c996 100644 (file)
                9398112E0824BF01008DF038 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 93D623DD051E791F002F47DD /* libicucore.dylib */; };
                9398112F0824BF01008DF038 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 830E81E005853AC000AD0891 /* Security.framework */; };
                ABDDF20D08EB0DDC001E1241 /* WebDownloadInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDF20C08EB0DDC001E1241 /* WebDownloadInternal.h */; };
+               DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = DD89681E09AA87240097E7F0 /* WebElementDictionary.h */; };
+               DD89682109AA87240097E7F0 /* WebElementDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = DD89681F09AA87240097E7F0 /* WebElementDictionary.m */; };
                ED6BE2E7088C32B50044DEDC /* WebNSAttributedStringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = ED6BE2E5088C32B50044DEDC /* WebNSAttributedStringExtras.h */; };
                ED6BE2E8088C32B50044DEDC /* WebNSAttributedStringExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6BE2E6088C32B50044DEDC /* WebNSAttributedStringExtras.m */; };
                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = ED7F6D8A0980683500C235ED /* WebNSDataExtrasPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BEE18F9A0472B73200CA289C /* WebLocalizableStrings.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebLocalizableStrings.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BEE52D4A0473032500CA289C /* WebKitSystemBits.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebKitSystemBits.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BEE52D4B0473032500CA289C /* WebKitSystemBits.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebKitSystemBits.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               DD89681E09AA87240097E7F0 /* WebElementDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebElementDictionary.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               DD89681F09AA87240097E7F0 /* WebElementDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebElementDictionary.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                ED21B9810528F7AA003299AC /* WebDocumentInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDocumentInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                ED2B2474033A2DA800C1A526 /* WebNSPasteboardExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNSPasteboardExtras.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                ED2B2475033A2DA800C1A526 /* WebNSPasteboardExtras.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNSPasteboardExtras.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                F59668C902AD2923018635CA /* WebStringTruncator.m */,
                                6578F5DE045F817400000128 /* WebDownload.h */,
                                6578F5DF045F817400000128 /* WebDownload.m */,
+                               DD89681E09AA87240097E7F0 /* WebElementDictionary.h */,
+                               DD89681F09AA87240097E7F0 /* WebElementDictionary.m */,
                        );
                        path = Misc;
                        sourceTree = "<group>";
                                ED7F6D8B0980683500C235ED /* WebNSDataExtrasPrivate.h in Headers */,
                                651951E209974178003DFC65 /* WebLoader.h in Headers */,
                                6550B7C7099EFAE90090D781 /* WebArchiver.h in Headers */,
+                               DD89682009AA87240097E7F0 /* WebElementDictionary.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1C68F672095B5FC100C2984E /* WebNodeHighlightView.m in Sources */,
                                65C7F42D0979DE640022E453 /* WebPageBridge.m in Sources */,
                                6550B7C8099EFAE90090D781 /* WebArchiver.m in Sources */,
+                               DD89682109AA87240097E7F0 /* WebElementDictionary.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 134e8ffa54b994cc167d021ca1961271233410bc..97a709615f89bf35e003465ec903db21399ac065 100644 (file)
@@ -43,6 +43,7 @@
 #import <WebKit/WebDocumentInternal.h>
 #import <WebKit/WebDOMOperationsPrivate.h>
 #import <WebKit/WebEditingDelegate.h>
+#import <WebKit/WebElementDictionary.h>
 #import <WebKit/WebFramePrivate.h>
 #import <WebKit/WebFrameInternal.h>
 #import <WebKit/WebFrameViewInternal.h>
@@ -1051,10 +1052,10 @@ static WebHTMLView *lastHitView = nil;
                     newToolTip = [[(DOMHTMLInputElement *) domElement form] action];
             }
             if (newToolTip == nil)
-                newToolTip = [[element objectForKey:WebCoreElementLinkURLKey] _web_userVisibleString];
+                newToolTip = [[element objectForKey:WebElementLinkURLKey] _web_userVisibleString];
         }
         if (newToolTip == nil)
-            newToolTip = [element objectForKey:WebCoreElementTitleKey];
+            newToolTip = [element objectForKey:WebElementTitleKey];
         [view _setToolTip:newToolTip];
 
         [view release];
@@ -1194,7 +1195,7 @@ static WebHTMLView *lastHitView = nil;
 
     // note per kwebster, the offset arg below is always ignored in positioning the image
     DOMHTMLElement *imageElement = [element objectForKey:WebElementDOMNodeKey];
-    if (imageURL != nil && [imageElement _image] != nil && (_private->dragSourceActionMask & WebDragSourceActionImage)) {
+    if (imageURL != nil && [imageElement image] != nil && (_private->dragSourceActionMask & WebDragSourceActionImage)) {
         id source = self;
         if (!dhtmlWroteData) {
             // Select the image when it is dragged. This allows the image to be moved via MoveSelectionCommandImpl and this matches NSTextView's behavior.
@@ -2865,35 +2866,11 @@ done:
 
 - (NSDictionary *)elementAtPoint:(NSPoint)point
 {
-    NSDictionary *elementInfoWC = [[self _bridge] elementAtPoint:point];
-    NSMutableDictionary *elementInfo = [elementInfoWC mutableCopy];
-    
-    // Convert URL strings to NSURLs.
-    [elementInfo _web_setObjectIfNotNil:[NSURL _web_URLWithDataAsString:[elementInfoWC objectForKey:WebElementLinkURLKey]] forKey:WebElementLinkURLKey];
-    [elementInfo _web_setObjectIfNotNil:[NSURL _web_URLWithDataAsString:[elementInfoWC objectForKey:WebElementImageURLKey]] forKey:WebElementImageURLKey];
-    if ([elementInfoWC objectForKey:WebElementImageURLKey])
-        [elementInfo _web_setObjectIfNotNil:[[elementInfoWC objectForKey:WebElementDOMNodeKey] _image] forKey:WebElementImageKey];
-
-    WebFrameView *webFrameView = [self _web_parentWebFrameView];
-    ASSERT(webFrameView);
-    WebFrame *webFrame = [webFrameView webFrame];
-    
-    if (webFrame) {
-        NSString *frameName = [elementInfoWC objectForKey:WebElementLinkTargetFrameKey];
-        if ([frameName length] == 0) {
-            [elementInfo setObject:webFrame forKey:WebElementLinkTargetFrameKey];
-        } else {
-            WebFrame *wf = [webFrame findFrameNamed:frameName];
-            if (wf != nil)
-                [elementInfo setObject:wf forKey:WebElementLinkTargetFrameKey];
-            else
-                [elementInfo removeObjectForKey:WebElementLinkTargetFrameKey];
-        }
-        
-        [elementInfo setObject:webFrame forKey:WebElementFrameKey];
-    }
-    
-    return [elementInfo autorelease];
+    DOMNode *innerNode = nil;
+    DOMNode *innerNonSharedNode = nil;
+    DOMElement *URLElement = nil;
+    [[self _bridge] getInnerNonSharedNode:&innerNonSharedNode innerNode:&innerNode URLElement:&URLElement atPoint:point];
+    return [[[WebElementDictionary alloc] initWithInnerNonSharedNode:innerNonSharedNode innerNode:innerNode URLElement:URLElement andPoint:point] autorelease];
 }
 
 - (void)mouseUp:(NSEvent *)event
index 8b40c7e38cebc3e199ac23489fa97a906b2a2d7a..90453e839d92d98e9fd0e8184ce2e22cb4746843 100644 (file)
@@ -309,6 +309,7 @@ NSString *WebElementImageAltStringKey =     @"WebElementImageAltString";
 NSString *WebElementImageRectKey =          @"WebElementImageRect";
 NSString *WebElementImageURLKey =           @"WebElementImageURL";
 NSString *WebElementIsSelectedKey =         @"WebElementIsSelected";
+NSString *WebElementTitleKey =              @"WebElementTitle";
 NSString *WebElementLinkURLKey =            @"WebElementLinkURL";
 NSString *WebElementLinkTargetFrameKey =    @"WebElementTargetFrame";
 NSString *WebElementLinkLabelKey =          @"WebElementLinkLabel";
index d9d901a44a0678699d43cb24fe1adf757a4e4518..a4684e07b0883d75d60600b076be3d0d57639eab 100644 (file)
@@ -65,6 +65,8 @@ extern NSString *_WebMainFrameIconKey;
 extern NSString *_WebMainFrameTitleKey;
 extern NSString *_WebMainFrameURLKey;
 
+extern NSString *WebElementTitleKey;   // NSString of the title of the element (pending public, used by Safari)
+
 typedef enum {
     WebDashboardBehaviorAlwaysSendMouseEventsToAllWindows,
     WebDashboardBehaviorAlwaysSendActiveNullEventsToPlugIns,