Commit f989049f authored by adele's avatar adele

Reviewed by Adam.

        Initial implementation of engine-based list box control.

        * WebCore.xcodeproj/project.pbxproj: Added RenderListBox.h and RenderListBox.cpp

        * bridge/mac/FrameMac.h: Added _mouseDownMayStartAutoscroll.
        * bridge/mac/FrameMac.mm: Updated autoscroll code to use renderers instead of layers, so any renderer that implements autoscroll will work.
        (WebCore::FrameMac::FrameMac):
        (WebCore::FrameMac::handleMousePressEvent):
        (WebCore::FrameMac::handleMouseMoveEvent):
        (WebCore::FrameMac::mouseDown):

        * page/Frame.cpp:
        (WebCore::Frame::handleMouseMoveEvent):
        (WebCore::Frame::scrollOverflow): Don't scroll list box here- this would cause arrow keys to scroll instead of select.
        (WebCore::Frame::handleAutoscroll): Updated to use a renderer instead of a layer when setting up autoscroll.
        (WebCore::Frame::autoscrollTimerFired): ditto.
        (WebCore::Frame::stopAutoscrollTimer): ditto.
        (WebCore::Frame::passWidgetMouseDownEventToWidget): Updated to check for list box's scroll bar.
        * page/Frame.h:
        * page/FramePrivate.h: (WebCore::FramePrivate::FramePrivate): Updated to use renderer unstead of layer for autoscroll.

        * page/FrameView.cpp: Keep track of current mouse position so this can be used for list box autoscroll.
        (WebCore::FrameViewPrivate::reset):
        (WebCore::FrameView::currentMousePosition):
        (WebCore::FrameView::handleMousePressEvent):
        (WebCore::FrameView::handleMouseDoubleClickEvent):
        (WebCore::selectCursor):
        (WebCore::FrameView::handleMouseMoveEvent):
        (WebCore::FrameView::handleMouseReleaseEvent):
        * page/FrameView.h:

        * platform/ScrollBar.cpp: (WebCore::ScrollBar::ScrollBar): Added controlSize argument.  The list box will use a smaller scroll bar size.
        * platform/ScrollBar.h:
        (WebCore::):
        (WebCore::ScrollBar::controlSize):
        * platform/mac/PlatformScrollBar.h:
        * platform/mac/PlatformScrollBarMac.mm:
        (NSControlSizeForScrollBarControlSize):
        (-[WebCoreScrollBar initWithPlatformScrollBar:]):
        (WebCore::PlatformScrollBar::PlatformScrollBar):

        * rendering/RenderBlock.h:
        * rendering/RenderLayer.cpp: (WebCore::RenderLayer::createScrollbar): Updated to pass regular control size to scrollbar constructor.
        * rendering/RenderLayer.h:
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::shouldAutoscroll):
        (WebCore::RenderObject::autoscroll):
        * rendering/RenderObject.h: (WebCore::RenderObject::isListBox):

        * css/html4.css: Added properties for new list boxes.

        * html/HTMLOptionElement.cpp:
        (WebCore::HTMLOptionElement::setSelected): Doesn't allow selection to be changed here if the option is disabled.
        (WebCore::HTMLOptionElement::disabled): Added. Checks the parent's disabled status.
        * html/HTMLOptionElement.h: Added disabled method.

        * html/HTMLSelectElement.cpp: Added appearance switch for new list box implementation.
        (WebCore::HTMLSelectElement::recalcStyle):
        (WebCore::HTMLSelectElement::lastSelectedListIndex):
        (WebCore::HTMLSelectElement::deselectItems):
        (WebCore::HTMLSelectElement::setSelectedIndex):
        (WebCore::HTMLSelectElement::isKeyboardFocusable):
        (WebCore::HTMLSelectElement::isMouseFocusable):
        (WebCore::HTMLSelectElement::createRenderer):
        (WebCore::HTMLSelectElement::recalcListItems):
        (WebCore::HTMLSelectElement::setRecalcListItems):
        (WebCore::HTMLSelectElement::reset):
        (WebCore::HTMLSelectElement::notifyOptionSelected):
        (WebCore::HTMLSelectElement::defaultEventHandler): Added code to select options for list box when clicking and using arrow keys.
        (WebCore::HTMLSelectElement::nextSelectableListIndex):
        (WebCore::HTMLSelectElement::previousSelectableListIndex):
        * html/HTMLSelectElement.h:

        * rendering/RenderTheme.cpp: Added support for ListBoxAppearance
        (WebCore::RenderTheme::paint):
        (WebCore::RenderTheme::paintBorderOnly):
        (WebCore::RenderTheme::paintDecorations):
        (WebCore::RenderTheme::activeListBoxSelectionBackgroundColor):
        (WebCore::RenderTheme::activeListBoxSelectionForegroundColor):
        (WebCore::RenderTheme::inactiveListBoxSelectionBackgroundColor):
        (WebCore::RenderTheme::inactiveListBoxSelectionForegroundColor):
        (WebCore::RenderTheme::isControlStyled):
        (WebCore::RenderTheme::supportsFocusRing):
        * rendering/RenderTheme.h:
        * rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::isControlStyled):

        * rendering/RenderListBox.cpp: Added.
        (WebCore::RenderListBox::RenderListBox):
        (WebCore::RenderListBox::~RenderListBox):
        (WebCore::RenderListBox::setStyle):
        (WebCore::RenderListBox::updateFromElement):
        (WebCore::RenderListBox::calcMinMaxWidth):
        (WebCore::RenderListBox::size):
        (WebCore::RenderListBox::numItems):
        (WebCore::RenderListBox::calcHeight):
        (WebCore::RenderListBox::baselinePosition):
        (WebCore::RenderListBox::itemBoundingBoxRect):
        (WebCore::RenderListBox::paintObject):
        (WebCore::RenderListBox::paintScrollbar):
        (WebCore::RenderListBox::paintItemForeground):
        (WebCore::RenderListBox::paintItemBackground):
        (WebCore::RenderListBox::scrollBarTarget):
        (WebCore::RenderListBox::isPointInScrollbar):
        (WebCore::RenderListBox::optionAtPoint):
        (WebCore::RenderListBox::autoscroll):
        (WebCore::RenderListBox::scrollToRevealElementAtListIndex):
        (WebCore::RenderListBox::scroll):
        (WebCore::RenderListBox::valueChanged):
        * rendering/RenderListBox.h: Added.
        (WebCore::RenderListBox::isListBox):
        (WebCore::RenderListBox::selectionChanged):
        (WebCore::RenderListBox::setSelectionChanged):
        (WebCore::RenderListBox::canHaveChildren):
        (WebCore::RenderListBox::renderName):
        (WebCore::RenderListBox::setOptionsChanged):
        (WebCore::RenderListBox::shouldAutoscroll):
        (WebCore::RenderListBox::listIndexIsVisible):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9d05e15f
