summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/wml
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-07-13 20:00:20 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-07-13 20:00:20 (GMT)
commitf23fa541a04abd1ddc36815a285ec824d5b5c5e0 (patch)
tree3d1002cb8367e8635bc0a0f78724661cbf75a8cb /src/3rdparty/webkit/WebCore/wml
parentfd302ab05face6c592944187fb594c1f55d62c5d (diff)
downloadQt-f23fa541a04abd1ddc36815a285ec824d5b5c5e0.zip
Qt-f23fa541a04abd1ddc36815a285ec824d5b5c5e0.tar.gz
Qt-f23fa541a04abd1ddc36815a285ec824d5b5c5e0.tar.bz2
Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit-4.6-snapshot-13072009 ( b2abc0c271880b8135507861056af497f895adf5 )
Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2009-07-13 Simon Hausmann <simon.hausmann@nokia.com> Reviewed by Ariya Hidayat. Fix qdoc warnings for QWebPage::shouldInterruptJavaScript() and mention how to re-implement it. * Api/qwebpage.cpp: 2009-07-13 Simon Hausmann <hausmann@webkit.org> Reviewed by Ariya Hidayat. Fix crash with plugins when the plugin stream is cancelled. Similar to r26667 handle the case where didReceiveResponse on the plugin view results in failure to set up the stream and setMainDocumentError being called instead. This will set the m_pluginView back to 0 and we need check for it before calling didReceiveData. This was triggered by consecutive execution of LayoutTests/plugins/return-error-from-new-stream-callback-in-full-frame-plugin.html followed by LayoutTests/scrollbars/scrollbar-crash-on-refresh.html * WebCoreSupport/FrameLoaderClientQt.cpp: (WebCore::FrameLoaderClientQt::committedLoad): 2009-07-13 Simon Hausmann <hausmann@webkit.org> Reviewed by Ariya Hidayat. Added QWebDatabase::removeAllDatabases, as a way to delete all databases from the offline storage path. Used by the Qt DRT. * Api/qwebdatabase.cpp: (QWebDatabase::removeAllDatabases): * Api/qwebdatabase.h: 2009-07-13 Simon Hausmann <hausmann@webkit.org> Reviewed by Ariya Hidayat. Added loadStarted() and loadFinished() signals to QWebFrame, to allow load tracking of individual frames, as opposed to QWebPage's loadStarted/loadFinished signals that are emitted whenever _any_ child frame loads/finishes. * Api/qwebframe.cpp: Document new signals. * Api/qwebframe.h: Add new signals. * WebCoreSupport/FrameLoaderClientQt.cpp: (WebCore::FrameLoaderClientQt::setFrame): Connect new signals. 2009-07-13 Simon Hausmann <hausmann@webkit.org> Reviewed by Ariya Hidayat. Add hooks for the GCController JavaScript interface needed by the Qt DRT. Fixed sort order of includes in qwebframe.cpp. * Api/qwebframe.cpp: (qt_drt_javaScriptObjectsCount): (qt_drt_garbageCollector_collect): (qt_drt_garbageCollector_collectOnAlternateThread): 2009-07-13 Simon Hausmann <hausmann@webkit.org> Reviewed by Ariya Hidayat. Add hooks for the GCController JavaScript interface needed by the Qt DRT. Fixed sort order of includes in qwebframe.cpp. * Api/qwebframe.cpp: (qt_drt_javaScriptObjectsCount): (qt_drt_garbageCollector_collect): (qt_drt_garbageCollector_collectOnAlternateThread): 2009-07-12 Brent Fulgham <bfulgham@gmail.com> Speculative build fix after http://trac.webkit.org/changeset/45786. * WebCoreSupport/ChromeClientQt.cpp: (WebCore::ChromeClientQt::addMessageToConsole): * WebCoreSupport/ChromeClientQt.h: 2009-07-10 Yael Aharon <yael.aharon@nokia.com> Reviewed by Holger Freyther. https://bugs.webkit.org/show_bug.cgi?id=27136 Fix a bug where webkit hangs when executing infinite JavaScript loop. * Api/qwebpage.cpp: (QWebPage::shouldInterruptJavaScript): * Api/qwebpage.h: * WebCoreSupport/ChromeClientQt.cpp: (WebCore::ChromeClientQt::shouldInterruptJavaScript): * tests/qwebpage/tst_qwebpage.cpp: (JSTestPage::JSTestPage): (JSTestPage::shouldInterruptJavaScript): (tst_QWebPage::infiniteLoopJS): 2009-07-10 Simon Hausmann <simon.hausmann@nokia.com> Reviewed by Holger Freyther. https://bugs.webkit.org/show_bug.cgi?id=27108 Fix crash when in frame tree of a new frame before the new frame has been installed in the frame tree, similar to r35088. After calling Frame::init() the frame it may have been removed from the frame tree again through JavaScript. Detect this by checking the page() afterwards. To make this check safe the Frame::init() code was moved into QWebFrameData's constructor, where a RefPtr holds a reference to the frame. After the check back in FrameLoaderClientQt we would hold the single reference left and after release() the frame, its frame loader, its client as well as the QWebFrame should have disappeared then. * Api/qwebframe.cpp: (QWebFramePrivate::init): Only call Frame::init here, the rest is done in QWebFrameData's constructor. (QWebFrame::QWebFrame): * Api/qwebframe_p.h: Adjust declaration. (QWebFrameData::QWebFrameData): Create the Frame here. * Api/qwebpage.cpp: (QWebPagePrivate::createMainFrame): Adjust and simplify to new QWebFrame constructor. * WebCoreSupport/FrameLoaderClientQt.cpp: (WebCore::FrameLoaderClientQt::createFrame): Adjust to new QWebFrame construction using QWebFrameData and add the check like in r35088. 2009-07-09 Beth Dakin <bdakin@apple.com> Reviewed by Dave Hyatt. Make Widget RefCounted to fix: <rdar://problem/7038831> REGRESSION (TOT): In Mail, a crash occurs at WebCore::Widget::afterMouseDown() after clicking To Do's close box <rdar://problem/6978804> WER #16: Repro Access Violation in WebCore::PluginView::bindingInstance (1310178023) -and- <rdar://problem/6991251> WER #13: Crash in WebKit! WebCore::PluginView::performRequest+203 (1311461169) * WebCoreSupport/FrameLoaderClientQt.cpp: (WebCore::FrameLoaderClientQt::createPlugin): (WebCore::FrameLoaderClientQt::createJavaAppletWidget): * WebCoreSupport/FrameLoaderClientQt.h: 2009-07-08 Pradeepto Bhattacharya <pradeepto@kde.org> Reviewed by Ariya Hidayat. Build fix. * WebCoreSupport/FrameLoaderClientQt.h: Removed the slot slotCallPolicyFunction(). 2009-07-08 Simon Hausmann <hausmann@webkit.org> Reviewed by Tor Arne Vestbø. https://bugs.webkit.org/show_bug.cgi?id=27080 Fix DRT instability issues with fast/loader/submit-form-while-parsing-2.html When the form is submitted we call the policy function in the frame loader delayed with a queued connection. That queued connection sometimes interferes with the javascript timeout set in the testcase. Eliminate the entire delayed policy function mechanism and instead always call back directly, like in the other ports. In most other places we called the slot directly anyway. * WebCoreSupport/FrameLoaderClientQt.cpp: (WebCore::FrameLoaderClientQt::FrameLoaderClientQt): Remove m_policyFunction. (WebCore::FrameLoaderClientQt::callPolicyFunction): Call the policy function directly instead of emitting the queued signal. (WebCore::FrameLoaderClientQt::cancelPolicyCheck): Call callPolicyFunction directly. (WebCore::FrameLoaderClientQt::dispatchWillSubmitForm): Ditto. (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForMIMEType): Ditto. (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction): Ditto. (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction): Ditto. * WebCoreSupport/FrameLoaderClientQt.h: Remove m_policyFunction as well as the associated signal. 2009-07-07 Simon Hausmann <hausmann@webkit.org> Reviewed by Holger Freyther. Add Qt DRT hook for clearing the frame name. * Api/qwebframe.cpp: (qt_drt_clearFrameName): 2009-07-05 Simon Hausmann <hausmann@webkit.org> Reviewed by Holger Freyther. Fix two qdoc warnings. Added missing \property for QWebFrame::hasFocus and added \a tag for pos of QWebPage::frameAt. * Api/qwebframe.cpp: * Api/qwebpage.cpp: 2009-07-04 Holger Hans Peter Freyther <zecke@selfish.org> Reviewed by Simon Hausmann. Use the recently introduced FocusController::setFocused Use the recently introduced FocusController::setFocused in the Qt platform. The SelectionController will be updated from within the FocusController now. * Api/qwebpage.cpp: (QWebPagePrivate::focusInEvent): (QWebPagePrivate::focusOutEvent): 2009-07-02 Simon Hausmann <simon.hausmann@nokia.com> Reviewed by Ariya Hidayat. Improve documentation of QWebFrame::setFocus and hasFocus() Added missing Q_PROPERTY for QWebFrame::hasFocus. * Api/qwebframe.cpp: Clarify the docs. * Api/qwebframe.h: add Q_PROPERTY(focus). 2009-07-02 Joe Ligman <joseph.ligman@nokia.com> Reviewed by Simon Hausmann. Bug 26855: [Qt] New methods for QWebFrame to check and set focus. Added new public methods QWebFrame::hasFocus() and QWebFrame::setFocus() Added auto test. * Api/qwebframe.cpp: (QWebFrame::hasFocus): (QWebFrame::setFocus): * Api/qwebframe.h: * tests/qwebframe/tst_qwebframe.cpp: 2009-07-01 Robert Hogan <robert@roberthogan.net> Reviewed by NOBODY. Fix Qt segfault when javascript disabled. If clients call addToJavaScriptWindowObject even though JavascriptEnabled is false webkit will segfault on the assert: ASSERTION FAILED: _rootObject (../../../WebCore/bridge/runtime.cpp:52 JSC::Bindings::Instance::Instance(WTF::PassRefPtr<JSC::Bindings::RootObject>)) Fix is to ensure JavaScript is enabled when client calls addToJavaScriptWindowObject. https://bugs.webkit.org/show_bug.cgi?id=26906 * Api/qwebframe.cpp: (QWebFrame::addToJavaScriptWindowObject): 2009-07-01 Jakub Wieczorek <faw217@gmail.com> Reviewed by Simon Hausmann. [Qt] Move some API headers from WebCore.pro to headers.pri so that they get installed when running make install from the build directory. * Api/headers.pri: 2009-07-01 Balazs Kelemen <kelemen.balazs.3@stud.u-szeged.hu> Reviewed by Simon Hausmann. Fixed robotized QtLauncher to work when there is no index.html in the user's home. * QtLauncher/main.cpp: (main): 2009-06-30 Brian Weinstein <bweinstein@apple.com> Reviewed by Adam Roben. Renamed scrollbarUnderPoint to scrollbarAtPoint to follow conventions. * Api/qwebpage.cpp: (QWebPage::swallowContextMenuEvent): 2009-06-30 Joe Ligman <joseph.ligman@nokia.com> Reviewed by Adam Treat. Bug 26422: [Qt] QWebPagePrivate::frameAt calculates wrong frame Added a public method QWebPage::frameAt Removed QWebPagePrivate::frameAt, which calcuated the wrong frame Modified QWebPage::swallowContextMenuEvent to use the new frameAt method New test case for frameAt added to tst_qwebpage.cpp * Api/qwebpage.cpp: (QWebPage::frameAt): (QWebPage::swallowContextMenuEvent): * Api/qwebpage.h: * Api/qwebpage_p.h: * tests/qwebpage/frametest/iframe.html: Added. * tests/qwebpage/frametest/iframe2.html: Added. * tests/qwebpage/frametest/iframe3.html: Added. * tests/qwebpage/tst_qwebpage.cpp: (frameAtHelper): (tst_QWebPage::frameAt): * tests/qwebpage/tst_qwebpage.qrc: 2009-06-30 Jakub Wieczorek <faw217@gmail.com> Reviewed by Simon Hausmann. Add QWebFrame::baseUrl() function that exposes the base URL of a frame. Autotests included. * Api/qwebframe.cpp: (QWebFrame::baseUrl): * Api/qwebframe.h: * tests/qwebframe/tst_qwebframe.cpp:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/wml')
-rw-r--r--src/3rdparty/webkit/WebCore/wml/WMLCardElement.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/wml/WMLErrorHandling.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/wml/WMLPageState.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/wml/WMLPostfieldElement.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/wml/WMLSelectElement.cpp336
-rw-r--r--src/3rdparty/webkit/WebCore/wml/WMLSelectElement.h23
-rw-r--r--src/3rdparty/webkit/WebCore/wml/WMLSetvarElement.cpp2
7 files changed, 359 insertions, 12 deletions
diff --git a/src/3rdparty/webkit/WebCore/wml/WMLCardElement.cpp b/src/3rdparty/webkit/WebCore/wml/WMLCardElement.cpp
index 3713c59..0f49bd7 100644
--- a/src/3rdparty/webkit/WebCore/wml/WMLCardElement.cpp
+++ b/src/3rdparty/webkit/WebCore/wml/WMLCardElement.cpp
@@ -34,6 +34,7 @@
#include "WMLInputElement.h"
#include "WMLIntrinsicEventHandler.h"
#include "WMLNames.h"
+#include "WMLSelectElement.h"
#include "WMLTemplateElement.h"
#include "WMLTimerElement.h"
#include "WMLVariables.h"
@@ -165,17 +166,14 @@ void WMLCardElement::handleIntrinsicEventIfNeeded()
if (m_eventTimer)
m_eventTimer->start();
- // FIXME: Initialize select elements in this card
for (Node* node = traverseNextNode(); node != 0; node = node->traverseNextNode()) {
if (!node->isElementNode())
continue;
if (node->hasTagName(inputTag))
static_cast<WMLInputElement*>(node)->initialize();
- /*
else if (node->hasTagName(selectTag))
static_cast<WMLSelectElement*>(node)->selectInitialOptions();
- */
}
}
diff --git a/src/3rdparty/webkit/WebCore/wml/WMLErrorHandling.cpp b/src/3rdparty/webkit/WebCore/wml/WMLErrorHandling.cpp
index a228299..87c8003 100644
--- a/src/3rdparty/webkit/WebCore/wml/WMLErrorHandling.cpp
+++ b/src/3rdparty/webkit/WebCore/wml/WMLErrorHandling.cpp
@@ -61,7 +61,7 @@ void reportWMLError(Document* doc, WMLErrorCode error)
if (!console)
return;
- console->addMessage(WMLMessageSource, ErrorMessageLevel, errorMessage, 0, String());
+ console->addMessage(WMLMessageSource, LogMessageType, ErrorMessageLevel, errorMessage, 0, String());
}
}
diff --git a/src/3rdparty/webkit/WebCore/wml/WMLPageState.cpp b/src/3rdparty/webkit/WebCore/wml/WMLPageState.cpp
index 15ae9ca..1afc0c9 100644
--- a/src/3rdparty/webkit/WebCore/wml/WMLPageState.cpp
+++ b/src/3rdparty/webkit/WebCore/wml/WMLPageState.cpp
@@ -54,7 +54,7 @@ void WMLPageState::reset()
m_page->backForwardList()->clearWmlPageHistory();
// reset implementation-specfic state if UA has
- m_historyLength = 1;
+ m_historyLength = 0;
}
bool WMLPageState::setNeedCheckDeckAccess(bool need)
diff --git a/src/3rdparty/webkit/WebCore/wml/WMLPostfieldElement.cpp b/src/3rdparty/webkit/WebCore/wml/WMLPostfieldElement.cpp
index 7d001e1..ca43f69 100644
--- a/src/3rdparty/webkit/WebCore/wml/WMLPostfieldElement.cpp
+++ b/src/3rdparty/webkit/WebCore/wml/WMLPostfieldElement.cpp
@@ -59,7 +59,7 @@ String WMLPostfieldElement::name() const
String WMLPostfieldElement::value() const
{
- return parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));
+ return parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));
}
static inline CString encodedString(const TextEncoding& encoding, const String& data)
diff --git a/src/3rdparty/webkit/WebCore/wml/WMLSelectElement.cpp b/src/3rdparty/webkit/WebCore/wml/WMLSelectElement.cpp
index 5b5aed1..5e70098 100644
--- a/src/3rdparty/webkit/WebCore/wml/WMLSelectElement.cpp
+++ b/src/3rdparty/webkit/WebCore/wml/WMLSelectElement.cpp
@@ -22,16 +22,21 @@
#if ENABLE(WML)
#include "WMLSelectElement.h"
-
+#include "CString.h"
#include "HTMLNames.h"
#include "MappedAttribute.h"
+#include "OptionElement.h"
#include "RenderListBox.h"
#include "RenderMenuList.h"
-
+#include "WMLDocument.h"
+#include "WMLNames.h"
+#include "WMLVariables.h"
#include <wtf/StdLibExtras.h>
namespace WebCore {
+using namespace WMLNames;
+
WMLSelectElement::WMLSelectElement(const QualifiedName& tagName, Document* document)
: WMLFormControlElement(tagName, document)
{
@@ -41,6 +46,17 @@ WMLSelectElement::~WMLSelectElement()
{
}
+String WMLSelectElement::title() const
+{
+ return substituteVariableReferences(getAttribute(HTMLNames::titleAttr), document());
+}
+
+const AtomicString& WMLSelectElement::formControlName() const
+{
+ AtomicString name = this->name();
+ return name.isNull() ? emptyAtom : name;
+}
+
const AtomicString& WMLSelectElement::formControlType() const
{
DEFINE_STATIC_LOCAL(const AtomicString, selectMultiple, ("select-multiple"));
@@ -92,9 +108,14 @@ int WMLSelectElement::selectedIndex() const
return SelectElement::selectedIndex(m_data, this);
}
-void WMLSelectElement::setSelectedIndex(int index, bool deselect, bool fireOnChange)
+void WMLSelectElement::setSelectedIndex(int optionIndex, bool deselect)
+{
+ SelectElement::setSelectedIndex(m_data, this, optionIndex, deselect, false, false);
+}
+
+void WMLSelectElement::setSelectedIndexByUser(int optionIndex, bool deselect, bool fireOnChangeNow)
{
- SelectElement::setSelectedIndex(m_data, this, index, deselect, fireOnChange);
+ SelectElement::setSelectedIndex(m_data, this, optionIndex, deselect, fireOnChangeNow, true);
}
bool WMLSelectElement::saveFormControlState(String& value) const
@@ -151,6 +172,14 @@ void WMLSelectElement::reset()
void WMLSelectElement::defaultEventHandler(Event* event)
{
SelectElement::defaultEventHandler(m_data, this, event);
+
+ // FIXME: There must be a better place to update the page variable state. Investigate.
+ updateVariables();
+
+ if (event->defaultHandled())
+ return;
+
+ WMLFormControlElement::defaultEventHandler(event);
}
void WMLSelectElement::accessKeyAction(bool sendToAnyElement)
@@ -213,12 +242,311 @@ void WMLSelectElement::scrollToSelection()
SelectElement::scrollToSelection(m_data, this);
}
+void WMLSelectElement::selectInitialOptions()
+{
+ // Spec: Step 1 - the default option index is determined using iname and ivalue
+ calculateDefaultOptionIndices();
+
+ if (m_defaultOptionIndices.isEmpty())
+ return;
+
+ // Spec: Step 2 – initialise variables
+ initializeVariables();
+
+ // Spec: Step 3 – pre-select option(s) specified by the default option index
+ selectDefaultOptions();
+}
+
void WMLSelectElement::insertedIntoTree(bool deep)
{
SelectElement::insertedIntoTree(m_data, this);
WMLFormControlElement::insertedIntoTree(deep);
}
+void WMLSelectElement::calculateDefaultOptionIndices()
+{
+ WMLPageState* pageState = wmlPageStateForDocument(document());
+ if (!pageState)
+ return;
+
+ String variable;
+
+ // Spec: If the 'iname' attribute is specified and names a variable that is set,
+ // then the default option index is the validated value of that variable.
+ String iname = this->iname();
+ if (!iname.isEmpty()) {
+ variable = pageState->getVariable(iname);
+ if (!variable.isEmpty())
+ m_defaultOptionIndices = parseIndexValueString(variable);
+ }
+
+ // Spec: If the default option index is empty and the 'ivalue' attribute is specified,
+ // then the default option index is the validated attribute value.
+ String ivalue = this->ivalue();
+ if (m_defaultOptionIndices.isEmpty() && !ivalue.isEmpty())
+ m_defaultOptionIndices = parseIndexValueString(ivalue);
+
+ // Spec: If the default option index is empty, and the 'name' attribute is specified
+ // and the 'name' ttribute names a variable that is set, then for each value in the 'name'
+ // variable that is present as a value in the select's option elements, the index of the
+ // first option element containing that value is added to the default index if that
+ // index has not been previously added.
+ String name = this->name();
+ if (m_defaultOptionIndices.isEmpty() && !name.isEmpty()) {
+ variable = pageState->getVariable(name);
+ if (!variable.isEmpty())
+ m_defaultOptionIndices = valueStringToOptionIndices(variable);
+ }
+
+ String value = parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));
+
+ // Spec: If the default option index is empty and the 'value' attribute is specified then
+ // for each value in the 'value' attribute that is present as a value in the select's
+ // option elements, the index of the first option element containing that value is added
+ // to the default index if that index has not been previously added.
+ if (m_defaultOptionIndices.isEmpty() && !value.isEmpty())
+ m_defaultOptionIndices = valueStringToOptionIndices(value);
+
+ // Spec: If the default option index is empty and the select is a multi-choice, then the
+ // default option index is set to zero. If the select is single-choice, then the default
+ // option index is set to one.
+ if (m_defaultOptionIndices.isEmpty())
+ m_defaultOptionIndices.append((unsigned) !m_data.multiple());
+}
+
+void WMLSelectElement::selectDefaultOptions()
+{
+ ASSERT(!m_defaultOptionIndices.isEmpty());
+
+ if (!m_data.multiple()) {
+ setSelectedIndex(m_defaultOptionIndices.first() - 1, false);
+ return;
+ }
+
+ Vector<unsigned>::const_iterator end = m_defaultOptionIndices.end();
+ for (Vector<unsigned>::const_iterator it = m_defaultOptionIndices.begin(); it != end; ++it)
+ setSelectedIndex((*it) - 1, false);
+}
+
+void WMLSelectElement::initializeVariables()
+{
+ ASSERT(!m_defaultOptionIndices.isEmpty());
+
+ WMLPageState* pageState = wmlPageStateForDocument(document());
+ if (!pageState)
+ return;
+
+ const Vector<Element*>& items = m_data.listItems(this);
+ if (items.isEmpty())
+ return;
+
+ // Spec: If the 'iname' attribute is specified, then the named variable is set with the default option index.
+ String iname = this->iname();
+ if (!iname.isEmpty())
+ pageState->storeVariable(iname, optionIndicesToString());
+
+ String name = this->name();
+ if (name.isEmpty())
+ return;
+
+ if (m_data.multiple()) {
+ // Spec: If the 'name' attribute is specified and the select is a multiple-choice element,
+ // then for each index greater than zero, the value of the 'value' attribute on the option
+ // element at the index is added to the name variable.
+ pageState->storeVariable(name, optionIndicesToValueString());
+ return;
+ }
+
+ // Spec: If the 'name' attribute is specified and the select is a single-choice element,
+ // then the named variable is set with the value of the 'value' attribute on the option
+ // element at the default option index.
+ unsigned optionIndex = m_defaultOptionIndices.first();
+ ASSERT(optionIndex >= 1);
+
+ int listIndex = optionToListIndex(optionIndex - 1);
+ ASSERT(listIndex >= 0);
+ ASSERT(listIndex < (int) items.size());
+
+ if (OptionElement* optionElement = toOptionElement(items[listIndex]))
+ pageState->storeVariable(name, optionElement->value());
+}
+
+void WMLSelectElement::updateVariables()
+{
+ WMLPageState* pageState = wmlPageStateForDocument(document());
+ if (!pageState)
+ return;
+
+ String name = this->name();
+ String iname = this->iname();
+ if (iname.isEmpty() && name.isEmpty())
+ return;
+
+ String nameString;
+ String inameString;
+
+ unsigned optionIndex = 0;
+ const Vector<Element*>& items = m_data.listItems(this);
+
+ for (unsigned i = 0; i < items.size(); ++i) {
+ OptionElement* optionElement = toOptionElement(items[i]);
+ if (!optionElement)
+ continue;
+
+ ++optionIndex;
+ if (!optionElement->selected())
+ continue;
+
+ if (!nameString.isEmpty())
+ nameString += ";";
+
+ if (!inameString.isEmpty())
+ inameString += ";";
+
+ nameString += optionElement->value();
+ inameString += String::number(optionIndex);
+ }
+
+ if (!name.isEmpty())
+ pageState->storeVariable(name, nameString);
+
+ if (!iname.isEmpty())
+ pageState->storeVariable(iname, inameString);
+}
+
+Vector<unsigned> WMLSelectElement::parseIndexValueString(const String& indexValue) const
+{
+ Vector<unsigned> indices;
+ if (indexValue.isEmpty())
+ return indices;
+
+ Vector<String> indexStrings;
+ indexValue.split(';', indexStrings);
+
+ bool ok = false;
+ unsigned optionCount = SelectElement::optionCount(m_data, this);
+
+ Vector<String>::const_iterator end = indexStrings.end();
+ for (Vector<String>::const_iterator it = indexStrings.begin(); it != end; ++it) {
+ unsigned parsedValue = (*it).toUIntStrict(&ok);
+ // Spec: Remove all non-integer indices from the value. Remove all out-of-range indices
+ // from the value, where out-of-range is defined as any index with a value greater than
+ // the number of options in the select or with a value less than one.
+ if (!ok || parsedValue < 1 || parsedValue > optionCount)
+ continue;
+
+ // Spec: Remove duplicate indices.
+ if (indices.find(parsedValue) == notFound)
+ indices.append(parsedValue);
+ }
+
+ return indices;
+}
+
+Vector<unsigned> WMLSelectElement::valueStringToOptionIndices(const String& value) const
+{
+ Vector<unsigned> indices;
+ if (value.isEmpty())
+ return indices;
+
+ const Vector<Element*>& items = m_data.listItems(this);
+ if (items.isEmpty())
+ return indices;
+
+ Vector<String> indexStrings;
+ value.split(';', indexStrings);
+
+ unsigned optionIndex = 0;
+
+ Vector<String>::const_iterator end = indexStrings.end();
+ for (Vector<String>::const_iterator it = indexStrings.begin(); it != end; ++it) {
+ String value = *it;
+
+ for (unsigned i = 0; i < items.size(); ++i) {
+ if (!isOptionElement(items[i]))
+ continue;
+
+ ++optionIndex;
+ if (OptionElement* optionElement = toOptionElement(items[i])) {
+ if (optionElement->value() == value) {
+ indices.append(optionIndex);
+ break;
+ }
+ }
+ }
+ }
+
+ return indices;
+}
+
+String WMLSelectElement::optionIndicesToValueString() const
+{
+ String valueString;
+ if (m_defaultOptionIndices.isEmpty())
+ return valueString;
+
+ const Vector<Element*>& items = m_data.listItems(this);
+ if (items.isEmpty())
+ return valueString;
+
+ Vector<unsigned>::const_iterator end = m_defaultOptionIndices.end();
+ for (Vector<unsigned>::const_iterator it = m_defaultOptionIndices.begin(); it != end; ++it) {
+ unsigned optionIndex = (*it);
+ if (optionIndex < 1 || optionIndex > items.size())
+ continue;
+
+ int listIndex = optionToListIndex((*it) - 1);
+ ASSERT(listIndex >= 0);
+ ASSERT(listIndex < (int) items.size());
+
+ if (OptionElement* optionElement = toOptionElement(items[listIndex])) {
+ if (!valueString.isEmpty())
+ valueString += ";";
+
+ valueString += optionElement->value();
+ }
+ }
+
+ return valueString;
+}
+
+String WMLSelectElement::optionIndicesToString() const
+{
+ String valueString;
+ if (m_defaultOptionIndices.isEmpty())
+ return valueString;
+
+ Vector<unsigned>::const_iterator end = m_defaultOptionIndices.end();
+ for (Vector<unsigned>::const_iterator it = m_defaultOptionIndices.begin(); it != end; ++it) {
+ if (!valueString.isEmpty())
+ valueString += ";";
+
+ valueString += String::number(*it);
+ }
+
+ return valueString;
+}
+
+String WMLSelectElement::name() const
+{
+ return parseValueForbiddingVariableReferences(getAttribute(HTMLNames::nameAttr));
+}
+
+String WMLSelectElement::value() const
+{
+ return parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));
+}
+
+String WMLSelectElement::iname() const
+{
+ return parseValueForbiddingVariableReferences(getAttribute(inameAttr));
+}
+
+String WMLSelectElement::ivalue() const
+{
+ return parseValueSubstitutingVariableReferences(getAttribute(ivalueAttr));
+}
+
}
#endif
diff --git a/src/3rdparty/webkit/WebCore/wml/WMLSelectElement.h b/src/3rdparty/webkit/WebCore/wml/WMLSelectElement.h
index 8d3e0f9..6cd3bcb 100644
--- a/src/3rdparty/webkit/WebCore/wml/WMLSelectElement.h
+++ b/src/3rdparty/webkit/WebCore/wml/WMLSelectElement.h
@@ -32,6 +32,9 @@ public:
WMLSelectElement(const QualifiedName&, Document*);
virtual ~WMLSelectElement();
+ virtual String title() const;
+
+ virtual const AtomicString& formControlName() const;
virtual const AtomicString& formControlType() const;
virtual bool isKeyboardFocusable(KeyboardEvent*) const;
@@ -47,7 +50,8 @@ public:
virtual bool canStartSelection() const { return false; }
virtual int selectedIndex() const;
- virtual void setSelectedIndex(int index, bool deselect = true, bool fireOnChange = false);
+ virtual void setSelectedIndex(int index, bool deselect = true);
+ virtual void setSelectedIndexByUser(int index, bool deselect = true, bool fireOnChangeNow = false);
virtual int size() const { return m_data.size(); }
virtual bool multiple() const { return m_data.multiple(); }
@@ -81,11 +85,28 @@ public:
void accessKeySetSelectedIndex(int);
void setRecalcListItems();
void scrollToSelection();
+ void selectInitialOptions();
private:
virtual void insertedIntoTree(bool);
+ void calculateDefaultOptionIndices();
+ void selectDefaultOptions();
+ void initializeVariables();
+ void updateVariables();
+
+ Vector<unsigned> parseIndexValueString(const String&) const;
+ Vector<unsigned> valueStringToOptionIndices(const String&) const;
+ String optionIndicesToValueString() const;
+ String optionIndicesToString() const;
+
+ String name() const;
+ String value() const;
+ String iname() const;
+ String ivalue() const;
+
SelectElementData m_data;
+ Vector<unsigned> m_defaultOptionIndices;
};
}
diff --git a/src/3rdparty/webkit/WebCore/wml/WMLSetvarElement.cpp b/src/3rdparty/webkit/WebCore/wml/WMLSetvarElement.cpp
index f0c50cc..e59b070 100644
--- a/src/3rdparty/webkit/WebCore/wml/WMLSetvarElement.cpp
+++ b/src/3rdparty/webkit/WebCore/wml/WMLSetvarElement.cpp
@@ -72,7 +72,7 @@ String WMLSetvarElement::name() const
String WMLSetvarElement::value() const
{
- return parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));
+ return parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));
}
}