Bug 27593

Summary: [Qt] Hyphenation is broken (no hyphens visible) for QtWebkit
Product: WebKit Reporter: Alexei Puzikov <puzikov@gmail.com>
Component: TextAssignee: Nobody <webkit-unassigned@lists.webkit.org>
Status: RESOLVED WORKSFORME    
Severity: Normal CC: cmarcelo@webkit.org, jesus@webkit.org, jocelyn.turcotte@digia.com, joseph.wild@nokia.com, kinbot@gmail.com, kovid@kovidgoyal.net, laszlo.gombos@webkit.org, pierre.rossi@gmail.com, vestbo@webkit.org
Priority: P2 Keywords: Qt, QtTriaged
Version: 420+   
Hardware: All   
OS: All   

Description From 2009-07-22 20:39:19 PST
Steps to reproduce:

1. With any QtWebkit-based browser or example (tested with Arora+Qt4.5.2 and Browser demo from the same Qt) browse to http://www.cs.tut.fi/~jkorpela/shytest.html
2. Resize browser window.
3. Observe that words are hyphenated/broken, but no hyphens are visible.

Works OK with:
Safari, Konqueror, Firefox
------- Comment #1 From 2009-09-07 10:39:31 PST -------
Confirmed in WebKit trunk (r48110), against Qt 4.6 (77fd77d6), on Mac OS 10.5
------- Comment #2 From 2010-03-06 23:34:57 PST -------
*** Bug 29576 has been marked as a duplicate of this bug. ***
------- Comment #3 From 2010-03-06 23:35:03 PST -------
*** Bug 29573 has been marked as a duplicate of this bug. ***
------- Comment #4 From 2010-03-06 23:35:08 PST -------
*** Bug 35838 has been marked as a duplicate of this bug. ***
------- Comment #5 From 2010-05-13 14:35:26 PST -------
Reproduced on Snow Leopard with Qt 4.7 trunk (HEAD 03f8f1df0d88f5ffe0b3120cffce614cbeefdb70) and WebKit trunk (r59155).
------- Comment #6 From 2011-02-28 11:50:28 PST -------
https://bugs.webkit.org/show_bug.cgi?id=27593
3. 27593 Nor P2 All webkit-unassigned@lists.web...  NEW [Qt] Hyphenation
is broken (no hyphens visible) for QtWebkit

From what I can tell the Qt line text breaking code does not honor the
soft hypen (&Shy;).

Below is a edited call stack.  I replaced soft hyphen char with
"\xAD".  Basically, it shows the WebCore line breaking calling into
the Qt TextBreakIterator and then into Qt
QTextBoundaryFinder::toNextBoundary(),


#0  WebCore::textBreakFollowing (bi=0x340bfe0, pos=19)
    /Source/WebCore/platform/text/qt/TextBreakIteratorQt.cpp:12

    int textBreakFollowing(TextBreakIterator* bi, int pos)
    {
        bi->setPosition(pos);
        int newpos = bi->toNextBoundary();
        DEBUG() << "textBreakFollowing" << pos << newpos;
        return newpos;
    }
#1  WebCore::lineBreakIterator
    /Source/WebCore/platform/text/qt/TextBreakIteratorQt.cpp:95
#2  WebCore::nextBreakablePosition 
#3  WebCore::isBreakable 
    /Source/WebCore/rendering/break_lines.h:33
#4  WebCore::RenderBlock::findNextLineBreak
    /Source/WebCore/rendering/RenderBlockLineLayout.cpp:1725
#5  WebCore::RenderBlock::layoutInlineChildren 
    /Source/WebCore/rendering/RenderBlockLineLayout.cpp:681
#6  WebCore::RenderBlock::layoutBlock 
    /Source/WebCore/rendering/RenderBlock.cpp:1222


Since I don't have Qt enabled for debugging, I traced that by looking
at the source.

The QTextBoundaryFinder::toNextBoundary() for Line skips anything <
HB_Break which means it will only return the position for HB_Break or
HB_ForcedBreak.  HB_SoftHyphen is ignored.  This routine returns when
it encounters the next whitespace ignoring any soft hyphens.

int QTextBoundaryFinder::toNextBoundary()
{
...
    case Line:
        Q_ASSERT(pos);
        while (pos < length && d->attributes[pos-1].lineBreakType < HB_Break)
            ++pos;
        break;

toNextBoundary uses harfbuzz.
./3rdparty/harfbuzz/src/harfbuzz-shaper.h:


typedef enum {
    HB_NoBreak,
    HB_SoftHyphen,
    HB_Break,
    HB_ForcedBreak
} HB_LineBreakType;

So is this as simple as changing the condition to < HB_SoftHyphen or 
is there a deeper problem.  Need to investigate.
------- Comment #7 From 2011-03-01 13:12:34 PST -------
When I enable ICU in WebKit with the following, the test case passes.
  build-webkit --qt --debug --qmakearg=CONFIG+=text_breaking_with_icu 

This further points to this code
  ./src/corelib/tools/qtextboundaryfinder.cpp
  int QTextBoundaryFinder::toNextBoundary()

which is not called when ICU is enabled.

There is a corresponding Qt error
  https://qtrequirements.europe.nokia.com/browse/QT-4657
which I need to get reopened.  I think we closed the wrong error.
------- Comment #8 From 2012-03-16 04:18:28 PST -------
This seems to work well these days. Could be a side effect of fixing QTextBoundaryFinder. :)