Title: [157423] trunk/Source/WebCore
Revision
157423
Author
[email protected]
Date
2013-10-14 14:45:13 -0700 (Mon, 14 Oct 2013)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=122774.
<rdar://problem/6138855>.

Reviewed by Brent Fulgham.

Add a field to keep track of hovered over index.
Use index to determine whether or not to use the existing selected index on the mouse down event.

* platform/win/PopupMenuWin.cpp:
(WebCore::PopupMenuWin::PopupMenuWin):
(WebCore::PopupMenuWin::show):
(WebCore::PopupMenuWin::wndProc):
* platform/win/PopupMenuWin.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (157422 => 157423)


--- trunk/Source/WebCore/ChangeLog	2013-10-14 21:41:13 UTC (rev 157422)
+++ trunk/Source/WebCore/ChangeLog	2013-10-14 21:45:13 UTC (rev 157423)
@@ -1,3 +1,19 @@
+2013-10-14  Roger Fong  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=122774.
+        <rdar://problem/6138855>.
+
+        Reviewed by Brent Fulgham.
+
+        Add a field to keep track of hovered over index.
+        Use index to determine whether or not to use the existing selected index on the mouse down event.
+
+        * platform/win/PopupMenuWin.cpp:
+        (WebCore::PopupMenuWin::PopupMenuWin):
+        (WebCore::PopupMenuWin::show):
+        (WebCore::PopupMenuWin::wndProc):
+        * platform/win/PopupMenuWin.h:
+
 2013-10-14  Tim Horton  <[email protected]>
 
         Virtualize PlatformCALayer

Modified: trunk/Source/WebCore/platform/win/PopupMenuWin.cpp (157422 => 157423)


--- trunk/Source/WebCore/platform/win/PopupMenuWin.cpp	2013-10-14 21:41:13 UTC (rev 157422)
+++ trunk/Source/WebCore/platform/win/PopupMenuWin.cpp	2013-10-14 21:45:13 UTC (rev 157423)
@@ -112,6 +112,7 @@
     , m_scrollOffset(0)
     , m_wheelDelta(0)
     , m_focusedIndex(0)
+    , m_hoveredIndex(0)
     , m_scrollbarCapturingMouse(false)
     , m_showPopup(false)
 {
@@ -156,6 +157,13 @@
     // Determine whether we should animate our popups
     // Note: Must use 'BOOL' and 'FALSE' instead of 'bool' and 'false' to avoid stack corruption with SystemParametersInfo
     BOOL shouldAnimate = FALSE;
+
+    if (client()) {
+        int index = client()->selectedIndex();
+        if (index >= 0)
+            setFocusedIndex(index);
+    }
+
 #if !OS(WINCE)
     ::SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &shouldAnimate, 0);
 
@@ -166,13 +174,8 @@
             ::AnimateWindow(m_popup, defaultAnimationDuration, AW_BLEND);
     } else
 #endif
-        ::ShowWindow(m_popup, SW_SHOWNOACTIVATE);
 
-    if (client()) {
-        int index = client()->selectedIndex();
-        if (index >= 0)
-            setFocusedIndex(index);
-    }
+    ::ShowWindow(m_popup, SW_SHOWNOACTIVATE);
 
     m_showPopup = true;
 
@@ -979,8 +982,10 @@
                 break;
             }
 
-            if ((shouldHotTrack || wParam & MK_LBUTTON) && ::PtInRect(&bounds, mousePoint))
+            if ((shouldHotTrack || wParam & MK_LBUTTON) && ::PtInRect(&bounds, mousePoint)) {
                 setFocusedIndex(listIndexAtPoint(mousePoint), true);
+                m_hoveredIndex = listIndexAtPoint(mousePoint);
+            }
 
             break;
         }
@@ -1002,8 +1007,10 @@
             // hide the popup.
             RECT bounds;
             GetClientRect(m_popup, &bounds);
-            if (::PtInRect(&bounds, mousePoint))
+            if (::PtInRect(&bounds, mousePoint)) {
                 setFocusedIndex(listIndexAtPoint(mousePoint), true);
+                m_hoveredIndex = listIndexAtPoint(mousePoint);
+            }
             else
                 hide();
             break;
@@ -1029,7 +1036,9 @@
             GetClientRect(popupHandle(), &bounds);
             if (client() && ::PtInRect(&bounds, mousePoint)) {
                 hide();
-                int index = focusedIndex();
+                int index = m_hoveredIndex;
+                if (!client()->itemIsEnabled(index))
+                    index = client()->selectedIndex();
                 if (index >= 0)
                     client()->valueChanged(index);
             }

Modified: trunk/Source/WebCore/platform/win/PopupMenuWin.h (157422 => 157423)


--- trunk/Source/WebCore/platform/win/PopupMenuWin.h	2013-10-14 21:41:13 UTC (rev 157422)
+++ trunk/Source/WebCore/platform/win/PopupMenuWin.h	2013-10-14 21:45:13 UTC (rev 157423)
@@ -128,6 +128,7 @@
     int m_scrollOffset;
     int m_wheelDelta;
     int m_focusedIndex;
+    int m_hoveredIndex;
     bool m_scrollbarCapturingMouse;
     bool m_showPopup;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to