- 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
+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.
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;
// 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);
// 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);
}
return document();
}
+int RenderMenuList::clientInsetLeft() const
+{
+ return 0;
+}
+
+int RenderMenuList::clientInsetRight() const
+{
+ return 0;
+}
+
int RenderMenuList::clientPaddingLeft() const
{
return paddingLeft();
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;
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();
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;