diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/platform/text/BidiResolver.h | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/platform/text/BidiResolver.h')
-rw-r--r-- | Source/WebCore/platform/text/BidiResolver.h | 96 |
1 files changed, 57 insertions, 39 deletions
diff --git a/Source/WebCore/platform/text/BidiResolver.h b/Source/WebCore/platform/text/BidiResolver.h index 72d163c..07e9274 100644 --- a/Source/WebCore/platform/text/BidiResolver.h +++ b/Source/WebCore/platform/text/BidiResolver.h @@ -126,6 +126,12 @@ struct BidiCharacterRun { BidiCharacterRun* m_next; }; +enum VisualDirectionOverride { + NoVisualOverride, + VisualLeftToRightOverride, + VisualRightToLeftOverride +}; + template <class Iterator, class Run> class BidiResolver { WTF_MAKE_NONCOPYABLE(BidiResolver); public : @@ -163,7 +169,7 @@ public : void embed(WTF::Unicode::Direction); bool commitExplicitEmbedding(); - void createBidiRunsForLine(const Iterator& end, bool visualOrder = false, bool hardLineBreak = false); + void createBidiRunsForLine(const Iterator& end, VisualDirectionOverride = NoVisualOverride, bool hardLineBreak = false); Run* firstRun() const { return m_firstRun; } Run* lastRun() const { return m_lastRun; } @@ -514,12 +520,28 @@ void BidiResolver<Iterator, Run>::reverseRuns(unsigned start, unsigned end) } template <class Iterator, class Run> -void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, bool visualOrder, bool hardLineBreak) +void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, VisualDirectionOverride override, bool hardLineBreak) { using namespace WTF::Unicode; ASSERT(m_direction == OtherNeutral); + if (override != NoVisualOverride) { + emptyRun = false; + sor = current; + eor = Iterator(); + while (current != end && !current.atEnd()) { + eor = current; + increment(); + } + m_direction = override == VisualLeftToRightOverride ? LeftToRight : RightToLeft; + appendRun(); + m_logicallyLastRun = m_lastRun; + if (override == VisualRightToLeftOverride) + reverseRuns(0, runCount() - 1); + return; + } + emptyRun = true; eor = Iterator(); @@ -916,49 +938,45 @@ void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, boo m_logicallyLastRun = m_lastRun; // reorder line according to run structure... - // do not reverse for visually ordered web sites - if (!visualOrder) { - - // first find highest and lowest levels - unsigned char levelLow = 128; - unsigned char levelHigh = 0; - Run* r = firstRun(); - while (r) { - if (r->m_level > levelHigh) - levelHigh = r->m_level; - if (r->m_level < levelLow) - levelLow = r->m_level; - r = r->next(); - } + // first find highest and lowest levels + unsigned char levelLow = 128; + unsigned char levelHigh = 0; + Run* r = firstRun(); + while (r) { + if (r->m_level > levelHigh) + levelHigh = r->m_level; + if (r->m_level < levelLow) + levelLow = r->m_level; + r = r->next(); + } - // implements reordering of the line (L2 according to Bidi spec): - // L2. From the highest level found in the text to the lowest odd level on each line, - // reverse any contiguous sequence of characters that are at that level or higher. + // implements reordering of the line (L2 according to Bidi spec): + // L2. From the highest level found in the text to the lowest odd level on each line, + // reverse any contiguous sequence of characters that are at that level or higher. - // reversing is only done up to the lowest odd level - if (!(levelLow % 2)) - levelLow++; + // reversing is only done up to the lowest odd level + if (!(levelLow % 2)) + levelLow++; - unsigned count = runCount() - 1; + unsigned count = runCount() - 1; - while (levelHigh >= levelLow) { - unsigned i = 0; - Run* currRun = firstRun(); - while (i < count) { - while (i < count && currRun && currRun->m_level < levelHigh) { - i++; - currRun = currRun->next(); - } - unsigned start = i; - while (i <= count && currRun && currRun->m_level >= levelHigh) { - i++; - currRun = currRun->next(); - } - unsigned end = i - 1; - reverseRuns(start, end); + while (levelHigh >= levelLow) { + unsigned i = 0; + Run* currRun = firstRun(); + while (i < count) { + while (i < count && currRun && currRun->m_level < levelHigh) { + i++; + currRun = currRun->next(); + } + unsigned start = i; + while (i <= count && currRun && currRun->m_level >= levelHigh) { + i++; + currRun = currRun->next(); } - levelHigh--; + unsigned end = i - 1; + reverseRuns(start, end); } + levelHigh--; } endOfLine = Iterator(); } |