summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/qt
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/platform/qt
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/platform/qt')
-rw-r--r--Source/WebCore/platform/qt/CookieJarQt.cpp16
-rw-r--r--Source/WebCore/platform/qt/DragDataQt.cpp15
-rw-r--r--Source/WebCore/platform/qt/PasteboardQt.cpp29
-rw-r--r--Source/WebCore/platform/qt/PlatformMouseEventQt.cpp2
-rw-r--r--Source/WebCore/platform/qt/RenderThemeQt.cpp98
-rw-r--r--Source/WebCore/platform/qt/RenderThemeQt.h4
-rw-r--r--Source/WebCore/platform/qt/WheelEventQt.cpp2
7 files changed, 125 insertions, 41 deletions
diff --git a/Source/WebCore/platform/qt/CookieJarQt.cpp b/Source/WebCore/platform/qt/CookieJarQt.cpp
index e5d36ba..b7ff5d1 100644
--- a/Source/WebCore/platform/qt/CookieJarQt.cpp
+++ b/Source/WebCore/platform/qt/CookieJarQt.cpp
@@ -30,14 +30,13 @@
#include "Cookie.h"
#include "Document.h"
+#include "FrameLoaderClientQt.h"
#include "KURL.h"
-#include "QtNAMThreadSafeProxy.h"
#include "NetworkingContext.h"
#include "PlatformString.h"
-
-#include "qwebpage.h"
+#include "QtNAMThreadSafeProxy.h"
#include "qwebframe.h"
-#include "FrameLoaderClientQt.h"
+#include "qwebpage.h"
#include <QNetworkAccessManager>
#include <QNetworkCookie>
#include <QStringList>
@@ -49,10 +48,10 @@ static QNetworkAccessManager *networkAccessManager(const Document *document)
{
if (!document)
return 0;
- Frame *frame = document->frame();
+ Frame* frame = document->frame();
if (!frame)
return 0;
- FrameLoader *loader = frame->loader();
+ FrameLoader* loader = frame->loader();
if (!loader)
return 0;
return loader->networkingContext()->networkAccessManager();
@@ -115,7 +114,10 @@ String cookieRequestHeaderFieldValue(const Document* document, const KURL &url)
bool cookiesEnabled(const Document* document)
{
- return networkAccessManager(document);
+ if (QNetworkAccessManager* manager = networkAccessManager(document))
+ return !!manager->cookieJar();
+
+ return false;
}
bool getRawCookies(const Document*, const KURL&, Vector<Cookie>& rawCookies)
diff --git a/Source/WebCore/platform/qt/DragDataQt.cpp b/Source/WebCore/platform/qt/DragDataQt.cpp
index 4033123..f68ad1d 100644
--- a/Source/WebCore/platform/qt/DragDataQt.cpp
+++ b/Source/WebCore/platform/qt/DragDataQt.cpp
@@ -28,6 +28,7 @@
#include "Document.h"
#include "DocumentFragment.h"
+#include "Frame.h"
#include "markup.h"
#include <QColor>
@@ -80,7 +81,7 @@ bool DragData::containsPlainText() const
return m_platformDragData->hasText() || m_platformDragData->hasUrls();
}
-String DragData::asPlainText() const
+String DragData::asPlainText(Frame* frame) const
{
if (!m_platformDragData)
return String();
@@ -89,7 +90,7 @@ String DragData::asPlainText() const
return text;
// FIXME: Should handle rich text here
- return asURL(DoNotConvertFilenames, 0);
+ return asURL(frame, DoNotConvertFilenames, 0);
}
Color DragData::asColor() const
@@ -103,10 +104,10 @@ bool DragData::containsCompatibleContent() const
{
if (!m_platformDragData)
return false;
- return containsColor() || containsURL() || m_platformDragData->hasHtml() || m_platformDragData->hasText();
+ return containsColor() || containsURL(0) || m_platformDragData->hasHtml() || m_platformDragData->hasText();
}
-bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
+bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
{
// FIXME: Use filenamePolicy.
if (!m_platformDragData)
@@ -114,7 +115,7 @@ bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
return m_platformDragData->hasUrls();
}
-String DragData::asURL(FilenameConversionPolicy filenamePolicy, String*) const
+String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String*) const
{
// FIXME: Use filenamePolicy.
if (!m_platformDragData)
@@ -127,10 +128,10 @@ String DragData::asURL(FilenameConversionPolicy filenamePolicy, String*) const
return encodeWithURLEscapeSequences(urls.first().toString());
}
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
{
if (m_platformDragData && m_platformDragData->hasHtml())
- return createFragmentFromMarkup(doc, m_platformDragData->html(), "", FragmentScriptingNotAllowed);
+ return createFragmentFromMarkup(frame->document(), m_platformDragData->html(), "", FragmentScriptingNotAllowed);
return 0;
}
diff --git a/Source/WebCore/platform/qt/PasteboardQt.cpp b/Source/WebCore/platform/qt/PasteboardQt.cpp
index 1c60da0..6865fd7 100644
--- a/Source/WebCore/platform/qt/PasteboardQt.cpp
+++ b/Source/WebCore/platform/qt/PasteboardQt.cpp
@@ -32,13 +32,12 @@
#include "Editor.h"
#include "Frame.h"
#include "Image.h"
-#include "markup.h"
#include "RenderImage.h"
-
-#include <qdebug.h>
+#include "markup.h"
+#include <qapplication.h>
#include <qclipboard.h>
+#include <qdebug.h>
#include <qmimedata.h>
-#include <qapplication.h>
#include <qurl.h>
#define methodDebug() qDebug() << "PasteboardQt: " << __FUNCTION__;
@@ -75,8 +74,7 @@ void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete,
#endif
#ifndef QT_NO_CLIPBOARD
- QApplication::clipboard()->setMimeData(md, m_selectionMode ?
- QClipboard::Selection : QClipboard::Clipboard);
+ QApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
if (canSmartCopyOrDelete)
md->setData("application/vnd.qtwebkit.smartpaste", QByteArray());
@@ -94,8 +92,7 @@ bool Pasteboard::canSmartReplace()
String Pasteboard::plainText(Frame*)
{
#ifndef QT_NO_CLIPBOARD
- return QApplication::clipboard()->text(m_selectionMode ?
- QClipboard::Selection : QClipboard::Clipboard);
+ return QApplication::clipboard()->text(m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#else
return String();
#endif
@@ -136,22 +133,20 @@ void Pasteboard::writePlainText(const String& text)
QString qtext = text;
qtext.replace(QChar(0xa0), QLatin1Char(' '));
md->setText(qtext);
- QApplication::clipboard()->setMimeData(md, m_selectionMode ?
- QClipboard::Selection : QClipboard::Clipboard);
+ QApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
}
-void Pasteboard::writeURL(const KURL& _url, const String&, Frame*)
+void Pasteboard::writeURL(const KURL& url, const String&, Frame*)
{
- ASSERT(!_url.isEmpty());
+ ASSERT(!url.isEmpty());
#ifndef QT_NO_CLIPBOARD
QMimeData* md = new QMimeData;
- QString url = _url.string();
- md->setText(url);
- md->setUrls(QList<QUrl>() << QUrl(url));
- QApplication::clipboard()->setMimeData(md, m_selectionMode ?
- QClipboard::Selection : QClipboard::Clipboard);
+ QString urlString = url.string();
+ md->setText(urlString);
+ md->setUrls(QList<QUrl>() << url);
+ QApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
}
diff --git a/Source/WebCore/platform/qt/PlatformMouseEventQt.cpp b/Source/WebCore/platform/qt/PlatformMouseEventQt.cpp
index a8956bf..125ae52 100644
--- a/Source/WebCore/platform/qt/PlatformMouseEventQt.cpp
+++ b/Source/WebCore/platform/qt/PlatformMouseEventQt.cpp
@@ -34,6 +34,7 @@
namespace WebCore {
+#if !defined(QT_NO_GRAPHICSVIEW)
PlatformMouseEvent::PlatformMouseEvent(QGraphicsSceneMouseEvent* event, int clickCount)
{
m_timestamp = WTF::currentTime();
@@ -69,6 +70,7 @@ PlatformMouseEvent::PlatformMouseEvent(QGraphicsSceneMouseEvent* event, int clic
m_altKey = (event->modifiers() & Qt::AltModifier);
m_metaKey = (event->modifiers() & Qt::MetaModifier);
}
+#endif // QT_NO_GRAPHICSVIEW
PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount)
{
diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp
index 2cc3625..8d5cfcd 100644
--- a/Source/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp
@@ -47,9 +47,11 @@
#include "QtMobileWebStyle.h"
#endif
#include "NotImplemented.h"
+#include "PaintInfo.h"
#include "Page.h"
#include "QWebPageClient.h"
#include "QtStyleOptionWebComboBox.h"
+#include "qwebsettings.h"
#include "RenderBox.h"
#if ENABLE(PROGRESS_TAG)
#include "RenderProgress.h"
@@ -92,6 +94,15 @@ inline static void initStyleOption(QWidget *widget, QStyleOption& option)
option.state = QStyle::State_Active | QStyle::State_Enabled;
}
}
+// These values all match Safari/Win/Chromium
+static const float defaultControlFontPixelSize = 13;
+static const float defaultCancelButtonSize = 9;
+static const float minCancelButtonSize = 5;
+static const float maxCancelButtonSize = 21;
+static const float defaultSearchFieldResultsDecorationSize = 13;
+static const float minSearchFieldResultsDecorationSize = 9;
+static const float maxSearchFieldResultsDecorationSize = 30;
+static const float defaultSearchFieldResultsButtonWidth = 18;
StylePainter::StylePainter(RenderThemeQt* theme, const PaintInfo& paintInfo)
@@ -186,6 +197,7 @@ bool RenderThemeQt::isControlStyled(const RenderStyle* style, const BorderData&
case PushButtonPart:
case ButtonPart:
case MenulistPart:
+ // FIXME: Need to add SearchFieldPart if it should be style-able.
case TextFieldPart:
case TextAreaPart:
return true;
@@ -201,6 +213,20 @@ int RenderThemeQt::popupInternalPaddingBottom(RenderStyle* style) const
{
return 1;
}
+#else
+// Remove this when SearchFieldPart is style-able in RenderTheme::isControlStyled()
+bool RenderThemeQt::isControlStyled(const RenderStyle* style, const BorderData& border, const FillLayer& fill, const Color& backgroundColor) const
+{
+ switch (style->appearance()) {
+ case SearchFieldPart:
+ // Test the style to see if the UA border and background match.
+ return (style->border() != border
+ || *style->backgroundLayers() != fill
+ || style->visitedDependentColor(CSSPropertyBackgroundColor) != backgroundColor);
+ default:
+ return RenderTheme::isControlStyled(style, border, fill, backgroundColor);
+ }
+}
#endif
// for some widget painting, we need to fallback to Windows style
@@ -413,6 +439,7 @@ void RenderThemeQt::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
switch (renderStyle->appearance()) {
case TextAreaPart:
+ case SearchFieldPart:
case TextFieldPart: {
int padding = findFrameLineWidth(style);
@@ -611,6 +638,11 @@ bool RenderThemeQt::paintButton(RenderObject* o, const PaintInfo& i, const IntRe
void RenderThemeQt::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
{
+ // Resetting the style like this leads to differences like:
+ // - RenderTextControl {INPUT} at (2,2) size 168x25 [bgcolor=#FFFFFF] border: (2px inset #000000)]
+ // + RenderTextControl {INPUT} at (2,2) size 166x26
+ // in layout tests when a CSS style is applied that doesn't affect background color, border or
+ // padding. Just worth keeping in mind!
style->setBackgroundColor(Color::transparent);
style->resetBorder();
style->resetPadding();
@@ -886,28 +918,73 @@ void RenderThemeQt::adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle* style
bool RenderThemeQt::paintSearchField(RenderObject* o, const PaintInfo& pi,
const IntRect& r)
{
- return true;
+ return paintTextField(o, pi, r);
}
void RenderThemeQt::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style,
Element* e) const
{
- notImplemented();
- RenderTheme::adjustSearchFieldStyle(selector, style, e);
+ // Resetting the style like this leads to differences like:
+ // - RenderTextControl {INPUT} at (2,2) size 168x25 [bgcolor=#FFFFFF] border: (2px inset #000000)]
+ // + RenderTextControl {INPUT} at (2,2) size 166x26
+ // in layout tests when a CSS style is applied that doesn't affect background color, border or
+ // padding. Just worth keeping in mind!
+ style->setBackgroundColor(Color::transparent);
+ style->resetBorder();
+ style->resetPadding();
+ computeSizeBasedOnStyle(style);
}
void RenderThemeQt::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style,
Element* e) const
{
- notImplemented();
- RenderTheme::adjustSearchFieldCancelButtonStyle(selector, style, e);
+ // Logic taken from RenderThemeChromium.cpp.
+ // Scale the button size based on the font size.
+ float fontScale = style->fontSize() / defaultControlFontPixelSize;
+ int cancelButtonSize = lroundf(qMin(qMax(minCancelButtonSize, defaultCancelButtonSize * fontScale), maxCancelButtonSize));
+ style->setWidth(Length(cancelButtonSize, Fixed));
+ style->setHeight(Length(cancelButtonSize, Fixed));
+}
+
+// Function taken from RenderThemeChromium.cpp
+IntRect RenderThemeQt::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const
+{
+ // Compute an offset between the part renderer and the input renderer.
+ IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer));
+ // Move the rect into partRenderer's coords.
+ partRect.move(offsetFromInputRenderer);
+ // Account for the local drawing offset.
+ partRect.move(localOffset.x(), localOffset.y());
+
+ return partRect;
}
bool RenderThemeQt::paintSearchFieldCancelButton(RenderObject* o, const PaintInfo& pi,
const IntRect& r)
{
- notImplemented();
- return RenderTheme::paintSearchFieldCancelButton(o, pi, r);
+ // Logic copied from RenderThemeChromium.cpp.
+
+ // Get the renderer of <input> element.
+ Node* input = o->node()->shadowAncestorNode();
+ if (!input->renderer()->isBox())
+ return false;
+ RenderBox* inputRenderBox = toRenderBox(input->renderer());
+ IntRect inputContentBox = inputRenderBox->contentBoxRect();
+
+ // Make sure the scaled button stays square and will fit in its parent's box.
+ int cancelButtonSize = qMin(inputContentBox.width(), qMin(inputContentBox.height(), r.height()));
+ // Calculate cancel button's coordinates relative to the input element.
+ // Center the button vertically. Round up though, so if it has to be one pixel off-center, it will
+ // be one pixel closer to the bottom of the field. This tends to look better with the text.
+ IntRect cancelButtonRect(o->offsetFromAncestorContainer(inputRenderBox).width(),
+ inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
+ cancelButtonSize, cancelButtonSize);
+ IntRect paintingRect = convertToPaintingRect(inputRenderBox, o, cancelButtonRect, r);
+ static Image* cancelImage = Image::loadPlatformResource("searchCancelButton").releaseRef();
+ static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelButtonPressed").releaseRef();
+ pi.context->drawImage(isPressed(o) ? cancelPressedImage : cancelImage,
+ o->style()->colorSpace(), paintingRect);
+ return false;
}
void RenderThemeQt::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderStyle* style,
@@ -1037,7 +1114,12 @@ ControlPart RenderThemeQt::initializeCommonQStyleOptions(QStyleOption& option, R
String RenderThemeQt::extraMediaControlsStyleSheet()
{
- return String(mediaControlsQtUserAgentStyleSheet, sizeof(mediaControlsQtUserAgentStyleSheet));
+ String result = String(mediaControlsQtUserAgentStyleSheet, sizeof(mediaControlsQtUserAgentStyleSheet));
+
+ if (m_page && m_page->chrome()->requiresFullscreenForVideoPlayback())
+ result += String(mediaControlsQtFullscreenUserAgentStyleSheet, sizeof(mediaControlsQtFullscreenUserAgentStyleSheet));
+
+ return result;
}
// Helper class to transform the painter's world matrix to the object's content area, scaled to 0,0,100,100
diff --git a/Source/WebCore/platform/qt/RenderThemeQt.h b/Source/WebCore/platform/qt/RenderThemeQt.h
index c28168a..6981641 100644
--- a/Source/WebCore/platform/qt/RenderThemeQt.h
+++ b/Source/WebCore/platform/qt/RenderThemeQt.h
@@ -81,8 +81,8 @@ public:
virtual double caretBlinkInterval() const;
-#if USE(QT_MOBILE_THEME)
virtual bool isControlStyled(const RenderStyle*, const BorderData&, const FillLayer&, const Color& backgroundColor) const;
+#if USE(QT_MOBILE_THEME)
virtual int popupInternalPaddingBottom(RenderStyle*) const;
#endif
@@ -180,6 +180,8 @@ private:
QStyle* fallbackStyle() const;
+ IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const;
+
Page* m_page;
#ifdef Q_WS_MAC
diff --git a/Source/WebCore/platform/qt/WheelEventQt.cpp b/Source/WebCore/platform/qt/WheelEventQt.cpp
index 57a7ebc..aa61d91 100644
--- a/Source/WebCore/platform/qt/WheelEventQt.cpp
+++ b/Source/WebCore/platform/qt/WheelEventQt.cpp
@@ -48,10 +48,10 @@ void PlatformWheelEvent::applyDelta(int delta, Qt::Orientation orientation)
m_wheelTicksX = m_deltaX;
m_wheelTicksY = m_deltaY;
+#ifndef QT_NO_WHEELEVENT
// Use the same single scroll step as QTextEdit
// (in QTextEditPrivate::init [h,v]bar->setSingleStep)
static const float cDefaultQtScrollStep = 20.f;
-#ifndef QT_NO_WHEELEVENT
m_deltaX *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
m_deltaY *= (fullTick) ? QApplication::wheelScrollLines() * cDefaultQtScrollStep : 1;
#endif