Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (194446 => 194447)
--- trunk/Source/WebCore/CMakeLists.txt 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/CMakeLists.txt 2015-12-30 17:19:03 UTC (rev 194447)
@@ -2472,6 +2472,7 @@
rendering/SimpleLineLayoutResolver.cpp
rendering/SimpleLineLayoutTextFragmentIterator.cpp
rendering/TextAutosizer.cpp
+ rendering/TextDecorationPainter.cpp
rendering/TextPaintStyle.cpp
rendering/TextPainter.cpp
rendering/break_lines.cpp
Modified: trunk/Source/WebCore/ChangeLog (194446 => 194447)
--- trunk/Source/WebCore/ChangeLog 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/ChangeLog 2015-12-30 17:19:03 UTC (rev 194447)
@@ -1,3 +1,51 @@
+2015-12-30 Zalan Bujtas <[email protected]>
+
+ Move InlineTextBox's text decoration painting to its own class.
+ https://bugs.webkit.org/show_bug.cgi?id=152587
+
+ Reviewed by Myles C. Maxfield.
+
+ This is in preparation for adding text decoration support for simple line layout.
+
+ No change in functionality.
+
+ * CMakeLists.txt:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::paintDecoration):
+ (WebCore::compareTuples): Deleted.
+ (WebCore::translateIntersectionPointsToSkipInkBoundaries): Deleted.
+ (WebCore::drawSkipInkUnderline): Deleted.
+ (WebCore::textDecorationStyleToStrokeStyle): Deleted.
+ (WebCore::adjustStepToDecorationLength): Deleted.
+ (WebCore::strokeWavyTextDecoration): Deleted.
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::getTextDecorationColorsAndStyles):
+ * rendering/RenderObject.h:
+ * rendering/RenderingAllInOne.cpp:
+ * rendering/TextDecorationPainter.cpp: Added.
+ (WebCore::adjustStepToDecorationLength):
+ (WebCore::strokeWavyTextDecoration):
+ (WebCore::compareTuples):
+ (WebCore::translateIntersectionPointsToSkipInkBoundaries):
+ (WebCore::drawSkipInkUnderline):
+ (WebCore::textDecorationStyleToStrokeStyle):
+ (WebCore::TextDecorationPainter::TextDecorationPainter):
+ (WebCore::TextDecorationPainter::paintTextDecoration):
+ * rendering/TextDecorationPainter.h: Added.
+ (WebCore::TextDecorationPainter::setInlineTextBox):
+ (WebCore::TextDecorationPainter::setFont):
+ (WebCore::TextDecorationPainter::setIsHorizontal):
+ (WebCore::TextDecorationPainter::setWidth):
+ (WebCore::TextDecorationPainter::setBaseline):
+ (WebCore::TextDecorationPainter::addTextShadow):
+ * style/InlineTextBoxStyle.cpp:
+ (WebCore::computeUnderlineOffset):
+ (WebCore::visualOverflowForDecorations):
+ * style/InlineTextBoxStyle.h:
+
2015-12-30 Zan Dobersek <[email protected]>
[CoordinatedGraphics] VideoRenderRequestScheduler shouldn't dispatch to main thread in threaded compositor
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (194446 => 194447)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2015-12-30 17:19:03 UTC (rev 194447)
@@ -13480,6 +13480,20 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="..\rendering\TextDecorationPainter.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="..\rendering\TextPainter.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -21841,6 +21855,7 @@
<ClInclude Include="..\rendering\svg\SVGResourcesCache.h" />
<ClInclude Include="..\rendering\svg\SVGResourcesCycleSolver.h" />
<ClInclude Include="..\rendering\TableLayout.h" />
+ <ClInclude Include="..\rendering\TextDecorationPainter.h" />
<ClInclude Include="..\rendering\TextPaintStyle.h" />
<ClInclude Include="..\rendering\TextPainter.h" />
<ClInclude Include="..\rendering\TrailingFloatsRootInlineBox.h" />
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (194446 => 194447)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2015-12-30 17:19:03 UTC (rev 194447)
@@ -2900,6 +2900,9 @@
<ClCompile Include="..\rendering\svg\SVGTextRunRenderingContext.cpp">
<Filter>rendering\svg</Filter>
</ClCompile>
+ <ClCompile Include="..\rendering\TextDecorationPainter.cpp">
+ <Filter>rendering</Filter>
+ </ClCompile>
<ClCompile Include="..\rendering\TextPainter.cpp">
<Filter>rendering</Filter>
</ClCompile>
@@ -9682,6 +9685,9 @@
<ClInclude Include="..\rendering\TableLayout.h">
<Filter>rendering</Filter>
</ClInclude>
+ <ClInclude Include="..\rendering\TextDecorationPainter.h">
+ <Filter>rendering</Filter>
+ </ClInclude>
<ClInclude Include="..\rendering\TextPainter.h">
<Filter>rendering</Filter>
</ClInclude>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (194446 => 194447)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2015-12-30 17:19:03 UTC (rev 194447)
@@ -2288,6 +2288,8 @@
5824ABAB1AE849C8009074B7 /* RenderTreePosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 5824ABA91AE849C8009074B7 /* RenderTreePosition.h */; };
582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h */; };
582CB0551A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp */; };
+ 582DE3241C30C85400BE02A8 /* TextDecorationPainter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 582DE3221C30C85400BE02A8 /* TextDecorationPainter.cpp */; };
+ 582DE3251C30C85400BE02A8 /* TextDecorationPainter.h in Headers */ = {isa = PBXBuildFile; fileRef = 582DE3231C30C85400BE02A8 /* TextDecorationPainter.h */; };
585D6DFC1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */; };
585D6E031A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 585D6E011A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.cpp */; };
585D6E041A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h in Headers */ = {isa = PBXBuildFile; fileRef = 585D6E021A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h */; };
@@ -9731,6 +9733,8 @@
5824ABA91AE849C8009074B7 /* RenderTreePosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreePosition.h; sourceTree = "<group>"; };
582CB0521A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutTextFragmentIterator.h; sourceTree = "<group>"; };
582CB0541A78A2B200AFFCC4 /* SimpleLineLayoutTextFragmentIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutTextFragmentIterator.cpp; sourceTree = "<group>"; };
+ 582DE3221C30C85400BE02A8 /* TextDecorationPainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextDecorationPainter.cpp; sourceTree = "<group>"; };
+ 582DE3231C30C85400BE02A8 /* TextDecorationPainter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextDecorationPainter.h; sourceTree = "<group>"; };
585D6DFB1A15355600FA4F12 /* SimpleLineLayoutResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutResolver.cpp; sourceTree = "<group>"; };
585D6E011A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutFlowContents.cpp; sourceTree = "<group>"; };
585D6E021A1A792E00FA4F12 /* SimpleLineLayoutFlowContents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutFlowContents.h; sourceTree = "<group>"; };
@@ -23696,6 +23700,8 @@
A8CFF04C0A154F09000A4234 /* TableLayout.h */,
0F54DCE31881051D003EEDBB /* TextAutoSizing.cpp */,
0F54DCE41881051D003EEDBB /* TextAutoSizing.h */,
+ 582DE3221C30C85400BE02A8 /* TextDecorationPainter.cpp */,
+ 582DE3231C30C85400BE02A8 /* TextDecorationPainter.h */,
1C18DA56181AF6A500C4EF22 /* TextPainter.cpp */,
1C18DA57181AF6A500C4EF22 /* TextPainter.h */,
E4C91A0F1802343900A17F6D /* TextPaintStyle.cpp */,
@@ -25750,6 +25756,7 @@
A871D4560A127CBC00B12A68 /* HTMLPlugInElement.h in Headers */,
4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */,
A8EA7CB00A192B9C00A8EF5F /* HTMLPreElement.h in Headers */,
+ 582DE3251C30C85400BE02A8 /* TextDecorationPainter.h in Headers */,
977B3873122883E900B81FF8 /* HTMLPreloadScanner.h in Headers */,
A43BF5991149290A00C643CA /* HTMLProgressElement.h in Headers */,
A8CFF7A30A156978000A4234 /* HTMLQuoteElement.h in Headers */,
@@ -30543,6 +30550,7 @@
371E65CE13661EED00BEEDB0 /* PageSerializer.cpp in Sources */,
A7197F2617568AE5007B9442 /* PageThrottler.cpp in Sources */,
E1284AEA10447DEE00EAEB52 /* PageTransitionEvent.cpp in Sources */,
+ 582DE3241C30C85400BE02A8 /* TextDecorationPainter.cpp in Sources */,
51E1ECC20C91C90400DC255B /* PageURLRecord.cpp in Sources */,
FFD5B97A135CC97800D5E92A /* PageVisibilityState.cpp in Sources */,
FD3160A212B026F700C1A359 /* Panner.cpp in Sources */,
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (194446 => 194447)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2015-12-30 17:19:03 UTC (rev 194447)
@@ -48,6 +48,7 @@
#include "Settings.h"
#include "SVGTextRunRenderingContext.h"
#include "Text.h"
+#include "TextDecorationPainter.h"
#include "TextPaintStyle.h"
#include "TextPainter.h"
#include "break_lines.h"
@@ -67,71 +68,6 @@
typedef WTF::HashMap<const InlineTextBox*, LayoutRect> InlineTextBoxOverflowMap;
static InlineTextBoxOverflowMap* gTextBoxesWithOverflow;
-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
-static bool compareTuples(std::pair<float, float> l, std::pair<float, float> r)
-{
- return l.first < r.first;
-}
-
-static DashArray translateIntersectionPointsToSkipInkBoundaries(const DashArray& intersections, float dilationAmount, float totalWidth)
-{
- ASSERT(!(intersections.size() % 2));
-
- // Step 1: Make pairs so we can sort based on range starting-point. We dilate the ranges in this step as well.
- Vector<std::pair<float, float>> tuples;
- for (auto i = intersections.begin(); i != intersections.end(); i++, i++)
- tuples.append(std::make_pair(*i - dilationAmount, *(i + 1) + dilationAmount));
- std::sort(tuples.begin(), tuples.end(), &compareTuples);
-
- // Step 2: Deal with intersecting ranges.
- Vector<std::pair<float, float>> intermediateTuples;
- if (tuples.size() >= 2) {
- intermediateTuples.append(*tuples.begin());
- for (auto i = tuples.begin() + 1; i != tuples.end(); i++) {
- float& firstEnd = intermediateTuples.last().second;
- float secondStart = i->first;
- float secondEnd = i->second;
- if (secondStart <= firstEnd && secondEnd <= firstEnd) {
- // Ignore this range completely
- } else if (secondStart <= firstEnd)
- firstEnd = secondEnd;
- else
- intermediateTuples.append(*i);
- }
- } else
- intermediateTuples = tuples;
-
- // Step 3: Output the space between the ranges, but only if the space warrants an underline.
- float previous = 0;
- DashArray result;
- for (const auto& tuple : intermediateTuples) {
- if (tuple.first - previous > dilationAmount) {
- result.append(previous);
- result.append(tuple.first);
- }
- previous = tuple.second;
- }
- if (totalWidth - previous > dilationAmount) {
- result.append(previous);
- result.append(totalWidth);
- }
-
- return result;
-}
-
-static void drawSkipInkUnderline(GraphicsContext& context, const FontCascade& font, const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& localOrigin,
- float underlineOffset, float width, bool isPrinting, bool doubleLines)
-{
- FloatPoint adjustedLocalOrigin = localOrigin;
- adjustedLocalOrigin.move(0, underlineOffset);
- FloatRect underlineBoundingBox = context.computeLineBoundsForText(adjustedLocalOrigin, width, isPrinting);
- DashArray intersections = font.dashesForIntersectionsWithRect(textRun, textOrigin, underlineBoundingBox);
- DashArray a = translateIntersectionPointsToSkipInkBoundaries(intersections, underlineBoundingBox.height(), width);
- ASSERT(!(a.size() % 2));
- context.drawLinesForText(adjustedLocalOrigin, a, isPrinting, doubleLines);
-}
-#endif
-
InlineTextBox::~InlineTextBox()
{
if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow)
@@ -763,144 +699,6 @@
context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), compositionColor);
}
-static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle)
-{
- StrokeStyle strokeStyle = SolidStroke;
- switch (decorationStyle) {
- case TextDecorationStyleSolid:
- strokeStyle = SolidStroke;
- break;
- case TextDecorationStyleDouble:
- strokeStyle = DoubleStroke;
- break;
- case TextDecorationStyleDotted:
- strokeStyle = DottedStroke;
- break;
- case TextDecorationStyleDashed:
- strokeStyle = DashedStroke;
- break;
- case TextDecorationStyleWavy:
- strokeStyle = WavyStroke;
- break;
- }
-
- return strokeStyle;
-}
-
-static void adjustStepToDecorationLength(float& step, float& controlPointDistance, float length)
-{
- ASSERT(step > 0);
-
- if (length <= 0)
- return;
-
- unsigned stepCount = static_cast<unsigned>(length / step);
-
- // Each Bezier curve starts at the same pixel that the previous one
- // ended. We need to subtract (stepCount - 1) pixels when calculating the
- // length covered to account for that.
- float uncoveredLength = length - (stepCount * step - (stepCount - 1));
- float adjustment = uncoveredLength / stepCount;
- step += adjustment;
- controlPointDistance += adjustment;
-}
-
-/*
- * Draw one cubic Bezier curve and repeat the same pattern long the the decoration's axis.
- * The start point (p1), controlPoint1, controlPoint2 and end point (p2) of the Bezier curve
- * form a diamond shape:
- *
- * step
- * |-----------|
- *
- * controlPoint1
- * +
- *
- *
- * . .
- * . .
- * . .
- * (x1, y1) p1 + . + p2 (x2, y2) - <--- Decoration's axis
- * . . |
- * . . |
- * . . | controlPointDistance
- * |
- * |
- * + -
- * controlPoint2
- *
- * |-----------|
- * step
- */
-static void strokeWavyTextDecoration(GraphicsContext& context, FloatPoint& p1, FloatPoint& p2, float strokeThickness)
-{
- context.adjustLineToPixelBoundaries(p1, p2, strokeThickness, context.strokeStyle());
-
- Path path;
- path.moveTo(p1);
-
- float controlPointDistance;
- float step;
- getWavyStrokeParameters(strokeThickness, controlPointDistance, step);
-
- bool isVerticalLine = (p1.x() == p2.x());
-
- if (isVerticalLine) {
- ASSERT(p1.x() == p2.x());
-
- float xAxis = p1.x();
- float y1;
- float y2;
-
- if (p1.y() < p2.y()) {
- y1 = p1.y();
- y2 = p2.y();
- } else {
- y1 = p2.y();
- y2 = p1.y();
- }
-
- adjustStepToDecorationLength(step, controlPointDistance, y2 - y1);
- FloatPoint controlPoint1(xAxis + controlPointDistance, 0);
- FloatPoint controlPoint2(xAxis - controlPointDistance, 0);
-
- for (float y = y1; y + 2 * step <= y2;) {
- controlPoint1.setY(y + step);
- controlPoint2.setY(y + step);
- y += 2 * step;
- path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(xAxis, y));
- }
- } else {
- ASSERT(p1.y() == p2.y());
-
- float yAxis = p1.y();
- float x1;
- float x2;
-
- if (p1.x() < p2.x()) {
- x1 = p1.x();
- x2 = p2.x();
- } else {
- x1 = p2.x();
- x2 = p1.x();
- }
-
- adjustStepToDecorationLength(step, controlPointDistance, x2 - x1);
- FloatPoint controlPoint1(0, yAxis + controlPointDistance);
- FloatPoint controlPoint2(0, yAxis - controlPointDistance);
-
- for (float x = x1; x + 2 * step <= x2;) {
- controlPoint1.setX(x + step);
- controlPoint2.setX(x + step);
- x += 2 * step;
- path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(x, yAxis));
- }
- }
-
- context.setShouldAntialias(true);
- context.strokePath(path);
-}
-
void InlineTextBox::paintDecoration(GraphicsContext& context, const FontCascade& font, const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin,
TextDecoration decoration, const ShadowData* shadow)
{
@@ -921,128 +719,16 @@
localOrigin.move(m_logicalWidth - width, 0);
}
- // Get the text decoration colors.
- Color underlineColor, overlineColor, linethroughColor;
- TextDecorationStyle underlineStyle, overlineStyle, linethroughStyle;
- renderer().getTextDecorationColorsAndStyles(decoration, underlineColor, overlineColor, linethroughColor, underlineStyle, overlineStyle, linethroughStyle);
- if (isFirstLine())
- renderer().getTextDecorationColorsAndStyles(decoration, underlineColor, overlineColor, linethroughColor, underlineStyle, overlineStyle, linethroughStyle, true);
-
- // Use a special function for underlines to get the positioning exactly right.
- bool isPrinting = renderer().document().printing();
+ int baseline = lineStyle().fontMetrics().ascent();
+ TextDecorationPainter decorationPainter(context, decoration, renderer(), isFirstLine());
+ decorationPainter.setInlineTextBox(this);
+ decorationPainter.setFont(font);
+ decorationPainter.setWidth(width);
+ decorationPainter.setBaseline(baseline);
+ decorationPainter.setIsHorizontal(isHorizontal());
+ decorationPainter.addTextShadow(shadow);
- float textDecorationThickness = textDecorationStrokeThickness(renderer().style().fontSize());
- context.setStrokeThickness(textDecorationThickness);
-
- bool linesAreOpaque = !isPrinting && (!(decoration & TextDecorationUnderline) || underlineColor.alpha() == 255) && (!(decoration & TextDecorationOverline) || overlineColor.alpha() == 255) && (!(decoration & TextDecorationLineThrough) || linethroughColor.alpha() == 255);
-
- const RenderStyle& lineStyle = this->lineStyle();
- int baseline = lineStyle.fontMetrics().ascent();
-
- bool setClip = false;
- int extraOffset = 0;
- if (!linesAreOpaque && shadow && shadow->next()) {
- FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2));
- for (const ShadowData* s = shadow; s; s = s->next()) {
- int shadowExtent = s->paintingExtent();
- FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2));
- shadowRect.inflate(shadowExtent);
- int shadowX = isHorizontal() ? s->x() : s->y();
- int shadowY = isHorizontal() ? s->y() : -s->x();
- shadowRect.move(shadowX, shadowY);
- clipRect.unite(shadowRect);
- extraOffset = std::max(extraOffset, std::max(0, shadowY) + shadowExtent);
- }
- context.save();
- context.clip(clipRect);
- extraOffset += baseline + 2;
- localOrigin.move(0, extraOffset);
- setClip = true;
- }
-
- bool setShadow = false;
-
- do {
- if (shadow) {
- if (!shadow->next()) {
- // The last set of lines paints normally inside the clip.
- localOrigin.move(0, -extraOffset);
- extraOffset = 0;
- }
- int shadowX = isHorizontal() ? shadow->x() : shadow->y();
- int shadowY = isHorizontal() ? shadow->y() : -shadow->x();
- context.setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow->radius(), shadow->color());
- setShadow = true;
- shadow = shadow->next();
- }
-
- float wavyOffset = wavyOffsetFromDecoration();
-
- // These decorations should match the visual overflows computed in visualOverflowForDecorations()
- if (decoration & TextDecorationUnderline) {
- context.setStrokeColor(underlineColor);
- context.setStrokeStyle(textDecorationStyleToStrokeStyle(underlineStyle));
- const int underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), this, textDecorationThickness);
-
- switch (underlineStyle) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() + underlineOffset + wavyOffset);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() + underlineOffset + wavyOffset);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- default:
-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
- if ((lineStyle.textDecorationSkip() == TextDecorationSkipInk || lineStyle.textDecorationSkip() == TextDecorationSkipAuto) && isHorizontal()) {
- if (!context.paintingDisabled())
- drawSkipInkUnderline(context, font, textRun, textOrigin, localOrigin, underlineOffset, width, isPrinting, underlineStyle == TextDecorationStyleDouble);
- } else
- // FIXME: Need to support text-decoration-skip: none.
-#endif // CSS3_TEXT_DECORATION_SKIP_INK
- context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + underlineOffset), width, isPrinting, underlineStyle == TextDecorationStyleDouble);
- }
- }
- if (decoration & TextDecorationOverline) {
- context.setStrokeColor(overlineColor);
- context.setStrokeStyle(textDecorationStyleToStrokeStyle(overlineStyle));
- switch (overlineStyle) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() - wavyOffset);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() - wavyOffset);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- default:
-#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
- if ((lineStyle.textDecorationSkip() == TextDecorationSkipInk || lineStyle.textDecorationSkip() == TextDecorationSkipAuto) && isHorizontal()) {
- if (!context.paintingDisabled())
- drawSkipInkUnderline(context, font, textRun, textOrigin, localOrigin, 0, width, isPrinting, overlineStyle == TextDecorationStyleDouble);
- } else
- // FIXME: Need to support text-decoration-skip: none.
-#endif // CSS3_TEXT_DECORATION_SKIP_INK
- context.drawLineForText(localOrigin, width, isPrinting, overlineStyle == TextDecorationStyleDouble);
- }
- }
- if (decoration & TextDecorationLineThrough) {
- context.setStrokeColor(linethroughColor);
- context.setStrokeStyle(textDecorationStyleToStrokeStyle(linethroughStyle));
- switch (linethroughStyle) {
- case TextDecorationStyleWavy: {
- FloatPoint start(localOrigin.x(), localOrigin.y() + 2 * baseline / 3);
- FloatPoint end(localOrigin.x() + width, localOrigin.y() + 2 * baseline / 3);
- strokeWavyTextDecoration(context, start, end, textDecorationThickness);
- break;
- }
- default:
- context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + 2 * baseline / 3), width, isPrinting, linethroughStyle == TextDecorationStyleDouble);
- }
- }
- } while (shadow);
-
- if (setClip)
- context.restore();
- else if (setShadow)
- context.clearShadow();
+ decorationPainter.paintTextDecoration(textRun, textOrigin, localOrigin);
}
static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentMarker::MarkerType markerType)
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (194446 => 194447)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2015-12-30 17:19:03 UTC (rev 194447)
@@ -1801,9 +1801,9 @@
}
void RenderObject::getTextDecorationColorsAndStyles(int decorations, Color& underlineColor, Color& overlineColor, Color& linethroughColor,
- TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle)
+ TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle) const
{
- RenderObject* current = this;
+ const RenderObject* current = this;
RenderStyle* styleToUse = nullptr;
TextDecoration currDecs = TextDecorationNone;
Color resultColor;
Modified: trunk/Source/WebCore/rendering/RenderObject.h (194446 => 194447)
--- trunk/Source/WebCore/rendering/RenderObject.h 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2015-12-30 17:19:03 UTC (rev 194447)
@@ -706,7 +706,7 @@
virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
void getTextDecorationColorsAndStyles(int decorations, Color& underlineColor, Color& overlineColor, Color& linethroughColor,
- TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle = false);
+ TextDecorationStyle& underlineStyle, TextDecorationStyle& overlineStyle, TextDecorationStyle& linethroughStyle, bool firstlineStyle = false) const;
// Return the RenderLayerModelObject in the container chain which is responsible for painting this object, or nullptr
// if painting is root-relative. This is the container that should be passed to the 'forRepaint'
Modified: trunk/Source/WebCore/rendering/RenderingAllInOne.cpp (194446 => 194447)
--- trunk/Source/WebCore/rendering/RenderingAllInOne.cpp 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/rendering/RenderingAllInOne.cpp 2015-12-30 17:19:03 UTC (rev 194447)
@@ -146,6 +146,7 @@
#include "SimpleLineLayoutResolver.cpp"
#include "SimpleLineLayoutTextFragmentIterator.cpp"
#include "TextAutosizer.cpp"
+#include "TextDecorationPainter.cpp"
#include "TextPaintStyle.cpp"
#include "TextPainter.cpp"
#include "break_lines.cpp"
Added: trunk/Source/WebCore/rendering/TextDecorationPainter.cpp (0 => 194447)
--- trunk/Source/WebCore/rendering/TextDecorationPainter.cpp (rev 0)
+++ trunk/Source/WebCore/rendering/TextDecorationPainter.cpp 2015-12-30 17:19:03 UTC (rev 194447)
@@ -0,0 +1,350 @@
+/*
+ * (C) 1999 Lars Knoll ([email protected])
+ * (C) 2000 Dirk Mueller ([email protected])
+ * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "TextDecorationPainter.h"
+
+#include "FontCascade.h"
+#include "GraphicsContext.h"
+#include "InlineTextBoxStyle.h"
+#include "RenderStyle.h"
+#include "RenderText.h"
+#include "ShadowData.h"
+#include "TextRun.h"
+
+namespace WebCore {
+
+static void adjustStepToDecorationLength(float& step, float& controlPointDistance, float length)
+{
+ ASSERT(step > 0);
+
+ if (length <= 0)
+ return;
+
+ unsigned stepCount = static_cast<unsigned>(length / step);
+
+ // Each Bezier curve starts at the same pixel that the previous one
+ // ended. We need to subtract (stepCount - 1) pixels when calculating the
+ // length covered to account for that.
+ float uncoveredLength = length - (stepCount * step - (stepCount - 1));
+ float adjustment = uncoveredLength / stepCount;
+ step += adjustment;
+ controlPointDistance += adjustment;
+}
+
+/*
+ * Draw one cubic Bezier curve and repeat the same pattern long the the decoration's axis.
+ * The start point (p1), controlPoint1, controlPoint2 and end point (p2) of the Bezier curve
+ * form a diamond shape:
+ *
+ * step
+ * |-----------|
+ *
+ * controlPoint1
+ * +
+ *
+ *
+ * . .
+ * . .
+ * . .
+ * (x1, y1) p1 + . + p2 (x2, y2) - <--- Decoration's axis
+ * . . |
+ * . . |
+ * . . | controlPointDistance
+ * |
+ * |
+ * + -
+ * controlPoint2
+ *
+ * |-----------|
+ * step
+ */
+static void strokeWavyTextDecoration(GraphicsContext& context, const FloatPoint& start, const FloatPoint& end, float strokeThickness)
+{
+ FloatPoint p1 = start;
+ FloatPoint p2 = end;
+ context.adjustLineToPixelBoundaries(p1, p2, strokeThickness, context.strokeStyle());
+
+ Path path;
+ path.moveTo(p1);
+
+ float controlPointDistance;
+ float step;
+ getWavyStrokeParameters(strokeThickness, controlPointDistance, step);
+
+ bool isVerticalLine = (p1.x() == p2.x());
+
+ if (isVerticalLine) {
+ ASSERT(p1.x() == p2.x());
+
+ float xAxis = p1.x();
+ float y1;
+ float y2;
+
+ if (p1.y() < p2.y()) {
+ y1 = p1.y();
+ y2 = p2.y();
+ } else {
+ y1 = p2.y();
+ y2 = p1.y();
+ }
+
+ adjustStepToDecorationLength(step, controlPointDistance, y2 - y1);
+ FloatPoint controlPoint1(xAxis + controlPointDistance, 0);
+ FloatPoint controlPoint2(xAxis - controlPointDistance, 0);
+
+ for (float y = y1; y + 2 * step <= y2;) {
+ controlPoint1.setY(y + step);
+ controlPoint2.setY(y + step);
+ y += 2 * step;
+ path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(xAxis, y));
+ }
+ } else {
+ ASSERT(p1.y() == p2.y());
+
+ float yAxis = p1.y();
+ float x1;
+ float x2;
+
+ if (p1.x() < p2.x()) {
+ x1 = p1.x();
+ x2 = p2.x();
+ } else {
+ x1 = p2.x();
+ x2 = p1.x();
+ }
+
+ adjustStepToDecorationLength(step, controlPointDistance, x2 - x1);
+ FloatPoint controlPoint1(0, yAxis + controlPointDistance);
+ FloatPoint controlPoint2(0, yAxis - controlPointDistance);
+
+ for (float x = x1; x + 2 * step <= x2;) {
+ controlPoint1.setX(x + step);
+ controlPoint2.setX(x + step);
+ x += 2 * step;
+ path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(x, yAxis));
+ }
+ }
+
+ context.setShouldAntialias(true);
+ context.strokePath(path);
+}
+
+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+static bool compareTuples(std::pair<float, float> l, std::pair<float, float> r)
+{
+ return l.first < r.first;
+}
+
+static DashArray translateIntersectionPointsToSkipInkBoundaries(const DashArray& intersections, float dilationAmount, float totalWidth)
+{
+ ASSERT(!(intersections.size() % 2));
+
+ // Step 1: Make pairs so we can sort based on range starting-point. We dilate the ranges in this step as well.
+ Vector<std::pair<float, float>> tuples;
+ for (auto i = intersections.begin(); i != intersections.end(); i++, i++)
+ tuples.append(std::make_pair(*i - dilationAmount, *(i + 1) + dilationAmount));
+ std::sort(tuples.begin(), tuples.end(), &compareTuples);
+
+ // Step 2: Deal with intersecting ranges.
+ Vector<std::pair<float, float>> intermediateTuples;
+ if (tuples.size() >= 2) {
+ intermediateTuples.append(*tuples.begin());
+ for (auto i = tuples.begin() + 1; i != tuples.end(); i++) {
+ float& firstEnd = intermediateTuples.last().second;
+ float secondStart = i->first;
+ float secondEnd = i->second;
+ if (secondStart <= firstEnd && secondEnd <= firstEnd) {
+ // Ignore this range completely
+ } else if (secondStart <= firstEnd)
+ firstEnd = secondEnd;
+ else
+ intermediateTuples.append(*i);
+ }
+ } else
+ intermediateTuples = tuples;
+
+ // Step 3: Output the space between the ranges, but only if the space warrants an underline.
+ float previous = 0;
+ DashArray result;
+ for (const auto& tuple : intermediateTuples) {
+ if (tuple.first - previous > dilationAmount) {
+ result.append(previous);
+ result.append(tuple.first);
+ }
+ previous = tuple.second;
+ }
+ if (totalWidth - previous > dilationAmount) {
+ result.append(previous);
+ result.append(totalWidth);
+ }
+
+ return result;
+}
+
+static void drawSkipInkUnderline(GraphicsContext& context, const FontCascade& font, const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& localOrigin,
+ float underlineOffset, float width, bool isPrinting, bool doubleLines)
+{
+ FloatPoint adjustedLocalOrigin = localOrigin;
+ adjustedLocalOrigin.move(0, underlineOffset);
+ FloatRect underlineBoundingBox = context.computeLineBoundsForText(adjustedLocalOrigin, width, isPrinting);
+ DashArray intersections = font.dashesForIntersectionsWithRect(textRun, textOrigin, underlineBoundingBox);
+ DashArray a = translateIntersectionPointsToSkipInkBoundaries(intersections, underlineBoundingBox.height(), width);
+ ASSERT(!(a.size() % 2));
+ context.drawLinesForText(adjustedLocalOrigin, a, isPrinting, doubleLines);
+}
+#endif
+
+static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle)
+{
+ StrokeStyle strokeStyle = SolidStroke;
+ switch (decorationStyle) {
+ case TextDecorationStyleSolid:
+ strokeStyle = SolidStroke;
+ break;
+ case TextDecorationStyleDouble:
+ strokeStyle = DoubleStroke;
+ break;
+ case TextDecorationStyleDotted:
+ strokeStyle = DottedStroke;
+ break;
+ case TextDecorationStyleDashed:
+ strokeStyle = DashedStroke;
+ break;
+ case TextDecorationStyleWavy:
+ strokeStyle = WavyStroke;
+ break;
+ }
+
+ return strokeStyle;
+}
+
+TextDecorationPainter::TextDecorationPainter(GraphicsContext& context, TextDecoration decoration, const RenderText& renderer, bool isFirstLine)
+ : m_context(context)
+ , m_decoration(decoration)
+ , m_wavyOffset(wavyOffsetFromDecoration())
+ , m_isPrinting(renderer.document().printing())
+ , m_lineStyle(isFirstLine ? renderer.firstLineStyle() : renderer.style())
+{
+ renderer.getTextDecorationColorsAndStyles(m_decoration, m_underlineColor, m_overlineColor, m_linethroughColor, m_underlineStyle, m_overlineStyle,
+ m_linethroughStyle);
+ if (isFirstLine) {
+ renderer.getTextDecorationColorsAndStyles(m_decoration, m_underlineColor, m_overlineColor, m_linethroughColor,
+ m_underlineStyle, m_overlineStyle, m_linethroughStyle, true);
+ }
+}
+
+void TextDecorationPainter::paintTextDecoration(const TextRun& textRun, const FloatPoint& textOrigin, const FloatPoint& boxOrigin)
+{
+ ASSERT(m_font);
+ float textDecorationThickness = textDecorationStrokeThickness(m_lineStyle.fontSize());
+ m_context.setStrokeThickness(textDecorationThickness);
+ FloatPoint localOrigin = boxOrigin;
+
+ auto paintDecoration = [&](TextDecorationStyle style, Color color, StrokeStyle strokeStyle,
+ const FloatPoint& start, const FloatPoint& end, int offset) {
+ m_context.setStrokeColor(color);
+ m_context.setStrokeStyle(strokeStyle);
+
+ if (style == TextDecorationStyleWavy) {
+ strokeWavyTextDecoration(m_context, start, end, textDecorationThickness);
+ } else if (m_decoration & TextDecorationUnderline || m_decoration & TextDecorationOverline) {
+#if ENABLE(CSS3_TEXT_DECORATION_SKIP_INK)
+ if ((m_lineStyle.textDecorationSkip() == TextDecorationSkipInk || m_lineStyle.textDecorationSkip() == TextDecorationSkipAuto) && m_isHorizontal) {
+ if (!m_context.paintingDisabled())
+ drawSkipInkUnderline(m_context, *m_font, textRun, textOrigin, localOrigin, offset, m_width, m_isPrinting, style == TextDecorationStyleDouble);
+ } else
+ // FIXME: Need to support text-decoration-skip: none.
+#endif
+ m_context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + offset), m_width, m_isPrinting, style == TextDecorationStyleDouble);
+
+ } else {
+ ASSERT(m_decoration & TextDecorationLineThrough);
+ m_context.drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + 2 * m_baseline / 3), m_width, m_isPrinting, style == TextDecorationStyleDouble);
+ }
+ };
+
+ bool linesAreOpaque = !m_isPrinting
+ && (!(m_decoration & TextDecorationUnderline) || m_underlineColor.alpha() == 255)
+ && (!(m_decoration & TextDecorationOverline) || m_overlineColor.alpha() == 255)
+ && (!(m_decoration & TextDecorationLineThrough) || m_linethroughColor.alpha() == 255);
+
+ int extraOffset = 0;
+ bool clipping = !linesAreOpaque && m_shadow && m_shadow->next();
+ if (clipping) {
+ FloatRect clipRect(localOrigin, FloatSize(m_width, m_baseline + 2));
+ for (const ShadowData* shadow = m_shadow; shadow; shadow = shadow->next()) {
+ int shadowExtent = shadow->paintingExtent();
+ FloatRect shadowRect(localOrigin, FloatSize(m_width, m_baseline + 2));
+ shadowRect.inflate(shadowExtent);
+ int shadowX = m_isHorizontal ? shadow->x() : shadow->y();
+ int shadowY = m_isHorizontal ? shadow->y() : -shadow->x();
+ shadowRect.move(shadowX, shadowY);
+ clipRect.unite(shadowRect);
+ extraOffset = std::max(extraOffset, std::max(0, shadowY) + shadowExtent);
+ }
+ m_context.save();
+ m_context.clip(clipRect);
+ extraOffset += m_baseline + 2;
+ localOrigin.move(0, extraOffset);
+ }
+
+ const ShadowData* shadow = m_shadow;
+ do {
+ if (shadow) {
+ if (!shadow->next()) {
+ // The last set of lines paints normally inside the clip.
+ localOrigin.move(0, -extraOffset);
+ extraOffset = 0;
+ }
+ int shadowX = m_isHorizontal ? shadow->x() : shadow->y();
+ int shadowY = m_isHorizontal ? shadow->y() : -shadow->x();
+ m_context.setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow->radius(), shadow->color());
+ shadow = shadow->next();
+ }
+
+ // These decorations should match the visual overflows computed in visualOverflowForDecorations()
+ if (m_decoration & TextDecorationUnderline) {
+ const int offset = computeUnderlineOffset(m_lineStyle.textUnderlinePosition(), m_lineStyle.fontMetrics(), m_inlineTextBox, textDecorationThickness);
+ FloatPoint start(localOrigin.x(), localOrigin.y() + offset + m_wavyOffset);
+ FloatPoint end(localOrigin.x() + m_width, localOrigin.y() + offset + m_wavyOffset);
+ paintDecoration(m_underlineStyle, m_underlineColor, textDecorationStyleToStrokeStyle(m_underlineStyle), start, end, offset);
+ }
+ if (m_decoration & TextDecorationOverline) {
+ FloatPoint start(localOrigin.x(), localOrigin.y() - m_wavyOffset);
+ FloatPoint end(localOrigin.x() + m_width, localOrigin.y() - m_wavyOffset);
+ paintDecoration(m_overlineStyle, m_overlineColor, textDecorationStyleToStrokeStyle(m_overlineStyle), start, end, 0);
+ }
+ if (m_decoration & TextDecorationLineThrough) {
+ FloatPoint start(localOrigin.x(), localOrigin.y() + 2 * m_baseline / 3);
+ FloatPoint end(localOrigin.x() + m_width, localOrigin.y() + 2 * m_baseline / 3);
+ paintDecoration(m_linethroughStyle, m_linethroughColor, textDecorationStyleToStrokeStyle(m_linethroughStyle), start, end, 0);
+ }
+ } while (shadow);
+
+ if (clipping)
+ m_context.restore();
+ else if (m_shadow)
+ m_context.clearShadow();
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/rendering/TextDecorationPainter.h (0 => 194447)
--- trunk/Source/WebCore/rendering/TextDecorationPainter.h (rev 0)
+++ trunk/Source/WebCore/rendering/TextDecorationPainter.h 2015-12-30 17:19:03 UTC (rev 194447)
@@ -0,0 +1,77 @@
+/*
+ * (C) 1999 Lars Knoll ([email protected])
+ * (C) 2000 Dirk Mueller ([email protected])
+ * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TextDecorationPainter_h
+#define TextDecorationPainter_h
+
+#include "Color.h"
+#include "FloatPoint.h"
+#include "RenderStyleConstants.h"
+
+namespace WebCore {
+
+class FontCascade;
+class GraphicsContext;
+class InlineTextBox;
+class RenderStyle;
+class RenderText;
+class ShadowData;
+class TextRun;
+
+class TextDecorationPainter {
+public:
+ TextDecorationPainter(GraphicsContext&, TextDecoration, const RenderText&, bool isFirstLine);
+
+ void setInlineTextBox(const InlineTextBox* inlineTextBox) { m_inlineTextBox = inlineTextBox; }
+ void setFont(const FontCascade& font) { m_font = &font; }
+ void setIsHorizontal(bool isHorizontal) { m_isHorizontal = isHorizontal; }
+ void setWidth(float width) { m_width = width; }
+ void setBaseline(int baseline) { m_baseline = baseline; }
+ void addTextShadow(const ShadowData* textShadow) { m_shadow = textShadow; }
+
+ void paintTextDecoration(const TextRun&, const FloatPoint& textOrigin, const FloatPoint& boxOrigin);
+
+private:
+ GraphicsContext& m_context;
+ TextDecoration m_decoration;
+ int m_wavyOffset { 0 };
+ bool m_isPrinting { false };
+ float m_width { 0 };
+ int m_baseline { 0 };
+ FloatPoint m_boxOrigin;
+ bool m_isHorizontal { true };
+ const ShadowData* m_shadow { nullptr };
+ const InlineTextBox* m_inlineTextBox { nullptr };
+ const FontCascade* m_font { nullptr };
+
+ Color m_underlineColor;
+ Color m_overlineColor;
+ Color m_linethroughColor;
+ TextDecorationStyle m_underlineStyle;
+ TextDecorationStyle m_overlineStyle;
+ TextDecorationStyle m_linethroughStyle;
+ const RenderStyle& m_lineStyle;
+};
+
+} // namespace WebCore
+
+#endif // TextDecorationPainter_h
Modified: trunk/Source/WebCore/style/InlineTextBoxStyle.cpp (194446 => 194447)
--- trunk/Source/WebCore/style/InlineTextBoxStyle.cpp 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/style/InlineTextBoxStyle.cpp 2015-12-30 17:19:03 UTC (rev 194447)
@@ -32,7 +32,7 @@
namespace WebCore {
-int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, InlineTextBox* inlineTextBox, int textDecorationThickness)
+int computeUnderlineOffset(TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, int textDecorationThickness)
{
// This represents the gap between the baseline and the closest edge of the underline.
int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.0));
@@ -97,7 +97,7 @@
extendMe = std::max(extendMe, static_cast<int>(ceilf(extendTo)));
}
-GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, InlineTextBox* inlineTextBox)
+GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineTextBox* inlineTextBox)
{
ASSERT(!inlineTextBox || inlineTextBox->lineStyle() == lineStyle);
Modified: trunk/Source/WebCore/style/InlineTextBoxStyle.h (194446 => 194447)
--- trunk/Source/WebCore/style/InlineTextBoxStyle.h 2015-12-30 09:48:34 UTC (rev 194446)
+++ trunk/Source/WebCore/style/InlineTextBoxStyle.h 2015-12-30 17:19:03 UTC (rev 194447)
@@ -44,9 +44,9 @@
return 2;
}
-GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, InlineTextBox*);
+GlyphOverflow visualOverflowForDecorations(const RenderStyle& lineStyle, const InlineTextBox*);
void getWavyStrokeParameters(float strokeThickness, float& controlPointDistance, float& step);
-int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, InlineTextBox*, int textDecorationThickness);
+int computeUnderlineOffset(TextUnderlinePosition, const FontMetrics&, const InlineTextBox*, int textDecorationThickness);
}