2006-09-29 Adele Peterson <adele@apple.com>
Reviewed by Adam.
Initial implementation of engine-based list box control.
* WebCore.xcodeproj/project.pbxproj: Added RenderListBox.h and RenderListBox.cpp
* bridge/mac/FrameMac.h: Added _mouseDownMayStartAutoscroll.
* bridge/mac/FrameMac.mm: Updated autoscroll code to use renderers instead of layers, so any renderer that implements autoscroll will work.
(WebCore::FrameMac::FrameMac):
(WebCore::FrameMac::handleMousePressEvent):
(WebCore::FrameMac::handleMouseMoveEvent):
(WebCore::FrameMac::mouseDown):
* page/Frame.cpp:
(WebCore::Frame::handleMouseMoveEvent):
(WebCore::Frame::scrollOverflow): Don't scroll list box here- this would cause arrow keys to scroll instead of select.
(WebCore::Frame::handleAutoscroll): Updated to use a renderer instead of a layer when setting up autoscroll.
(WebCore::Frame::autoscrollTimerFired): ditto.
(WebCore::Frame::stopAutoscrollTimer): ditto.
(WebCore::Frame::passWidgetMouseDownEventToWidget): Updated to check for list box's scroll bar.
* page/Frame.h:
* page/FramePrivate.h: (WebCore::FramePrivate::FramePrivate): Updated to use renderer unstead of layer for autoscroll.
* page/FrameView.cpp: Keep track of current mouse position so this can be used for list box autoscroll.
(WebCore::FrameViewPrivate::reset):
(WebCore::FrameView::currentMousePosition):
(WebCore::FrameView::handleMousePressEvent):
(WebCore::FrameView::handleMouseDoubleClickEvent):
(WebCore::selectCursor):
(WebCore::FrameView::handleMouseMoveEvent):
(WebCore::FrameView::handleMouseReleaseEvent):
* page/FrameView.h:
* platform/ScrollBar.cpp: (WebCore::ScrollBar::ScrollBar): Added controlSize argument. The list box will use a smaller scroll bar size.
* platform/ScrollBar.h:
(WebCore::):
(WebCore::ScrollBar::controlSize):
* platform/mac/PlatformScrollBar.h:
* platform/mac/PlatformScrollBarMac.mm:
(NSControlSizeForScrollBarControlSize):
(-[WebCoreScrollBar initWithPlatformScrollBar:]):
(WebCore::PlatformScrollBar::PlatformScrollBar):
* rendering/RenderBlock.h:
* rendering/RenderLayer.cpp: (WebCore::RenderLayer::createScrollbar): Updated to pass regular control size to scrollbar constructor.
* rendering/RenderLayer.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::shouldAutoscroll):
(WebCore::RenderObject::autoscroll):
* rendering/RenderObject.h: (WebCore::RenderObject::isListBox):
* css/html4.css: Added properties for new list boxes.
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::setSelected): Doesn't allow selection to be changed here if the option is disabled.
(WebCore::HTMLOptionElement::disabled): Added. Checks the parent's disabled status.
* html/HTMLOptionElement.h: Added disabled method.
* html/HTMLSelectElement.cpp: Added appearance switch for new list box implementation.
(WebCore::HTMLSelectElement::recalcStyle):
(WebCore::HTMLSelectElement::lastSelectedListIndex):
(WebCore::HTMLSelectElement::deselectItems):
(WebCore::HTMLSelectElement::setSelectedIndex):
(WebCore::HTMLSelectElement::isKeyboardFocusable):
(WebCore::HTMLSelectElement::isMouseFocusable):
(WebCore::HTMLSelectElement::createRenderer):
(WebCore::HTMLSelectElement::recalcListItems):
(WebCore::HTMLSelectElement::setRecalcListItems):
(WebCore::HTMLSelectElement::reset):
(WebCore::HTMLSelectElement::notifyOptionSelected):
(WebCore::HTMLSelectElement::defaultEventHandler): Added code to select options for list box when clicking and using arrow keys.
(WebCore::HTMLSelectElement::nextSelectableListIndex):
(WebCore::HTMLSelectElement::previousSelectableListIndex):
* html/HTMLSelectElement.h:
* rendering/RenderTheme.cpp: Added support for ListBoxAppearance
(WebCore::RenderTheme::paint):
(WebCore::RenderTheme::paintBorderOnly):
(WebCore::RenderTheme::paintDecorations):
(WebCore::RenderTheme::activeListBoxSelectionBackgroundColor):
(WebCore::RenderTheme::activeListBoxSelectionForegroundColor):
(WebCore::RenderTheme::inactiveListBoxSelectionBackgroundColor):
(WebCore::RenderTheme::inactiveListBoxSelectionForegroundColor):
(WebCore::RenderTheme::isControlStyled):
(WebCore::RenderTheme::supportsFocusRing):
* rendering/RenderTheme.h:
* rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::isControlStyled):
* rendering/RenderListBox.cpp: Added.
(WebCore::RenderListBox::RenderListBox):
(WebCore::RenderListBox::~RenderListBox):
(WebCore::RenderListBox::setStyle):
(WebCore::RenderListBox::updateFromElement):
(WebCore::RenderListBox::calcMinMaxWidth):
(WebCore::RenderListBox::size):
(WebCore::RenderListBox::numItems):
(WebCore::RenderListBox::calcHeight):
(WebCore::RenderListBox::baselinePosition):
(WebCore::RenderListBox::itemBoundingBoxRect):
(WebCore::RenderListBox::paintObject):
(WebCore::RenderListBox::paintScrollbar):
(WebCore::RenderListBox::paintItemForeground):
(WebCore::RenderListBox::paintItemBackground):
(WebCore::RenderListBox::scrollBarTarget):
(WebCore::RenderListBox::isPointInScrollbar):
(WebCore::RenderListBox::optionAtPoint):
(WebCore::RenderListBox::autoscroll):
(WebCore::RenderListBox::scrollToRevealElementAtListIndex):
(WebCore::RenderListBox::scroll):
(WebCore::RenderListBox::valueChanged):
* rendering/RenderListBox.h: Added.
(WebCore::RenderListBox::isListBox):
(WebCore::RenderListBox::selectionChanged):
(WebCore::RenderListBox::setSelectionChanged):
(WebCore::RenderListBox::canHaveChildren):
(WebCore::RenderListBox::renderName):
(WebCore::RenderListBox::setOptionsChanged):
(WebCore::RenderListBox::shouldAutoscroll):
(WebCore::RenderListBox::listIndexIsVisible):
2006-09-29 Beth Dakin <bdakin@apple.com>
Reviewed by Darin.
......@@ -1891,6 +1891,8 @@
AB4261D80A2F6C9700BDD17D /* missingImage.tiff in Resources */ = {isa = PBXBuildFile; fileRef = AB4261D70A2F6C9700BDD17D /* missingImage.tiff */; };
AB67D1A8097F3AE300F9392E /* RenderTextControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB67D1A6097F3AE300F9392E /* RenderTextControl.cpp */; };
AB67D1A9097F3AE300F9392E /* RenderTextControl.h in Headers */ = {isa = PBXBuildFile; fileRef = AB67D1A7097F3AE300F9392E /* RenderTextControl.h */; };
ABB5419E0ACDDFE4002820EB /* RenderListBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABB5419C0ACDDFE4002820EB /* RenderListBox.cpp */; };
ABB5419F0ACDDFE4002820EB /* RenderListBox.h in Headers */ = {isa = PBXBuildFile; fileRef = ABB5419D0ACDDFE4002820EB /* RenderListBox.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 */; };
......@@ -4343,6 +4345,8 @@
AB4261D70A2F6C9700BDD17D /* missingImage.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = missingImage.tiff; sourceTree = "<group>"; };
AB67D1A6097F3AE300F9392E /* RenderTextControl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextControl.cpp; sourceTree = "<group>"; };
AB67D1A7097F3AE300F9392E /* RenderTextControl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTextControl.h; sourceTree = "<group>"; };
ABB5419C0ACDDFE4002820EB /* RenderListBox.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderListBox.cpp; sourceTree = "<group>"; };
ABB5419D0ACDDFE4002820EB /* RenderListBox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderListBox.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>"; };
......@@ -7697,6 +7701,8 @@
F523D2F302DE443B018635CA /* rendering */ = {
isa = PBXGroup;
children = (
ABB5419C0ACDDFE4002820EB /* RenderListBox.cpp */,
ABB5419D0ACDDFE4002820EB /* RenderListBox.h */,
A8CFF04B0A154F09000A4234 /* AutoTableLayout.cpp */,
A8CFF0490A154F09000A4234 /* AutoTableLayout.h */,
BCEA4813097D93020094C9E4 /* bidi.cpp */,
......@@ -9135,6 +9141,7 @@
85989DD00ACC8BBD00A0BC51 /* DOMUIEventInternal.h in Headers */,
85989DD10ACC8BBD00A0BC51 /* DOMWheelEventInternal.h in Headers */,
4BBDBF7E0ACC9290005F6E97 /* CommandByName.h in Headers */,
ABB5419F0ACDDFE4002820EB /* RenderListBox.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -9182,7 +9189,6 @@
mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
93F198A508245E59001E9ABC /* WebCore */,
DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
......@@ -10247,6 +10253,7 @@
85D79ADB0ACA17EB00F02FC5 /* DOMSVGStringList.mm in Sources */,
859C9C400ACACCCC00791611 /* DOMSVGRectElement.mm in Sources */,
4BBDBF7D0ACC9290005F6E97 /* CommandByName.cpp in Sources */,
ABB5419E0ACDDFE4002820EB /* RenderListBox.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -351,6 +351,7 @@ private:
bool _sendingEventToSubview;
bool _mouseDownMayStartDrag;
bool _mouseDownMayStartSelect;
bool _mouseDownMayStartAutoscroll;
PlatformMouseEvent m_mouseDown;
// in our view's coords
IntPoint m_mouseDownPos;
......
......@@ -153,6 +153,7 @@ FrameMac::FrameMac(Page* page, Element* ownerElement)
, _sendingEventToSubview(false)
, _mouseDownMayStartDrag(false)
, _mouseDownMayStartSelect(false)
, _mouseDownMayStartAutoscroll(false)
, _activationEventNumber(0)
, _bindingRoot(0)
, _windowScriptObject(0)
......@@ -1380,6 +1381,8 @@ void FrameMac::handleMousePressEvent(const MouseEventWithHitTestResults& event)
_mouseDownMayStartDrag = singleClick;
d->m_mousePressNode = event.targetNode();
_mouseDownMayStartAutoscroll = d->m_mousePressNode && d->m_mousePressNode->renderer() && d->m_mousePressNode->renderer()->shouldAutoscroll();
if (!passWidgetMouseDownEventToWidget(event, false)) {
// We don't do this at the start of mouse down handling (before calling into WebCore),
......@@ -1714,7 +1717,7 @@ void FrameMac::handleMouseMoveEvent(const MouseEventWithHitTestResults& event)
// No more default handling (like selection), whether we're past the hysteresis bounds or not
return;
}
if (!_mouseDownMayStartSelect) {
if (!_mouseDownMayStartSelect && !_mouseDownMayStartAutoscroll) {
return;
}
......@@ -1723,16 +1726,16 @@ void FrameMac::handleMouseMoveEvent(const MouseEventWithHitTestResults& event)
d->m_view->invalidateClick();
Node* node = event.targetNode();
RenderLayer* layer = 0;
if (node && node->renderer())
layer = node->renderer()->enclosingLayer();
RenderObject* renderer = 0;
if (node)
renderer = node->renderer();
// If the selection is contained in a layer that can scroll, that layer should handle the autoscroll
// Otherwise, let the bridge handle it so the view can scroll itself.
while (layer && !layer->shouldAutoscroll())
layer = layer->parent();
if (layer)
handleAutoscroll(layer);
while (renderer && !renderer->shouldAutoscroll())
renderer = renderer->parent();
if (renderer)
handleAutoscroll(renderer);
else {
if (!d->m_autoscrollTimer.isActive())
startAutoscrollTimer();
......@@ -1965,6 +1968,7 @@ void FrameMac::mouseDown(NSEvent *event)
_mouseDownMayStartDrag = false;
_mouseDownMayStartSelect = false;
_mouseDownMayStartAutoscroll = false;
v->handleMousePressEvent(event);
......
......@@ -379,7 +379,7 @@ input[type="button"], input[type="submit"], input[type="reset"], input[type="fil
box-sizing: border-box
}
input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, input[type="file"]::-webkit-file-upload-button:disabled, button:disabled, select:disabled {
input[type="button"]:disabled, input[type="submit"]:disabled, input[type="reset"]:disabled, input[type="file"]::-webkit-file-upload-button:disabled, button:disabled, select:disabled, optgroup:disabled, option:disabled {
color: GrayText
}
......@@ -431,6 +431,14 @@ select[size][multiple] {
color: initial;
border: initial;
background-color: initial;
/*
-webkit-appearance: listbox;
-webkit-box-align: start;
box-sizing: initial;
border: 1px inset gray;
-webkit-border-radius: initial;
white-space: initial;
*/
}
select[size="0"],
......@@ -521,7 +529,7 @@ html:focus, body:focus {
outline: none
}
input:focus, textarea:focus, isindex:focus {
input:focus, textarea:focus, isindex:focus, select:focus {
outline-offset: -2px
}
......
......@@ -29,6 +29,7 @@
#include "Document.h"
#include "ExceptionCode.h"
#include "EventNames.h"
#include "HTMLNames.h"
#include "HTMLSelectElement.h"
#include "RenderMenuList.h"
......@@ -39,6 +40,7 @@
namespace WebCore {
using namespace HTMLNames;
using namespace EventNames;
HTMLOptionElement::HTMLOptionElement(Document* doc, HTMLFormElement* f)
: HTMLGenericFormElement(optionTag, doc, f)
......@@ -169,7 +171,7 @@ void HTMLOptionElement::setValue(const String& value)
void HTMLOptionElement::setSelected(bool selected)
{
if (m_selected == selected)
if (m_selected == selected || disabled())
return;
m_selected = selected;
if (HTMLSelectElement* select = getSelect())
......@@ -238,4 +240,9 @@ String HTMLOptionElement::optionText()
return itemText;
}
bool HTMLOptionElement::disabled() const
{
return HTMLGenericFormElement::disabled() || (parentNode() && static_cast<HTMLGenericFormElement*>(parentNode())->disabled());
}
} // namespace
......@@ -79,6 +79,8 @@ public:
void setLabel(const String&);
String optionText();
virtual bool disabled() const;
private:
String m_value;
......
This diff is collapsed.
......@@ -55,8 +55,9 @@ public:
virtual void recalcStyle(StyleChange);
int selectedIndex() const;
void setSelectedIndex(int index, bool = true);
void setSelectedIndex(int index, bool deselect = true);
void notifyOptionSelected(HTMLOptionElement* selectedOption, bool selected);
virtual bool isEnumeratable() const { return true; }
int length() const;
......@@ -105,7 +106,6 @@ public:
return m_listItems;
}
virtual void reset();
void notifyOptionSelected(HTMLOptionElement* selectedOption, bool selected);
virtual void defaultEventHandler(Event*);
virtual void accessKeyAction(bool sendToAnyElement);
......@@ -120,10 +120,16 @@ public:
virtual Node* namedItem(const String& name, bool caseSensitive = true);
HTMLCollection::CollectionInfo* collectionInfo() { return &m_collectionInfo; }
private:
void recalcListItems() const;
bool shouldUseMenuList() const { return !m_multiple && m_size <= 1; }
void deselectItems(HTMLOptionElement* excludeElement);
bool usesMenuList() const { return !m_multiple && m_size <= 1; }
int lastSelectedListIndex() const;
int nextSelectableListIndex(int startIndex);
int previousSelectableListIndex(int startIndex);
void menuListDefaultEventHandler(Event*);
void listBoxDefaultEventHandler(Event*);
mutable Vector<HTMLElement*> m_listItems;
int m_minwidth;
......
......@@ -64,6 +64,7 @@
#include "PlugInInfoStore.h"
#include "Plugin.h"
#include "PluginDocument.h"
#include "RenderListBox.h"
#include "RenderPart.h"
#include "RenderTextControl.h"
#include "RenderTheme.h"
......@@ -1954,6 +1955,7 @@ void Frame::handleMouseMoveEvent(const MouseEventWithHitTestResults& event)
return;
// handle making selection
IntPoint vPoint = view()->convertFromContainingWindow(event.event().pos());
VisiblePosition pos(innerNode->renderer()->positionForPoint(vPoint));
......@@ -2841,7 +2843,7 @@ bool Frame::scrollOverflow(ScrollDirection direction, ScrollGranularity granular
if (node != 0) {
RenderObject *r = node->renderer();
if (r != 0) {
if (r != 0 && !r->isListBox()) {
return r->scroll(direction, granularity);
}
}
......@@ -2849,11 +2851,11 @@ bool Frame::scrollOverflow(ScrollDirection direction, ScrollGranularity granular
return false;
}
void Frame::handleAutoscroll(RenderLayer* layer)
void Frame::handleAutoscroll(RenderObject* renderer)
{
if (d->m_autoscrollTimer.isActive())
return;
d->m_autoscrollLayer = layer;
d->m_autoscrollRenderer = renderer;
startAutoscrollTimer();
}
......@@ -2863,8 +2865,8 @@ void Frame::autoscrollTimerFired(Timer<Frame>*)
stopAutoscrollTimer();
return;
}
if (d->m_autoscrollLayer) {
d->m_autoscrollLayer->autoscroll();
if (d->m_autoscrollRenderer) {
d->m_autoscrollRenderer->autoscroll();
}
}
......@@ -2929,7 +2931,7 @@ void Frame::startAutoscrollTimer()
void Frame::stopAutoscrollTimer()
{
d->m_autoscrollLayer = 0;
d->m_autoscrollRenderer = 0;
d->m_autoscrollTimer.stop();
}
......@@ -3260,7 +3262,12 @@ bool Frame::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&
if (!target)
return false;
Widget* widget = RenderLayer::gScrollBar;
Widget* widget;
if (target->isListBox())
widget = static_cast<RenderListBox*>(target)->scrollBarTarget();
else
widget = RenderLayer::gScrollBar;
if (!widget) {
if (!target->isWidget())
return false;
......
......@@ -760,7 +760,7 @@ protected:
virtual void cleanupPluginObjects() { }
void cancelAndClear();
void handleAutoscroll(RenderLayer*);
void handleAutoscroll(RenderObject*);
void startAutoscrollTimer();
void stopAutoscrollTimer();
......
......@@ -102,7 +102,7 @@ namespace WebCore {
, m_userStyleSheetLoader(0)
, m_iconLoader(0)
, m_autoscrollTimer(thisFrame, &Frame::autoscrollTimerFired)
, m_autoscrollLayer(0)
, m_autoscrollRenderer(0)
, m_paintRestriction(PaintRestrictionNone)
, m_markedTextUsesUnderlines(false)
, m_highlightTextMatches(false)
......@@ -223,7 +223,7 @@ namespace WebCore {
IconLoader* m_iconLoader;
Timer<Frame> m_autoscrollTimer;
RenderLayer* m_autoscrollLayer;
RenderObject* m_autoscrollRenderer;
RefPtr<Node> m_elementToDraw;
PaintRestriction m_paintRestriction;
......
......@@ -125,6 +125,7 @@ public:
repaintRects->clear();
resizingFrameSet = 0;
m_resizeLayer = 0;
m_currentMousePosition = IntPoint();
}
RefPtr<Node> underMouse;
......@@ -183,6 +184,8 @@ public:
bool horizontalOverflow;
bool m_verticalOverflow;
RenderObject* m_viewportRenderer;
IntPoint m_currentMousePosition;
};
FrameView::FrameView(Frame *frame)
......@@ -564,6 +567,11 @@ static Frame* subframeForEvent(const MouseEventWithHitTestResults& mev)
return static_cast<FrameView*>(widget)->frame();
}
IntPoint FrameView::currentMousePosition() const
{
return d->m_currentMousePosition;
}
void FrameView::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
{
if (!m_frame->document())
......@@ -572,7 +580,8 @@ void FrameView::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
RefPtr<FrameView> protector(this);
d->mousePressed = true;
d->m_currentMousePosition = convertFromContainingWindow(mouseEvent.pos());
MouseEventWithHitTestResults mev = prepareMouseEvent(false, true, false, mouseEvent);
if (m_frame->passSubframeEventToSubframe(mev)) {
......@@ -623,6 +632,7 @@ void FrameView::handleMouseDoubleClickEvent(const PlatformMouseEvent& mouseEvent
// We get this instead of a second mouse-up
d->mousePressed = false;
d->m_currentMousePosition = convertFromContainingWindow(mouseEvent.pos());
MouseEventWithHitTestResults mev = prepareMouseEvent(false, true, false, mouseEvent);
......@@ -755,7 +765,8 @@ void FrameView::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent)
return;
RefPtr<FrameView> protector(this);
d->m_currentMousePosition = convertFromContainingWindow(mouseEvent.pos());
if (d->hoverTimer.isActive())
d->hoverTimer.stop();
......@@ -814,6 +825,7 @@ void FrameView::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
RefPtr<FrameView> protector(this);
d->mousePressed = false;
d->m_currentMousePosition = convertFromContainingWindow(mouseEvent.pos());
if (d->resizingFrameSet) {
dispatchMouseEvent(mouseupEvent, d->resizingFrameSet.get(), true, d->clickCount, mouseEvent, false);
......
......@@ -53,6 +53,7 @@ class HTMLFrameSetElement;
class HTMLGenericFormElement;
class HTMLTitleElement;
class InlineBox;
class IntPoint;
class IntRect;
class PlatformKeyboardEvent;
class FrameMac;
......@@ -183,10 +184,12 @@ public:
void scheduleEvent(PassRefPtr<Event>, PassRefPtr<EventTargetNode>, bool tempEvent);
IntPoint currentMousePosition() const;
void ref() { ++m_refCount; }
void deref() { if (!--m_refCount) delete this; }
bool hasOneRef() { return m_refCount == 1; }
private:
void cleared();
void scrollBarMoved();
......
......@@ -28,9 +28,10 @@
namespace WebCore {
ScrollBar::ScrollBar(ScrollBarClient* client, ScrollBarOrientation orientation)
ScrollBar::ScrollBar(ScrollBarClient* client, ScrollBarOrientation orientation, ScrollBarControlSize controlSize)
: m_client(client)
, m_orientation(orientation)
, m_controlSize(controlSize)
, m_visibleSize(0)
, m_totalSize(0)
, m_currentPos(0)
......
......@@ -55,6 +55,8 @@ enum ScrollGranularity {
enum ScrollBarOrientation { HorizontalScrollBar, VerticalScrollBar };
enum ScrollBarControlSize { RegularScrollBar, SmallScrollBar, MiniScrollBar };
class ScrollBarClient {
public:
virtual ~ScrollBarClient() {}
......@@ -63,7 +65,7 @@ public:
class ScrollBar : public Shared<ScrollBar> {
protected:
ScrollBar(ScrollBarClient*, ScrollBarOrientation);
ScrollBar(ScrollBarClient*, ScrollBarOrientation, ScrollBarControlSize);
public:
virtual ~ScrollBar() {}
......@@ -72,6 +74,8 @@ public:
ScrollBarOrientation orientation() const { return m_orientation; }
int value() const { return m_currentPos; }
ScrollBarControlSize controlSize() const { return m_controlSize; }
void setSteps(int lineStep, int pageStep);
......@@ -107,6 +111,7 @@ protected:
ScrollBarClient* m_client;
ScrollBarOrientation m_orientation;
ScrollBarControlSize m_controlSize;
int m_visibleSize;
int m_totalSize;
int m_currentPos;
......
......@@ -40,7 +40,7 @@ namespace WebCore {
class PlatformScrollBar : public Widget, public ScrollBar {
public:
PlatformScrollBar(ScrollBarClient*, ScrollBarOrientation);
PlatformScrollBar(ScrollBarClient*, ScrollBarOrientation, ScrollBarControlSize);
virtual ~PlatformScrollBar();
virtual bool isWidget() const { return true; }
......
......@@ -44,6 +44,15 @@ using namespace WebCore;
@implementation WebCoreScrollBar
static NSControlSize NSControlSizeForScrollBarControlSize(ScrollBarControlSize size)
{
if (size == SmallScrollBar)
return NSSmallControlSize;
if (size == MiniScrollBar)
return NSMiniControlSize;
return NSRegularControlSize;
}
- (id)initWithPlatformScrollBar:(PlatformScrollBar*)s
{
// Cocoa scrollbars just set their orientation by examining their own
......@@ -64,6 +73,7 @@ using namespace WebCore;
[self setEnabled:YES];
[self setTarget:self];
[self setAction:@selector(scroll:)];
[self setControlSize:NSControlSizeForScrollBarControlSize(s->controlSize())];
return self;
}
......@@ -97,8 +107,8 @@ using namespace WebCore;
namespace WebCore
{
PlatformScrollBar::PlatformScrollBar(ScrollBarClient* client, ScrollBarOrientation orientation)
: ScrollBar(client, orientation)
PlatformScrollBar::PlatformScrollBar(ScrollBarClient* client, ScrollBarOrientation orientation, ScrollBarControlSize controlSize)
: ScrollBar(client, orientation, controlSize)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
......
......@@ -201,7 +201,7 @@ public:
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty,
HitTestAction hitTestAction);
bool isPointInScrollbar(int x, int y, int tx, int ty);
virtual bool isPointInScrollbar(int x, int y, int tx, int ty);
virtual VisiblePosition positionForCoordinates(int x, int y);
......
......@@ -792,13 +792,6 @@ void RenderLayer::autoscroll()
scrollToOffset(xOffset + diffX, yOffset + diffY);
}