summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/qt
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/qt')
-rw-r--r--Source/WebCore/platform/qt/ClipboardQt.cpp17
-rw-r--r--Source/WebCore/platform/qt/ClipboardQt.h2
-rw-r--r--Source/WebCore/platform/qt/CursorQt.cpp7
-rw-r--r--Source/WebCore/platform/qt/DragImageQt.cpp4
-rw-r--r--Source/WebCore/platform/qt/GamepadsQt.cpp2
-rw-r--r--Source/WebCore/platform/qt/PasteboardQt.cpp8
-rw-r--r--Source/WebCore/platform/qt/PlatformKeyboardEventQt.cpp94
-rw-r--r--Source/WebCore/platform/qt/PlatformScreenQt.cpp2
-rw-r--r--Source/WebCore/platform/qt/QStyleFacade.cpp46
-rw-r--r--Source/WebCore/platform/qt/QStyleFacade.h201
-rw-r--r--Source/WebCore/platform/qt/RenderThemeQStyle.cpp620
-rw-r--r--Source/WebCore/platform/qt/RenderThemeQStyle.h158
-rw-r--r--Source/WebCore/platform/qt/RenderThemeQt.cpp2
-rw-r--r--Source/WebCore/platform/qt/RunLoopQt.cpp2
-rw-r--r--Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp221
-rw-r--r--Source/WebCore/platform/qt/ScrollbarThemeQStyle.h65
16 files changed, 1378 insertions, 73 deletions
diff --git a/Source/WebCore/platform/qt/ClipboardQt.cpp b/Source/WebCore/platform/qt/ClipboardQt.cpp
index e1569926e..6212f58b8 100644
--- a/Source/WebCore/platform/qt/ClipboardQt.cpp
+++ b/Source/WebCore/platform/qt/ClipboardQt.cpp
@@ -48,9 +48,8 @@
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
-#include <QGuiApplication>
#include <QClipboard>
-#include <QImage>
+#include <QGuiApplication>
#include <QList>
#include <QMimeData>
#include <QStringList>
@@ -183,13 +182,13 @@ bool ClipboardQt::setData(const String& type, const String& data)
}
// extensions beyond IE's API
-HashSet<String> ClipboardQt::types() const
+ListHashSet<String> ClipboardQt::types() const
{
if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
- return HashSet<String>();
+ return ListHashSet<String>();
ASSERT(m_readableData);
- HashSet<String> result;
+ ListHashSet<String> result;
QStringList formats = m_readableData->formats();
for (int i = 0; i < formats.count(); ++i)
result.add(formats.at(i));
@@ -244,7 +243,7 @@ DragImageRef ClipboardQt::createDragImage(IntPoint& dragLoc) const
if (!m_dragImage)
return 0;
dragLoc = m_dragLoc;
- return new QImage(*m_dragImage->image()->nativeImageForCurrentFrame());
+ return m_dragImage->image()->nativeImageForCurrentFrame();
}
@@ -274,9 +273,9 @@ void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, co
CachedImage* cachedImage = getCachedImage(element);
if (!cachedImage || !cachedImage->imageForRenderer(element->renderer()) || !cachedImage->isLoaded())
return;
- QImage* image = cachedImage->imageForRenderer(element->renderer())->nativeImageForCurrentFrame();
- if (image)
- m_writableData->setImageData(*image);
+ QPixmap* pixmap = cachedImage->imageForRenderer(element->renderer())->nativeImageForCurrentFrame();
+ if (pixmap)
+ m_writableData->setImageData(*pixmap);
QList<QUrl> urls;
urls.append(url);
diff --git a/Source/WebCore/platform/qt/ClipboardQt.h b/Source/WebCore/platform/qt/ClipboardQt.h
index 5d09c84f4..b81c148ea 100644
--- a/Source/WebCore/platform/qt/ClipboardQt.h
+++ b/Source/WebCore/platform/qt/ClipboardQt.h
@@ -57,7 +57,7 @@ public:
bool setData(const String& type, const String& data);
// extensions beyond IE's API
- virtual HashSet<String> types() const;
+ virtual ListHashSet<String> types() const;
virtual PassRefPtr<FileList> files() const;
void setDragImage(CachedImage*, const IntPoint&);
diff --git a/Source/WebCore/platform/qt/CursorQt.cpp b/Source/WebCore/platform/qt/CursorQt.cpp
index 168a2f56b..e7854dde5 100644
--- a/Source/WebCore/platform/qt/CursorQt.cpp
+++ b/Source/WebCore/platform/qt/CursorQt.cpp
@@ -37,8 +37,6 @@
#include "NotImplemented.h"
-#include <QImage>
-#include <QPixmap>
#include <stdio.h>
#include <stdlib.h>
@@ -77,11 +75,10 @@ Cursor& Cursor::operator=(const Cursor& other)
#ifndef QT_NO_CURSOR
static QCursor* createCustomCursor(Image* image, const IntPoint& hotSpot)
{
- QImage* nativeImage = image->nativeImageForCurrentFrame();
- if (!nativeImage)
+ if (!image->nativeImageForCurrentFrame())
return 0;
IntPoint effectiveHotSpot = determineHotSpot(image, hotSpot);
- return new QCursor(QPixmap::fromImage(*nativeImage), effectiveHotSpot.x(), effectiveHotSpot.y());
+ return new QCursor(*(image->nativeImageForCurrentFrame()), effectiveHotSpot.x(), effectiveHotSpot.y());
}
#endif
diff --git a/Source/WebCore/platform/qt/DragImageQt.cpp b/Source/WebCore/platform/qt/DragImageQt.cpp
index e93ac7089..0e7ce0465 100644
--- a/Source/WebCore/platform/qt/DragImageQt.cpp
+++ b/Source/WebCore/platform/qt/DragImageQt.cpp
@@ -29,8 +29,6 @@
#include "CachedImage.h"
#include "Image.h"
-#include <QImage>
-
namespace WebCore {
IntSize dragImageSize(DragImageRef image)
@@ -68,7 +66,7 @@ DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum)
if (!image || !image->nativeImageForCurrentFrame())
return 0;
- return new QImage(*image->nativeImageForCurrentFrame());
+ return new QPixmap(*image->nativeImageForCurrentFrame());
}
DragImageRef createDragImageIconForCachedImage(CachedImage*)
diff --git a/Source/WebCore/platform/qt/GamepadsQt.cpp b/Source/WebCore/platform/qt/GamepadsQt.cpp
index 624fde947..dc4f16a7a 100644
--- a/Source/WebCore/platform/qt/GamepadsQt.cpp
+++ b/Source/WebCore/platform/qt/GamepadsQt.cpp
@@ -34,7 +34,7 @@
#include <QSocketNotifier>
extern "C" {
- #include <libudev.h>
+#include <libudev.h>
}
#include <unistd.h>
diff --git a/Source/WebCore/platform/qt/PasteboardQt.cpp b/Source/WebCore/platform/qt/PasteboardQt.cpp
index 66b0e4026..96deac499 100644
--- a/Source/WebCore/platform/qt/PasteboardQt.cpp
+++ b/Source/WebCore/platform/qt/PasteboardQt.cpp
@@ -35,9 +35,9 @@
#include "Image.h"
#include "RenderImage.h"
#include "markup.h"
-#include <qguiapplication.h>
#include <qclipboard.h>
#include <qdebug.h>
+#include <qguiapplication.h>
#include <qmimedata.h>
#include <qurl.h>
@@ -168,10 +168,10 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
Image* image = cachedImage->imageForRenderer(node->renderer());
ASSERT(image);
- QImage* nativeImage = image->nativeImageForCurrentFrame();
- if (!image)
+ QPixmap* pixmap = image->nativeImageForCurrentFrame();
+ if (!pixmap)
return;
- QGuiApplication::clipboard()->setImage(*nativeImage, QClipboard::Clipboard);
+ QGuiApplication::clipboard()->setPixmap(*pixmap, QClipboard::Clipboard);
#endif
}
diff --git a/Source/WebCore/platform/qt/PlatformKeyboardEventQt.cpp b/Source/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
index 62d8a2482..5123a8d8c 100644
--- a/Source/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
+++ b/Source/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
@@ -42,97 +42,97 @@ String keyIdentifierForQtKeyCode(int keyCode)
switch (keyCode) {
case Qt::Key_Menu:
case Qt::Key_Alt:
- return "Alt";
+ return ASCIILiteral("Alt");
case Qt::Key_Clear:
- return "Clear";
+ return ASCIILiteral("Clear");
case Qt::Key_Down:
- return "Down";
+ return ASCIILiteral("Down");
case Qt::Key_End:
- return "End";
+ return ASCIILiteral("End");
case Qt::Key_Return:
case Qt::Key_Enter:
- return "Enter";
+ return ASCIILiteral("Enter");
case Qt::Key_Execute:
- return "Execute";
+ return ASCIILiteral("Execute");
case Qt::Key_F1:
- return "F1";
+ return ASCIILiteral("F1");
case Qt::Key_F2:
- return "F2";
+ return ASCIILiteral("F2");
case Qt::Key_F3:
- return "F3";
+ return ASCIILiteral("F3");
case Qt::Key_F4:
- return "F4";
+ return ASCIILiteral("F4");
case Qt::Key_F5:
- return "F5";
+ return ASCIILiteral("F5");
case Qt::Key_F6:
- return "F6";
+ return ASCIILiteral("F6");
case Qt::Key_F7:
- return "F7";
+ return ASCIILiteral("F7");
case Qt::Key_F8:
- return "F8";
+ return ASCIILiteral("F8");
case Qt::Key_F9:
- return "F9";
+ return ASCIILiteral("F9");
case Qt::Key_F10:
- return "F10";
+ return ASCIILiteral("F10");
case Qt::Key_F11:
- return "F11";
+ return ASCIILiteral("F11");
case Qt::Key_F12:
- return "F12";
+ return ASCIILiteral("F12");
case Qt::Key_F13:
- return "F13";
+ return ASCIILiteral("F13");
case Qt::Key_F14:
- return "F14";
+ return ASCIILiteral("F14");
case Qt::Key_F15:
- return "F15";
+ return ASCIILiteral("F15");
case Qt::Key_F16:
- return "F16";
+ return ASCIILiteral("F16");
case Qt::Key_F17:
- return "F17";
+ return ASCIILiteral("F17");
case Qt::Key_F18:
- return "F18";
+ return ASCIILiteral("F18");
case Qt::Key_F19:
- return "F19";
+ return ASCIILiteral("F19");
case Qt::Key_F20:
- return "F20";
+ return ASCIILiteral("F20");
case Qt::Key_F21:
- return "F21";
+ return ASCIILiteral("F21");
case Qt::Key_F22:
- return "F22";
+ return ASCIILiteral("F22");
case Qt::Key_F23:
- return "F23";
+ return ASCIILiteral("F23");
case Qt::Key_F24:
- return "F24";
+ return ASCIILiteral("F24");
case Qt::Key_Help:
- return "Help";
+ return ASCIILiteral("Help");
case Qt::Key_Home:
- return "Home";
+ return ASCIILiteral("Home");
case Qt::Key_Insert:
- return "Insert";
+ return ASCIILiteral("Insert");
case Qt::Key_Left:
- return "Left";
+ return ASCIILiteral("Left");
case Qt::Key_PageDown:
- return "PageDown";
+ return ASCIILiteral("PageDown");
case Qt::Key_PageUp:
- return "PageUp";
+ return ASCIILiteral("PageUp");
case Qt::Key_Pause:
- return "Pause";
+ return ASCIILiteral("Pause");
case Qt::Key_Print:
- return "PrintScreen";
+ return ASCIILiteral("PrintScreen");
case Qt::Key_Right:
- return "Right";
+ return ASCIILiteral("Right");
case Qt::Key_Select:
- return "Select";
+ return ASCIILiteral("Select");
case Qt::Key_Up:
- return "Up";
+ return ASCIILiteral("Up");
// Standard says that DEL becomes U+007F.
case Qt::Key_Delete:
- return "U+007F";
+ return ASCIILiteral("U+007F");
case Qt::Key_Backspace:
- return "U+0008";
+ return ASCIILiteral("U+0008");
case Qt::Key_Tab:
- return "U+0009";
+ return ASCIILiteral("U+0009");
case Qt::Key_Backtab:
- return "U+0009";
+ return ASCIILiteral("U+0009");
default:
return String::format("U+%04X", toupper(keyCode));
}
@@ -585,11 +585,11 @@ static String keyTextForKeyEvent(const QKeyEvent* event)
case Qt::Key_Tab:
case Qt::Key_Backtab:
if (event->text().isNull())
- return "\t";
+ return ASCIILiteral("\t");
break;
case Qt::Key_Enter:
if (event->text().isNull())
- return "\r";
+ return ASCIILiteral("\r");
}
return event->text();
}
diff --git a/Source/WebCore/platform/qt/PlatformScreenQt.cpp b/Source/WebCore/platform/qt/PlatformScreenQt.cpp
index fa2e837ea..d08230299 100644
--- a/Source/WebCore/platform/qt/PlatformScreenQt.cpp
+++ b/Source/WebCore/platform/qt/PlatformScreenQt.cpp
@@ -36,8 +36,8 @@
#include "FrameView.h"
#include "HostWindow.h"
#include "NotImplemented.h"
-#include "Widget.h"
#include "QWebPageClient.h"
+#include "Widget.h"
#include <QGuiApplication>
#include <QScreen>
diff --git a/Source/WebCore/platform/qt/QStyleFacade.cpp b/Source/WebCore/platform/qt/QStyleFacade.cpp
new file mode 100644
index 000000000..4707a2fc1
--- /dev/null
+++ b/Source/WebCore/platform/qt/QStyleFacade.cpp
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the theme implementation for form controls in WebCore.
+ *
+ * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "QStyleFacade.h"
+
+#include "QWebPageClient.h"
+#include <Chrome.h>
+#include <ChromeClient.h>
+#include <Page.h>
+
+namespace WebCore {
+
+QStyle* QStyleFacade::styleForPage(Page* page)
+{
+ if (!page)
+ return 0;
+ QWebPageClient* pageClient = page->chrome()->client()->platformPageClient();
+
+ if (!pageClient)
+ return 0;
+
+ return pageClient->style();
+}
+
+}
diff --git a/Source/WebCore/platform/qt/QStyleFacade.h b/Source/WebCore/platform/qt/QStyleFacade.h
new file mode 100644
index 000000000..73e8362b1
--- /dev/null
+++ b/Source/WebCore/platform/qt/QStyleFacade.h
@@ -0,0 +1,201 @@
+/*
+ * This file is part of the theme implementation for form controls in WebCore.
+ *
+ * Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+ * Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef QStyleFacade_h
+#define QStyleFacade_h
+
+#include <QPalette>
+#include <QRect>
+
+QT_BEGIN_NAMESPACE
+class QStyle;
+QT_END_NAMESPACE
+
+namespace WebCore {
+
+class Page;
+class QStyleFacadeOption;
+
+class QStyleFacade {
+public:
+ enum ButtonSubElement {
+ PushButtonLayoutItem,
+ PushButtonContents
+ };
+
+#define FOR_EACH_MAPPED_STATE(F, SEPARATOR) \
+ F(State_None, 0x00000000) SEPARATOR \
+ F(State_Enabled, 0x00000001) SEPARATOR \
+ F(State_Raised, 0x00000002) SEPARATOR \
+ F(State_Sunken, 0x00000004) SEPARATOR \
+ F(State_Off, 0x00000008) SEPARATOR \
+ F(State_NoChange, 0x00000010) SEPARATOR \
+ F(State_On, 0x00000020) SEPARATOR \
+ F(State_DownArrow, 0x00000040) SEPARATOR \
+ F(State_Horizontal, 0x00000080) SEPARATOR \
+ F(State_HasFocus, 0x00000100) SEPARATOR \
+ F(State_Top, 0x00000200) SEPARATOR \
+ F(State_Bottom, 0x00000400) SEPARATOR \
+ F(State_FocusAtBorder, 0x00000800) SEPARATOR \
+ F(State_AutoRaise, 0x00001000) SEPARATOR \
+ F(State_MouseOver, 0x00002000) SEPARATOR \
+ F(State_UpArrow, 0x00004000) SEPARATOR \
+ F(State_Selected, 0x00008000) SEPARATOR \
+ F(State_Active, 0x00010000) SEPARATOR \
+ F(State_Window, 0x00020000) SEPARATOR \
+ F(State_Open, 0x00040000) SEPARATOR \
+ F(State_Children, 0x00080000) SEPARATOR \
+ F(State_Item, 0x00100000) SEPARATOR \
+ F(State_Sibling, 0x00200000) SEPARATOR \
+ F(State_Editing, 0x00400000) SEPARATOR \
+ F(State_KeyboardFocusChange, 0x00800000) SEPARATOR \
+ F(State_ReadOnly, 0x02000000) SEPARATOR \
+ F(State_Small, 0x04000000) SEPARATOR \
+ F(State_Mini, 0x0800000)
+
+#define COMMA ,
+#define SEMICOLON ;
+#define DEFINE_MAPPED_STATE(Name, Value) \
+ Name = Value
+
+ // ### Remove unused states.
+ enum StateFlag {
+ FOR_EACH_MAPPED_STATE(DEFINE_MAPPED_STATE, COMMA)
+ };
+ Q_DECLARE_FLAGS(State, StateFlag)
+
+#define FOR_EACH_MAPPED_METRIC(F, SEPARATOR) \
+ F(PM_ButtonMargin) SEPARATOR \
+ F(PM_DefaultFrameWidth) SEPARATOR \
+ F(PM_IndicatorWidth) SEPARATOR \
+ F(PM_ExclusiveIndicatorWidth) SEPARATOR \
+ F(PM_ButtonIconSize)
+
+#define DEFINE_METRIC(F) F
+
+ enum PixelMetric {
+ FOR_EACH_MAPPED_METRIC(DEFINE_METRIC, COMMA)
+ };
+
+#define FOR_EACH_SUBCONTROL(F, SEPARATOR) \
+ F(SC_None, 0x00000000) SEPARATOR \
+ F(SC_ScrollBarAddLine, 0x00000001) SEPARATOR \
+ F(SC_ScrollBarSubLine, 0x00000002) SEPARATOR \
+ F(SC_ScrollBarAddPage, 0x00000004) SEPARATOR \
+ F(SC_ScrollBarSubPage, 0x00000008) SEPARATOR \
+ F(SC_ScrollBarFirst, 0x00000010) SEPARATOR \
+ F(SC_ScrollBarLast, 0x00000020) SEPARATOR \
+ F(SC_ScrollBarSlider, 0x00000040) SEPARATOR \
+ F(SC_ScrollBarGroove, 0x00000080)
+
+#define DEFINE_SUBCONTROL(F, Value) F
+
+ enum SubControl {
+ FOR_EACH_SUBCONTROL(DEFINE_SUBCONTROL, COMMA)
+ };
+
+ virtual ~QStyleFacade() { }
+
+ virtual QRect buttonSubElementRect(ButtonSubElement buttonElement, State, const QRect& originalRect) const = 0;
+
+ virtual int findFrameLineWidth() const = 0;
+ virtual int simplePixelMetric(PixelMetric, State = State_None) const = 0;
+ virtual int buttonMargin(State, const QRect& originalRect) const = 0;
+ virtual int sliderLength(Qt::Orientation) const = 0;
+ virtual int sliderThickness(Qt::Orientation) const = 0;
+ virtual int progressBarChunkWidth(const QSize&) const = 0;
+ virtual void getButtonMetrics(QString* buttonFontFamily, int* buttonFontPixelSize) const = 0;
+
+ virtual QSize comboBoxSizeFromContents(State, const QSize& contentsSize) const = 0;
+ virtual QSize pushButtonSizeFromContents(State, const QSize& contentsSize) const = 0;
+
+ enum ButtonType {
+ PushButton,
+ RadioButton,
+ CheckBox
+ };
+
+ virtual void paintButton(QPainter*, ButtonType, const QStyleFacadeOption&) = 0;
+ virtual void paintTextField(QPainter*, const QStyleFacadeOption&) = 0;
+ virtual void paintComboBox(QPainter*, const QStyleFacadeOption&) = 0;
+ virtual void paintComboBoxArrow(QPainter*, const QStyleFacadeOption&) = 0;
+
+ virtual void paintSliderTrack(QPainter*, const QStyleFacadeOption&) = 0;
+ virtual void paintSliderThumb(QPainter*, const QStyleFacadeOption&) = 0;
+ virtual void paintInnerSpinButton(QPainter*, const QStyleFacadeOption&, bool spinBoxUp) = 0;
+ virtual void paintProgressBar(QPainter*, const QStyleFacadeOption&, double progress, double animationProgress) = 0;
+
+ virtual int scrollBarExtent(bool mini) = 0;
+ virtual bool scrollBarMiddleClickAbsolutePositionStyleHint() const = 0;
+ virtual void paintScrollCorner(QPainter*, const QRect&) = 0;
+
+ virtual SubControl hitTestScrollBar(const QStyleFacadeOption&, const QPoint& pos) = 0;
+ virtual QRect scrollBarSubControlRect(const QStyleFacadeOption&, SubControl) = 0;
+ virtual void paintScrollBar(QPainter*, const QStyleFacadeOption&) = 0;
+
+ virtual QObject* widgetForPainter(QPainter*) = 0;
+
+ virtual bool isValid() const = 0;
+
+ static QStyle* styleForPage(Page*);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleFacade::State)
+
+struct QStyleFacadeOption {
+ QStyleFacadeOption()
+ : state(QStyleFacade::State_None)
+ , direction(Qt::LayoutDirectionAuto)
+ {
+ slider.orientation = Qt::Horizontal;
+ slider.upsideDown = false;
+ slider.minimum = 0;
+ slider.maximum = 0;
+ slider.position = 0;
+ slider.value = 0;
+ slider.singleStep = 0;
+ slider.pageStep = 0;
+ slider.activeSubControls = QStyleFacade::SC_None;
+ }
+
+ QStyleFacade::State state;
+ QRect rect;
+ Qt::LayoutDirection direction;
+ QPalette palette;
+
+ // Slider features
+ struct {
+ Qt::Orientation orientation;
+ bool upsideDown;
+ int minimum;
+ int maximum;
+ int position;
+ int value;
+ int singleStep;
+ int pageStep;
+ QStyleFacade::SubControl activeSubControls;
+ } slider;
+};
+
+}
+
+#endif // QStyleFacade_h
diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp
new file mode 100644
index 000000000..f7e8bf5c9
--- /dev/null
+++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp
@@ -0,0 +1,620 @@
+/*
+ * This file is part of the WebKit project.
+ *
+ * Copyright (C) 2008-2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ * 2006 Dirk Mueller <mueller@kde.org>
+ * 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2008 Holger Hans Peter Freyther
+ *
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "RenderThemeQStyle.h"
+
+#include "CSSFontSelector.h"
+#include "CSSValueKeywords.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Color.h"
+#include "Document.h"
+#include "Font.h"
+#include "FontSelector.h"
+#include "GraphicsContext.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "LocalizedStrings.h"
+#include "NotImplemented.h"
+#include "Page.h"
+#include "PaintInfo.h"
+#include "QWebPageClient.h"
+#include "RenderBox.h"
+#if ENABLE(PROGRESS_ELEMENT)
+#include "RenderProgress.h"
+#endif
+#include "RenderSlider.h"
+#include "ScrollbarThemeQStyle.h"
+#include "SliderThumbElement.h"
+#include "StyleResolver.h"
+#include "UserAgentStyleSheets.h"
+
+#include <QPainter>
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+QSharedPointer<StylePainter> RenderThemeQStyle::getStylePainter(const PaintInfo& paintInfo)
+{
+ return QSharedPointer<StylePainter>(new StylePainterQStyle(this, paintInfo, /*RenderObject*/0));
+}
+
+StylePainterQStyle::StylePainterQStyle(RenderThemeQStyle* theme, const PaintInfo& paintInfo, RenderObject* renderObject)
+ : StylePainter(theme, paintInfo)
+ , qStyle(theme->qStyle())
+ , appearance(NoControlPart)
+{
+ init(paintInfo.context ? paintInfo.context : 0);
+ if (renderObject)
+ appearance = theme->initializeCommonQStyleOptions(styleOption, renderObject);
+}
+
+StylePainterQStyle::StylePainterQStyle(ScrollbarThemeQStyle* theme, GraphicsContext* context)
+ : StylePainter()
+ , qStyle(theme->qStyle())
+ , appearance(NoControlPart)
+{
+ init(context);
+}
+
+void StylePainterQStyle::init(GraphicsContext* context)
+{
+ painter = static_cast<QPainter*>(context->platformContext());
+ if (QObject* widget = qStyle->widgetForPainter(painter)) {
+ styleOption.palette = widget->property("palette").value<QPalette>();
+ styleOption.rect = widget->property("rect").value<QRect>();
+ styleOption.direction = static_cast<Qt::LayoutDirection>(widget->property("layoutDirection").toInt());
+ }
+
+ StylePainter::init(context);
+}
+
+PassRefPtr<RenderTheme> RenderThemeQStyle::create(Page* page)
+{
+ return adoptRef(new RenderThemeQStyle(page));
+}
+
+static QtStyleFactoryFunction styleFactoryFunction;
+
+void RenderThemeQStyle::setStyleFactoryFunction(QtStyleFactoryFunction function)
+{
+ styleFactoryFunction = function;
+}
+
+QtStyleFactoryFunction RenderThemeQStyle::styleFactory()
+{
+ return styleFactoryFunction;
+}
+
+RenderThemeQStyle::RenderThemeQStyle(Page* page)
+ : RenderThemeQt(page)
+ , m_qStyle(adoptPtr(styleFactoryFunction(page)))
+{
+ int buttonPixelSize = 0;
+ m_qStyle->getButtonMetrics(&m_buttonFontFamily, &buttonPixelSize);
+#ifdef Q_WS_MAC
+ m_buttonFontPixelSize = buttonPixelSize;
+#endif
+}
+
+RenderThemeQStyle::~RenderThemeQStyle()
+{
+}
+
+void RenderThemeQStyle::setPaletteFromPageClientIfExists(QPalette& palette) const
+{
+ if (!m_page)
+ return;
+
+ ASSERT(m_page->chrome());
+ ChromeClient* chromeClient = m_page->chrome()->client();
+ if (!chromeClient)
+ return;
+
+ if (QWebPageClient* pageClient = chromeClient->platformPageClient())
+ palette = pageClient->palette();
+}
+
+QRect RenderThemeQStyle::inflateButtonRect(const QRect& originalRect) const
+{
+ QRect layoutRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonLayoutItem, QStyleFacade::State_Small, originalRect);
+ if (!layoutRect.isNull()) {
+ int paddingLeft = layoutRect.left() - originalRect.left();
+ int paddingRight = originalRect.right() - layoutRect.right();
+ int paddingTop = layoutRect.top() - originalRect.top();
+ int paddingBottom = originalRect.bottom() - layoutRect.bottom();
+
+ return originalRect.adjusted(-paddingLeft, -paddingTop, paddingRight, paddingBottom);
+ }
+ return originalRect;
+}
+
+void RenderThemeQStyle::computeSizeBasedOnStyle(RenderStyle* renderStyle) const
+{
+ QSize size(0, 0);
+ const QFontMetrics fm(renderStyle->font().syntheticFont());
+
+ switch (renderStyle->appearance()) {
+ case TextAreaPart:
+ case SearchFieldPart:
+ case TextFieldPart: {
+ int padding = m_qStyle->findFrameLineWidth();
+ renderStyle->setPaddingLeft(Length(padding, Fixed));
+ renderStyle->setPaddingRight(Length(padding, Fixed));
+ renderStyle->setPaddingTop(Length(padding, Fixed));
+ renderStyle->setPaddingBottom(Length(padding, Fixed));
+ break;
+ }
+ default:
+ break;
+ }
+ // If the width and height are both specified, then we have nothing to do.
+ if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto())
+ return;
+
+ switch (renderStyle->appearance()) {
+ case CheckboxPart: {
+ int checkBoxWidth = m_qStyle->simplePixelMetric(QStyleFacade::PM_IndicatorWidth, QStyleFacade::State_Small);
+ checkBoxWidth *= renderStyle->effectiveZoom();
+ size = QSize(checkBoxWidth, checkBoxWidth);
+ break;
+ }
+ case RadioPart: {
+ int radioWidth = m_qStyle->simplePixelMetric(QStyleFacade::PM_ExclusiveIndicatorWidth, QStyleFacade::State_Small);
+ radioWidth *= renderStyle->effectiveZoom();
+ size = QSize(radioWidth, radioWidth);
+ break;
+ }
+ case PushButtonPart:
+ case ButtonPart: {
+ QSize contentSize = fm.size(Qt::TextShowMnemonic, QString::fromLatin1("X"));
+ QSize pushButtonSize = m_qStyle->pushButtonSizeFromContents(QStyleFacade::State_Small, contentSize);
+ QRect layoutRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonLayoutItem, QStyleFacade::State_Small, QRect(0, 0, pushButtonSize.width(), pushButtonSize.height()));
+
+ // If the style supports layout rects we use that, and compensate accordingly
+ // in paintButton() below.
+ if (!layoutRect.isNull())
+ size.setHeight(layoutRect.height());
+ else
+ size.setHeight(pushButtonSize.height());
+
+ break;
+ }
+ case MenulistPart: {
+ int contentHeight = qMax(fm.lineSpacing(), 14) + 2;
+ QSize menuListSize = m_qStyle->comboBoxSizeFromContents(QStyleFacade::State_Small, QSize(0, contentHeight));
+ size.setHeight(menuListSize.height());
+ break;
+ }
+ default:
+ break;
+ }
+
+ // FIXME: Check is flawed, since it doesn't take min-width/max-width into account.
+ if (renderStyle->width().isIntrinsicOrAuto() && size.width() > 0)
+ renderStyle->setMinWidth(Length(size.width(), Fixed));
+ if (renderStyle->height().isAuto() && size.height() > 0)
+ renderStyle->setMinHeight(Length(size.height(), Fixed));
+}
+
+
+
+void RenderThemeQStyle::adjustButtonStyle(StyleResolver* styleResolver, RenderStyle* style, Element*) const
+{
+ // Ditch the border.
+ style->resetBorder();
+
+#ifdef Q_WS_MAC
+ if (style->appearance() == PushButtonPart) {
+ // The Mac ports ignore the specified height for <input type="button"> elements
+ // unless a border and/or background CSS property is also specified.
+ style->setHeight(Length(Auto));
+ }
+#endif
+
+ FontDescription fontDescription = style->fontDescription();
+ fontDescription.setIsAbsoluteSize(true);
+
+#ifdef Q_WS_MAC // Use fixed font size and family on Mac (like Safari does)
+ fontDescription.setSpecifiedSize(m_buttonFontPixelSize);
+ fontDescription.setComputedSize(m_buttonFontPixelSize);
+#else
+ fontDescription.setSpecifiedSize(style->fontSize());
+ fontDescription.setComputedSize(style->fontSize());
+#endif
+
+ FontFamily fontFamily;
+ fontFamily.setFamily(m_buttonFontFamily);
+ fontDescription.setFamily(fontFamily);
+ style->setFontDescription(fontDescription);
+ style->font().update(styleResolver->fontSelector());
+ style->setLineHeight(RenderStyle::initialLineHeight());
+ setButtonSize(style);
+ setButtonPadding(style);
+}
+
+void RenderThemeQStyle::setButtonPadding(RenderStyle* style) const
+{
+ // Fake a button rect here, since we're just computing deltas
+ QRect originalRect = QRect(0, 0, 100, 30);
+
+ // Default padding is based on the button margin pixel metric
+ int buttonMargin = m_qStyle->buttonMargin(QStyleFacade::State_Small, originalRect);
+ int paddingLeft = buttonMargin;
+ int paddingRight = buttonMargin;
+ int paddingTop = buttonMargin;
+ int paddingBottom = buttonMargin;
+
+ // Then check if the style uses layout margins
+ QRect layoutRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonLayoutItem, QStyleFacade::State_Small, originalRect);
+ if (!layoutRect.isNull()) {
+ QRect contentsRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonContents, QStyleFacade::State_Small, originalRect);
+ paddingLeft = contentsRect.left() - layoutRect.left();
+ paddingRight = layoutRect.right() - contentsRect.right();
+ paddingTop = contentsRect.top() - layoutRect.top();
+
+ // Can't use this right now because we don't have the baseline to compensate
+ // paddingBottom = layoutRect.bottom() - contentsRect.bottom();
+ }
+ style->setPaddingLeft(Length(paddingLeft, Fixed));
+ style->setPaddingRight(Length(paddingRight, Fixed));
+ style->setPaddingTop(Length(paddingTop, Fixed));
+ style->setPaddingBottom(Length(paddingBottom, Fixed));
+}
+
+bool RenderThemeQStyle::paintButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ StylePainterQStyle p(this, i, o);
+ if (!p.isValid())
+ return true;
+
+ p.styleOption.rect = r;
+ p.styleOption.state |= QStyleFacade::State_Small;
+
+ if (p.appearance == PushButtonPart || p.appearance == ButtonPart) {
+ p.styleOption.rect = inflateButtonRect(p.styleOption.rect);
+ p.paintButton(QStyleFacade::PushButton);
+ } else if (p.appearance == RadioPart)
+ p.paintButton(QStyleFacade::RadioButton);
+ else if (p.appearance == CheckboxPart)
+ p.paintButton(QStyleFacade::CheckBox);
+
+ return false;
+}
+
+bool RenderThemeQStyle::paintTextField(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ StylePainterQStyle p(this, i, o);
+ if (!p.isValid())
+ return true;
+
+ p.styleOption.rect = r;
+ p.styleOption.state |= QStyleFacade::State_Sunken;
+
+ // Get the correct theme data for a text field
+ if (p.appearance != TextFieldPart
+ && p.appearance != SearchFieldPart
+ && p.appearance != TextAreaPart
+ && p.appearance != ListboxPart)
+ return true;
+
+ // Now paint the text field.
+ p.paintTextField();
+ return false;
+}
+
+void RenderThemeQStyle::adjustTextAreaStyle(StyleResolver* styleResolver, RenderStyle* style, Element* element) const
+{
+ adjustTextFieldStyle(styleResolver, style, element);
+}
+
+bool RenderThemeQStyle::paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ return paintTextField(o, i, r);
+}
+
+void RenderThemeQStyle::setPopupPadding(RenderStyle* style) const
+{
+ const int paddingLeft = 4;
+ const int paddingRight = style->width().isFixed() || style->width().isPercent() ? 5 : 8;
+
+ style->setPaddingLeft(Length(paddingLeft, Fixed));
+
+ int w = m_qStyle->simplePixelMetric(QStyleFacade::PM_ButtonIconSize);
+ style->setPaddingRight(Length(paddingRight + w, Fixed));
+
+ style->setPaddingTop(Length(2, Fixed));
+ style->setPaddingBottom(Length(2, Fixed));
+}
+
+QPalette RenderThemeQStyle::colorPalette() const
+{
+ QPalette palette = RenderThemeQt::colorPalette();
+ setPaletteFromPageClientIfExists(palette);
+ return palette;
+}
+
+bool RenderThemeQStyle::paintMenuList(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ StylePainterQStyle p(this, i, o);
+ if (!p.isValid())
+ return true;
+
+ p.styleOption.rect = r;
+ p.paintComboBox();
+ return false;
+}
+
+void RenderThemeQStyle::adjustMenuListButtonStyle(StyleResolver* styleResolver, RenderStyle* style, Element* e) const
+{
+ // WORKAROUND because html.css specifies -webkit-border-radius for <select> so we override it here
+ // see also http://bugs.webkit.org/show_bug.cgi?id=18399
+ style->resetBorderRadius();
+
+ RenderThemeQt::adjustMenuListButtonStyle(styleResolver, style, e);
+}
+
+bool RenderThemeQStyle::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& r)
+{
+ StylePainterQStyle p(this, i, o);
+ if (!p.isValid())
+ return true;
+
+ p.styleOption.rect = r;
+ p.paintComboBoxArrow();
+ return false;
+}
+
+#if ENABLE(PROGRESS_ELEMENT)
+double RenderThemeQStyle::animationDurationForProgressBar(RenderProgress* renderProgress) const
+{
+ if (renderProgress->position() >= 0)
+ return 0;
+
+ IntSize size = renderProgress->pixelSnappedSize();
+ // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed,
+ // we simulate one square animating across the progress bar.
+ return (size.width() / m_qStyle->progressBarChunkWidth(size)) * animationRepeatIntervalForProgressBar(renderProgress);
+}
+
+bool RenderThemeQStyle::paintProgressBar(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+{
+ if (!o->isProgress())
+ return true;
+
+ StylePainterQStyle p(this, pi, o);
+ if (!p.isValid())
+ return true;
+
+ p.styleOption.rect = r;
+ RenderProgress* renderProgress = toRenderProgress(o);
+ p.paintProgressBar(renderProgress->position(), renderProgress->animationProgress());
+ return false;
+}
+#endif
+
+bool RenderThemeQStyle::paintSliderTrack(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+{
+ StylePainterQStyle p(this, pi, o);
+ if (!p.isValid())
+ return true;
+
+ const QPoint topLeft = r.location();
+ p.painter->translate(topLeft);
+
+ p.styleOption.rect = r;
+ p.styleOption.rect.moveTo(QPoint(0, 0));
+
+ if (p.appearance == SliderVerticalPart)
+ p.styleOption.slider.orientation = Qt::Vertical;
+
+ if (isPressed(o))
+ p.styleOption.state |= QStyleFacade::State_Sunken;
+
+ // some styles need this to show a highlight on one side of the groove
+ HTMLInputElement* slider = o->node()->toInputElement();
+ if (slider) {
+ p.styleOption.slider.upsideDown = (p.appearance == SliderHorizontalPart) && !o->style()->isLeftToRightDirection();
+ // Use the width as a multiplier in case the slider values are <= 1
+ const int width = r.width() > 0 ? r.width() : 100;
+ p.styleOption.slider.maximum = slider->maximum() * width;
+ p.styleOption.slider.minimum = slider->minimum() * width;
+ if (!p.styleOption.slider.upsideDown)
+ p.styleOption.slider.position = slider->valueAsNumber() * width;
+ else
+ p.styleOption.slider.position = p.styleOption.slider.minimum + p.styleOption.slider.maximum - slider->valueAsNumber() * width;
+ }
+
+ p.paintSliderTrack();
+
+ p.painter->translate(-topLeft);
+ return false;
+}
+
+void RenderThemeQStyle::adjustSliderTrackStyle(StyleResolver*, RenderStyle* style, Element*) const
+{
+ style->setBoxShadow(nullptr);
+}
+
+bool RenderThemeQStyle::paintSliderThumb(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+{
+ StylePainterQStyle p(this, pi, o);
+ if (!p.isValid())
+ return true;
+
+ const QPoint topLeft = r.location();
+ p.painter->translate(topLeft);
+
+ p.styleOption.rect = r;
+ p.styleOption.rect.moveTo(QPoint(0, 0));
+ p.styleOption.slider.orientation = Qt::Horizontal;
+ if (p.appearance == SliderThumbVerticalPart)
+ p.styleOption.slider.orientation = Qt::Vertical;
+ if (isPressed(o))
+ p.styleOption.state |= QStyleFacade::State_Sunken;
+
+ p.paintSliderThumb();
+
+ p.painter->translate(-topLeft);
+ return false;
+}
+
+void RenderThemeQStyle::adjustSliderThumbStyle(StyleResolver* styleResolver, RenderStyle* style, Element* element) const
+{
+ RenderTheme::adjustSliderThumbStyle(styleResolver, style, element);
+ style->setBoxShadow(nullptr);
+}
+
+bool RenderThemeQStyle::paintSearchField(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+{
+ return paintTextField(o, pi, r);
+}
+
+void RenderThemeQStyle::adjustSearchFieldDecorationStyle(StyleResolver* styleResolver, RenderStyle* style, Element* e) const
+{
+ notImplemented();
+ RenderTheme::adjustSearchFieldDecorationStyle(styleResolver, style, e);
+}
+
+bool RenderThemeQStyle::paintSearchFieldDecoration(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+{
+ notImplemented();
+ return RenderTheme::paintSearchFieldDecoration(o, pi, r);
+}
+
+void RenderThemeQStyle::adjustSearchFieldResultsDecorationStyle(StyleResolver* styleResolver, RenderStyle* style, Element* e) const
+{
+ notImplemented();
+ RenderTheme::adjustSearchFieldResultsDecorationStyle(styleResolver, style, e);
+}
+
+bool RenderThemeQStyle::paintSearchFieldResultsDecoration(RenderObject* o, const PaintInfo& pi, const IntRect& r)
+{
+ notImplemented();
+ return RenderTheme::paintSearchFieldResultsDecoration(o, pi, r);
+}
+
+#ifndef QT_NO_SPINBOX
+
+bool RenderThemeQStyle::paintInnerSpinButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect)
+{
+ StylePainterQStyle p(this, paintInfo, o);
+ if (!p.isValid())
+ return true;
+
+ p.styleOption.rect = rect;
+ p.paintInnerSpinButton(isSpinUpButtonPartPressed(o));
+ return false;
+}
+#endif
+
+ControlPart RenderThemeQStyle::initializeCommonQStyleOptions(QStyleFacadeOption &option, RenderObject* o) const
+{
+ // Default bits: no focus, no mouse over
+ option.state &= ~(QStyleFacade::State_HasFocus | QStyleFacade::State_MouseOver);
+
+ if (isReadOnlyControl(o))
+ // Readonly is supported on textfields.
+ option.state |= QStyleFacade::State_ReadOnly;
+
+ option.direction = Qt::LeftToRight;
+
+ if (isHovered(o))
+ option.state |= QStyleFacade::State_MouseOver;
+
+ setPaletteFromPageClientIfExists(option.palette);
+
+ if (!isEnabled(o)) {
+ option.palette.setCurrentColorGroup(QPalette::Disabled);
+ option.state &= ~QStyleFacade::State_Enabled;
+ }
+
+ RenderStyle* style = o->style();
+ if (!style)
+ return NoControlPart;
+
+ ControlPart result = style->appearance();
+ if (supportsFocus(result) && isFocused(o)) {
+ option.state |= QStyleFacade::State_HasFocus;
+ option.state |= QStyleFacade::State_KeyboardFocusChange;
+ }
+
+ if (style->direction() == WebCore::RTL)
+ option.direction = Qt::RightToLeft;
+
+ switch (result) {
+ case PushButtonPart:
+ case SquareButtonPart:
+ case ButtonPart:
+ case ButtonBevelPart:
+ case ListItemPart:
+ case MenulistButtonPart:
+ case InnerSpinButtonPart:
+ case SearchFieldResultsButtonPart:
+ case SearchFieldCancelButtonPart: {
+ if (isPressed(o))
+ option.state |= QStyleFacade::State_Sunken;
+ else if (result == PushButtonPart || result == ButtonPart)
+ option.state |= QStyleFacade::State_Raised;
+ break;
+ }
+ case RadioPart:
+ case CheckboxPart:
+ option.state |= (isChecked(o) ? QStyleFacade::State_On : QStyleFacade::State_Off);
+ }
+
+ return result;
+}
+
+void RenderThemeQStyle::adjustSliderThumbSize(RenderStyle* style, Element* element) const
+{
+ const ControlPart part = style->appearance();
+ if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) {
+ Qt::Orientation orientation = Qt::Horizontal;
+ if (part == SliderThumbVerticalPart)
+ orientation = Qt::Vertical;
+
+ int length = m_qStyle->sliderLength(orientation);
+ int thickness = m_qStyle->sliderThickness(orientation);
+ if (orientation == Qt::Vertical) {
+ style->setWidth(Length(thickness, Fixed));
+ style->setHeight(Length(length, Fixed));
+ } else {
+ style->setWidth(Length(length, Fixed));
+ style->setHeight(Length(thickness, Fixed));
+ }
+ } else
+ RenderThemeQt::adjustSliderThumbSize(style, element);
+}
+
+}
+
+// vim: ts=4 sw=4 et
diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.h b/Source/WebCore/platform/qt/RenderThemeQStyle.h
new file mode 100644
index 000000000..08c18b971
--- /dev/null
+++ b/Source/WebCore/platform/qt/RenderThemeQStyle.h
@@ -0,0 +1,158 @@
+/*
+ * This file is part of the theme implementation for form controls in WebCore.
+ *
+ * Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef RenderThemeQStyle_h
+#define RenderThemeQStyle_h
+
+#include "QStyleFacade.h"
+#include "RenderThemeQt.h"
+
+namespace WebCore {
+
+class ScrollbarThemeQStyle;
+
+class Page;
+class QStyleFacade;
+struct QStyleFacadeOption;
+
+typedef QStyleFacade* (*QtStyleFactoryFunction)(Page*);
+
+class RenderThemeQStyle : public RenderThemeQt {
+private:
+ friend class StylePainterQStyle;
+
+ RenderThemeQStyle(Page*);
+ virtual ~RenderThemeQStyle();
+
+public:
+ static PassRefPtr<RenderTheme> create(Page*);
+
+ static void setStyleFactoryFunction(QtStyleFactoryFunction);
+ static QtStyleFactoryFunction styleFactory();
+
+ virtual void adjustSliderThumbSize(RenderStyle*, Element*) const;
+
+ QStyleFacade* qStyle() { return m_qStyle.get(); }
+
+protected:
+ virtual void adjustButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
+ virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual bool paintTextArea(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual void adjustTextAreaStyle(StyleResolver*, RenderStyle*, Element*) const;
+
+ virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual bool paintMenuListButton(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual void adjustMenuListButtonStyle(StyleResolver*, RenderStyle*, Element*) const;
+
+#if ENABLE(PROGRESS_ELEMENT)
+ // Returns the duration of the animation for the progress bar.
+ virtual double animationDurationForProgressBar(RenderProgress*) const;
+ virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&);
+#endif
+
+ virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual void adjustSliderTrackStyle(StyleResolver*, RenderStyle*, Element*) const;
+
+ virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
+ virtual void adjustSliderThumbStyle(StyleResolver*, RenderStyle*, Element*) const;
+
+ virtual bool paintSearchField(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual void adjustSearchFieldDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
+ virtual bool paintSearchFieldDecoration(RenderObject*, const PaintInfo&, const IntRect&);
+
+ virtual void adjustSearchFieldResultsDecorationStyle(StyleResolver*, RenderStyle*, Element*) const;
+ virtual bool paintSearchFieldResultsDecoration(RenderObject*, const PaintInfo&, const IntRect&);
+
+#ifndef QT_NO_SPINBOX
+ virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&);
+#endif
+
+protected:
+ virtual void computeSizeBasedOnStyle(RenderStyle*) const;
+
+ virtual QSharedPointer<StylePainter> getStylePainter(const PaintInfo&);
+
+ virtual QRect inflateButtonRect(const QRect& originalRect) const;
+
+ virtual void setPopupPadding(RenderStyle*) const;
+
+ virtual QPalette colorPalette() const;
+
+private:
+ ControlPart initializeCommonQStyleOptions(QStyleFacadeOption&, RenderObject*) const;
+
+ void setButtonPadding(RenderStyle*) const;
+
+ void setPaletteFromPageClientIfExists(QPalette&) const;
+
+#ifdef Q_OS_MAC
+ int m_buttonFontPixelSize;
+#endif
+
+ OwnPtr<QStyleFacade> m_qStyle;
+};
+
+class StylePainterQStyle : public StylePainter {
+public:
+ explicit StylePainterQStyle(RenderThemeQStyle*, const PaintInfo&, RenderObject*);
+ explicit StylePainterQStyle(ScrollbarThemeQStyle*, GraphicsContext*);
+
+ bool isValid() const { return qStyle && qStyle->isValid() && StylePainter::isValid(); }
+
+ QStyleFacade* qStyle;
+ QStyleFacadeOption styleOption;
+ ControlPart appearance;
+
+ void paintButton(QStyleFacade::ButtonType type)
+ { qStyle->paintButton(painter, type, styleOption); }
+ void paintTextField()
+ { qStyle->paintTextField(painter, styleOption); }
+ void paintComboBox()
+ { qStyle->paintComboBox(painter, styleOption); }
+ void paintComboBoxArrow()
+ { qStyle->paintComboBoxArrow(painter, styleOption); }
+ void paintSliderTrack()
+ { qStyle->paintSliderTrack(painter, styleOption); }
+ void paintSliderThumb()
+ { qStyle->paintSliderThumb(painter, styleOption); }
+ void paintInnerSpinButton(bool spinBoxUp)
+ { qStyle->paintInnerSpinButton(painter, styleOption, spinBoxUp); }
+ void paintProgressBar(double progress, double animationProgress)
+ { qStyle->paintProgressBar(painter, styleOption, progress, animationProgress); }
+ void paintScrollCorner(const QRect& rect)
+ { qStyle->paintScrollCorner(painter, rect); }
+ void paintScrollBar()
+ { qStyle->paintScrollBar(painter, styleOption); }
+
+private:
+ void init(GraphicsContext*);
+
+ Q_DISABLE_COPY(StylePainterQStyle)
+};
+
+}
+
+#endif // RenderThemeQStyle_h
diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp
index 1de8153a3..af36a4f7a 100644
--- a/Source/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp
@@ -60,10 +60,10 @@
#include "UserAgentStyleSheets.h"
#include <wtf/text/StringBuilder.h>
-#include <QGuiApplication>
#include <QColor>
#include <QFile>
#include <QFontMetrics>
+#include <QGuiApplication>
#include <QStyleHints>
diff --git a/Source/WebCore/platform/qt/RunLoopQt.cpp b/Source/WebCore/platform/qt/RunLoopQt.cpp
index 2a87e2fc8..501bd5c12 100644
--- a/Source/WebCore/platform/qt/RunLoopQt.cpp
+++ b/Source/WebCore/platform/qt/RunLoopQt.cpp
@@ -109,7 +109,7 @@ void RunLoop::TimerBase::timerFired(RunLoop* runLoop, int ID)
{
TimerMap::iterator it = runLoop->m_activeTimers.find(ID);
ASSERT(it != runLoop->m_activeTimers.end());
- TimerBase* timer = it->second;
+ TimerBase* timer = it->value;
if (!timer->m_isRepeating) {
// Stop the timer (calling stop would need another hash table lookup).
diff --git a/Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp b/Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp
new file mode 100644
index 000000000..ac0dc3844
--- /dev/null
+++ b/Source/WebCore/platform/qt/ScrollbarThemeQStyle.cpp
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
+ * Copyright (C) 2008 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 "ScrollbarThemeQStyle.h"
+
+#include "GraphicsContext.h"
+#include "PlatformMouseEvent.h"
+#include "RenderThemeQStyle.h"
+#include "ScrollView.h"
+#include "Scrollbar.h"
+
+namespace WebCore {
+
+ScrollbarThemeQStyle::ScrollbarThemeQStyle()
+{
+ m_qStyle = adoptPtr(RenderThemeQStyle::styleFactory()(/*page*/ 0));
+}
+
+ScrollbarThemeQStyle::~ScrollbarThemeQStyle()
+{
+}
+
+static QStyleFacade::SubControl scPart(const ScrollbarPart& part)
+{
+ switch (part) {
+ case NoPart:
+ return QStyleFacade::SC_None;
+ case BackButtonStartPart:
+ case BackButtonEndPart:
+ return QStyleFacade::SC_ScrollBarSubLine;
+ case BackTrackPart:
+ return QStyleFacade::SC_ScrollBarSubPage;
+ case ThumbPart:
+ return QStyleFacade::SC_ScrollBarSlider;
+ case ForwardTrackPart:
+ return QStyleFacade::SC_ScrollBarAddPage;
+ case ForwardButtonStartPart:
+ case ForwardButtonEndPart:
+ return QStyleFacade::SC_ScrollBarAddLine;
+ }
+
+ return QStyleFacade::SC_None;
+}
+
+static ScrollbarPart scrollbarPart(const QStyleFacade::SubControl& sc)
+{
+ switch (sc) {
+ case QStyleFacade::SC_None:
+ return NoPart;
+ case QStyleFacade::SC_ScrollBarSubLine:
+ return BackButtonStartPart;
+ case QStyleFacade::SC_ScrollBarSubPage:
+ return BackTrackPart;
+ case QStyleFacade::SC_ScrollBarSlider:
+ return ThumbPart;
+ case QStyleFacade::SC_ScrollBarAddPage:
+ return ForwardTrackPart;
+ case QStyleFacade::SC_ScrollBarAddLine:
+ return ForwardButtonStartPart;
+ }
+ return NoPart;
+}
+
+static QStyleFacadeOption initSliderStyleOption(ScrollbarThemeClient* scrollbar, QObject* widget = 0)
+{
+ QStyleFacadeOption opt;
+ if (widget) {
+ opt.palette = widget->property("palette").value<QPalette>();
+ opt.rect = widget->property("rect").value<QRect>();
+ opt.direction = static_cast<Qt::LayoutDirection>(widget->property("layoutDirection").toInt());
+ } else
+ opt.state |= QStyleFacade::State_Active;
+
+ opt.state &= ~QStyleFacade::State_HasFocus;
+
+ opt.rect = scrollbar->frameRect();
+ if (scrollbar->enabled())
+ opt.state |= QStyleFacade::State_Enabled;
+ if (scrollbar->controlSize() != RegularScrollbar)
+ opt.state |= QStyleFacade::State_Mini;
+ opt.slider.orientation = (scrollbar->orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal;
+
+ if (scrollbar->orientation() == HorizontalScrollbar)
+ opt.state |= QStyleFacade::State_Horizontal;
+ else
+ opt.state &= ~QStyleFacade::State_Horizontal;
+
+ opt.slider.value = scrollbar->value();
+ opt.slider.position = opt.slider.value;
+ opt.slider.pageStep = scrollbar->pageStep();
+ opt.slider.singleStep = scrollbar->lineStep();
+ opt.slider.minimum = 0;
+ opt.slider.maximum = qMax(0, scrollbar->maximum());
+ ScrollbarPart pressedPart = scrollbar->pressedPart();
+ ScrollbarPart hoveredPart = scrollbar->hoveredPart();
+ if (pressedPart != NoPart) {
+ opt.slider.activeSubControls = scPart(scrollbar->pressedPart());
+ if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart
+ || pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart
+ || pressedPart == ThumbPart)
+ opt.state |= QStyleFacade::State_Sunken;
+ } else
+ opt.slider.activeSubControls = scPart(hoveredPart);
+ if (hoveredPart != NoPart)
+ opt.state |= QStyleFacade::State_MouseOver;
+ return opt;
+}
+
+bool ScrollbarThemeQStyle::paint(ScrollbarThemeClient* scrollbar, GraphicsContext* graphicsContext, const IntRect& dirtyRect)
+{
+ if (graphicsContext->updatingControlTints()) {
+ scrollbar->invalidateRect(dirtyRect);
+ return false;
+ }
+
+ StylePainterQStyle p(this, graphicsContext);
+ if (!p.isValid())
+ return true;
+
+ p.painter->save();
+ p.styleOption = initSliderStyleOption(scrollbar, m_qStyle->widgetForPainter(p.painter));
+
+ p.painter->setClipRect(p.styleOption.rect.intersected(dirtyRect), Qt::IntersectClip);
+ p.paintScrollBar();
+ p.painter->restore();
+ return true;
+}
+
+ScrollbarPart ScrollbarThemeQStyle::hitTest(ScrollbarThemeClient* scrollbar, const PlatformMouseEvent& evt)
+{
+ QStyleFacadeOption opt = initSliderStyleOption(scrollbar);
+ const QPoint pos = scrollbar->convertFromContainingWindow(evt.position());
+ opt.rect.moveTo(QPoint(0, 0));
+ QStyleFacade::SubControl sc = m_qStyle->hitTestScrollBar(opt, pos);
+ return scrollbarPart(sc);
+}
+
+bool ScrollbarThemeQStyle::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt)
+{
+ // Middle click centers slider thumb (if supported).
+ return m_qStyle->scrollBarMiddleClickAbsolutePositionStyleHint() && evt.button() == MiddleButton;
+}
+
+void ScrollbarThemeQStyle::invalidatePart(ScrollbarThemeClient* scrollbar, ScrollbarPart)
+{
+ // FIXME: Do more precise invalidation.
+ scrollbar->invalidate();
+}
+
+int ScrollbarThemeQStyle::scrollbarThickness(ScrollbarControlSize controlSize)
+{
+ const bool mini = controlSize != RegularScrollbar;
+ return m_qStyle->scrollBarExtent(mini);
+}
+
+int ScrollbarThemeQStyle::thumbPosition(ScrollbarThemeClient* scrollbar)
+{
+ if (scrollbar->enabled()) {
+ float pos = (float)scrollbar->currentPos() * (trackLength(scrollbar) - thumbLength(scrollbar)) / scrollbar->maximum();
+ return (pos < 1 && pos > 0) ? 1 : pos;
+ }
+ return 0;
+}
+
+int ScrollbarThemeQStyle::thumbLength(ScrollbarThemeClient* scrollbar)
+{
+ QStyleFacadeOption opt = initSliderStyleOption(scrollbar);
+ QRect thumb = m_qStyle->scrollBarSubControlRect(opt, QStyleFacade::SC_ScrollBarSlider);
+ return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height();
+}
+
+int ScrollbarThemeQStyle::trackPosition(ScrollbarThemeClient* scrollbar)
+{
+ QStyleFacadeOption opt = initSliderStyleOption(scrollbar);
+ QRect track = m_qStyle->scrollBarSubControlRect(opt, QStyleFacade::SC_ScrollBarGroove);
+ return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y();
+}
+
+int ScrollbarThemeQStyle::trackLength(ScrollbarThemeClient* scrollbar)
+{
+ QStyleFacadeOption opt = initSliderStyleOption(scrollbar);
+ QRect track = m_qStyle->scrollBarSubControlRect(opt, QStyleFacade::SC_ScrollBarGroove);
+ return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height();
+}
+
+void ScrollbarThemeQStyle::paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& rect)
+{
+ StylePainterQStyle p(this, context);
+ if (!p.isValid())
+ return;
+
+ p.paintScrollCorner(rect);
+}
+
+}
+
diff --git a/Source/WebCore/platform/qt/ScrollbarThemeQStyle.h b/Source/WebCore/platform/qt/ScrollbarThemeQStyle.h
new file mode 100644
index 000000000..e04afad12
--- /dev/null
+++ b/Source/WebCore/platform/qt/ScrollbarThemeQStyle.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * 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 ScrollbarThemeQStyle_h
+#define ScrollbarThemeQStyle_h
+
+#include "ScrollbarTheme.h"
+
+#include <QtCore/qglobal.h>
+
+namespace WebCore {
+
+class QStyleFacade;
+
+class ScrollbarThemeQStyle : public ScrollbarTheme {
+public:
+ ScrollbarThemeQStyle();
+ virtual ~ScrollbarThemeQStyle();
+
+ virtual bool paint(ScrollbarThemeClient*, GraphicsContext*, const IntRect& dirtyRect);
+ virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect);
+
+ virtual ScrollbarPart hitTest(ScrollbarThemeClient*, const PlatformMouseEvent&);
+
+ virtual bool shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent&);
+
+ virtual void invalidatePart(ScrollbarThemeClient*, ScrollbarPart);
+
+ virtual int thumbPosition(ScrollbarThemeClient*);
+ virtual int thumbLength(ScrollbarThemeClient*);
+ virtual int trackPosition(ScrollbarThemeClient*);
+ virtual int trackLength(ScrollbarThemeClient*);
+
+ virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
+
+ QStyleFacade* qStyle() { return m_qStyle.get(); }
+
+private:
+ OwnPtr<QStyleFacade> m_qStyle;
+};
+
+}
+#endif