Title: [176412] trunk/Source
Revision
176412
Author
[email protected]
Date
2014-11-20 14:03:39 -0800 (Thu, 20 Nov 2014)

Log Message

Invalid message WebPageProxy.DidPerformDictionaryLookup on Google stocks result
https://bugs.webkit.org/show_bug.cgi?id=138568
-and corresponding-
rdar://problem/18904600

Reviewed by Tim Horton.

Source/WebCore:

Add an optional parameter indicating whether or not to include images.
* WebCore.exp.in:
* editing/cocoa/HTMLConverter.h:
* editing/cocoa/HTMLConverter.mm:
(WebCore::editingAttributedStringFromRange):

Source/WebKit/mac:

Skip images for lookup.
* WebView/WebActionMenuController.mm:
(performDictionaryLookupForRange):

Source/WebKit2:

Skip images for lookup.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performDictionaryLookupForRange):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (176411 => 176412)


--- trunk/Source/WebCore/ChangeLog	2014-11-20 21:50:06 UTC (rev 176411)
+++ trunk/Source/WebCore/ChangeLog	2014-11-20 22:03:39 UTC (rev 176412)
@@ -1,3 +1,18 @@
+2014-11-20  Beth Dakin  <[email protected]>
+
+        Invalid message WebPageProxy.DidPerformDictionaryLookup on Google stocks result
+        https://bugs.webkit.org/show_bug.cgi?id=138568
+        -and corresponding-
+        rdar://problem/18904600
+
+        Reviewed by Tim Horton.
+
+        Add an optional parameter indicating whether or not to include images.
+        * WebCore.exp.in:
+        * editing/cocoa/HTMLConverter.h:
+        * editing/cocoa/HTMLConverter.mm:
+        (WebCore::editingAttributedStringFromRange):
+
 2014-11-20  Myles C. Maxfield  <[email protected]>
 
         Fix the !ENABLE(SVG_FONTS) build after r176276

Modified: trunk/Source/WebCore/WebCore.exp.in (176411 => 176412)


--- trunk/Source/WebCore/WebCore.exp.in	2014-11-20 21:50:06 UTC (rev 176411)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-11-20 22:03:39 UTC (rev 176412)
@@ -2366,7 +2366,7 @@
 __ZN7WebCore32applicationIsAOLInstantMessengerEv
 __ZN7WebCore32contextMenuItemTagInspectElementEv
 __ZN7WebCore32contextMenuItemTagSmartCopyPasteEv
-__ZN7WebCore32editingAttributedStringFromRangeERNS_5RangeE
+__ZN7WebCore32editingAttributedStringFromRangeERNS_5RangeENS_31IncludeImagesInAttributedStringE
 __ZN7WebCore32useBlockedPlugInContextMenuTitleEv
 __ZN7WebCore33contextMenuItemTagTextReplacementEv
 __ZN7WebCore33postScriptDocumentTypeDescriptionEv

Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.h (176411 => 176412)


--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.h	2014-11-20 21:50:06 UTC (rev 176411)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.h	2014-11-20 22:03:39 UTC (rev 176412)
@@ -31,10 +31,12 @@
 namespace WebCore {
     
 class Range;
+
+enum class IncludeImagesInAttributedString { Yes, No };
     
 WEBCORE_EXPORT NSAttributedString *attributedStringFromRange(Range&);
 #if !PLATFORM(IOS)
-WEBCORE_EXPORT NSAttributedString *editingAttributedStringFromRange(Range&);
+WEBCORE_EXPORT NSAttributedString *editingAttributedStringFromRange(Range&, IncludeImagesInAttributedString = IncludeImagesInAttributedString::Yes);
 #endif
 
 }

Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (176411 => 176412)


--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2014-11-20 21:50:06 UTC (rev 176411)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2014-11-20 22:03:39 UTC (rev 176412)
@@ -2555,7 +2555,7 @@
     
 #if !PLATFORM(IOS)
 // This function uses TextIterator, which makes offsets in its result compatible with HTML editing.
