OLD | NEW |
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, 2009, 2010, 2011 Apple Inc. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
4 * All right reserved. | 4 * All right reserved. |
5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 void constructBidiRunsForLine(InlineBidiResolver& topResolver, | 131 void constructBidiRunsForLine(InlineBidiResolver& topResolver, |
132 BidiRunList<BidiRun>& bidiRuns, const InlineIterator& endOfLine, | 132 BidiRunList<BidiRun>& bidiRuns, const InlineIterator& endOfLine, |
133 VisualDirectionOverride override, bool previousLineBrokeCleanly, | 133 VisualDirectionOverride override, bool previousLineBrokeCleanly, |
134 bool isNewUBAParagraph) | 134 bool isNewUBAParagraph) |
135 { | 135 { |
136 // FIXME: We should pass a BidiRunList into createBidiRunsForLine instead | 136 // FIXME: We should pass a BidiRunList into createBidiRunsForLine instead |
137 // of the resolver owning the runs. | 137 // of the resolver owning the runs. |
138 ASSERT(&topResolver.runs() == &bidiRuns); | 138 ASSERT(&topResolver.runs() == &bidiRuns); |
139 ASSERT(topResolver.position() != endOfLine); | 139 ASSERT(topResolver.position() != endOfLine); |
140 LayoutObject* currentRoot = topResolver.position().root(); | 140 const LayoutObject* currentRoot = topResolver.position().root(); |
141 topResolver.createBidiRunsForLine(endOfLine, override, | 141 topResolver.createBidiRunsForLine(endOfLine, override, |
142 previousLineBrokeCleanly); | 142 previousLineBrokeCleanly); |
| 143 struct BidiRunsWithRoot { |
| 144 const LayoutObject* root; |
| 145 Vector<BidiRun*> isolatedRuns; |
| 146 }; |
| 147 Vector<BidiRunsWithRoot> isolatedRunsStack; |
143 | 148 |
144 while (!topResolver.isolatedRuns().isEmpty()) { | 149 while (true) { |
| 150 if (topResolver.isolatedRuns().isEmpty()) { |
| 151 if (isolatedRunsStack.isEmpty()) |
| 152 break; |
| 153 topResolver.isolatedRuns().appendVector(isolatedRunsStack.last().iso
latedRuns); |
| 154 ASSERT(!topResolver.isolatedRuns().isEmpty()); |
| 155 currentRoot = isolatedRunsStack.last().root; |
| 156 isolatedRunsStack.removeLast(); |
| 157 } |
| 158 |
145 // It does not matter which order we resolve the runs as long as we | 159 // It does not matter which order we resolve the runs as long as we |
146 // resolve them all. | 160 // resolve them all. |
147 BidiRun* isolatedRun = topResolver.isolatedRuns().last(); | 161 BidiRun* isolatedRun = topResolver.isolatedRuns().last(); |
148 topResolver.isolatedRuns().removeLast(); | 162 topResolver.isolatedRuns().removeLast(); |
149 | 163 |
150 LayoutObject* startObj = isolatedRun->object(); | 164 LayoutObject* startObj = isolatedRun->object(); |
151 | 165 |
152 // Only inlines make sense with unicode-bidi: isolate (blocks are | 166 // Only inlines make sense with unicode-bidi: isolate (blocks are |
153 // already isolated). | 167 // already isolated). |
154 // FIXME: Because enterIsolate is not passed a LayoutObject, we have to | 168 // FIXME: Because enterIsolate is not passed a LayoutObject, we have to |
155 // crawl up the tree to see which parent inline is the isolate. We could | 169 // crawl up the tree to see which parent inline is the isolate. We could |
156 // change enterIsolate to take a LayoutObject and do this logic there, | 170 // change enterIsolate to take a LayoutObject and do this logic there, |
157 // but that would be a layering violation for BidiResolver (which knows | 171 // but that would be a layering violation for BidiResolver (which knows |
158 // nothing about LayoutObject). | 172 // nothing about LayoutObject). |
159 LayoutInline* isolatedInline = toLayoutInline( | 173 LayoutInline* isolatedInline = toLayoutInline( |
160 highestContainingIsolateWithinRoot(LineLayoutItem(startObj), LineLay
outItem(currentRoot))); | 174 highestContainingIsolateWithinRoot(LineLayoutItem(startObj), |
| 175 LineLayoutItem(const_cast<LayoutObject*>(currentRoot)))); |
161 ASSERT(isolatedInline); | 176 ASSERT(isolatedInline); |
162 | 177 |
163 InlineBidiResolver isolatedResolver; | 178 InlineBidiResolver isolatedResolver; |
164 LineMidpointState& isolatedLineMidpointState = | 179 LineMidpointState& isolatedLineMidpointState = |
165 isolatedResolver.midpointState(); | 180 isolatedResolver.midpointState(); |
166 isolatedLineMidpointState = topResolver.midpointStateForIsolatedRun( | 181 isolatedLineMidpointState = topResolver.midpointStateForIsolatedRun( |
167 isolatedRun); | 182 isolatedRun); |
168 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); | 183 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); |
169 TextDirection direction; | 184 TextDirection direction; |
170 if (unicodeBidi == Plaintext) { | 185 if (unicodeBidi == Plaintext) { |
(...skipping 21 matching lines...) Expand all Loading... |
192 // FIXME: What should end and previousLineBrokeCleanly be? | 207 // FIXME: What should end and previousLineBrokeCleanly be? |
193 // rniwa says previousLineBrokeCleanly is just a WinIE hack and could | 208 // rniwa says previousLineBrokeCleanly is just a WinIE hack and could |
194 // always be false here? | 209 // always be false here? |
195 isolatedResolver.createBidiRunsForLine(endOfLine, NoVisualOverride, | 210 isolatedResolver.createBidiRunsForLine(endOfLine, NoVisualOverride, |
196 previousLineBrokeCleanly); | 211 previousLineBrokeCleanly); |
197 | 212 |
198 ASSERT(isolatedResolver.runs().runCount()); | 213 ASSERT(isolatedResolver.runs().runCount()); |
199 if (isolatedResolver.runs().runCount()) | 214 if (isolatedResolver.runs().runCount()) |
200 bidiRuns.replaceRunWithRuns(isolatedRun, isolatedResolver.runs()); | 215 bidiRuns.replaceRunWithRuns(isolatedRun, isolatedResolver.runs()); |
201 | 216 |
202 // If we encountered any nested isolate runs, just move them | 217 // If we encountered any nested isolate runs, save them for later |
203 // to the top resolver's list for later processing. | 218 // processing. |
204 if (!isolatedResolver.isolatedRuns().isEmpty()) { | 219 if (!isolatedResolver.isolatedRuns().isEmpty()) { |
205 topResolver.isolatedRuns().appendVector( | 220 isolatedRunsStack.resize(isolatedRunsStack.size() + 1); |
| 221 isolatedRunsStack.last().isolatedRuns.appendVector( |
206 isolatedResolver.isolatedRuns()); | 222 isolatedResolver.isolatedRuns()); |
207 currentRoot = isolatedInline; | 223 isolatedRunsStack.last().root = isolatedInline; |
208 restoreIsolatedMidpointStates(topResolver, isolatedResolver); | 224 restoreIsolatedMidpointStates(topResolver, isolatedResolver); |
209 } | 225 } |
210 } | 226 } |
211 } | 227 } |
212 | 228 |
213 } // namespace blink | 229 } // namespace blink |
214 | 230 |
215 #endif // BidiRunForLine_h | 231 #endif // BidiRunForLine_h |
OLD | NEW |