WebCore:
authorbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2006 22:58:31 +0000 (22:58 +0000)
committerbdakin <bdakin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Nov 2006 22:58:31 +0000 (22:58 +0000)
        Reviewed by Adam.

        Add ability to HitTestResult to ask if the inner non-shared node is
        content editable.

        * WebCore.exp: Export HitTestResult::isContentEditable()
        * rendering/HitTestResult.cpp:
        (WebCore::HitTestResult::isContentEditable):
        * rendering/HitTestResult.h:

WebKit:
        Reviewed by Adam.

        Add WebElementIsContentEditableKey to the WebElementDictionary, and
        use it!

        * DefaultDelegates/WebDefaultContextMenuDelegate.m:
        (-[WebDefaultUIDelegate
        webView:contextMenuItemsForElement:defaultMenuItems:]): Use new
        WebElementIsContentEditableKey.
        * Misc/WebElementDictionary.m:
        (+[WebElementDictionary initializeLookupTable]):
        (-[WebElementDictionary _isContentEditable]): Call into
        HitTestResult::isContentEditable()
        * WebView/WebView.mm: Add new key.
        * WebView/WebViewPrivate.h: Add new key.

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

WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/rendering/HitTestResult.cpp
WebCore/rendering/HitTestResult.h
WebKit/ChangeLog
WebKit/DefaultDelegates/WebDefaultContextMenuDelegate.m
WebKit/Misc/WebElementDictionary.m
WebKit/WebView/WebView.mm
WebKit/WebView/WebViewPrivate.h

index ef5b9cb41032aedd788ea73376853ab681842141..26a546e1679ade31d6be344dd65f233952e3b175 100644 (file)
@@ -1,3 +1,15 @@
+2006-11-08  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Adam.
+
+        Add ability to HitTestResult to ask if the inner non-shared node is 
+        content editable.
+
+        * WebCore.exp: Export HitTestResult::isContentEditable()
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::isContentEditable):
+        * rendering/HitTestResult.h:
+
 2006-11-08  Anders Carlsson  <acarlsson@apple.com>
 
         Build fix.
index b45c7d90c4335ef629fad6f15441793b82928061..878e3151b7413b42bccdfb556889e6f20f651576 100644 (file)
@@ -318,6 +318,7 @@ __ZNK7WebCore13HitTestResult15absoluteLinkURLEv
 __ZNK7WebCore13HitTestResult15spellingToolTipEv
 __ZNK7WebCore13HitTestResult16absoluteImageURLEv
 __ZNK7WebCore13HitTestResult16altDisplayStringEv
+__ZNK7WebCore13HitTestResult17isContentEditableEv
 __ZNK7WebCore13HitTestResult18titleDisplayStringEv
 __ZNK7WebCore13HitTestResult5imageEv
 __ZNK7WebCore13HitTestResult5titleEv
index 9f227aeedd35a41201a65c6c7fba2a06889e15e3..2be8b909480bf31d6219231396333717dc67f948 100644 (file)
@@ -259,4 +259,18 @@ String HitTestResult::textContent() const
     return m_innerURLElement->textContent();
 }
 
+bool HitTestResult::isContentEditable() const
+{
+    if (!m_innerNonSharedNode)
+        return false;
+
+    if (m_innerNonSharedNode->hasTagName(textareaTag) || m_innerNonSharedNode->hasTagName(isindexTag))
+        return true;
+
+    if (m_innerNonSharedNode->hasTagName(inputTag))
+        return static_cast<HTMLInputElement*>(m_innerNonSharedNode.get())->isTextField();
+
+    return m_innerNonSharedNode->isContentEditable();
+}
+
 } // namespace WebCore
index 270287d76fd52d19bf54433d593659e1ad61f25a..2156219cc096600fdb4429e75a3233a88a6f2916 100644 (file)
@@ -67,6 +67,7 @@ public:
     String titleDisplayString() const;
     String textContent() const;
     bool isLiveLink() const;
+    bool isContentEditable() const;
 
 private:
     RefPtr<Node> m_innerNode;
index b3242ae2ffa0e5714e6bf940ac9a3cb90921215c..721f8d8c251e6f81b7fb477261af65a6b939608a 100644 (file)
@@ -1,3 +1,21 @@
+2006-11-08  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Adam.
+
+        Add WebElementIsContentEditableKey to the WebElementDictionary, and 
+        use it!
+
+        * DefaultDelegates/WebDefaultContextMenuDelegate.m:
+        (-[WebDefaultUIDelegate 
+        webView:contextMenuItemsForElement:defaultMenuItems:]): Use new 
+        WebElementIsContentEditableKey.
+        * Misc/WebElementDictionary.m:
+        (+[WebElementDictionary initializeLookupTable]):
+        (-[WebElementDictionary _isContentEditable]): Call into 
+        HitTestResult::isContentEditable()
+        * WebView/WebView.mm: Add new key.
+        * WebView/WebViewPrivate.h: Add new key.
+
 2006-11-08  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Oliver.
