Title: [121756] trunk
- Revision
- 121756
- Author
- [email protected]
- Date
- 2012-07-03 03:29:08 -0700 (Tue, 03 Jul 2012)
Log Message
Fix text positioning with non-bmp characters.
https://bugs.webkit.org/show_bug.cgi?id=87681
Reviewed by Nikolas Zimmermann.
Source/WebCore:
Previously when constructing metrics for tspans with non-bmp characters,
each non-bmp character treated as a skipped character in the same way that
spaces are ignored.
This made sense because the initial SVGCharacterDataMap for <text> is
indexed by character index (not string length) so the high portion of a
non-bmp character was treated as a skipped space. Unfortunately, this
led to a bug because skipped spaces lead to an offset in the positioning
values list but non-bmp characters do not.
This change switches the code to use a new offset for non-bmp characters,
surrogatePairCharacters, which does not affect the positioning values list.
Tests: svg/text/non-bmp-tspans-expected.svg
svg/text/non-bmp-tspans.svg
* rendering/svg/SVGTextMetricsBuilder.cpp:
(WebCore::SVGTextMetricsBuilder::measureTextRenderer):
LayoutTests:
* svg/text/non-bmp-tspans-expected.svg: Added.
* svg/text/non-bmp-tspans.svg: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (121755 => 121756)
--- trunk/LayoutTests/ChangeLog 2012-07-03 10:25:36 UTC (rev 121755)
+++ trunk/LayoutTests/ChangeLog 2012-07-03 10:29:08 UTC (rev 121756)
@@ -1,3 +1,13 @@
+2012-07-03 Philip Rogers <[email protected]>
+
+ Fix text positioning with non-bmp characters.
+ https://bugs.webkit.org/show_bug.cgi?id=87681
+
+ Reviewed by Nikolas Zimmermann.
+
+ * svg/text/non-bmp-tspans-expected.svg: Added.
+ * svg/text/non-bmp-tspans.svg: Added.
+
2012-07-03 Gyuyoung Kim <[email protected]>
Improve test cases for network information APIs
Added: trunk/LayoutTests/svg/text/non-bmp-tspans-expected.svg (0 => 121756)
--- trunk/LayoutTests/svg/text/non-bmp-tspans-expected.svg (rev 0)
+++ trunk/LayoutTests/svg/text/non-bmp-tspans-expected.svg 2012-07-03 10:29:08 UTC (rev 121756)
@@ -0,0 +1,14 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800">
+ <!-- Test for WK87681 where non-BMP characters broke positioning in sibling tspans. -->
+ <text x="30" y="30">This test passes if there are three rows of 2 green Cs each with</text>
+ <text x="30" y="50">the first row cursive, the second plain, and the third cursive.</text>
+ <text fill="green">
+ <tspan x="100" y="100">𝒞𝒞</tspan>
+ </text>
+ <text fill="green">
+ <tspan x="100" y="150">CC</tspan>
+ </text>
+ <text fill="green">
+ <tspan x="100" y="200">𝒞𝒞</tspan>
+ </text>
+</svg>
Added: trunk/LayoutTests/svg/text/non-bmp-tspans.svg (0 => 121756)
--- trunk/LayoutTests/svg/text/non-bmp-tspans.svg (rev 0)
+++ trunk/LayoutTests/svg/text/non-bmp-tspans.svg 2012-07-03 10:29:08 UTC (rev 121756)
@@ -0,0 +1,10 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800">
+ <!-- Test for WK87681 where non-BMP characters broke positioning in sibling tspans. -->
+ <text x="30" y="30">This test passes if there are three rows of 2 green Cs each with</text>
+ <text x="30" y="50">the first row cursive, the second plain, and the third cursive.</text>
+ <text fill="green">
+ <tspan x="100" y="100">𝒞𝒞</tspan>
+ <tspan x="100" y="150">CC</tspan>
+ <tspan x="100" y="200">𝒞𝒞</tspan>
+ </text>
+</svg>
Modified: trunk/Source/WebCore/ChangeLog (121755 => 121756)
--- trunk/Source/WebCore/ChangeLog 2012-07-03 10:25:36 UTC (rev 121755)
+++ trunk/Source/WebCore/ChangeLog 2012-07-03 10:29:08 UTC (rev 121756)
@@ -1,3 +1,28 @@
+2012-07-03 Philip Rogers <[email protected]>
+
+ Fix text positioning with non-bmp characters.
+ https://bugs.webkit.org/show_bug.cgi?id=87681
+
+ Reviewed by Nikolas Zimmermann.
+
+ Previously when constructing metrics for tspans with non-bmp characters,
+ each non-bmp character treated as a skipped character in the same way that
+ spaces are ignored.
+ This made sense because the initial SVGCharacterDataMap for <text> is
+ indexed by character index (not string length) so the high portion of a
+ non-bmp character was treated as a skipped space. Unfortunately, this
+ led to a bug because skipped spaces lead to an offset in the positioning
+ values list but non-bmp characters do not.
+
+ This change switches the code to use a new offset for non-bmp characters,
+ surrogatePairCharacters, which does not affect the positioning values list.
+
+ Tests: svg/text/non-bmp-tspans-expected.svg
+ svg/text/non-bmp-tspans.svg
+
+ * rendering/svg/SVGTextMetricsBuilder.cpp:
+ (WebCore::SVGTextMetricsBuilder::measureTextRenderer):
+
2012-07-03 Gyuyoung Kim <[email protected]>
Improve test cases for network information APIs
Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp (121755 => 121756)
--- trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp 2012-07-03 10:25:36 UTC (rev 121755)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp 2012-07-03 10:29:08 UTC (rev 121756)
@@ -155,6 +155,7 @@
initializeMeasurementWithTextRenderer(text);
bool preserveWhiteSpace = text->style()->whiteSpace() == PRE;
+ int surrogatePairCharacters = 0;
while (advance()) {
const UChar* currentCharacter = m_run.data(m_textPosition);
@@ -168,7 +169,7 @@
if (data->processRenderer) {
if (data->allCharactersMap) {
- const SVGCharacterDataMap::const_iterator it = data->allCharactersMap->find(data->valueListPosition + m_textPosition - data->skippedCharacters + 1);
+ const SVGCharacterDataMap::const_iterator it = data->allCharactersMap->find(data->valueListPosition + m_textPosition - data->skippedCharacters - surrogatePairCharacters + 1);
if (it != data->allCharactersMap->end())
attributes->characterDataMap().set(m_textPosition + 1, it->second);
}
@@ -176,7 +177,7 @@
}
if (data->allCharactersMap && currentCharacterStartsSurrogatePair())
- data->skippedCharacters += m_currentMetrics.length() - 1;
+ surrogatePairCharacters++;
data->lastCharacter = currentCharacter;
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes