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

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

Issue 104813005: Explicitly set text direction for TextRuns (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp ('k') | no next file » | 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (dir == WTF::Unicode::RightToLeft) 133 if (dir == WTF::Unicode::RightToLeft)
134 m_level++; 134 m_level++;
135 else if (dir == WTF::Unicode::ArabicNumber || dir == WTF::Unicode::E uropeanNumber) 135 else if (dir == WTF::Unicode::ArabicNumber || dir == WTF::Unicode::E uropeanNumber)
136 m_level += 2; 136 m_level += 2;
137 } 137 }
138 } 138 }
139 139
140 int start() const { return m_start; } 140 int start() const { return m_start; }
141 int stop() const { return m_stop; } 141 int stop() const { return m_stop; }
142 unsigned char level() const { return m_level; } 142 unsigned char level() const { return m_level; }
143 bool reversed(bool visuallyOrdered) { return m_level % 2 && !visuallyOrdered ; } 143 bool reversed(bool visuallyOrdered) const { return m_level % 2 && !visuallyO rdered; }
144 bool dirOverride(bool visuallyOrdered) { return m_override || visuallyOrdere d; } 144 bool dirOverride(bool visuallyOrdered) { return m_override || visuallyOrdere d; }
145 TextDirection direction() const { return reversed(false) ? RTL : LTR; }
145 146
146 BidiCharacterRun* next() const { return m_next; } 147 BidiCharacterRun* next() const { return m_next; }
147 void setNext(BidiCharacterRun* next) { m_next = next; } 148 void setNext(BidiCharacterRun* next) { m_next = next; }
148 149
149 // Do not add anything apart from bitfields until after m_next. See https:// bugs.webkit.org/show_bug.cgi?id=100173 150 // Do not add anything apart from bitfields until after m_next. See https:// bugs.webkit.org/show_bug.cgi?id=100173
150 bool m_override : 1; 151 bool m_override : 1;
151 bool m_hasHyphen : 1; // Used by BidiRun subclass which is a layering violat ion but enables us to save 8 bytes per object on 64-bit. 152 bool m_hasHyphen : 1; // Used by BidiRun subclass which is a layering violat ion but enables us to save 8 bytes per object on 64-bit.
152 bool m_startsSegment : 1; // Same comment as m_hasHyphen. 153 bool m_startsSegment : 1; // Same comment as m_hasHyphen.
153 unsigned char m_level; 154 unsigned char m_level;
154 BidiCharacterRun* m_next; 155 BidiCharacterRun* m_next;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // The current algorithm handles nested isolates one layer of nesting at a t ime. 213 // The current algorithm handles nested isolates one layer of nesting at a t ime.
213 // But when we layout each isolated span, we will walk into (and ignore) all 214 // But when we layout each isolated span, we will walk into (and ignore) all
214 // child isolated spans. 215 // child isolated spans.
215 void enterIsolate() { m_nestedIsolateCount++; } 216 void enterIsolate() { m_nestedIsolateCount++; }
216 void exitIsolate() { ASSERT(m_nestedIsolateCount >= 1); m_nestedIsolateCount --; } 217 void exitIsolate() { ASSERT(m_nestedIsolateCount >= 1); m_nestedIsolateCount --; }
217 bool inIsolate() const { return m_nestedIsolateCount; } 218 bool inIsolate() const { return m_nestedIsolateCount; }
218 219
219 void embed(WTF::Unicode::Direction, BidiEmbeddingSource); 220 void embed(WTF::Unicode::Direction, BidiEmbeddingSource);
220 bool commitExplicitEmbedding(); 221 bool commitExplicitEmbedding();
221 222
222 void createBidiRunsForLine(const Iterator& end, VisualDirectionOverride = No VisualOverride, bool hardLineBreak = false); 223 void createBidiRunsForLine(const Iterator& end, VisualDirectionOverride = No VisualOverride, bool hardLineBreak = false, bool reorderRuns = true);
223 224
224 BidiRunList<Run>& runs() { return m_runs; } 225 BidiRunList<Run>& runs() { return m_runs; }
225 226
226 // FIXME: This used to be part of deleteRuns() but was a layering violation. 227 // FIXME: This used to be part of deleteRuns() but was a layering violation.
227 // It's unclear if this is still needed. 228 // It's unclear if this is still needed.
228 void markCurrentRunEmpty() { m_emptyRun = true; } 229 void markCurrentRunEmpty() { m_emptyRun = true; }
229 230
230 Vector<Run*>& isolatedRuns() { return m_isolatedRuns; } 231 Vector<Run*>& isolatedRuns() { return m_isolatedRuns; }
231 232
232 bool isEndOfLine(const Iterator& end) { return m_current == end || m_current .atEnd(); } 233 bool isEndOfLine(const Iterator& end) { return m_current == end || m_current .atEnd(); }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 return RTL; 629 return RTL;
629 } 630 }
630 increment(); 631 increment();
631 } 632 }
632 if (hasStrongDirectionality) 633 if (hasStrongDirectionality)
633 *hasStrongDirectionality = false; 634 *hasStrongDirectionality = false;
634 return LTR; 635 return LTR;
635 } 636 }
636 637
637 template <class Iterator, class Run> 638 template <class Iterator, class Run>
638 void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, Vis ualDirectionOverride override, bool hardLineBreak) 639 void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, Vis ualDirectionOverride override, bool hardLineBreak, bool reorderRuns)
639 { 640 {
640 using namespace WTF::Unicode; 641 using namespace WTF::Unicode;
641 642
642 ASSERT(m_direction == OtherNeutral); 643 ASSERT(m_direction == OtherNeutral);
643 m_trailingSpaceRun = 0; 644 m_trailingSpaceRun = 0;
644 645
645 m_endOfLine = end; 646 m_endOfLine = end;
646 647
647 if (override != NoVisualOverride) { 648 if (override != NoVisualOverride) {
648 m_emptyRun = false; 649 m_emptyRun = false;
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 m_reachedEndOfLine = stateAtEnd.m_reachedEndOfLine; 1028 m_reachedEndOfLine = stateAtEnd.m_reachedEndOfLine;
1028 m_lastBeforeET = stateAtEnd.m_lastBeforeET; 1029 m_lastBeforeET = stateAtEnd.m_lastBeforeET;
1029 m_emptyRun = stateAtEnd.m_emptyRun; 1030 m_emptyRun = stateAtEnd.m_emptyRun;
1030 m_direction = OtherNeutral; 1031 m_direction = OtherNeutral;
1031 break; 1032 break;
1032 } 1033 }
1033 } 1034 }
1034 } 1035 }
1035 1036
1036 m_runs.setLogicallyLastRun(m_runs.lastRun()); 1037 m_runs.setLogicallyLastRun(m_runs.lastRun());
1037 reorderRunsFromLevels(); 1038 if (reorderRuns)
1039 reorderRunsFromLevels();
1038 m_endOfRunAtEndOfLine = Iterator(); 1040 m_endOfRunAtEndOfLine = Iterator();
1039 m_endOfLine = Iterator(); 1041 m_endOfLine = Iterator();
1040 1042
1041 if (!hardLineBreak && m_runs.runCount()) 1043 if (!hardLineBreak && m_runs.runCount())
1042 applyL1Rule(); 1044 applyL1Rule();
1043 } 1045 }
1044 1046
1045 template <class Iterator, class Run> 1047 template <class Iterator, class Run>
1046 void BidiResolver<Iterator, Run>::setMidpointStateForIsolatedRun(Run* run, const MidpointState<Iterator>& midpoint) 1048 void BidiResolver<Iterator, Run>::setMidpointStateForIsolatedRun(Run* run, const MidpointState<Iterator>& midpoint)
1047 { 1049 {
1048 ASSERT(!m_midpointStateForIsolatedRun.contains(run)); 1050 ASSERT(!m_midpointStateForIsolatedRun.contains(run));
1049 m_midpointStateForIsolatedRun.add(run, midpoint); 1051 m_midpointStateForIsolatedRun.add(run, midpoint);
1050 } 1052 }
1051 1053
1052 template<class Iterator, class Run> 1054 template<class Iterator, class Run>
1053 MidpointState<Iterator> BidiResolver<Iterator, Run>::midpointStateForIsolatedRun (Run* run) 1055 MidpointState<Iterator> BidiResolver<Iterator, Run>::midpointStateForIsolatedRun (Run* run)
1054 { 1056 {
1055 return m_midpointStateForIsolatedRun.take(run); 1057 return m_midpointStateForIsolatedRun.take(run);
1056 } 1058 }
1057 1059
1058 1060
1059 } // namespace WebCore 1061 } // namespace WebCore
1060 1062
1061 #endif // BidiResolver_h 1063 #endif // BidiResolver_h
OLDNEW
« no previous file with comments | « Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698