summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebKit/qt
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@nokia.com>2009-09-29 10:36:30 (GMT)
committerJocelyn Turcotte <jocelyn.turcotte@nokia.com>2009-09-29 10:41:41 (GMT)
commitbb917438a942da68e065a4810b29697a1340cdd6 (patch)
tree84f2f55fda1d2895bc2d0f10529fcdbbef76adef /src/3rdparty/webkit/WebKit/qt
parentf234e50f3d29c4a7dfefd89d537787b1fc327eb2 (diff)
downloadQt-bb917438a942da68e065a4810b29697a1340cdd6.zip
Qt-bb917438a942da68e065a4810b29697a1340cdd6.tar.gz
Qt-bb917438a942da68e065a4810b29697a1340cdd6.tar.bz2
Updated WebKit from /home/joce/dev/qtwebkit/ to qtwebkit-4.6-snapshot-29092009-2 ( 999c28aa9f6ad9e0d6a26a794220e1cb45408a97 )
Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2009-09-28 HJK Reviewed by Simon Hausmann. Compile fix with namespaced Qt. * Api/qwebinspector_p.h: 2009-09-27 Joe Ligman <joseph.ligman@mindspring.com> Reviewed by Simon Hausmann. [Qt] Adding API setFocus and hasFocus to QWebElement. This API is needed for clients that want to check/set the focus node of the document. https://bugs.webkit.org/show_bug.cgi?id=29682 * Api/qwebelement.cpp: (QWebElement::hasFocus): (QWebElement::setFocus): * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::hasSetFocus): 2009-09-25 Csaba Osztrogonac <oszi@inf.u-szeged.hu> Reviewed by Simon Hausmann. [Qt] Make tst_qwebframe work if Qt built without SSL support https://bugs.webkit.org/show_bug.cgi?id=29735 * tests/qwebframe/tst_qwebframe.cpp: Missing #ifndef blocks added. 2009-09-24 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> Reviewed by Simon Hausmann. [Qt] Update QWebElement API to remove script related methods. QWebElement::evaluateScript is the only one kept, these are removed to postpone most of the QtWebKit<->JavaScript API design after 4.6. https://bugs.webkit.org/show_bug.cgi?id=29708 * Api/qwebelement.cpp: * Api/qwebelement.h: Methods removed: - QWebElement::callFunction - QWebElement::functions - QWebElement::scriptableProperty - QWebElement::setScriptableProperty - QWebElement::scriptableProperties * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::evaluateScript): 2009-09-25 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> Reviewed by Simon Hausmann. [Qt] Rename QWebElement::evaluateScript to QWebElement::evaluateJavaScript. https://bugs.webkit.org/show_bug.cgi?id=29709 * Api/qwebelement.cpp: (QWebElement::evaluateJavaScript): * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::evaluateJavaScript): 2009-09-25 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> Reviewed by Simon Hausmann. [Qt] Update the stypeProperty API of QWebElement. https://bugs.webkit.org/show_bug.cgi?id=29711 * Api/qwebelement.cpp: (QWebElement::styleProperty): - Merge the stypeProperty and the computedStyleProperty methods - Remove the default value for the style resolving enum - Rename ResolveRule to StyleResolveStrategy (QWebElement::setStyleProperty): - Remove the priority argument since it is possible to control the behaviour by adding !important or removing in the value. * Api/qwebelement.h: * tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::style): (tst_QWebElement::computedStyle): * tests/qwebframe/tst_qwebframe.cpp: 2009-09-24 Jon Honeycutt <jhoneycutt@apple.com> Reviewed by Alice Liu. * Api/qwebpage.cpp: (QWebPagePrivate::QWebPagePrivate): Pass 0 for new Page constructor argument.
Diffstat (limited to 'src/3rdparty/webkit/WebKit/qt')
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp396
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h26
-rw-r--r--src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp12
-rw-r--r--src/3rdparty/webkit/WebKit/qt/ChangeLog96
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp163
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp15
6 files changed, 237 insertions, 471 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp
index ff086f6..939d881 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp
@@ -95,16 +95,6 @@ public:
It is possible to replace the contents of child elements using
setPlainText() and setInnerXml(). To replace the element itself and its
contents, use setOuterXml().
-
- In the JavaScript DOM interfaces, elements can have additional functions
- depending on their type. For example, an HTML form element can be triggered
- to submit the entire form to the web server using the submit() function. A
- list of these special functions can be obtained in QWebElement using
- functions(); they can be invoked using callFunction().
-
- Similarly, element specific properties can be obtained using
- scriptableProperties() and read or written using scriptableProperty() or
- setScriptableProperty().
*/
/*!
@@ -473,6 +463,33 @@ bool QWebElement::hasAttributes() const
}
/*!
+ Returns true if the element has keyboard input focus; otherwise, returns false
+
+ \sa setFocus()
+*/
+bool QWebElement::hasFocus() const
+{
+ if (!m_element)
+ return false;
+ if (m_element->document())
+ return m_element == m_element->document()->focusedNode();
+ return false;
+}
+
+/*!
+ Gives keyboard input focus to this element
+
+ \sa hasFocus()
+*/
+void QWebElement::setFocus()
+{
+ if (!m_element)
+ return;
+ if (m_element->document() && m_element->isFocusable())
+ m_element->document()->setFocusedNode(m_element);
+}
+
+/*!
Returns the geometry of this element, relative to its containing frame.
\sa tagName()
@@ -673,41 +690,10 @@ static bool setupScriptContext(WebCore::Element* element, JSC::JSValue& thisValu
}
-static bool setupScriptObject(WebCore::Element* element, ScriptObject& object, ScriptState*& state, ScriptController*& scriptController)
-{
- if (!element)
- return false;
-
- Document* document = element->document();
- if (!document)
- return false;
-
- Frame* frame = document->frame();
- if (!frame)
- return false;
-
- scriptController = frame->script();
-
- state = scriptController->globalObject()->globalExec();
-
- JSC::JSValue thisValue = toJS(state, element);
- if (!thisValue)
- return false;
-
- JSC::JSObject* thisObject = thisValue.toObject(state);
- if (!thisObject)
- return false;
-
- object = ScriptObject(state, thisObject);
- return true;
-}
-
/*!
Executes \a scriptSource with this element as \c this object.
-
- \sa callFunction()
*/
-QVariant QWebElement::evaluateScript(const QString& scriptSource)
+QVariant QWebElement::evaluateJavaScript(const QString& scriptSource)
{
if (scriptSource.isEmpty())
return QVariant();
@@ -734,256 +720,25 @@ QVariant QWebElement::evaluateScript(const QString& scriptSource)
}
/*!
- Calls the function with the given \a name and \a arguments.
-
- The underlying DOM element that QWebElement wraps may have dedicated
- functions, depending on its type. For example, a form element can have the
- \c submit function, that would submit the form to the destination specified
- in the HTML.
-
- \sa functions()
-*/
-QVariant QWebElement::callFunction(const QString &name, const QVariantList &arguments)
-{
- ScriptState* state = 0;
- ScriptObject thisObject;
- ScriptController* scriptController = 0;
-
- if (!setupScriptObject(m_element, thisObject, state, scriptController))
- return QVariant();
-
- ScriptFunctionCall functionCall(state, thisObject, name);
-
- for (QVariantList::ConstIterator it = arguments.constBegin(), end = arguments.constEnd();
- it != end; ++it)
- functionCall.appendArgument(JSC::Bindings::convertQVariantToValue(state, scriptController->bindingRootObject(), *it));
-
- bool hadException = false;
- ScriptValue result = functionCall.call(hadException);
- if (hadException)
- return QVariant();
-
- int distance = 0;
- return JSC::Bindings::convertValueToQVariant(state, result.jsValue(), QMetaType::Void, &distance);
-}
-
-/*!
- Returns a list of function names this element supports.
-
- The function names returned are the same functions callable from the DOM
- element's JavaScript binding.
-
- \sa callFunction()
-*/
-QStringList QWebElement::functions() const
-{
- ScriptState* state = 0;
- ScriptObject thisObject;
- ScriptController* scriptController = 0;
-
- if (!setupScriptObject(m_element, thisObject, state, scriptController))
- return QStringList();
-
- JSC::JSObject* object = thisObject.jsObject();
- if (!object)
- return QStringList();
-
- QStringList names;
-
- // Enumerate the contents of the object
- JSC::PropertyNameArray properties(state);
- object->getPropertyNames(state, properties);
- for (JSC::PropertyNameArray::const_iterator it = properties.begin();
- it != properties.end(); ++it) {
-
- JSC::JSValue property = object->get(state, *it);
- if (!property)
- continue;
-
- JSC::JSObject* function = property.toObject(state);
- if (!function)
- continue;
-
- JSC::CallData callData;
- JSC::CallType callType = function->getCallData(callData);
- if (callType == JSC::CallTypeNone)
- continue;
-
- JSC::UString ustring = (*it).ustring();
- names << QString::fromUtf16((const ushort*)ustring.rep()->data(), ustring.size());
- }
-
- if (state->hadException())
- state->clearException();
-
- return names;
-}
-
-/*!
- Returns the value of the element's \a name property. If no such property
- exists, an invalid QVariant is returned.
-
- The return value's property has the same value as the corresponding
- property in the element's JavaScript binding with the same name.
-
- Information about all available properties is provided through
- scriptProperties().
-
- \sa setScriptableProperty(), scriptableProperties()
-*/
-QVariant QWebElement::scriptableProperty(const QString &name) const
-{
- ScriptState* state = 0;
- ScriptObject thisObject;
- ScriptController *scriptController = 0;
-
- if (!setupScriptObject(m_element, thisObject, state, scriptController))
- return QVariant();
-
- String wcName(name);
- JSC::JSValue property = thisObject.jsObject()->get(state, JSC::Identifier(state, wcName));
-
- // ###
- if (state->hadException())
- state->clearException();
-
- int distance = 0;
- return JSC::Bindings::convertValueToQVariant(state, property, QMetaType::Void, &distance);
-}
-
-/*!
- Sets the value of the element's \a name property to \a value.
-
- Information about all available properties is provided through
- scriptProperties().
-
- Setting the property will affect the corresponding property in the
- element's JavaScript binding with the same name.
-
- \sa scriptableProperty(), scriptableProperties()
-*/
-void QWebElement::setScriptableProperty(const QString &name, const QVariant &value)
-{
- ScriptState* state = 0;
- ScriptObject thisObject;
- ScriptController* scriptController = 0;
-
- if (!setupScriptObject(m_element, thisObject, state, scriptController))
- return;
-
- JSC::JSValue jsValue = JSC::Bindings::convertQVariantToValue(state, scriptController->bindingRootObject(), value);
- if (!jsValue)
- return;
-
- String wcName(name);
- JSC::PutPropertySlot slot;
- thisObject.jsObject()->put(state, JSC::Identifier(state, wcName), jsValue, slot);
- if (state->hadException())
- state->clearException();
-}
-
-/*!
- Returns a list of property names this element supports.
-
- The function names returned are the same properties that are accessible
- from the DOM element's JavaScript binding.
-
- \sa setScriptableProperty(), scriptableProperty()
-*/
-QStringList QWebElement::scriptableProperties() const
-{
- if (!m_element)
- return QStringList();
-
- Document* document = m_element->document();
- if (!document)
- return QStringList();
-
- Frame* frame = document->frame();
- if (!frame)
- return QStringList();
-
- ScriptController* script = frame->script();
- JSC::ExecState* exec = script->globalObject()->globalExec();
-
- JSC::JSValue thisValue = toJS(exec, m_element);
- if (!thisValue)
- return QStringList();
-
- JSC::JSObject* object = thisValue.toObject(exec);
- if (!object)
- return QStringList();
-
- QStringList names;
-
- // Enumerate the contents of the object
- JSC::PropertyNameArray properties(exec);
- object->getPropertyNames(exec, properties);
- for (JSC::PropertyNameArray::const_iterator it = properties.begin();
- it != properties.end(); ++it) {
-
- JSC::JSValue property = object->get(exec, *it);
- if (!property)
- continue;
-
- JSC::JSObject* function = property.toObject(exec);
- if (!function)
- continue;
-
- JSC::CallData callData;
- JSC::CallType callType = function->getCallData(callData);
- if (callType != JSC::CallTypeNone)
- continue;
-
- JSC::UString ustring = (*it).ustring();
- names << QString::fromUtf16((const ushort*)ustring.rep()->data(), ustring.size());
- }
-
- if (exec->hadException())
- exec->clearException();
-
- return names;
-}
-
-/*!
- \enum QWebElement::ResolveRule
- \since 4.6
+ \enum QWebElement::StyleResolveStrategy
This enum describes how QWebElement's styleProperty resolves the given
property name.
- \value IgnoreCascadingStyles Return the property value as it is defined in
+ \value InlineStyle Return the property value as it is defined in
the element, without respecting style inheritance and other CSS
rules.
- \value RespectCascadingStyles The property's value is determined using the
+ \value CascadedStyle The property's value is determined using the
inheritance and importance rules defined in the document's
stylesheet.
+ \value ComputedStyle The property's value is the absolute value
+ of the style property resolved from the environment.
*/
/*!
- \enum QWebElement::StylePriority
- \since 4.6
-
- This enum describes the priority newly set CSS properties should have when
- set using QWebElement::setStyleProperty().
-
- \value NormalStylePriority Define the property without important priority
- even if "!important" is explicitly set in \a value.
- \value DeclaredStylePriority Define the property respecting the priority
- specified in \a value.
- \value ImportantStylePriority Define the property to have an important
- priority. This is equal to appending "!important" to the value.
-*/
-
-/*!
- Returns the value of the style with the given \a name. If a style with
- \a name does not exist, an empty string is returned.
-
- If \a rule is IgnoreCascadingStyles, the value defined inside the element
- (inline in CSS terminology) is returned.
-
- if \a rule is RespectCascadingStyles, the actual style applied to the
- element is returned.
+ Returns the value of the style with the given \a name using the specified
+ \a strategy. If a style with \a name does not exist, an empty string is
+ returned.
In CSS, the cascading part depends on which CSS rule has priority and is
thus applied. Generally, the last defined rule has priority. Thus, an
@@ -997,7 +752,8 @@ QStringList QWebElement::scriptableProperties() const
\sa setStyleProperty()
*/
-QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const
+
+QString QWebElement::styleProperty(const QString &name, StyleResolveStrategy strategy) const
{
if (!m_element || !m_element->isStyledElement())
return QString();
@@ -1009,10 +765,10 @@ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const
CSSStyleDeclaration* style = static_cast<StyledElement*>(m_element)->style();
- if (rule == IgnoreCascadingStyles)
+ if (strategy == InlineStyle)
return style->getPropertyValue(propID);
- if (rule == RespectCascadingStyles) {
+ if (strategy == CascadedStyle) {
if (style->getPropertyPriority(propID))
return style->getPropertyValue(propID);
@@ -1040,33 +796,33 @@ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const
return style->getPropertyValue(propID);
}
+ if (strategy == ComputedStyle) {
+ if (!m_element || !m_element->isStyledElement())
+ return QString();
+
+ int propID = cssPropertyID(name);
+
+ RefPtr<CSSComputedStyleDeclaration> style = computedStyle(m_element);
+ if (!propID || !style)
+ return QString();
+
+ return style->getPropertyValue(propID);
+ }
+
return QString();
}
/*!
- Sets the value of the style with the given \a name to \a value.
+ Sets the value of the inline style with the given \a name to \a value.
Setting a value, does not necessarily mean that it will become the applied
value, due to the fact that the style property's value might have been set
- earlier with priority in external or embedded style declarations.
-
- In order to ensure that the value will be applied, ImportantStylePriority
- should be used as \a priority.
+ earlier with a higher priority in external or embedded style declarations.
- Following the CSS syntax for property values, this is equal to appending
+ In order to ensure that the value will be applied, you may have to append
"!important" to the value.
-
- This syntax is supported when using DeclaredStylePriority as \a priority.
-
- Using NormalStylePriority as \a priority, the property will have normal
- priority, and any "!important" declaration will be ignored. On the other
- hand, using ImportantStylePriority sets the important priority even when
- it is not explicitly passed in \a value.
-
- By using DeclaredStylePriority as \a priority the property will respect the
- priority specified in \a value.
*/
-void QWebElement::setStyleProperty(const QString &name, const QString &value, StylePriority priority)
+void QWebElement::setStyleProperty(const QString &name, const QString &value)
{
if (!m_element || !m_element->isStyledElement())
return;
@@ -1077,43 +833,7 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value, St
return;
ExceptionCode exception = 0;
-
- const QRegExp hasImportantTest(QLatin1String("!\\s*important"));
- int index = value.indexOf(hasImportantTest);
-
- QString newValue = (index != -1) ? value.left(index - 1) : value;
-
- switch (priority) {
- case NormalStylePriority:
- style->setProperty(name, newValue, "", exception);
- break;
- case DeclaredStylePriority:
- style->setProperty(name, newValue, (index != -1) ? "important" : "", exception);
- break;
- case ImportantStylePriority:
- style->setProperty(name, newValue, "important", exception);
- break;
- default:
- break;
- }
-}
-
-/*!
- Returns the computed value for style with the given \a name. If a style
- with \a name does not exist, an empty string is returned.
-*/
-QString QWebElement::computedStyleProperty(const QString &name) const
-{
- if (!m_element || !m_element->isStyledElement())
- return QString();
-
- int propID = cssPropertyID(name);
-
- RefPtr<CSSComputedStyleDeclaration> style = computedStyle(m_element);
- if (!propID || !style)
- return QString();
-
- return style->getPropertyValue(propID);
+ style->setProperty(name, value, exception);
}
/*!
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
index 5f4870c..3db4637 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h
@@ -74,6 +74,9 @@ public:
void removeClass(const QString& name);
void toggleClass(const QString& name);
+ bool hasFocus() const;
+ void setFocus();
+
QRect geometry() const;
QString tagName() const;
@@ -120,22 +123,15 @@ public:
void removeFromDocument();
void removeChildren();
- QVariant evaluateScript(const QString& scriptSource);
-
- QVariant callFunction(const QString& functionName, const QVariantList& arguments = QVariantList());
- QStringList functions() const;
-
- QVariant scriptableProperty(const QString& name) const;
- void setScriptableProperty(const QString& name, const QVariant& value);
- QStringList scriptableProperties() const;
-
- enum ResolveRule { IgnoreCascadingStyles, RespectCascadingStyles };
- QString styleProperty(const QString& name, ResolveRule = IgnoreCascadingStyles) const;
-
- enum StylePriority { NormalStylePriority, DeclaredStylePriority, ImportantStylePriority };
- void setStyleProperty(const QString& name, const QString& value, StylePriority = DeclaredStylePriority);
+ QVariant evaluateJavaScript(const QString& scriptSource);
- QString computedStyleProperty(const QString& name) const;
+ enum StyleResolveStrategy {
+ InlineStyle,
+ CascadedStyle,
+ ComputedStyle,
+ };
+ QString styleProperty(const QString& name, StyleResolveStrategy strategy) const;
+ void setStyleProperty(const QString& name, const QString& value);
private:
explicit QWebElement(WebCore::Element*);
diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
index af27788..aad718b 100644
--- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp
@@ -271,7 +271,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
contextMenuClient = new ContextMenuClientQt();
editorClient = new EditorClientQt(q);
page = new Page(chromeClient, contextMenuClient, editorClient,
- new DragClientQt(q), new InspectorClientQt(q));
+ new DragClientQt(q), new InspectorClientQt(q), 0);
// ### should be configurable
page->settings()->setDefaultTextEncodingName("iso-8859-1");
@@ -1491,11 +1491,9 @@ QWebPage::QWebPage(QObject *parent)
*/
QWebPage::~QWebPage()
{
- if (d->mainFrame) {
- FrameLoader *loader = d->mainFrame->d->frame->loader();
- if (loader)
- loader->detachFromParent();
- }
+ FrameLoader *loader = d->mainFrame->d->frame->loader();
+ if (loader)
+ loader->detachFromParent();
if (d->inspector)
d->inspector->setPage(0);
delete d;
@@ -1522,7 +1520,6 @@ QWebFrame *QWebPage::mainFrame() const
*/
QWebFrame *QWebPage::currentFrame() const
{
- d->createMainFrame();
return static_cast<WebCore::FrameLoaderClientQt *>(d->page->focusController()->focusedOrMainFrame()->loader()->client())->webFrame();
}
@@ -1548,7 +1545,6 @@ QWebFrame* QWebPage::frameAt(const QPoint& pos) const
*/
QWebHistory *QWebPage::history() const
{
- d->createMainFrame();
return &d->history;
}
diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog
index 7020ec0..a8b5c38 100644
--- a/src/3rdparty/webkit/WebKit/qt/ChangeLog
+++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog
@@ -1,3 +1,99 @@
+2009-09-28 Andre Poenitz <andre.poenitz@trolltech.com>
+
+ Reviewed by Simon Hausmann.
+
+ Compile fix with namespaced Qt.
+
+ * Api/qwebinspector_p.h:
+
+2009-09-27 Joe Ligman <joseph.ligman@mindspring.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Adding API setFocus and hasFocus to QWebElement. This API is needed for
+ clients that want to check/set the focus node of the document.
+ https://bugs.webkit.org/show_bug.cgi?id=29682
+
+ * Api/qwebelement.cpp:
+ (QWebElement::hasFocus):
+ (QWebElement::setFocus):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::hasSetFocus):
+
+2009-09-25 Csaba Osztrogonac <oszi@inf.u-szeged.hu>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Make tst_qwebframe work if Qt built without SSL support
+ https://bugs.webkit.org/show_bug.cgi?id=29735
+
+ * tests/qwebframe/tst_qwebframe.cpp: Missing #ifndef blocks added.
+
+2009-09-24 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Update QWebElement API to remove script related methods.
+ QWebElement::evaluateScript is the only one kept, these are
+ removed to postpone most of the QtWebKit<->JavaScript API design
+ after 4.6.
+ https://bugs.webkit.org/show_bug.cgi?id=29708
+
+ * Api/qwebelement.cpp:
+ * Api/qwebelement.h:
+ Methods removed:
+ - QWebElement::callFunction
+ - QWebElement::functions
+ - QWebElement::scriptableProperty
+ - QWebElement::setScriptableProperty
+ - QWebElement::scriptableProperties
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::evaluateScript):
+
+2009-09-25 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Rename QWebElement::evaluateScript
+ to QWebElement::evaluateJavaScript.
+ https://bugs.webkit.org/show_bug.cgi?id=29709
+
+ * Api/qwebelement.cpp:
+ (QWebElement::evaluateJavaScript):
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::evaluateJavaScript):
+
+2009-09-25 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Update the stypeProperty API of QWebElement.
+ https://bugs.webkit.org/show_bug.cgi?id=29711
+
+ * Api/qwebelement.cpp:
+ (QWebElement::styleProperty):
+ - Merge the stypeProperty and the computedStyleProperty methods
+ - Remove the default value for the style resolving enum
+ - Rename ResolveRule to StyleResolveStrategy
+ (QWebElement::setStyleProperty):
+ - Remove the priority argument since it is possible to control the
+ behaviour by adding !important or removing in the value.
+ * Api/qwebelement.h:
+ * tests/qwebelement/tst_qwebelement.cpp:
+ (tst_QWebElement::style):
+ (tst_QWebElement::computedStyle):
+ * tests/qwebframe/tst_qwebframe.cpp:
+
+2009-09-24 Jon Honeycutt <jhoneycutt@apple.com>
+
+ Reviewed by Alice Liu.
+
+ * Api/qwebpage.cpp:
+ (QWebPagePrivate::QWebPagePrivate):
+ Pass 0 for new Page constructor argument.
+
2009-09-24 Martin Smith <msmith@trolltech.com>
Reviewed by Simon Hausmann.
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
index 0819a3a..00783d1 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
@@ -71,15 +71,11 @@ private slots:
void classes();
void namespaceURI();
void foreachManipulation();
- void evaluateScript();
- void callFunction();
- void callFunctionSubmitForm();
- void functionNames();
+ void evaluateJavaScript();
void documentElement();
void frame();
void style();
void computedStyle();
- void properties();
void appendAndPrepend();
void insertBeforeAndAfter();
void remove();
@@ -90,6 +86,7 @@ private slots:
void nullSelect();
void firstChildNextSibling();
void lastChildPreviousSibling();
+ void hasSetFocus();
private:
QWebView* m_view;
@@ -282,69 +279,31 @@ void tst_QWebElement::foreachManipulation()
QCOMPARE(body.findAll("div").count(), 4);
}
-void tst_QWebElement::evaluateScript()
+void tst_QWebElement::evaluateJavaScript()
{
QVariant result;
m_mainFrame->setHtml("<body><p>test");
QWebElement para = m_mainFrame->findFirstElement("p");
- result = para.evaluateScript("this.tagName");
+ result = para.evaluateJavaScript("this.tagName");
QVERIFY(result.isValid());
QVERIFY(result.type() == QVariant::String);
QCOMPARE(result.toString(), QLatin1String("P"));
- QVERIFY(para.functions().contains("hasAttributes"));
- result = para.evaluateScript("this.hasAttributes()");
+ result = para.evaluateJavaScript("this.hasAttributes()");
QVERIFY(result.isValid());
QVERIFY(result.type() == QVariant::Bool);
QVERIFY(!result.toBool());
- para.evaluateScript("this.setAttribute('align', 'left');");
+ para.evaluateJavaScript("this.setAttribute('align', 'left');");
QCOMPARE(para.attribute("align"), QLatin1String("left"));
- result = para.evaluateScript("this.hasAttributes()");
+ result = para.evaluateJavaScript("this.hasAttributes()");
QVERIFY(result.isValid());
QVERIFY(result.type() == QVariant::Bool);
QVERIFY(result.toBool());
}
-void tst_QWebElement::callFunction()
-{
- m_mainFrame->setHtml("<body><p>test");
- QWebElement body = m_mainFrame->documentElement();
- QVERIFY(body.functions().contains("hasChildNodes"));
- QVariant result = body.callFunction("hasChildNodes");
- QVERIFY(result.isValid());
- QVERIFY(result.type() == QVariant::Bool);
- QVERIFY(result.toBool());
-
- body.callFunction("setAttribute", QVariantList() << "foo" << "bar");
- QCOMPARE(body.attribute("foo"), QString("bar"));
-}
-
-void tst_QWebElement::callFunctionSubmitForm()
-{
- m_mainFrame->setHtml(QString("<html><body><form name='tstform' action='data:text/html,foo'method='get'>"
- "<input type='text'><input type='submit'></form></body></html>"), QUrl());
-
- QWebElement form = m_mainFrame->documentElement().findAll("form").at(0);
- QVERIFY(form.functions().contains("submit"));
- QVERIFY(!form.isNull());
- form.callFunction("submit");
-
- waitForSignal(m_page, SIGNAL(loadFinished(bool)));
- QCOMPARE(m_mainFrame->url().toString(), QString("data:text/html,foo?"));
-}
-
-void tst_QWebElement::functionNames()
-{
- m_mainFrame->setHtml("<body><p>Test");
-
- QWebElement body = m_mainFrame->documentElement();
-
- QVERIFY(body.functions().contains("setAttribute"));
-}
-
void tst_QWebElement::documentElement()
{
m_mainFrame->setHtml("<body><p>Test");
@@ -398,27 +357,27 @@ void tst_QWebElement::style()
m_mainFrame->setHtml(html);
QWebElement p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QVERIFY(p.styleProperty("cursor").isEmpty());
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty());
p.setStyleProperty("color", "red");
p.setStyleProperty("cursor", "auto");
- QCOMPARE(p.styleProperty("color"), QLatin1String("red"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("yellow"));
- QCOMPARE(p.styleProperty("cursor"), QLatin1String("auto"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("yellow"));
+ QCOMPARE(p.styleProperty("cursor", QWebElement::InlineStyle), QLatin1String("auto"));
p.setStyleProperty("color", "green !important");
- QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green"));
p.setStyleProperty("color", "blue");
- QCOMPARE(p.styleProperty("color"), QLatin1String("green"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("green"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("green"));
- p.setStyleProperty("color", "blue", QWebElement::ImportantStylePriority);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+ p.setStyleProperty("color", "blue !important");
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue"));
QString html2 = "<head>"
"<style type='text/css'>"
@@ -434,8 +393,8 @@ void tst_QWebElement::style()
m_mainFrame->setHtml(html2);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue"));
QString html3 = "<head>"
"<style type='text/css'>"
@@ -451,8 +410,8 @@ void tst_QWebElement::style()
m_mainFrame->setHtml(html3);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("blue"));
QString html5 = "<head>"
"<style type='text/css'>"
@@ -468,8 +427,8 @@ void tst_QWebElement::style()
m_mainFrame->setHtml(html5);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String(""));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("red"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String(""));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red"));
QString html6 = "<head>"
"<link rel='stylesheet' href='qrc:/style.css' type='text/css' />"
@@ -489,8 +448,8 @@ void tst_QWebElement::style()
QTest::qWait(200);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String("blue"));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("blue"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("black"));
QString html7 = "<head>"
"<style type='text/css'>"
@@ -507,15 +466,15 @@ void tst_QWebElement::style()
QTest::qWait(200);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("black"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("black"));
QString html8 = "<body><p>some text</p></body>";
m_mainFrame->setHtml(html8);
p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color"), QLatin1String(""));
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String(""));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String(""));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String(""));
}
void tst_QWebElement::computedStyle()
@@ -524,47 +483,16 @@ void tst_QWebElement::computedStyle()
m_mainFrame->setHtml(html);
QWebElement p = m_mainFrame->documentElement().findAll("p").at(0);
- QCOMPARE(p.computedStyleProperty("cursor"), QLatin1String("auto"));
- QVERIFY(!p.computedStyleProperty("cursor").isEmpty());
- QVERIFY(p.styleProperty("cursor").isEmpty());
+ QCOMPARE(p.styleProperty("cursor", QWebElement::ComputedStyle), QLatin1String("auto"));
+ QVERIFY(!p.styleProperty("cursor", QWebElement::ComputedStyle).isEmpty());
+ QVERIFY(p.styleProperty("cursor", QWebElement::InlineStyle).isEmpty());
p.setStyleProperty("cursor", "text");
p.setStyleProperty("color", "red");
- QCOMPARE(p.computedStyleProperty("cursor"), QLatin1String("text"));
- QCOMPARE(p.computedStyleProperty("color"), QLatin1String("rgb(255, 0, 0)"));
- QCOMPARE(p.styleProperty("color"), QLatin1String("red"));
-}
-
-void tst_QWebElement::properties()
-{
- m_mainFrame->setHtml("<body><form><input type=checkbox id=ourcheckbox checked=true>");
-
- QWebElement checkBox = m_mainFrame->findFirstElement("#ourcheckbox");
- QVERIFY(!checkBox.isNull());
-
- QVERIFY(checkBox.scriptableProperties().contains("checked"));
-
- QCOMPARE(checkBox.scriptableProperty("checked"), QVariant(true));
- checkBox.setScriptableProperty("checked", false);
- QCOMPARE(checkBox.scriptableProperty("checked"), QVariant(false));
-
- QVERIFY(!checkBox.scriptableProperties().contains("non_existant"));
- QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant());
-
- checkBox.setScriptableProperty("non_existant", "test");
-
- QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant("test"));
- QVERIFY(checkBox.scriptableProperties().contains("non_existant"));
-
- // removing scriptableProperties is currently not supported. We should look into this
- // and consider the option of just allowing through the QtScript API only.
-#if 0
- checkBox.setScriptableProperty("non_existant", QVariant());
-
- QCOMPARE(checkBox.scriptableProperty("non_existant"), QVariant());
- QVERIFY(!checkBox.scriptableProperties().contains("non_existant"));
-#endif
+ QCOMPARE(p.styleProperty("cursor", QWebElement::ComputedStyle), QLatin1String("text"));
+ QCOMPARE(p.styleProperty("color", QWebElement::ComputedStyle), QLatin1String("rgb(255, 0, 0)"));
+ QCOMPARE(p.styleProperty("color", QWebElement::InlineStyle), QLatin1String("red"));
}
void tst_QWebElement::appendAndPrepend()
@@ -878,5 +806,24 @@ void tst_QWebElement::lastChildPreviousSibling()
QVERIFY(p.previousSibling().isNull());
}
+void tst_QWebElement::hasSetFocus()
+{
+ m_mainFrame->setHtml("<html><body>" \
+ "<input type='text' id='input1'/>" \
+ "<br>"\
+ "<input type='text' id='input2'/>" \
+ "</body></html>");
+
+ QList<QWebElement> inputs = m_mainFrame->documentElement().findAll("input");
+ QWebElement input1 = inputs.at(0);
+ input1.setFocus();
+ QVERIFY(input1.hasFocus());
+
+ QWebElement input2 = inputs.at(1);
+ input2.setFocus();
+ QVERIFY(!input1.hasFocus());
+ QVERIFY(input2.hasFocus());
+}
+
QTEST_MAIN(tst_QWebElement)
#include "tst_qwebelement.moc"
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index 729b971..797446b 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -33,7 +33,9 @@
#include <QRegExp>
#include <QNetworkRequest>
#include <QNetworkReply>
+#ifndef QT_NO_OPENSSL
#include <qsslerror.h>
+#endif
#include "../util.h"
//TESTED_CLASS=
@@ -2183,8 +2185,11 @@ public:
if (request.url() == QUrl("qrc:/test1.html")) {
setHeader(QNetworkRequest::LocationHeader, QString("qrc:/test2.html"));
setAttribute(QNetworkRequest::RedirectionTargetAttribute, QUrl("qrc:/test2.html"));
- } else if (request.url() == QUrl("qrc:/fake-ssl-error.html"))
+ }
+#ifndef QT_NO_OPENSSL
+ else if (request.url() == QUrl("qrc:/fake-ssl-error.html"))
setError(QNetworkReply::SslHandshakeFailedError, tr("Fake error !")); // force a ssl error
+#endif
else if (request.url() == QUrl("http://abcdef.abcdef/"))
setError(QNetworkReply::HostNotFoundError, tr("Invalid URL"));
@@ -2211,8 +2216,10 @@ private slots:
emit error(this->error());
else if (request().url() == QUrl("http://abcdef.abcdef/"))
emit metaDataChanged();
+#ifndef QT_NO_OPENSSL
else if (request().url() == QUrl("qrc:/fake-ssl-error.html"))
return;
+#endif
emit readyRead();
emit finished();
@@ -2232,12 +2239,14 @@ protected:
if (op == QNetworkAccessManager::GetOperation)
if (url == "qrc:/test1.html" || url == "http://abcdef.abcdef/")
return new FakeReply(request, this);
+#ifndef QT_NO_OPENSSL
else if (url == "qrc:/fake-ssl-error.html") {
FakeReply* reply = new FakeReply(request, this);
QList<QSslError> errors;
emit sslErrors(reply, errors << QSslError(QSslError::UnspecifiedError));
return reply;
}
+#endif
return QNetworkAccessManager::createRequest(op, request, outgoingData);
}
@@ -2271,6 +2280,7 @@ void tst_QWebFrame::requestedUrl()
QCOMPARE(frame->requestedUrl(), QUrl("http://abcdef.abcdef/"));
QCOMPARE(frame->url(), QUrl("http://abcdef.abcdef/"));
+#ifndef QT_NO_OPENSSL
qRegisterMetaType<QList<QSslError> >("QList<QSslError>");
qRegisterMetaType<QNetworkReply* >("QNetworkReply*");
@@ -2280,6 +2290,7 @@ void tst_QWebFrame::requestedUrl()
QCOMPARE(spy2.count(), 1);
QCOMPARE(frame->requestedUrl(), QUrl("qrc:/fake-ssl-error.html"));
QCOMPARE(frame->url(), QUrl("qrc:/fake-ssl-error.html"));
+#endif
}
void tst_QWebFrame::javaScriptWindowObjectCleared_data()
@@ -2356,7 +2367,7 @@ void tst_QWebFrame::setHtmlWithResource()
QCOMPARE(spy.size(), 2);
QWebElement p = frame->documentElement().findAll("p").at(0);
- QCOMPARE(p.styleProperty("color", QWebElement::RespectCascadingStyles), QLatin1String("red"));
+ QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red"));
}
class TestNetworkManager : public QNetworkAccessManager