Skip to content
Permalink
Browse files
[HarfBuzz] ComplexTextRun should initialize direction from the harfbu…
…zz buffer

https://bugs.webkit.org/show_bug.cgi?id=178788

Reviewed by Michael Catanzaro.

Instead of using the TextRun direction. If the TextRun is ltr, but the harfbuzz buffer is rtl, the character
indexes will be swapped in m_coreTextIndices.

* platform/graphics/ComplexTextController.h:
(WebCore::ComplexTextController::ComplexTextRun::create): Remove the ltr parameter.
* platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Initialize m_isLTR using hb_buffer_get_direction().
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Do not pass ltr to ComplexTextRun::create().

Canonical link: https://commits.webkit.org/195001@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224007 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Oct 26, 2017
1 parent bd7318a commit 4c831bf2a4f18c78f3ab9781ee33fa7947d571c5
Showing 3 changed files with 22 additions and 6 deletions.
@@ -1,3 +1,19 @@
2017-10-25 Carlos Garcia Campos <cgarcia@igalia.com>

[HarfBuzz] ComplexTextRun should initialize direction from the harfbuzz buffer
https://bugs.webkit.org/show_bug.cgi?id=178788

Reviewed by Michael Catanzaro.

Instead of using the TextRun direction. If the TextRun is ltr, but the harfbuzz buffer is rtl, the character
indexes will be swapped in m_coreTextIndices.

* platform/graphics/ComplexTextController.h:
(WebCore::ComplexTextController::ComplexTextRun::create): Remove the ltr parameter.
* platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun): Initialize m_isLTR using hb_buffer_get_direction().
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Do not pass ltr to ComplexTextRun::create().

2017-10-25 Keith Miller <keith_miller@apple.com>

Move remaining platform independent sources to unified sources
@@ -79,9 +79,9 @@ class ComplexTextController {
return adoptRef(*new ComplexTextRun(ctRun, font, characters, stringLocation, stringLength, indexBegin, indexEnd));
}

static Ref<ComplexTextRun> create(hb_buffer_t* buffer, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
static Ref<ComplexTextRun> create(hb_buffer_t* buffer, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd)
{
return adoptRef(*new ComplexTextRun(buffer, font, characters, stringLocation, stringLength, indexBegin, indexEnd, ltr));
return adoptRef(*new ComplexTextRun(buffer, font, characters, stringLocation, stringLength, indexBegin, indexEnd));
}

static Ref<ComplexTextRun> create(const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
@@ -142,7 +142,7 @@ class ComplexTextController {

private:
ComplexTextRun(CTRunRef, const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd);
ComplexTextRun(hb_buffer_t*, const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr);
ComplexTextRun(hb_buffer_t*, const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd);
ComplexTextRun(const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr);
WEBCORE_EXPORT ComplexTextRun(const Vector<FloatSize>& advances, const Vector<FloatPoint>& origins, const Vector<Glyph>& glyphs, const Vector<unsigned>& stringIndices, FloatSize initialAdvance, const Font&, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr);

@@ -38,7 +38,7 @@ static inline float harfBuzzPositionToFloat(hb_position_t value)
return static_cast<float>(value) / (1 << 16);
}

ComplexTextController::ComplexTextRun::ComplexTextRun(hb_buffer_t* buffer, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd, bool ltr)
ComplexTextController::ComplexTextRun::ComplexTextRun(hb_buffer_t* buffer, const Font& font, const UChar* characters, unsigned stringLocation, unsigned stringLength, unsigned indexBegin, unsigned indexEnd)
: m_initialAdvance(0, 0)
, m_font(font)
, m_characters(characters)
@@ -47,7 +47,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(hb_buffer_t* buffer, const
, m_indexEnd(indexEnd)
, m_glyphCount(hb_buffer_get_length(buffer))
, m_stringLocation(stringLocation)
, m_isLTR(ltr)
, m_isLTR(HB_DIRECTION_IS_FORWARD(hb_buffer_get_direction(buffer)))
{
if (!m_glyphCount)
return;
@@ -224,7 +224,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cha

HbUniquePtr<hb_font_t> harfBuzzFont(face->createFont());
hb_shape(harfBuzzFont.get(), buffer.get(), features.isEmpty() ? nullptr : features.data(), features.size());
m_complexTextRuns.append(ComplexTextRun::create(buffer.get(), *font, characters, stringLocation, length, run.startIndex, run.endIndex, m_run.ltr()));
m_complexTextRuns.append(ComplexTextRun::create(buffer.get(), *font, characters, stringLocation, length, run.startIndex, run.endIndex));
hb_buffer_reset(buffer.get());
}
}

0 comments on commit 4c831bf

Please sign in to comment.