summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/qt
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-24 11:24:40 +0100
committerBen Murdoch <benm@google.com>2011-06-02 09:53:15 +0100
commit81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch)
tree7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/platform/qt
parent94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff)
downloadexternal_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/platform/qt')
-rw-r--r--Source/WebCore/platform/qt/CookieJarQt.cpp67
-rw-r--r--Source/WebCore/platform/qt/GeolocationServiceQt.cpp115
-rw-r--r--Source/WebCore/platform/qt/GeolocationServiceQt.h70
-rw-r--r--Source/WebCore/platform/qt/PlatformTouchEventQt.cpp2
-rw-r--r--Source/WebCore/platform/qt/RenderThemeQt.cpp33
-rw-r--r--Source/WebCore/platform/qt/SharedTimerQt.cpp8
-rw-r--r--Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp10
7 files changed, 84 insertions, 221 deletions
diff --git a/Source/WebCore/platform/qt/CookieJarQt.cpp b/Source/WebCore/platform/qt/CookieJarQt.cpp
index e5a2dcd..db4a42a 100644
--- a/Source/WebCore/platform/qt/CookieJarQt.cpp
+++ b/Source/WebCore/platform/qt/CookieJarQt.cpp
@@ -34,7 +34,6 @@
#include "KURL.h"
#include "NetworkingContext.h"
#include "PlatformString.h"
-#include "QtNAMThreadSafeProxy.h"
#include "qwebframe.h"
#include "qwebpage.h"
#include <QNetworkAccessManager>
@@ -43,8 +42,7 @@
namespace WebCore {
-
-static QNetworkAccessManager *networkAccessManager(const Document *document)
+static QNetworkCookieJar *cookieJar(const Document *document)
{
if (!document)
return 0;
@@ -54,30 +52,38 @@ static QNetworkAccessManager *networkAccessManager(const Document *document)
FrameLoader* loader = frame->loader();
if (!loader)
return 0;
- return loader->networkingContext()->networkAccessManager();
+ QNetworkAccessManager* manager = loader->networkingContext()->networkAccessManager();
+ QNetworkCookieJar* jar = manager->cookieJar();
+ return jar;
}
void setCookies(Document* document, const KURL& url, const String& value)
{
- QNetworkAccessManager* manager = networkAccessManager(document);
- if (!manager)
+ QUrl u(url);
+ QUrl p(document->firstPartyForCookies());
+ QNetworkCookieJar* jar = cookieJar(document);
+ if (!jar)
return;
- // Create the manipulator on the heap to let it live until the
- // async request is picked by the other thread's event loop.
- QtNAMThreadSafeProxy* managerProxy = new QtNAMThreadSafeProxy(manager);
- managerProxy->setCookies(url, value);
- managerProxy->deleteLater();
+ QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toAscii());
+ QList<QNetworkCookie>::Iterator it = cookies.begin();
+ while (it != cookies.end()) {
+ if (it->isHttpOnly())
+ it = cookies.erase(it);
+ else
+ ++it;
+ }
+ jar->setCookiesFromUrl(cookies, u);
}
String cookies(const Document* document, const KURL& url)
{
- QNetworkAccessManager* manager = networkAccessManager(document);
- if (!manager)
+ QUrl u(url);
+ QNetworkCookieJar* jar = cookieJar(document);
+ if (!jar)
return String();
- QtNAMThreadSafeProxy managerProxy(manager);
- QList<QNetworkCookie> cookies = managerProxy.cookiesForUrl(url);
+ QList<QNetworkCookie> cookies = jar->cookiesForUrl(u);
if (cookies.isEmpty())
return String();
@@ -94,12 +100,12 @@ String cookies(const Document* document, const KURL& url)
String cookieRequestHeaderFieldValue(const Document* document, const KURL &url)
{
- QNetworkAccessManager* manager = networkAccessManager(document);
- if (!manager)
+ QUrl u(url);
+ QNetworkCookieJar* jar = cookieJar(document);
+ if (!jar)
return String();
- QtNAMThreadSafeProxy managerProxy(manager);
- QList<QNetworkCookie> cookies = managerProxy.cookiesForUrl(url);
+ QList<QNetworkCookie> cookies = jar->cookiesForUrl(u);
if (cookies.isEmpty())
return String();
@@ -114,12 +120,8 @@ String cookieRequestHeaderFieldValue(const Document* document, const KURL &url)
bool cookiesEnabled(const Document* document)
{
- QNetworkAccessManager* manager = networkAccessManager(document);
- if (!manager)
- return false;
-
- QtNAMThreadSafeProxy managerProxy(manager);
- return managerProxy.hasCookieJar();
+ QNetworkCookieJar* jar = cookieJar(document);
+ return jar;
}
bool getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
@@ -134,6 +136,21 @@ void deleteCookie(const Document*, const KURL&, const String&)
// FIXME: Not yet implemented
}
+void getHostnamesWithCookies(HashSet<String>& hostnames)
+{
+ // FIXME: Not yet implemented
+}
+
+void deleteCookiesForHostname(const String& hostname)
+{
+ // FIXME: Not yet implemented
+}
+
+void deleteAllCookies()
+{
+ // FIXME: Not yet implemented
+}
+
}
// vim: ts=4 sw=4 et
diff --git a/Source/WebCore/platform/qt/GeolocationServiceQt.cpp b/Source/WebCore/platform/qt/GeolocationServiceQt.cpp
deleted file mode 100644
index f4379b2..0000000
--- a/Source/WebCore/platform/qt/GeolocationServiceQt.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GeolocationServiceQt.h"
-
-#include "Geolocation.h"
-#include "Geoposition.h"
-#include "PositionError.h"
-#include "PositionOptions.h"
-
-using namespace QtMobility;
-
-namespace WebCore {
-
-GeolocationService::FactoryFunction* GeolocationService::s_factoryFunction = &GeolocationServiceQt::create;
-
-GeolocationService* GeolocationServiceQt::create(GeolocationServiceClient* client)
-{
- return new GeolocationServiceQt(client);
-}
-
-GeolocationServiceQt::GeolocationServiceQt(GeolocationServiceClient* client)
- : GeolocationService(client)
- , m_lastPosition(0)
- , m_lastError(0)
-{
- m_location = QGeoPositionInfoSource::createDefaultSource(this);
-
- if (m_location)
- connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
-}
-
-GeolocationServiceQt::~GeolocationServiceQt()
-{
- delete m_location;
-}
-
-void GeolocationServiceQt::positionUpdated(const QGeoPositionInfo &geoPosition)
-{
- if (!geoPosition.isValid())
- errorOccurred();
-
- QGeoCoordinate coord = geoPosition.coordinate();
- double latitude = coord.latitude();
- double longitude = coord.longitude();
- bool providesAltitude = (geoPosition.coordinate().type() == QGeoCoordinate::Coordinate3D);
- double altitude = coord.altitude();
-
- double accuracy = geoPosition.attribute(QGeoPositionInfo::HorizontalAccuracy);
-
- bool providesAltitudeAccuracy = geoPosition.hasAttribute(QGeoPositionInfo::VerticalAccuracy);
- double altitudeAccuracy = geoPosition.attribute(QGeoPositionInfo::VerticalAccuracy);
-
- bool providesHeading = geoPosition.hasAttribute(QGeoPositionInfo::Direction);
- double heading = geoPosition.attribute(QGeoPositionInfo::Direction);
-
- bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed);
- double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed);
-
- RefPtr<Coordinates> coordinates = Coordinates::create(latitude, longitude, providesAltitude, altitude,
- accuracy, providesAltitudeAccuracy, altitudeAccuracy,
- providesHeading, heading, providesSpeed, speed);
-
-#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
- m_lastPosition = Geoposition::create(coordinates.release(), geoPosition.timestamp().toMSecsSinceEpoch());
-#else
- QDateTime timestamp = geoPosition.timestamp();
- m_lastPosition = Geoposition::create(coordinates.release(), (timestamp.toTime_t() * 1000.00) + timestamp.time().msec());
-#endif
- positionChanged();
-}
-
-bool GeolocationServiceQt::startUpdating(PositionOptions*)
-{
- m_lastPosition = 0;
-
- if (!m_location)
- return false;
-
- // TODO: handle enableHighAccuracy()
-
- m_location->startUpdates();
- return true;
-}
-
-void GeolocationServiceQt::stopUpdating()
-{
- if (m_location)
- m_location->stopUpdates();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/qt/GeolocationServiceQt.h b/Source/WebCore/platform/qt/GeolocationServiceQt.h
deleted file mode 100644
index 2525e47..0000000
--- a/Source/WebCore/platform/qt/GeolocationServiceQt.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GeolocationServiceQt_h
-#define GeolocationServiceQt_h
-
-#include "GeolocationService.h"
-#include <QGeoPositionInfoSource>
-#include <wtf/RefPtr.h>
-
-// FIXME: Remove usage of "using namespace" in a header file.
-// There is bug in qtMobility signal names are not full qualified when used with namespace
-// QtMobility namespace in slots throws up error and its required to be fixed in qtmobility.
-using namespace QtMobility;
-
-namespace WebCore {
-
-// This class provides a implementation of a GeolocationService for qtWebkit.
-// It uses QtMobility (v1.0.0) location service to get positions
-class GeolocationServiceQt : public QObject, GeolocationService {
- Q_OBJECT
-
-public:
- static GeolocationService* create(GeolocationServiceClient*);
-
- GeolocationServiceQt(GeolocationServiceClient*);
- virtual ~GeolocationServiceQt();
-
- virtual bool startUpdating(PositionOptions*);
- virtual void stopUpdating();
-
- virtual Geoposition* lastPosition() const { return m_lastPosition.get(); }
- virtual PositionError* lastError() const { return m_lastError.get(); }
-
-public Q_SLOTS:
- // QGeoPositionInfoSource
- void positionUpdated(const QGeoPositionInfo&);
-
-private:
- RefPtr<Geoposition> m_lastPosition;
- RefPtr<PositionError> m_lastError;
-
- QtMobility::QGeoPositionInfoSource* m_location;
-};
-
-} // namespace WebCore
-
-#endif // GeolocationServiceQt_h
diff --git a/Source/WebCore/platform/qt/PlatformTouchEventQt.cpp b/Source/WebCore/platform/qt/PlatformTouchEventQt.cpp
index 338e9d4..91b6a51 100644
--- a/Source/WebCore/platform/qt/PlatformTouchEventQt.cpp
+++ b/Source/WebCore/platform/qt/PlatformTouchEventQt.cpp
@@ -22,6 +22,7 @@
#include "config.h"
#include "PlatformTouchEvent.h"
+#include <wtf/CurrentTime.h>
#if ENABLE(TOUCH_EVENTS)
@@ -42,6 +43,7 @@ PlatformTouchEvent::PlatformTouchEvent(QTouchEvent* event)
m_altKey = (event->modifiers() & Qt::AltModifier);
m_shiftKey = (event->modifiers() & Qt::ShiftModifier);
m_metaKey = (event->modifiers() & Qt::MetaModifier);
+ m_timestamp = WTF::currentTime();
}
}
diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp
index d4688cf..ca8c6dd 100644
--- a/Source/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp
@@ -66,6 +66,7 @@
#include <QColor>
#include <QFile>
#include <QLineEdit>
+#include <QMacStyle>
#include <QPainter>
#include <QPushButton>
#include <QStyleFactory>
@@ -380,30 +381,35 @@ void RenderThemeQt::adjustRepaintRect(const RenderObject* o, IntRect& rect)
Color RenderThemeQt::platformActiveSelectionBackgroundColor() const
{
QPalette pal = QApplication::palette();
+ setPaletteFromPageClientIfExists(pal);
return pal.brush(QPalette::Active, QPalette::Highlight).color();
}
Color RenderThemeQt::platformInactiveSelectionBackgroundColor() const
{
QPalette pal = QApplication::palette();
+ setPaletteFromPageClientIfExists(pal);
return pal.brush(QPalette::Inactive, QPalette::Highlight).color();
}
Color RenderThemeQt::platformActiveSelectionForegroundColor() const
{
QPalette pal = QApplication::palette();
+ setPaletteFromPageClientIfExists(pal);
return pal.brush(QPalette::Active, QPalette::HighlightedText).color();
}
Color RenderThemeQt::platformInactiveSelectionForegroundColor() const
{
QPalette pal = QApplication::palette();
+ setPaletteFromPageClientIfExists(pal);
return pal.brush(QPalette::Inactive, QPalette::HighlightedText).color();
}
Color RenderThemeQt::platformFocusRingColor() const
{
QPalette pal = QApplication::palette();
+ setPaletteFromPageClientIfExists(pal);
return pal.brush(QPalette::Active, QPalette::Highlight).color();
}
@@ -547,9 +553,6 @@ void RenderThemeQt::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* s
}
#endif
- // White-space is locked to pre
- style->setWhiteSpace(PRE);
-
FontDescription fontDescription = style->fontDescription();
fontDescription.setIsAbsoluteSize(true);
@@ -704,15 +707,17 @@ void RenderThemeQt::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, E
void RenderThemeQt::setPopupPadding(RenderStyle* style) const
{
- const int padding = 8;
- style->setPaddingLeft(Length(padding, Fixed));
+ const int paddingLeft = 4;
+ const int paddingRight = style->width().isFixed() || style->width().isPercent() ? 5 : 8;
+
+ style->setPaddingLeft(Length(paddingLeft, Fixed));
QStyleOptionComboBox opt;
int w = qStyle()->pixelMetric(QStyle::PM_ButtonIconSize, &opt, 0);
- style->setPaddingRight(Length(padding + w, Fixed));
+ style->setPaddingRight(Length(paddingRight + w, Fixed));
style->setPaddingTop(Length(2, Fixed));
- style->setPaddingBottom(Length(0, Fixed));
+ style->setPaddingBottom(Length(2, Fixed));
}
@@ -726,10 +731,20 @@ bool RenderThemeQt::paintMenuList(RenderObject* o, const PaintInfo& i, const Int
initStyleOption(p.widget, opt);
initializeCommonQStyleOptions(opt, o);
- const QPoint topLeft = r.location();
+ IntRect rect = r;
+
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
+ // QMacStyle makes the combo boxes a little bit smaller to leave space for the focus rect.
+ // Because of it, the combo button is drawn at a point to the left of where it was expect to be and may end up
+ // overlapped with the text. This will force QMacStyle to draw the combo box with the expected width.
+ if (qobject_cast<QMacStyle*>(p.style))
+ rect.inflateX(3);
+#endif
+
+ const QPoint topLeft = rect.location();
p.painter->translate(topLeft);
opt.rect.moveTo(QPoint(0, 0));
- opt.rect.setSize(r.size());
+ opt.rect.setSize(rect.size());
p.drawComplexControl(QStyle::CC_ComboBox, opt);
p.painter->translate(-topLeft);
diff --git a/Source/WebCore/platform/qt/SharedTimerQt.cpp b/Source/WebCore/platform/qt/SharedTimerQt.cpp
index 8a6bd81..5075395 100644
--- a/Source/WebCore/platform/qt/SharedTimerQt.cpp
+++ b/Source/WebCore/platform/qt/SharedTimerQt.cpp
@@ -68,8 +68,12 @@ SharedTimerQt::SharedTimerQt()
SharedTimerQt::~SharedTimerQt()
{
- if (m_timer.isActive())
- (m_timerFunction)();
+ if (m_timer.isActive()) {
+ if (m_timerFunction) {
+ (m_timerFunction)();
+ m_timerFunction = 0;
+ }
+ }
}
void SharedTimerQt::destroy()
diff --git a/Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp b/Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp
index a46b82c..12c54f2 100644
--- a/Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp
+++ b/Source/WebCore/platform/qt/TemporaryLinkStubsQt.cpp
@@ -128,6 +128,16 @@ void setCookieStoragePrivateBrowsingEnabled(bool)
notImplemented();
}
+void startObservingCookieChanges()
+{
+ notImplemented();
+}
+
+void stopObservingCookieChanges()
+{
+ notImplemented();
+}
+
}
// vim: ts=4 sw=4 et