[GTK] Add support for automatic hyphenation
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Apr 2015 22:46:15 +0000 (22:46 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Apr 2015 22:46:15 +0000 (22:46 +0000)
commit37db9480e7a8235cc173f9b77ec41055031357ca
treec2efe8ec078649d36fb5ff364ea000f821a57414
parent992c1600a5025549ef01e6c39ed3ad82cdbc3469
[GTK] Add support for automatic hyphenation
https://bugs.webkit.org/show_bug.cgi?id=44478

Reviewed by Carlos Garcia Campos.

.:

* Source/cmake/FindHyphen.cmake: Added. A CMake module for finding libhyphen.
* Source/cmake/OptionsGTK.cmake: Look for libhyphen and enable hyphenation if found.
* Source/cmakeconfig.h.cmake: Pass through the whether libhyphen is enabled.

Source/WebCore:

No new tests. This patch unskips and updates results for existing hyphenation tests.

* PlatformGTK.cmake: Add the libhypen implementation to the source list.
* platform/gtk/GtkUtilities.cpp:
(WebCore::topLevelPath): Add this helper function taken from the test harness.
(WebCore::getWebKitBuildDirectory): Ditto.
* platform/gtk/GtkUtilities.h: Add function declarations for the helper functions.
* platform/text/Hyphenation.cpp: Surround this implementation with !USE(LIBHYPHEN),
  so that it can still be shared.
* platform/text/gtk/HyphenationLibHyphen.cpp: Added.
(WebCore::extractLocaleFromDictionaryFilePath): Take in a dictionary filename and
determine the locale that it covers.
(WebCore::scanDirectoryForDicionaries): Look for all installed dictionaries as well
as ones in the JHBuild root for testing.
(WebCore::scanTestDictionariesDirectoryIfNecessary): Try to scan the dictionaries installed
in the JHBuild root.
(WebCore::availableLocales): Getter for global hash of installed dictionaries.
(WebCore::canHyphenate): Added libhyphen implementation.
(WebCore::HyphenationDictionary): Helper class that properly manages the memory of
an open libhyphen dictionary. This is useful so that they can be stored in an MRU
cache. This is a similar approach to the CoreFoundation implementation.
(WebCore::AtomicStringKeyedMRUCache<RefPtr<HyphenationDictionary>>::createValueForNullKey): MRU cache
helper.
(WebCore::AtomicStringKeyedMRUCache<RefPtr<HyphenationDictionary>>::createValueForKey): Ditto.
(WebCore::hyphenDictionaryCache): A cache for opened hyphenation dictionaries.
(WebCore::countLeadingSpaces): Count leading spaces, since WebCore often passes words with them.
(WebCore::lastHyphenLocation): Added libhyphen implementation.

Tools:

* gtk/jhbuild.modules: Add a module for testing dictionaries, so that
all systems will use the same dictionaries for testing purposes.

LayoutTests:

* platform/gtk/TestExpectations: Unskip most hyphenation tests.
* platform/gtk/fast/text/hyphenate-character-expected.png: Added.
* platform/gtk/fast/text/hyphenate-character-expected.txt:
* platform/gtk/fast/text/hyphenate-first-word-expected.png: Added.
* platform/gtk/fast/text/hyphenate-first-word-expected.txt:
* platform/gtk/fast/text/hyphenate-limit-before-after-expected.png:
* platform/gtk/fast/text/hyphenate-limit-before-after-expected.txt:
* platform/gtk/fast/text/hyphenate-limit-lines-expected.png:
* platform/gtk/fast/text/hyphenate-limit-lines-expected.txt:
* platform/gtk/fast/text/hyphenate-locale-expected.png: Added.
* platform/gtk/fast/text/hyphenate-locale-expected.txt:
* platform/gtk/fast/text/hyphens-expected.png: Added.
* platform/gtk/fast/text/hyphens-expected.txt:
* platform/gtk/fast/text/word-break-soft-hyphen-expected.png:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/gtk/fast/text/hyphenate-character-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/fast/text/hyphenate-character-expected.txt
LayoutTests/platform/gtk/fast/text/hyphenate-first-word-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/fast/text/hyphenate-first-word-expected.txt
LayoutTests/platform/gtk/fast/text/hyphenate-limit-before-after-expected.png
LayoutTests/platform/gtk/fast/text/hyphenate-limit-before-after-expected.txt
LayoutTests/platform/gtk/fast/text/hyphenate-limit-lines-expected.png
LayoutTests/platform/gtk/fast/text/hyphenate-limit-lines-expected.txt
LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/fast/text/hyphenate-locale-expected.txt
LayoutTests/platform/gtk/fast/text/hyphens-expected.png [new file with mode: 0644]
LayoutTests/platform/gtk/fast/text/hyphens-expected.txt
LayoutTests/platform/gtk/fast/text/word-break-soft-hyphen-expected.png
Source/WebCore/ChangeLog
Source/WebCore/PlatformGTK.cmake
Source/WebCore/platform/gtk/GtkUtilities.cpp
Source/WebCore/platform/gtk/GtkUtilities.h
Source/WebCore/platform/text/Hyphenation.cpp
Source/WebCore/platform/text/gtk/HyphenationLibHyphen.cpp [new file with mode: 0644]
Source/cmake/FindHyphen.cmake [new file with mode: 0644]
Source/cmake/OptionsGTK.cmake
Tools/ChangeLog
Tools/gtk/jhbuild.modules