diff options
Diffstat (limited to 'WebCore/rendering/RenderMenuList.cpp')
-rw-r--r-- | WebCore/rendering/RenderMenuList.cpp | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/WebCore/rendering/RenderMenuList.cpp b/WebCore/rendering/RenderMenuList.cpp index 04242e0..469a73d 100644 --- a/WebCore/rendering/RenderMenuList.cpp +++ b/WebCore/rendering/RenderMenuList.cpp @@ -34,8 +34,10 @@ #include "HTMLSelectElement.h" #include "PopupMenu.h" #include "RenderBR.h" +#include "RenderScrollbar.h" #include "RenderText.h" #include "RenderTheme.h" +#include "NodeRenderStyle.h" #include <math.h> using namespace std; @@ -62,6 +64,12 @@ RenderMenuList::~RenderMenuList() m_popup = 0; } +// this static cast is safe because RenderMenuLists are only created for HTMLSelectElements +HTMLSelectElement* RenderMenuList::selectElement() +{ + return static_cast<HTMLSelectElement*>(node()); +} + void RenderMenuList::createInnerBlock() { if (m_innerBlock) { @@ -110,21 +118,18 @@ void RenderMenuList::removeChild(RenderObject* oldChild) m_innerBlock->removeChild(oldChild); } -void RenderMenuList::setStyle(RenderStyle* newStyle) +void RenderMenuList::styleDidChange(RenderStyle::Diff diff, const RenderStyle* oldStyle) { - bool fontChanged = !style() || style()->font() != newStyle->font(); - - // Don't allow overflow on menu lists. - newStyle->setOverflowX(OVISIBLE); - newStyle->setOverflowY(OVISIBLE); - - RenderBlock::setStyle(newStyle); + RenderBlock::styleDidChange(diff, oldStyle); if (m_buttonText) - m_buttonText->setStyle(newStyle); + m_buttonText->setStyle(style()); if (m_innerBlock) // RenderBlock handled updating the anonymous block's style. adjustInnerStyle(); + setReplaced(isInline()); + + bool fontChanged = !oldStyle || oldStyle->font() != style()->font(); if (fontChanged) updateOptionsWidth(); } @@ -310,12 +315,13 @@ bool RenderMenuList::itemIsEnabled(unsigned listIndex) const return element->isEnabled() && groupEnabled; } -RenderStyle* RenderMenuList::itemStyle(unsigned listIndex) const +PopupMenuStyle RenderMenuList::itemStyle(unsigned listIndex) const { HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node()); HTMLElement* element = select->listItems()[listIndex]; - return element->renderStyle() ? element->renderStyle() : clientStyle(); + RenderStyle* style = element->renderStyle() ? element->renderStyle() : element->computedStyle(); + return style ? PopupMenuStyle(style->color(), itemBackgroundColor(listIndex), style->font(), style->visibility() == VISIBLE) : menuStyle(); } Color RenderMenuList::itemBackgroundColor(unsigned listIndex) const @@ -339,14 +345,27 @@ Color RenderMenuList::itemBackgroundColor(unsigned listIndex) const return Color(Color::white).blend(backgroundColor); } -RenderStyle* RenderMenuList::clientStyle() const +PopupMenuStyle RenderMenuList::menuStyle() const +{ + + RenderStyle* s = m_innerBlock ? m_innerBlock->style() : style(); + return PopupMenuStyle(s->color(), s->backgroundColor(), s->font(), s->visibility() == VISIBLE); +} + +HostWindow* RenderMenuList::hostWindow() const { - return m_innerBlock ? m_innerBlock->style() : style(); + return document()->view()->hostWindow(); } -Document* RenderMenuList::clientDocument() const +PassRefPtr<Scrollbar> RenderMenuList::createScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) { - return document(); + RefPtr<Scrollbar> widget; + bool hasCustomScrollbarStyle = style()->hasPseudoStyle(RenderStyle::SCROLLBAR); + if (hasCustomScrollbarStyle) + widget = RenderScrollbar::createCustomScrollbar(client, orientation, this); + else + widget = Scrollbar::createNativeScrollbar(client, orientation, controlSize); + return widget.release(); } int RenderMenuList::clientInsetLeft() const |