summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/qt
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/qt')
-rw-r--r--WebCore/platform/graphics/qt/FontCacheQt.cpp22
-rw-r--r--WebCore/platform/graphics/qt/FontCustomPlatformData.cpp19
-rw-r--r--WebCore/platform/graphics/qt/FontCustomPlatformData.h3
-rw-r--r--WebCore/platform/graphics/qt/FontFallbackListQt.cpp106
-rw-r--r--WebCore/platform/graphics/qt/FontPlatformData.h22
-rw-r--r--WebCore/platform/graphics/qt/FontPlatformDataQt.cpp78
-rw-r--r--WebCore/platform/graphics/qt/FontQt.cpp550
-rw-r--r--WebCore/platform/graphics/qt/FontQt43.cpp356
-rw-r--r--WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp7
-rw-r--r--WebCore/platform/graphics/qt/GradientQt.cpp2
-rw-r--r--WebCore/platform/graphics/qt/GraphicsContextQt.cpp106
-rw-r--r--WebCore/platform/graphics/qt/ImageDecoderQt.cpp30
-rw-r--r--WebCore/platform/graphics/qt/ImageDecoderQt.h19
-rw-r--r--WebCore/platform/graphics/qt/ImageQt.cpp16
-rw-r--r--WebCore/platform/graphics/qt/ImageSourceQt.cpp45
-rw-r--r--WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp62
-rw-r--r--WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h11
-rw-r--r--WebCore/platform/graphics/qt/PathQt.cpp54
-rw-r--r--WebCore/platform/graphics/qt/PatternQt.cpp4
-rw-r--r--WebCore/platform/graphics/qt/SimpleFontDataQt.cpp35
-rw-r--r--WebCore/platform/graphics/qt/StillImageQt.h2
-rw-r--r--WebCore/platform/graphics/qt/TransformationMatrixQt.cpp (renamed from WebCore/platform/graphics/qt/AffineTransformQt.cpp)66
22 files changed, 879 insertions, 736 deletions
diff --git a/WebCore/platform/graphics/qt/FontCacheQt.cpp b/WebCore/platform/graphics/qt/FontCacheQt.cpp
index be31d96..114f073 100644
--- a/WebCore/platform/graphics/qt/FontCacheQt.cpp
+++ b/WebCore/platform/graphics/qt/FontCacheQt.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008 Holger Hans Peter Freyther
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -21,18 +22,31 @@
*/
#include "config.h"
#include "FontCache.h"
+
#include "FontDescription.h"
+#include "FontPlatformData.h"
#include "Font.h"
+#include <wtf/StdLibExtras.h>
namespace WebCore {
+FontCache* fontCache()
+{
+ DEFINE_STATIC_LOCAL(FontCache, globalFontCache, ());
+ return &globalFontCache;
+}
+
+FontCache::FontCache()
+{
+}
+
void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
{
}
-FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName)
+FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& description, const AtomicString& family, bool checkingAlternateName)
{
- return 0;
+ return new FontPlatformData(description);
}
SimpleFontData* FontCache::getCachedFontData(const FontPlatformData*)
@@ -45,6 +59,10 @@ FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription&)
return 0;
}
+void FontCache::releaseFontData(const WebCore::SimpleFontData*)
+{
+}
+
void FontCache::addClient(FontSelector*)
{
}
diff --git a/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp b/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp
index 8fc3ea0..a19464e 100644
--- a/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp
@@ -25,19 +25,25 @@
#include "FontPlatformData.h"
#include "SharedBuffer.h"
#include <QFontDatabase>
+#include <QStringList>
namespace WebCore {
FontCustomPlatformData::~FontCustomPlatformData()
{
- QFontDatabase::removeApplicationFont(handle);
+ QFontDatabase::removeApplicationFont(m_handle);
}
FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontRenderingMode)
{
- FontPlatformData result;
- result.handle = handle;
- return result;
+ QFont font;
+ font.setFamily(QFontDatabase::applicationFontFamilies(m_handle)[0]);
+ font.setPixelSize(size);
+ if (bold)
+ font.setWeight(QFont::Bold);
+ font.setItalic(italic);
+
+ return FontPlatformData(font, bold);
}
FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
@@ -47,8 +53,11 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
int id = QFontDatabase::addApplicationFontFromData(QByteArray(buffer->data(), buffer->size()));
if (id == -1)
return 0;
+
+ Q_ASSERT(QFontDatabase::applicationFontFamilies(id).size() > 0);
+
FontCustomPlatformData *data = new FontCustomPlatformData;
- data->handle = id;
+ data->m_handle = id;
return data;
}
diff --git a/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/WebCore/platform/graphics/qt/FontCustomPlatformData.h
index da5159d..4305b87 100644
--- a/WebCore/platform/graphics/qt/FontCustomPlatformData.h
+++ b/WebCore/platform/graphics/qt/FontCustomPlatformData.h
@@ -33,7 +33,8 @@ class FontPlatformData;
struct FontCustomPlatformData : Noncopyable {
~FontCustomPlatformData();
- int handle; // for use with QFontDatabase::addApplicationFont/removeApplicationFont
+ // for use with QFontDatabase::addApplicationFont/removeApplicationFont
+ int m_handle;
FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
};
diff --git a/WebCore/platform/graphics/qt/FontFallbackListQt.cpp b/WebCore/platform/graphics/qt/FontFallbackListQt.cpp
new file mode 100644
index 0000000..22ae205
--- /dev/null
+++ b/WebCore/platform/graphics/qt/FontFallbackListQt.cpp
@@ -0,0 +1,106 @@
+/*
+ Copyright (C) 2008 Holger Hans Peter Freyther
+
+ 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.
+
+ Replacement of the stock FontFallbackList as Qt is going to find us a
+ replacement font, will do caching and the other stuff we implement in
+ WebKit.
+*/
+
+#include "config.h"
+#include "FontFallbackList.h"
+
+#include "Font.h"
+#include "SegmentedFontData.h"
+
+#include <QDebug>
+
+namespace WebCore {
+
+FontFallbackList::FontFallbackList()
+ : m_familyIndex(0)
+ , m_pitch(UnknownPitch)
+ , m_loadingCustomFonts(false)
+ , m_fontSelector(0)
+ , m_generation(0)
+{
+}
+
+void FontFallbackList::invalidate(WTF::PassRefPtr<WebCore::FontSelector> fontSelector)
+{
+ releaseFontData();
+ m_fontList.clear();
+ m_familyIndex = 0;
+ m_pitch = UnknownPitch;
+ m_loadingCustomFonts = false;
+ m_fontSelector = fontSelector;
+ m_generation = 0;
+}
+
+void FontFallbackList::releaseFontData()
+{
+}
+
+void FontFallbackList::determinePitch(const WebCore::Font* font) const
+{
+ const FontData* fontData = primaryFont(font);
+ if (!fontData->isSegmented())
+ m_pitch = static_cast<const SimpleFontData*>(fontData)->pitch();
+ else {
+ const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
+ unsigned numRanges = segmentedFontData->numRanges();
+ if (numRanges == 1)
+ m_pitch = segmentedFontData->rangeAt(0).fontData()->pitch();
+ else
+ m_pitch = VariablePitch;
+ }
+}
+
+const FontData* FontFallbackList::fontDataAt(const WebCore::Font* _font, unsigned index) const
+{
+ if (index != 0)
+ return 0;
+
+ // Use the FontSelector to get a WebCore font and then fallback to Qt
+ const FontDescription& description = _font->fontDescription();
+ const FontFamily* family = &description.family();
+ while (family) {
+ if (m_fontSelector) {
+ FontData* data = m_fontSelector->getFontData(description, family->family());
+ if (data) {
+ if (data->isLoading())
+ m_loadingCustomFonts = true;
+ return data;
+ }
+ }
+ family = family->next();
+ }
+
+ return new SimpleFontData(FontPlatformData(description), _font->wordSpacing(), _font->letterSpacing());
+}
+
+const FontData* FontFallbackList::fontDataForCharacters(const WebCore::Font* font, const UChar*, int) const
+{
+ return primaryFont(font);
+}
+
+void FontFallbackList::setPlatformFont(const WebCore::FontPlatformData& platformData)
+{
+ m_familyIndex = cAllFamiliesScanned;
+}
+
+}
diff --git a/WebCore/platform/graphics/qt/FontPlatformData.h b/WebCore/platform/graphics/qt/FontPlatformData.h
index e4363be..5e97678 100644
--- a/WebCore/platform/graphics/qt/FontPlatformData.h
+++ b/WebCore/platform/graphics/qt/FontPlatformData.h
@@ -1,5 +1,6 @@
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008 Holger Hans Peter Freyther
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -22,14 +23,29 @@
#ifndef FontPlatformData_h
#define FontPlatformData_h
+#include "FontDescription.h"
+
+#include <QFont>
+
namespace WebCore {
class FontPlatformData
{
public:
- // this is only used for custom loaded fonts and represents the id handle passed to
- // QFontDatabase::addApplicationFont/removeApplicationFont
- int handle;
+#if ENABLE(SVG_FONTS)
+ FontPlatformData(float size, bool bold, bool oblique);
+#endif
+ FontPlatformData();
+ FontPlatformData(const FontDescription&, int wordSpacing = 0, int letterSpacing = 0);
+ FontPlatformData(const QFont&, bool bold);
+
+ QFont font() const { return m_font; }
+ float size() const { return m_size; }
+
+ float m_size;
+ bool m_bold;
+ bool m_oblique;
+ QFont m_font;
};
} // namespace WebCore
diff --git a/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
new file mode 100644
index 0000000..ea51fe8
--- /dev/null
+++ b/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 2008 Holger Hans Peter Freyther
+
+ 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 "FontPlatformData.h"
+
+namespace WebCore {
+
+FontPlatformData::FontPlatformData(const FontDescription& description, int wordSpacing, int letterSpacing)
+ : m_size(0.0f)
+ , m_bold(false)
+ , m_oblique(false)
+{
+ QString familyName;
+ const FontFamily* family = &description.family();
+ while (family) {
+ familyName += family->family();
+ family = family->next();
+ if (family)
+ familyName += QLatin1Char(',');
+ }
+
+ m_font.setFamily(familyName);
+ m_font.setPixelSize(qRound(description.computedSize()));
+ m_font.setItalic(description.italic());
+ // FIXME: Map all FontWeight values to QFont weights.
+ if (description.weight() >= FontWeight600)
+ m_font.setWeight(QFont::Bold);
+ else
+ m_font.setWeight(QFont::Normal);
+
+ bool smallCaps = description.smallCaps();
+ m_font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
+ m_font.setWordSpacing(wordSpacing);
+ m_font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
+ m_size = m_font.pointSize();
+}
+
+FontPlatformData::FontPlatformData(const QFont& font, bool bold)
+ : m_size(font.pointSize())
+ , m_bold(bold)
+ , m_oblique(false)
+ , m_font(font)
+{
+}
+
+FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
+ : m_size(size)
+ , m_bold(bold)
+ , m_oblique(oblique)
+{
+}
+
+FontPlatformData::FontPlatformData()
+ : m_size(0.0f)
+ , m_bold(false)
+ , m_oblique(false)
+{
+}
+
+}
diff --git a/WebCore/platform/graphics/qt/FontQt.cpp b/WebCore/platform/graphics/qt/FontQt.cpp
index e2ef605..deeea99 100644
--- a/WebCore/platform/graphics/qt/FontQt.cpp
+++ b/WebCore/platform/graphics/qt/FontQt.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008 Holger Hans Peter Freyther
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -20,6 +21,7 @@
#include "config.h"
#include "Font.h"
#include "FontDescription.h"
+#include "FontFallbackList.h"
#include "FontSelector.h"
#include "GraphicsContext.h"
@@ -31,66 +33,9 @@
#include <qdebug.h>
#include <limits.h>
-namespace WebCore {
#if QT_VERSION >= 0x040400
-
-Font::Font()
- : m_letterSpacing(0)
- , m_wordSpacing(0)
- , m_font()
- , m_scFont()
-{
- QFontMetrics metrics(m_font);
- m_spaceWidth = metrics.width(QLatin1Char(' '));
-}
-
-Font::Font(const FontDescription& description, short letterSpacing, short wordSpacing)
- : m_fontDescription(description)
- , m_letterSpacing(letterSpacing)
- , m_wordSpacing(wordSpacing)
-{
- const FontFamily* family = &description.family();
- QString familyName;
- while (family) {
- familyName += family->family();
- family = family->next();
- if (family)
- familyName += QLatin1Char(',');
- }
-
- m_font.setFamily(familyName);
- m_font.setPixelSize(qRound(description.computedSize()));
- m_font.setItalic(description.italic());
- // FIXME: Map all FontWeight values to QFont weights.
- if (description.weight() >= FontWeight600)
- m_font.setWeight(QFont::Bold);
- else
- m_font.setWeight(QFont::Normal);
-
- bool smallCaps = description.smallCaps();
- m_font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
-
- QFontMetrics metrics = QFontMetrics(m_font);
- m_spaceWidth = metrics.width(QLatin1Char(' '));
-
- if (wordSpacing)
- m_font.setWordSpacing(wordSpacing);
- if (letterSpacing)
- m_font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
-}
-
-void Font::setWordSpacing(short s)
-{
- m_font.setWordSpacing(s);
- m_wordSpacing = s;
-}
-void Font::setLetterSpacing(short s)
-{
- m_font.setLetterSpacing(QFont::AbsoluteSpacing, s);
- m_letterSpacing = s;
-}
-
+namespace WebCore {
static QString qstring(const TextRun& run)
{
@@ -121,10 +66,11 @@ static QTextLine setupLayout(QTextLayout* layout, const TextRun& style)
return line;
}
-void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
+void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
{
if (to < 0)
to = run.length();
+
QPainter *p = ctx->platformContext();
Color color = ctx->fillColor();
p->setPen(QColor(color));
@@ -138,14 +84,14 @@ void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint&
bool hasShadow = ctx->textDrawingMode() == cTextFill && ctx->getShadow(shadowSize, shadowBlur, shadowColor);
if (from > 0 || to < run.length()) {
- QTextLayout layout(string, m_font);
+ QTextLayout layout(string, font());
QTextLine line = setupLayout(&layout, run);
float x1 = line.cursorToX(from);
float x2 = line.cursorToX(to);
if (x2 < x1)
qSwap(x1, x2);
- QFontMetrics fm(m_font);
+ QFontMetrics fm(font());
int ascent = fm.ascent();
QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height());
@@ -179,7 +125,7 @@ void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint&
return;
}
- p->setFont(m_font);
+ p->setFont(font());
QPointF pt(point.x(), point.y());
int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
@@ -194,12 +140,12 @@ void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint&
p->drawText(pt, string, flags, run.padding());
}
-int Font::width(const TextRun& run) const
+float Font::floatWidthForComplexText(const TextRun& run) const
{
if (!run.length())
return 0;
QString string = qstring(run);
- QTextLayout layout(string, m_font);
+ QTextLayout layout(string, font());
QTextLine line = setupLayout(&layout, run);
int w = int(line.naturalTextWidth());
// WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does)
@@ -209,30 +155,18 @@ int Font::width(const TextRun& run) const
return w + run.padding();
}
-float Font::floatWidth(const TextRun& run) const
-{
- return width(run);
-}
-
-float Font::floatWidth(const TextRun& run, int /*extraCharsAvailable*/, int& charsConsumed, String& glyphName) const
-{
- charsConsumed = run.length();
- glyphName = "";
- return width(run);
-}
-
-int Font::offsetForPosition(const TextRun& run, int position, bool /*includePartialGlyphs*/) const
+int Font::offsetForPositionForComplexText(const TextRun& run, int position, bool includePartialGlyphs) const
{
QString string = qstring(run);
- QTextLayout layout(string, m_font);
+ QTextLayout layout(string, font());
QTextLine line = setupLayout(&layout, run);
return line.xToCursor(position);
}
-FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& pt, int h, int from, int to) const
+FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& pt, int h, int from, int to) const
{
QString string = qstring(run);
- QTextLayout layout(string, m_font);
+ QTextLayout layout(string, font());
QTextLine line = setupLayout(&layout, run);
float x1 = line.cursorToX(from);
@@ -243,464 +177,12 @@ FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& pt, int
return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h);
}
-#else
-
-
-struct TextRunComponent {
- TextRunComponent() : font(0) {}
- TextRunComponent(const UChar *start, int length, bool rtl, const QFont *font, int offset, bool sc = false);
- TextRunComponent(int spaces, bool rtl, const QFont *font, int offset);
-
- inline bool isSpace() const { return spaces != 0; }
-
- QString string;
- const QFont *font;
- int width;
- int offset;
- int spaces;
-};
-
-TextRunComponent::TextRunComponent(const UChar *start, int length, bool rtl, const QFont *f, int o, bool sc)
- : string(reinterpret_cast<const QChar*>(start), length)
- , font(f)
- , offset(o)
- , spaces(0)
-{
- if (sc)
- string = string.toUpper();
- string.prepend(rtl ? QChar(0x202e) : QChar(0x202d));
- width = QFontMetrics(*font).width(string);
-}
-
-TextRunComponent::TextRunComponent(int s, bool rtl, const QFont *f, int o)
- : string(s, QLatin1Char(' '))
- , font(f)
- , offset(o)
- , spaces(s)
-{
- string.prepend(rtl ? QChar(0x202e) : QChar(0x202d));
- width = spaces * QFontMetrics(*font).width(QLatin1Char(' '));
-}
-
-
-Font::Font()
- : m_letterSpacing(0)
- , m_wordSpacing(0)
- , m_font()
- , m_scFont()
-{
- QFontMetrics metrics(m_font);
- m_spaceWidth = metrics.width(QLatin1Char(' '));
- qreal pointsize = m_font.pointSizeF();
- if (pointsize > 0)
- m_scFont.setPointSizeF(pointsize*0.7);
- else
- m_scFont.setPixelSize(qRound(m_font.pixelSize()*.7));
-}
-
-Font::Font(const FontDescription& description, short letterSpacing, short wordSpacing)
- : m_fontDescription(description)
- , m_letterSpacing(letterSpacing)
- , m_wordSpacing(wordSpacing)
-{
- const FontFamily* family = &description.family();
- QString familyName;
- while (family) {
- familyName += family->family();
- family = family->next();
- if (family)
- familyName += QLatin1Char(',');
- }
-
- m_font.setFamily(familyName);
- m_font.setPixelSize(qRound(description.computedSize()));
- m_font.setItalic(description.italic());
- // FIXME: Map all FontWeight values to QFont weights.
- if (description.weight() >= FontWeight600)
- m_font.setWeight(QFont::Bold);
- else
- m_font.setWeight(QFont::Normal);
-
- QFontMetrics metrics = QFontMetrics(m_font);
- m_spaceWidth = metrics.width(QLatin1Char(' '));
- m_scFont = m_font;
- m_scFont.setPixelSize(qRound(description.computedSize()*.7));
-}
-
-void Font::setWordSpacing(short s)
-{
- m_wordSpacing = s;
-}
-void Font::setLetterSpacing(short s)
-{
- m_letterSpacing = s;
-}
-
-static int generateComponents(Vector<TextRunComponent, 1024>* components, const Font &font, const TextRun &run)
-{
-// qDebug() << "generateComponents" << QString((const QChar *)run.characters(), run.length());
- int letterSpacing = font.letterSpacing();
- int wordSpacing = font.wordSpacing();
- bool smallCaps = font.fontDescription().smallCaps();
- int padding = run.padding();
- int numSpaces = 0;
- if (padding) {
- for (int i = 0; i < run.length(); i++)
- if (Font::treatAsSpace(run[i]))
- ++numSpaces;
- }
-
- int offset = 0;
- const QFont *f = &font.font();
- if (letterSpacing || smallCaps) {
- // need to draw every letter on it's own
- int start = 0;
- if (Font::treatAsSpace(run[0])) {
- int add = 0;
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
- offset += add + letterSpacing + components->last().width;
- start = 1;
-// qDebug() << "space at 0" << offset;
- } else if (smallCaps) {
- f = (QChar::category(run[0]) == QChar::Letter_Lowercase ? &font.scFont() : &font.font());
- }
- for (int i = 1; i < run.length(); ++i) {
- uint ch = run[i];
- if (QChar(ch).isHighSurrogate() && QChar(run[i-1]).isLowSurrogate())
- ch = QChar::surrogateToUcs4(ch, run[i-1]);
- if (QChar(ch).isLowSurrogate() || QChar::category(ch) == QChar::Mark_NonSpacing)
- continue;
- if (Font::treatAsSpace(run[i])) {
- int add = 0;
-// qDebug() << " treatAsSpace:" << i << start;
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run.rtl(),
- f, offset, f == &font.scFont()));
- offset += components->last().width + letterSpacing;
-// qDebug() << " appending(1) " << components->last().string << components->last().width;
- }
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
- offset += wordSpacing + add + components->last().width + letterSpacing;
- start = i + 1;
- continue;
- } else if (!letterSpacing) {
-// qDebug() << i << char(run[i]) << (QChar::category(ch) == QChar::Letter_Lowercase) <<
-// QFontInfo(*f).pointSizeF();
- if (QChar::category(ch) == QChar::Letter_Lowercase) {
- if (f == &font.scFont())
- continue;
- } else {
- if (f == &font.font())
- continue;
- }
- }
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run.rtl(),
- f, offset, f == &font.scFont()));
- offset += components->last().width + letterSpacing;
-// qDebug() << " appending(2) " << components->last().string << components->last().width;
- }
- if (smallCaps)
- f = (QChar::category(ch) == QChar::Letter_Lowercase ? &font.scFont() : &font.font());
- start = i;
- }
- if (run.length() - start > 0) {
- components->append(TextRunComponent(run.characters() + start, run.length() - start,
- run.rtl(),
- f, offset, f == &font.scFont()));
- offset += components->last().width;
-// qDebug() << " appending(3) " << components->last().string << components->last().width;
- }
- offset += letterSpacing;
- } else {
- int start = 0;
- for (int i = 0; i < run.length(); ++i) {
- if (Font::treatAsSpace(run[i])) {
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run.rtl(),
- f, offset));
- offset += components->last().width;
- }
- int add = 0;
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
- offset += add + components->last().width;
- if (i)
- offset += wordSpacing;
- start = i + 1;
- }
- }
- if (run.length() - start > 0) {
- components->append(TextRunComponent(run.characters() + start, run.length() - start,
- run.rtl(),
- f, offset));
- offset += components->last().width;
- }
- }
- return offset;
-}
-
-void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- if (to < 0)
- to = run.length();
- QPainter *p = ctx->platformContext();
- Color color = ctx->fillColor();
- p->setPen(QColor(color));
-
- Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run);
-
- if (from > 0 || to < run.length()) {
- FloatRect clip = selectionRectForText(run,
- IntPoint(qRound(point.x()), qRound(point.y())),
- QFontMetrics(m_font).height(), from, to);
- QRectF rect(clip.x(), clip.y() - ascent(), clip.width(), clip.height());
- p->save();
- p->setClipRect(rect.toRect());
- }
-
- if (run.rtl()) {
- for (int i = 0; i < components.size(); ++i) {
- if (!components.at(i).isSpace()) {
- p->setFont(*components.at(i).font);
- QPointF pt(point.x() + w - components.at(i).offset - components.at(i).width, point.y());
- p->drawText(pt, components.at(i).string);
- }
- }
- } else {
- for (int i = 0; i < components.size(); ++i) {
- if (!components.at(i).isSpace()) {
- p->setFont(*components.at(i).font);
- QPointF pt(point.x() + components.at(i).offset, point.y());
- p->drawText(pt, components.at(i).string);
- }
- }
- }
- if (from > 0 || to < run.length())
- p->restore();
-}
-
-int Font::width(const TextRun& run) const
-{
- Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run);
-
-// qDebug() << " width=" << w;
- return w;
-}
-
-float Font::floatWidth(const TextRun& run) const
-{
- return width(run);
-}
-
-float Font::floatWidth(const TextRun& run, int /*extraCharsAvailable*/, int& charsConsumed, String& glyphName) const
+QFont Font::font() const
{
- charsConsumed = run.length();
- glyphName = "";
- return width(run);
+ return primaryFont()->getQtFont();
}
-int Font::offsetForPosition(const TextRun& run, int position, bool includePartialGlyphs) const
-{
- Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run);
-
- int offset = 0;
- if (run.rtl()) {
- for (int i = 0; i < components.size(); ++i) {
- int xe = w - components.at(i).offset;
- int xs = xe - components.at(i).width;
- if (position >= xs) {
- QTextLayout layout(components.at(i).string, *components.at(i).font);
- layout.beginLayout();
- QTextLine l = layout.createLine();
- if (!l.isValid())
- return offset;
-
- l.setLineWidth(INT_MAX/256);
- layout.endLayout();
-
- if (position - xs >= l.width())
- return offset;
- int cursor = l.xToCursor(position - xs);
- if (cursor > 1)
- --cursor;
- return offset + cursor;
- } else {
- offset += components.at(i).string.length() - 1;
- }
- }
- } else {
- for (int i = 0; i < components.size(); ++i) {
- int xs = components.at(i).offset;
- int xe = xs + components.at(i).width;
- if (position <= xe) {
- QTextLayout layout(components.at(i).string, *components.at(i).font);
- layout.beginLayout();
- QTextLine l = layout.createLine();
- if (!l.isValid())
- return offset;
-
- l.setLineWidth(INT_MAX/256);
- layout.endLayout();
-
- if (position - xs >= l.width())
- return offset + components.at(i).string.length() - 1;
- int cursor = l.xToCursor(position - xs);
- if (cursor > 1)
- --cursor;
- return offset + cursor;
- } else {
- offset += components.at(i).string.length() - 1;
- }
- }
- }
- return run.length();
}
-static float cursorToX(const Vector<TextRunComponent, 1024>& components, int width, bool rtl, int cursor)
-{
- int start = 0;
- for (int i = 0; i < components.size(); ++i) {
- if (start + components.at(i).string.length() - 1 < cursor) {
- start += components.at(i).string.length() - 1;
- continue;
- }
- int xs = components.at(i).offset;
- if (rtl)
- xs = width - xs - components.at(i).width;
- QTextLayout layout(components.at(i).string, *components.at(i).font);
- layout.beginLayout();
- QTextLine l = layout.createLine();
- if (!l.isValid())
- return 0;
-
- l.setLineWidth(INT_MAX/256);
- layout.endLayout();
-
- return xs + l.cursorToX(cursor - start + 1);
- }
- return width;
-}
-
-FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& pt,
- int h, int from, int to) const
-{
- Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run);
-
- if (from == 0 && to == run.length())
- return FloatRect(pt.x(), pt.y(), w, h);
-
- float x1 = cursorToX(components, w, run.rtl(), from);
- float x2 = cursorToX(components, w, run.rtl(), to);
- if (x2 < x1)
- qSwap(x1, x2);
-
- return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h);
-}
#endif
-
-Font::~Font()
-{
-}
-
-Font::Font(const Font& other)
- : m_fontDescription(other.m_fontDescription)
- , m_letterSpacing(other.m_letterSpacing)
- , m_wordSpacing(other.m_wordSpacing)
- , m_font(other.m_font)
- , m_scFont(other.m_scFont)
- , m_spaceWidth(other.m_spaceWidth)
-{
-}
-
-Font& Font::operator=(const Font& other)
-{
- m_fontDescription = other.m_fontDescription;
- m_letterSpacing = other.m_letterSpacing;
- m_wordSpacing = other.m_wordSpacing;
- m_font = other.m_font;
- m_scFont = other.m_scFont;
- m_spaceWidth = other.m_spaceWidth;
- return *this;
-}
-
-bool Font::operator==(const Font& other) const
-{
- return m_fontDescription == other.m_fontDescription
- && m_letterSpacing == other.m_letterSpacing
- && m_wordSpacing == other.m_wordSpacing
- && m_font == other.m_font
- && m_scFont == other.m_scFont
- && m_spaceWidth == other.m_spaceWidth;
-}
-
-void Font::update(PassRefPtr<FontSelector>) const
-{
- // don't think we need this
-}
-
-
-bool Font::isFixedPitch() const
-{
- return QFontInfo(m_font).fixedPitch();
-}
-
-// Metrics that we query the FontFallbackList for.
-int Font::ascent() const
-{
- return QFontMetrics(m_font).ascent();
-}
-
-int Font::descent() const
-{
- return QFontMetrics(m_font).descent();
-}
-
-int Font::lineSpacing() const
-{
- return QFontMetrics(m_font).lineSpacing();
-}
-
-int Font::lineGap() const
-{
- return QFontMetrics(m_font).leading();
-}
-
-float Font::xHeight() const
-{
- return QFontMetrics(m_font).xHeight();
-}
-
-unsigned Font::unitsPerEm() const
-{
- return 1; // FIXME!
-}
-
-int Font::spaceWidth() const
-{
- return m_spaceWidth;
-}
-
-}
diff --git a/WebCore/platform/graphics/qt/FontQt43.cpp b/WebCore/platform/graphics/qt/FontQt43.cpp
new file mode 100644
index 0000000..137b7c9
--- /dev/null
+++ b/WebCore/platform/graphics/qt/FontQt43.cpp
@@ -0,0 +1,356 @@
+/*
+ Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008 Holger Hans Peter Freyther
+
+ 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 "Font.h"
+#include "FontDescription.h"
+#include "FontFallbackList.h"
+#include "FontSelector.h"
+
+#include "GraphicsContext.h"
+#include <QTextLayout>
+#include <QPainter>
+#include <QFontMetrics>
+#include <QFontInfo>
+#include <qalgorithms.h>
+#include <qdebug.h>
+
+#include <limits.h>
+
+#if QT_VERSION < 0x040400
+
+namespace WebCore {
+
+struct TextRunComponent {
+ TextRunComponent() : font(0) {}
+ TextRunComponent(const UChar *start, int length, bool rtl, const QFont *font, int offset, bool sc = false);
+ TextRunComponent(int spaces, bool rtl, const QFont *font, int offset);
+
+ inline bool isSpace() const { return spaces != 0; }
+
+ QString string;
+ const QFont *font;
+ int width;
+ int offset;
+ int spaces;
+};
+
+TextRunComponent::TextRunComponent(const UChar *start, int length, bool rtl, const QFont *f, int o, bool sc)
+ : string(reinterpret_cast<const QChar*>(start), length)
+ , font(f)
+ , offset(o)
+ , spaces(0)
+{
+ if (sc)
+ string = string.toUpper();
+ string.prepend(rtl ? QChar(0x202e) : QChar(0x202d));
+ width = QFontMetrics(*font).width(string);
+}
+
+TextRunComponent::TextRunComponent(int s, bool rtl, const QFont *f, int o)
+ : string(s, QLatin1Char(' '))
+ , font(f)
+ , offset(o)
+ , spaces(s)
+{
+ string.prepend(rtl ? QChar(0x202e) : QChar(0x202d));
+ width = spaces * QFontMetrics(*font).width(QLatin1Char(' '));
+}
+
+
+static int generateComponents(Vector<TextRunComponent, 1024>* components, const Font &font, const TextRun &run)
+{
+// qDebug() << "generateComponents" << QString((const QChar *)run.characters(), run.length());
+ int letterSpacing = font.letterSpacing();
+ int wordSpacing = font.wordSpacing();
+ bool smallCaps = font.fontDescription().smallCaps();
+ int padding = run.padding();
+ int numSpaces = 0;
+ if (padding) {
+ for (int i = 0; i < run.length(); i++)
+ if (Font::treatAsSpace(run[i]))
+ ++numSpaces;
+ }
+
+ int offset = 0;
+ const QFont *f = &font.font();
+ if (letterSpacing || smallCaps) {
+ // need to draw every letter on it's own
+ int start = 0;
+ if (Font::treatAsSpace(run[0])) {
+ int add = 0;
+ if (numSpaces) {
+ add = padding/numSpaces;
+ padding -= add;
+ --numSpaces;
+ }
+ components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
+ offset += add + letterSpacing + components->last().width;
+ start = 1;
+// qDebug() << "space at 0" << offset;
+ } else if (smallCaps) {
+ f = (QChar::category(run[0]) == QChar::Letter_Lowercase ? &font.scFont() : &font.font());
+ }
+ for (int i = 1; i < run.length(); ++i) {
+ uint ch = run[i];
+ if (QChar(ch).isHighSurrogate() && QChar(run[i-1]).isLowSurrogate())
+ ch = QChar::surrogateToUcs4(ch, run[i-1]);
+ if (QChar(ch).isLowSurrogate() || QChar::category(ch) == QChar::Mark_NonSpacing)
+ continue;
+ if (Font::treatAsSpace(run[i])) {
+ int add = 0;
+// qDebug() << " treatAsSpace:" << i << start;
+ if (i - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, i - start,
+ run.rtl(),
+ f, offset, f == &font.scFont()));
+ offset += components->last().width + letterSpacing;
+// qDebug() << " appending(1) " << components->last().string << components->last().width;
+ }
+ if (numSpaces) {
+ add = padding/numSpaces;
+ padding -= add;
+ --numSpaces;
+ }
+ components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
+ offset += wordSpacing + add + components->last().width + letterSpacing;
+ start = i + 1;
+ continue;
+ } else if (!letterSpacing) {
+// qDebug() << i << char(run[i]) << (QChar::category(ch) == QChar::Letter_Lowercase) <<
+// QFontInfo(*f).pointSizeF();
+ if (QChar::category(ch) == QChar::Letter_Lowercase) {
+ if (f == &font.scFont())
+ continue;
+ } else {
+ if (f == &font.font())
+ continue;
+ }
+ }
+ if (i - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, i - start,
+ run.rtl(),
+ f, offset, f == &font.scFont()));
+ offset += components->last().width + letterSpacing;
+// qDebug() << " appending(2) " << components->last().string << components->last().width;
+ }
+ if (smallCaps)
+ f = (QChar::category(ch) == QChar::Letter_Lowercase ? &font.scFont() : &font.font());
+ start = i;
+ }
+ if (run.length() - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, run.length() - start,
+ run.rtl(),
+ f, offset, f == &font.scFont()));
+ offset += components->last().width;
+// qDebug() << " appending(3) " << components->last().string << components->last().width;
+ }
+ offset += letterSpacing;
+ } else {
+ int start = 0;
+ for (int i = 0; i < run.length(); ++i) {
+ if (Font::treatAsSpace(run[i])) {
+ if (i - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, i - start,
+ run.rtl(),
+ f, offset));
+ offset += components->last().width;
+ }
+ int add = 0;
+ if (numSpaces) {
+ add = padding/numSpaces;
+ padding -= add;
+ --numSpaces;
+ }
+ components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
+ offset += add + components->last().width;
+ if (i)
+ offset += wordSpacing;
+ start = i + 1;
+ }
+ }
+ if (run.length() - start > 0) {
+ components->append(TextRunComponent(run.characters() + start, run.length() - start,
+ run.rtl(),
+ f, offset));
+ offset += components->last().width;
+ }
+ }
+ return offset;
+}
+
+void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
+{
+ if (to < 0)
+ to = run.length();
+
+ QPainter *p = ctx->platformContext();
+ Color color = ctx->fillColor();
+ p->setPen(QColor(color));
+
+ Vector<TextRunComponent, 1024> components;
+ int w = generateComponents(&components, *this, run);
+
+ if (from > 0 || to < run.length()) {
+ FloatRect clip = selectionRectForComplexText(run,
+ IntPoint(qRound(point.x()), qRound(point.y())),
+ QFontMetrics(font()).height(), from, to);
+ QRectF rect(clip.x(), clip.y() - ascent(), clip.width(), clip.height());
+ p->save();
+ p->setClipRect(rect.toRect());
+ }
+
+ if (run.rtl()) {
+ for (int i = 0; i < components.size(); ++i) {
+ if (!components.at(i).isSpace()) {
+ p->setFont(*components.at(i).font);
+ QPointF pt(point.x() + w - components.at(i).offset - components.at(i).width, point.y());
+ p->drawText(pt, components.at(i).string);
+ }
+ }
+ } else {
+ for (int i = 0; i < components.size(); ++i) {
+ if (!components.at(i).isSpace()) {
+ p->setFont(*components.at(i).font);
+ QPointF pt(point.x() + components.at(i).offset, point.y());
+ p->drawText(pt, components.at(i).string);
+ }
+ }
+ }
+ if (from > 0 || to < run.length())
+ p->restore();
+}
+
+float Font::floatWidthForComplexText(const TextRun& run) const
+{
+ Vector<TextRunComponent, 1024> components;
+ int w = generateComponents(&components, *this, run);
+
+ return w;
+}
+
+int Font::offsetForPositionForComplexText(const TextRun& run, int position, bool includePartialGlyphs) const
+{
+ Vector<TextRunComponent, 1024> components;
+ int w = generateComponents(&components, *this, run);
+
+ int offset = 0;
+ if (run.rtl()) {
+ for (int i = 0; i < components.size(); ++i) {
+ int xe = w - components.at(i).offset;
+ int xs = xe - components.at(i).width;
+ if (position >= xs) {
+ QTextLayout layout(components.at(i).string, *components.at(i).font);
+ layout.beginLayout();
+ QTextLine l = layout.createLine();
+ if (!l.isValid())
+ return offset;
+
+ l.setLineWidth(INT_MAX/256);
+ layout.endLayout();
+
+ if (position - xs >= l.width())
+ return offset;
+ int cursor = l.xToCursor(position - xs);
+ if (cursor > 1)
+ --cursor;
+ return offset + cursor;
+ } else {
+ offset += components.at(i).string.length() - 1;
+ }
+ }
+ } else {
+ for (int i = 0; i < components.size(); ++i) {
+ int xs = components.at(i).offset;
+ int xe = xs + components.at(i).width;
+ if (position <= xe) {
+ QTextLayout layout(components.at(i).string, *components.at(i).font);
+ layout.beginLayout();
+ QTextLine l = layout.createLine();
+ if (!l.isValid())
+ return offset;
+
+ l.setLineWidth(INT_MAX/256);
+ layout.endLayout();
+
+ if (position - xs >= l.width())
+ return offset + components.at(i).string.length() - 1;
+ int cursor = l.xToCursor(position - xs);
+ if (cursor > 1)
+ --cursor;
+ return offset + cursor;
+ } else {
+ offset += components.at(i).string.length() - 1;
+ }
+ }
+ }
+ return run.length();
+}
+
+static float cursorToX(const Vector<TextRunComponent, 1024>& components, int width, bool rtl, int cursor)
+{
+ int start = 0;
+ for (int i = 0; i < components.size(); ++i) {
+ if (start + components.at(i).string.length() - 1 < cursor) {
+ start += components.at(i).string.length() - 1;
+ continue;
+ }
+ int xs = components.at(i).offset;
+ if (rtl)
+ xs = width - xs - components.at(i).width;
+ QTextLayout layout(components.at(i).string, *components.at(i).font);
+ layout.beginLayout();
+ QTextLine l = layout.createLine();
+ if (!l.isValid())
+ return 0;
+
+ l.setLineWidth(INT_MAX/256);
+ layout.endLayout();
+
+ return xs + l.cursorToX(cursor - start + 1);
+ }
+ return width;
+}
+
+FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& pt,
+ int h, int from, int to) const
+{
+ Vector<TextRunComponent, 1024> components;
+ int w = generateComponents(&components, *this, run);
+
+ if (from == 0 && to == run.length())
+ return FloatRect(pt.x(), pt.y(), w, h);
+
+ float x1 = cursorToX(components, w, run.rtl(), from);
+ float x2 = cursorToX(components, w, run.rtl(), to);
+ if (x2 < x1)
+ qSwap(x1, x2);
+
+ return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h);
+}
+
+int Font::lineGap() const
+{
+ return QFontMetrics(m_font).leading();
+}
+
+}
+
+#endif
diff --git a/WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp b/WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp
index d32cc63..2121206 100644
--- a/WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp
+++ b/WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008 Holger Hans Peter Freyther
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -24,7 +25,11 @@
namespace WebCore {
-void GlyphPageTreeNode::pruneTreeCustomFontData(const FontData* fontData)
+void GlyphPageTreeNode::pruneTreeCustomFontData(const FontData*)
+{
+}
+
+void GlyphPageTreeNode::pruneTreeFontData(const WebCore::SimpleFontData*)
{
}
diff --git a/WebCore/platform/graphics/qt/GradientQt.cpp b/WebCore/platform/graphics/qt/GradientQt.cpp
index f414efa..a0edf8d 100644
--- a/WebCore/platform/graphics/qt/GradientQt.cpp
+++ b/WebCore/platform/graphics/qt/GradientQt.cpp
@@ -52,7 +52,7 @@ QGradient* Gradient::platformGradient()
QColor stopColor;
Vector<ColorStop>::iterator stopIterator = m_stops.begin();
- qreal lastStop;
+ qreal lastStop(0.0);
const qreal lastStopDiff = 0.0000001;
while (stopIterator != m_stops.end()) {
stopColor.setRgbF(stopIterator->red, stopIterator->green, stopIterator->blue, stopIterator->alpha);
diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index 600d77c..2e7cdcb 100644
--- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -39,7 +39,7 @@
#include <windows.h>
#endif
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "Color.h"
#include "FloatConversion.h"
#include "Font.h"
@@ -280,7 +280,7 @@ PlatformGraphicsContext* GraphicsContext::platformContext() const
return m_data->p();
}
-AffineTransform GraphicsContext::getCTM() const
+TransformationMatrix GraphicsContext::getCTM() const
{
return platformContext()->combinedMatrix();
}
@@ -293,6 +293,11 @@ void GraphicsContext::savePlatformState()
void GraphicsContext::restorePlatformState()
{
m_data->p()->restore();
+
+ if (!m_data->currentPath.isEmpty() && m_common->state.pathTransform.isInvertible()) {
+ QMatrix matrix = m_common->state.pathTransform;
+ m_data->currentPath = m_data->currentPath * matrix;
+ }
}
/* FIXME: DISABLED WHILE MERGING BACK FROM UNITY
@@ -520,6 +525,15 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
p->restore();
}
+QPen GraphicsContext::pen()
+{
+ if (paintingDisabled())
+ return QPen();
+
+ QPainter *p = m_data->p();
+ return p->pen();
+}
+
void GraphicsContext::fillPath()
{
if (paintingDisabled())
@@ -533,15 +547,18 @@ void GraphicsContext::fillPath()
if (fillColor().alpha())
p->fillPath(path, p->brush());
break;
- case PatternColorSpace:
- p->fillPath(path, QBrush(m_common->state.fillPattern.get()->createPlatformPattern(getCTM())));
+ case PatternColorSpace: {
+ TransformationMatrix affine;
+ p->fillPath(path, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
break;
+ }
case GradientColorSpace:
- QGradient* gradient = m_common->state.fillGradient.get()->platformGradient();
+ QGradient* gradient = m_common->state.fillGradient->platformGradient();
*gradient = applySpreadMethod(*gradient, spreadMethod());
p->fillPath(path, QBrush(*gradient));
break;
}
+ m_data->currentPath = QPainterPath();
}
void GraphicsContext::strokePath()
@@ -559,13 +576,14 @@ void GraphicsContext::strokePath()
p->strokePath(path, pen);
break;
case PatternColorSpace: {
- pen.setBrush(QBrush(m_common->state.strokePattern.get()->createPlatformPattern(getCTM())));
+ TransformationMatrix affine;
+ pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine)));
p->setPen(pen);
p->strokePath(path, pen);
break;
}
case GradientColorSpace: {
- QGradient* gradient = m_common->state.strokeGradient.get()->platformGradient();
+ QGradient* gradient = m_common->state.strokeGradient->platformGradient();
*gradient = applySpreadMethod(*gradient, spreadMethod());
pen.setBrush(QBrush(*gradient));
p->setPen(pen);
@@ -573,6 +591,7 @@ void GraphicsContext::strokePath()
break;
}
}
+ m_data->currentPath = QPainterPath();
}
void GraphicsContext::fillRect(const FloatRect& rect)
@@ -587,13 +606,16 @@ void GraphicsContext::fillRect(const FloatRect& rect)
if (fillColor().alpha())
p->fillRect(rect, p->brush());
break;
- case PatternColorSpace:
- p->fillRect(rect, QBrush(m_common->state.fillPattern.get()->createPlatformPattern(getCTM())));
+ case PatternColorSpace: {
+ TransformationMatrix affine;
+ p->fillRect(rect, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
break;
+ }
case GradientColorSpace:
p->fillRect(rect, QBrush(*(m_common->state.fillGradient.get()->platformGradient())));
break;
}
+ m_data->currentPath = QPainterPath();
}
void GraphicsContext::fillRect(const FloatRect& rect, const Color& c)
@@ -621,7 +643,9 @@ void GraphicsContext::beginPath()
void GraphicsContext::addPath(const Path& path)
{
- m_data->currentPath = *(path.platformPath());
+ QPainterPath newPath = m_data->currentPath;
+ newPath.addPath(*(path.platformPath()));
+ m_data->currentPath = newPath;
}
bool GraphicsContext::inTransparencyLayer() const
@@ -645,6 +669,17 @@ void GraphicsContext::clip(const FloatRect& rect)
else p->setClipRect(rect, Qt::IntersectClip);
}
+void GraphicsContext::clipPath(WindRule clipRule)
+{
+ if (paintingDisabled())
+ return;
+
+ QPainter *p = m_data->p();
+ QPainterPath newPath = m_data->currentPath;
+ newPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+ p->setClipPath(newPath);
+}
+
/**
* Focus ring handling is not handled here. Qt style in
* RenderTheme handles drawing focus on widgets which
@@ -823,8 +858,9 @@ void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
if (dashLength % 2)
count *= 2;
+ float penWidth = narrowPrecisionToFloat(double(pen.widthF()));
for (unsigned i = 0; i < count; i++)
- pattern.append(dashes[i % dashLength] / narrowPrecisionToFloat(pen.widthF()));
+ pattern.append(dashes[i % dashLength] / penWidth);
pen.setDashPattern(pattern);
pen.setDashOffset(dashOffset);
@@ -901,6 +937,12 @@ void GraphicsContext::translate(float x, float y)
return;
m_data->p()->translate(x, y);
+
+ if (!m_data->currentPath.isEmpty()) {
+ QMatrix matrix;
+ m_data->currentPath = m_data->currentPath * matrix.translate(-x, -y);
+ m_common->state.pathTransform.translate(x, y);
+ }
}
IntPoint GraphicsContext::origin()
@@ -917,6 +959,12 @@ void GraphicsContext::rotate(float radians)
return;
m_data->p()->rotate(180/M_PI*radians);
+
+ if (!m_data->currentPath.isEmpty()) {
+ QMatrix matrix;
+ m_data->currentPath = m_data->currentPath * matrix.rotate(-180/M_PI*radians);
+ m_common->state.pathTransform.rotate(radians);
+ }
}
void GraphicsContext::scale(const FloatSize& s)
@@ -925,6 +973,12 @@ void GraphicsContext::scale(const FloatSize& s)
return;
m_data->p()->scale(s.width(), s.height());
+
+ if (!m_data->currentPath.isEmpty()) {
+ QMatrix matrix;
+ m_data->currentPath = m_data->currentPath * matrix.scale(1 / s.width(), 1 / s.height());
+ m_common->state.pathTransform.scale(s.width(), s.height());
+ }
}
void GraphicsContext::clipOut(const IntRect& rect)
@@ -982,12 +1036,20 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect,
m_data->p()->setClipPath(path, Qt::IntersectClip);
}
-void GraphicsContext::concatCTM(const AffineTransform& transform)
+void GraphicsContext::concatCTM(const TransformationMatrix& transform)
{
if (paintingDisabled())
return;
m_data->p()->setMatrix(transform, true);
+
+ // Transformations to the context shouldn't transform the currentPath.
+ // We have to undo every change made to the context from the currentPath to avoid wrong drawings.
+ if (!m_data->currentPath.isEmpty() && transform.isInvertible()) {
+ QMatrix matrix = transform.inverse();
+ m_data->currentPath = m_data->currentPath * matrix;
+ m_common->state.pathTransform.multiply(transform);
+ }
}
void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
@@ -995,13 +1057,6 @@ void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
notImplemented();
}
-void GraphicsContext::setPlatformFont(const Font& aFont)
-{
- if (paintingDisabled())
- return;
- m_data->p()->setFont(aFont.font());
-}
-
void GraphicsContext::setPlatformStrokeColor(const Color& color)
{
if (paintingDisabled())
@@ -1039,7 +1094,7 @@ void GraphicsContext::setPlatformFillColor(const Color& color)
m_data->p()->setBrush(QBrush(color));
}
-void GraphicsContext::setUseAntialiasing(bool enable)
+void GraphicsContext::setPlatformShouldAntialias(bool enable)
{
if (paintingDisabled())
return;
@@ -1051,8 +1106,8 @@ void GraphicsContext::setUseAntialiasing(bool enable)
HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
{
- // painting through native HDC is only supported for plugin, where mayCreateBitmap is always TRUE
- Q_ASSERT(mayCreateBitmap == TRUE);
+ // painting through native HDC is only supported for plugin, where mayCreateBitmap is always true
+ Q_ASSERT(mayCreateBitmap);
if (dstRect.isEmpty())
return 0;
@@ -1090,6 +1145,7 @@ HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlpha
memset(bmpInfo.bmBits, 0, bufferSize);
}
+#if !PLATFORM(WIN_CE)
// Make sure we can do world transforms.
SetGraphicsMode(bitmapDC, GM_ADVANCED);
@@ -1102,15 +1158,15 @@ HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlpha
xform.eDx = -dstRect.x();
xform.eDy = -dstRect.y();
::SetWorldTransform(bitmapDC, &xform);
-
+#endif
return bitmapDC;
}
void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
{
- // painting through native HDC is only supported for plugin, where mayCreateBitmap is always TRUE
- Q_ASSERT(mayCreateBitmap == TRUE);
+ // painting through native HDC is only supported for plugin, where mayCreateBitmap is always true
+ Q_ASSERT(mayCreateBitmap);
if (hdc) {
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index e3b00a1..394c7a7 100644
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -178,9 +178,26 @@ ImageDecoderQt::ReadContext::IncrementalReadResult
return IncrementalReadComplete;
}
+ImageDecoderQt* ImageDecoderQt::create(const SharedBuffer& data)
+{
+ // We need at least 4 bytes to figure out what kind of image we're dealing with.
+ if (data.size() < 4)
+ return 0;
+
+ QByteArray bytes = QByteArray::fromRawData(data.data(), data.size());
+ QBuffer buffer(&bytes);
+ if (!buffer.open(QBuffer::ReadOnly))
+ return 0;
+
+ QString imageFormat = QString::fromLatin1(QImageReader::imageFormat(&buffer).toLower());
+ if (imageFormat.isEmpty())
+ return 0; // Image format not supported
+
+ return new ImageDecoderQt(imageFormat);
+}
-// ImageDecoderQt
-ImageDecoderQt::ImageDecoderQt( )
+ImageDecoderQt::ImageDecoderQt(const QString &imageFormat)
+ : m_imageFormat(imageFormat)
{
}
@@ -254,7 +271,6 @@ int ImageDecoderQt::frameCount() const
return m_imageList.size();
}
-
int ImageDecoderQt::repetitionCount() const
{
if (debugImageDecoderQt)
@@ -262,7 +278,6 @@ int ImageDecoderQt::repetitionCount() const
return m_loopCount;
}
-
bool ImageDecoderQt::supportsAlpha() const
{
return hasFirstImageHeader() && m_imageList[0].m_image.hasAlphaChannel();
@@ -275,6 +290,13 @@ int ImageDecoderQt::duration(size_t index) const
return m_imageList[index].m_duration;
}
+String ImageDecoderQt::filenameExtension() const
+{
+ if (debugImageDecoderQt)
+ qDebug() << " ImageDecoderQt::filenameExtension() returns" << m_imageFormat;
+ return m_imageFormat;
+};
+
RGBA32Buffer* ImageDecoderQt::frameBufferAtIndex(size_t index)
{
Q_ASSERT("use imageAtIndex instead");
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.h b/WebCore/platform/graphics/qt/ImageDecoderQt.h
index 3573dd0..a2eb6aa 100644
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.h
+++ b/WebCore/platform/graphics/qt/ImageDecoderQt.h
@@ -38,34 +38,30 @@ namespace WebCore {
class ImageDecoderQt : public ImageDecoder
{
- ImageDecoderQt(const ImageDecoderQt&);
- ImageDecoderQt &operator=(const ImageDecoderQt&);
public:
- ImageDecoderQt();
+ static ImageDecoderQt* create(const SharedBuffer& data);
~ImageDecoderQt();
typedef Vector<char> IncomingData;
virtual void setData(const IncomingData& data, bool allDataReceived);
-
virtual bool isSizeAvailable() const;
-
virtual int frameCount() const;
-
-
virtual int repetitionCount() const;
-
-
virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
QPixmap* imageAtIndex(size_t index) const;
-
virtual bool supportsAlpha() const;
-
int duration(size_t index) const;
+ virtual String filenameExtension() const;
void clearFrame(size_t index);
+
private:
+ ImageDecoderQt(const QString &imageFormat);
+ ImageDecoderQt(const ImageDecoderQt&);
+ ImageDecoderQt &operator=(const ImageDecoderQt&);
+
class ReadContext;
void reset();
bool hasFirstImageHeader() const;
@@ -89,6 +85,7 @@ private:
ImageList m_imageList;
mutable QHash<int, QPixmap> m_pixmapCache;
int m_loopCount;
+ QString m_imageFormat;
};
diff --git a/WebCore/platform/graphics/qt/ImageQt.cpp b/WebCore/platform/graphics/qt/ImageQt.cpp
index 9234c69..99062f9 100644
--- a/WebCore/platform/graphics/qt/ImageQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageQt.cpp
@@ -34,7 +34,7 @@
#include "FloatRect.h"
#include "PlatformString.h"
#include "GraphicsContext.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "NotImplemented.h"
#include "StillImageQt.h"
#include "qwebsettings.h"
@@ -69,14 +69,16 @@ static QPixmap loadResourcePixmap(const char *name)
namespace WebCore {
-void FrameData::clear()
+bool FrameData::clear(bool clearMetadata)
{
+ if (clearMetadata)
+ m_haveMetadata = false;
+
if (m_frame) {
m_frame = 0;
- // NOTE: We purposefully don't reset metadata here, so that even if we
- // throw away previously-decoded data, animation loops can still access
- // properties like frame durations without re-decoding.
+ return true;
}
+ return false;
}
@@ -91,7 +93,7 @@ PassRefPtr<Image> Image::loadPlatformResource(const char* name)
}
-void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
+void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const TransformationMatrix& patternTransform,
const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect)
{
notImplemented();
@@ -136,7 +138,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
ctxt->restore();
}
-void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
+void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const TransformationMatrix& patternTransform,
const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect)
{
QPixmap* framePixmap = nativeImageForCurrentFrame();
diff --git a/WebCore/platform/graphics/qt/ImageSourceQt.cpp b/WebCore/platform/graphics/qt/ImageSourceQt.cpp
index 1d14f9d..d62acc3 100644
--- a/WebCore/platform/graphics/qt/ImageSourceQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageSourceQt.cpp
@@ -29,6 +29,7 @@
#include "config.h"
#include "ImageSource.h"
#include "ImageDecoderQt.h"
+#include "NotImplemented.h"
#include "SharedBuffer.h"
#include <QBuffer>
@@ -36,25 +37,6 @@
#include <QImageReader>
namespace WebCore {
-static bool canHandleImage(const SharedBuffer& _data)
-{
- // We need at least 4 bytes to figure out what kind of image we're dealing with.
- if (_data.size() < 4)
- return false;
-
- QByteArray data = QByteArray::fromRawData(_data.data(), _data.size());
- QBuffer buffer(&data);
- if (!buffer.open(QBuffer::ReadOnly))
- return false;
-
- return !QImageReader::imageFormat(&buffer).isEmpty();
-}
-
-ImageDecoderQt* createDecoder(const SharedBuffer& data) {
- if (!canHandleImage(data))
- return 0;
- return new ImageDecoderQt();
-}
ImageSource::ImageSource()
: m_decoder(0)
@@ -63,7 +45,7 @@ ImageSource::ImageSource()
ImageSource::~ImageSource()
{
- delete m_decoder;
+ clear(true);
}
bool ImageSource::initialized() const
@@ -78,7 +60,7 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
// If insufficient bytes are available to determine the image type, no decoder plugin will be
// made.
if (!m_decoder)
- m_decoder = createDecoder(*data);
+ m_decoder = ImageDecoderQt::create(*data);
if (!m_decoder)
return;
@@ -86,6 +68,14 @@ void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
m_decoder->setData(data->buffer(), allDataReceived);
}
+String ImageSource::filenameExtension() const
+{
+ if (!m_decoder)
+ return String();
+
+ return m_decoder->filenameExtension();
+}
+
bool ImageSource::isSizeAvailable()
{
if (!m_decoder)
@@ -162,13 +152,20 @@ bool ImageSource::frameIsCompleteAtIndex(size_t index)
return (m_decoder && m_decoder->imageAtIndex(index) != 0);
}
-void ImageSource::clear()
+void ImageSource::clear(bool destroyAll, size_t clearBeforeFrame, SharedBuffer* data, bool allDataReceived)
{
- delete m_decoder;
+ if (!destroyAll) {
+ if (m_decoder)
+ m_decoder->clearFrameBufferCache(clearBeforeFrame);
+ return;
+ }
+
+ delete m_decoder;
m_decoder = 0;
+ if (data)
+ setData(data, allDataReceived);
}
-
}
// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp b/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp
index 431e68e..b1a48fb 100644
--- a/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp
+++ b/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp
@@ -84,6 +84,9 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
{
// Hint to Phonon to disable overlay painting
m_videoWidget->setAttribute(Qt::WA_DontShowOnScreen);
+#if QT_VERSION < 0x040500
+ m_videoWidget->setAttribute(Qt::WA_QuitOnClose, false);
+#endif
createPath(m_mediaObject, m_videoWidget);
createPath(m_mediaObject, m_audioOutput);
@@ -96,7 +99,6 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
this, SLOT(stateChanged(Phonon::State, Phonon::State)));
- connect(m_mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
connect(m_mediaObject, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
connect(m_mediaObject, SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
connect(m_mediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool)));
@@ -105,7 +107,6 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
connect(m_mediaObject, SIGNAL(currentSourceChanged(const Phonon::MediaSource&)),
this, SLOT(currentSourceChanged(const Phonon::MediaSource&)));
connect(m_mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish()));
- connect(m_mediaObject, SIGNAL(prefinishMarkReached(qint32)), this, SLOT(prefinishMarkReached(qint32)));
connect(m_mediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64)));
}
@@ -314,7 +315,7 @@ void MediaPlayerPrivate::updateStates()
m_mediaObject->pause();
}
} else if (phononState == Phonon::PausedState) {
- m_networkState = MediaPlayer::LoadedFirstFrame;
+ m_networkState = MediaPlayer::Loaded;
m_readyState = MediaPlayer::CanPlayThrough;
} else if (phononState == Phonon::ErrorState) {
if (!m_mediaObject || m_mediaObject->errorType() == Phonon::FatalError) {
@@ -371,42 +372,6 @@ void MediaPlayerPrivate::setRect(const IntRect& newRect)
m_videoWidget->resize(newRect.width(), newRect.height());
}
-
-void MediaPlayerPrivate::loadStateChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::rateChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::sizeChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::timeChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::volumeChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::didEnd()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::loadingFailed()
-{
- notImplemented();
-}
-
IntSize MediaPlayerPrivate::naturalSize() const
{
if (!hasVideo()) {
@@ -430,17 +395,12 @@ IntSize MediaPlayerPrivate::naturalSize() const
bool MediaPlayerPrivate::eventFilter(QObject* obj, QEvent* event)
{
- if (event->type() == QEvent::Paint)
+ if (event->type() == QEvent::UpdateRequest)
m_player->repaint();
return QObject::eventFilter(obj, event);
}
-void MediaPlayerPrivate::repaint()
-{
- m_player->repaint();
-}
-
void MediaPlayerPrivate::paint(GraphicsContext* graphicsContect, const IntRect& rect)
{
if (graphicsContect->paintingDisabled())
@@ -469,12 +429,6 @@ void MediaPlayerPrivate::stateChanged(Phonon::State newState, Phonon::State oldS
updateStates();
}
-void MediaPlayerPrivate::tick(qint64)
-{
- updateStates();
- m_player->timeChanged();
-}
-
void MediaPlayerPrivate::metaDataChanged()
{
LOG(Media, "MediaPlayerPrivatePhonon::metaDataChanged()");
@@ -516,12 +470,6 @@ void MediaPlayerPrivate::aboutToFinish()
LOG_MEDIAOBJECT();
}
-void MediaPlayerPrivate::prefinishMarkReached(qint32)
-{
- notImplemented();
- LOG_MEDIAOBJECT();
-}
-
void MediaPlayerPrivate::totalTimeChanged(qint64 totalTime)
{
LOG(Media, "MediaPlayerPrivatePhonon::totalTimeChanged(%d)", totalTime);
diff --git a/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h b/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h
index 5eb2a09..1b20a84 100644
--- a/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h
+++ b/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h
@@ -111,15 +111,6 @@ namespace WebCore {
void setVisible(bool);
void setRect(const IntRect&);
- void loadStateChanged();
- void rateChanged();
- void sizeChanged();
- void timeChanged();
- void volumeChanged();
- void didEnd();
- void loadingFailed();
-
- void repaint();
void paint(GraphicsContext*, const IntRect&);
static void getSupportedTypes(HashSet<String>&);
static bool isAvailable() { return true; }
@@ -129,7 +120,6 @@ namespace WebCore {
private slots:
void stateChanged(Phonon::State, Phonon::State);
- void tick(qint64);
void metaDataChanged();
void seekableChanged(bool);
void hasVideoChanged(bool);
@@ -137,7 +127,6 @@ namespace WebCore {
void finished();
void currentSourceChanged(const Phonon::MediaSource&);
void aboutToFinish();
- void prefinishMarkReached(qint32);
void totalTimeChanged(qint64);
private:
diff --git a/WebCore/platform/graphics/qt/PathQt.cpp b/WebCore/platform/graphics/qt/PathQt.cpp
index 76f375c..bd0192c 100644
--- a/WebCore/platform/graphics/qt/PathQt.cpp
+++ b/WebCore/platform/graphics/qt/PathQt.cpp
@@ -29,9 +29,12 @@
#include "config.h"
#include "Path.h"
+#include "TransformationMatrix.h"
#include "FloatRect.h"
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
#include "PlatformString.h"
-#include "AffineTransform.h"
+#include "StrokeStyleApplier.h"
#include <QPainterPath>
#include <QMatrix>
#include <QString>
@@ -39,6 +42,10 @@
#define _USE_MATH_DEFINES
#include <math.h>
+#ifndef M_PI
+# define M_PI 3.14159265358979323846
+#endif
+
namespace WebCore {
Path::Path()
@@ -77,6 +84,28 @@ bool Path::contains(const FloatPoint& point, WindRule rule) const
return contains;
}
+bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
+{
+ ASSERT(applier);
+
+ // FIXME: We should try to use a 'shared Context' instead of creating a new ImageBuffer
+ // on each call.
+ std::auto_ptr<ImageBuffer> scratchImage = ImageBuffer::create(IntSize(1, 1), false);
+ GraphicsContext* gc = scratchImage->context();
+ QPainterPathStroker stroke;
+ applier->strokeStyle(gc);
+
+ QPen pen = gc->pen();
+ stroke.setWidth(pen.widthF());
+ stroke.setCapStyle(pen.capStyle());
+ stroke.setJoinStyle(pen.joinStyle());
+ stroke.setMiterLimit(pen.miterLimit());
+ stroke.setDashPattern(pen.dashPattern());
+ stroke.setDashOffset(pen.dashOffset());
+
+ return (stroke.createStroke(*platformPath())).contains(point);
+}
+
void Path::translate(const FloatSize& size)
{
QMatrix matrix;
@@ -89,6 +118,27 @@ FloatRect Path::boundingRect() const
return m_path->boundingRect();
}
+FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
+{
+ // FIXME: We should try to use a 'shared Context' instead of creating a new ImageBuffer
+ // on each call.
+ std::auto_ptr<ImageBuffer> scratchImage = ImageBuffer::create(IntSize(1, 1), false);
+ GraphicsContext* gc = scratchImage->context();
+ QPainterPathStroker stroke;
+ if (applier) {
+ applier->strokeStyle(gc);
+
+ QPen pen = gc->pen();
+ stroke.setWidth(pen.widthF());
+ stroke.setCapStyle(pen.capStyle());
+ stroke.setJoinStyle(pen.joinStyle());
+ stroke.setMiterLimit(pen.miterLimit());
+ stroke.setDashPattern(pen.dashPattern());
+ stroke.setDashOffset(pen.dashOffset());
+ }
+ return (stroke.createStroke(*platformPath())).boundingRect();
+}
+
void Path::moveTo(const FloatPoint& point)
{
m_path->moveTo(point);
@@ -263,7 +313,7 @@ void Path::apply(void* info, PathApplierFunction function) const
}
}
-void Path::transform(const AffineTransform& transform)
+void Path::transform(const TransformationMatrix& transform)
{
if (m_path) {
QMatrix mat = transform;
diff --git a/WebCore/platform/graphics/qt/PatternQt.cpp b/WebCore/platform/graphics/qt/PatternQt.cpp
index 883a258..5b76841 100644
--- a/WebCore/platform/graphics/qt/PatternQt.cpp
+++ b/WebCore/platform/graphics/qt/PatternQt.cpp
@@ -26,12 +26,12 @@
#include "config.h"
#include "Pattern.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "GraphicsContext.h"
namespace WebCore {
-QBrush Pattern::createPlatformPattern(const AffineTransform& transform) const
+QBrush Pattern::createPlatformPattern(const TransformationMatrix& transform) const
{
QPixmap* pixmap = tileImage()->nativeImageForCurrentFrame();
if (!pixmap)
diff --git a/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp b/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
index 1ffce33..6cf4e55 100644
--- a/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
+++ b/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2008 Holger Hans Peter Freyther
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -19,37 +20,47 @@
This class provides all functionality needed for loading images, style sheets and html
pages from the web. It has a memory cache for these objects.
*/
+
#include "config.h"
#include "SimpleFontData.h"
-#include "SVGFontData.h"
+#include <QFontMetrics>
namespace WebCore {
-SimpleFontData::SimpleFontData(const FontPlatformData& font, bool customFont, bool loading, SVGFontData*)
- : m_font(font)
- , m_isCustomFont(customFont)
- , m_isLoading(loading)
+void SimpleFontData::determinePitch()
{
+ m_treatAsFixedPitch = m_font.font().fixedPitch();
}
-SimpleFontData::~SimpleFontData()
+bool SimpleFontData::containsCharacters(const UChar*, int length) const
{
+ return true;
}
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
+void SimpleFontData::platformInit()
{
- return true;
+ QFontMetrics fm(m_font.font());
+
+ m_ascent = fm.ascent();
+ m_descent = fm.descent();
+ m_lineSpacing = fm.lineSpacing();
+ m_xHeight = fm.xHeight();
+ m_spaceWidth = fm.width(QLatin1Char(' '));
+ m_lineGap = fm.leading();
}
-const SimpleFontData* SimpleFontData::fontDataForCharacter(UChar32) const
+void SimpleFontData::platformGlyphInit()
{
- return this;
+ m_spaceGlyph = 0;
+ m_adjustedSpaceWidth = m_spaceWidth;
+ determinePitch();
+ m_missingGlyphData.fontData = this;
+ m_missingGlyphData.glyph = 0;
}
-bool SimpleFontData::isSegmented() const
+void SimpleFontData::platformDestroy()
{
- return false;
}
}
diff --git a/WebCore/platform/graphics/qt/StillImageQt.h b/WebCore/platform/graphics/qt/StillImageQt.h
index 37b8b2c..2b2c1f7 100644
--- a/WebCore/platform/graphics/qt/StillImageQt.h
+++ b/WebCore/platform/graphics/qt/StillImageQt.h
@@ -41,7 +41,7 @@ namespace WebCore {
// FIXME: StillImages are underreporting decoded sizes and will be unable
// to prune because these functions are not implemented yet.
- virtual void destroyDecodedData(bool incremental = false, bool preserveNearbyFrames = false) { }
+ virtual void destroyDecodedData(bool destroyAll = true) { }
virtual unsigned decodedSize() const { return 0; }
virtual IntSize size() const;
diff --git a/WebCore/platform/graphics/qt/AffineTransformQt.cpp b/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp
index 2793043..47abd17 100644
--- a/WebCore/platform/graphics/qt/AffineTransformQt.cpp
+++ b/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp
@@ -24,34 +24,34 @@
*/
#include "config.h"
-#include "AffineTransform.h"
+#include "TransformationMatrix.h"
#include "IntRect.h"
#include "FloatRect.h"
namespace WebCore {
-AffineTransform::AffineTransform()
+TransformationMatrix::TransformationMatrix()
: m_transform()
{
}
-AffineTransform::AffineTransform(double a, double b, double c, double d, double tx, double ty)
+TransformationMatrix::TransformationMatrix(double a, double b, double c, double d, double tx, double ty)
: m_transform(a, b, c, d, tx, ty)
{
}
-AffineTransform::AffineTransform(const PlatformAffineTransform& matrix)
+TransformationMatrix::TransformationMatrix(const PlatformTransformationMatrix& matrix)
: m_transform(matrix)
{
}
-void AffineTransform::setMatrix(double a, double b, double c, double d, double tx, double ty)
+void TransformationMatrix::setMatrix(double a, double b, double c, double d, double tx, double ty)
{
m_transform.setMatrix(a, b, c, d, tx, ty);
}
-void AffineTransform::map(double x, double y, double* x2, double* y2) const
+void TransformationMatrix::map(double x, double y, double* x2, double* y2) const
{
qreal tx2, ty2;
m_transform.map(qreal(x), qreal(y), &tx2, &ty2);
@@ -59,140 +59,140 @@ void AffineTransform::map(double x, double y, double* x2, double* y2) const
*y2 = ty2;
}
-IntRect AffineTransform::mapRect(const IntRect& rect) const
+IntRect TransformationMatrix::mapRect(const IntRect& rect) const
{
return m_transform.mapRect(rect);
}
-FloatRect AffineTransform::mapRect(const FloatRect& rect) const
+FloatRect TransformationMatrix::mapRect(const FloatRect& rect) const
{
return m_transform.mapRect(rect);
}
-bool AffineTransform::isIdentity() const
+bool TransformationMatrix::isIdentity() const
{
return m_transform.isIdentity();
}
-double AffineTransform::a() const
+double TransformationMatrix::a() const
{
return m_transform.m11();
}
-void AffineTransform::setA(double a)
+void TransformationMatrix::setA(double a)
{
m_transform.setMatrix(a, b(), c(), d(), e(), f());
}
-double AffineTransform::b() const
+double TransformationMatrix::b() const
{
return m_transform.m12();
}
-void AffineTransform::setB(double b)
+void TransformationMatrix::setB(double b)
{
m_transform.setMatrix(a(), b, c(), d(), e(), f());
}
-double AffineTransform::c() const
+double TransformationMatrix::c() const
{
return m_transform.m21();
}
-void AffineTransform::setC(double c)
+void TransformationMatrix::setC(double c)
{
m_transform.setMatrix(a(), b(), c, d(), e(), f());
}
-double AffineTransform::d() const
+double TransformationMatrix::d() const
{
return m_transform.m22();
}
-void AffineTransform::setD(double d)
+void TransformationMatrix::setD(double d)
{
m_transform.setMatrix(a(), b(), c(), d, e(), f());
}
-double AffineTransform::e() const
+double TransformationMatrix::e() const
{
return m_transform.dx();
}
-void AffineTransform::setE(double e)
+void TransformationMatrix::setE(double e)
{
m_transform.setMatrix(a(), b(), c(), d(), e, f());
}
-double AffineTransform::f() const
+double TransformationMatrix::f() const
{
return m_transform.dy();
}
-void AffineTransform::setF(double f)
+void TransformationMatrix::setF(double f)
{
m_transform.setMatrix(a(), b(), c(), d(), e(), f);
}
-void AffineTransform::reset()
+void TransformationMatrix::reset()
{
m_transform.reset();
}
-AffineTransform& AffineTransform::scale(double sx, double sy)
+TransformationMatrix& TransformationMatrix::scale(double sx, double sy)
{
m_transform.scale(sx, sy);
return *this;
}
-AffineTransform& AffineTransform::rotate(double d)
+TransformationMatrix& TransformationMatrix::rotate(double d)
{
m_transform.rotate(d);
return *this;
}
-AffineTransform& AffineTransform::translate(double tx, double ty)
+TransformationMatrix& TransformationMatrix::translate(double tx, double ty)
{
m_transform.translate(tx, ty);
return *this;
}
-AffineTransform& AffineTransform::shear(double sx, double sy)
+TransformationMatrix& TransformationMatrix::shear(double sx, double sy)
{
m_transform.shear(sx, sy);
return *this;
}
-double AffineTransform::det() const
+double TransformationMatrix::det() const
{
return m_transform.det();
}
-AffineTransform AffineTransform::inverse() const
+TransformationMatrix TransformationMatrix::inverse() const
{
if(!isInvertible())
- return AffineTransform();
+ return TransformationMatrix();
return m_transform.inverted();
}
-AffineTransform::operator QMatrix() const
+TransformationMatrix::operator QMatrix() const
{
return m_transform;
}
-bool AffineTransform::operator==(const AffineTransform& other) const
+bool TransformationMatrix::operator==(const TransformationMatrix& other) const
{
return m_transform == other.m_transform;
}
-AffineTransform& AffineTransform::operator*=(const AffineTransform& other)
+TransformationMatrix& TransformationMatrix::operator*=(const TransformationMatrix& other)
{
m_transform *= other.m_transform;
return *this;
}
-AffineTransform AffineTransform::operator*(const AffineTransform& other)
+TransformationMatrix TransformationMatrix::operator*(const TransformationMatrix& other)
{
return m_transform * other.m_transform;
}