-NSAttributedString *editingAttributedStringFromRange(Range& range)
+NSAttributedString *editingAttributedStringFromRange(Range& range, IncludeImagesInAttributedString includeOrSkipImages)
 {
     NSFontManager *fontManager = [NSFontManager sharedFontManager];
     NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
@@ -2568,14 +2568,16 @@
         Node* endContainer = currentTextRange->endContainer();
         int startOffset = currentTextRange->startOffset();
         int endOffset = currentTextRange->endOffset();
-        
-        if (startContainer == endContainer && (startOffset == endOffset - 1)) {
-            Node* node = startContainer->traverseToChildAt(startOffset);
-            if (is<HTMLImageElement>(node)) {
-                NSFileWrapper* fileWrapper = fileWrapperForElement(downcast<HTMLImageElement>(node));
-                NSTextAttachment* attachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
-                [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
-                [attachment release];
+
+        if (includeOrSkipImages == IncludeImagesInAttributedString::Yes) {
+            if (startContainer == endContainer && (startOffset == endOffset - 1)) {
+                Node* node = startContainer->traverseToChildAt(startOffset);
+                if (is<HTMLImageElement>(node)) {
+                    NSFileWrapper* fileWrapper = fileWrapperForElement(downcast<HTMLImageElement>(node));
+                    NSTextAttachment* attachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
+                    [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];
+                    [attachment release];
+                }
             }
         }
 

Modified: trunk/Source/WebKit/mac/ChangeLog (176411 => 176412)


--- trunk/Source/WebKit/mac/ChangeLog	2014-11-20 21:50:06 UTC (rev 176411)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-11-20 22:03:39 UTC (rev 176412)
@@ -1,3 +1,16 @@
+2014-11-20  Beth Dakin  <[email protected]>
+
+        Invalid message WebPageProxy.DidPerformDictionaryLookup on Google stocks result
+        https://bugs.webkit.org/show_bug.cgi?id=138568
+        -and corresponding-
+        rdar://problem/18904600
+
+        Reviewed by Tim Horton.
+
+        Skip images for lookup.
+        * WebView/WebActionMenuController.mm:
+        (performDictionaryLookupForRange):
+
 2014-11-19  Beth Dakin  <[email protected]>
 
         Invoking an action menu on a selection should result in the text menu

Modified: trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm (176411 => 176412)


--- trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-11-20 21:50:06 UTC (rev 176411)
+++ trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-11-20 22:03:39 UTC (rev 176412)
@@ -664,7 +664,7 @@
     popupInfo.origin = NSMakePoint(rangeRect.x(), rangeRect.y() + (style.fontMetrics().descent() * frame->page()->pageScaleFactor()));
     popupInfo.options = options;
 
-    NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range);
+    NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
     RetainPtr<NSMutableAttributedString> scaledNSAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[nsAttributedString string]]);
     NSFontManager *fontManager = [NSFontManager sharedFontManager];
 

Modified: trunk/Source/WebKit2/ChangeLog (176411 => 176412)


--- trunk/Source/WebKit2/ChangeLog	2014-11-20 21:50:06 UTC (rev 176411)
+++ trunk/Source/WebKit2/ChangeLog	2014-11-20 22:03:39 UTC (rev 176412)
@@ -1,3 +1,16 @@
+2014-11-20  Beth Dakin  <[email protected]>
+
+        Invalid message WebPageProxy.DidPerformDictionaryLookup on Google stocks result
+        https://bugs.webkit.org/show_bug.cgi?id=138568
+        -and corresponding-
+        rdar://problem/18904600
+
+        Reviewed by Tim Horton.
+
+        Skip images for lookup.
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::performDictionaryLookupForRange):
+
 2014-11-20  Daniel Bates  <[email protected]>
 
         [iOS] Add more ENABLE({TOUCH_EVENTS, IOS_TOUCH_EVENTS})-guards in WebKit2

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (176411 => 176412)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-11-20 21:50:06 UTC (rev 176411)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-11-20 22:03:39 UTC (rev 176412)
@@ -530,7 +530,7 @@
     dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y() + (style.fontMetrics().ascent() * pageScaleFactor()));
     dictionaryPopupInfo.options = (CFDictionaryRef)options;
 
-    NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range);
+    NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
 
     RetainPtr<NSMutableAttributedString> scaledNSAttributedString = adoptNS([[NSMutableAttributedString alloc] initWithString:[nsAttributedString string]]);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to