Changeset 79914 in webkit
- Timestamp:
- Feb 28, 2011 1:39:27 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r79891 r79914 1 2011-02-28 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Brady Eidson. 4 5 WK2 Context Menus - Implement LookUpInDictionary 6 https://bugs.webkit.org/show_bug.cgi?id=55405 7 8 * Shared/DictionaryPopupInfo.cpp: 9 (WebKit::DictionaryPopupInfo::encode): 10 (WebKit::DictionaryPopupInfo::decode): 11 * Shared/DictionaryPopupInfo.h: 12 Add type to differentiate between HotKey and ContextMenu triggered 13 dictionary popups. This is necessary since HotKey triggered ones want 14 to override the style to always be overlay. 15 16 * UIProcess/API/mac/PageClientImpl.mm: 17 (WebKit::PageClientImpl::didPerformDictionaryLookup): 18 Only force the overlay style for HotKey triggered dictionary lookups. 19 20 * WebProcess/WebPage/WebPage.h: 21 * WebProcess/WebPage/mac/WebPageMac.mm: 22 (WebKit::WebPage::performDictionaryLookupAtLocation): 23 (WebKit::WebPage::performDictionaryLookupForRange): 24 Factor out shared functionality into performDictionaryLookupForRange. 25 26 * WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm: 27 (WebKit::WebContextMenuClient::lookUpInDictionary): 28 Get selected range and call newly factored out performDictionaryLookupForRange. 29 1 30 2011-02-28 Anders Carlsson <andersca@apple.com> 2 31 -
trunk/Source/WebKit2/Shared/DictionaryPopupInfo.cpp
r79886 r79914 35 35 encoder->encode(origin); 36 36 encoder->encode(fontInfo); 37 encoder->encodeEnum(type); 37 38 } 38 39 … … 43 44 if (!decoder->decode(result.fontInfo)) 44 45 return false; 46 if (!decoder->decodeEnum(result.type)) 47 return false; 45 48 return true; 46 49 } -
trunk/Source/WebKit2/Shared/DictionaryPopupInfo.h
r79886 r79914 41 41 static bool decode(CoreIPC::ArgumentDecoder*, DictionaryPopupInfo&); 42 42 43 enum Type { 44 ContextMenu, 45 HotKey 46 }; 47 43 48 WebCore::FloatPoint origin; 44 49 FontInfo fontInfo; 50 Type type; 45 51 }; 46 52 -
trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
r79886 r79914 425 425 textBaselineOrigin.y += [font ascender]; 426 426 427 NSDictionary *options = [NSDictionary dictionaryWithObject:NSDefinitionPresentationTypeOverlay forKey:NSDefinitionPresentationTypeKey]; 427 // If the dictionary lookup is being triggered by a hot key, force the overlay style. 428 NSDictionary *options = (dictionaryPopupInfo.type == DictionaryPopupInfo::HotKey) ? [NSDictionary dictionaryWithObject:NSDefinitionPresentationTypeOverlay forKey:NSDefinitionPresentationTypeKey] : 0; 428 429 [m_wkView showDefinitionForAttributedString:attributedString.get() range:NSMakeRange(0, [attributedString.get() length]) options:options baselineOriginProvider:^(NSRange adjustedRange) { return (NSPoint)textBaselineOrigin; }]; 429 430 } -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm
r79335 r79914 27 27 #import "WebContextMenuClient.h" 28 28 29 #import "DictionaryPopupInfo.h" 30 #import "WebCoreArgumentCoders.h" 29 31 #import "WebPage.h" 32 #import "WebPageProxyMessages.h" 30 33 #import <WebCore/Frame.h> 31 #i nclude <WebCore/NotImplemented.h>34 #import <WebCore/FrameView.h> 32 35 #import <WebCore/Page.h> 33 36 #import <wtf/text/WTFString.h> … … 37 40 namespace WebKit { 38 41 39 void WebContextMenuClient::lookUpInDictionary(Frame* )42 void WebContextMenuClient::lookUpInDictionary(Frame* frame) 40 43 { 41 // FIXME: <rdar://problem/8750610> - Implement 42 notImplemented(); 44 RefPtr<Range> selectedRange = frame->selection()->selection().toNormalizedRange(); 45 if (!selectedRange) 46 return; 47 48 m_page->performDictionaryLookupForRange(DictionaryPopupInfo::ContextMenu, frame, selectedRange.get()); 43 49 } 44 50 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r79863 r79914 58 58 59 59 #if PLATFORM(MAC) 60 #include "DictionaryPopupInfo.h" 60 61 #include <wtf/RetainPtr.h> 61 62 OBJC_CLASS AccessibilityWebPageObject; … … 308 309 309 310 #if PLATFORM(MAC) 311 void performDictionaryLookupForRange(DictionaryPopupInfo::Type, WebCore::Frame*, WebCore::Range*); 312 310 313 bool isSpeaking(); 311 314 void speak(const String&); -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r79886 r79914 29 29 #import "AccessibilityWebPageObject.h" 30 30 #import "DataReference.h" 31 #import "DictionaryPopupInfo.h"32 31 #import "PluginView.h" 33 32 #import "WebCoreArgumentCoders.h" … … 287 286 return; 288 287 289 RenderObject* renderer = finalRange->startContainer()->renderer(); 288 performDictionaryLookupForRange(DictionaryPopupInfo::HotKey, frame, finalRange.get()); 289 } 290 291 void WebPage::performDictionaryLookupForRange(DictionaryPopupInfo::Type type, Frame* frame, Range* range) 292 { 293 String rangeText = range->text(); 294 if (rangeText.stripWhiteSpace().isEmpty()) 295 return; 296 297 RenderObject* renderer = range->startContainer()->renderer(); 290 298 RenderStyle* style = renderer->style(); 291 299 NSFont *font = style->font().primaryFont()->getNSFont(); 292 300 if (!font) 293 301 return; 294 302 295 303 CFDictionaryRef fontDescriptorAttributes = (CFDictionaryRef)[[font fontDescriptor] fontAttributes]; 296 304 if (!fontDescriptorAttributes) … … 298 306 299 307 Vector<FloatQuad> quads; 300 finalRange->textQuads(quads);308 range->textQuads(quads); 301 309 if (quads.isEmpty()) 302 310 return; 303 304 IntRect finalRangeRect = frame->view()->contentsToWindow(quads[0].enclosingBoundingBox());305 311 312 IntRect rangeRect = frame->view()->contentsToWindow(quads[0].enclosingBoundingBox()); 313 306 314 DictionaryPopupInfo dictionaryPopupInfo; 307 dictionaryPopupInfo.origin = FloatPoint(finalRangeRect.x(), finalRangeRect.y()); 315 dictionaryPopupInfo.type = type; 316 dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y()); 308 317 dictionaryPopupInfo.fontInfo.fontAttributeDictionary = fontDescriptorAttributes; 309 318 310 send(Messages::WebPageProxy::DidPerformDictionaryLookup( finalRange->text(), dictionaryPopupInfo));319 send(Messages::WebPageProxy::DidPerformDictionaryLookup(rangeText, dictionaryPopupInfo)); 311 320 } 312 321
Note: See TracChangeset
for help on using the changeset viewer.