Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: Source/core/platform/text/BidiResolver.h

Issue 23456046: Implement unicode bidi P2 and P3 rules in BidiResolver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/platform/graphics/TextRunIterator.h ('k') | Source/core/rendering/InlineIterator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008 Apple Inc. All right reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008 Apple Inc. All right reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 BidiRunList<Run>& runs() { return m_runs; } 216 BidiRunList<Run>& runs() { return m_runs; }
217 217
218 // FIXME: This used to be part of deleteRuns() but was a layering violation. 218 // FIXME: This used to be part of deleteRuns() but was a layering violation.
219 // It's unclear if this is still needed. 219 // It's unclear if this is still needed.
220 void markCurrentRunEmpty() { m_emptyRun = true; } 220 void markCurrentRunEmpty() { m_emptyRun = true; }
221 221
222 Vector<Run*>& isolatedRuns() { return m_isolatedRuns; } 222 Vector<Run*>& isolatedRuns() { return m_isolatedRuns; }
223 223
224 bool isEndOfParagraph(const Iterator& end) { return m_current == end || m_cu rrent.atEnd(); } 224 bool isEndOfParagraph(const Iterator& end) { return m_current == end || m_cu rrent.atEnd(); }
225 225
226 TextDirection determineParagraphDirectionality(bool* hasStrongDirectionality = 0);
227
226 protected: 228 protected:
227 void increment() { m_current.increment(); } 229 void increment() { m_current.increment(); }
228 // FIXME: Instead of InlineBidiResolvers subclassing this method, we should 230 // FIXME: Instead of InlineBidiResolvers subclassing this method, we should
229 // pass in some sort of Traits object which knows how to create runs for app ending. 231 // pass in some sort of Traits object which knows how to create runs for app ending.
230 void appendRun(); 232 void appendRun();
231 233
232 Iterator m_current; 234 Iterator m_current;
233 // sor and eor are "start of run" and "end of run" respectively and correpon d 235 // sor and eor are "start of run" and "end of run" respectively and correpon d
234 // to abreviations used in UBA spec: http://unicode.org/reports/tr9/#BD7 236 // to abreviations used in UBA spec: http://unicode.org/reports/tr9/#BD7
235 Iterator m_sor; // Points to the first character in the current run. 237 Iterator m_sor; // Points to the first character in the current run.
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 for (;i <= count && run && run->level() >= levelHigh; i++) 520 for (;i <= count && run && run->level() >= levelHigh; i++)
519 run = run->next(); 521 run = run->next();
520 unsigned end = i - 1; 522 unsigned end = i - 1;
521 m_runs.reverseRuns(start, end); 523 m_runs.reverseRuns(start, end);
522 } 524 }
523 levelHigh--; 525 levelHigh--;
524 } 526 }
525 } 527 }
526 528
527 template <class Iterator, class Run> 529 template <class Iterator, class Run>
530 TextDirection BidiResolver<Iterator, Run>::determineParagraphDirectionality(bool * hasStrongDirectionality)
531 {
532 while (!m_current.atEnd()) {
533 if (inIsolate()) {
534 increment();
535 continue;
536 }
537 if (m_current.atParagraphSeparator())
538 break;
539 if (UChar current = m_current.current()) {
540 WTF::Unicode::Direction charDirection = WTF::Unicode::direction(curr ent);
541 if (charDirection == WTF::Unicode::LeftToRight) {
542 if (hasStrongDirectionality)
543 *hasStrongDirectionality = true;
544 return LTR;
545 }
546 if (charDirection == WTF::Unicode::RightToLeft || charDirection == W TF::Unicode::RightToLeftArabic) {
547 if (hasStrongDirectionality)
548 *hasStrongDirectionality = true;
549 return RTL;
550 }
551 }
552 increment();
553 }
554 if (hasStrongDirectionality)
555 *hasStrongDirectionality = false;
556 return LTR;
557 }
558
559 template <class Iterator, class Run>
528 void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, Vis ualDirectionOverride override, bool hardLineBreak) 560 void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, Vis ualDirectionOverride override, bool hardLineBreak)
529 { 561 {
530 using namespace WTF::Unicode; 562 using namespace WTF::Unicode;
531 563
532 ASSERT(m_direction == OtherNeutral); 564 ASSERT(m_direction == OtherNeutral);
533 565
534 if (override != NoVisualOverride) { 566 if (override != NoVisualOverride) {
535 m_emptyRun = false; 567 m_emptyRun = false;
536 m_sor = m_current; 568 m_sor = m_current;
537 m_eor = Iterator(); 569 m_eor = Iterator();
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 951 }
920 952
921 m_runs.setLogicallyLastRun(m_runs.lastRun()); 953 m_runs.setLogicallyLastRun(m_runs.lastRun());
922 reorderRunsFromLevels(); 954 reorderRunsFromLevels();
923 endOfLine = Iterator(); 955 endOfLine = Iterator();
924 } 956 }
925 957
926 } // namespace WebCore 958 } // namespace WebCore
927 959
928 #endif // BidiResolver_h 960 #endif // BidiResolver_h
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/TextRunIterator.h ('k') | Source/core/rendering/InlineIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698