<rdar://problem/8665102> and https://bugs.webkit.org/show_bug.cgi?id=58595
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Apr 2011 23:13:35 +0000 (23:13 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Apr 2011 23:13:35 +0000 (23:13 +0000)
Menu is not displayed for <input type=search results="5">

Reviewed by Sam Weinig.

* WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp:
(WebKit::WebSearchPopupMenu::enabled): Return true, like all good search popup menus should.

* WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm:
(WebKit::WebPopupMenu::setUpPlatformData): Remember the shouldPopOver-ness.

* Shared/PlatformPopupMenuData.cpp:
(WebKit::PlatformPopupMenuData::encode): Remember the shouldPopOver-ness.
(WebKit::PlatformPopupMenuData::decode): Remember the shouldPopOver-ness.
* Shared/PlatformPopupMenuData.h:

* UIProcess/mac/WebPopupMenuProxyMac.mm:
(WebKit::WebPopupMenuProxyMac::showPopupMenu): Use the shouldPopOver-ness to adjust display position.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/PlatformPopupMenuData.cpp
Source/WebKit2/Shared/PlatformPopupMenuData.h
Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm

index e96768c..35360e6 100644 (file)
@@ -1,3 +1,24 @@
+2011-04-14  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        <rdar://problem/8665102> and https://bugs.webkit.org/show_bug.cgi?id=58595
+        Menu is not displayed for <input type=search results="5">
+
+        * WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp:
+        (WebKit::WebSearchPopupMenu::enabled): Return true, like all good search popup menus should.
+
+        * WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm:
+        (WebKit::WebPopupMenu::setUpPlatformData): Remember the shouldPopOver-ness.
+
+        * Shared/PlatformPopupMenuData.cpp:
+        (WebKit::PlatformPopupMenuData::encode): Remember the shouldPopOver-ness.
+        (WebKit::PlatformPopupMenuData::decode): Remember the shouldPopOver-ness.
+        * Shared/PlatformPopupMenuData.h:
+
+        * UIProcess/mac/WebPopupMenuProxyMac.mm:
+        (WebKit::WebPopupMenuProxyMac::showPopupMenu): Use the shouldPopOver-ness to adjust display position.
+
 2011-04-14  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Dan Bernstein.
index 1f56daf..6c4d20e 100644 (file)
@@ -61,6 +61,7 @@ void PlatformPopupMenuData::encode(CoreIPC::ArgumentEncoder* encoder) const
     encoder->encode(selectedBackingStoreHandle);
 #elif PLATFORM(MAC)
     encoder->encode(fontInfo);
+    encoder->encode(shouldPopOver);
 #endif
 }
 
@@ -92,6 +93,8 @@ bool PlatformPopupMenuData::decode(CoreIPC::ArgumentDecoder* decoder, PlatformPo
 #elif PLATFORM(MAC)
     if (!decoder->decode(data.fontInfo))
         return false;
+    if (!decoder->decode(data.shouldPopOver))
+        return false;
 #endif
     
     return true;
index 5b3f58d..f85008a 100644 (file)
@@ -54,6 +54,7 @@ struct PlatformPopupMenuData {
     RefPtr<ShareableBitmap> m_selectedBackingStore;
 #elif PLATFORM(MAC)
     FontInfo fontInfo;
+    bool shouldPopOver;
 #endif
 };
 
index 7ce8764..3523e3b 100644 (file)
@@ -108,11 +108,20 @@ void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection text
 
     // These values were borrowed from AppKit to match their placement of the menu.
     const int popOverHorizontalAdjust = -10;
-    NSRect titleFrame = [m_popup.get()  titleRectForBounds:rect];
-    if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0)
-        titleFrame = rect;
-    float vertOffset = roundf((NSMaxY(rect) - NSMaxY(titleFrame)) + NSHeight(titleFrame));
-    NSPoint location = NSMakePoint(NSMinX(rect) + popOverHorizontalAdjust, NSMaxY(rect) - vertOffset);
+    const int popUnderHorizontalAdjust = 6;
+    const int popUnderVerticalAdjust = 6;
+    
+    // Menus that pop-over directly obscure the node that generated the popup menu.
+    // Menus that pop-under are offset underneath it.
+    NSPoint location;
+    if (data.shouldPopOver) {
+        NSRect titleFrame = [m_popup.get()  titleRectForBounds:rect];
+        if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0)
+            titleFrame = rect;
+        float vertOffset = roundf((NSMaxY(rect) - NSMaxY(titleFrame)) + NSHeight(titleFrame));
+        location = NSMakePoint(NSMinX(rect) + popOverHorizontalAdjust, NSMaxY(rect) - vertOffset);
+    } else
+        location = NSMakePoint(NSMinX(rect) + popUnderHorizontalAdjust, NSMaxY(rect) + popUnderVerticalAdjust);  
 
     RetainPtr<NSView> dummyView(AdoptNS, [[NSView alloc] initWithFrame:rect]);
     [m_webView addSubview:dummyView.get()];
index b875f32..abe710a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -52,7 +52,7 @@ void WebSearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&
 
 bool WebSearchPopupMenu::enabled()
 {
-    return false;
+    return true;
 }
 
 } // namespace WebKit
index e36f438..b9bc48f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -46,6 +46,7 @@ void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData& data
         return;
     
     data.fontInfo.fontAttributeDictionary = fontDescriptorAttributes;
+    data.shouldPopOver = m_popupClient->shouldPopOver();
 }
 
 } // namespace WebKit