summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-06-24 17:40:05 +0200
committerPierre Rossi <pierre.rossi@gmail.com>2014-07-30 21:25:00 +0200
commit5f12776a6e3d346bdfea8fbc12df8e643c52c3fd (patch)
treec3811ed2457e2cfe1128e384657b2ed6ad9bb8a0
parent622bd271367a251b87881d53df45467777ee863a (diff)
[WK2] Update text upon item selection for menu lists
While RenderListBox repaints itself on selection changes, RenderMenuList lacks this logic when it's used for multiple selections (acting as a listbox). Make sure we properly update the element's text as the options are toggled. Originally reported and proposed fix in http://wkb.ug/91862 Task-number: QTBUG-39675 Change-Id: I09f17ff03577fc6f65875674d632684b560fffb7 Reviewed-by: Michael Bruning <michael.bruning@digia.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
-rw-r--r--Source/WebCore/WebCore.exp.in1
-rw-r--r--Source/WebCore/html/HTMLSelectElement.cpp16
-rw-r--r--Source/WebCore/rendering/RenderMenuList.h2
-rw-r--r--Source/WebCore/rendering/RenderTheme.cpp12
-rw-r--r--Source/WebCore/rendering/RenderTheme.h3
-rw-r--r--Source/WebCore/testing/Internals.cpp7
-rw-r--r--Source/WebCore/testing/Internals.h2
-rw-r--r--Source/WebCore/testing/Internals.idl1
-rw-r--r--Source/autotools/symbols.filter1
9 files changed, 37 insertions, 8 deletions
diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in
index 6b1ce256d..d8957fec6 100644
--- a/Source/WebCore/WebCore.exp.in
+++ b/Source/WebCore/WebCore.exp.in
@@ -175,6 +175,7 @@ __ZN7WebCore11startOfWordERKNS_15VisiblePositionENS_9EWordSideE
__ZN7WebCore11writeToFileEiPKci
__ZN7WebCore12ChromeClient23paintCustomOverhangAreaEPNS_15GraphicsContextERKNS_7IntRectES5_S5_
__ZN7WebCore12EditingStyleD1Ev
+__ZN7WebCore11RenderTheme29setDelegatesMenuListRenderingEb
__ZN7WebCore12EventHandler10mouseMovedERKNS_18PlatformMouseEventE
__ZN7WebCore12EventHandler14scrollOverflowENS_15ScrollDirectionENS_17ScrollGranularityEPNS_4NodeE
__ZN7WebCore12EventHandler15handleAccessKeyERKNS_21PlatformKeyboardEventE
diff --git a/Source/WebCore/html/HTMLSelectElement.cpp b/Source/WebCore/html/HTMLSelectElement.cpp
index a437b375b..31958c89a 100644
--- a/Source/WebCore/html/HTMLSelectElement.cpp
+++ b/Source/WebCore/html/HTMLSelectElement.cpp
@@ -182,6 +182,8 @@ void HTMLSelectElement::listBoxSelectItem(int listIndex, bool allowMultiplySelec
if (fireOnChangeNow)
listBoxOnChange();
}
+ if (usesMenuList() && renderer())
+ toRenderMenuList(renderer())->setTextFromOption(selectedIndex());
}
bool HTMLSelectElement::usesMenuList() const
@@ -826,6 +828,8 @@ void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, b
selectOption(option->index());
else if (!usesMenuList())
selectOption(-1);
+ else if (m_multiple)
+ selectOption(selectedIndex());
else
selectOption(nextSelectableListIndex(-1));
}
@@ -862,12 +866,12 @@ void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags)
m_isProcessingUserDrivenChange = flags & UserDriven;
if (flags & DispatchChangeEvent)
dispatchChangeEventForMenuList();
- if (RenderObject* renderer = this->renderer()) {
- if (usesMenuList())
- toRenderMenuList(renderer)->didSetSelectedIndex(listIndex);
- else if (renderer->isListBox())
- toRenderListBox(renderer)->selectionChanged();
- }
+ }
+ if (RenderObject* renderer = this->renderer()) {
+ if (usesMenuList())
+ toRenderMenuList(renderer)->didSetSelectedIndex(listIndex);
+ else if (renderer->isListBox())
+ toRenderListBox(renderer)->selectionChanged();
}
setNeedsValidityCheck();
diff --git a/Source/WebCore/rendering/RenderMenuList.h b/Source/WebCore/rendering/RenderMenuList.h
index 7287ac300..eb90a5fc8 100644
--- a/Source/WebCore/rendering/RenderMenuList.h
+++ b/Source/WebCore/rendering/RenderMenuList.h
@@ -54,6 +54,7 @@ public:
void setOptionsChanged(bool changed) { m_needsOptionsWidthUpdate = changed; }
void didSetSelectedIndex(int listIndex);
+ void setTextFromOption(int optionIndex);
String text() const;
@@ -129,7 +130,6 @@ private:
void createInnerBlock();
void adjustInnerStyle();
void setText(const String&);
- void setTextFromOption(int optionIndex);
void updateOptionsWidth();
void didUpdateActiveOption(int optionIndex);
diff --git a/Source/WebCore/rendering/RenderTheme.cpp b/Source/WebCore/rendering/RenderTheme.cpp
index c0c584ddc..5dd361fed 100644
--- a/Source/WebCore/rendering/RenderTheme.cpp
+++ b/Source/WebCore/rendering/RenderTheme.cpp
@@ -74,6 +74,8 @@ static Color& customFocusRingColor()
return color;
}
+static bool forceMenuListDelegation = false;
+
RenderTheme::RenderTheme()
#if USE(NEW_THEME)
: m_theme(platformTheme())
@@ -1071,6 +1073,16 @@ bool RenderTheme::shouldHaveSpinButton(HTMLInputElement* inputElement) const
return inputElement->isSteppable() && !inputElement->isRangeControl();
}
+bool RenderTheme::delegatesMenuListRendering() const
+{
+ return forceMenuListDelegation;
+}
+
+void RenderTheme::setDelegatesMenuListRendering(bool on)
+{
+ forceMenuListDelegation = on;
+}
+
void RenderTheme::adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const
{
}
diff --git a/Source/WebCore/rendering/RenderTheme.h b/Source/WebCore/rendering/RenderTheme.h
index d3b92b2b1..1e35f14b8 100644
--- a/Source/WebCore/rendering/RenderTheme.h
+++ b/Source/WebCore/rendering/RenderTheme.h
@@ -228,9 +228,10 @@ public:
virtual bool shouldHaveSpinButton(HTMLInputElement*) const;
// Functions for <select> elements.
- virtual bool delegatesMenuListRendering() const { return false; }
+ virtual bool delegatesMenuListRendering() const;
virtual bool popsMenuByArrowKeys() const { return false; }
virtual bool popsMenuBySpaceOrReturn() const { return false; }
+ static void setDelegatesMenuListRendering(bool on);
virtual String fileListDefaultLabel(bool multipleFilesAllowed) const;
virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const;
diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp
index b1064e91d..4cfbfdb74 100644
--- a/Source/WebCore/testing/Internals.cpp
+++ b/Source/WebCore/testing/Internals.cpp
@@ -81,6 +81,7 @@
#include "RenderEmbeddedObject.h"
#include "RenderMenuList.h"
#include "RenderObject.h"
+#include "RenderTheme.h"
#include "RenderTreeAsText.h"
#include "RenderView.h"
#include "RuntimeEnabledFeatures.h"
@@ -263,6 +264,7 @@ void Internals::resetToConsistentState(Page* page)
page->setPagination(Pagination());
#if USE(ACCELERATED_COMPOSITING)
+ RenderTheme::setDelegatesMenuListRendering(false);
FrameView* mainFrameView = page->mainFrame()->view();
if (mainFrameView) {
mainFrameView->setHeaderHeight(0);
@@ -2205,4 +2207,9 @@ bool Internals::isPluginUnavailabilityIndicatorObscured(Element* element, Except
return embed->isReplacementObscured();
}
+void Internals::setDelegatesMenuListRendering(bool forceOn)
+{
+ RenderTheme::setDelegatesMenuListRendering(forceOn);
+}
+
}
diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h
index 25ba4498e..1e1aefad1 100644
--- a/Source/WebCore/testing/Internals.h
+++ b/Source/WebCore/testing/Internals.h
@@ -287,6 +287,8 @@ public:
void setUsesOverlayScrollbars(bool enabled);
+ void setDelegatesMenuListRendering(bool);
+
String getCurrentCursorInfo(Document*, ExceptionCode&);
String markerTextForListItem(Element*, ExceptionCode&);
diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl
index 9622e5020..a550ac7c6 100644
--- a/Source/WebCore/testing/Internals.idl
+++ b/Source/WebCore/testing/Internals.idl
@@ -258,6 +258,7 @@
[Conditional=ENCRYPTED_MEDIA_V2] void initializeMockCDM();
[Conditional=SPEECH_SYNTHESIS] void enableMockSpeechSynthesizer();
+ void setDelegatesMenuListRendering(in boolean forceOn);
[RaisesException] DOMString getImageSourceURL(Element element);
diff --git a/Source/autotools/symbols.filter b/Source/autotools/symbols.filter
index 4a66ac6c9..aea145813 100644
--- a/Source/autotools/symbols.filter
+++ b/Source/autotools/symbols.filter
@@ -64,6 +64,7 @@ _ZN7WebCore11memoryCacheEv;
_ZN7WebCore11EventTarget17toGeneratedStreamEv;
_ZN7WebCore11EventTarget8toStreamEv;
_ZN7WebCore11MemoryCache14resourceForURLERKNS_4KURLE;
+_ZN7WebCore11RenderTheme29setDelegatesMenuListRenderingEb;
_ZN7WebCore12TextIterator26rangeFromLocationAndLengthEPNS_13ContainerNodeEiib;
_ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_4NodeEPKNS_5RangeERjS6_;
_ZN7WebCore12TextIterator29getLocationAndLengthFromRangeEPNS_4NodeEPKNS_5RangeERmS6_;