Bug 27593

Summary: [Qt] Hyphenation is broken (no hyphens visible) for QtWebkit
Product: WebKit Reporter: Alexei Puzikov <puzikov>
Component: TextAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: cmarcelo, jesus, joseph.wild, jturcotte, kinbot, kovid, laszlo.gombos, pierre.rossi, vestbo
Priority: P2 Keywords: Qt, QtTriaged
Version: 420+   
Hardware: All   
OS: All   

Description Alexei Puzikov 2009-07-22 20:39:19 PDT
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 Tor Arne Vestbø (not active) 2009-09-07 10:39:31 PDT
Confirmed in WebKit trunk (r48110), against Qt 4.6 (77fd77d6), on Mac OS 10.5
Comment 2 Alexey Proskuryakov 2010-03-06 23:34:57 PST
*** Bug 29576 has been marked as a duplicate of this bug. ***
Comment 3 Alexey Proskuryakov 2010-03-06 23:35:03 PST
*** Bug 29573 has been marked as a duplicate of this bug. ***
Comment 4 Alexey Proskuryakov 2010-03-06 23:35:08 PST
*** Bug 35838 has been marked as a duplicate of this bug. ***
Comment 5 Jesus Sanchez-Palencia 2010-05-13 14:35:26 PDT
Reproduced on Snow Leopard with Qt 4.7 trunk (HEAD 03f8f1df0d88f5ffe0b3120cffce614cbeefdb70) and WebKit trunk (r59155).
Comment 6 Joe Wild 2011-02-28 11:50:28 PST
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

#0  WebCore::textBreakFollowing (bi=0x340bfe0, pos=19)

    int textBreakFollowing(TextBreakIterator* bi, int pos)
        int newpos = bi->toNextBoundary();
        DEBUG() << "textBreakFollowing" << pos << newpos;
        return newpos;
#1  WebCore::lineBreakIterator
#2  WebCore::nextBreakablePosition 
#3  WebCore::isBreakable 
#4  WebCore::RenderBlock::findNextLineBreak
#5  WebCore::RenderBlock::layoutInlineChildren 
#6  WebCore::RenderBlock::layoutBlock 

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:
        while (pos < length && d->attributes[pos-1].lineBreakType < HB_Break)

toNextBoundary uses harfbuzz.

typedef enum {
} 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 Joe Wild 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
  int QTextBoundaryFinder::toNextBoundary()

which is not called when ICU is enabled.

There is a corresponding Qt error
which I need to get reopened.  I think we closed the wrong error.
Comment 8 Pierre Rossi 2012-03-16 04:18:28 PDT
This seems to work well these days. Could be a side effect of fixing QTextBoundaryFinder. :)