summaryrefslogtreecommitdiff
path: root/src/3rdparty/webkit/WebCore
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2010-06-24 15:18:58 +0200
committerJørgen Lind <jorgen.lind@nokia.com>2010-06-24 15:18:58 +0200
commit9ecd67ee21ededfbd262279ebdb73324540f5df4 (patch)
tree5387e993b3befdf6255b9cf2b724189f11e73738 /src/3rdparty/webkit/WebCore
parentbd337d251a3ff54c6845f1c4469ec7c99068971e (diff)
parent3555687f5ff270c61499a5597444895bec0d70fb (diff)
downloadqt4-tools-9ecd67ee21ededfbd262279ebdb73324540f5df4.tar.gz
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into lighthouse
Diffstat (limited to 'src/3rdparty/webkit/WebCore')
-rw-r--r--src/3rdparty/webkit/WebCore/ChangeLog359
-rw-r--r--src/3rdparty/webkit/WebCore/WebCore.gypi4
-rw-r--r--src/3rdparty/webkit/WebCore/WebCore.pro2
-rw-r--r--src/3rdparty/webkit/WebCore/html/HTMLInputElement.h4
-rw-r--r--src/3rdparty/webkit/WebCore/page/EventHandler.cpp3
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp104
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/Font.h32
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp88
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.cpp (renamed from src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.cpp)22
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.h (renamed from src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.h)57
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp8
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h31
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp21
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h13
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp190
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp24
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp10
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp18
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp17
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp34
-rw-r--r--src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h10
-rw-r--r--src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h7
-rw-r--r--src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp31
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp44
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp50
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h14
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp12
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/RenderText.cpp58
-rw-r--r--src/3rdparty/webkit/WebCore/rendering/RenderText.h10
29 files changed, 969 insertions, 308 deletions
diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog
index c17a8aa8a1..687b76bee7 100644
--- a/src/3rdparty/webkit/WebCore/ChangeLog
+++ b/src/3rdparty/webkit/WebCore/ChangeLog
@@ -1,3 +1,362 @@
+2010-06-22 Simon Hausmann <simon.hausmann@nokia.com>
+
+ Unreviewed Qt/Symbian build fix.
+
+ Fix "make clean" to not try to execute clean commands for
+ the extra targets we use to simulate "make install".
+
+ * WebCore.pro: Use no_clean in CONFIG of extra compilers.
+
+2010-06-21 Balazs Kelemen <kb@inf.u-szeged.hu>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Avoid unnecessary image conversion in RGBA32Buffer::zeroFill()
+ https://bugs.webkit.org/show_bug.cgi?id=40910
+
+ * platform/image-decoders/qt/RGBA32BufferQt.cpp:
+ (WebCore::RGBA32Buffer::zeroFill):
+
+2010-05-31 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Implement the simple text code path.
+ https://bugs.webkit.org/show_bug.cgi?id=40077
+
+ Remove the FONT_FAST_PATH macro and use the Qt's
+ fast text implementation instead of the one of WebKit.
+
+ The Qt::TextBypassShaping flag is used to tell Qt to
+ only use the glyph advances.
+
+ Qt 4.7 is needed to get this flag thus the complex path is always
+ used if QtWebKit is compiled against an earlier version.
+
+ Contrary to the WebKit's implementation, the complex code path
+ is taken if the text is RightToLeft, justified or is formatted
+ with non-zero letter or word spacing.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::drawText):
+ (WebCore::Font::floatWidth):
+ (WebCore::Font::selectionRectForText):
+ (WebCore::Font::offsetForPosition):
+ * platform/graphics/Font.h:
+ (WebCore::Font::isRoundingHackCharacter):
+ * platform/graphics/qt/FontQt.cpp:
+ (WebCore::fromRawDataWithoutRef):
+ (WebCore::needComplexCodePath):
+ (WebCore::setupPlatformContext):
+ (WebCore::Font::canReturnFallbackFontsForComplexText):
+ (WebCore::Font::drawSimpleText):
+ (WebCore::Font::drawComplexText):
+ (WebCore::Font::floatWidthForSimpleText):
+ (WebCore::Font::offsetForPositionForSimpleText):
+ (WebCore::Font::selectionRectForSimpleText):
+
+2010-06-03 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ Move the text code path detection code from FontFastPath.cpp to Font.cpp.
+ https://bugs.webkit.org/show_bug.cgi?id=40077
+
+ This is a patch preliminary to the implementation of the
+ simple font code path for the Qt port.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::setCodePath):
+ (WebCore::Font::codePath):
+ * platform/graphics/Font.h:
+ * platform/graphics/FontFastPath.cpp:
+
+2010-04-30 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Adele Peterson.
+
+ Part of <rdar://problem/6649734> Text repainting does not account for glyphs which draw outside the typographic bounds of the font
+ https://bugs.webkit.org/show_bug.cgi?id=6274
+
+ Account for glyph overflow of characters in the range U+1E00..U+2000, but without sending them
+ through the complex text code path. Instead, introduce a variant of the fast path that tracks
+ glyph overflow.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::drawText): Use codePath().
+ (WebCore::Font::floatWidth): Use codePath(). Pass the GlyphOverflow pointer through to
+ floatWidthForSimpleText() if the code path is SimpleWithGlyphOverflow.
+ (WebCore::Font::selectionRectForText): Use codePath().
+ (WebCore::Font::offsetForPosition): Ditto.
+ * platform/graphics/Font.h: Replaced canUseGlyphCache() with codePath(). Added a GlyphOverflow
+ parameter to floatWidthForSimpleText().
+ * platform/graphics/FontFastPath.cpp:
+ Removed ROMAN_AND_GREEK_DIACRITICS_CAN_USE_GLYPH_CACHE.
+ (WebCore::Font::codePath): Renamed canUseGlyphCache() to this. Where it used to return false,
+ it now returns Complex. Where it used to return true, it now returns Simple, except for
+ the range U+1E00..U+2000, where it now returns SimpleWithGlyphOverflow.
+ (WebCore::Font::floatWidthForSimpleText): Added a GlyphOverflow parameter. If not 0, have the
+ width iterator account for glyph bounds, then update the GlyphOverflow accordingly.
+ * platform/graphics/WidthIterator.cpp:
+ (WebCore::WidthIterator::WidthIterator): Added boolean parameter telling the width iterator
+ whether to account for glyph bounds. Initialize m_accountForGlyphBounds accordingly. Initialize
+ m_maxGlyphBoundingBoxY, m_minGlyphBoundingBoxY, m_firstGlyphOverflow and m_lastGlyphOverflow.
+ (WebCore::WidthIterator::advance): If accounting for glyph bounds, update the above member variables.
+ * platform/graphics/WidthIterator.h:
+ (WebCore::WidthIterator::maxGlyphBoundingBoxY): Added this accessor.
+ (WebCore::WidthIterator::minGlyphBoundingBoxY): Ditto.
+ (WebCore::WidthIterator::firstGlyphOverflow): Ditto.
+ (WebCore::WidthIterator::lastGlyphOverflow): Ditto.
+
+2010-04-21 Ojan Vafai <ojan@chromium.org>
+
+ Reviewed by Adele Peterson.
+
+ http://trac.webkit.org/changeset/57215 caused perf/memory regressions
+ https://bugs.webkit.org/show_bug.cgi?id=37292
+
+ #if out the canUseGlyphCache Changes from r57215 as they caused a
+ 8% perf regression on Chromium's international page load tests so that
+ the perf regression can be fixed properly without being left in the tree.
+
+ * platform/graphics/FontFastPath.cpp:
+ (WebCore::Font::canUseGlyphCache):
+
+2010-04-07 Enrica Casucci <enrica@apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ Text repainting does not account for glyphs which draw outside the typographic bounds of the font (6274).
+ <rdar://problem/6649734>
+ <https://bugs.webkit.org/show_bug.cgi?id=6274>
+
+ In order to be able to handle successfully this case, it is necessary to change the glyph width cache to store
+ the bounding box for the glyph instead of the simply caching the glyph width.
+ Retrieving the bounding box for the glyph is expensive, therefore we do it only
+ when we are rendering text using the complex text path to minimize the performance impact.
+ To support characters with stacked diacritics, the method canUseGlyphCache has been modified to
+ return false for the range of characters with stacked diacritics.
+ The glyph cache has been also updated to allow storing the glyph bounding box together with the
+ horizontal width. The bounding box is populated only for complex text.
+
+ The original version of this patch has been written by Dan Bernstein.
+
+ Test: fast/repaint/stacked-diacritics.html
+
+ * Android.mk: File name change.
+ * GNUmakefile.am: File name change.
+ * WebCore.base.exp: Added parameter in exported function.
+ * WebCore.gypi: File name change.
+ * WebCore.vcproj/WebCore.vcproj: File name change.
+ * WebCore.xcodeproj/project.pbxproj: File name change.
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::floatWidth): Added glyphOverflow parameter.
+ * platform/graphics/Font.h:
+ (WebCore::GlyphOverflow::GlyphOverflow): Added.
+ (WebCore::Font::width): Added glyphOverflow parameter.
+ * platform/graphics/FontFastPath.cpp:
+ (WebCore::Font::canUseGlyphCache): Modified to render characters with stacked diacritics with complex text path.
+ * platform/graphics/GlyphMetricsMap.cpp: Copied from WebCore/platform/graphics/GlyphWidthMap.cpp.
+ (WebCore::GlyphMetricsMap::locatePageSlowCase): Class name changed to reflect new semantics.
+ * platform/graphics/GlyphMetricsMap.h: Copied from WebCore/platform/graphics/GlyphWidthMap.h.
+ (WebCore::GlyphMetricsMap::GlyphMetricsMap):
+ (WebCore::GlyphMetricsMap::~GlyphMetricsMap):
+ (WebCore::GlyphMetricsMap::metricsForGlyph):
+ (WebCore::GlyphMetricsMap::widthForGlyph):
+ (WebCore::GlyphMetricsMap::setMetricsForGlyph):
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::metricsForGlyph):
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::setMetricsForGlyph):
+ (WebCore::GlyphMetricsMap::GlyphMetricsPage::setMetricsForIndex):
+ (WebCore::GlyphMetricsMap::locatePage):
+ * platform/graphics/GlyphWidthMap.cpp: Removed.
+ * platform/graphics/GlyphWidthMap.h: Removed.
+ * platform/graphics/SimpleFontData.cpp:
+ (WebCore::SimpleFontData::platformGlyphInit):
+ * platform/graphics/SimpleFontData.h:
+ (WebCore::):
+ (WebCore::SimpleFontData::widthForGlyph):
+ (WebCore::SimpleFontData::metricsForGlyph):
+ * platform/graphics/cairo/SimpleFontDataCairo.cpp:
+ (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change.
+ * platform/graphics/chromium/FontChromiumWin.cpp:
+ (WebCore::Font::floatWidthForComplexText): Added parameter.
+ * platform/graphics/chromium/FontLinux.cpp:
+ (WebCore::Font::floatWidthForComplexText): Added parameter.
+ * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp:
+ (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change.
+ * platform/graphics/chromium/SimpleFontDataLinux.cpp:
+ (WebCore::SimpleFontData::platformWidthForGlyph): Name and signature vachange
+ * platform/graphics/efl/FontEfl.cpp:
+ (WebCore::Font::floatWidthForComplexText): Name and signature change.
+ * platform/graphics/gtk/SimpleFontDataPango.cpp:
+ (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change.
+ * platform/graphics/haiku/FontHaiku.cpp:
+ (WebCore::Font::floatWidthForComplexText): Added parameter.
+ * platform/graphics/haiku/SimpleFontDataHaiku.cpp:
+ (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change.
+ * platform/graphics/mac/ComplexTextController.cpp:
+ (WebCore::ComplexTextController::ComplexTextController):
+ (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+ * platform/graphics/mac/ComplexTextController.h:
+ (WebCore::ComplexTextController::minGlyphBoundingBoxX):
+ (WebCore::ComplexTextController::maxGlyphBoundingBoxX):
+ (WebCore::ComplexTextController::minGlyphBoundingBoxY):
+ (WebCore::ComplexTextController::maxGlyphBoundingBoxY):
+ * platform/graphics/mac/FontComplexTextMac.cpp:
+ (WebCore::Font::floatWidthForComplexText): Added paramter.
+ * platform/graphics/mac/SimpleFontDataMac.mm:
+ (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change.
+ * platform/graphics/qt/FontQt.cpp:
+ (WebCore::Font::floatWidthForComplexText): Added paramter.
+ * platform/graphics/win/FontWin.cpp:
+ (WebCore::Font::floatWidthForComplexText): Added parameter.
+ * platform/graphics/win/SimpleFontDataCGWin.cpp:
+ (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change.
+ * platform/graphics/win/SimpleFontDataWin.cpp:
+ (WebCore::SimpleFontData::metricsForGDIGlyph):
+ * platform/graphics/win/UniscribeController.cpp:
+ (WebCore::UniscribeController::UniscribeController):
+ (WebCore::UniscribeController::shapeAndPlaceItem):
+ * platform/graphics/win/UniscribeController.h:
+ (WebCore::UniscribeController::minGlyphBoundingBoxX):
+ (WebCore::UniscribeController::maxGlyphBoundingBoxX):
+ (WebCore::UniscribeController::minGlyphBoundingBoxY):
+ (WebCore::UniscribeController::maxGlyphBoundingBoxY):
+ * platform/graphics/wince/FontWince.cpp:
+ (WebCore::Font::floatWidthForComplexText): Added parameter.
+ * platform/graphics/wx/FontWx.cpp:
+ (WebCore::Font::floatWidthForComplexText): Added parameter.
+ * platform/graphics/wx/SimpleFontDataWx.cpp:
+ (WebCore::SimpleFontData::platformMetricsForGlyph): Name and signature change.
+ * rendering/InlineFlowBox.cpp:
+ (WebCore::InlineFlowBox::placeBoxesHorizontally):
+ (WebCore::InlineFlowBox::computeLogicalBoxHeights):
+ (WebCore::InlineFlowBox::computeVerticalOverflow):
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::setFallbackFonts):
+ (WebCore::InlineTextBox::fallbackFonts):
+ (WebCore::InlineTextBox::setGlyphOverflow):
+ (WebCore::InlineTextBox::glyphOverflow):
+ * rendering/InlineTextBox.h:
+ (WebCore::InlineTextBox::clearGlyphOverflowAndFallbackFontMap): Added.
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlock::computeHorizontalPositionsForLine):
+ (WebCore::RenderBlock::layoutInlineChildren):
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::RenderText):
+ (WebCore::RenderText::styleDidChange):
+ (WebCore::RenderText::widthFromCache):
+ (WebCore::RenderText::trimmedPrefWidths):
+ (WebCore::RenderText::calcPrefWidths):
+ (WebCore::RenderText::setText):
+ (WebCore::RenderText::width):
+ * rendering/RenderText.h:
+
+2010-03-23 Evan Martin <evan@chromium.org>
+
+ Reviewed by Dmitry Titov.
+
+ [chromium] use integral glyph widths
+ https://bugs.webkit.org/show_bug.cgi?id=36510
+
+ Despite WebKit (and Skia, to an extent) supporting non-integral
+ glyph widths, the font code path we hit in Skia only supports
+ integral glyph positions. This means that we would accumulate
+ offsets when drawing a sequence up non-integer-width glyphs
+ which would cause gaps when snapped to the pixel grid when drawing.
+
+ * platform/graphics/chromium/SimpleFontDataLinux.cpp:
+ (WebCore::SimpleFontData::platformWidthForGlyph):
+ round glyph widths to integers.
+
+2010-06-21 Benjamin Poulain <benjamin.poulain@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Decode images directly to QPixmap
+ https://bugs.webkit.org/show_bug.cgi?id=40797
+
+ Decode images to QPixmap directly instead of QImage when possible.
+ RGBA32Buffer transforms the pixmap back to image if
+ necessary.
+
+ This improve the performance with certain graphic system, and
+ can reduce memory usage.
+
+ * platform/graphics/qt/ImageDecoderQt.cpp:
+ (WebCore::ImageDecoderQt::setData):
+ (WebCore::ImageDecoderQt::internalHandleCurrentImage):
+ * platform/image-decoders/ImageDecoder.h:
+ (WebCore::RGBA32Buffer::getAddr):
+ * platform/image-decoders/qt/RGBA32BufferQt.cpp:
+ (WebCore::RGBA32Buffer::clear):
+ (WebCore::RGBA32Buffer::zeroFill):
+ (WebCore::RGBA32Buffer::copyBitmapData):
+ (WebCore::RGBA32Buffer::setSize):
+ (WebCore::RGBA32Buffer::asNewNativeImage):
+ (WebCore::RGBA32Buffer::setPixmap):
+
+2010-06-17 Benjamin Poulain <benjamin.poulain@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Get rid of the the unused imageSize of ImageDecoderQt::internalHandleCurrentImage()
+ https://bugs.webkit.org/show_bug.cgi?id=40620
+
+ Remove an unused variable.
+
+ * platform/graphics/qt/ImageDecoderQt.cpp:
+ (WebCore::ImageDecoderQt::internalHandleCurrentImage):
+
+2010-06-18 Ananth Jasty <ext-ananth.jasty@nokia.com>
+
+ Reviewed by Simon Hausmann.
+
+ [Qt] Text spacing miscalculation when using wordSpacing.
+ https://bugs.webkit.org/show_bug.cgi?id=40483
+
+ Removed wordSpacing compensation in FontQt whitespace width
+ calculation. The QFontMetrics::width() overload that takes
+ a character does not take QFont's word spacing into account.
+
+ * platform/graphics/qt/FontQt.cpp:
+ (WebCore::Font::floatWidthForComplexText):
+
+2010-06-13 Robert Hogan <robert@webkit.org>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ WebCore EventHandler needs to take account of onLoad events
+ fired before layout() complete
+
+ https://bugs.webkit.org/show_bug.cgi?id=40102
+
+ WebCore 'cheats' by firing onLoad events before the frame's layout
+ has been performed. This can result in event listeners performing
+ operations that depend on the document's final layout, such as
+ scrolling operations.
+
+ When scrolling a frameview in eventhandler ensure the layout is complete.
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::scrollRecursively):
+
+2010-06-10 Raine Makelainen <raine.makelainen@nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Impossible to set input method hints based HTML5 input types
+ https://bugs.webkit.org/show_bug.cgi?id=40107
+
+ Helper methods for checking "tel", "number", "email",
+ and "url" input element types.
+
+ * html/HTMLInputElement.h:
+ (WebCore::HTMLInputElement::isTelephoneField):
+ (WebCore::HTMLInputElement::isNumberField):
+ (WebCore::HTMLInputElement::isEmailField):
+ (WebCore::HTMLInputElement::isUrlField):
+
2010-06-17 Mark Brand <mabrand@mabrand.nl>
Reviewed by Simon Hausmann.
diff --git a/src/3rdparty/webkit/WebCore/WebCore.gypi b/src/3rdparty/webkit/WebCore/WebCore.gypi
index 94a6052b03..27b9085068 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.gypi
+++ b/src/3rdparty/webkit/WebCore/WebCore.gypi
@@ -2320,8 +2320,8 @@
'platform/graphics/GlyphBuffer.h',
'platform/graphics/GlyphPageTreeNode.cpp',
'platform/graphics/GlyphPageTreeNode.h',
- 'platform/graphics/GlyphWidthMap.cpp',
- 'platform/graphics/GlyphWidthMap.h',
+ 'platform/graphics/GlyphMetricsMap.cpp',
+ 'platform/graphics/GlyphMetricsMap.h',
'platform/graphics/Gradient.cpp',
'platform/graphics/Gradient.h',
'platform/graphics/GraphicsContext.cpp',
diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro
index 9870769b5d..fd2b4473e7 100644
--- a/src/3rdparty/webkit/WebCore/WebCore.pro
+++ b/src/3rdparty/webkit/WebCore/WebCore.pro
@@ -2867,6 +2867,7 @@ HEADERS += $$WEBKIT_API_HEADERS
# INSTALLS is not implemented in qmake's s60 generators, copy headers manually
inst_headers.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT}
inst_headers.input = WEBKIT_INSTALL_HEADERS
+ inst_headers.CONFIG = no_clean
!isEmpty(INSTALL_HEADERS): inst_headers.output = $$INSTALL_HEADERS/QtWebKit/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
else: inst_headers.output = $$[QT_INSTALL_HEADERS]/QtWebKit/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
@@ -2876,6 +2877,7 @@ HEADERS += $$WEBKIT_API_HEADERS
inst_modfile.commands = $$inst_headers.commands
inst_modfile.input = moduleFile
inst_modfile.output = $$[QMAKE_MKSPECS]/modules
+ inst_modfile.CONFIG = no_clean
QMAKE_EXTRA_COMPILERS += inst_modfile
diff --git a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h
index c3b0a734fc..087cffa364 100644
--- a/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h
+++ b/src/3rdparty/webkit/WebCore/html/HTMLInputElement.h
@@ -128,6 +128,10 @@ public:
virtual bool isSearchField() const { return m_type == SEARCH; }
virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
virtual bool isPasswordField() const { return m_type == PASSWORD; }
+ bool isTelephoneField() const { return m_type == TELEPHONE; }
+ bool isNumberField() const { return m_type == NUMBER; }
+ bool isEmailField() const { return m_type == EMAIL; }
+ bool isUrlField() const { return m_type == URL; }
bool checked() const { return m_checked; }
void setChecked(bool, bool sendChangeEvent = false);
diff --git a/src/3rdparty/webkit/WebCore/page/EventHandler.cpp b/src/3rdparty/webkit/WebCore/page/EventHandler.cpp
index c40299cf9a..165425713e 100644
--- a/src/3rdparty/webkit/WebCore/page/EventHandler.cpp
+++ b/src/3rdparty/webkit/WebCore/page/EventHandler.cpp
@@ -952,6 +952,9 @@ bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g
bool EventHandler::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity, Node* startingNode)
{
+ // The layout needs to be up to date to determine if we can scroll. We may be
+ // here because of an onLoad event, in which case the final layout hasn't been performed yet.
+ m_frame->document()->updateLayoutIgnorePendingStylesheets();
bool handled = scrollOverflow(direction, granularity, startingNode);
if (!handled) {
Frame* frame = m_frame;
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp
index 3d3ffe36f7..8e132e1520 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/Font.cpp
@@ -38,7 +38,6 @@ using namespace Unicode;
namespace WebCore {
-#if USE(FONT_FAST_PATH)
const uint8_t Font::gRoundingHackCharacterTable[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*\t*/, 1 /*\n*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1 /*space*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*-*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*?*/,
@@ -51,7 +50,6 @@ const uint8_t Font::gRoundingHackCharacterTable[256] = {
};
Font::CodePath Font::s_codePath = Auto;
-#endif
// ============================================================================================
// Font Implementation (Cross-Platform Portion)
@@ -174,31 +172,28 @@ void Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoi
}
#endif
-#if USE(FONT_FAST_PATH)
- if (canUseGlyphCache(run))
+ if (codePath(run) != Complex)
return drawSimpleText(context, run, point, from, to);
-#endif
return drawComplexText(context, run, point, from, to);
}
-float Font::floatWidth(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts) const
+float Font::floatWidth(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
#if ENABLE(SVG_FONTS)
if (primaryFont()->isSVGFont())
return floatWidthUsingSVGFont(run);
#endif
-#if USE(FONT_FAST_PATH)
- if (canUseGlyphCache(run)) {
+ CodePath codePathToUse = codePath(run);
+ if (codePathToUse != Complex) {
// If the complex text implementation cannot return fallback fonts, avoid
// returning them for simple text as well.
static bool returnFallbackFonts = canReturnFallbackFontsForComplexText();
- return floatWidthForSimpleText(run, 0, returnFallbackFonts ? fallbackFonts : 0);
+ return floatWidthForSimpleText(run, 0, returnFallbackFonts ? fallbackFonts : 0, codePathToUse == SimpleWithGlyphOverflow ? glyphOverflow : 0);
}
-#endif
- return floatWidthForComplexText(run, fallbackFonts);
+ return floatWidthForComplexText(run, fallbackFonts, glyphOverflow);
}
float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
@@ -213,10 +208,8 @@ float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsCo
charsConsumed = run.length();
glyphName = "";
-#if USE(FONT_FAST_PATH)
- if (canUseGlyphCache(run))
+ if (codePath(run) != Complex)
return floatWidthForSimpleText(run, 0);
-#endif
return floatWidthForComplexText(run);
}
@@ -230,10 +223,8 @@ FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& point,
to = (to == -1 ? run.length() : to);
-#if USE(FONT_FAST_PATH)
- if (canUseGlyphCache(run))
+ if (codePath(run) != Complex)
return selectionRectForSimpleText(run, point, h, from, to);
-#endif
return selectionRectForComplexText(run, point, h, from, to);
}
@@ -245,10 +236,8 @@ int Font::offsetForPosition(const TextRun& run, int x, bool includePartialGlyphs
return offsetForPositionForTextUsingSVGFont(run, x, includePartialGlyphs);
#endif
-#if USE(FONT_FAST_PATH)
- if (canUseGlyphCache(run))
+ if (codePath(run) != Complex)
return offsetForPositionForSimpleText(run, x, includePartialGlyphs);
-#endif
return offsetForPositionForComplexText(run, x, includePartialGlyphs);
}
@@ -295,4 +284,79 @@ bool Font::shouldUseSmoothing()
return shouldUseFontSmoothing;
}
+void Font::setCodePath(CodePath p)
+{
+ s_codePath = p;
+}
+
+Font::CodePath Font::codePath()
+{
+ return s_codePath;
+}
+
+Font::CodePath Font::codePath(const TextRun& run) const
+{
+ if (s_codePath != Auto)
+ return s_codePath;
+
+#if PLATFORM(QT)
+ if (run.padding() || run.rtl() || isSmallCaps() || wordSpacing() || letterSpacing())
+ return Complex;
+#endif
+
+ // Start from 0 since drawing and highlighting also measure the characters before run->from
+ for (int i = 0; i < run.length(); i++) {
+ const UChar c = run[i];
+ if (c < 0x300) // U+0300 through U+036F Combining diacritical marks
+ continue;
+ if (c <= 0x36F)
+ return Complex;
+
+ if (c < 0x0591 || c == 0x05BE) // U+0591 through U+05CF excluding U+05BE Hebrew combining marks, Hebrew punctuation Paseq, Sof Pasuq and Nun Hafukha
+ continue;
+ if (c <= 0x05CF)
+ return Complex;
+
+ if (c < 0x0600) // U+0600 through U+1059 Arabic, Syriac, Thaana, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala, Thai, Lao, Tibetan, Myanmar
+ continue;
+ if (c <= 0x1059)
+ return Complex;
+
+ if (c < 0x1100) // U+1100 through U+11FF Hangul Jamo (only Ancient Korean should be left here if you precompose; Modern Korean will be precomposed as a result of step A)
+ continue;
+ if (c <= 0x11FF)
+ return Complex;
+
+ if (c < 0x1780) // U+1780 through U+18AF Khmer, Mongolian
+ continue;
+ if (c <= 0x18AF)
+ return Complex;
+
+ if (c < 0x1900) // U+1900 through U+194F Limbu (Unicode 4.0)
+ continue;
+ if (c <= 0x194F)
+ return Complex;
+
+ if (c < 0x1E00) // U+1E00 through U+2000 characters with diacritics and stacked diacritics
+ continue;
+ if (c <= 0x2000)
+ return SimpleWithGlyphOverflow;
+
+ if (c < 0x20D0) // U+20D0 through U+20FF Combining marks for symbols
+ continue;
+ if (c <= 0x20FF)
+ return Complex;
+
+ if (c < 0xFE20) // U+FE20 through U+FE2F Combining half marks
+ continue;
+ if (c <= 0xFE2F)
+ return Complex;
+ }
+
+ if (typesettingFeatures())
+ return Complex;
+
+ return Simple;
+}
+
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/Font.h b/src/3rdparty/webkit/WebCore/platform/graphics/Font.h
index 3c07be7412..772ad939f0 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/Font.h
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/Font.h
@@ -56,6 +56,21 @@ struct GlyphData;
const unsigned defaultUnitsPerEm = 1000;
+struct GlyphOverflow {
+ GlyphOverflow()
+ : left(0)
+ , right(0)
+ , top(0)
+ , bottom(0)
+ {
+ }
+
+ int left;
+ int right;
+ int top;
+ int bottom;
+};
+
class Font {
public:
Font();
@@ -81,8 +96,8 @@ public:
void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const;
- int width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts = 0) const { return lroundf(floatWidth(run, fallbackFonts)); }
- float floatWidth(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0) const;
+ int width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* glyphOverflow = 0) const { return lroundf(floatWidth(run, fallbackFonts, glyphOverflow)); }
+ float floatWidth(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* glyphOverflow = 0) const;
float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const;
int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const;
@@ -137,6 +152,8 @@ public:
static void setShouldUseSmoothing(bool);
static bool shouldUseSmoothing();
+ enum CodePath { Auto, Simple, Complex, SimpleWithGlyphOverflow };
+
private:
#if ENABLE(SVG_FONTS)
void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
@@ -146,20 +163,18 @@ private:
int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const;
#endif
-#if USE(FONT_FAST_PATH)
- bool canUseGlyphCache(const TextRun&) const;
void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const;
void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const;
- float floatWidthForSimpleText(const TextRun&, GlyphBuffer*, HashSet<const SimpleFontData*>* fallbackFonts = 0) const;
+ float floatWidthForSimpleText(const TextRun&, GlyphBuffer*, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const;
FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const;
static bool canReturnFallbackFontsForComplexText();
-#endif
+ CodePath codePath(const TextRun&) const;
void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
- float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0) const;
+ float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const;
FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const;
@@ -167,8 +182,6 @@ private:
public:
// Useful for debugging the different font rendering code paths.
-#if USE(FONT_FAST_PATH)
- enum CodePath { Auto, Simple, Complex };
static void setCodePath(CodePath);
static CodePath codePath();
static CodePath s_codePath;
@@ -178,7 +191,6 @@ public:
{
return (((c & ~0xFF) == 0 && gRoundingHackCharacterTable[c]));
}
-#endif
FontSelector* fontSelector() const;
static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == 0x00A0; }
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp
index 428e85ef35..b863e8346f 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/FontFastPath.cpp
@@ -24,17 +24,17 @@
#include "Font.h"
#include "CharacterNames.h"
+#include "FloatRect.h"
#include "FontCache.h"
#include "FontFallbackList.h"
-#include "FloatRect.h"
#include "GlyphBuffer.h"
#include "GlyphPageTreeNode.h"
#include "IntPoint.h"
#include "SimpleFontData.h"
#include "WidthIterator.h"
-#include <wtf/unicode/Unicode.h>
#include <wtf/MathExtras.h>
+#include <wtf/unicode/Unicode.h>
using namespace WTF;
using namespace Unicode;
@@ -180,78 +180,6 @@ GlyphData Font::glyphDataForCharacter(UChar32 c, bool mirror, bool forceSmallCap
return data;
}
-void Font::setCodePath(CodePath p)
-{
- s_codePath = p;
-}
-
-Font::CodePath Font::codePath()
-{
- return s_codePath;
-}
-
-bool Font::canUseGlyphCache(const TextRun& run) const
-{
- switch (s_codePath) {
- case Auto:
- break;
- case Simple:
- return true;
- case Complex:
- return false;
- }
-
- // Start from 0 since drawing and highlighting also measure the characters before run->from
- for (int i = 0; i < run.length(); i++) {
- const UChar c = run[i];
- if (c < 0x300) // U+0300 through U+036F Combining diacritical marks
- continue;
- if (c <= 0x36F)
- return false;
-
- if (c < 0x0591 || c == 0x05BE) // U+0591 through U+05CF excluding U+05BE Hebrew combining marks, Hebrew punctuation Paseq, Sof Pasuq and Nun Hafukha
- continue;
- if (c <= 0x05CF)
- return false;
-
- if (c < 0x0600) // U+0600 through U+1059 Arabic, Syriac, Thaana, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala, Thai, Lao, Tibetan, Myanmar
- continue;
- if (c <= 0x1059)
- return false;
-
- if (c < 0x1100) // U+1100 through U+11FF Hangul Jamo (only Ancient Korean should be left here if you precompose; Modern Korean will be precomposed as a result of step A)
- continue;
- if (c <= 0x11FF)
- return false;
-
- if (c < 0x1780) // U+1780 through U+18AF Khmer, Mongolian
- continue;
- if (c <= 0x18AF)
- return false;
-
- if (c < 0x1900) // U+1900 through U+194F Limbu (Unicode 4.0)
- continue;
- if (c <= 0x194F)
- return false;
-
- if (c < 0x20D0) // U+20D0 through U+20FF Combining marks for symbols
- continue;
- if (c <= 0x20FF)
- return false;
-
- if (c < 0xFE20) // U+FE20 through U+FE2F Combining half marks
- continue;
- if (c <= 0xFE2F)
- return false;
- }
-
- if (typesettingFeatures())
- return false;
-
- return true;
-
-}
-
void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// This glyph buffer holds our glyphs+advances+font data for each glyph.
@@ -314,10 +242,18 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const GlyphBuffer& glyphBuf
drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
}
-float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet<const SimpleFontData*>* fallbackFonts) const
+float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
- WidthIterator it(this, run, fallbackFonts);
+ WidthIterator it(this, run, fallbackFonts, glyphOverflow);
it.advance(run.length(), glyphBuffer);
+
+ if (glyphOverflow) {
+ glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-it.minGlyphBoundingBoxY()) - ascent());
+ glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(it.maxGlyphBoundingBoxY()) - descent());
+ glyphOverflow->left = ceilf(it.firstGlyphOverflow());
+ glyphOverflow->right = ceilf(it.lastGlyphOverflow());
+ }
+
return it.m_runWidthSoFar;
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.cpp
index 43cab65c32..d3c3180af5 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.cpp
@@ -27,14 +27,14 @@
*/
#include "config.h"
-#include "GlyphWidthMap.h"
+#include "GlyphMetricsMap.h"
namespace WebCore {
-GlyphWidthMap::GlyphWidthPage* GlyphWidthMap::locatePageSlowCase(unsigned pageNumber)
+GlyphMetricsMap::GlyphMetricsPage* GlyphMetricsMap::locatePageSlowCase(unsigned pageNumber)
{
- GlyphWidthPage* page;
- if (pageNumber == 0) {
+ GlyphMetricsPage* page;
+ if (!pageNumber) {
ASSERT(!m_filledPrimaryPage);
page = &m_primaryPage;
m_filledPrimaryPage = true;
@@ -43,14 +43,18 @@ GlyphWidthMap::GlyphWidthPage* GlyphWidthMap::locatePageSlowCase(unsigned pageNu
if ((page = m_pages->get(pageNumber)))
return page;
} else
- m_pages.set(new HashMap<int, GlyphWidthPage*>);
- page = new GlyphWidthPage;
+ m_pages.set(new HashMap<int, GlyphMetricsPage*>);
+ page = new GlyphMetricsPage;
m_pages->set(pageNumber, page);
}
- // Fill in the whole page with the unknown glyph width value.
- for (unsigned i = 0; i < GlyphWidthPage::size; i++)
- page->setWidthForIndex(i, cGlyphWidthUnknown);
+ GlyphMetrics unknownMetrics;
+ unknownMetrics.horizontalAdvance = cGlyphSizeUnknown;
+ unknownMetrics.boundingBox.setWidth(cGlyphSizeUnknown);
+ unknownMetrics.boundingBox.setHeight(cGlyphSizeUnknown);
+ // Fill in the whole page with the unknown glyph information.
+ for (unsigned i = 0; i < GlyphMetricsPage::size; i++)
+ page->setMetricsForIndex(i, unknownMetrics);
return page;
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.h b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.h
index 66dea1fb2d..49854be8b3 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/GlyphWidthMap.h
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/GlyphMetricsMap.h
@@ -26,9 +26,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GlyphWidthMap_h
-#define GlyphWidthMap_h
+#ifndef GlyphMetricsMap_h
+#define GlyphMetricsMap_h
+#include "FloatRect.h"
#include <wtf/HashMap.h>
#include <wtf/OwnPtr.h>
#include <wtf/unicode/Unicode.h>
@@ -37,53 +38,67 @@ namespace WebCore {
typedef unsigned short Glyph;
-const float cGlyphWidthUnknown = -1;
+const float cGlyphSizeUnknown = -1;
-class GlyphWidthMap : public Noncopyable {
+struct GlyphMetrics {
+ float horizontalAdvance;
+ FloatRect boundingBox;
+};
+
+class GlyphMetricsMap : public Noncopyable {
public:
- GlyphWidthMap() : m_filledPrimaryPage(false) { }
- ~GlyphWidthMap() { if (m_pages) { deleteAllValues(*m_pages); } }
+ GlyphMetricsMap() : m_filledPrimaryPage(false) { }
+ ~GlyphMetricsMap()
+ {
+ if (m_pages)
+ deleteAllValues(*m_pages);
+ }
+
+ GlyphMetrics metricsForGlyph(Glyph glyph)
+ {
+ return locatePage(glyph / GlyphMetricsPage::size)->metricsForGlyph(glyph);
+ }
float widthForGlyph(Glyph glyph)
{
- return locatePage(glyph / GlyphWidthPage::size)->widthForGlyph(glyph);
+ return locatePage(glyph / GlyphMetricsPage::size)->metricsForGlyph(glyph).horizontalAdvance;
}
- void setWidthForGlyph(Glyph glyph, float width)
+ void setMetricsForGlyph(Glyph glyph, const GlyphMetrics& metrics)
{
- locatePage(glyph / GlyphWidthPage::size)->setWidthForGlyph(glyph, width);
+ locatePage(glyph / GlyphMetricsPage::size)->setMetricsForGlyph(glyph, metrics);
}
private:
- struct GlyphWidthPage {
+ struct GlyphMetricsPage {
static const size_t size = 256; // Usually covers Latin-1 in a single page.
- float m_widths[size];
+ GlyphMetrics m_metrics[size];
- float widthForGlyph(Glyph glyph) const { return m_widths[glyph % size]; }
- void setWidthForGlyph(Glyph glyph, float width)
+ GlyphMetrics metricsForGlyph(Glyph glyph) const { return m_metrics[glyph % size]; }
+ void setMetricsForGlyph(Glyph glyph, const GlyphMetrics& metrics)
{
- setWidthForIndex(glyph % size, width);
+ setMetricsForIndex(glyph % size, metrics);
}
- void setWidthForIndex(unsigned index, float width)
+ void setMetricsForIndex(unsigned index, const GlyphMetrics& metrics)
{
- m_widths[index] = width;
+ m_metrics[index] = metrics;
}
};
- GlyphWidthPage* locatePage(unsigned pageNumber)
+ GlyphMetricsPage* locatePage(unsigned pageNumber)
{
if (!pageNumber && m_filledPrimaryPage)
return &m_primaryPage;
return locatePageSlowCase(pageNumber);
}
- GlyphWidthPage* locatePageSlowCase(unsigned pageNumber);
+ GlyphMetricsPage* locatePageSlowCase(unsigned pageNumber);
bool m_filledPrimaryPage;
- GlyphWidthPage m_primaryPage; // We optimize for the page that contains glyph indices 0-255.
- OwnPtr<HashMap<int, GlyphWidthPage*> > m_pages;
+ GlyphMetricsPage m_primaryPage; // We optimize for the page that contains glyph indices 0-255.
+ OwnPtr<HashMap<int, GlyphMetricsPage*> > m_pages;
};
-}
+} // namespace WebCore
#endif
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp
index 2ec8abb8e2..04b6ab1c04 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.cpp
@@ -157,9 +157,11 @@ void SimpleFontData::platformGlyphInit()
// are mapped to the ZERO WIDTH SPACE glyph.
Glyph zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
if (zeroWidthSpaceGlyph) {
- if (zeroWidthSpaceGlyph != m_spaceGlyph)
- m_glyphToWidthMap.setWidthForGlyph(zeroWidthSpaceGlyph, 0);
- else
+ if (zeroWidthSpaceGlyph != m_spaceGlyph) {
+ GlyphMetrics metrics;
+ metrics.horizontalAdvance = 0;
+ m_glyphToMetricsMap.setMetricsForGlyph(zeroWidthSpaceGlyph, metrics);
+ } else
LOG_ERROR("Font maps SPACE and ZERO WIDTH SPACE to the same glyph. Glyph width not overridden.");
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h b/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h
index 0366e3b989..efdbba4877 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/SimpleFontData.h
@@ -26,8 +26,8 @@
#include "FontData.h"
#include "FontPlatformData.h"
+#include "GlyphMetricsMap.h"
#include "GlyphPageTreeNode.h"
-#include "GlyphWidthMap.h"
#include "TypesettingFeatures.h"
#include <wtf/OwnPtr.h>
@@ -58,9 +58,9 @@ class FontDescription;
class FontPlatformData;
class SharedBuffer;
class SVGFontData;
-class WidthMap;
enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
+enum GlyphMetricsMode { GlyphBoundingBox, GlyphWidthOnly };
class SimpleFontData : public FontData {
public:
@@ -81,8 +81,9 @@ public:
float xHeight() const { return m_xHeight; }
unsigned unitsPerEm() const { return m_unitsPerEm; }
- float widthForGlyph(Glyph) const;
- float platformWidthForGlyph(Glyph) const;
+ float widthForGlyph(Glyph glyph) const { return metricsForGlyph(glyph, GlyphWidthOnly).horizontalAdvance; }
+ GlyphMetrics metricsForGlyph(Glyph, GlyphMetricsMode = GlyphBoundingBox) const;
+ GlyphMetrics platformMetricsForGlyph(Glyph, GlyphMetricsMode) const;
float spaceWidth() const { return m_spaceWidth; }
float adjustedSpaceWidth() const { return m_adjustedSpaceWidth; }
@@ -167,7 +168,7 @@ private:
|| (OS(WINDOWS) && PLATFORM(WX))
void initGDIFont();
void platformCommonDestroy();
- float widthForGDIGlyph(Glyph glyph) const;
+ GlyphMetrics metricsForGDIGlyph(Glyph glyph) const;
#endif
int m_ascent;
@@ -181,7 +182,7 @@ private:
FontPlatformData m_platformData;
- mutable GlyphWidthMap m_glyphToWidthMap;
+ mutable GlyphMetricsMap m_glyphToMetricsMap;
bool m_treatAsFixedPitch;
@@ -237,16 +238,16 @@ private:
#if !PLATFORM(QT)
-ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const
+ALWAYS_INLINE GlyphMetrics SimpleFontData::metricsForGlyph(Glyph glyph, GlyphMetricsMode metricsMode) const
{
- float width = m_glyphToWidthMap.widthForGlyph(glyph);
- if (width != cGlyphWidthUnknown)
- return width;
-
- width = platformWidthForGlyph(glyph);
- m_glyphToWidthMap.setWidthForGlyph(glyph, width);
-
- return width;
+ GlyphMetrics metrics = m_glyphToMetricsMap.metricsForGlyph(glyph);
+ if ((metricsMode == GlyphWidthOnly && metrics.horizontalAdvance != cGlyphSizeUnknown) || (metricsMode == GlyphBoundingBox && metrics.boundingBox.width() != cGlyphSizeUnknown))
+ return metrics;
+
+ metrics = platformMetricsForGlyph(glyph, metricsMode);
+ m_glyphToMetricsMap.setMetricsForGlyph(glyph, metrics);
+
+ return metrics;
}
#endif
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp
index 9157310646..996ce40f8e 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.cpp
@@ -33,13 +33,14 @@
using namespace WTF;
using namespace Unicode;
+using namespace std;
namespace WebCore {
// According to http://www.unicode.org/Public/UNIDATA/UCD.html#Canonical_Combining_Class_Values
static const uint8_t hiraganaKatakanaVoicingMarksCombiningClass = 8;
-WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts)
+WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, bool accountForGlyphBounds)
: m_font(font)
, m_run(run)
, m_end(run.length())
@@ -47,6 +48,11 @@ WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet<const
, m_runWidthSoFar(0)
, m_finalRoundingWidth(0)
, m_fallbackFonts(fallbackFonts)
+ , m_accountForGlyphBounds(accountForGlyphBounds)
+ , m_maxGlyphBoundingBoxY(numeric_limits<float>::min())
+ , m_minGlyphBoundingBoxY(numeric_limits<float>::max())
+ , m_firstGlyphOverflow(0)
+ , m_lastGlyphOverflow(0)
{
// If the padding is non-zero, count the number of spaces in the run
// and divide that by the padding for per space addition.
@@ -79,6 +85,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
float runWidthSoFar = m_runWidthSoFar;
float lastRoundingWidth = m_finalRoundingWidth;
+ FloatRect bounds;
const SimpleFontData* primaryFont = m_font->primaryFont();
const SimpleFontData* lastFontData = primaryFont;
@@ -175,6 +182,12 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
}
}
+ if (m_accountForGlyphBounds) {
+ bounds = fontData->boundsForGlyph(glyph);
+ if (!currentCharacter)
+ m_firstGlyphOverflow = max<float>(0, -bounds.x());
+ }
+
// Advance past the character we just dealt with.
cp += clusterLength;
currentCharacter += clusterLength;
@@ -205,6 +218,12 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
glyphBuffer->add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
lastRoundingWidth = width - oldWidth;
+
+ if (m_accountForGlyphBounds) {
+ m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, bounds.bottom());
+ m_minGlyphBoundingBoxY = min(m_minGlyphBoundingBoxY, bounds.y());
+ m_lastGlyphOverflow = max<float>(0, bounds.right() - width);
+ }
}
m_currentCharacter = currentCharacter;
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h b/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h
index 7ca4198edc..d42a0c5e95 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/WidthIterator.h
@@ -33,11 +33,16 @@ class SimpleFontData;
class TextRun;
struct WidthIterator {
- WidthIterator(const Font*, const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0);
+ WidthIterator(const Font*, const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, bool accountForGlyphBounds = false);
void advance(int to, GlyphBuffer* = 0);
bool advanceOneCharacter(float& width, GlyphBuffer* = 0);
+ float maxGlyphBoundingBoxY() const { ASSERT(m_accountForGlyphBounds); return m_maxGlyphBoundingBoxY; }
+ float minGlyphBoundingBoxY() const { ASSERT(m_accountForGlyphBounds); return m_minGlyphBoundingBoxY; }
+ float firstGlyphOverflow() const { ASSERT(m_accountForGlyphBounds); return m_firstGlyphOverflow; }
+ float lastGlyphOverflow() const { ASSERT(m_accountForGlyphBounds); return m_lastGlyphOverflow; }
+
const Font* m_font;
const TextRun& m_run;
@@ -51,7 +56,13 @@ struct WidthIterator {
private:
UChar32 normalizeVoicingMarks(int currentCharacter);
+
HashSet<const SimpleFontData*>* m_fallbackFonts;
+ bool m_accountForGlyphBounds;
+ float m_maxGlyphBoundingBoxY;
+ float m_minGlyphBoundingBoxY;
+ float m_firstGlyphOverflow;
+ float m_lastGlyphOverflow;
};
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp
index ae1033e105..06885ba9ec 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/FontQt.cpp
@@ -44,11 +44,15 @@
namespace WebCore {
-static const QString fromRawDataWithoutRef(const String& string)
+static const QString fromRawDataWithoutRef(const String& string, int start = 0, int len = -1)
{
+ if (len < 0)
+ len = string.length() - start;
+ Q_ASSERT(start + len <= string.length());
+
// We don't detach. This assumes the WebCore string data will stay valid for the
// lifetime of the QString we pass back, since we don't ref the WebCore string.
- return QString::fromRawData(reinterpret_cast<const QChar*>(string.characters()), string.length());
+ return QString::fromRawData(reinterpret_cast<const QChar*>(string.characters() + start), len);
}
static QTextLine setupLayout(QTextLayout* layout, const TextRun& style)
@@ -66,7 +70,7 @@ static QTextLine setupLayout(QTextLayout* layout, const TextRun& style)
return line;
}
-void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
+static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to, const QFont& font, bool isComplexText)
{
if (to < 0)
to = run.length();
@@ -102,6 +106,7 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float
String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
QString string = fromRawDataWithoutRef(sanitized);
+ QPointF pt(point.x(), point.y());
// text shadow
IntSize shadowSize;
@@ -110,52 +115,63 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float
bool hasShadow = ctx->textDrawingMode() == cTextFill && ctx->getShadow(shadowSize, shadowBlur, shadowColor);
if (from > 0 || to < run.length()) {
- 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(font());
- int ascent = fm.ascent();
- QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height());
-
- if (hasShadow) {
- // TODO: when blur support is added, the clip will need to account
- // for the blur radius
- qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
- if (shadowSize.width() > 0)
- dx2 = shadowSize.width();
- else
- dx1 = -shadowSize.width();
- if (shadowSize.height() > 0)
- dy2 = shadowSize.height();
- else
- dy1 = -shadowSize.height();
- // expand the clip rect to include the text shadow as well
- clip.adjust(dx1, dx2, dy1, dy2);
- }
- p->save();
- p->setClipRect(clip.toRect(), Qt::IntersectClip);
- QPointF pt(point.x(), point.y() - ascent);
- if (hasShadow) {
+ if (isComplexText) {
+ 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(font);
+ int ascent = fm.ascent();
+ QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height());
+
+ if (hasShadow) {
+ // TODO: when blur support is added, the clip will need to account
+ // for the blur radius
+ qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
+ if (shadowSize.width() > 0)
+ dx2 = shadowSize.width();
+ else
+ dx1 = -shadowSize.width();
+ if (shadowSize.height() > 0)
+ dy2 = shadowSize.height();
+ else
+ dy1 = -shadowSize.height();
+ // expand the clip rect to include the text shadow as well
+ clip.adjust(dx1, dx2, dy1, dy2);
+ }
p->save();
- p->setPen(QColor(shadowColor));
- p->translate(shadowSize.width(), shadowSize.height());
+ p->setClipRect(clip.toRect(), Qt::IntersectClip);
+ pt.setY(pt.y() - ascent);
+ if (hasShadow) {
+ p->save();
+ p->setPen(QColor(shadowColor));
+ p->translate(shadowSize.width(), shadowSize.height());
+ line.draw(p, pt);
+ p->restore();
+ }
+ p->setPen(textFillPen);
line.draw(p, pt);
p->restore();
+ return;
}
- p->setPen(textFillPen);
- line.draw(p, pt);
- p->restore();
- return;
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ int skipWidth = QFontMetrics(font).width(string, from, Qt::TextBypassShaping);
+ pt.setX(pt.x() + skipWidth);
+ string = fromRawDataWithoutRef(sanitized, from, to - from);
+#endif
}
- p->setFont(font());
+ p->setFont(font);
- QPointF pt(point.x(), point.y());
int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ // See QWebPagePrivate::QWebPagePrivate() where the default path is set to Complex for Qt 4.6 and earlier.
+ if (!isComplexText)
+ flags |= Qt::TextBypassShaping;
+#endif
if (hasShadow) {
// TODO: text shadow blur support
p->save();
@@ -166,7 +182,7 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float
}
if (ctx->textDrawingMode() & cTextStroke) {
QPainterPath path;
- path.addText(pt, font(), string);
+ path.addText(pt, font, string);
p->setPen(textStrokePen);
p->strokePath(path, p->pen());
}
@@ -176,13 +192,49 @@ void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const Float
}
}
-float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*) const
+void Font::drawSimpleText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */false);
+#else
+ Q_ASSERT(false);
+#endif
+}
+
+void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
+{
+ drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */true);
+}
+
+float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ if (!run.length())
+ return 0;
+
+ String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
+ QString string = fromRawDataWithoutRef(sanitized);
+
+ int w = QFontMetrics(font()).width(string, -1, Qt::TextBypassShaping);
+
+ // WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does)
+ if (treatAsSpace(run[0]))
+ w -= m_wordSpacing;
+
+ return w + run.padding();
+#else
+ Q_ASSERT(false);
+ return 0.0f;
+#endif
+}
+
+float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*, GlyphOverflow*) const
{
if (!run.length())
return 0;
if (run.length() == 1 && treatAsSpace(run[0]))
- return QFontMetrics(font()).width(run[0]) - m_wordSpacing + run.padding();
+ return QFontMetrics(font()).width(run[0]) + run.padding();
String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
QString string = fromRawDataWithoutRef(sanitized);
@@ -195,6 +247,34 @@ float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFon
return w + run.padding();
}
+int Font::offsetForPositionForSimpleText(const TextRun& run, int position, bool includePartialGlyphs) const
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
+ QString string = fromRawDataWithoutRef(sanitized);
+
+ QFontMetrics fm(font());
+ float delta = (float)position;
+ int curPos = 0;
+ do {
+ float charWidth = fm.width(string[curPos]);
+ delta -= charWidth;
+ if (includePartialGlyphs) {
+ if (delta + charWidth / 2 <= 0)
+ break;
+ } else {
+ if (delta + charWidth <= 0)
+ break;
+ }
+ } while (++curPos < string.size());
+
+ return curPos;
+#else
+ Q_ASSERT(false);
+ return 0;
+#endif
+}
+
int Font::offsetForPositionForComplexText(const TextRun& run, int position, bool) const
{
String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
@@ -205,6 +285,23 @@ int Font::offsetForPositionForComplexText(const TextRun& run, int position, bool
return line.xToCursor(position);
}
+FloatRect Font::selectionRectForSimpleText(const TextRun& run, const IntPoint& pt, int h, int from, int to) const
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
+ QString wholeText = fromRawDataWithoutRef(sanitized);
+ QString selectedText = fromRawDataWithoutRef(sanitized, from, to - from);
+
+ int startX = QFontMetrics(font()).width(wholeText, from, Qt::TextBypassShaping);
+ int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping);
+
+ return FloatRect(pt.x() + startX, pt.y(), width, h);
+#else
+ Q_ASSERT(false);
+ return FloatRect();
+#endif
+}
+
FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& pt, int h, int from, int to) const
{
String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
@@ -221,6 +318,11 @@ FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint&
return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h);
}
+bool Font::canReturnFallbackFontsForComplexText()
+{
+ return false;
+}
+
QFont Font::font() const
{
QFont f = primaryFont()->getQtFont();
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
index cc707da1b1..fb3d6219d9 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
@@ -78,9 +78,6 @@ void ImageDecoderQt::setData(SharedBuffer* data, bool allDataReceived)
m_buffer->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
m_reader.set(new QImageReader(m_buffer.get(), m_format));
- // This will force the JPEG decoder to use JDCT_IFAST
- m_reader->setQuality(49);
-
// QImageReader only allows retrieving the format before reading the image
m_format = m_reader->format();
}
@@ -188,9 +185,21 @@ void ImageDecoderQt::internalReadImage(size_t frameIndex)
bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex)
{
- // Now get the QImage from Qt and place it in the RGBA32Buffer
- QImage img;
- if (!m_reader->read(&img)) {
+ QPixmap pixmap;
+ bool pixmapLoaded;
+ const int imageCount = m_reader->imageCount();
+ if (imageCount == 0 || imageCount == 1)
+ pixmapLoaded = pixmap.loadFromData((const uchar*)(m_data->data()), m_data->size(), m_format);
+ else {
+ QImage img;
+ const bool imageLoaded = m_reader->read(&img);
+ if (imageLoaded) {
+ pixmap = QPixmap::fromImage(img);
+ pixmapLoaded = true;
+ }
+ }
+
+ if (!pixmapLoaded) {
frameCount();
repetitionCount();
clearPointers();
@@ -198,12 +207,11 @@ bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex)
}
// now into the RGBA32Buffer - even if the image is not
- QSize imageSize = img.size();
RGBA32Buffer* const buffer = &m_frameBufferCache[frameIndex];
buffer->setRect(m_reader->currentImageRect());
buffer->setStatus(RGBA32Buffer::FrameComplete);
buffer->setDuration(m_reader->nextImageDelay());
- buffer->setDecodedImage(img);
+ buffer->setPixmap(pixmap);
return true;
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp
index 27d8dee712..717171f093 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/FontWin.cpp
@@ -34,6 +34,8 @@
#include "UniscribeController.h"
#include <wtf/MathExtras.h>
+using namespace std;
+
namespace WebCore {
bool Font::canReturnFallbackFontsForComplexText()
@@ -89,10 +91,16 @@ void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const F
drawGlyphBuffer(context, glyphBuffer, run, startPoint);
}
-float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts) const
+float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
UniscribeController controller(this, run, fallbackFonts);
controller.advance(run.length());
+ if (glyphOverflow) {
+ glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - ascent());
+ glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - descent());
+ glyphOverflow->left = max<int>(0, ceilf(-controller.minGlyphBoundingBoxX()));
+ glyphOverflow->right = max<int>(0, ceilf(controller.maxGlyphBoundingBoxX() - controller.runWidthSoFar()));
+ }
return controller.runWidthSoFar();
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
index 6b3a96e067..ee3a980693 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
@@ -126,10 +126,10 @@ void SimpleFontData::platformCharWidthInit()
}
}
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
+GlyphMetrics SimpleFontData::platformMetricsForGlyph(Glyph glyph, GlyphMetricsMode metricsMode) const
{
if (m_platformData.useGDI())
- return widthForGDIGlyph(glyph);
+ return metricsForGDIGlyph(glyph);
CGFontRef font = m_platformData.cgFont();
float pointSize = m_platformData.size();
@@ -139,8 +139,18 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
// FIXME: Need to add real support for printer fonts.
bool isPrinterFont = false;
wkGetGlyphAdvances(font, m, m_isSystemFont, isPrinterFont, glyph, advance);
-
- return advance.width + m_syntheticBoldOffset;
+ GlyphMetrics metrics;
+ metrics.horizontalAdvance = advance.width + m_syntheticBoldOffset;
+
+ if (metricsMode == GlyphBoundingBox) {
+ CGRect boundingBox;
+ CGFontGetGlyphBBoxes(font, &glyph, 1, &boundingBox);
+ CGFloat scale = pointSize / unitsPerEm();
+ metrics.boundingBox = CGRectApplyAffineTransform(boundingBox, CGAffineTransformMakeScale(scale, -scale));
+ if (m_syntheticBoldOffset)
+ metrics.boundingBox.setWidth(metrics.boundingBox.width() + m_syntheticBoldOffset);
+ }
+ return metrics;
}
}
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
index 5a3244ce10..f85f9ba544 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
@@ -179,16 +179,25 @@ void SimpleFontData::determinePitch()
ReleaseDC(0, dc);
}
-float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
+GlyphMetrics SimpleFontData::metricsForGDIGlyph(Glyph glyph) const
{
HDC hdc = GetDC(0);
SetGraphicsMode(hdc, GM_ADVANCED);
HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
- int width;
- GetCharWidthI(hdc, glyph, 1, 0, &width);
+
+ GLYPHMETRICS gdiMetrics;
+ static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 };
+ GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity);
+
SelectObject(hdc, oldFont);
ReleaseDC(0, hdc);
- return width + m_syntheticBoldOffset;
+
+ GlyphMetrics glyphMetrics;
+ glyphMetrics.horizontalAdvance = gdiMetrics.gmCellIncX + m_syntheticBoldOffset;
+ glyphMetrics.boundingBox = FloatRect(gdiMetrics.gmptGlyphOrigin.x, -gdiMetrics.gmptGlyphOrigin.y,
+ gdiMetrics.gmBlackBoxX + m_syntheticBoldOffset, gdiMetrics.gmBlackBoxY);
+
+ return glyphMetrics;
}
SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp
index f382857715..cfa15a2703 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.cpp
@@ -32,6 +32,8 @@
#include "SimpleFontData.h"
#include <wtf/MathExtras.h>
+using namespace std;
+
namespace WebCore {
// FIXME: Rearchitect this to be more like WidthIterator in Font.cpp. Have an advance() method
@@ -39,16 +41,20 @@ namespace WebCore {
// take the GlyphBuffer as an arg so that we don't have to populate the glyph buffer when
// measuring.
UniscribeController::UniscribeController(const Font* font, const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts)
-: m_font(*font)
-, m_run(run)
-, m_fallbackFonts(fallbackFonts)
-, m_end(run.length())
-, m_currentCharacter(0)
-, m_runWidthSoFar(0)
-, m_computingOffsetPosition(false)
-, m_includePartialGlyphs(false)
-, m_offsetX(0)
-, m_offsetPosition(0)
+ : m_font(*font)
+ , m_run(run)
+ , m_fallbackFonts(fallbackFonts)
+ , m_minGlyphBoundingBoxX(numeric_limits<float>::max())
+ , m_maxGlyphBoundingBoxX(numeric_limits<float>::min())
+ , m_minGlyphBoundingBoxY(numeric_limits<float>::max())
+ , m_maxGlyphBoundingBoxY(numeric_limits<float>::min())
+ , m_end(run.length())
+ , m_currentCharacter(0)
+ , m_runWidthSoFar(0)
+ , m_computingOffsetPosition(false)
+ , m_includePartialGlyphs(false)
+ , m_offsetX(0)
+ , m_offsetPosition(0)
{
m_padding = m_run.padding();
if (!m_padding)
@@ -374,6 +380,14 @@ bool UniscribeController::shapeAndPlaceItem(const UChar* cp, unsigned i, const S
glyphBuffer->add(glyph, fontData, advance, &size);
}
+ GlyphMetrics glyphMetrics = fontData->metricsForGlyph(glyph);
+ glyphMetrics.boundingBox.move(m_glyphOrigin.x(), m_glyphOrigin.y());
+ m_minGlyphBoundingBoxX = min(m_minGlyphBoundingBoxX, glyphMetrics.boundingBox.x());
+ m_maxGlyphBoundingBoxX = max(m_maxGlyphBoundingBoxX, glyphMetrics.boundingBox.right());
+ m_minGlyphBoundingBoxY = min(m_minGlyphBoundingBoxY, glyphMetrics.boundingBox.y());
+ m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, glyphMetrics.boundingBox.bottom());
+ m_glyphOrigin.move(advance + offsetX, -offsetY);
+
// Mutate the glyph array to contain our altered advances.
if (m_computingOffsetPosition)
advances[k] = advance;
diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h b/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h
index 23b8108b11..09203b5e9a 100644
--- a/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h
+++ b/src/3rdparty/webkit/WebCore/platform/graphics/win/UniscribeController.h
@@ -49,6 +49,11 @@ public:
// Returns the width of everything we've consumed so far.
float runWidthSoFar() const { return m_runWidthSoFar; }
+ float minGlyphBoundingBoxX() const { return m_minGlyphBoundingBoxX; }
+ float maxGlyphBoundingBoxX() const { return m_maxGlyphBoundingBoxX; }
+ float minGlyphBoundingBoxY() const { return m_minGlyphBoundingBoxY; }
+ float maxGlyphBoundingBoxY() const { return m_maxGlyphBoundingBoxY; }
+
private:
void resetControlAndState();
@@ -61,6 +66,11 @@ private:
const Font& m_font;
const TextRun& m_run;
HashSet<const SimpleFontData*>* m_fallbackFonts;
+ FloatPoint m_glyphOrigin;
+ float m_minGlyphBoundingBoxX;
+ float m_maxGlyphBoundingBoxX;
+ float m_minGlyphBoundingBoxY;
+ float m_maxGlyphBoundingBoxY;
SCRIPT_CONTROL m_control;
SCRIPT_STATE m_state;
diff --git a/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h b/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h
index d526e5e819..10747537c4 100644
--- a/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h
+++ b/src/3rdparty/webkit/WebCore/platform/image-decoders/ImageDecoder.h
@@ -40,6 +40,7 @@
#if PLATFORM(SKIA)
#include "NativeImageSkia.h"
#elif PLATFORM(QT)
+#include <QPixmap>
#include <QImage>
#endif
@@ -130,8 +131,7 @@ namespace WebCore {
}
#if PLATFORM(QT)
- void setDecodedImage(const QImage& image);
- QImage decodedImage() const { return m_image; }
+ void setPixmap(const QPixmap& pixmap);
#endif
private:
@@ -143,6 +143,8 @@ namespace WebCore {
#if PLATFORM(SKIA)
return m_bitmap.getAddr32(x, y);
#elif PLATFORM(QT)
+ m_image = m_pixmap.toImage();
+ m_pixmap = QPixmap();
return reinterpret_cast<QRgb*>(m_image.scanLine(y)) + x;
#else
return m_bytes.data() + (y * width()) + x;
@@ -168,6 +170,7 @@ namespace WebCore {
#if PLATFORM(SKIA)
NativeImageSkia m_bitmap;
#elif PLATFORM(QT)
+ mutable QPixmap m_pixmap;
mutable QImage m_image;
bool m_hasAlpha;
IntSize m_size;
diff --git a/src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp b/src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
index b2e5e1765a..044515abd9 100644
--- a/src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp
@@ -57,6 +57,7 @@ RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
void RGBA32Buffer::clear()
{
+ m_pixmap = QPixmap();
m_image = QImage();
m_status = FrameEmpty;
// NOTE: Do not reset other members here; clearFrameBufferCache()
@@ -67,7 +68,11 @@ void RGBA32Buffer::clear()
void RGBA32Buffer::zeroFill()
{
- m_image.fill(0);
+ if (m_pixmap.isNull() && !m_image.isNull()) {
+ m_pixmap = QPixmap(m_image.width(), m_image.height());
+ m_image = QImage();
+ }
+ m_pixmap.fill(QColor(0, 0, 0, 0));
}
void RGBA32Buffer::copyBitmapData(const RGBA32Buffer& other)
@@ -76,6 +81,7 @@ void RGBA32Buffer::copyBitmapData(const RGBA32Buffer& other)
return;
m_image = other.m_image;
+ m_pixmap = other.m_pixmap;
m_size = other.m_size;
m_hasAlpha = other.m_hasAlpha;
}
@@ -87,8 +93,9 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight)
ASSERT(width() == 0 && height() == 0);
m_size = IntSize(newWidth, newHeight);
- m_image = QImage(newWidth, newHeight, QImage::Format_ARGB32_Premultiplied);
- if (m_image.isNull())
+ m_image = QImage();
+ m_pixmap = QPixmap(newWidth, newHeight);
+ if (m_pixmap.isNull())
return false;
// Zero the image.
@@ -99,10 +106,11 @@ bool RGBA32Buffer::setSize(int newWidth, int newHeight)
QPixmap* RGBA32Buffer::asNewNativeImage() const
{
- QPixmap pix = QPixmap::fromImage(m_image);
- m_image = QImage();
-
- return new QPixmap(pix);
+ if (m_pixmap.isNull() && !m_image.isNull()) {
+ m_pixmap = QPixmap::fromImage(m_image);
+ m_image = QImage();
+ }
+ return new QPixmap(m_pixmap);
}
bool RGBA32Buffer::hasAlpha() const
@@ -121,11 +129,12 @@ void RGBA32Buffer::setStatus(FrameStatus status)
}
// The image must not have format 8888 pre multiplied...
-void RGBA32Buffer::setDecodedImage(const QImage& image)
+void RGBA32Buffer::setPixmap(const QPixmap& pixmap)
{
- m_image = image;
- m_size = image.size();
- m_hasAlpha = image.hasAlphaChannel();
+ m_pixmap = pixmap;
+ m_image = QImage();
+ m_size = pixmap.size();
+ m_hasAlpha = pixmap.hasAlphaChannel();
}
int RGBA32Buffer::width() const
diff --git a/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp b/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp
index 23dc4e7ba6..f83ebc60d5 100644
--- a/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp
+++ b/src/3rdparty/webkit/WebCore/rendering/InlineFlowBox.cpp
@@ -288,8 +288,10 @@ int InlineFlowBox::placeBoxesHorizontally(int xPos, bool& needsWordSpacing)
int letterSpacing = min(0, (int)rt->style(m_firstLine)->font().letterSpacing());
rightLayoutOverflow = max(xPos + text->width() - letterSpacing, rightLayoutOverflow);
- int leftGlyphOverflow = -strokeOverflow;
- int rightGlyphOverflow = strokeOverflow - letterSpacing;
+ GlyphOverflow* glyphOverflow = static_cast<InlineTextBox*>(curr)->glyphOverflow();
+
+ int leftGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->left : 0);
+ int rightGlyphOverflow = strokeOverflow - letterSpacing + (glyphOverflow ? glyphOverflow->right : 0);
int childOverflowLeft = leftGlyphOverflow;
int childOverflowRight = rightGlyphOverflow;
@@ -412,35 +414,35 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi
int lineHeight;
int baseline;
- Vector<const SimpleFontData*> usedFonts;
+ Vector<const SimpleFontData*>* usedFonts = 0;
if (curr->isInlineTextBox())
- static_cast<InlineTextBox*>(curr)->takeFallbackFonts(usedFonts);
+ usedFonts = static_cast<InlineTextBox*>(curr)->fallbackFonts();
- if (!usedFonts.isEmpty()) {
- usedFonts.append(curr->renderer()->style(m_firstLine)->font().primaryFont());
+ if (usedFonts) {
+ usedFonts->append(curr->renderer()->style(m_firstLine)->font().primaryFont());
Length parentLineHeight = curr->renderer()->parent()->style()->lineHeight();
if (parentLineHeight.isNegative()) {
int baselineToBottom = 0;
baseline = 0;
- for (size_t i = 0; i < usedFonts.size(); ++i) {
- int halfLeading = (usedFonts[i]->lineSpacing() - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2;
- baseline = max(baseline, halfLeading + usedFonts[i]->ascent());
- baselineToBottom = max(baselineToBottom, usedFonts[i]->lineSpacing() - usedFonts[i]->ascent() - usedFonts[i]->descent() - halfLeading);
+ for (size_t i = 0; i < usedFonts->size(); ++i) {
+ int halfLeading = (usedFonts->at(i)->lineSpacing() - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2;
+ baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent());
+ baselineToBottom = max(baselineToBottom, usedFonts->at(i)->lineSpacing() - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent() - halfLeading);
}
lineHeight = baseline + baselineToBottom;
} else if (parentLineHeight.isPercent()) {
lineHeight = parentLineHeight.calcMinValue(curr->renderer()->style()->fontSize());
baseline = 0;
- for (size_t i = 0; i < usedFonts.size(); ++i) {
- int halfLeading = (lineHeight - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2;
- baseline = max(baseline, halfLeading + usedFonts[i]->ascent());
+ for (size_t i = 0; i < usedFonts->size(); ++i) {
+ int halfLeading = (lineHeight - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2;
+ baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent());
}
} else {
lineHeight = parentLineHeight.value();
baseline = 0;
- for (size_t i = 0; i < usedFonts.size(); ++i) {
- int halfLeading = (lineHeight - usedFonts[i]->ascent() - usedFonts[i]->descent()) / 2;
- baseline = max(baseline, halfLeading + usedFonts[i]->ascent());
+ for (size_t i = 0; i < usedFonts->size(); ++i) {
+ int halfLeading = (lineHeight - usedFonts->at(i)->ascent() - usedFonts->at(i)->descent()) / 2;
+ baseline = max(baseline, halfLeading + usedFonts->at(i)->ascent());
}
}
} else {
@@ -562,10 +564,12 @@ void InlineFlowBox::computeVerticalOverflow(int lineTop, int lineBottom, bool st
continue;
int strokeOverflow = static_cast<int>(ceilf(rt->style()->textStrokeWidth() / 2.0f));
-
- int topGlyphOverflow = -strokeOverflow;
- int bottomGlyphOverflow = strokeOverflow;
-
+
+ GlyphOverflow* glyphOverflow = static_cast<InlineTextBox*>(curr)->glyphOverflow();
+
+ int topGlyphOverflow = -strokeOverflow - (glyphOverflow ? glyphOverflow->top : 0);
+ int bottomGlyphOverflow = strokeOverflow + (glyphOverflow ? glyphOverflow->bottom : 0);
+
int childOverflowTop = topGlyphOverflow;
int childOverflowBottom = bottomGlyphOverflow;
for (ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next) {
diff --git a/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp b/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp
index 9f17b0c05d..3c0d13bc18 100644
--- a/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp
+++ b/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.cpp
@@ -1029,30 +1029,48 @@ bool InlineTextBox::containsCaretOffset(int offset) const
return true;
}
-typedef HashMap<InlineTextBox*, Vector<const SimpleFontData*> > FallbackFontsMap;
-static FallbackFontsMap* gFallbackFontsMap;
-
void InlineTextBox::setFallbackFonts(const HashSet<const SimpleFontData*>& fallbackFonts)
{
- if (!gFallbackFontsMap)
- gFallbackFontsMap = new FallbackFontsMap;
+ if (!s_glyphOverflowAndFallbackFontsMap)
+ s_glyphOverflowAndFallbackFontsMap = new GlyphOverflowAndFallbackFontsMap;
- FallbackFontsMap::iterator it = gFallbackFontsMap->set(this, Vector<const SimpleFontData*>()).first;
- ASSERT(it->second.isEmpty());
- copyToVector(fallbackFonts, it->second);
+ GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->add(this, make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
+ ASSERT(it->second.first.isEmpty());
+ copyToVector(fallbackFonts, it->second.first);
}
-void InlineTextBox::takeFallbackFonts(Vector<const SimpleFontData*>& fallbackFonts)
+Vector<const SimpleFontData*>* InlineTextBox::fallbackFonts() const
{
- if (!gFallbackFontsMap)
- return;
+ if (!s_glyphOverflowAndFallbackFontsMap)
+ return 0;
- FallbackFontsMap::iterator it = gFallbackFontsMap->find(this);
- if (it == gFallbackFontsMap->end())
- return;
+ GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->find(this);
+ if (it == s_glyphOverflowAndFallbackFontsMap->end())
+ return 0;
+
+ return &it->second.first;
+}
+
+InlineTextBox::GlyphOverflowAndFallbackFontsMap* InlineTextBox::s_glyphOverflowAndFallbackFontsMap = 0;
+
+void InlineTextBox::setGlyphOverflow(const GlyphOverflow& glyphOverflow)
+{
+ if (!s_glyphOverflowAndFallbackFontsMap)
+ s_glyphOverflowAndFallbackFontsMap = new GlyphOverflowAndFallbackFontsMap;
+
+ GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->add(this, make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).first;
+ it->second.second = glyphOverflow;
+}
+
+GlyphOverflow* InlineTextBox::glyphOverflow() const
+{
+ if (!s_glyphOverflowAndFallbackFontsMap)
+ return 0;
+ GlyphOverflowAndFallbackFontsMap::iterator it = s_glyphOverflowAndFallbackFontsMap->find(this);
+ if (it == s_glyphOverflowAndFallbackFontsMap->end())
+ return 0;
- fallbackFonts.swap(it->second);
- gFallbackFontsMap->remove(it);
+ return &it->second.second;
}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h b/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h
index 96ca4c3873..7a4432e9ae 100644
--- a/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h
+++ b/src/3rdparty/webkit/WebCore/rendering/InlineTextBox.h
@@ -64,7 +64,16 @@ public:
void offsetRun(int d) { m_start += d; }
void setFallbackFonts(const HashSet<const SimpleFontData*>&);
- void takeFallbackFonts(Vector<const SimpleFontData*>&);
+ Vector<const SimpleFontData*>* fallbackFonts() const;
+
+ void setGlyphOverflow(const GlyphOverflow&);
+ GlyphOverflow* glyphOverflow() const;
+
+ static void clearGlyphOverflowAndFallbackFontMap()
+ {
+ if (s_glyphOverflowAndFallbackFontsMap)
+ s_glyphOverflowAndFallbackFontsMap->clear();
+ }
unsigned short truncation() { return m_truncation; }
@@ -129,6 +138,9 @@ private:
unsigned short m_truncation; // Where to truncate when text overflow is applied. We use special constants to
// denote no truncation (the whole run paints) and full truncation (nothing paints at all).
+ typedef HashMap<const InlineTextBox*, pair<Vector<const SimpleFontData*>, GlyphOverflow> > GlyphOverflowAndFallbackFontsMap;
+ static GlyphOverflowAndFallbackFontsMap* s_glyphOverflowAndFallbackFontsMap;
+
protected:
void paintCompositionBackground(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, int startPos, int endPos);
void paintDocumentMarkers(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, bool background);
diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp
index 6e890606c5..9ef6a23702 100644
--- a/src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/src/3rdparty/webkit/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -342,7 +342,8 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool
needsWordSpacing = !isSpaceOrNewline(rt->characters()[r->m_stop - 1]) && r->m_stop == length;
}
HashSet<const SimpleFontData*> fallbackFonts;
- r->m_box->setWidth(rt->width(r->m_start, r->m_stop - r->m_start, totWidth, firstLine, &fallbackFonts));
+ GlyphOverflow glyphOverflow;
+ r->m_box->setWidth(rt->width(r->m_start, r->m_stop - r->m_start, totWidth, firstLine, &fallbackFonts, &glyphOverflow));
if (!fallbackFonts.isEmpty()
#if ENABLE(SVG)
&& !isSVGText()
@@ -351,6 +352,14 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool
ASSERT(r->m_box->isText());
static_cast<InlineTextBox*>(r->m_box)->setFallbackFonts(fallbackFonts);
}
+ if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right)
+#if ENABLE(SVG)
+ && !isSVGText()
+#endif
+ ) {
+ ASSERT(r->m_box->isText());
+ static_cast<InlineTextBox*>(r->m_box)->setGlyphOverflow(glyphOverflow);
+ }
} else if (!r->m_object->isRenderInline()) {
RenderBox* renderBox = toRenderBox(r->m_object);
renderBox->calcWidth();
@@ -734,6 +743,7 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
// Now position our text runs vertically.
computeVerticalPositionsForLine(lineBox, resolver.firstRun());
+ InlineTextBox::clearGlyphOverflowAndFallbackFontMap();
#if ENABLE(SVG)
// Special SVG text layout code
diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderText.cpp b/src/3rdparty/webkit/WebCore/rendering/RenderText.cpp
index aa919e0fb5..307db64314 100644
--- a/src/3rdparty/webkit/WebCore/rendering/RenderText.cpp
+++ b/src/3rdparty/webkit/WebCore/rendering/RenderText.cpp
@@ -61,7 +61,7 @@ RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str)
, m_linesDirty(false)
, m_containsReversedText(false)
, m_isAllASCII(m_text.containsOnlyASCII())
- , m_knownNotToUseFallbackFonts(false)
+ , m_knownToHaveNoOverflowAndNoFallbackFonts(false)
{
ASSERT(m_text);
@@ -106,7 +106,7 @@ void RenderText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl
// need to relayout.
if (diff == StyleDifferenceLayout) {
setNeedsLayoutAndPrefWidthsRecalc();
- m_knownNotToUseFallbackFonts = false;
+ m_knownToHaveNoOverflowAndNoFallbackFonts = false;
}
ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE;
@@ -428,7 +428,7 @@ IntRect RenderText::localCaretRect(InlineBox* inlineBox, int caretOffset, int* e
return IntRect(left, top, caretWidth, height);
}
-ALWAYS_INLINE int RenderText::widthFromCache(const Font& f, int start, int len, int xPos, HashSet<const SimpleFontData*>* fallbackFonts) const
+ALWAYS_INLINE int RenderText::widthFromCache(const Font& f, int start, int len, int xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
if (f.isFixedPitch() && !f.isSmallCaps() && m_isAllASCII) {
int monospaceCharacterWidth = f.spaceWidth();
@@ -460,7 +460,7 @@ ALWAYS_INLINE int RenderText::widthFromCache(const Font& f, int start, int len,
return w;
}
- return f.width(TextRun(text()->characters() + start, len, allowTabs(), xPos), fallbackFonts);
+ return f.width(TextRun(text()->characters() + start, len, allowTabs(), xPos), fallbackFonts, glyphOverflow);
}
void RenderText::trimmedPrefWidths(int leadWidth,
@@ -531,7 +531,7 @@ void RenderText::trimmedPrefWidths(int leadWidth,
linelen++;
if (linelen) {
- endMaxW = widthFromCache(f, i, linelen, leadWidth + endMaxW, 0);
+ endMaxW = widthFromCache(f, i, linelen, leadWidth + endMaxW, 0, 0);
if (firstLine) {
firstLine = false;
leadWidth = 0;
@@ -576,14 +576,15 @@ int RenderText::maxPrefWidth() const
void RenderText::calcPrefWidths(int leadWidth)
{
HashSet<const SimpleFontData*> fallbackFonts;
- calcPrefWidths(leadWidth, fallbackFonts);
- if (fallbackFonts.isEmpty())
- m_knownNotToUseFallbackFonts = true;
+ GlyphOverflow glyphOverflow;
+ calcPrefWidths(leadWidth, fallbackFonts, glyphOverflow);
+ if (fallbackFonts.isEmpty() && !glyphOverflow.left && !glyphOverflow.right && !glyphOverflow.top && !glyphOverflow.bottom)
+ m_knownToHaveNoOverflowAndNoFallbackFonts = true;
}
-void RenderText::calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& fallbackFonts)
+void RenderText::calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
{
- ASSERT(m_hasTab || prefWidthsDirty() || !m_knownNotToUseFallbackFonts);
+ ASSERT(m_hasTab || prefWidthsDirty() || !m_knownToHaveNoOverflowAndNoFallbackFonts);
m_minWidth = 0;
m_beginMinWidth = 0;
@@ -613,6 +614,8 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& f
int nextBreakable = -1;
int lastWordBoundary = 0;
+ int firstGlyphLeftOverflow = -1;
+
bool breakNBSP = style()->autoWrap() && style()->nbspMode() == SPACE;
bool breakAll = (style()->wordBreak() == BreakAllWordBreak || style()->wordBreak() == BreakWordBreak) && style()->autoWrap();
@@ -655,7 +658,9 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& f
lastWordBoundary++;
continue;
} else if (c == softHyphen) {
- currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts);
+ currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow);
+ if (firstGlyphLeftOverflow < 0)
+ firstGlyphLeftOverflow = glyphOverflow.left;
lastWordBoundary = i + 1;
continue;
}
@@ -678,13 +683,15 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& f
int wordLen = j - i;
if (wordLen) {
- int w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts);
+ int w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow);
+ if (firstGlyphLeftOverflow < 0)
+ firstGlyphLeftOverflow = glyphOverflow.left;
currMinWidth += w;
if (betweenWords) {
if (lastWordBoundary == i)
currMaxWidth += w;
else
- currMaxWidth += widthFromCache(f, lastWordBoundary, j - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts);
+ currMaxWidth += widthFromCache(f, lastWordBoundary, j - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow);
lastWordBoundary = j;
}
@@ -737,6 +744,7 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& f
currMaxWidth = 0;
} else {
currMaxWidth += f.width(TextRun(txt + i, 1, allowTabs(), leadWidth + currMaxWidth));
+ glyphOverflow.right = 0;
needsWordSpacing = isSpace && !previousCharacterIsSpace && i == len - 1;
}
ASSERT(lastWordBoundary == i);
@@ -744,6 +752,9 @@ void RenderText::calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& f
}
}
+ if (firstGlyphLeftOverflow > 0)
+ glyphOverflow.left = firstGlyphLeftOverflow;
+
if ((needsWordSpacing && len > 1) || (ignoringSpaces && !firstWord))
currMaxWidth += wordSpacing;
@@ -1019,7 +1030,7 @@ void RenderText::setText(PassRefPtr<StringImpl> text, bool force)
setTextInternal(text);
setNeedsLayoutAndPrefWidthsRecalc();
- m_knownNotToUseFallbackFonts = false;
+ m_knownToHaveNoOverflowAndNoFallbackFonts = false;
AXObjectCache* axObjectCache = document()->axObjectCache();
if (axObjectCache->accessibilityEnabled())
@@ -1085,7 +1096,7 @@ void RenderText::positionLineBox(InlineBox* box)
m_containsReversedText |= s->direction() == RTL;
}
-unsigned RenderText::width(unsigned from, unsigned len, int xPos, bool firstLine, HashSet<const SimpleFontData*>* fallbackFonts) const
+unsigned RenderText::width(unsigned from, unsigned len, int xPos, bool firstLine, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
if (from >= textLength())
return 0;
@@ -1093,10 +1104,10 @@ unsigned RenderText::width(unsigned from, unsigned len, int xPos, bool firstLine
if (from + len > textLength())
len = textLength() - from;
- return width(from, len, style(firstLine)->font(), xPos, fallbackFonts);
+ return width(from, len, style(firstLine)->font(), xPos, fallbackFonts, glyphOverflow);
}
-unsigned RenderText::width(unsigned from, unsigned len, const Font& f, int xPos, HashSet<const SimpleFontData*>* fallbackFonts) const
+unsigned RenderText::width(unsigned from, unsigned len, const Font& f, int xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
ASSERT(from + len <= textLength());
if (!characters())
@@ -1106,18 +1117,19 @@ unsigned RenderText::width(unsigned from, unsigned len, const Font& f, int xPos,
if (&f == &style()->font()) {
if (!style()->preserveNewline() && !from && len == textLength()) {
if (fallbackFonts) {
- if (prefWidthsDirty() || !m_knownNotToUseFallbackFonts) {
- const_cast<RenderText*>(this)->calcPrefWidths(0, *fallbackFonts);
- if (fallbackFonts->isEmpty())
- m_knownNotToUseFallbackFonts = true;
+ ASSERT(glyphOverflow);
+ if (prefWidthsDirty() || !m_knownToHaveNoOverflowAndNoFallbackFonts) {
+ const_cast<RenderText*>(this)->calcPrefWidths(0, *fallbackFonts, *glyphOverflow);
+ if (fallbackFonts->isEmpty() && !glyphOverflow->left && !glyphOverflow->right && !glyphOverflow->top && !glyphOverflow->bottom)
+ m_knownToHaveNoOverflowAndNoFallbackFonts = true;
}
w = m_maxWidth;
} else
w = maxPrefWidth();
} else
- w = widthFromCache(f, from, len, xPos, fallbackFonts);
+ w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow);
} else
- w = f.width(TextRun(text()->characters() + from, len, allowTabs(), xPos), fallbackFonts);
+ w = f.width(TextRun(text()->characters() + from, len, allowTabs(), xPos), fallbackFonts, glyphOverflow);
return w;
}
diff --git a/src/3rdparty/webkit/WebCore/rendering/RenderText.h b/src/3rdparty/webkit/WebCore/rendering/RenderText.h
index e9ed147a4d..9b1467d459 100644
--- a/src/3rdparty/webkit/WebCore/rendering/RenderText.h
+++ b/src/3rdparty/webkit/WebCore/rendering/RenderText.h
@@ -67,8 +67,8 @@ public:
unsigned textLength() const { return m_text.length(); } // non virtual implementation of length()
void positionLineBox(InlineBox*);
- virtual unsigned width(unsigned from, unsigned len, const Font&, int xPos, HashSet<const SimpleFontData*>* fallbackFonts = 0) const;
- virtual unsigned width(unsigned from, unsigned len, int xPos, bool firstLine = false, HashSet<const SimpleFontData*>* fallbackFonts = 0) const;
+ virtual unsigned width(unsigned from, unsigned len, const Font&, int xPos, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
+ virtual unsigned width(unsigned from, unsigned len, int xPos, bool firstLine = false, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
@@ -133,7 +133,7 @@ protected:
virtual InlineTextBox* createTextBox(); // Subclassed by SVG.
private:
- void calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& fallbackFonts);
+ void calcPrefWidths(int leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow&);
// Make length() private so that callers that have a RenderText*
// will use the more efficient textLength() instead, while
@@ -146,7 +146,7 @@ private:
void deleteTextBoxes();
bool containsOnlyWhitespace(unsigned from, unsigned len) const;
- int widthFromCache(const Font&, int start, int len, int xPos, HashSet<const SimpleFontData*>* fallbackFonts) const;
+ int widthFromCache(const Font&, int start, int len, int xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const;
bool isAllASCII() const { return m_isAllASCII; }
int m_minWidth; // here to minimize padding in 64-bit.
@@ -171,7 +171,7 @@ private:
// or removed).
bool m_containsReversedText : 1;
bool m_isAllASCII : 1;
- mutable bool m_knownNotToUseFallbackFonts : 1;
+ mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1;
};
inline RenderText* toRenderText(RenderObject* object)