Changeset 41923 in webkit


Ignore:
Timestamp:
Mar 23, 2009 4:46:27 PM (15 years ago)
Author:
adachan@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=24762
Support text-indent in <option> elements on windows platform.

Reviewed by Adele Peterson.

  • css/themeWin.css:
  • platform/PopupMenuStyle.h: We don't honor font specified on <option> elements right now. Make this explicit via windows themed default stylesheet. (WebCore::PopupMenuStyle::PopupMenuStyle): Also store text-indent and text-direction. (WebCore::PopupMenuStyle::textIndent): (WebCore::PopupMenuStyle::textDirection):
  • platform/win/PopupMenuWin.cpp: (WebCore::PopupMenu::paint): Adjust the text's x-coordinate if text-indent is supported for options and text-indent is specified with LTR direction.
  • rendering/RenderMenuList.cpp: (WebCore::RenderMenuList::updateOptionsWidth): Take text-indent into account if theme supports text-indent for options. (WebCore::RenderMenuList::itemStyle): Use new PopupMenuStyle constructor on windows. (WebCore::RenderMenuList::menuStyle): Ditto.
  • rendering/RenderTextControlSingleLine.cpp: (WebCore::RenderTextControlSingleLine::menuStyle): Ditto.
  • rendering/RenderTheme.h: (WebCore::RenderTheme::popupOptionSupportsTextIndent): Added. Default is false since we are only supporting it in windows for now.
  • rendering/RenderThemeWin.h: (WebCore::RenderThemeWin::popupOptionSupportsTextIndent): Returns true for windows.
Location:
trunk/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r41922 r41923  
     12009-03-23  Ada Chan  <adachan@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=24762
     4        Support text-indent in <option> elements on windows platform.
     5
     6        Reviewed by Adele Peterson.
     7
     8        * css/themeWin.css:
     9        * platform/PopupMenuStyle.h: We don't honor font specified on <option> elements right now.  Make this
     10        explicit via windows themed default stylesheet.
     11        (WebCore::PopupMenuStyle::PopupMenuStyle): Also store text-indent and text-direction.
     12        (WebCore::PopupMenuStyle::textIndent):
     13        (WebCore::PopupMenuStyle::textDirection):
     14        * platform/win/PopupMenuWin.cpp:
     15        (WebCore::PopupMenu::paint): Adjust the text's x-coordinate if text-indent is supported for options and
     16        text-indent is specified with LTR direction.
     17        * rendering/RenderMenuList.cpp:
     18        (WebCore::RenderMenuList::updateOptionsWidth): Take text-indent into account if theme supports text-indent for options.
     19        (WebCore::RenderMenuList::itemStyle): Use new PopupMenuStyle constructor on windows.
     20        (WebCore::RenderMenuList::menuStyle): Ditto.
     21        * rendering/RenderTextControlSingleLine.cpp:
     22        (WebCore::RenderTextControlSingleLine::menuStyle): Ditto.
     23        * rendering/RenderTheme.h:
     24        (WebCore::RenderTheme::popupOptionSupportsTextIndent): Added.  Default is false since we are only supporting it in windows for now.
     25        * rendering/RenderThemeWin.h:
     26        (WebCore::RenderThemeWin::popupOptionSupportsTextIndent): Returns true for windows.
     27
    1282009-03-23  Sam Weinig  <sam@webkit.org>
    229
  • trunk/WebCore/css/themeWin.css

    r41652 r41923  
    9494    margin: 0;
    9595}
     96/* Options always use the selects' fonts */
     97option {
     98    font: inherit !important;
     99}
    96100
    97101textarea {
  • trunk/WebCore/platform/PopupMenuStyle.h

    r37295 r41923  
    2929#include "Color.h"
    3030#include "Font.h"
     31#include "Length.h"
     32#include "TextDirection.h"
    3133
    3234namespace WebCore {
     
    3436class PopupMenuStyle {
    3537public:
    36     PopupMenuStyle(const Color& foreground, const Color& background, const Font& font, bool visible)
     38    PopupMenuStyle(const Color& foreground, const Color& background, const Font& font, bool visible, Length textIndent, TextDirection textDirection)
    3739        : m_foregroundColor(foreground)
    3840        , m_backgroundColor(background)
    3941        , m_font(font)
    4042        , m_visible(visible)
     43        , m_textIndent(textIndent)
     44        , m_textDirection(textDirection)
    4145    {
    4246    }
     
    4650    const Font& font() const { return m_font; }
    4751    bool isVisible() const { return m_visible; }
     52    Length textIndent() const { return m_textIndent; }
     53    TextDirection textDirection() const { return m_textDirection; }
    4854
    4955private:
     
    5258    Font m_font;
    5359    bool m_visible;
     60    Length m_textIndent;
     61    TextDirection m_textDirection;
    5462};
    5563
  • trunk/WebCore/platform/win/PopupMenuWin.cpp

    r40020 r41923  
    528528        if (itemStyle.isVisible()) {
    529529            int textX = max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
     530            if (theme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR)
     531                textX += itemStyle.textIndent().calcMinValue(itemRect.width());
    530532            int textY = itemRect.y() + itemFont.ascent() + (itemRect.height() - itemFont.height()) / 2;
    531533            context.drawBidiText(itemFont, textRun, IntPoint(textX, textY));
  • trunk/WebCore/rendering/RenderMenuList.cpp

    r40628 r41923  
    144144
    145145        String text = optionElement->textIndentedToRespectGroupLabel();
    146         if (!text.isEmpty())
     146        if (theme()->popupOptionSupportsTextIndent()) {
     147            // Add in the option's text indent.  We can't calculate percentage values for now.
     148            float optionWidth = 0;
     149            if (RenderStyle* optionStyle = element->renderStyle())
     150                optionWidth += optionStyle->textIndent().calcMinValue(0);
     151            if (!text.isEmpty())
     152                optionWidth += style()->font().floatWidth(text);
     153            maxOptionWidth = max(maxOptionWidth, optionWidth);
     154        } else if (!text.isEmpty())
    147155            maxOptionWidth = max(maxOptionWidth, style()->font().floatWidth(text));
    148156    }
     
    333341   
    334342    RenderStyle* style = element->renderStyle() ? element->renderStyle() : element->computedStyle();
    335     return style ? PopupMenuStyle(style->color(), itemBackgroundColor(listIndex), style->font(), style->visibility() == VISIBLE) : menuStyle();
     343    return style ? PopupMenuStyle(style->color(), itemBackgroundColor(listIndex), style->font(), style->visibility() == VISIBLE, style->textIndent(), style->direction()) : menuStyle();
    336344}
    337345
     
    361369
    362370    RenderStyle* s = m_innerBlock ? m_innerBlock->style() : style();
    363     return PopupMenuStyle(s->color(), s->backgroundColor(), s->font(), s->visibility() == VISIBLE);
     371    return PopupMenuStyle(s->color(), s->backgroundColor(), s->font(), s->visibility() == VISIBLE, s->textIndent(), s->direction());
    364372}
    365373
  • trunk/WebCore/rendering/RenderTextControlSingleLine.cpp

    r41899 r41923  
    693693PopupMenuStyle RenderTextControlSingleLine::menuStyle() const
    694694{
    695     return PopupMenuStyle(style()->color(), style()->backgroundColor(), style()->font(), style()->visibility() == VISIBLE);
     695    return PopupMenuStyle(style()->color(), style()->backgroundColor(), style()->font(), style()->visibility() == VISIBLE, style()->textIndent(), style()->direction());
    696696}
    697697
  • trunk/WebCore/rendering/RenderTheme.h

    r41362 r41923  
    136136    virtual int popupInternalPaddingTop(RenderStyle*) const { return 0; }
    137137    virtual int popupInternalPaddingBottom(RenderStyle*) const { return 0; }
     138    virtual bool popupOptionSupportsTextIndent() const { return false; }
    138139
    139140    virtual int buttonInternalPaddingLeft() const { return 0; }
  • trunk/WebCore/rendering/RenderThemeWin.h

    r41362 r41923  
    9393    virtual void adjustSliderThumbSize(RenderObject*) const;
    9494
     95    virtual bool popupOptionSupportsTextIndent() const { return true; }
     96
    9597    virtual int buttonInternalPaddingLeft() const;
    9698    virtual int buttonInternalPaddingRight() const;
Note: See TracChangeset for help on using the changeset viewer.