Title: [200807] trunk
- Revision
- 200807
- Author
- [email protected]
- Date
- 2016-05-12 18:55:40 -0700 (Thu, 12 May 2016)
Log Message
Source/WebCore:
[Cocoa] Text shadow sometimes clipped unexpectedly
https://bugs.webkit.org/show_bug.cgi?id=108929
Reviewed by Dean Jackson.
CoreGraphics can only draw one text shadow at a time. We work around that by drawing
the text multiple times, one for each shadow. However, we want to make sure that the
original text isn't also drawn multiple times, so we bump up the shadow offsets so
the text and the shadow don't intersect, and then we clip out the original text (so
only the shadow remains).
Unfortunately, this clipping requires knowing where the visual extent of the text is,
which WebKit currently has trouble with. In particular, we often use layout extents
in lieu of visual extents, which is a problem when the glyphs draw outside of their
layout boxes. In this case, it causes us to think the text shadow is much smaller
than it really is, so our clipping operation clips to an area which is too small.
A quick solution to this is to inflate the clip rect by an amount proportional to the
font size, and offset the text shadow accordingly. If this amount is large enough,
this bug will occur on few enough sites that it is reasonable to consider this bug
fixed without the real solution of educating WebKit properly about the difference
between text layout rects and text visual extent rects.
Test: fast/text/multiple-text-shadow-overflow-layout-rect.html
* rendering/TextPainter.cpp:
(WebCore::ShadowApplier::ShadowApplier):
LayoutTests:
Text shadow sometimes clipped unexpectedly
https://bugs.webkit.org/show_bug.cgi?id=108929
Reviewed by Dean Jackson.
Add a font which draws dramatically far outside of its layout rect.
* fast/text/multiple-text-shadow-overflow-layout-rect-expected.html: Added.
* fast/text/multiple-text-shadow-overflow-layout-rect.html: Added.
* fast/text/resources/font-overflow-layout-rect.svg: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (200806 => 200807)
--- trunk/LayoutTests/ChangeLog 2016-05-13 01:24:50 UTC (rev 200806)
+++ trunk/LayoutTests/ChangeLog 2016-05-13 01:55:40 UTC (rev 200807)
@@ -1,3 +1,16 @@
+2016-05-12 Myles C. Maxfield <[email protected]>
+
+ Text shadow sometimes clipped unexpectedly
+ https://bugs.webkit.org/show_bug.cgi?id=108929
+
+ Reviewed by Dean Jackson.
+
+ Add a font which draws dramatically far outside of its layout rect.
+
+ * fast/text/multiple-text-shadow-overflow-layout-rect-expected.html: Added.
+ * fast/text/multiple-text-shadow-overflow-layout-rect.html: Added.
+ * fast/text/resources/font-overflow-layout-rect.svg: Added.
+
2016-05-12 Ryan Haddad <[email protected]>
Marking inspector/debugger/command-line-api-exception-nested-catch.html as a flaky timeout on mac
Added: trunk/LayoutTests/fast/text/multiple-text-shadow-overflow-layout-rect-expected.html (0 => 200807)
--- trunk/LayoutTests/fast/text/multiple-text-shadow-overflow-layout-rect-expected.html (rev 0)
+++ trunk/LayoutTests/fast/text/multiple-text-shadow-overflow-layout-rect-expected.html 2016-05-13 01:55:40 UTC (rev 200807)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+ font-family: fontoverfowlayoutrect;
+ src: url("resources/font-overflow-layout-rect.svg") format("svg");
+}
+</style>
+</head>
+<body>
+This test makes sure that shadows on text which draws far outside its layout box don't get clipped.
+<div style="position: relative">
+<span style="position: absolute; left: 109px; top: 109px; font: 100px fontoverfowlayoutrect; color: rgb(0, 255, 0)">a</span>
+<span style="position: absolute; left: 100px; top: 100px; font: 100px fontoverfowlayoutrect;">a</span>
+</div>
+</body>
+<html>
Added: trunk/LayoutTests/fast/text/multiple-text-shadow-overflow-layout-rect.html (0 => 200807)
--- trunk/LayoutTests/fast/text/multiple-text-shadow-overflow-layout-rect.html (rev 0)
+++ trunk/LayoutTests/fast/text/multiple-text-shadow-overflow-layout-rect.html 2016-05-13 01:55:40 UTC (rev 200807)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+ font-family: fontoverfowlayoutrect;
+ src: url("resources/font-overflow-layout-rect.svg") format("svg");
+}
+</style>
+</head>
+<body>
+This test makes sure that shadows on text which draws far outside its layout box don't get clipped.
+<div style="position: relative">
+<span style="position: absolute; left: 100px; top: 100px; font: 100px fontoverfowlayoutrect; text-shadow: rgb(128, 128, 128) -500px 0px 0px, rgb(0, 255, 0) 9px 9px 0px;">a</span>
+</div>
+</body>
+<html>
Added: trunk/LayoutTests/fast/text/resources/font-overflow-layout-rect.svg (0 => 200807)
--- trunk/LayoutTests/fast/text/resources/font-overflow-layout-rect.svg (rev 0)
+++ trunk/LayoutTests/fast/text/resources/font-overflow-layout-rect.svg 2016-05-13 01:55:40 UTC (rev 200807)
@@ -0,0 +1,14 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
+<svg xmlns="http://www.w3.org/2000/svg">
+<metadata></metadata>
+<defs>
+<font id="font-overflow-layout-rect" horiz-adv-x="1024">
+<font-face font-family="font-overflow-layout-rect" units-per-em="1024" ascent="1024" descent="1"/>
+<glyph unicode="a" horiz-adv-x="1024" d="M0 341L-1024 512L0 682L341 1024L512 2048L682 1024L1024 682L2048 512L1024 341L682 0L512 -1024L341 0z"/>
+</font>
+</defs>
+<text x="8" y="24" font-size="16">The green box represents the layout rect of the 'a' glyph.</text>
+<text x="100" y="200" font-size="100" font-family="font-overflow-layout-rect">a</text>
+<rect x="100" y="100" width="100" height="100" fill="none" stroke="green"/>
+</svg>
Modified: trunk/Source/WebCore/ChangeLog (200806 => 200807)
--- trunk/Source/WebCore/ChangeLog 2016-05-13 01:24:50 UTC (rev 200806)
+++ trunk/Source/WebCore/ChangeLog 2016-05-13 01:55:40 UTC (rev 200807)
@@ -1,5 +1,35 @@
2016-05-12 Myles C. Maxfield <[email protected]>
+ [Cocoa] Text shadow sometimes clipped unexpectedly
+ https://bugs.webkit.org/show_bug.cgi?id=108929
+
+ Reviewed by Dean Jackson.
+
+ CoreGraphics can only draw one text shadow at a time. We work around that by drawing
+ the text multiple times, one for each shadow. However, we want to make sure that the
+ original text isn't also drawn multiple times, so we bump up the shadow offsets so
+ the text and the shadow don't intersect, and then we clip out the original text (so
+ only the shadow remains).
+
+ Unfortunately, this clipping requires knowing where the visual extent of the text is,
+ which WebKit currently has trouble with. In particular, we often use layout extents
+ in lieu of visual extents, which is a problem when the glyphs draw outside of their
+ layout boxes. In this case, it causes us to think the text shadow is much smaller
+ than it really is, so our clipping operation clips to an area which is too small.
+
+ A quick solution to this is to inflate the clip rect by an amount proportional to the
+ font size, and offset the text shadow accordingly. If this amount is large enough,
+ this bug will occur on few enough sites that it is reasonable to consider this bug
+ fixed without the real solution of educating WebKit properly about the difference
+ between text layout rects and text visual extent rects.
+
+ Test: fast/text/multiple-text-shadow-overflow-layout-rect.html
+
+ * rendering/TextPainter.cpp:
+ (WebCore::ShadowApplier::ShadowApplier):
+
+2016-05-12 Myles C. Maxfield <[email protected]>
+
REGRESSION(r200601): Crash when using local() and unicode-range in @font-face blocks
https://bugs.webkit.org/show_bug.cgi?id=157646
Modified: trunk/Source/WebCore/rendering/TextPainter.cpp (200806 => 200807)
--- trunk/Source/WebCore/rendering/TextPainter.cpp 2016-05-13 01:24:50 UTC (rev 200806)
+++ trunk/Source/WebCore/rendering/TextPainter.cpp 2016-05-13 01:55:40 UTC (rev 200807)
@@ -54,13 +54,13 @@
// often draw the *last* shadow and the text itself in a single call.
if (m_onlyDrawsShadow) {
FloatRect shadowRect(textRect);
- shadowRect.inflate(shadow->paintingExtent());
+ shadowRect.inflate(shadow->paintingExtent() + 3 * textRect.height());
shadowRect.move(shadowOffset);
context.save();
context.clip(shadowRect);
m_didSaveContext = true;
- m_extraOffset = FloatSize(0, 2 * textRect.height() + std::max(0.0f, shadowOffset.height()) + shadowRadius);
+ m_extraOffset = FloatSize(0, 2 * shadowRect.height() + std::max(0.0f, shadowOffset.height()) + shadowRadius);
shadowOffset -= m_extraOffset;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes