Bug 957128 - Report hyphen breaks also for word-wrap:break-word (to display soft-hyphens). r=smontagu
authorMats Palmgren <matspal@gmail.com>
Wed, 29 Jan 2014 14:45:23 +0000
changeset 181766 3ef6bc080fa37537a626448adc0fb2b5aa935432
parent 181765 192c0bc86b01c007b775d4dbf59082d5194b9200
child 181767 0c8fa25eafe967559e5562569fb9090ff688a29d
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs957128
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 957128 - Report hyphen breaks also for word-wrap:break-word (to display soft-hyphens). r=smontagu
gfx/thebes/gfxFont.cpp
layout/reftests/text/reftest.list
layout/reftests/text/soft-hyphens-break-word-1-ref.html
layout/reftests/text/soft-hyphens-break-word-1a.html
layout/reftests/text/soft-hyphens-break-word-1b.html
layout/reftests/text/soft-hyphens-break-word-1c.html
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -6395,26 +6395,26 @@ gfxTextRun::BreakAndMeasureText(uint32_t
             bool lineBreakHere = mCharacterGlyphs[i].CanBreakBefore() == 1;
             bool hyphenation = haveHyphenation && hyphenBuffer[i - bufferStart];
             bool wordWrapping =
                 aCanWordWrap && mCharacterGlyphs[i].IsClusterStart() &&
                 *aBreakPriority <= gfxBreakPriority::eWordWrapBreak;
 
             if (lineBreakHere || hyphenation || wordWrapping) {
                 gfxFloat hyphenatedAdvance = advance;
-                if (!lineBreakHere && !wordWrapping) {
+                if (!lineBreakHere && hyphenation) {
                     hyphenatedAdvance += aProvider->GetHyphenWidth();
                 }
             
                 if (lastBreak < 0 || width + hyphenatedAdvance - trimmableAdvance <= aWidth) {
                     // We can break here.
                     lastBreak = i;
                     lastBreakTrimmableChars = trimmableChars;
                     lastBreakTrimmableAdvance = trimmableAdvance;
-                    lastBreakUsedHyphenation = !lineBreakHere && !wordWrapping;
+                    lastBreakUsedHyphenation = !lineBreakHere && hyphenation;
                     *aBreakPriority = hyphenation || lineBreakHere ?
                         gfxBreakPriority::eNormalBreak : gfxBreakPriority::eWordWrapBreak;
                 }
 
                 width += advance;
                 advance = 0;
                 if (width - trimmableAdvance > aWidth) {
                     // No more text fits. Abort
--- a/layout/reftests/text/reftest.list
+++ b/layout/reftests/text/reftest.list
@@ -28,16 +28,19 @@ skip-if(B2G) == long-1.html long-ref.htm
 fuzzy-if(Android,255,42) == pre-line-1.html pre-line-1-ref.html
 == pre-line-2.html pre-line-2-ref.html
 == pre-line-3.html pre-line-3-ref.html
 == pre-line-4.html pre-line-4-ref.html
 == pre-discard-newlines-1.html pre-discard-newlines-1-ref.html
 == soft-hyphens-1a.html soft-hyphens-1-ref.html
 == soft-hyphens-1b.html soft-hyphens-1-ref.html
 == soft-hyphens-1c.html soft-hyphens-1-ref.html
+== soft-hyphens-break-word-1a.html soft-hyphens-break-word-1-ref.html
+== soft-hyphens-break-word-1b.html soft-hyphens-break-word-1-ref.html
+== soft-hyphens-break-word-1c.html soft-hyphens-break-word-1-ref.html
 # Tests for soft hyphens in table cells, bug 418975
 != soft-hyphen-in-table-1.html soft-hyphen-in-table-1-notref.html
 == soft-hyphen-in-table-1.html soft-hyphen-in-table-1-ref.html
 == soft-hyphen-in-table-2.html soft-hyphen-in-table-2-ref.html
 # Cairo's FreeType and GDI backends snap glyphs to pixels, while Mac (usually)
 # and D2D have subpixel positioning.  The tests for pixel-snapping assume that
 # 1 CSS pixel == 1 device pixel
 fails-if(Android) skip-if(d2d||cocoaWidget) == subpixel-glyphs-x-1a.html subpixel-glyphs-x-1b.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text/soft-hyphens-break-word-1-ref.html
@@ -0,0 +1,13 @@
+<html>
+<body>
+
+<div>
+<p>H<br>y-<br>p<br>h<br>e<br>n<br>.
+<p>H<br>y-<br>p<br>h<br>e<br>n<br>.
+<p>H<br>y-<br>p<br>h<br>e<br>n<br>.
+<p>H<br>y-<br>p<br>h<br>e<br>n<br>.
+<p>H<br>y-<br>p<br>h<br>e<br>n<br>.
+</div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text/soft-hyphens-break-word-1a.html
@@ -0,0 +1,13 @@
+<html>
+<body>
+
+<div style="width:0; word-wrap:break-word;">
+<p>Hy&shy;phen.
+<p><span>H</span>y&shy;phen.
+<p><span>Hy</span>&shy;phen.
+<p><span>Hy&shy;</span>phen.
+<p><span>Hy&shy;p</span>hen.
+</div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text/soft-hyphens-break-word-1b.html
@@ -0,0 +1,13 @@
+<html>
+<body>
+
+<div style="width:0; word-wrap:break-word;">
+<p>Hy&shy;&shy;phen.
+<p><span>Hy</span>&shy;&shy;phen.
+<p><span>Hy&shy;</span>&shy;phen.
+<p><span>Hy&shy;&shy;</span>phen.
+<p><span>Hy&shy;&shy;p</span>hen.
+</div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text/soft-hyphens-break-word-1c.html
@@ -0,0 +1,13 @@
+<html>
+<body>
+
+<div style="width:0; word-wrap:break-word;">
+<p><span>H</span><span>y&shy;phen</span>.
+<p><span>Hy</span><span>&shy;phen</span>.
+<p><span>Hy</span>&shy;<span>phen</span>.
+<p><span>Hy&shy;</span><span>phen</span>.
+<p><span>Hy&shy;p</span><span>hen</span>.
+</div>
+
+</body>
+</html>