Bug 27593 - [Qt] Hyphenation is broken (no hyphens visible) for QtWebkit
Summary: [Qt] Hyphenation is broken (no hyphens visible) for QtWebkit
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: 420+
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: Qt, QtTriaged
: 29573 29576 35838 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-07-22 20:39 PDT by Alexei Puzikov
Modified: 2012-03-16 04:18 PDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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ø 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
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 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
  ./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 Pierre Rossi 2012-03-16 04:18:28 PDT
This seems to work well these days. Could be a side effect of fixing QTextBoundaryFinder. :)