index bc3c353eacde2cb291990f12adecb524cd0ca9fd..30722cbafeabc48059c14d8948820a55b0243cee 100644 (file)
@@ -360,15 +360,7 @@ static NSString *localizedMenuTitleFromAppKit(NSString *key, NSString *comment)
 
 - (NSArray *)webView:(WebView *)wv contextMenuItemsForElement:(NSDictionary *)element  defaultMenuItems:(NSArray *)defaultMenuItems
 {
-    BOOL contentEditible = NO;
-    id domElement = [element objectForKey:WebElementDOMNodeKey];
-    if ([wv isEditable] || [domElement isKindOfClass:[DOMHTMLTextAreaElement class]] || [domElement isKindOfClass:[DOMHTMLIsIndexElement class]])
-        contentEditible = YES;
-    else if ([domElement isKindOfClass:[DOMHTMLInputElement class]])
-        contentEditible = [(DOMHTMLInputElement *)domElement _isTextField];
-    else if ([domElement isKindOfClass:[DOMNode class]])
-        contentEditible = [(DOMNode *)domElement isContentEditable];
-
+    BOOL contentEditible = [wv isEditable] || [[element objectForKey:WebElementIsContentEditableKey] boolValue];
     NSView *documentView = [[[element objectForKey:WebElementFrameKey] frameView] documentView];
     if ([documentView isKindOfClass:[WebHTMLView class]] && contentEditible) {
         return [self editingContextMenuItemsForElement:element defaultMenuItems:defaultMenuItems];
index f8089837613b86a502a471a492950088e5a2c10a..c29eec4b37d00c24f659cd4d0f064618155392ae 100644 (file)
@@ -80,6 +80,7 @@ static void cacheValueForKey(const void *key, const void *value, void *self)
     addLookupKey(WebElementLinkTitleKey, @selector(_titleDisplayString));
     addLookupKey(WebElementLinkLabelKey, @selector(_textContent));
     addLookupKey(WebElementLinkIsLiveKey, @selector(_isLiveLink));
+    addLookupKey(WebElementIsContentEditableKey, @selector(_isContentEditable));
 }
 
 - (id)initWithHitTestResult:(const HitTestResult&)result
@@ -224,4 +225,9 @@ static void cacheValueForKey(const void *key, const void *value, void *self)
     return [NSNumber numberWithBool:_result->isLiveLink()];
 }
 
+- (NSNumber *)_isContentEditable
+{
+    return [NSNumber numberWithBool:_result->isContentEditable()];
+}
+
 @end
index 5d85c10fa2de00810809c16fbf361d66b611d5d5..e9def163c844cb15d5e0a3033817f843055bbd06 100644 (file)
@@ -345,6 +345,7 @@ NSString *WebElementLinkURLKey =            @"WebElementLinkURL";
 NSString *WebElementSpellingToolTipKey =    @"WebElementSpellingToolTip";
 NSString *WebElementTitleKey =              @"WebElementTitle";
 NSString *WebElementLinkIsLiveKey =         @"WebElementLinkIsLive";
+NSString *WebElementIsContentEditableKey =  @"WebElementIsContentEditableKey";
 
 NSString *WebViewProgressStartedNotification =          @"WebProgressStartedNotification";
 NSString *WebViewProgressEstimateChangedNotification =  @"WebProgressEstimateChangedNotification";
index 7a0e202a84c27c7bc36f7b46fcb7daf569c92736..2f0afc790fba4d39b4ae0cfcc318125459cc7283 100644 (file)
@@ -83,6 +83,7 @@ extern NSString *_WebMainFrameDocumentKey;
 // pending public WebElementDictionary keys
 extern NSString *WebElementTitleKey;             // NSString of the title of the element (used by Safari)
 extern NSString *WebElementSpellingToolTipKey;   // NSString of a tooltip representing misspelling or bad grammar (used internally)
+extern NSString *WebElementIsContentEditableKey; // NSNumber indicating whether the inner non-shared node is content editable (used internally)
 
 // other WebElementDictionary keys
 extern NSString *WebElementLinkIsLiveKey;        // NSNumber of BOOL indictating whether the link is live or not