summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/qt
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/qt')
-rw-r--r--WebCore/platform/qt/DragDataQt.cpp2
-rw-r--r--WebCore/platform/qt/KURLQt.cpp9
-rw-r--r--WebCore/platform/qt/Localizations.cpp11
-rw-r--r--WebCore/platform/qt/PasteboardQt.cpp2
-rw-r--r--WebCore/platform/qt/PlatformKeyboardEventQt.cpp16
-rw-r--r--WebCore/platform/qt/PlatformTouchEventQt.cpp49
-rw-r--r--WebCore/platform/qt/PlatformTouchPointQt.cpp (renamed from WebCore/platform/qt/QWebPopup.h)38
-rw-r--r--WebCore/platform/qt/PopupMenuQt.cpp75
-rw-r--r--WebCore/platform/qt/QWebPageClient.h18
-rw-r--r--WebCore/platform/qt/QWebPopup.cpp87
-rw-r--r--WebCore/platform/qt/QtAbstractWebPopup.cpp60
-rw-r--r--WebCore/platform/qt/QtAbstractWebPopup.h69
-rw-r--r--WebCore/platform/qt/RenderThemeQt.cpp203
-rw-r--r--WebCore/platform/qt/RenderThemeQt.h23
-rw-r--r--WebCore/platform/qt/ScrollViewQt.cpp13
-rw-r--r--WebCore/platform/qt/ScrollbarThemeQt.cpp26
-rw-r--r--WebCore/platform/qt/ScrollbarThemeQt.h8
-rw-r--r--WebCore/platform/qt/SharedBufferQt.cpp2
18 files changed, 449 insertions, 262 deletions
diff --git a/WebCore/platform/qt/DragDataQt.cpp b/WebCore/platform/qt/DragDataQt.cpp
index b0611e6..09a797f 100644
--- a/WebCore/platform/qt/DragDataQt.cpp
+++ b/WebCore/platform/qt/DragDataQt.cpp
@@ -134,7 +134,7 @@ String DragData::asURL(String*) const
PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
{
if (m_platformDragData && m_platformDragData->hasHtml())
- return createFragmentFromMarkup(doc, m_platformDragData->html(), "");
+ return createFragmentFromMarkup(doc, m_platformDragData->html(), "", FragmentScriptingNotAllowed);
return 0;
}
diff --git a/WebCore/platform/qt/KURLQt.cpp b/WebCore/platform/qt/KURLQt.cpp
index 0763fe0..3bb3db2 100644
--- a/WebCore/platform/qt/KURLQt.cpp
+++ b/WebCore/platform/qt/KURLQt.cpp
@@ -86,7 +86,8 @@ KURL::operator QUrl() const
#else
// Qt 4.5 or later
// No need for special encoding
- QByteArray ba = m_string.utf8().data();
+ QString str = QString::fromRawData(reinterpret_cast<const QChar*>(m_string.characters()), m_string.length());
+ QByteArray ba = str.toUtf8();
#endif
QUrl url = QUrl::fromEncoded(ba);
@@ -95,8 +96,10 @@ KURL::operator QUrl() const
String KURL::fileSystemPath() const
{
- notImplemented();
- return String();
+ if (!isValid() || !protocolIs("file"))
+ return String();
+
+ return String(path());
}
}
diff --git a/WebCore/platform/qt/Localizations.cpp b/WebCore/platform/qt/Localizations.cpp
index 1768502..c919193 100644
--- a/WebCore/platform/qt/Localizations.cpp
+++ b/WebCore/platform/qt/Localizations.cpp
@@ -32,6 +32,7 @@
#include "LocalizedStrings.h"
#include "NotImplemented.h"
#include "PlatformString.h"
+#include <wtf/MathExtras.h>
#include <QCoreApplication>
#include <QLocale>
@@ -340,6 +341,16 @@ String AXLinkActionVerb()
return String();
}
+String AXMenuListPopupActionVerb()
+{
+ return String();
+}
+
+String AXMenuListActionVerb()
+{
+ return String();
+}
+
String multipleFileUploadText(unsigned)
{
return String();
diff --git a/WebCore/platform/qt/PasteboardQt.cpp b/WebCore/platform/qt/PasteboardQt.cpp
index 209a573..44c9eec 100644
--- a/WebCore/platform/qt/PasteboardQt.cpp
+++ b/WebCore/platform/qt/PasteboardQt.cpp
@@ -103,7 +103,7 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
if (mimeData->hasHtml()) {
QString html = mimeData->html();
if (!html.isEmpty()) {
- RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "");
+ RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "", FragmentScriptingNotAllowed);
if (fragment)
return fragment.release();
}
diff --git a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp b/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
index f78c7d7..12200f4 100644
--- a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
+++ b/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
@@ -171,6 +171,22 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad = false
return VK_DECIMAL; // (6E) Decimal key
case Qt::Key_Slash:
return VK_DIVIDE; // (6F) Divide key
+ case Qt::Key_PageUp:
+ return VK_PRIOR; // (21) PAGE UP key
+ case Qt::Key_PageDown:
+ return VK_NEXT; // (22) PAGE DOWN key
+ case Qt::Key_End:
+ return VK_END; // (23) END key
+ case Qt::Key_Home:
+ return VK_HOME; // (24) HOME key
+ case Qt::Key_Left:
+ return VK_LEFT; // (25) LEFT ARROW key
+ case Qt::Key_Up:
+ return VK_UP; // (26) UP ARROW key
+ case Qt::Key_Right:
+ return VK_RIGHT; // (27) RIGHT ARROW key
+ case Qt::Key_Down:
+ return VK_DOWN; // (28) DOWN ARROW key
default:
return 0;
}
diff --git a/WebCore/platform/qt/PlatformTouchEventQt.cpp b/WebCore/platform/qt/PlatformTouchEventQt.cpp
new file mode 100644
index 0000000..338e9d4
--- /dev/null
+++ b/WebCore/platform/qt/PlatformTouchEventQt.cpp
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the WebKit project.
+ *
+ * Copyright (C) 2009 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 "PlatformTouchEvent.h"
+
+#if ENABLE(TOUCH_EVENTS)
+
+namespace WebCore {
+
+PlatformTouchEvent::PlatformTouchEvent(QTouchEvent* event)
+{
+ switch (event->type()) {
+ case QEvent::TouchBegin: m_type = TouchStart; break;
+ case QEvent::TouchUpdate: m_type = TouchMove; break;
+ case QEvent::TouchEnd: m_type = TouchEnd; break;
+ }
+ const QList<QTouchEvent::TouchPoint>& points = event->touchPoints();
+ for (int i = 0; i < points.count(); ++i)
+ m_touchPoints.append(PlatformTouchPoint(points.at(i)));
+
+ m_ctrlKey = (event->modifiers() & Qt::ControlModifier);
+ m_altKey = (event->modifiers() & Qt::AltModifier);
+ m_shiftKey = (event->modifiers() & Qt::ShiftModifier);
+ m_metaKey = (event->modifiers() & Qt::MetaModifier);
+}
+
+}
+
+#endif
diff --git a/WebCore/platform/qt/QWebPopup.h b/WebCore/platform/qt/PlatformTouchPointQt.cpp
index 36d6781..1788cef 100644
--- a/WebCore/platform/qt/QWebPopup.h
+++ b/WebCore/platform/qt/PlatformTouchPointQt.cpp
@@ -1,6 +1,7 @@
/*
+ * This file is part of the WebKit project.
*
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2009 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
@@ -18,31 +19,26 @@
* Boston, MA 02110-1301, USA.
*
*/
-#ifndef QWebPopup_h
-#define QWebPopup_h
-#include <QComboBox>
+#include "config.h"
+#include "PlatformTouchPoint.h"
-#include "PopupMenuClient.h"
+#if ENABLE(TOUCH_EVENTS)
namespace WebCore {
-class QWebPopup : public QComboBox {
- Q_OBJECT
-public:
- QWebPopup(PopupMenuClient* client);
-
- void exec();
-
- virtual void showPopup();
- virtual void hidePopup();
-
-private slots:
- void activeChanged(int);
-private:
- PopupMenuClient* m_client;
- bool m_popupVisible;
-};
+PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point)
+{
+ m_id = point.id();
+ switch (point.state()) {
+ case Qt::TouchPointReleased: m_state = TouchReleased; break;
+ case Qt::TouchPointMoved: m_state = TouchMoved; break;
+ case Qt::TouchPointPressed: m_state = TouchPressed; break;
+ case Qt::TouchPointStationary: m_state = TouchStationary; break;
+ }
+ m_screenPos = point.screenPos().toPoint();
+ m_pos = point.pos().toPoint();
+}
}
diff --git a/WebCore/platform/qt/PopupMenuQt.cpp b/WebCore/platform/qt/PopupMenuQt.cpp
index f6ec4f7..315b891 100644
--- a/WebCore/platform/qt/PopupMenuQt.cpp
+++ b/WebCore/platform/qt/PopupMenuQt.cpp
@@ -1,7 +1,7 @@
/*
* This file is part of the popup menu implementation for <select> elements in WebCore.
*
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2008, 2009, 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2006 Apple Computer, Inc.
* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
* Coypright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
@@ -26,28 +26,19 @@
#include "config.h"
#include "PopupMenu.h"
-#include "Frame.h"
+#include "Chrome.h"
+#include "ChromeClientQt.h"
#include "FrameView.h"
-#include "HostWindow.h"
#include "PopupMenuClient.h"
#include "QWebPageClient.h"
-#include "QWebPopup.h"
-
-#include <QAction>
-#include <QDebug>
-#include <QListWidget>
-#include <QListWidgetItem>
-#include <QMenu>
-#include <QPoint>
-#include <QStandardItemModel>
-#include <QWidgetAction>
+#include "QtAbstractWebPopup.h"
namespace WebCore {
PopupMenu::PopupMenu(PopupMenuClient* client)
: m_popupClient(client)
+ , m_popup(0)
{
- m_popup = new QWebPopup(client);
}
PopupMenu::~PopupMenu()
@@ -55,52 +46,30 @@ PopupMenu::~PopupMenu()
delete m_popup;
}
-void PopupMenu::clear()
+void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
{
- m_popup->clear();
-}
+ ChromeClientQt* chromeClient = static_cast<ChromeClientQt*>(
+ view->frame()->page()->chrome()->client());
+ ASSERT(chromeClient);
-void PopupMenu::populate(const IntRect&)
-{
- clear();
- Q_ASSERT(client());
-
- QStandardItemModel* model = qobject_cast<QStandardItemModel*>(m_popup->model());
- Q_ASSERT(model);
-
- int size = client()->listSize();
- for (int i = 0; i < size; i++) {
- if (client()->itemIsSeparator(i))
- m_popup->insertSeparator(i);
- else {
- m_popup->insertItem(i, client()->itemText(i));
-
- if (model && !client()->itemIsEnabled(i))
- model->item(i)->setEnabled(false);
-
- if (client()->itemIsSelected(i))
- m_popup->setCurrentIndex(i);
- }
- }
-}
+ if (!m_popup)
+ m_popup = chromeClient->createSelectPopup();
+
+ m_popup->m_popupClient = m_popupClient;
+ m_popup->m_currentIndex = index;
+ m_popup->m_pageClient = chromeClient->platformPageClient();
+
+ QRect geometry(rect);
+ geometry.moveTopLeft(view->contentsToWindow(rect.topLeft()));
+ m_popup->m_geometry = geometry;
+
+ m_popup->show();
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
-{
- QWebPageClient* client = v->hostWindow()->platformPageClient();
- populate(r);
- QRect rect = r;
- rect.moveTopLeft(v->contentsToWindow(r.topLeft()));
- rect.setHeight(m_popup->sizeHint().height());
-
- m_popup->setParent(client->ownerWidget());
- m_popup->setGeometry(rect);
- m_popup->setCurrentIndex(index);
- m_popup->exec();
}
void PopupMenu::hide()
{
- m_popup->hidePopup();
+ m_popup->hide();
}
void PopupMenu::updateFromElement()
diff --git a/WebCore/platform/qt/QWebPageClient.h b/WebCore/platform/qt/QWebPageClient.h
index b510736..6d47c29 100644
--- a/WebCore/platform/qt/QWebPageClient.h
+++ b/WebCore/platform/qt/QWebPageClient.h
@@ -29,8 +29,14 @@
#ifndef QT_NO_CURSOR
#include <QCursor>
#endif
+
#include <QRect>
+QT_BEGIN_NAMESPACE
+class QGraphicsItem;
+class QStyle;
+QT_END_NAMESPACE
+
class QWebPageClient {
public:
virtual ~QWebPageClient() { }
@@ -39,6 +45,16 @@ public:
virtual void update(const QRect&) = 0;
virtual void setInputMethodEnabled(bool enable) = 0;
virtual bool inputMethodEnabled() const = 0;
+#if USE(ACCELERATED_COMPOSITING)
+ // this gets called when we start/stop compositing.
+ virtual void setRootGraphicsLayer(QGraphicsItem* layer) {}
+
+ // this gets called when the compositor wants us to sync the layers
+ // if scheduleSync is true, we schedule a sync ourselves. otherwise,
+ // we wait for the next update and sync the layers then.
+ virtual void markForSync(bool scheduleSync = false) {}
+#endif
+
#if QT_VERSION >= 0x040600
virtual void setInputMethodHint(Qt::InputMethodHint hint, bool enable) = 0;
#endif
@@ -67,6 +83,8 @@ public:
virtual QObject* pluginParent() const = 0;
+ virtual QStyle* style() const = 0;
+
protected:
#ifndef QT_NO_CURSOR
virtual QCursor cursor() const = 0;
diff --git a/WebCore/platform/qt/QWebPopup.cpp b/WebCore/platform/qt/QWebPopup.cpp
deleted file mode 100644
index d077079..0000000
--- a/WebCore/platform/qt/QWebPopup.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- *
- * Copyright (C) 2008 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 "QWebPopup.h"
-#include "PopupMenuStyle.h"
-
-#include <QAbstractItemView>
-#include <QApplication>
-#include <QInputContext>
-#include <QMouseEvent>
-
-namespace WebCore {
-
-QWebPopup::QWebPopup(PopupMenuClient* client)
- : m_client(client)
- , m_popupVisible(false)
-{
- Q_ASSERT(m_client);
-
- setFont(m_client->menuStyle().font().font());
- connect(this, SIGNAL(activated(int)),
- SLOT(activeChanged(int)), Qt::QueuedConnection);
-}
-
-
-void QWebPopup::exec()
-{
- QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton,
- Qt::LeftButton, Qt::NoModifier);
- QCoreApplication::sendEvent(this, &event);
-}
-
-void QWebPopup::showPopup()
-{
- QComboBox::showPopup();
- m_popupVisible = true;
-}
-
-void QWebPopup::hidePopup()
-{
- QWidget* activeFocus = QApplication::focusWidget();
- if (activeFocus && activeFocus == view()
- && activeFocus->testAttribute(Qt::WA_InputMethodEnabled)) {
- QInputContext* qic = activeFocus->inputContext();
- if (qic) {
- qic->reset();
- qic->setFocusWidget(0);
- }
- }
-
- QComboBox::hidePopup();
- if (!m_popupVisible)
- return;
-
- m_popupVisible = false;
- m_client->popupDidHide();
-}
-
-void QWebPopup::activeChanged(int index)
-{
- if (index < 0)
- return;
-
- m_client->valueChanged(index);
-}
-
-} // namespace WebCore
-
-#include "moc_QWebPopup.cpp"
diff --git a/WebCore/platform/qt/QtAbstractWebPopup.cpp b/WebCore/platform/qt/QtAbstractWebPopup.cpp
new file mode 100644
index 0000000..f64287d
--- /dev/null
+++ b/WebCore/platform/qt/QtAbstractWebPopup.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2009 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 "QtAbstractWebPopup.h"
+
+#include "PopupMenuClient.h"
+
+
+namespace WebCore {
+
+QtAbstractWebPopup::QtAbstractWebPopup()
+ : m_popupClient(0)
+ , m_pageClient(0)
+ , m_currentIndex(-1)
+{
+}
+
+QtAbstractWebPopup::~QtAbstractWebPopup()
+{
+}
+
+void QtAbstractWebPopup::popupDidHide()
+{
+ Q_ASSERT(m_popupClient);
+ m_popupClient->popupDidHide();
+}
+
+void QtAbstractWebPopup::valueChanged(int index)
+{
+ Q_ASSERT(m_popupClient);
+ m_popupClient->valueChanged(index);
+}
+
+QtAbstractWebPopup::ItemType QtAbstractWebPopup::itemType(int idx) const
+{
+ if (m_popupClient->itemIsSeparator(idx))
+ return Separator;
+ if (m_popupClient->itemIsLabel(idx))
+ return Group;
+ return Option;
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/qt/QtAbstractWebPopup.h b/WebCore/platform/qt/QtAbstractWebPopup.h
new file mode 100644
index 0000000..93b4122
--- /dev/null
+++ b/WebCore/platform/qt/QtAbstractWebPopup.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 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 QtAbstractWebPopup_h
+#define QtAbstractWebPopup_h
+
+#include "PopupMenuClient.h"
+
+#include <QFont>
+#include <QList>
+#include <QRect>
+#include <QWidget>
+
+class QWebPageClient;
+
+namespace WebCore {
+
+class QtAbstractWebPopup {
+public:
+ enum ItemType { Option, Group, Separator };
+
+ ItemType itemType(int) const;
+ QString itemText(int idx) const { return m_popupClient->itemText(idx); }
+ QString itemToolTip(int idx) const { return m_popupClient->itemToolTip(idx); }
+ bool itemIsEnabled(int idx) const { return m_popupClient->itemIsEnabled(idx); }
+ int itemCount() const { return m_popupClient->listSize(); }
+
+ QWebPageClient* pageClient() const { return m_pageClient; }
+ QRect geometry() const { return m_geometry; }
+ int currentIndex() const { return m_currentIndex; }
+
+ QtAbstractWebPopup();
+ virtual ~QtAbstractWebPopup();
+
+ virtual void show() = 0;
+ virtual void hide() = 0;
+
+ void popupDidHide();
+ void valueChanged(int index);
+
+ QFont font() { return m_popupClient->menuStyle().font().font(); }
+
+private:
+ friend class PopupMenu;
+ PopupMenuClient* m_popupClient;
+ QWebPageClient* m_pageClient;
+ int m_currentIndex;
+ QRect m_geometry;
+};
+
+}
+
+#endif // QtAbstractWebPopup_h
diff --git a/WebCore/platform/qt/RenderThemeQt.cpp b/WebCore/platform/qt/RenderThemeQt.cpp
index 501a28b..83e3746 100644
--- a/WebCore/platform/qt/RenderThemeQt.cpp
+++ b/WebCore/platform/qt/RenderThemeQt.cpp
@@ -32,6 +32,7 @@
#include "CSSStyleSelector.h"
#include "CSSStyleSheet.h"
+#include "Chrome.h"
#include "ChromeClientQt.h"
#include "Color.h"
#include "Document.h"
@@ -42,10 +43,12 @@
#include "HTMLNames.h"
#include "NotImplemented.h"
#include "Page.h"
+#include "QWebPageClient.h"
#include "RenderBox.h"
+#include "RenderSlider.h"
#include "RenderTheme.h"
+#include "ScrollbarThemeQt.h"
#include "UserAgentStyleSheets.h"
-#include "QWebPageClient.h"
#include "qwebpage.h"
#include <QApplication>
@@ -58,6 +61,7 @@
#include <QStyleFactory>
#include <QStyleOptionButton>
#include <QStyleOptionFrameV2>
+#include <QStyleOptionSlider>
#include <QWidget>
@@ -66,17 +70,17 @@ namespace WebCore {
using namespace HTMLNames;
-StylePainter::StylePainter(const RenderObject::PaintInfo& paintInfo)
+StylePainter::StylePainter(RenderThemeQt* theme, const RenderObject::PaintInfo& paintInfo)
{
- init(paintInfo.context ? paintInfo.context : 0);
+ init(paintInfo.context ? paintInfo.context : 0, theme->qStyle());
}
-StylePainter::StylePainter(GraphicsContext* context)
+StylePainter::StylePainter(ScrollbarThemeQt* theme, GraphicsContext* context)
{
- init(context);
+ init(context, theme->style());
}
-void StylePainter::init(GraphicsContext* context)
+void StylePainter::init(GraphicsContext* context, QStyle* themeStyle)
{
painter = static_cast<QPainter*>(context->platformContext());
widget = 0;
@@ -85,7 +89,7 @@ void StylePainter::init(GraphicsContext* context)
dev = painter->device();
if (dev && dev->devType() == QInternal::Widget)
widget = static_cast<QWidget*>(dev);
- style = (widget ? widget->style() : QApplication::style());
+ style = themeStyle;
if (painter) {
// the styles often assume being called with a pristine painter where no brush is set,
@@ -157,13 +161,10 @@ QStyle* RenderThemeQt::fallbackStyle()
QStyle* RenderThemeQt::qStyle() const
{
if (m_page) {
- ChromeClientQt* client = static_cast<ChromeClientQt*>(m_page->chrome()->client());
-
- if (!client->m_webPage)
- return QApplication::style();
+ QWebPageClient* pageClient = m_page->chrome()->client()->platformPageClient();
- if (QWidget* view = client->m_webPage->view())
- return view->style();
+ if (pageClient)
+ return pageClient->style();
}
return QApplication::style();
@@ -394,8 +395,13 @@ void RenderThemeQt::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* s
// Ditch the border.
style->resetBorder();
- // Height is locked to auto.
- style->setHeight(Length(Auto));
+#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
// White-space is locked to pre
style->setWhiteSpace(PRE);
@@ -465,7 +471,7 @@ void RenderThemeQt::setButtonPadding(RenderStyle* style) const
bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
- StylePainter p(i);
+ StylePainter p(this, i);
if (!p.isValid())
return true;
@@ -476,7 +482,7 @@ bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo&
option.rect = r;
option.state |= QStyle::State_Small;
- ControlPart appearance = applyTheme(option, o);
+ ControlPart appearance = initializeCommonQStyleOptions(option, o);
if (appearance == PushButtonPart || appearance == ButtonPart) {
option.rect = inflateButtonRect(option.rect, qStyle());
p.drawControl(QStyle::CE_PushButton, option);
@@ -498,7 +504,7 @@ void RenderThemeQt::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style,
bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
- StylePainter p(i);
+ StylePainter p(this, i);
if (!p.isValid())
return true;
@@ -512,7 +518,7 @@ bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInf
panel.features = QStyleOptionFrameV2::None;
// Get the correct theme data for a text field
- ControlPart appearance = applyTheme(panel, o);
+ ControlPart appearance = initializeCommonQStyleOptions(panel, o);
if (appearance != TextFieldPart
&& appearance != SearchFieldPart
&& appearance != TextAreaPart
@@ -567,14 +573,14 @@ void RenderThemeQt::setPopupPadding(RenderStyle* style) const
bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
- StylePainter p(i);
+ StylePainter p(this, i);
if (!p.isValid())
return true;
QStyleOptionComboBox opt;
if (p.widget)
opt.initFrom(p.widget);
- applyTheme(opt, o);
+ initializeCommonQStyleOptions(opt, o);
const QPoint topLeft = r.topLeft();
p.painter->translate(topLeft);
@@ -607,14 +613,14 @@ void RenderThemeQt::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle* st
bool RenderThemeQt::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i,
const IntRect& r)
{
- StylePainter p(i);
+ StylePainter p(this, i);
if (!p.isValid())
return true;
QStyleOptionComboBox option;
if (p.widget)
option.initFrom(p.widget);
- applyTheme(option, o);
+ initializeCommonQStyleOptions(option, o);
option.rect = r;
// for drawing the combo box arrow, rely only on the fallback style
@@ -628,22 +634,73 @@ bool RenderThemeQt::paintMenuListButton(RenderObject* o, const RenderObject::Pai
bool RenderThemeQt::paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& pi,
const IntRect& r)
{
- notImplemented();
- return RenderTheme::paintSliderTrack(o, pi, r);
+ StylePainter p(this, pi);
+ if (!p.isValid())
+ return true;
+
+ QStyleOptionSlider option;
+ if (p.widget)
+ option.initFrom(p.widget);
+ ControlPart appearance = initializeCommonQStyleOptions(option, o);
+
+ RenderSlider* renderSlider = toRenderSlider(o);
+ IntRect thumbRect = renderSlider->thumbRect();
+
+ option.rect = r;
+
+ int value;
+ if (appearance == SliderVerticalPart) {
+ option.maximum = r.height() - thumbRect.height();
+ value = thumbRect.y();
+ } else {
+ option.maximum = r.width() - thumbRect.width();
+ value = thumbRect.x();
+ }
+
+ value = QStyle::sliderValueFromPosition(0, option.maximum, value, option.maximum);
+
+ option.sliderValue = value;
+ option.sliderPosition = value;
+ if (appearance == SliderVerticalPart)
+ option.orientation = Qt::Vertical;
+
+ if (renderSlider->inDragMode()) {
+ option.activeSubControls = QStyle::SC_SliderHandle;
+ option.state |= QStyle::State_Sunken;
+ }
+
+ const QPoint topLeft = r.topLeft();
+ p.painter->translate(topLeft);
+ option.rect.moveTo(QPoint(0, 0));
+ option.rect.setSize(r.size());
+
+ p.drawComplexControl(QStyle::CC_Slider, option);
+ p.painter->translate(-topLeft);
+
+ return false;
+}
+
+void RenderThemeQt::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
+{
+ style->setBoxShadow(0);
}
bool RenderThemeQt::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& pi,
const IntRect& r)
{
- notImplemented();
- return RenderTheme::paintSliderThumb(o, pi, r);
+ // We've already painted it in paintSliderTrack(), no need to do anything here.
+ return false;
+}
+
+void RenderThemeQt::adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
+{
+ style->setBoxShadow(0);
}
bool RenderThemeQt::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& pi,
const IntRect& r)
{
- paintTextField(o, pi, r);
- return false;
+ return true;
}
void RenderThemeQt::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style,
@@ -706,13 +763,32 @@ bool RenderThemeQt::supportsFocus(ControlPart appearance) const
case MenulistPart:
case RadioPart:
case CheckboxPart:
+ case SliderHorizontalPart:
+ case SliderVerticalPart:
return true;
default: // No for all others...
return false;
}
}
-ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const
+void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const
+{
+ // If the webview has a custom palette, use it
+ if (!m_page)
+ return;
+ Chrome* chrome = m_page->chrome();
+ if (!chrome)
+ return;
+ ChromeClient* chromeClient = chrome->client();
+ if (!chromeClient)
+ return;
+ QWebPageClient* pageClient = chromeClient->platformPageClient();
+ if (!pageClient)
+ return;
+ palette = pageClient->palette();
+}
+
+ControlPart RenderThemeQt::initializeCommonQStyleOptions(QStyleOption& option, RenderObject* o) const
{
// Default bits: no focus, no mouse over
option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
@@ -724,19 +800,24 @@ ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) con
// Readonly is supported on textfields.
option.state |= QStyle::State_ReadOnly;
- if (supportsFocus(o->style()->appearance()) && isFocused(o)) {
- option.state |= QStyle::State_HasFocus;
- option.state |= QStyle::State_KeyboardFocusChange;
- }
+ option.direction = Qt::LeftToRight;
if (isHovered(o))
option.state |= QStyle::State_MouseOver;
- option.direction = Qt::LeftToRight;
- if (o->style() && o->style()->direction() == WebCore::RTL)
- option.direction = Qt::RightToLeft;
+ setPaletteFromPageClientIfExists(option.palette);
+ RenderStyle* style = o->style();
+ if (!style)
+ return NoControlPart;
- ControlPart result = o->style()->appearance();
+ ControlPart result = style->appearance();
+ if (supportsFocus(result) && isFocused(o)) {
+ option.state |= QStyle::State_HasFocus;
+ option.state |= QStyle::State_KeyboardFocusChange;
+ }
+
+ if (style->direction() == WebCore::RTL)
+ option.direction = Qt::RightToLeft;
switch (result) {
case PushButtonPart:
@@ -753,18 +834,9 @@ ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) con
option.state |= QStyle::State_Raised;
break;
}
- }
-
- if (result == RadioPart || result == CheckboxPart)
+ case RadioPart:
+ case CheckboxPart:
option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off);
-
- // If the owner widget has a custom palette, use it
- Page* page = o->document()->page();
- if (page) {
- ChromeClient* client = page->chrome()->client();
- QWebPageClient* pageClient = client->platformPageClient();
- if (pageClient)
- option.palette = pageClient->palette();
}
return result;
@@ -833,7 +905,7 @@ bool RenderThemeQt::paintMediaMuteButton(RenderObject* o, const RenderObject::Pa
if (!mediaElement)
return false;
- StylePainter p(paintInfo);
+ StylePainter p(this, paintInfo);
if (!p.isValid())
return true;
@@ -862,7 +934,7 @@ bool RenderThemeQt::paintMediaPlayButton(RenderObject* o, const RenderObject::Pa
if (!mediaElement)
return false;
- StylePainter p(paintInfo);
+ StylePainter p(this, paintInfo);
if (!p.isValid())
return true;
@@ -901,7 +973,7 @@ bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const RenderObject::P
if (!mediaElement)
return false;
- StylePainter p(paintInfo);
+ StylePainter p(this, paintInfo);
if (!p.isValid())
return true;
@@ -909,16 +981,6 @@ bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const RenderObject::P
paintMediaBackground(p.painter, r);
- if (MediaPlayer* player = mediaElement->player()) {
- if (player->totalBytesKnown()) {
- float percentLoaded = static_cast<float>(player->bytesLoaded()) / player->totalBytes();
-
- WorldMatrixTransformer transformer(p.painter, o, r);
- p.painter->setBrush(getMediaControlForegroundColor());
- p.painter->drawRect(0, 37, 100 * percentLoaded, 26);
- }
- }
-
return false;
}
@@ -928,7 +990,7 @@ bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const RenderObject::P
if (!mediaElement)
return false;
- StylePainter p(paintInfo);
+ StylePainter p(this, paintInfo);
if (!p.isValid())
return true;
@@ -944,13 +1006,26 @@ bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const RenderObject::P
void RenderThemeQt::adjustSliderThumbSize(RenderObject* o) const
{
- if (o->style()->appearance() == MediaSliderThumbPart) {
+ ControlPart part = o->style()->appearance();
+
+ if (part == MediaSliderThumbPart) {
RenderStyle* parentStyle = o->parent()->style();
Q_ASSERT(parentStyle);
int parentHeight = parentStyle->height().value();
o->style()->setWidth(Length(parentHeight / 3, Fixed));
o->style()->setHeight(Length(parentHeight, Fixed));
+ } else if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) {
+ QStyleOptionSlider option;
+ if (part == SliderThumbVerticalPart)
+ option.orientation = Qt::Vertical;
+
+ QStyle* style = qStyle();
+
+ int width = style->pixelMetric(QStyle::PM_SliderLength, &option);
+ int height = style->pixelMetric(QStyle::PM_SliderThickness, &option);
+ o->style()->setWidth(Length(width, Fixed));
+ o->style()->setHeight(Length(height, Fixed));
}
}
diff --git a/WebCore/platform/qt/RenderThemeQt.h b/WebCore/platform/qt/RenderThemeQt.h
index 617c875..e6bab7e 100644
--- a/WebCore/platform/qt/RenderThemeQt.h
+++ b/WebCore/platform/qt/RenderThemeQt.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*
*/
-#ifndef RenderThemeQt_H
-#define RenderThemeQt_H
+#ifndef RenderThemeQt_h
+#define RenderThemeQt_h
#include "RenderTheme.h"
@@ -35,6 +35,7 @@ namespace WebCore {
class RenderStyle;
class HTMLMediaElement;
+class ScrollbarThemeQt;
class RenderThemeQt : public RenderTheme {
private:
@@ -75,6 +76,8 @@ public:
virtual String extraMediaControlsStyleSheet();
#endif
+ QStyle* qStyle() const;
+
protected:
virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
virtual void setCheckboxSize(RenderStyle*) const;
@@ -99,7 +102,10 @@ protected:
virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+ virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
+
virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+ virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
@@ -132,12 +138,13 @@ private:
private:
bool supportsFocus(ControlPart) const;
- ControlPart applyTheme(QStyleOption&, RenderObject*) const;
+ ControlPart initializeCommonQStyleOptions(QStyleOption&, RenderObject*) const;
void setButtonPadding(RenderStyle*) const;
void setPopupPadding(RenderStyle*) const;
- QStyle* qStyle() const;
+ void setPaletteFromPageClientIfExists(QPalette&) const;
+
QStyle* fallbackStyle();
Page* m_page;
@@ -152,8 +159,8 @@ private:
class StylePainter {
public:
- explicit StylePainter(const RenderObject::PaintInfo& paintInfo);
- explicit StylePainter(GraphicsContext* context);
+ explicit StylePainter(RenderThemeQt*, const RenderObject::PaintInfo&);
+ explicit StylePainter(ScrollbarThemeQt*, GraphicsContext*);
~StylePainter();
bool isValid() const { return painter && style; }
@@ -170,7 +177,7 @@ public:
{ style->drawComplexControl(cc, &opt, painter, widget); }
private:
- void init(GraphicsContext* context);
+ void init(GraphicsContext* context, QStyle*);
QBrush oldBrush;
bool oldAntialiasing;
@@ -180,4 +187,4 @@ private:
}
-#endif
+#endif // RenderThemeQt_h
diff --git a/WebCore/platform/qt/ScrollViewQt.cpp b/WebCore/platform/qt/ScrollViewQt.cpp
index ccbd751..17ad253 100644
--- a/WebCore/platform/qt/ScrollViewQt.cpp
+++ b/WebCore/platform/qt/ScrollViewQt.cpp
@@ -36,32 +36,19 @@ namespace WebCore {
void ScrollView::platformInit()
{
- m_widgetsPreventingBlitting = 0;
}
void ScrollView::platformDestroy()
{
}
-// Windowed plugins are using native windows and are thus preventing
-// us from doing any kind of scrolling optimization.
-
-void ScrollView::adjustWidgetsPreventingBlittingCount(int delta)
-{
- m_widgetsPreventingBlitting += delta;
- if (parent())
- parent()->adjustWidgetsPreventingBlittingCount(delta);
-}
-
void ScrollView::platformAddChild(Widget*)
{
- adjustWidgetsPreventingBlittingCount(1);
}
void ScrollView::platformRemoveChild(Widget* child)
{
child->hide();
- adjustWidgetsPreventingBlittingCount(-1);
}
}
diff --git a/WebCore/platform/qt/ScrollbarThemeQt.cpp b/WebCore/platform/qt/ScrollbarThemeQt.cpp
index 561e55f..c0c80ba 100644
--- a/WebCore/platform/qt/ScrollbarThemeQt.cpp
+++ b/WebCore/platform/qt/ScrollbarThemeQt.cpp
@@ -140,14 +140,14 @@ bool ScrollbarThemeQt::paint(Scrollbar* scrollbar, GraphicsContext* graphicsCont
return false;
}
- StylePainter p(graphicsContext);
+ StylePainter p(this, graphicsContext);
if (!p.isValid())
return true;
p.painter->save();
QStyleOptionSlider* opt = styleOptionSlider(scrollbar, p.widget);
- p.painter->setClipRect(opt->rect.intersected(damageRect));
+ p.painter->setClipRect(opt->rect.intersected(damageRect), Qt::IntersectClip);
#ifdef Q_WS_MAC
p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
@@ -172,14 +172,14 @@ ScrollbarPart ScrollbarThemeQt::hitTest(Scrollbar* scrollbar, const PlatformMous
QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
const QPoint pos = scrollbar->convertFromContainingWindow(evt.pos());
opt->rect.moveTo(QPoint(0, 0));
- QStyle::SubControl sc = QApplication::style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0);
+ QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0);
return scrollbarPart(sc);
}
bool ScrollbarThemeQt::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
{
// Middle click centers slider thumb (if supported)
- return QApplication::style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton;
+ return style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton;
}
void ScrollbarThemeQt::invalidatePart(Scrollbar* scrollbar, ScrollbarPart)
@@ -190,13 +190,12 @@ void ScrollbarThemeQt::invalidatePart(Scrollbar* scrollbar, ScrollbarPart)
int ScrollbarThemeQt::scrollbarThickness(ScrollbarControlSize controlSize)
{
- QStyle* s = QApplication::style();
QStyleOptionSlider o;
o.orientation = Qt::Vertical;
o.state &= ~QStyle::State_Horizontal;
if (controlSize != RegularScrollbar)
o.state |= QStyle::State_Mini;
- return s->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
+ return style()->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
}
int ScrollbarThemeQt::thumbPosition(Scrollbar* scrollbar)
@@ -209,21 +208,21 @@ int ScrollbarThemeQt::thumbPosition(Scrollbar* scrollbar)
int ScrollbarThemeQt::thumbLength(Scrollbar* scrollbar)
{
QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
- IntRect thumb = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0);
+ IntRect thumb = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0);
return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height();
}
int ScrollbarThemeQt::trackPosition(Scrollbar* scrollbar)
{
QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
- IntRect track = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
+ IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y();
}
int ScrollbarThemeQt::trackLength(Scrollbar* scrollbar)
{
QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
- IntRect track = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
+ IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height();
}
@@ -235,9 +234,9 @@ void ScrollbarThemeQt::paintScrollCorner(ScrollView* scrollView, GraphicsContext
}
#if QT_VERSION < 0x040500
- context->fillRect(rect, QApplication::palette().color(QPalette::Normal, QPalette::Window));
+ context->fillRect(rect, QApplication::palette().color(QPalette::Normal, QPalette::Window), DeviceColorSpace);
#else
- StylePainter p(context);
+ StylePainter p(this, context);
if (!p.isValid())
return;
@@ -247,5 +246,10 @@ void ScrollbarThemeQt::paintScrollCorner(ScrollView* scrollView, GraphicsContext
#endif
}
+QStyle* ScrollbarThemeQt::style() const
+{
+ return QApplication::style();
+}
+
}
diff --git a/WebCore/platform/qt/ScrollbarThemeQt.h b/WebCore/platform/qt/ScrollbarThemeQt.h
index 6ca44ea..cf4882d 100644
--- a/WebCore/platform/qt/ScrollbarThemeQt.h
+++ b/WebCore/platform/qt/ScrollbarThemeQt.h
@@ -28,6 +28,12 @@
#include "ScrollbarTheme.h"
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+class QStyle;
+QT_END_NAMESPACE
+
namespace WebCore {
class ScrollbarThemeQt : public ScrollbarTheme {
@@ -49,6 +55,8 @@ public:
virtual int trackLength(Scrollbar*);
virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
+
+ QStyle* style() const;
};
}
diff --git a/WebCore/platform/qt/SharedBufferQt.cpp b/WebCore/platform/qt/SharedBufferQt.cpp
index 8d62226..029d9d6 100644
--- a/WebCore/platform/qt/SharedBufferQt.cpp
+++ b/WebCore/platform/qt/SharedBufferQt.cpp
@@ -45,6 +45,8 @@ PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& fi
if (result->m_buffer.size() != file.size())
return 0;
+ result->m_size = result->m_buffer.size();
+
file.read(result->m_buffer.data(), result->m_buffer.size());
return result.release();
}