Reviewed by Adam Roben and John Sullivan.
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2007 04:34:38 +0000 (04:34 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2007 04:34:38 +0000 (04:34 +0000)
        - make the recent searches popup extend only along the straight part of
          the search field (unless it needs to be wider).

        * platform/PopupMenuClient.h:
          Added clientInsetLeft() and clientInsetRight() for clients to
          specify desired horizontal insets for the menu.
        * platform/win/PopupMenuWin.cpp:
        (WebCore::PopupMenu::calculatePositionAndSize):
        (WebCore::PopupMenu::paint):
        * rendering/RenderMenuList.cpp:
        (WebCore::RenderMenuList::clientInsetLeft): Added. Returns 0.
        (WebCore::RenderMenuList::clientInsetRight): Ditto.
        * rendering/RenderMenuList.h:
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::clientInsetLeft): Added. Returns half the
        control's height, which is the radius of the cap on the left.
        (WebCore::RenderTextControl::clientInsetRight): Added.
        * rendering/RenderTextControl.h:

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

WebCore/ChangeLog
WebCore/platform/PopupMenuClient.h
WebCore/platform/win/PopupMenuWin.cpp
WebCore/rendering/RenderMenuList.cpp
WebCore/rendering/RenderMenuList.h
WebCore/rendering/RenderTextControl.cpp
WebCore/rendering/RenderTextControl.h

index fbbaa5eed4e132b8a98a2f8c304f34677e49fb16..38bd01ef48ce25d348c64cbf0419d58ee6989162 100644 (file)
@@ -1,3 +1,26 @@
+2007-11-29  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Adam Roben and John Sullivan.
+
+        - make the recent searches popup extend only along the straight part of
+          the search field (unless it needs to be wider).
+
+        * platform/PopupMenuClient.h:
+          Added clientInsetLeft() and clientInsetRight() for clients to
+          specify desired horizontal insets for the menu.
+        * platform/win/PopupMenuWin.cpp:
+        (WebCore::PopupMenu::calculatePositionAndSize):
+        (WebCore::PopupMenu::paint):
+        * rendering/RenderMenuList.cpp:
+        (WebCore::RenderMenuList::clientInsetLeft): Added. Returns 0.
+        (WebCore::RenderMenuList::clientInsetRight): Ditto.
+        * rendering/RenderMenuList.h:
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::clientInsetLeft): Added. Returns half the
+        control's height, which is the radius of the cap on the left.
+        (WebCore::RenderTextControl::clientInsetRight): Added.
+        * rendering/RenderTextControl.h:
+
 2007-11-30  Alp Toker  <alp@atoker.com>
 
         Reviewed by Maciej.
index 86292793d163de9b9f9544716fd23503dffb02a7..81be90e5e218a355ab03189680153e3bd3b72dd3 100644 (file)
@@ -40,6 +40,8 @@ public:
     virtual RenderStyle* itemStyle(unsigned listIndex) const = 0;
     virtual RenderStyle* clientStyle() const = 0;
     virtual Document* clientDocument() const = 0;
+    virtual int clientInsetLeft() const = 0;
+    virtual int clientInsetRight() const = 0;
     virtual int clientPaddingLeft() const = 0;
     virtual int clientPaddingRight() const = 0;
     virtual int listSize() const = 0;
index 3bdf59b7c14d58c6f06e83addfe8b932abd5ab3e..1e3b9a3c14feb91b56d4d7fa17b8dc03a5edc853 100644 (file)
@@ -198,17 +198,17 @@ void PopupMenu::calculatePositionAndSize(const IntRect& r, FrameView* v)
     // Add padding to align the popup text with the <select> text
     // Note: We can't add paddingRight() because that value includes the width
     // of the dropdown button, so we must use our own endOfLinePadding constant.
-    popupWidth += endOfLinePadding + client()->clientPaddingLeft();
+    popupWidth += max(0, endOfLinePadding - client()->clientInsetRight()) + max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
 
     // Leave room for the border
     popupWidth += 2 * popupWindowBorderWidth;
     popupHeight += 2 * popupWindowBorderWidth;
 
     // The popup should be at least as wide as the control on the page
-    popupWidth = max(rScreenCoords.width(), popupWidth);
+    popupWidth = max(rScreenCoords.width() - client()->clientInsetLeft() - client()->clientInsetRight(), popupWidth);
 
     // Always left-align items in the popup.  This matches popup menus on the mac.
-    int popupX = rScreenCoords.x();
+    int popupX = rScreenCoords.x() + client()->clientInsetLeft();
 
     IntRect popupRect(popupX, rScreenCoords.bottom(), popupWidth, popupHeight);
 
@@ -526,7 +526,7 @@ void PopupMenu::paint(const IntRect& damageRect, HDC hdc)
         
         // Draw the item text
         if (itemStyle->visibility() != HIDDEN) {
-            int textX = client()->clientPaddingLeft();
+            int textX = max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
             int textY = itemRect.y() + itemFont.ascent() + (itemRect.height() - itemFont.height()) / 2;
             context.drawBidiText(textRun, IntPoint(textX, textY), textStyle);
         }
index a079848fc97a0ffa93f260cc980e832a7bb33a09..9667cabe8da1d3efbdfcb79648e1e96ade29a26e 100644 (file)
@@ -350,6 +350,16 @@ Document* RenderMenuList::clientDocument() const
     return document();
 }
 
+int RenderMenuList::clientInsetLeft() const
+{
+    return 0;
+}
+
+int RenderMenuList::clientInsetRight() const
+{
+    return 0;
+}
+
 int RenderMenuList::clientPaddingLeft() const
 {
     return paddingLeft();
index 740f987f707153f29e983b44324461700a99760f..c0c40477a9a503ce7f941bb73e20ac25acacde3e 100644 (file)
@@ -75,6 +75,8 @@ private:
     virtual RenderStyle* itemStyle(unsigned listIndex) const;
     virtual RenderStyle* clientStyle() const;
     virtual Document* clientDocument() const;
+    virtual int clientInsetLeft() const;
+    virtual int clientInsetRight() const;
     virtual int clientPaddingLeft() const;
     virtual int clientPaddingRight() const;
     virtual int listSize() const;
index 8df160724dc969e10d79375fa1cae3d037a3e4d1..643a61a67704eec8d6059def99595ccb6f4a0513 100644 (file)
@@ -1113,6 +1113,21 @@ Document* RenderTextControl::clientDocument() const
     return document();
 }
 
+int RenderTextControl::clientInsetLeft() const
+{
+    // Inset the menu by the radius of the cap on the left so that
+    // it only runs along the straight part of the bezel.
+    return height() / 2;
+}
+
+int RenderTextControl::clientInsetRight() const
+{
+    // Inset the menu by the radius of the cap on the right so that
+    // it only runs along the straight part of the bezel (unless it needs
+    // to be wider).
+    return height() / 2;
+}
+
 int RenderTextControl::clientPaddingLeft() const
 {
     return paddingLeft() + m_resultsButton->renderer()->width();
index 303b9eadc57d609b59b1d78033c1934f1f183a25..75d12c819902cfebd18e83e63d9d6c7d45001f51 100644 (file)
@@ -115,6 +115,8 @@ private:
     virtual RenderStyle* itemStyle(unsigned listIndex) const;
     virtual RenderStyle* clientStyle() const;
     virtual Document* clientDocument() const;
+    virtual int clientInsetLeft() const;
+    virtual int clientInsetRight() const;
     virtual int clientPaddingLeft() const;
     virtual int clientPaddingRight() const;
     virtual int listSize() const;