Reviewed by Maciej and Hyatt.
Initial implementation of popup menu control. This can be turned on by setting -webkit-appearance: menulist on a select element.
* WebCore.xcodeproj/project.pbxproj: Added RenderMenuList.h, RenderMenuList.cpp, RenderPopupMenu.h, RenderPopupMenu.cpp,
RenderPopupMenuWin.h, RenderPopupMenuMac.h, RenderPopupMenuMac.mm,
* dom/Node.cpp:
(WebCore::Node::renderStyle): Added. Returns the renderer's style. If there's no renderer, returns's a RenderStyle that's kept by the node.
This is important for HTMLOptGroupElement and HTMLOptionElement, which don't have renderers.
(WebCore::Node::setRenderStyle): Added.
* dom/Node.h:
* dom/Element.cpp: (WebCore::Element::recalcStyle): Updated to use renderStyle so recalcStyle will work for HTMLOptionElements and HTMLOptGroupElements.
* css/cssstyleselector.cpp: Updated to call renderStyle method on the node, so resolving style works on elements w/o renderers that cache style.
(WebCore::CSSStyleSelector::initForStyleResolve):
(WebCore::CSSStyleSelector::locateCousinList):
(WebCore::CSSStyleSelector::canShareStyleWithElement):
(WebCore::CSSStyleSelector::locateSharedStyle):
(WebCore::CSSStyleSelector::checkOneSelector):
* css/html4.css: Removed display:none from options and optgroups, since we're now caching style for these elements.
Added font-weight styles for option and optgroup.
* html/HTMLOptGroupElement.h: Added m_style to keep track of a RenderStyle for the element, even though we aren't creating a renderer.
This will allow us to honor style for optgroups and options for popup menus (and eventually list boxes too).
(WebCore::HTMLOptGroupElement::rendererIsNeeded): Added.
(WebCore::HTMLOptGroupElement::renderStyle): Added.
* html/HTMLOptionElement.h: ditto.
(WebCore::HTMLOptionElement::rendererIsNeeded): Added.
(WebCore::HTMLOptionElement::renderStyle): Added.
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::HTMLOptGroupElement): Initialize m_style.
(WebCore::HTMLOptGroupElement::attach): Set the renderStyle.
(WebCore::HTMLOptGroupElement::detach): Clear m_style.
(WebCore::HTMLOptGroupElement::setRenderStyle): Added.
(WebCore::HTMLOptGroupElement::groupLabelText): Added.
* html/HTMLOptionElement.cpp: ditto.
(WebCore::HTMLOptionElement::HTMLOptionElement):
(WebCore::HTMLOptionElement::attach):
(WebCore::HTMLOptionElement::detach):
(WebCore::HTMLOptionElement::setRenderStyle):
(WebCore::HTMLOptionElement::optionText):
* html/HTMLSelectElement.cpp: Added code to use the new RenderMenuList if the appearance is set to MenuListAppearance,
and if we're not creating a list box renderer.
(WebCore::HTMLSelectElement::recalcStyle):
(WebCore::HTMLSelectElement::createRenderer):
(WebCore::HTMLSelectElement::setRecalcListItems):
(WebCore::HTMLSelectElement::reset):
(WebCore::HTMLSelectElement::notifyOptionSelected):
(WebCore::HTMLSelectElement::defaultEventHandler):
* html/HTMLSelectElement.h:
* WebCore.exp: Added _wkPopupMenu.
* platform/mac/WebCoreSystemInterface.h: Added wkPopupMenu to get the NSMenu to pop up.
* platform/mac/WebCoreSystemInterface.mm:
* platform/win/TemporaryLinkStubs.cpp: Added stubs for RenderPopupMenuWin.
(RenderPopupMenuWin::RenderPopupMenuWin):
(RenderPopupMenuWin::~RenderPopupMenuWin):
(RenderPopupMenuWin::clear):
(RenderPopupMenuWin::populate):
(RenderPopupMenuWin::showPopup):
(RenderPopupMenuWin::addSeparator):
(RenderPopupMenuWin::addGroupLabel):
(RenderPopupMenuWin::addOption):
* rendering/RenderPopupMenuWin.h: Added.
* rendering/RenderPopupMenu.cpp: Added.
(WebCore::RenderPopupMenu::RenderPopupMenu):
(WebCore::RenderPopupMenu::~RenderPopupMenu):
(WebCore::RenderPopupMenu::clear):
(WebCore::RenderPopupMenu::populate): Walks the DOM tree, and adds separators, options, and group labels to the RenderPopupMenu.
(WebCore::RenderPopupMenu::showPopup):
(WebCore::RenderPopupMenu::addSeparator):
(WebCore::RenderPopupMenu::addGroupLabel):
(WebCore::RenderPopupMenu::addOption):
* rendering/RenderPopupMenu.h: Added.
(WebCore::RenderPopupMenu::renderName):
(WebCore::RenderPopupMenu::getRenderMenuList):
* rendering/RenderPopupMenuMac.h: Added.
* rendering/RenderPopupMenuMac.mm: Added.
(WebCore::RenderPopupMenuMac::RenderPopupMenuMac):
(WebCore::RenderPopupMenuMac::~RenderPopupMenuMac):
(WebCore::RenderPopupMenuMac::clear): Removes all items from the menu.
(WebCore::RenderPopupMenuMac::populate): Disables menuChangedMessages before populating the menu.
(WebCore::RenderPopupMenuMac::showPopup): Calculates the right position, and calls wkPopupMenu.
(WebCore::RenderPopupMenuMac::addSeparator):
(WebCore::RenderPopupMenuMac::addGroupLabel):
(WebCore::RenderPopupMenuMac::addOption):
* rendering/RenderMenuList.cpp: Added.
(WebCore::RenderMenuList::RenderMenuList):
(WebCore::RenderMenuList::addChild):
(WebCore::RenderMenuList::removeChild):
(WebCore::RenderMenuList::setStyle):
(WebCore::RenderMenuList::updateFromElement): If the options have changed, iterate through the children to find the menu item with the widest text.
Set the button text to the selected item's text.
(WebCore::RenderMenuList::setText):
(WebCore::RenderMenuList::paintObject):
(WebCore::RenderMenuList::baselinePosition):
(WebCore::RenderMenuList::calcMinMaxWidth):
(WebCore::RenderMenuList::showPopup):
(WebCore::RenderMenuList::layout):
(WebCore::RenderMenuList::updateSelection):
(WebCore::RenderMenuList::valueChanged):
* rendering/RenderMenuList.h: Added.
(WebCore::RenderMenuList::removeLeftoverAnonymousBoxes):
(WebCore::RenderMenuList::allowsReusingAnonymousChild):
(WebCore::RenderMenuList::canHaveChildren):
(WebCore::RenderMenuList::renderName):
(WebCore::RenderMenuList::setOptionsChanged):
(WebCore::RenderMenuList::selectionChanged):
(WebCore::RenderMenuList::setSelectionChanged):
(WebCore::RenderMenuList::hasPopupMenu):
* rendering/RenderTheme.cpp: Added cases for MenuListAppearance.
(WebCore::RenderTheme::adjustStyle):
(WebCore::RenderTheme::paint):
(WebCore::RenderTheme::paintBorderOnly):
(WebCore::RenderTheme::isControlStyled):
(WebCore::RenderTheme::adjustMenuListStyle):
(WebCore::RenderTheme::createPopupMenu): creates platform-specific RenderPopupMenu.
* rendering/RenderTheme.h:
(WebCore::RenderTheme::sizeOfArrowControl): Added.
(WebCore::RenderTheme::paintMenuList): Added.
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::adjustRepaintRect):
(WebCore::RenderThemeMac::paintMenuList):
(WebCore::RenderThemeMac::adjustMenuListStyle):
(WebCore::RenderThemeMac::setPopupButtonCellState):
(WebCore::RenderThemeMac::createPopupMenu):
(WebCore::RenderThemeMac::sizeOfArrowControl):
* rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::createPopupMenu):
* rendering/RenderThemeWin.h:
WebKit:
Reviewed by Maciej and Hyatt.
WebKit part of initial popup menu implementation.
* WebCoreSupport/WebSystemInterface.m: (InitWebCoreSystemInterface):
Initialize WKPopupMenu.
WebKitLibraries:
Reviewed by Maciej and Hyatt.
* WebKitSystemInterface.h: Updated.
* libWebKitSystemInterface.a: Updated.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15177
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-07-05 Adele Peterson <adele@apple.com>
+
+ Reviewed by Maciej and Hyatt.
+
+ Initial implementation of popup menu control. This can be turned on by setting -webkit-appearance: menulist on a select element.
+
+ * WebCore.xcodeproj/project.pbxproj: Added RenderMenuList.h, RenderMenuList.cpp, RenderPopupMenu.h, RenderPopupMenu.cpp,
+ RenderPopupMenuWin.h, RenderPopupMenuMac.h, RenderPopupMenuMac.mm,
+
+ * dom/Node.cpp:
+ (WebCore::Node::renderStyle): Added. Returns the renderer's style. If there's no renderer, returns's a RenderStyle that's kept by the node.
+ This is important for HTMLOptGroupElement and HTMLOptionElement, which don't have renderers.
+ (WebCore::Node::setRenderStyle): Added.
+ * dom/Node.h:
+ * dom/Element.cpp: (WebCore::Element::recalcStyle): Updated to use renderStyle so recalcStyle will work for HTMLOptionElements and HTMLOptGroupElements.
+
+ * css/cssstyleselector.cpp: Updated to call renderStyle method on the node, so resolving style works on elements w/o renderers that cache style.
+ (WebCore::CSSStyleSelector::initForStyleResolve):
+ (WebCore::CSSStyleSelector::locateCousinList):
+ (WebCore::CSSStyleSelector::canShareStyleWithElement):
+ (WebCore::CSSStyleSelector::locateSharedStyle):
+ (WebCore::CSSStyleSelector::checkOneSelector):
+
+ * css/html4.css: Removed display:none from options and optgroups, since we're now caching style for these elements.
+ Added font-weight styles for option and optgroup.
+
+ * html/HTMLOptGroupElement.h: Added m_style to keep track of a RenderStyle for the element, even though we aren't creating a renderer.
+ This will allow us to honor style for optgroups and options for popup menus (and eventually list boxes too).
+ (WebCore::HTMLOptGroupElement::rendererIsNeeded): Added.
+ (WebCore::HTMLOptGroupElement::renderStyle): Added.
+ * html/HTMLOptionElement.h: ditto.
+ (WebCore::HTMLOptionElement::rendererIsNeeded): Added.
+ (WebCore::HTMLOptionElement::renderStyle): Added.
+
+ * html/HTMLOptGroupElement.cpp:
+ (WebCore::HTMLOptGroupElement::HTMLOptGroupElement): Initialize m_style.
+ (WebCore::HTMLOptGroupElement::attach): Set the renderStyle.
+ (WebCore::HTMLOptGroupElement::detach): Clear m_style.
+ (WebCore::HTMLOptGroupElement::setRenderStyle): Added.
+ (WebCore::HTMLOptGroupElement::groupLabelText): Added.
+ * html/HTMLOptionElement.cpp: ditto.
+ (WebCore::HTMLOptionElement::HTMLOptionElement):
+ (WebCore::HTMLOptionElement::attach):
+ (WebCore::HTMLOptionElement::detach):
+ (WebCore::HTMLOptionElement::setRenderStyle):
+ (WebCore::HTMLOptionElement::optionText):
+
+ * html/HTMLSelectElement.cpp: Added code to use the new RenderMenuList if the appearance is set to MenuListAppearance,
+ and if we're not creating a list box renderer.
+ (WebCore::HTMLSelectElement::recalcStyle):
+ (WebCore::HTMLSelectElement::createRenderer):
+ (WebCore::HTMLSelectElement::setRecalcListItems):
+ (WebCore::HTMLSelectElement::reset):
+ (WebCore::HTMLSelectElement::notifyOptionSelected):
+ (WebCore::HTMLSelectElement::defaultEventHandler):
+ * html/HTMLSelectElement.h:
+
+ * WebCore.exp: Added _wkPopupMenu.
+ * platform/mac/WebCoreSystemInterface.h: Added wkPopupMenu to get the NSMenu to pop up.
+ * platform/mac/WebCoreSystemInterface.mm:
+
+ * platform/win/TemporaryLinkStubs.cpp: Added stubs for RenderPopupMenuWin.
+ (RenderPopupMenuWin::RenderPopupMenuWin):
+ (RenderPopupMenuWin::~RenderPopupMenuWin):
+ (RenderPopupMenuWin::clear):
+ (RenderPopupMenuWin::populate):
+ (RenderPopupMenuWin::showPopup):
+ (RenderPopupMenuWin::addSeparator):
+ (RenderPopupMenuWin::addGroupLabel):
+ (RenderPopupMenuWin::addOption):
+ * rendering/RenderPopupMenuWin.h: Added.
+
+ * rendering/RenderPopupMenu.cpp: Added.
+ (WebCore::RenderPopupMenu::RenderPopupMenu):
+ (WebCore::RenderPopupMenu::~RenderPopupMenu):
+ (WebCore::RenderPopupMenu::clear):
+ (WebCore::RenderPopupMenu::populate): Walks the DOM tree, and adds separators, options, and group labels to the RenderPopupMenu.
+ (WebCore::RenderPopupMenu::showPopup):
+ (WebCore::RenderPopupMenu::addSeparator):
+ (WebCore::RenderPopupMenu::addGroupLabel):
+ (WebCore::RenderPopupMenu::addOption):
+ * rendering/RenderPopupMenu.h: Added.
+ (WebCore::RenderPopupMenu::renderName):
+ (WebCore::RenderPopupMenu::getRenderMenuList):
+ * rendering/RenderPopupMenuMac.h: Added.
+ * rendering/RenderPopupMenuMac.mm: Added.
+ (WebCore::RenderPopupMenuMac::RenderPopupMenuMac):
+ (WebCore::RenderPopupMenuMac::~RenderPopupMenuMac):
+ (WebCore::RenderPopupMenuMac::clear): Removes all items from the menu.
+ (WebCore::RenderPopupMenuMac::populate): Disables menuChangedMessages before populating the menu.
+ (WebCore::RenderPopupMenuMac::showPopup): Calculates the right position, and calls wkPopupMenu.
+ (WebCore::RenderPopupMenuMac::addSeparator):
+ (WebCore::RenderPopupMenuMac::addGroupLabel):
+ (WebCore::RenderPopupMenuMac::addOption):
+
+ * rendering/RenderMenuList.cpp: Added.
+ (WebCore::RenderMenuList::RenderMenuList):
+ (WebCore::RenderMenuList::addChild):
+ (WebCore::RenderMenuList::removeChild):
+ (WebCore::RenderMenuList::setStyle):
+ (WebCore::RenderMenuList::updateFromElement): If the options have changed, iterate through the children to find the menu item with the widest text.
+ Set the button text to the selected item's text.
+ (WebCore::RenderMenuList::setText):
+ (WebCore::RenderMenuList::paintObject):
+ (WebCore::RenderMenuList::baselinePosition):
+ (WebCore::RenderMenuList::calcMinMaxWidth):
+ (WebCore::RenderMenuList::showPopup):
+ (WebCore::RenderMenuList::layout):
+ (WebCore::RenderMenuList::updateSelection):
+ (WebCore::RenderMenuList::valueChanged):
+ * rendering/RenderMenuList.h: Added.
+ (WebCore::RenderMenuList::removeLeftoverAnonymousBoxes):
+ (WebCore::RenderMenuList::allowsReusingAnonymousChild):
+ (WebCore::RenderMenuList::canHaveChildren):
+ (WebCore::RenderMenuList::renderName):
+ (WebCore::RenderMenuList::setOptionsChanged):
+ (WebCore::RenderMenuList::selectionChanged):
+ (WebCore::RenderMenuList::setSelectionChanged):
+ (WebCore::RenderMenuList::hasPopupMenu):
+
+ * rendering/RenderTheme.cpp: Added cases for MenuListAppearance.
+ (WebCore::RenderTheme::adjustStyle):
+ (WebCore::RenderTheme::paint):
+ (WebCore::RenderTheme::paintBorderOnly):
+ (WebCore::RenderTheme::isControlStyled):
+ (WebCore::RenderTheme::adjustMenuListStyle):
+ (WebCore::RenderTheme::createPopupMenu): creates platform-specific RenderPopupMenu.
+ * rendering/RenderTheme.h:
+ (WebCore::RenderTheme::sizeOfArrowControl): Added.
+ (WebCore::RenderTheme::paintMenuList): Added.
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::adjustRepaintRect):
+ (WebCore::RenderThemeMac::paintMenuList):
+ (WebCore::RenderThemeMac::adjustMenuListStyle):
+ (WebCore::RenderThemeMac::setPopupButtonCellState):
+ (WebCore::RenderThemeMac::createPopupMenu):
+ (WebCore::RenderThemeMac::sizeOfArrowControl):
+ * rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::createPopupMenu):
+ * rendering/RenderThemeWin.h:
+
2006-07-05 Brady Eidson <beidson@apple.com>
Reviewed by Tim Omernick.
_wkGetMIMETypeForExtension
_wkGetNSFontATSUFontId
_wkInitializeGlyphVector
+_wkPopupMenu
_wkReleaseStyleGroup
_wkSetCGFontRenderingMode
_wkSetDragImage
AB4261D80A2F6C9700BDD17D /* missingImage.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AB4261D70A2F6C9700BDD17D /* missingImage.tiff */; };
AB67D1A8097F3AE300F9392E /* RenderTextField.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */; };
AB67D1A9097F3AE300F9392E /* RenderTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = AB67D1A7097F3AE300F9392E /* RenderTextField.h */; };
+ ABDDFE790A5C6E7000A3E11D /* RenderMenuList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */; };
+ ABDDFE7A0A5C6E7000A3E11D /* RenderMenuList.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */; };
+ ABDDFE7B0A5C6E7000A3E11D /* RenderPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABDDFE750A5C6E7000A3E11D /* RenderPopupMenu.cpp */; };
+ ABDDFE7C0A5C6E7000A3E11D /* RenderPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDFE760A5C6E7000A3E11D /* RenderPopupMenu.h */; };
+ ABDDFE7D0A5C6E7000A3E11D /* RenderPopupMenuMac.h in Headers */ = {isa = PBXBuildFile; fileRef = ABDDFE770A5C6E7000A3E11D /* RenderPopupMenuMac.h */; };
+ ABDDFE7E0A5C6E7000A3E11D /* RenderPopupMenuMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ABDDFE780A5C6E7000A3E11D /* RenderPopupMenuMac.mm */; };
ABE7B5230A489F830031881C /* DeprecatedRenderSelect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABE7B5210A489F830031881C /* DeprecatedRenderSelect.cpp */; };
ABE7B5240A489F830031881C /* DeprecatedRenderSelect.h in Headers */ = {isa = PBXBuildFile; fileRef = ABE7B5220A489F830031881C /* DeprecatedRenderSelect.h */; };
BC066F6F09FEB2FA00C589A7 /* WebCoreTextRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = BC066F6C09FEB2FA00C589A7 /* WebCoreTextRenderer.h */; settings = {ATTRIBUTES = (Private, ); }; };
AB4261D70A2F6C9700BDD17D /* missingImage.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = missingImage.tiff; sourceTree = "<group>"; };
AB67D1A6097F3AE300F9392E /* RenderTextField.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextField.cpp; sourceTree = "<group>"; };
AB67D1A7097F3AE300F9392E /* RenderTextField.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTextField.h; sourceTree = "<group>"; };
+ ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMenuList.cpp; sourceTree = "<group>"; };
+ ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderMenuList.h; sourceTree = "<group>"; };
+ ABDDFE750A5C6E7000A3E11D /* RenderPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPopupMenu.cpp; sourceTree = "<group>"; };
+ ABDDFE760A5C6E7000A3E11D /* RenderPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderPopupMenu.h; sourceTree = "<group>"; };
+ ABDDFE770A5C6E7000A3E11D /* RenderPopupMenuMac.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderPopupMenuMac.h; sourceTree = "<group>"; };
+ ABDDFE780A5C6E7000A3E11D /* RenderPopupMenuMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderPopupMenuMac.mm; sourceTree = "<group>"; };
ABE7B5210A489F830031881C /* DeprecatedRenderSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DeprecatedRenderSelect.cpp; sourceTree = "<group>"; };
ABE7B5220A489F830031881C /* DeprecatedRenderSelect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DeprecatedRenderSelect.h; sourceTree = "<group>"; };
BC066F6C09FEB2FA00C589A7 /* WebCoreTextRenderer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreTextRenderer.h; sourceTree = "<group>"; };
F523D2F302DE443B018635CA /* rendering */ = {
isa = PBXGroup;
children = (
+ ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */,
+ ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */,
+ ABDDFE750A5C6E7000A3E11D /* RenderPopupMenu.cpp */,
+ ABDDFE760A5C6E7000A3E11D /* RenderPopupMenu.h */,
+ ABDDFE770A5C6E7000A3E11D /* RenderPopupMenuMac.h */,
+ ABDDFE780A5C6E7000A3E11D /* RenderPopupMenuMac.mm */,
ABE7B5210A489F830031881C /* DeprecatedRenderSelect.cpp */,
ABE7B5220A489F830031881C /* DeprecatedRenderSelect.h */,
A8CFF04B0A154F09000A4234 /* AutoTableLayout.cpp */,
1A1D13800A5325520064BF5F /* DOMXPath.h in Headers */,
1A1D13CA0A5329090064BF5F /* DOMXPathInternal.h in Headers */,
93A1EAA80A563508006960A0 /* ImageDocumentMac.h in Headers */,
+ ABDDFE7A0A5C6E7000A3E11D /* RenderMenuList.h in Headers */,
+ ABDDFE7C0A5C6E7000A3E11D /* RenderPopupMenu.h in Headers */,
+ ABDDFE7D0A5C6E7000A3E11D /* RenderPopupMenuMac.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
516149ED0A525E3A003DFC7A /* SiteIcon.cpp in Sources */,
1A1D13810A5325520064BF5F /* DOMXPath.mm in Sources */,
93A1EAA00A5634C9006960A0 /* ImageDocumentMac.mm in Sources */,
+ ABDDFE790A5C6E7000A3E11D /* RenderMenuList.cpp in Sources */,
+ ABDDFE7B0A5C6E7000A3E11D /* RenderPopupMenu.cpp in Sources */,
+ ABDDFE7E0A5C6E7000A3E11D /* RenderPopupMenuMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
if (defaultParent)
parentStyle = defaultParent;
else
- parentStyle = (parentNode && parentNode->renderer()) ? parentNode->renderer()->style() : 0;
+ parentStyle = parentNode ? parentNode->renderStyle() : 0;
view = element->document()->view();
isXMLDoc = !element->document()->isHTMLDocument();
frame = element->document()->frame();
{
if (parent && parent->isStyledElement()) {
StyledElement* p = static_cast<StyledElement*>(parent);
- if (p->renderer() && !p->inlineStyleDecl() && !p->hasID()) {
+ if (!p->inlineStyleDecl() && !p->hasID()) {
Node* r = p->previousSibling();
int subcount = 0;
- RenderStyle* st = p->renderer()->style();
+ RenderStyle* st = p->renderStyle();
while (r) {
- if (r->renderer() && r->renderer()->style() == st)
+ if (r->renderStyle() == st)
return r->lastChild();
if (subcount++ == siblingThreshold)
return 0;
if (!r)
r = locateCousinList(static_cast<Element*>(parent->parentNode()));
while (r) {
- if (r->renderer() && r->renderer()->style() == st)
+ if (r->renderStyle() == st)
return r->lastChild();
if (subcount++ == siblingThreshold)
return 0;
{
if (n->isStyledElement()) {
StyledElement* s = static_cast<StyledElement*>(n);
- if (s->renderer() && !s->renderer()->style()->unique() &&
+ RenderStyle* style = s->renderStyle();
+ if (style && !style->unique() &&
(s->tagQName() == element->tagQName()) && !s->hasID() &&
(s->hasClass() == element->hasClass()) && !s->inlineStyleDecl() &&
(s->hasMappedAttributes() == styledElement->hasMappedAttributes()) &&
(s->isLink() == element->isLink()) &&
- !s->renderer()->style()->affectedByAttributeSelectors() &&
+ !style->affectedByAttributeSelectors() &&
(s->hovered() == element->hovered()) &&
(s->active() == element->active()) &&
(s->focused() == element->focused()) &&
Color linkColor = element->document()->linkColor();
Color visitedColor = element->document()->visitedLinkColor();
if (pseudoState == PseudoUnknown)
- checkPseudoState(element, s->renderer()->style()->pseudoState() != PseudoAnyLink ||
+ checkPseudoState(element, style->pseudoState() != PseudoAnyLink ||
linkColor != visitedColor);
- linksMatch = (pseudoState == s->renderer()->style()->pseudoState());
+ linksMatch = (pseudoState == style->pseudoState());
}
if (linksMatch)
for (n = element->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
while (n) {
if (canShareStyleWithElement(n))
- return n->renderer()->style();
+ return n->renderStyle();
if (count++ == siblingThreshold)
return 0;
for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
n = locateCousinList(static_cast<Element*>(element->parentNode()));
while (n) {
if (canShareStyleWithElement(n))
- return n->renderer()->style();
+ return n->renderStyle();
if (count++ == siblingThreshold)
return 0;
for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
if (strictParsing || isSubSelector || sel->relation() == CSSSelector::SubSelector || (sel->hasTag() && !e->hasTagName(aTag)) || e->isLink()) {
if (element == e && style)
style->setAffectedByHoverRules(true);
- if (e->renderer()) {
- if (element != e)
- e->renderer()->style()->setAffectedByHoverRules(true);
+ if (element != e && e->renderStyle())
+ e->renderStyle()->setAffectedByHoverRules(true);
if (e->hovered())
return true;
- }
}
break;
}
case CSSSelector::PseudoDrag: {
if (element == e && style)
style->setAffectedByDragRules(true);
- if (e->renderer()) {
- if (element != e)
- e->renderer()->style()->setAffectedByDragRules(true);
- if (e->renderer()->isDragging())
+ if (element != e && e->renderStyle())
+ e->renderStyle()->setAffectedByDragRules(true);
+ if (e->renderer() && e->renderer()->isDragging())
return true;
- }
break;
}
case CSSSelector::PseudoFocus:
if (strictParsing || isSubSelector || sel->relation() == CSSSelector::SubSelector || (sel->hasTag() && !e->hasTagName(aTag)) || e->isLink()) {
if (element == e && style)
style->setAffectedByActiveRules(true);
- else if (e->renderer())
- e->renderer()->style()->setAffectedByActiveRules(true);
+ else if (e->renderStyle())
+ e->renderStyle()->setAffectedByActiveRules(true);
if (e->active())
return true;
}
-webkit-user-select: ignore
}
-option, optgroup, area, param {
+area, param {
display: none
}
}
select {
+ // FIXME: Uncomment this when flipping the switch to use the new popup menu implementation
+ // -webkit-appearance: menulist;
box-sizing: border-box;
}
+optgroup {
+ font-weight: bolder;
+}
+
+option {
+ font-weight: normal;
+}
+
/* inline elements */
u, ins {
ContainerNode::attach();
}
-void Element::recalcStyle( StyleChange change )
+void Element::recalcStyle(StyleChange change)
{
// ### should go away and be done in renderobject
- RenderStyle* _style = renderer() ? renderer()->style() : 0;
- bool hasParentRenderer = parent() ? parent()->renderer() : false;
+ RenderStyle* _style = renderStyle();
+ bool hasParentStyle = parentNode() ? parentNode()->renderStyle() : false;
- if ( hasParentRenderer && (change >= Inherit || changed()) ) {
+ if (hasParentStyle && (change >= Inherit || changed())) {
RenderStyle *newStyle = document()->styleSelector()->styleForElement(this);
- StyleChange ch = diff( _style, newStyle );
+ StyleChange ch = diff(_style, newStyle);
if (ch == Detach) {
if (attached())
detach();
// ### Suboptimal. Style gets calculated again.
attach();
// attach recalulates the style for all children. No need to do it twice.
- setChanged( false );
- setHasChangedChild( false );
+ setChanged(false);
+ setHasChangedChild(false);
newStyle->deref(document()->renderArena());
return;
}
else if (ch != NoChange) {
- if (renderer() && newStyle)
- renderer()->setStyle(newStyle);
+ if (newStyle)
+ setRenderStyle(newStyle);
}
- else if (changed() && renderer() && newStyle && (document()->usesSiblingRules() || document()->usesDescendantRules())) {
+ else if (changed() && newStyle && (document()->usesSiblingRules() || document()->usesDescendantRules())) {
// Although no change occurred, we use the new style so that the cousin style sharing code won't get
// fooled into believing this style is the same. This is only necessary if the document actually uses
// sibling/descendant rules, since otherwise it isn't possible for ancestor styles to affect sharing of
// descendants.
- renderer()->setStyleInternal(newStyle);
+ if (renderer())
+ renderer()->setStyleInternal(newStyle);
+ else
+ setRenderStyle(newStyle);
}
newStyle->deref(document()->renderArena());
- if ( change != Force) {
+ if (change != Force) {
if (document()->usesDescendantRules())
change = Force;
else
n->recalcStyle(change);
}
- setChanged( false );
- setHasChangedChild( false );
+ setChanged(false);
+ setHasChangedChild(false);
}
bool Element::childTypeAllowed(NodeType type)
return 0;
}
+RenderStyle* Node::renderStyle()
+{
+ return m_renderer ? m_renderer->style() : 0;
+}
+
+void Node::setRenderStyle(RenderStyle* s) {
+ if (m_renderer)
+ m_renderer->setStyle(s);
+}
+
int Node::maxOffset() const
{
return 1;
virtual bool childShouldCreateRenderer(Node*) const { return true; }
#endif
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
+
+ // Wrapper for nodes that don't have a renderer, but still cache the style (like HTMLOptionElement).
+ virtual RenderStyle* renderStyle();
+ virtual void setRenderStyle(RenderStyle* s);
// -----------------------------------------------------------------------------
// Notification of document structure changes
#include "config.h"
#include "HTMLOptGroupElement.h"
+#include "Document.h"
+#include "cssstyleselector.h"
#include "HTMLSelectElement.h"
#include "HTMLNames.h"
+#include "RenderMenuList.h"
namespace WebCore {
HTMLOptGroupElement::HTMLOptGroupElement(Document* doc, HTMLFormElement* f)
: HTMLGenericFormElement(optgroupTag, doc, f)
-{
-}
-
-HTMLOptGroupElement::~HTMLOptGroupElement()
+ , m_style(0)
{
}
{
return newChild->hasTagName(HTMLNames::optionTag) || newChild->hasTagName(HTMLNames::hrTag);
}
+
+void HTMLOptGroupElement::attach()
+{
+ setRenderStyle(styleForRenderer(0));
+ HTMLGenericFormElement::attach();
+}
+
+void HTMLOptGroupElement::detach()
+{
+ if (m_style) {
+ m_style->deref(document()->renderArena());
+ m_style = 0;
+ }
+ HTMLGenericFormElement::detach();
+}
+
+void HTMLOptGroupElement::setRenderStyle( RenderStyle* newStyle )
+{
+ RenderStyle* oldStyle = m_style;
+ m_style = newStyle;
+ if (m_style)
+ m_style->ref();
+
+ if (oldStyle)
+ oldStyle->deref(document()->renderArena());
+}
+
+String HTMLOptGroupElement::groupLabelText()
+{
+ DeprecatedString itemText = getAttribute(labelAttr).deprecatedString();
+
+ itemText.replace('\\', document()->backslashAsCurrencySymbol());
+ // In WinIE, leading and trailing whitespace is ignored in options and optgroups. We match this behavior.
+ itemText = itemText.stripWhiteSpace();
+ // We want to collapse our whitespace too. This will match other browsers.
+ itemText = itemText.simplifyWhiteSpace();
+
+ return itemText;
+}
} // namespace
class HTMLOptGroupElement : public HTMLGenericFormElement {
public:
HTMLOptGroupElement(Document*, HTMLFormElement* = 0);
- virtual ~HTMLOptGroupElement();
virtual bool checkDTD(const Node*);
virtual const AtomicString& type() const;
virtual bool appendChild(PassRefPtr<Node> newChild, ExceptionCode&);
virtual ContainerNode* addChild(PassRefPtr<Node>);
virtual void parseMappedAttribute(MappedAttribute*);
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+ virtual void attach();
+ virtual void detach();
+ virtual RenderStyle* renderStyle() const { return m_style; }
+ virtual void setRenderStyle(RenderStyle* s);
void recalcSelectOptions();
String label() const;
void setLabel(const String&);
+
+ String groupLabelText();
+
+private:
+ RenderStyle* m_style;
};
} //namespace
#include "HTMLOptionElement.h"
#include "Document.h"
+#include "cssstyleselector.h"
#include "ExceptionCode.h"
#include "HTMLNames.h"
#include "HTMLSelectElement.h"
+#include "RenderMenuList.h"
#include "Text.h"
#include <wtf/Vector.h>
HTMLOptionElement::HTMLOptionElement(Document* doc, HTMLFormElement* f)
: HTMLGenericFormElement(optionTag, doc, f)
, m_selected(false)
+ , m_style(0)
{
}
return newChild->isTextNode() || newChild->hasTagName(scriptTag);
}
+void HTMLOptionElement::attach()
+{
+ setRenderStyle(styleForRenderer(0));
+ HTMLGenericFormElement::attach();
+}
+
+void HTMLOptionElement::detach()
+{
+ if (m_style) {
+ m_style->deref(document()->renderArena());
+ m_style = 0;
+ }
+ HTMLGenericFormElement::detach();
+}
+
bool HTMLOptionElement::isFocusable() const
{
return false;
setAttribute(labelAttr, value);
}
+void HTMLOptionElement::setRenderStyle( RenderStyle* newStyle )
+{
+ RenderStyle* oldStyle = m_style;
+ m_style = newStyle;
+ if (m_style)
+ m_style->ref();
+
+ if (oldStyle)
+ oldStyle->deref(document()->renderArena());
+}
+
+String HTMLOptionElement::optionText()
+{
+ DeprecatedString itemText = text().deprecatedString();
+ if (itemText.isEmpty())
+ itemText = getAttribute(labelAttr).deprecatedString();
+
+ itemText.replace('\\', document()->backslashAsCurrencySymbol());
+ // In WinIE, leading and trailing whitespace is ignored in options and optgroups. We match this behavior.
+ itemText = itemText.stripWhiteSpace();
+ // We want to collapse our whitespace too. This will match other browsers.
+ itemText = itemText.simplifyWhiteSpace();
+ if (parentNode() && parentNode()->hasTagName(optgroupTag))
+ itemText.prepend(" ");
+
+ return itemText;
+}
+
} // namespace
{
friend class DeprecatedRenderSelect;
friend class HTMLSelectElement;
+ friend class RenderMenuList;
public:
HTMLOptionElement(Document*, HTMLFormElement* = 0);
virtual int tagPriority() const { return 2; }
virtual bool checkDTD(const Node* newChild);
virtual bool isFocusable() const;
-
+ virtual bool rendererIsNeeded(RenderStyle*) { return false; }
+ virtual void attach();
+ virtual void detach();
+ virtual RenderStyle* renderStyle() const { return m_style; }
+ virtual void setRenderStyle(RenderStyle*);
+
virtual const AtomicString& type() const;
String text() const;
String label() const;
void setLabel(const String&);
+
+ String optionText();
private:
String m_value;
bool m_selected;
+ RenderStyle* m_style;
};
} //namespace
#include "CSSPropertyNames.h"
#include "Document.h"
+#include "DeprecatedRenderSelect.h"
#include "Event.h"
#include "EventNames.h"
#include "FormDataList.h"
#include "HTMLOptionElement.h"
#include "HTMLOptionsCollection.h"
#include "KeyboardEvent.h"
-#include "DeprecatedRenderSelect.h"
+#include "RenderMenuList.h"
#include "cssstyleselector.h"
#include <wtf/Vector.h>
void HTMLSelectElement::recalcStyle( StyleChange ch )
{
- if (hasChangedChild() && renderer())
- static_cast<DeprecatedRenderSelect*>(renderer())->setOptionsChanged(true);
+ if (hasChangedChild() && renderer()) {
+ if (shouldUseMenuList(renderer()->style()))
+ static_cast<RenderMenuList*>(renderer())->setOptionsChanged(true);
+ else
+ static_cast<DeprecatedRenderSelect*>(renderer())->setOptionsChanged(true);
+ }
HTMLGenericFormElement::recalcStyle( ch );
}
RenderObject *HTMLSelectElement::createRenderer(RenderArena *arena, RenderStyle *style)
{
+ if (shouldUseMenuList(style))
+ return new (arena) RenderMenuList(this);
return new (arena) DeprecatedRenderSelect(this);
}
void HTMLSelectElement::setRecalcListItems()
{
m_recalcListItems = true;
- if (renderer())
- static_cast<DeprecatedRenderSelect*>(renderer())->setOptionsChanged(true);
+ if (renderer()) {
+ if (shouldUseMenuList(renderer()->style()))
+ static_cast<RenderMenuList*>(renderer())->setOptionsChanged(true);
+ else
+ static_cast<DeprecatedRenderSelect*>(renderer())->setOptionsChanged(true);
+ }
setChanged();
}
}
if (!optionSelected && firstOption)
firstOption->setSelected(true);
- if (renderer())
- static_cast<DeprecatedRenderSelect*>(renderer())->setSelectionChanged(true);
+ if (renderer()) {
+ if (shouldUseMenuList(renderer()->style()))
+ static_cast<RenderMenuList*>(renderer())->setSelectionChanged(true);
+ else
+ static_cast<DeprecatedRenderSelect*>(renderer())->setSelectionChanged(true);
+ }
setChanged(true);
}
static_cast<HTMLOptionElement*>(items[i])->m_selected = (items[i] == selectedOption);
}
}
- if (renderer())
- static_cast<DeprecatedRenderSelect*>(renderer())->setSelectionChanged(true);
+ if (renderer()) {
+ if (shouldUseMenuList(renderer()->style()))
+ static_cast<RenderMenuList*>(renderer())->setSelectionChanged(true);
+ else
+ static_cast<DeprecatedRenderSelect*>(renderer())->setSelectionChanged(true);
+ }
setChanged(true);
}
evt->setDefaultHandled();
}
}
+ if (evt->type() == mousedownEvent && renderer() && shouldUseMenuList(renderer()->style()))
+ static_cast<RenderMenuList*>(renderer())->showPopup();
+
HTMLGenericFormElement::defaultEventHandler(evt);
}
#include "HTMLGenericFormElement.h"
#include "HTMLCollection.h"
+#include "render_style.h"
#include <wtf/Vector.h>
namespace WebCore {
class HTMLSelectElement : public HTMLGenericFormElement {
friend class DeprecatedRenderSelect;
+ friend class RenderMenuList;
public:
HTMLSelectElement(Document*, HTMLFormElement* = 0);
private:
void recalcListItems();
+ bool shouldUseMenuList(RenderStyle* style) { return !m_multiple && m_size <= 1 && style->appearance() == MenulistAppearance; }
mutable Vector<HTMLElement*> m_listItems;
int m_minwidth;
#ifndef __OBJC__
class NSImage;
+class NSMenu;
class NSString;
+class NSView;
#endif
#ifdef __cplusplus
extern NSString* (*wkGetMIMETypeForExtension)(NSString*);
extern ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
extern OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
+extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
extern void (*wkReleaseStyleGroup)(void* group);
extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
extern void (*wkSetDragImage)(NSImage*, NSPoint offset);
NSString* (*wkGetMIMETypeForExtension)(NSString*);
ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
+void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
void (*wkReleaseStyleGroup)(void* group);
void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
void (*wkSetDragImage)(NSImage*, NSPoint offset);
#include "RenderThemeWin.h"
#include "TextBoundaries.h"
#include "AccessibilityObjectCache.h"
+#include "RenderPopupMenuWin.h"
using namespace WebCore;
void Frame::setNeedsReapplyStyles() { }
void Image::drawTiled(GraphicsContext*, const FloatRect&, const FloatRect&, TileRule, TileRule, CompositeOperator) { }
+
+RenderPopupMenuWin::RenderPopupMenuWin(Node*) { notImplemented();}
+RenderPopupMenuWin::~RenderPopupMenuWin() { notImplemented(); }
+void RenderPopupMenuWin::clear() { notImplemented(); }
+void RenderPopupMenuWin::populate() { notImplemented(); }
+void RenderPopupMenuWin::showPopup(const IntRect&, FrameView*, int index) { notImplemented(); }
+void RenderPopupMenuWin::addSeparator() { notImplemented(); }
+void RenderPopupMenuWin::addGroupLabel(HTMLOptGroupElement*) { notImplemented(); }
+void RenderPopupMenuWin::addOption(HTMLOptionElement*) { notImplemented(); }
+
+bool RenderThemeWin::paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&) { notImplemented(); return false; }
+void RenderThemeWin::adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const { notImplemented(); }
--- /dev/null
+/**
+ * This file is part of the select element renderer in WebCore.
+ *
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderMenuList.h"
+
+#include "Document.h"
+#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "RenderPopupMenu.h"
+#include "RenderText.h"
+#include "RenderTheme.h"
+#include <math.h>
+
+namespace WebCore {
+
+using namespace HTMLNames;
+using namespace std;
+
+RenderMenuList::RenderMenuList(HTMLSelectElement* element)
+ : RenderFlexibleBox(element)
+ , m_buttonText(0)
+ , m_inner(0)
+ , m_popupMenu(0)
+ , m_size(element->size())
+ , m_selectionChanged(true)
+ , m_optionsChanged(true)
+ , m_longestWidth(0)
+ , m_selectedIndex(0)
+{
+}
+
+void RenderMenuList::addChild(RenderObject* newChild, RenderObject* beforeChild)
+{
+ if (!m_inner) {
+ // Create an anonymous block.
+ assert(!m_first);
+ m_inner = createAnonymousBlock();
+ m_inner->style()->setBoxFlex(1.0f);
+ RenderFlexibleBox::addChild(m_inner);
+ }
+ m_inner->addChild(newChild, beforeChild);
+}
+
+void RenderMenuList::removeChild(RenderObject* oldChild)
+{
+ if (oldChild == m_inner || !m_inner) {
+ RenderFlexibleBox::removeChild(oldChild);
+ m_inner = 0;
+ }
+ else
+ m_inner->removeChild(oldChild);
+}
+
+void RenderMenuList::setStyle(RenderStyle* style)
+{
+ style->setPaddingLeft(Length(10, Fixed));
+ style->setPaddingRight(Length(8, Fixed));
+ RenderBlock::setStyle(style);
+ if (m_buttonText)
+ m_buttonText->setStyle(style);
+ if (m_inner)
+ m_inner->style()->setBoxFlex(1.0f);
+ if (m_popupMenu) {
+ RenderStyle *newStyle = new (renderArena()) RenderStyle();
+ newStyle->inheritFrom(style);
+ m_popupMenu->setStyle(newStyle);
+ }
+ setReplaced(isInline());
+}
+
+void RenderMenuList::updateFromElement()
+{
+ if (m_optionsChanged) {
+ HTMLSelectElement* select = static_cast<HTMLSelectElement*>(node());
+ if (select->m_recalcListItems)
+ select->recalcListItems();
+
+ Vector<HTMLElement*> listItems = select->listItems();
+ bool found = false;
+ unsigned firstOption = listItems.size();
+ int i = listItems.size();
+ m_longestWidth = 0;
+ while (i--)
+ if (listItems[i]->hasTagName(optionTag)) {
+ HTMLOptionElement* element = static_cast<HTMLOptionElement*>(listItems[i]);
+ String text = element->optionText();
+ float stringWidth = (text.isNull() || text.isEmpty()) ? 0 : style()->font().floatWidth(TextRun(text.impl()), TextStyle(0, 0, 0, false, false, false, false));
+ if (stringWidth > m_longestWidth)
+ m_longestWidth = stringWidth;
+ if (found)
+ element->m_selected = false;
+ else if (element->selected()) {
+ setText(text);
+ m_selectedIndex = i;
+ found = true;
+ }
+ firstOption = i;
+ }
+ m_optionsChanged = false;
+ }
+}
+
+void RenderMenuList::setText(String s)
+{
+ if (s.isEmpty()) {
+ if (m_buttonText) {
+ m_buttonText->destroy();
+ m_buttonText = 0;
+ }
+ } else {
+ if (m_buttonText)
+ m_buttonText->setText(s.impl());
+ else {
+ m_buttonText = new (renderArena()) RenderText(document(), s.impl());
+ m_buttonText->setStyle(style());
+ addChild(m_buttonText);
+ }
+ }
+}
+
+void RenderMenuList::paintObject(PaintInfo& i, int _tx, int _ty)
+{
+ // Push a clip.
+ if (m_inner && i.phase == PaintPhaseForeground) {
+ IntRect clipRect(_tx + borderLeft(), _ty + borderTop(),
+ width() - borderLeft() - borderRight(), height() - borderBottom() - borderTop());
+ if (clipRect.width() == 0 || clipRect.height() == 0)
+ return;
+ i.p->save();
+ i.p->addClip(clipRect);
+ }
+
+ // Paint the children.
+ RenderBlock::paintObject(i, _tx, _ty);
+
+ // Pop the clip.
+ if (m_inner && i.phase == PaintPhaseForeground)
+ i.p->restore();
+}
+
+
+short RenderMenuList::baselinePosition(bool f, bool b) const
+{
+ return RenderFlexibleBox::baselinePosition(f, b);
+}
+
+void RenderMenuList::calcMinMaxWidth()
+{
+ if (m_optionsChanged)
+ updateFromElement();
+
+ m_minWidth = 0;
+ m_maxWidth = 0;
+
+ if (style()->width().isFixed() && style()->width().value() > 0)
+ m_minWidth = m_maxWidth = calcContentBoxWidth(style()->width().value());
+ else
+ m_maxWidth = m_longestWidth;
+
+ if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
+ m_maxWidth = max(m_maxWidth, calcContentBoxWidth(style()->minWidth().value()));
+ m_minWidth = max(m_minWidth, calcContentBoxWidth(style()->minWidth().value()));
+ } else if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent()))
+ m_minWidth = 0;
+ else
+ m_minWidth = m_maxWidth;
+
+ if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
+ m_maxWidth = min(m_maxWidth, calcContentBoxWidth(style()->maxWidth().value()));
+ m_minWidth = min(m_minWidth, calcContentBoxWidth(style()->maxWidth().value()));
+ }
+
+ int toAdd = paddingLeft() + paddingRight() + borderLeft() + borderRight() + theme()->sizeOfArrowControl(style());
+ m_minWidth += toAdd;
+ m_maxWidth += toAdd;
+
+ setMinMaxKnown();
+}
+
+void RenderMenuList::showPopup()
+{
+ if (!m_popupMenu) {
+ RenderStyle *newStyle = new (renderArena()) RenderStyle();
+ newStyle->inheritFrom(style());
+ m_popupMenu = theme()->createPopupMenu(renderArena(), document());
+ m_popupMenu->setStyle(newStyle);
+ RenderFlexibleBox::addChild(m_popupMenu);
+ }
+ m_popupMenu->showPopup(absoluteBoundingBoxRect(), document()->view(), m_selectedIndex);
+ m_popupMenu->destroy();
+ m_popupMenu = 0;
+}
+
+void RenderMenuList::layout()
+{
+ RenderFlexibleBox::layout();
+}
+
+
+void RenderMenuList::updateSelection()
+{
+
+}
+
+void RenderMenuList::valueChanged(unsigned index)
+{
+ m_selectedIndex = index;
+ Vector<HTMLElement*> listItems = static_cast<HTMLSelectElement*>(node())->listItems();
+
+ for (unsigned i = 0; i < listItems.size(); ++i)
+ if (listItems[i]->hasTagName(optionTag) && i != index)
+ static_cast<HTMLOptionElement*>(listItems[i])->m_selected = false;
+
+ HTMLOptionElement* element = static_cast<HTMLOptionElement*>(listItems[index]);
+ element->m_selected = true;
+
+ setText(element->optionText());
+
+ static_cast<HTMLSelectElement*>(node())->onChange();
+}
+
+}
--- /dev/null
+/*
+ * This file is part of the select element renderer in WebCore.
+ *
+ * Copyright (C) 2006 Apple Computer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RenderMenuList_H
+#define RenderMenuList_H
+
+#include "RenderButton.h"
+#include "HTMLSelectElement.h"
+
+namespace WebCore {
+
+class RenderPopupMenu;
+
+class RenderMenuList : public RenderFlexibleBox
+{
+public:
+ RenderMenuList(HTMLSelectElement*);
+
+ virtual void addChild(RenderObject* newChild, RenderObject *beforeChild = 0);
+ virtual void removeChild(RenderObject* oldChild);
+ virtual void removeLeftoverAnonymousBoxes() {}
+ virtual bool allowsReusingAnonymousChild() const { return false; }
+ virtual bool canHaveChildren() const { return false; }
+
+ virtual void setStyle(RenderStyle*);
+ virtual void updateFromElement();
+
+ virtual void paintObject(PaintInfo&, int tx, int ty);
+
+ virtual const char* renderName() const { return "RenderMenuList"; }
+
+ short baselinePosition(bool f, bool b) const;
+ virtual void calcMinMaxWidth();
+ virtual void layout();
+
+ void setOptionsChanged(bool o) { m_optionsChanged = o; }
+
+ bool selectionChanged() { return m_selectionChanged; }
+ void setSelectionChanged(bool selectionChanged) { m_selectionChanged = selectionChanged; }
+ void updateSelection();
+
+ void showPopup();
+ void valueChanged(unsigned index);
+ bool hasPopupMenu() { return m_popupMenu; }
+
+protected:
+ void setText(String);
+
+ RenderText* m_buttonText;
+ RenderBlock* m_inner;
+ RenderPopupMenu* m_popupMenu;
+
+ unsigned m_size;
+ bool m_selectionChanged;
+ bool m_optionsChanged;
+ float m_longestWidth;
+ int m_selectedIndex;
+};
+
+}
+
+#endif
--- /dev/null
+/**
+ * This file is part of the popup menu implementation for <select> elements in WebCore.
+ *
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include "RenderPopupMenu.h"
+
+#include "HTMLNames.h"
+#include "HTMLOptionElement.h"
+#include "HTMLOptGroupElement.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderPopupMenu::RenderPopupMenu(Node* element)
+ : RenderBlock(element)
+{
+}
+
+void RenderPopupMenu::populate()
+{
+ RenderMenuList* select = getRenderMenuList();
+ ASSERT(select);
+ if (!select->node())
+ return;
+ for (Node* n = select->node()->firstChild(); n; n = n->traverseNextNode(select->node())) {
+ if (n->hasTagName(optionTag))
+ addOption(static_cast<HTMLOptionElement*>(n));
+ else if (n->hasTagName(optgroupTag))
+ addGroupLabel(static_cast<HTMLOptGroupElement*>(n));
+ else if (n->hasTagName(hrTag))
+ addSeparator();
+ }
+}
+
+}
--- /dev/null
+/*
+ * This file is part of the popup menu implementation for <select> elements in WebCore.
+ *
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RENDER_POPUPMENU_H
+#define RENDER_POPUPMENU_H
+
+#include "RenderBlock.h"
+#include "RenderMenuList.h"
+
+namespace WebCore {
+
+class HTMLOptionElement;
+class HTMLOptGroupElement;
+
+class RenderPopupMenu : public RenderBlock {
+public:
+ RenderPopupMenu(Node*);
+ virtual ~RenderPopupMenu() {}
+
+ virtual const char* renderName() const { return "RenderPopupMenu"; }
+
+ virtual void clear() = 0;
+ virtual void populate();
+ virtual void showPopup(const IntRect&, FrameView*, int index) = 0;
+
+ RenderMenuList* getRenderMenuList() { return static_cast<RenderMenuList*>(parent() ? parent()->parent() : 0); }
+
+protected:
+ virtual void addSeparator() = 0;
+ virtual void addGroupLabel(HTMLOptGroupElement*) = 0;
+ virtual void addOption(HTMLOptionElement*) = 0;
+
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ * This file is part of the popup menu implementation for <select> elements in WebCore.
+ *
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RENDER_POPUPMENU_MAC_H
+#define RENDER_POPUPMENU_MAC_H
+
+#import "RenderPopupMenu.h"
+#import <AppKit/NSPopUpButtonCell.h>
+
+namespace WebCore {
+
+class RenderPopupMenuMac : public RenderPopupMenu {
+public:
+ RenderPopupMenuMac(Node*);
+ ~RenderPopupMenuMac();
+
+ virtual void clear();
+ virtual void showPopup(const IntRect&, FrameView*, int index);
+ virtual void populate();
+
+protected:
+ virtual void addSeparator();
+ virtual void addGroupLabel(HTMLOptGroupElement*);
+ virtual void addOption(HTMLOptionElement*);
+
+ NSPopUpButtonCell* popup;
+
+};
+
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+/*
+ * This file is part of the popup menu implementation for <select> elements in WebCore.
+ *
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#import "config.h"
+#import "RenderPopupMenuMac.h"
+
+#import "FrameView.h"
+#import "HTMLNames.h"
+#import "HTMLOptionElement.h"
+#import "HTMLOptGroupElement.h"
+#import "RenderMenuList.h"
+#import "WebCoreSystemInterface.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+RenderPopupMenuMac::RenderPopupMenuMac(Node* element)
+ : RenderPopupMenu(element)
+ , popup(nil)
+{
+}
+
+RenderPopupMenuMac::~RenderPopupMenuMac()
+{
+ if (popup) {
+ [popup setControlView: nil];
+ [popup release];
+ }
+}
+
+void RenderPopupMenuMac::clear()
+{
+ if (popup)
+ [popup removeAllItems];
+}
+
+void RenderPopupMenuMac::populate()
+{
+ BOOL messagesEnabled = [[popup menu] menuChangedMessagesEnabled];
+ [[popup menu] setMenuChangedMessagesEnabled:NO];
+ RenderPopupMenu::populate();
+ [[popup menu] setMenuChangedMessagesEnabled:messagesEnabled];
+
+}
+
+void RenderPopupMenuMac::showPopup(const IntRect& r, FrameView* v, int index)
+{
+ if (!popup) {
+ popup = [[[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO] retain];
+ [popup setUsesItemFromMenu:NO];
+ [popup setAutoenablesItems:NO];
+ }
+ // If we decide to cache the NSMenuItems, we shouldn't clear and populate every time we show the popup menu
+ clear();
+ populate();
+
+ if ([popup numberOfItems] <= 0)
+ return;
+
+ ASSERT([popup numberOfItems] > index);
+
+ NSView* view = v->getDocumentView();
+ [popup attachPopUpWithFrame:r inView:view];
+
+ [popup selectItemAtIndex:index];
+
+ NSPoint location = NSMakePoint(NSMinX(r), NSMaxY(r));
+ float vertOffset;
+
+ //center it in our title frame
+ NSRect titleFrame = [popup titleRectForBounds:r];
+ if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0)
+ titleFrame = r;
+ NSFont* font = style()->font().getNSFont();
+ NSSize sizeOfSelectedItem = titleFrame.size;
+
+ vertOffset = round((NSMaxY(r) - NSMaxY(titleFrame)) + (NSHeight(titleFrame) + sizeOfSelectedItem.height)/2.f);
+
+ //Align us for different fonts
+ NSFont* defaultFont = [NSFont systemFontOfSize:[font pointSize]];
+ vertOffset += [font descender] - [defaultFont descender];
+
+ vertOffset = fmin(NSHeight(r), vertOffset);
+
+ location.x -= 10;
+ location.y -= vertOffset;
+
+// NSColor* backgroundColor = nsColor(style()->backgroundColor());
+ NSMenu* menu = [popup menu];
+
+ wkPopupMenu(menu, location, floor(NSWidth(r) + 0.5), view, index, font);
+
+ // update text on button
+ int newIndex = [popup indexOfSelectedItem];
+ if (index != newIndex && newIndex >= 0)
+ getRenderMenuList()->valueChanged(newIndex);
+
+ [popup dismissPopUp];
+}
+
+void RenderPopupMenuMac::addSeparator()
+{
+ NSMenuItem *separator = [NSMenuItem separatorItem];
+ [[popup menu] addItem:separator];
+}
+
+void RenderPopupMenuMac::addGroupLabel(HTMLOptGroupElement* element)
+{
+ if (!element)
+ return;
+ String text = element->groupLabelText();
+
+ [popup addItemWithTitle:@""];
+ NSMenuItem *menuItem = [popup lastItem];
+
+ RenderStyle* s = element->renderStyle();
+ if (!s)
+ s = style();
+
+ NSMutableDictionary* attributes = [[NSMutableDictionary alloc] init];
+ if (s->font() != Font())
+ [attributes setObject:s->font().getNSFont() forKey:NSFontAttributeName];
+ [attributes setObject:nsColor(s->color()) forKey:NSForegroundColorAttributeName];
+ NSAttributedString *string = [[NSAttributedString alloc] initWithString:text attributes:attributes];
+
+ [menuItem setAttributedTitle:string];
+ [string release];
+ [attributes release];
+ [menuItem setEnabled:NO];
+}
+
+void RenderPopupMenuMac::addOption(HTMLOptionElement* element)
+{
+ if (!element)
+ return;
+ String text = element->optionText();
+
+ bool groupEnabled = true;
+ if (element->parentNode() && element->parentNode()->hasTagName(optgroupTag))
+ groupEnabled = element->parentNode()->isEnabled();
+
+ [popup addItemWithTitle:@""];
+ NSMenuItem *menuItem = [popup lastItem];
+
+ RenderStyle* s = element->renderStyle();
+ if (!s)
+ s = style();
+
+ NSMutableDictionary* attributes = [[NSMutableDictionary alloc] init];
+ if (s->font() != Font())
+ [attributes setObject:s->font().getNSFont() forKey:NSFontAttributeName];
+ [attributes setObject:nsColor(s->color()) forKey:NSForegroundColorAttributeName];
+ NSAttributedString *string = [[NSAttributedString alloc] initWithString:text attributes:attributes];
+
+ [menuItem setAttributedTitle:string];
+ [string release];
+ [attributes release];
+ [menuItem setEnabled:groupEnabled && element->isEnabled()];
+
+}
+
+}
--- /dev/null
+/*
+ * This file is part of the popup menu implementation for <select> elements in WebCore.
+ *
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef RENDER_POPUPMENU_WIN_H
+#define RENDER_POPUPMENU_WIN_H
+
+#include "RenderPopupMenu.h"
+
+namespace WebCore {
+
+class HTMLOptionElement;
+class HTMLOptGroupElement;
+
+class RenderPopupMenuWin : public RenderPopupMenu {
+public:
+ RenderPopupMenuWin(Node*);
+ ~RenderPopupMenuWin();
+
+ virtual void clear();
+ virtual void populate();
+ virtual void showPopup(const IntRect&, FrameView*, int index);
+
+protected:
+ virtual void addSeparator();
+ virtual void addGroupLabel(HTMLOptGroupElement*);
+ virtual void addOption(HTMLOptionElement*);
+
+};
+
+}
+
+#endif
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "render_style.h"
+#include "RenderPopupMenu.h"
// The methods in this file are shared by all themes on every platform.
return adjustTextFieldStyle(selector, style, e);
case TextAreaAppearance:
return adjustTextAreaStyle(selector, style, e);
+ case MenulistAppearance:
+ return adjustMenuListStyle(selector, style, e);
default:
break;
}
case SquareButtonAppearance:
case ButtonAppearance:
return paintButton(o, i, r);
+ case MenulistAppearance:
+ return paintMenuList(o, i, r);
case TextFieldAppearance:
case TextAreaAppearance:
return true;
case PushButtonAppearance:
case SquareButtonAppearance:
case ButtonAppearance:
+ case MenulistAppearance:
default:
break;
}
case PushButtonAppearance:
case SquareButtonAppearance:
case ButtonAppearance:
+ case MenulistAppearance:
case TextFieldAppearance:
case TextAreaAppearance: {
// Test the style to see if the UA border and background match.
{
}
+void RenderTheme::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+}
+
}
namespace WebCore {
class Element;
+class RenderPopupMenu;
+
enum ControlState { HoverState, PressedState, FocusState, EnabledState, CheckedState, ReadOnlyState };
class RenderTheme {
virtual Color platformActiveSelectionForegroundColor() const;
virtual Color platformInactiveSelectionForegroundColor() const;
+ virtual int sizeOfArrowControl(RenderStyle*) const { return 0; }
+ virtual RenderPopupMenu* createPopupMenu(RenderArena*, Document*) = 0;
+
protected:
// Methods for state querying
bool isChecked(const RenderObject* o) const;
virtual void adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const;
virtual bool paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return true; }
+
+ virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const;
+ virtual bool paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { return true; }
+
};
// Function to obtain the theme. This is implemented in your platform-specific theme implementation to hand
namespace WebCore {
class RenderStyle;
+class RenderPopupMenu;
class RenderThemeMac : public RenderTheme {
public:
virtual Color platformActiveSelectionBackgroundColor() const;
virtual Color platformInactiveSelectionBackgroundColor() const;
+
+ virtual int sizeOfArrowControl(RenderStyle*) const;
+ virtual RenderPopupMenu* createPopupMenu(RenderArena*, Document*);
protected:
// Methods for each appearance value.
virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+ virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+ virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+
private:
IntRect inflateRect(const IntRect&, const IntSize&, const int* margins) const;
const IntSize* buttonSizes() const;
const int* buttonMargins() const;
void setButtonCellState(const RenderObject*, const IntRect&);
+
+ void setPopupButtonCellState(const RenderObject*, const IntRect&);
private:
NSButtonCell* checkbox;
NSButtonCell* radio;
NSButtonCell* button;
+ NSPopUpButtonCell* popupButton;
Image* resizeCornerImage;
};
#import "RenderView.h"
#import "WebCoreSystemInterface.h"
#import "cssstyleselector.h"
+#import "RenderPopupMenuMac.h"
// The methods in this file are specific to the Mac OS X platform.
r = inflateRect(r, buttonSizes()[[button controlSize]], buttonMargins());
break;
}
+ case MenulistAppearance: {
+ setPopupButtonCellState(o, r);
+ break;
+ }
default:
break;
}
addIntrinsicMargins(style, NSRegularControlSize);
}
+bool RenderThemeMac::paintMenuList(RenderObject* o, const RenderObject::PaintInfo&, const IntRect& r)
+{
+ setPopupButtonCellState(o, r);
+
+ [popupButton drawWithFrame:r inView:o->view()->frameView()->getDocumentView()];
+ [popupButton setControlView:nil];
+ return false;
+}
+
+void RenderThemeMac::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ NSControlSize controlSize = controlSizeForFont(style);
+
+ // Add in intrinsic margins
+ addIntrinsicMargins(style, controlSize);
+
+ // Height is locked to auto.
+ style->setHeight(Length(Auto));
+
+ // White-space is locked to pre
+ style->setWhiteSpace(PRE);
+
+ if (controlSize != NSMiniControlSize) {
+ style->setPaddingTop(Length(2, Fixed));
+ style->setPaddingBottom(Length(5, Fixed));
+ }
+
+ // Our font is locked to the appropriate system font size for the control. To clarify, we first use the CSS-specified font to figure out
+ // a reasonable control size, but once that control size is determined, we throw that font away and use the appropriate
+ // system font for the control size instead.
+ setFontFromControlSize(selector, style, controlSize);
+}
+
+void RenderThemeMac::setPopupButtonCellState(const RenderObject* o, const IntRect& r)
+{
+ if (!popupButton) {
+ popupButton = KWQRetainNSRelease([[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO]);
+ [popupButton setUsesItemFromMenu:NO];
+ }
+
+ // Set the control size based off the rectangle we're painting into.
+ RenderThemeMac::setControlSize(popupButton, buttonSizes(), IntSize(r.width(), r.height()));
+
+ // Update the various states we respond to.
+ updateCheckedState(popupButton, o);
+ updateEnabledState(popupButton, o);
+ updatePressedState(popupButton, o);
+ updateFocusedState(popupButton, o);
+}
+
+RenderPopupMenu* RenderThemeMac::createPopupMenu(RenderArena* arena, Document* doc)
+{
+ return new (arena) RenderPopupMenuMac(doc);
+}
+
+int RenderThemeMac::sizeOfArrowControl(RenderStyle* style) const
+{
+ NSControlSize controlSize = controlSizeForFont(style);
+
+ switch (controlSize) {
+ case NSRegularControlSize:
+ return 26;
+ case NSSmallControlSize:
+ return 20;
+ case NSMiniControlSize:
+ return 16;
+ }
+ return 0;
+}
+
}
return paintTextField(o, i, r);
}
+RenderPopupMenu* RenderThemeWin::createPopupMenu(RenderArena* arena, Document* doc)
+{
+ return new (arena) RenderPopupMenuWin(doc);
+}
+
}
virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, WebCore::Element*) const;
virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+ virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+ virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+ virtual RenderPopupMenu* createPopupMenu(RenderArena*, Document*);
+
private:
void addIntrinsicMargins(RenderStyle*) const;
void close();
+2006-07-05 Adele Peterson <adele@apple.com>
+
+ Reviewed by Maciej and Hyatt.
+
+ WebKit part of initial popup menu implementation.
+
+ * WebCoreSupport/WebSystemInterface.m: (InitWebCoreSystemInterface):
+ Initialize WKPopupMenu.
+
2006-07-05 Anders Carlsson <acarlsson@apple.com>
Reviewed by Maciej.
* WebKit.LP64.exp: Added.
* WebKit.xcodeproj/project.pbxproj:
->>>>>>> .r15169
2006-07-04 Timothy Hatcher <timothy@apple.com>
Reviewed by Maciej.
INIT(GetMIMETypeForExtension);
INIT(GetNSFontATSUFontId);
INIT(InitializeGlyphVector);
+ INIT(PopupMenu);
INIT(ReleaseStyleGroup);
INIT(SetCGFontRenderingMode);
INIT(SetDragImage);
+2006-07-05 Adele Peterson <adele@apple.com>
+
+ Reviewed by Maciej and Hyatt.
+
+ * WebKitSystemInterface.h: Updated.
+ * libWebKitSystemInterface.a: Updated.
+
2006-06-16 Adele Peterson <adele@apple.com>
Reviewed by Alice.
void WKDrawBezeledTextFieldCell(NSRect, BOOL enabled);
void WKDrawBezeledTextArea(NSRect, BOOL enabled);
+void WKPopupMenu(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
void WKSendUserChangeNotifications(void);
BOOL WKConvertNSEventToCarbonEvent(EventRecord *carbonEvent, NSEvent *cocoaEvent);