Changeset 113968 in webkit
- Timestamp:
- Apr 12, 2012 6:28:22 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r113967 r113968 1 2012-03-05 Pierre Rossi <pierre.rossi@gmail.com> 2 3 [Qt] Use QRawFont when building with Qt 5 4 https://bugs.webkit.org/show_bug.cgi?id=78001 5 6 Up until now, fonts in the Qt port have been handled via 7 the QFont API. QRawFont offers a lower-level API enabling 8 us to be more in line with what other WebKit ports do. 9 This patch proceeds to switching over to QRawFont, and 10 effectively use an earlier change by Andreas Kling 11 that remained guarded up until now. 12 13 Reviewed by Simon Hausmann. 14 15 No new tests since this is refactoring of existing 16 functionality. 17 18 * Target.pri: 19 * platform/graphics/Font.cpp: 20 (WebCore::Font::drawText): 21 * platform/graphics/Font.h: 22 (Font): 23 (WebCore): 24 (WebCore::Font::syntheticFont): Added. 25 * platform/graphics/SimpleFontData.h: 26 (SimpleFontData): 27 (WebCore::SimpleFontData::getQtRawFont): 28 (WebCore): 29 * platform/graphics/qt/FontCacheQt.cpp: 30 (WebCore::rawFontForCharacters): 31 (WebCore): 32 (WebCore::FontCache::getFontDataForCharacters): 33 (WebCore::FontCache::createFontPlatformData): 34 * platform/graphics/qt/FontCustomPlatformData.h: 35 (FontCustomPlatformData): 36 * platform/graphics/qt/FontCustomPlatformDataQt.cpp: 37 (WebCore::FontCustomPlatformData::~FontCustomPlatformData): 38 (WebCore::FontCustomPlatformData::fontPlatformData): 39 (WebCore::createFontCustomPlatformData): 40 * platform/graphics/qt/FontPlatformData.h: 41 (WebCore::FontPlatformDataPrivate::FontPlatformDataPrivate): 42 (FontPlatformDataPrivate): 43 (FontPlatformData): 44 * platform/graphics/qt/FontPlatformDataQt.cpp: 45 (WebCore::FontPlatformData::FontPlatformData): 46 (WebCore): 47 (WebCore::FontPlatformData::operator==): 48 * platform/graphics/qt/FontQt.cpp: 49 (WebCore::fillPenForContext): 50 (WebCore::pathForGlyphs): 51 (WebCore::drawQtGlyphRun): 52 (WebCore::Font::drawComplexText): 53 (WebCore::Font::floatWidthForComplexText): 54 (WebCore::Font::offsetForPositionForComplexText): 55 (WebCore::Font::selectionRectForComplexText): 56 (WebCore::Font::initFormatForTextLayout): 57 (WebCore): 58 (WebCore::Font::drawGlyphs): 59 (WebCore::Font::syntheticFont): 60 (WebCore::Font::rawFont): 61 * platform/graphics/qt/FontQt4.cpp: Copied from Source/WebCore/platform/graphics/qt/FontQt.cpp. 62 (WebCore): 63 (WebCore::fromRawDataWithoutRef): 64 (WebCore::setupLayout): 65 (WebCore::fillPenForContext): 66 (WebCore::strokePenForContext): 67 (WebCore::drawTextCommon): 68 (WebCore::Font::drawComplexText): 69 (WebCore::Font::floatWidthForComplexText): 70 (WebCore::Font::offsetForPositionForComplexText): 71 (WebCore::Font::selectionRectForComplexText): 72 (WebCore::Font::canReturnFallbackFontsForComplexText): 73 (WebCore::Font::drawEmphasisMarksForComplexText): 74 (WebCore::Font::drawSimpleText): 75 (WebCore::Font::offsetForPositionForSimpleText): 76 (WebCore::Font::floatWidthForSimpleText): 77 (WebCore::Font::selectionRectForSimpleText): 78 (WebCore::Font::canExpandAroundIdeographsInComplexText): 79 (WebCore::Font::primaryFontHasGlyphForCharacter): 80 (WebCore::Font::emphasisMarkAscent): 81 (WebCore::Font::emphasisMarkDescent): 82 (WebCore::Font::emphasisMarkHeight): 83 (WebCore::Font::drawEmphasisMarksForSimpleText): 84 (WebCore::Font::font): 85 * platform/graphics/qt/SimpleFontDataQt.cpp: 86 (WebCore::SimpleFontData::platformInit): 87 * platform/qt/RenderThemeQt.cpp: 88 (WebCore::RenderThemeQt::fileListNameForWidth): 89 * platform/qt/RenderThemeQtMobile.cpp: 90 (WebCore::RenderThemeQtMobile::computeSizeBasedOnStyle): 91 1 92 2012-04-12 JungJik Lee <jungjik.lee@samsung.com> 2 93 -
trunk/Source/WebCore/Target.pri
r113848 r113968 2827 2827 platform/graphics/qt/TransformationMatrixQt.cpp \ 2828 2828 platform/graphics/qt/ColorQt.cpp \ 2829 platform/graphics/qt/FontQt.cpp \2830 2829 platform/graphics/qt/FontPlatformDataQt.cpp \ 2831 2830 platform/graphics/qt/FloatPointQt.cpp \ … … 3391 3390 } 3392 3391 3393 # QRawFont feature added in Qt 4.8.03392 # QRawFont transition handling. 3394 3393 # 3395 # If available, this is used to implement the fast path for text rendering 3396 # and measurement in WebCore. Because the feature is still undergoing 3397 # development, it is disabled in builds. 3398 # 3399 # exists($$[QT_INSTALL_HEADERS]/QtGui/QRawFont): HAVE_QRAWFONT=1 3400 3401 !isEmpty(HAVE_QRAWFONT) { 3402 DEFINES += HAVE_QRAWFONT=1 3403 3394 # Even though QRawFont was already available in Qt 4.8, it had 3395 # limitations that made switching fully to it impossible. 3396 # We preserve the old code path when building with Qt 4. 3397 3398 contains(DEFINES, HAVE_QRAWFONT=1) { 3404 3399 SOURCES += \ 3400 platform/graphics/qt/FontQt.cpp \ 3405 3401 platform/graphics/FontFastPath.cpp \ 3406 3402 platform/graphics/GlyphPageTreeNode.cpp \ … … 3411 3407 platform/graphics/WidthIterator.h \ 3412 3408 platform/graphics/SurrogatePairAwareTextIterator.h 3409 } else { 3410 SOURCES += \ 3411 platform/graphics/qt/FontQt4.cpp 3413 3412 } 3413 3414 3414 3415 3415 contains(DEFINES, ENABLE_GEOLOCATION=1) { -
trunk/Source/WebCore/platform/graphics/Font.cpp
r108574 r113968 28 28 #include "FontCache.h" 29 29 #include "FontTranscoder.h" 30 #if PLATFORM(QT) && HAVE(QRAWFONT)31 #include "GraphicsContext.h"32 #endif33 30 #include "IntPoint.h" 34 31 #include "GlyphBuffer.h" … … 152 149 CodePath codePathToUse = codePath(run); 153 150 154 #if PLATFORM(QT) && HAVE(QRAWFONT)155 if (context->textDrawingMode() & TextModeStroke)156 codePathToUse = Complex;157 #endif158 159 151 if (codePathToUse != Complex) 160 152 return drawSimpleText(context, run, point, from, to); -
trunk/Source/WebCore/platform/graphics/Font.h
r111589 r113968 37 37 38 38 #if PLATFORM(QT) 39 #if HAVE(QRAWFONT) 40 #include <QRawFont> 41 class QTextLayout; 42 #else 39 43 #include <QFont> 44 #endif 40 45 #endif 41 46 … … 176 181 177 182 #if PLATFORM(QT) 183 #if HAVE(QRAWFONT) 184 QRawFont rawFont() const; 185 #else 178 186 QFont font() const; 187 #endif 188 QFont syntheticFont() const; 179 189 #endif 180 190 … … 254 264 return m_fontList && m_fontList->loadingCustomFonts(); 255 265 } 266 #if PLATFORM(QT) && HAVE(QRAWFONT) 267 void initFormatForTextLayout(QTextLayout*) const; 268 #endif 256 269 257 270 FontDescription m_fontDescription; -
trunk/Source/WebCore/platform/graphics/SimpleFontData.h
r112816 r113968 55 55 56 56 #if PLATFORM(QT) 57 #if !HAVE(QRAWFONT) 57 58 #include <QFont> 59 #else 60 #include <QRawFont> 61 #endif 58 62 #endif 59 63 … … 191 195 192 196 #if PLATFORM(QT) 197 #if !HAVE(QRAWFONT) 193 198 QFont getQtFont() const { return m_platformData.font(); } 199 #else 200 QRawFont getQtRawFont() const { return m_platformData.rawFont(); } 201 #endif // !HAVE(QRAWFONT) 194 202 #endif 195 203 … … 347 355 return width; 348 356 } 349 #endif 357 #endif // HAVE(QRAWFONT) 350 358 351 359 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/qt/FontCacheQt.cpp
r97990 r113968 50 50 51 51 #if HAVE(QRAWFONT) 52 static QRawFont rawFontForCharacters(const QString& string, const Q Font& requestedFont)52 static QRawFont rawFontForCharacters(const QString& string, const QRawFont& font) 53 53 { 54 QFont font(requestedFont); 55 font.setStyleStrategy(QFont::NoFontMerging); 56 57 QTextLayout layout(string, font); 54 QTextLayout layout(string); 55 layout.setRawFont(font); 58 56 layout.beginLayout(); 59 57 layout.createLine(); … … 61 59 62 60 QList<QGlyphRun> glyphList = layout.glyphRuns(); 63 64 ASSERT(glyphList.size() == 1); 61 ASSERT(glyphList.size() <= 1); 62 if (!glyphList.size()) 63 return QRawFont(); 65 64 66 65 const QGlyphRun& glyphs(glyphList.at(0)); 67 QVector<quint32> glyphIndexes = glyphs.glyphIndexes();68 69 if (glyphIndexes.isEmpty())70 return QRawFont();71 72 66 return glyphs.rawFont(); 73 67 } 74 #endif 68 #endif // HAVE(QRAWFONT) 75 69 76 70 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length) … … 78 72 #if HAVE(QRAWFONT) 79 73 QString qstring = QString::fromRawData(reinterpret_cast<const QChar*>(characters), length); 80 QRawFont computedFont = rawFontForCharacters(qstring, font. font());74 QRawFont computedFont = rawFontForCharacters(qstring, font.rawFont()); 81 75 if (!computedFont.isValid()) 82 76 return 0; … … 108 102 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName) 109 103 { 110 #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)111 104 QFontDatabase db; 112 105 if (!db.hasFamily(familyName)) 113 106 return 0; 114 #endif115 107 return new FontPlatformData(fontDescription, familyName); 116 108 } -
trunk/Source/WebCore/platform/graphics/qt/FontCustomPlatformData.h
r80582 r113968 30 30 #include <wtf/Forward.h> 31 31 #include <wtf/Noncopyable.h> 32 #if HAVE(QRAWFONT) 33 #include <QRawFont> 34 #endif 32 35 33 36 namespace WebCore { … … 42 45 ~FontCustomPlatformData(); 43 46 47 #if !HAVE(QRAWFONT) 44 48 // for use with QFontDatabase::addApplicationFont/removeApplicationFont 45 49 int m_handle; 50 #else 51 QRawFont m_rawFont; 52 #endif 46 53 47 54 FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight, -
trunk/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
r80582 r113968 25 25 #include "FontPlatformData.h" 26 26 #include "SharedBuffer.h" 27 #if !HAVE(QRAWFONT) 27 28 #include <QFontDatabase> 29 #endif 28 30 #include <QStringList> 29 31 … … 32 34 FontCustomPlatformData::~FontCustomPlatformData() 33 35 { 36 #if !HAVE(QRAWFONT) 34 37 QFontDatabase::removeApplicationFont(m_handle); 38 #endif 35 39 } 36 40 37 41 FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode) 38 42 { 43 #if !HAVE(QRAWFONT) 39 44 QFont font; 40 45 font.setFamily(QFontDatabase::applicationFontFamilies(m_handle)[0]); … … 43 48 font.setWeight(QFont::Bold); 44 49 font.setItalic(italic); 45 46 50 return FontPlatformData(font); 51 #else 52 Q_ASSERT(m_rawFont.isValid()); 53 m_rawFont.setPixelSize(qreal(size)); 54 return FontPlatformData(m_rawFont); 55 #endif 47 56 } 48 57 … … 51 60 ASSERT_ARG(buffer, buffer); 52 61 53 int id = QFontDatabase::addApplicationFontFromData(QByteArray(buffer->data(), buffer->size())); 62 const QByteArray fontData(buffer->data(), buffer->size()); 63 #if !HAVE(QRAWFONT) 64 int id = QFontDatabase::addApplicationFontFromData(fontData); 54 65 if (id == -1) 55 66 return 0; 56 57 67 Q_ASSERT(QFontDatabase::applicationFontFamilies(id).size() > 0); 68 #endif 58 69 59 70 FontCustomPlatformData *data = new FontCustomPlatformData; 71 #if !HAVE(QRAWFONT) 60 72 data->m_handle = id; 73 #else 74 // Pixel size doesn't matter at this point, it is set in FontCustomPlatformData::fontPlatformData. 75 data->m_rawFont.loadFromData(fontData, /*pixelSize = */0, QFont::PreferDefaultHinting); 76 #endif 61 77 return data; 62 78 } -
trunk/Source/WebCore/platform/graphics/qt/FontPlatformData.h
r86078 r113968 41 41 public: 42 42 FontPlatformDataPrivate() 43 #if !HAVE(QRAWFONT) 43 44 : size(font.pixelSize()) 44 45 , bold(font.bold()) 46 #else 47 : size(0) 48 , bold(false) 49 #endif 45 50 , oblique(false) 46 51 , isDeletedValue(false) … … 52 57 , isDeletedValue(false) 53 58 { } 59 #if !HAVE(QRAWFONT) 54 60 FontPlatformDataPrivate(const QFont& font) 55 61 : font(font) 56 #if HAVE(QRAWFONT)57 , rawFont(QRawFont::fromFont(font, QFontDatabase::Any))58 #endif59 62 , size(font.pixelSize()) 60 63 , bold(font.bold()) … … 62 65 , isDeletedValue(false) 63 66 { } 64 # if HAVE(QRAWFONT)67 #else 65 68 FontPlatformDataPrivate(const QRawFont& rawFont) 66 : font() 67 , rawFont(rawFont) 69 : rawFont(rawFont) 68 70 , size(rawFont.pixelSize()) 69 71 , bold(rawFont.weight() >= QFont::Bold) … … 76 78 { } 77 79 80 #if !HAVE(QRAWFONT) 78 81 QFont font; 79 # if HAVE(QRAWFONT)82 #else 80 83 QRawFont rawFont; 81 84 #endif … … 91 94 FontPlatformData(float size, bool bold, bool oblique); 92 95 FontPlatformData(const FontDescription&, const AtomicString& familyName, int wordSpacing = 0, int letterSpacing = 0); 96 #if !HAVE(QRAWFONT) 93 97 FontPlatformData(const QFont& font) 94 98 : m_data(adoptRef(new FontPlatformDataPrivate(font))) 95 99 { } 96 # if HAVE(QRAWFONT)100 #else 97 101 FontPlatformData(const FontPlatformData&, float size); 98 102 FontPlatformData(const QRawFont& rawFont) … … 113 117 } 114 118 119 #if !HAVE(QRAWFONT) 115 120 QFont font() const 116 121 { … … 120 125 return m_data->font; 121 126 } 122 # if HAVE(QRAWFONT)127 #else 123 128 QRawFont rawFont() const 124 129 { -
trunk/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
r91452 r113968 64 64 : m_data(adoptRef(new FontPlatformDataPrivate())) 65 65 { 66 #if !HAVE(QRAWFONT) 66 67 QFont& font = m_data->font; 68 #else 69 QFont font; 70 #endif 67 71 int requestedSize = description.computedPixelSize(); 68 72 font.setFamily(familyName); … … 72 76 font.setWordSpacing(wordSpacing); 73 77 font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing); 74 const bool smallCaps = description.smallCaps();75 font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);76 78 font.setStyleStrategy(QFont::ForceIntegerMetrics); 77 79 78 80 m_data->bold = font.bold(); 81 #if !HAVE(QRAWFONT) 82 const bool smallCaps = description.smallCaps(); 83 font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase); 79 84 // WebKit allows font size zero but QFont does not. We will return 80 85 // m_data->size if a font size of zero is requested and pixelSize() 81 86 // otherwise. 82 87 m_data->size = (!requestedSize) ? requestedSize : font.pixelSize(); 83 # if HAVE(QRAWFONT)88 #else 84 89 m_data->rawFont = QRawFont::fromFont(font, QFontDatabase::Any); 90 m_data->size = requestedSize; 85 91 #endif 86 92 } … … 90 96 : m_data(adoptRef(new FontPlatformDataPrivate())) 91 97 { 92 m_data->font = other.m_data->font;93 98 m_data->rawFont = other.m_data->rawFont; 94 99 m_data->bold = other.m_data->bold; 95 100 m_data->oblique = other.m_data->oblique; 96 m_data->font.setPixelSize(size);97 101 m_data->rawFont.setPixelSize(size); 98 m_data->size = size ? m_data->font.pixelSize() : 0;102 m_data->size = m_data->rawFont.pixelSize(); 99 103 } 100 #endif 104 #endif // HAVE(QRAWFONT) 101 105 102 106 bool FontPlatformData::operator==(const FontPlatformData& other) const … … 111 115 && m_data->bold == other.m_data->bold 112 116 && m_data->oblique == other.m_data->oblique 117 #if !HAVE(QRAWFONT) 113 118 && m_data->font == other.m_data->font); 119 #else 120 && m_data->rawFont == other.m_data->rawFont); 121 #endif 114 122 return equals; 115 123 } … … 121 129 if (m_data->isDeletedValue) 122 130 return 1; 123 return qHash(m_data->font.toString()) 124 ^ qHash(*reinterpret_cast<quint32*>(&m_data->size)) 125 ^ qHash(m_data->bold) 126 ^ qHash(m_data->oblique); 131 #if !HAVE(QRAWFONT) 132 return (qHash(m_data->font.toString()) ^ qHash(m_data->bold) 133 ^ qHash(m_data->oblique)) 134 ^ qHash(*reinterpret_cast<quint32*>(&m_data->size)); 135 #else 136 return qHash(m_data->rawFont.familyName()) ^ qHash(m_data->rawFont.style()) 137 ^ qHash(m_data->rawFont.weight()) 138 ^ qHash(*reinterpret_cast<quint32*>(&m_data->size)); 139 #endif 127 140 } 128 141 -
trunk/Source/WebCore/platform/graphics/qt/FontQt.cpp
r90919 r113968 1 1 /* 2 Copyright (C) 20 08Nokia Corporation and/or its subsidiary(-ies)2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 3 Copyright (C) 2008, 2010 Holger Hans Peter Freyther 4 4 Copyright (C) 2009 Dirk Schulze <krit@webkit.org> … … 27 27 #include "FontFallbackList.h" 28 28 #include "FontSelector.h" 29 #if HAVE(QRAWFONT)30 29 #include "GlyphBuffer.h" 31 #endif32 30 #include "Gradient.h" 33 31 #include "GraphicsContext.h" … … 38 36 39 37 #include <QBrush> 40 #include <QFontInfo>41 #include <QFontMetrics>42 38 #include <QPainter> 43 39 #include <QPainterPath> 44 40 #include <QPen> 45 #if HAVE(QRAWFONT)46 41 #include <QPointF> 47 #endif48 42 #include <QTextLayout> 49 43 #include <qalgorithms.h> 50 #include <qdebug.h>51 44 52 45 #include <limits.h> … … 93 86 } 94 87 95 return QPen(QColor(ctx->fillColor()) );88 return QPen(QColor(ctx->fillColor()), 0); 96 89 } 97 90 … … 113 106 } 114 107 115 static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to, const QFont& font, bool isComplexText) 116 { 117 if (to < 0) 118 to = run.length(); 119 120 QPainter *p = ctx->platformContext(); 121 122 QPen textFillPen; 123 if (ctx->textDrawingMode() & TextModeFill) 124 textFillPen = fillPenForContext(ctx); 125 126 QPen textStrokePen; 127 if (ctx->textDrawingMode() & TextModeStroke) 128 textStrokePen = strokePenForContext(ctx); 129 108 static QPainterPath pathForGlyphs(const QGlyphRun& glyphRun, const QPointF& offset) 109 { 110 QPainterPath path; 111 const QRawFont rawFont(glyphRun.rawFont()); 112 const QVector<quint32> glyphIndices = glyphRun.glyphIndexes(); 113 const QVector<QPointF> positions = glyphRun.positions(); 114 for (int i = 0; i < glyphIndices.size(); ++i) { 115 QPainterPath glyphPath = rawFont.pathForGlyph(glyphIndices.at(i)); 116 glyphPath.translate(positions.at(i) + offset); 117 path.addPath(glyphPath); 118 } 119 return path; 120 } 121 122 static void drawQtGlyphRun(GraphicsContext* context, const QGlyphRun& qtGlyphRun, const QPointF& point, int baseLineOffset) 123 { 124 QPainter* painter = context->platformContext(); 125 126 QPainterPath textStrokePath; 127 if (context->textDrawingMode() & TextModeStroke) 128 textStrokePath = pathForGlyphs(qtGlyphRun, point); 129 130 ShadowBlur* shadow = context->shadowBlur(); 131 if (context->hasShadow() && shadow->type() != ShadowBlur::NoShadow) { 132 switch (shadow->type()) { 133 case ShadowBlur::SolidShadow: { 134 QPen previousPen = painter->pen(); 135 painter->setPen(context->state().shadowColor); 136 const QPointF shadowOffset(context->state().shadowOffset.width(), context->state().shadowOffset.height()); 137 painter->translate(shadowOffset); 138 if (context->textDrawingMode() & TextModeFill) 139 painter->drawGlyphRun(point, qtGlyphRun); 140 else if (context->textDrawingMode() & TextModeStroke) 141 painter->strokePath(textStrokePath, painter->pen()); 142 painter->translate(-shadowOffset); 143 painter->setPen(previousPen); 144 break; 145 } 146 case ShadowBlur::BlurShadow: { 147 const int width = qtGlyphRun.boundingRect().width(); 148 const QRawFont& font = qtGlyphRun.rawFont(); 149 const int height = font.ascent() + font.descent(); 150 const QRectF boundingRect(point.x(), point.y() - font.ascent() + baseLineOffset, width, height); 151 GraphicsContext* shadowContext = shadow->beginShadowLayer(context, boundingRect); 152 if (shadowContext) { 153 QPainter* shadowPainter = shadowContext->platformContext(); 154 shadowPainter->setPen(shadowContext->state().shadowColor); 155 if (shadowContext->textDrawingMode() & TextModeFill) 156 shadowPainter->drawGlyphRun(point, qtGlyphRun); 157 else if (shadowContext->textDrawingMode() & TextModeStroke) 158 shadowPainter->strokePath(textStrokePath, shadowPainter->pen()); 159 shadow->endShadowLayer(context); 160 } 161 break; 162 } 163 case ShadowBlur::NoShadow: 164 default: 165 ASSERT_NOT_REACHED(); 166 break; 167 } 168 } 169 170 if (context->textDrawingMode() & TextModeStroke) 171 painter->strokePath(textStrokePath, strokePenForContext(context)); 172 173 if (context->textDrawingMode() & TextModeFill) { 174 QPen previousPen = painter->pen(); 175 painter->setPen(fillPenForContext(context)); 176 painter->drawGlyphRun(point, qtGlyphRun); 177 painter->setPen(previousPen); 178 } 179 } 180 181 void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const 182 { 183 String sanitized = Font::normalizeSpaces(run.characters(), run.length()); 184 const QString string = fromRawDataWithoutRef(sanitized); 185 QTextLayout layout(string); 186 layout.setRawFont(rawFont()); 187 initFormatForTextLayout(&layout); 188 QTextLine line = setupLayout(&layout, run); 189 const QPointF adjustedPoint(point.x(), point.y() - line.ascent()); 190 191 QList<QGlyphRun> runs = line.glyphRuns(from, to - from); 192 Q_FOREACH(QGlyphRun glyphRun, runs) 193 drawQtGlyphRun(ctx, glyphRun, adjustedPoint, line.ascent()); 194 } 195 196 float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*, GlyphOverflow*) const 197 { 198 if (!primaryFont()->platformData().size()) 199 return 0; 200 201 if (!run.length()) 202 return 0; 203 204 if (run.length() == 1 && treatAsSpace(run[0])) 205 return primaryFont()->spaceWidth() + run.expansion(); 130 206 String sanitized = Font::normalizeSpaces(run.characters(), run.length()); 131 207 QString string = fromRawDataWithoutRef(sanitized); 132 QPointF pt(point.x(), point.y()); 133 134 if (from > 0 || to < run.length()) { 135 if (isComplexText) { 136 QTextLayout layout(string, font); 137 QTextLine line = setupLayout(&layout, run); 138 float x1 = line.cursorToX(from); 139 float x2 = line.cursorToX(to); 140 if (x2 < x1) 141 qSwap(x1, x2); 142 143 QFontMetrics fm(font); 144 int ascent = fm.ascent(); 145 QRectF boundingRect(point.x() + x1, point.y() - ascent, x2 - x1, fm.height()); 146 QRectF clip = boundingRect; 147 148 ShadowBlur* ctxShadow = ctx->shadowBlur(); 149 if (ctxShadow->type() != ShadowBlur::NoShadow) { 150 const QPointF shadowOffset(ctx->state().shadowOffset.width(), ctx->state().shadowOffset.height()); 151 qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0; 152 if (shadowOffset.x() > 0) 153 dx2 = shadowOffset.x(); 154 else 155 dx1 = -shadowOffset.x(); 156 if (shadowOffset.y() > 0) 157 dy2 = shadowOffset.y(); 158 else 159 dy1 = -shadowOffset.y(); 160 // expand the clip rect to include the text shadow as well 161 const float blurDistance = ctx->state().shadowBlur; 162 clip.adjust(dx1, dx2, dy1, dy2); 163 clip.adjust(-blurDistance, -blurDistance, blurDistance, blurDistance); 164 } 165 p->save(); 166 p->setClipRect(clip.toRect(), Qt::IntersectClip); 167 pt.setY(pt.y() - ascent); 168 169 if (ctxShadow->type() != ShadowBlur::NoShadow) { 170 ShadowBlur* ctxShadow = ctx->shadowBlur(); 171 if (ctxShadow->type() != ShadowBlur::BlurShadow 172 && (!ctxShadow->shadowsIgnoreTransforms() || ctx->getCTM().isIdentity())) { 173 p->save(); 174 p->setPen(ctx->state().shadowColor); 175 p->translate(QPointF(ctx->state().shadowOffset.width(), ctx->state().shadowOffset.height())); 176 line.draw(p, pt); 177 p->restore(); 178 } else { 179 GraphicsContext* shadowContext = ctxShadow->beginShadowLayer(ctx, boundingRect); 180 if (shadowContext) { 181 QPainter* shadowPainter = shadowContext->platformContext(); 182 // Since it will be blurred anyway, we don't care about render hints. 183 shadowPainter->setFont(p->font()); 184 shadowPainter->setPen(ctx->state().shadowColor); 185 line.draw(shadowPainter, pt); 186 ctxShadow->endShadowLayer(ctx); 187 } 188 } 189 } 190 p->setPen(textFillPen); 191 line.draw(p, pt); 192 p->restore(); 193 return; 194 } 195 int skipWidth = QFontMetrics(font).width(string, from, Qt::TextBypassShaping); 196 pt.setX(pt.x() + skipWidth); 197 string = fromRawDataWithoutRef(sanitized, from, to - from); 198 } 199 200 p->setFont(font); 201 202 int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight; 203 if (!isComplexText && !(ctx->textDrawingMode() & TextModeStroke)) 204 flags |= Qt::TextBypassShaping; 205 206 QPainterPath textStrokePath; 207 if (ctx->textDrawingMode() & TextModeStroke) 208 textStrokePath.addText(pt, font, string); 209 210 ShadowBlur* ctxShadow = ctx->shadowBlur(); 211 if (ctx->hasShadow() && ctxShadow->type() != ShadowBlur::NoShadow) { 212 if (ctx->textDrawingMode() & TextModeFill) { 213 if (ctxShadow->type() != ShadowBlur::BlurShadow) { 214 p->save(); 215 p->setPen(ctx->state().shadowColor); 216 p->translate(QPointF(ctx->state().shadowOffset.width(), ctx->state().shadowOffset.height())); 217 p->drawText(pt, string, flags, run.expansion()); 218 p->restore(); 219 } else { 220 QFontMetrics fm(font); 221 QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1, flags), fm.height()); 222 GraphicsContext* shadowContext = ctxShadow->beginShadowLayer(ctx, boundingRect); 223 if (shadowContext) { 224 QPainter* shadowPainter = shadowContext->platformContext(); 225 // Since it will be blurred anyway, we don't care about render hints. 226 shadowPainter->setFont(p->font()); 227 shadowPainter->setPen(ctx->state().shadowColor); 228 shadowPainter->drawText(pt, string, flags, run.expansion()); 229 ctxShadow->endShadowLayer(ctx); 230 } 231 } 232 } else if (ctx->textDrawingMode() & TextModeStroke) { 233 if (ctxShadow->type() != ShadowBlur::BlurShadow) { 234 const QPointF shadowOffset(ctx->state().shadowOffset.width(), ctx->state().shadowOffset.height()); 235 p->translate(shadowOffset); 236 p->strokePath(textStrokePath, QPen(ctx->state().shadowColor)); 237 p->translate(-shadowOffset); 238 } else { 239 QFontMetrics fm(font); 240 QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1, flags), fm.height()); 241 GraphicsContext* shadowContext = ctxShadow->beginShadowLayer(ctx, boundingRect); 242 if (shadowContext) { 243 QPainter* shadowPainter = shadowContext->platformContext(); 244 // Since it will be blurred anyway, we don't care about render hints. 245 shadowPainter->setFont(p->font()); 246 shadowPainter->strokePath(textStrokePath, QPen(ctx->state().shadowColor)); 247 ctxShadow->endShadowLayer(ctx); 248 } 249 } 250 } 251 } 252 253 if (ctx->textDrawingMode() & TextModeStroke) 254 p->strokePath(textStrokePath, textStrokePen); 255 256 if (ctx->textDrawingMode() & TextModeFill) { 257 QPen previousPen = p->pen(); 258 p->setPen(textFillPen); 259 p->drawText(pt, string, flags, run.expansion()); 260 p->setPen(previousPen); 261 } 262 } 263 264 void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const 265 { 266 drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */true); 267 } 268 269 float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*, GlyphOverflow*) const 270 { 271 if (!primaryFont()->platformData().size()) 272 return 0; 273 274 if (!run.length()) 275 return 0; 276 277 if (run.length() == 1 && treatAsSpace(run[0])) 278 return QFontMetrics(font()).width(space) + run.expansion(); 279 208 209 QTextLayout layout(string); 210 layout.setRawFont(rawFont()); 211 initFormatForTextLayout(&layout); 212 QTextLine line = setupLayout(&layout, run); 213 float x1 = line.cursorToX(0); 214 float x2 = line.cursorToX(run.length()); 215 const float width = qAbs(x2 - x1); 216 217 return width + run.expansion(); 218 } 219 220 int Font::offsetForPositionForComplexText(const TextRun& run, float position, bool) const 221 { 280 222 String sanitized = Font::normalizeSpaces(run.characters(), run.length()); 281 223 QString string = fromRawDataWithoutRef(sanitized); 282 224 283 int w = QFontMetrics(font()).width(string); 284 // WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does) 285 if (treatAsSpace(run[0])) 286 w -= m_wordSpacing; 287 288 return w + run.expansion(); 289 } 290 291 int Font::offsetForPositionForComplexText(const TextRun& run, float position, bool) const 225 QTextLayout layout(string); 226 layout.setRawFont(rawFont()); 227 initFormatForTextLayout(&layout); 228 QTextLine line = setupLayout(&layout, run); 229 return line.xToCursor(position); 230 } 231 232 FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& pt, int h, int from, int to) const 292 233 { 293 234 String sanitized = Font::normalizeSpaces(run.characters(), run.length()); 294 235 QString string = fromRawDataWithoutRef(sanitized); 295 236 296 QTextLayout layout(string, font()); 297 QTextLine line = setupLayout(&layout, run); 298 return line.xToCursor(position); 299 } 300 301 FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& pt, int h, int from, int to) const 302 { 303 String sanitized = Font::normalizeSpaces(run.characters(), run.length()); 304 QString string = fromRawDataWithoutRef(sanitized); 305 306 QTextLayout layout(string, font()); 237 QTextLayout layout(string); 238 layout.setRawFont(rawFont()); 239 initFormatForTextLayout(&layout); 307 240 QTextLine line = setupLayout(&layout, run); 308 241 … … 315 248 } 316 249 250 void Font::initFormatForTextLayout(QTextLayout* layout) const 251 { 252 QTextLayout::FormatRange range; 253 range.start = 0; 254 range.length = layout->text().length(); 255 if (m_wordSpacing) 256 range.format.setFontWordSpacing(m_wordSpacing); 257 if (m_letterSpacing) 258 range.format.setFontLetterSpacing(m_letterSpacing); 259 if (typesettingFeatures() & Kerning) 260 range.format.setFontKerning(true); 261 if (isSmallCaps()) 262 range.format.setFontCapitalization(QFont::SmallCaps); 263 264 if (range.format.propertyCount()) 265 layout->setAdditionalFormats(QList<QTextLayout::FormatRange>() << range); 266 } 267 317 268 bool Font::canReturnFallbackFontsForComplexText() 318 269 { … … 325 276 } 326 277 327 #if HAVE(QRAWFONT)328 278 void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const 329 279 { … … 334 284 bool shouldStroke = context->textDrawingMode() & TextModeStroke; 335 285 336 // Stroking text should always take the complex path.337 ASSERT(!shouldStroke);338 339 286 if (!shouldFill && !shouldStroke) 340 287 return; … … 345 292 glyphIndexes.reserve(numGlyphs); 346 293 positions.reserve(numGlyphs); 294 const QRawFont& font(fontData->getQtRawFont()); 347 295 348 296 float width = 0; … … 358 306 } 359 307 360 QRawFont rawFont(fontData->platformData().rawFont());361 362 308 QGlyphRun qtGlyphs; 363 309 qtGlyphs.setGlyphIndexes(glyphIndexes); 364 310 qtGlyphs.setPositions(positions); 365 qtGlyphs.setRawFont(rawFont); 366 367 QPainter* painter = context->platformContext(); 368 369 ShadowBlur* shadow = context->shadowBlur(); 370 switch (shadow->type()) { 371 case ShadowBlur::SolidShadow: { 372 QPen previousPen = painter->pen(); 373 painter->setPen(context->state().shadowColor); 374 const QPointF shadowOffset(context->state().shadowOffset.width(), context->state().shadowOffset.height()); 375 painter->translate(shadowOffset); 376 painter->drawGlyphRun(point, qtGlyphs); 377 painter->translate(-shadowOffset); 378 painter->setPen(previousPen); 379 break; 380 } 381 case ShadowBlur::BlurShadow: { 382 qreal height = rawFont.ascent() + rawFont.descent() + 1; 383 QRectF boundingRect(point.x(), point.y() - rawFont.ascent(), width, height); 384 GraphicsContext* shadowContext = shadow->beginShadowLayer(context, boundingRect); 385 if (shadowContext) { 386 QPainter* shadowPainter = shadowContext->platformContext(); 387 shadowPainter->setPen(context->state().shadowColor); 388 shadowPainter->drawGlyphRun(point, qtGlyphs); 389 shadow->endShadowLayer(context); 390 } 391 break; 392 } 393 case ShadowBlur::NoShadow: 394 break; 395 default: 396 ASSERT_NOT_REACHED(); 397 break; 398 } 399 400 QPen previousPen = painter->pen(); 401 painter->setPen(fillPenForContext(context)); 402 painter->drawGlyphRun(point, qtGlyphs); 403 painter->setPen(previousPen); 404 } 311 qtGlyphs.setRawFont(font); 312 313 drawQtGlyphRun(context, qtGlyphs, point, /* baselineOffset = */0); 314 } 315 405 316 406 317 bool Font::canExpandAroundIdeographsInComplexText() … … 409 320 } 410 321 411 #else // !HAVE(QRAWFONT) 412 413 void Font::drawSimpleText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const 414 { 415 drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */false); 416 } 417 418 int Font::offsetForPositionForSimpleText(const TextRun& run, float position, bool includePartialGlyphs) const 419 { 420 String sanitized = Font::normalizeSpaces(run.characters(), run.length()); 421 QString string = fromRawDataWithoutRef(sanitized); 422 423 QFontMetrics fm(font()); 424 float delta = position; 425 int curPos = 0; 426 do { 427 float charWidth = fm.width(string[curPos]); 428 delta -= charWidth; 429 if (includePartialGlyphs) { 430 if (delta + charWidth / 2 <= 0) 431 break; 432 } else { 433 if (delta + charWidth <= 0) 434 break; 435 } 436 } while (++curPos < string.size()); 437 438 return curPos; 439 } 440 441 442 float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const 443 { 444 if (!primaryFont()->platformData().size()) 445 return 0; 446 447 if (!run.length()) 448 return 0; 449 450 String sanitized = Font::normalizeSpaces(run.characters(), run.length()); 451 QString string = fromRawDataWithoutRef(sanitized); 452 453 int w = QFontMetrics(font()).width(string, -1, Qt::TextBypassShaping); 454 455 // WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does) 456 if (treatAsSpace(run[0])) 457 w -= m_wordSpacing; 458 459 return w + run.expansion(); 460 } 461 462 463 FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& pt, int h, int from, int to) const 464 { 465 String sanitized = Font::normalizeSpaces(run.characters(), run.length()); 466 QString wholeText = fromRawDataWithoutRef(sanitized); 467 QString selectedText = fromRawDataWithoutRef(sanitized, from, qMin(to - from, wholeText.length() - from)); 468 469 int startX = QFontMetrics(font()).width(wholeText, from, Qt::TextBypassShaping); 470 int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping); 471 472 return FloatRect(pt.x() + startX, pt.y(), width, h); 473 } 474 475 bool Font::canExpandAroundIdeographsInComplexText() 476 { 477 return false; 478 } 479 480 bool Font::primaryFontHasGlyphForCharacter(UChar32) const 481 { 482 notImplemented(); 483 return true; 484 } 485 486 int Font::emphasisMarkAscent(const AtomicString&) const 487 { 488 notImplemented(); 489 return 0; 490 } 491 492 int Font::emphasisMarkDescent(const AtomicString&) const 493 { 494 notImplemented(); 495 return 0; 496 } 497 498 int Font::emphasisMarkHeight(const AtomicString&) const 499 { 500 notImplemented(); 501 return 0; 502 } 503 504 void Font::drawEmphasisMarksForSimpleText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const 505 { 506 notImplemented(); 507 } 508 #endif // HAVE(QRAWFONT) 509 510 QFont Font::font() const 511 { 512 QFont f = primaryFont()->getQtFont(); 513 if (m_letterSpacing != 0) 322 QFont Font::syntheticFont() const 323 { 324 QRawFont rawFont(primaryFont()->getQtRawFont()); 325 QFont f(rawFont.familyName()); 326 if (rawFont.pixelSize()) 327 f.setPixelSize(rawFont.pixelSize()); 328 f.setWeight(rawFont.weight()); 329 f.setStyle(rawFont.style()); 330 if (m_letterSpacing) 514 331 f.setLetterSpacing(QFont::AbsoluteSpacing, m_letterSpacing); 515 if (m_wordSpacing != 0)332 if (m_wordSpacing) 516 333 f.setWordSpacing(m_wordSpacing); 517 334 return f; … … 519 336 520 337 521 } 522 338 QRawFont Font::rawFont() const 339 { 340 return primaryFont()->getQtRawFont(); 341 } 342 343 } -
trunk/Source/WebCore/platform/graphics/qt/FontQt4.cpp
r113967 r113968 27 27 #include "FontFallbackList.h" 28 28 #include "FontSelector.h" 29 #if HAVE(QRAWFONT)30 29 #include "GlyphBuffer.h" 31 #endif32 30 #include "Gradient.h" 33 31 #include "GraphicsContext.h" … … 43 41 #include <QPainterPath> 44 42 #include <QPen> 45 #if HAVE(QRAWFONT)46 #include <QPointF>47 #endif48 43 #include <QTextLayout> 44 #include <limits.h> 49 45 #include <qalgorithms.h> 50 46 #include <qdebug.h> 51 47 52 #include <limits.h>53 48 54 49 namespace WebCore { … … 73 68 layout->beginLayout(); 74 69 QTextLine line = layout->createLine(); 75 line.setLineWidth(INT_MAX /256);70 line.setLineWidth(INT_MAX / 256); 76 71 if (style.expansion()) 77 72 line.setLineWidth(line.naturalTextWidth() + style.expansion()); … … 118 113 to = run.length(); 119 114 120 QPainter *p = ctx->platformContext();115 QPainter* p = ctx->platformContext(); 121 116 122 117 QPen textFillPen; … … 325 320 } 326 321 327 #if HAVE(QRAWFONT)328 void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const329 {330 if (context->paintingDisabled())331 return;332 333 bool shouldFill = context->textDrawingMode() & TextModeFill;334 bool shouldStroke = context->textDrawingMode() & TextModeStroke;335 336 // Stroking text should always take the complex path.337 ASSERT(!shouldStroke);338 339 if (!shouldFill && !shouldStroke)340 return;341 342 QVector<quint32> glyphIndexes;343 QVector<QPointF> positions;344 345 glyphIndexes.reserve(numGlyphs);346 positions.reserve(numGlyphs);347 348 float width = 0;349 350 for (int i = 0; i < numGlyphs; ++i) {351 Glyph glyph = glyphBuffer.glyphAt(from + i);352 float advance = glyphBuffer.advanceAt(from + i);353 if (!glyph)354 continue;355 glyphIndexes.append(glyph);356 positions.append(QPointF(width, 0));357 width += advance;358 }359 360 QRawFont rawFont(fontData->platformData().rawFont());361 362 QGlyphRun qtGlyphs;363 qtGlyphs.setGlyphIndexes(glyphIndexes);364 qtGlyphs.setPositions(positions);365 qtGlyphs.setRawFont(rawFont);366 367 QPainter* painter = context->platformContext();368 369 ShadowBlur* shadow = context->shadowBlur();370 switch (shadow->type()) {371 case ShadowBlur::SolidShadow: {372 QPen previousPen = painter->pen();373 painter->setPen(context->state().shadowColor);374 const QPointF shadowOffset(context->state().shadowOffset.width(), context->state().shadowOffset.height());375 painter->translate(shadowOffset);376 painter->drawGlyphRun(point, qtGlyphs);377 painter->translate(-shadowOffset);378 painter->setPen(previousPen);379 break;380 }381 case ShadowBlur::BlurShadow: {382 qreal height = rawFont.ascent() + rawFont.descent() + 1;383 QRectF boundingRect(point.x(), point.y() - rawFont.ascent(), width, height);384 GraphicsContext* shadowContext = shadow->beginShadowLayer(context, boundingRect);385 if (shadowContext) {386 QPainter* shadowPainter = shadowContext->platformContext();387 shadowPainter->setPen(context->state().shadowColor);388 shadowPainter->drawGlyphRun(point, qtGlyphs);389 shadow->endShadowLayer(context);390 }391 break;392 }393 case ShadowBlur::NoShadow:394 break;395 default:396 ASSERT_NOT_REACHED();397 break;398 }399 400 QPen previousPen = painter->pen();401 painter->setPen(fillPenForContext(context));402 painter->drawGlyphRun(point, qtGlyphs);403 painter->setPen(previousPen);404 }405 406 bool Font::canExpandAroundIdeographsInComplexText()407 {408 return false;409 }410 411 #else // !HAVE(QRAWFONT)412 413 322 void Font::drawSimpleText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const 414 323 { … … 506 415 notImplemented(); 507 416 } 508 #endif // HAVE(QRAWFONT)509 417 510 418 QFont Font::font() const 511 419 { 512 420 QFont f = primaryFont()->getQtFont(); 513 if (m_letterSpacing != 0)421 if (m_letterSpacing) 514 422 f.setLetterSpacing(QFont::AbsoluteSpacing, m_letterSpacing); 515 if (m_wordSpacing != 0)423 if (m_wordSpacing) 516 424 f.setWordSpacing(m_wordSpacing); 517 425 return f; 518 426 } 519 427 520 521 } 522 428 QFont Font::syntheticFont() const 429 { 430 return font(); 431 } 432 433 } 434 -
trunk/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
r108788 r113968 135 135 float ascent = rawFont.ascent(); 136 136 float xHeight = rawFont.xHeight(); 137 float lineSpacing = ascent + descent + rawFont.leading() + 1;137 float lineSpacing = ascent + descent + rawFont.leading(); 138 138 139 139 QVector<quint32> indexes = rawFont.glyphIndexesForString(QLatin1String(" ")); … … 166 166 167 167 m_fontMetrics.setAscent(ascent); 168 m_fontMetrics.setDescent(descent); 168 // WebKit expects the descent to be positive. 169 m_fontMetrics.setDescent(qAbs(descent)); 169 170 m_fontMetrics.setLineSpacing(lineSpacing); 170 171 m_fontMetrics.setXHeight(xHeight); -
trunk/Source/WebCore/platform/qt/RenderThemeQt.cpp
r113484 r113968 881 881 else if (fileList->length() == 1) { 882 882 String fname = fileList->item(0)->path(); 883 QFontMetrics fm(font. font());883 QFontMetrics fm(font.syntheticFont()); 884 884 string = fm.elidedText(fname, Qt::ElideLeft, width); 885 885 } else { -
trunk/Source/WebCore/platform/qt/RenderThemeQtMobile.cpp
r113532 r113968 46 46 #include <QColor> 47 47 #include <QFile> 48 #include <QFontMetrics>49 48 #include <QPainter> 50 49 #include <QPixmapCache> … … 582 581 { 583 582 QSize size(0, 0); 584 const QFontMetrics fm(renderStyle->font().font());585 583 586 584 switch (renderStyle->appearance()) { … … 618 616 case ButtonPart: 619 617 case MenulistPart: { 620 const int height = fm.height() * buttonHeightRatio * renderStyle->effectiveZoom();618 const int height = renderStyle->fontMetrics().height() * buttonHeightRatio * renderStyle->effectiveZoom(); 621 619 size = QSize(renderStyle->width().value(), height); 622 620 break; -
trunk/Source/WebKit/qt/Api/qwebpage.cpp
r113361 r113968 1393 1393 if (renderTextControl) { 1394 1394 RenderStyle* renderStyle = renderTextControl->style(); 1395 return QVariant(QFont(renderStyle->font(). font()));1395 return QVariant(QFont(renderStyle->font().syntheticFont())); 1396 1396 } 1397 1397 return QVariant(QFont()); -
trunk/Source/WebKit/qt/ChangeLog
r113484 r113968 1 2012-03-05 Pierre Rossi <pierre.rossi@gmail.com> 2 3 [Qt] Use QRawFont when building with Qt 5 4 https://bugs.webkit.org/show_bug.cgi?id=78001 5 6 Since QFont is not used internally, we now need 7 to query for a QFont that should be a good 8 enough match. 9 10 Reviewed by Simon Hausmann. 11 12 * Api/qwebpage.cpp: 13 (QWebPage::inputMethodQuery): 14 * WebCoreSupport/PopupMenuQt.cpp: 15 (WebCore::PopupMenuQt::show): 16 * WebCoreSupport/RenderThemeQStyle.cpp: 17 (WebCore::RenderThemeQStyle::computeSizeBasedOnStyle): 18 1 19 2012-04-06 Levi Weintraub <leviw@chromium.org> 2 20 -
trunk/Source/WebKit/qt/WebCoreSupport/PopupMenuQt.cpp
r102419 r113968 104 104 geometry.moveTopLeft(view->contentsToWindow(rect.location())); 105 105 m_popup->setGeometry(geometry); 106 m_popup->setFont(m_popupClient->menuStyle().font(). font());106 m_popup->setFont(m_popupClient->menuStyle().font().syntheticFont()); 107 107 108 108 m_selectData = adoptPtr(new SelectData(m_popupClient)); -
trunk/Source/WebKit/qt/WebCoreSupport/RenderThemeQStyle.cpp
r113484 r113968 210 210 { 211 211 QSize size(0, 0); 212 const QFontMetrics fm(renderStyle->font(). font());212 const QFontMetrics fm(renderStyle->font().syntheticFont()); 213 213 QStyle* style = qStyle(); 214 214 -
trunk/Tools/ChangeLog
r113966 r113968 1 2012-03-05 Pierre Rossi <pierre.rossi@gmail.com> 2 3 [Qt] Use QRawFont when building with Qt 5 4 https://bugs.webkit.org/show_bug.cgi?id=78001 5 6 Flip the QRawFont switch for Qt 5. 7 8 Reviewed by Simon Hausmann. 9 10 * qmake/mkspecs/features/features.prf: 11 1 12 2012-04-11 Vivek Galatage <vivekgalatage@gmail.com> 2 13 -
trunk/Tools/qmake/mkspecs/features/features.prf
r113853 r113968 44 44 DEFINES -= WTF_USE_ICU_UNICODE 45 45 } 46 47 # Use of QRawFont in Qt 5: 48 haveQt(5): DEFINES += HAVE_QRAWFONT=1 46 49 47 50 isEmpty(HAVE_QRAWFONT) { … … 231 234 DEFINES += ENABLE_JAVASCRIPT_DEBUGGER=0 232 235 } 233 234 236 haveQt(4) { 235 237 haveQtModule(declarative): DEFINES += HAVE_QQUICK1=1
Note: See TracChangeset
for help on using the changeset viewer.