| 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. All r
ight reserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 444 } |
| 445 | 445 |
| 446 // Adding a pair of midpoints before a character will split it out into a new li
ne box. | 446 // Adding a pair of midpoints before a character will split it out into a new li
ne box. |
| 447 static inline void ensureCharacterGetsLineBox(LineMidpointState& lineMidpointSta
te, InlineIterator& textParagraphSeparator) | 447 static inline void ensureCharacterGetsLineBox(LineMidpointState& lineMidpointSta
te, InlineIterator& textParagraphSeparator) |
| 448 { | 448 { |
| 449 InlineIterator midpoint(0, textParagraphSeparator.m_obj, textParagraphSepara
tor.m_pos); | 449 InlineIterator midpoint(0, textParagraphSeparator.m_obj, textParagraphSepara
tor.m_pos); |
| 450 startIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSepara
tor.m_obj, textParagraphSeparator.m_pos - 1)); | 450 startIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSepara
tor.m_obj, textParagraphSeparator.m_pos - 1)); |
| 451 stopIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSeparat
or.m_obj, textParagraphSeparator.m_pos)); | 451 stopIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSeparat
or.m_obj, textParagraphSeparator.m_pos)); |
| 452 } | 452 } |
| 453 | 453 |
| 454 static inline BidiRun* createRun(int start, int end, RenderObject* obj, InlineBi
diResolver& resolver) | |
| 455 { | |
| 456 return new BidiRun(start, end, obj, resolver.context(), resolver.dir()); | |
| 457 } | |
| 458 | |
| 459 void RenderBlockFlow::appendRunsForObject(BidiRunList<BidiRun>& runs, int start,
int end, RenderObject* obj, InlineBidiResolver& resolver) | 454 void RenderBlockFlow::appendRunsForObject(BidiRunList<BidiRun>& runs, int start,
int end, RenderObject* obj, InlineBidiResolver& resolver) |
| 460 { | 455 { |
| 461 if (start > end || shouldSkipCreatingRunsForObject(obj)) | 456 adjustMidpointsAndAppendRunsForObjectIfNeeded(obj, start, end, resolver, App
endingRunsForObject, &runs); |
| 462 return; | |
| 463 | |
| 464 LineMidpointState& lineMidpointState = resolver.midpointState(); | |
| 465 bool haveNextMidpoint = (lineMidpointState.currentMidpoint < lineMidpointSta
te.numMidpoints); | |
| 466 InlineIterator nextMidpoint; | |
| 467 if (haveNextMidpoint) | |
| 468 nextMidpoint = lineMidpointState.midpoints[lineMidpointState.currentMidp
oint]; | |
| 469 if (lineMidpointState.betweenMidpoints) { | |
| 470 if (!(haveNextMidpoint && nextMidpoint.m_obj == obj)) | |
| 471 return; | |
| 472 // This is a new start point. Stop ignoring objects and | |
| 473 // adjust our start. | |
| 474 lineMidpointState.betweenMidpoints = false; | |
| 475 start = nextMidpoint.m_pos; | |
| 476 lineMidpointState.currentMidpoint++; | |
| 477 if (start < end) | |
| 478 return appendRunsForObject(runs, start, end, obj, resolver); | |
| 479 } else { | |
| 480 if (!haveNextMidpoint || (obj != nextMidpoint.m_obj)) { | |
| 481 runs.addRun(createRun(start, end, obj, resolver)); | |
| 482 return; | |
| 483 } | |
| 484 | |
| 485 // An end midpoint has been encountered within our object. We | |
| 486 // need to go ahead and append a run with our endpoint. | |
| 487 if (static_cast<int>(nextMidpoint.m_pos + 1) <= end) { | |
| 488 lineMidpointState.betweenMidpoints = true; | |
| 489 lineMidpointState.currentMidpoint++; | |
| 490 if (nextMidpoint.m_pos != UINT_MAX) { // UINT_MAX means stop at the
object and don't include any of it. | |
| 491 if (static_cast<int>(nextMidpoint.m_pos + 1) > start) | |
| 492 runs.addRun(createRun(start, nextMidpoint.m_pos + 1, obj, re
solver)); | |
| 493 return appendRunsForObject(runs, nextMidpoint.m_pos + 1, end, ob
j, resolver); | |
| 494 } | |
| 495 } else | |
| 496 runs.addRun(createRun(start, end, obj, resolver)); | |
| 497 } | |
| 498 } | 457 } |
| 499 | 458 |
| 500 static inline InlineBox* createInlineBoxForRenderer(RenderObject* obj, bool isRo
otLineBox, bool isOnlyRun = false) | 459 static inline InlineBox* createInlineBoxForRenderer(RenderObject* obj, bool isRo
otLineBox, bool isOnlyRun = false) |
| 501 { | 460 { |
| 502 if (isRootLineBox) | 461 if (isRootLineBox) |
| 503 return toRenderBlock(obj)->createAndAppendRootInlineBox(); | 462 return toRenderBlock(obj)->createAndAppendRootInlineBox(); |
| 504 | 463 |
| 505 if (obj->isText()) { | 464 if (obj->isText()) { |
| 506 InlineTextBox* textBox = toRenderText(obj)->createInlineTextBox(); | 465 InlineTextBox* textBox = toRenderText(obj)->createInlineTextBox(); |
| 507 // We only treat a box as text for a <br> if we are on a line by ourself
or in strict mode | 466 // We only treat a box as text for a <br> if we are on a line by ourself
or in strict mode |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 | 1211 |
| 1253 static inline void setupResolverToResumeInIsolate(InlineBidiResolver& resolver,
RenderObject* root, RenderObject* startObject) | 1212 static inline void setupResolverToResumeInIsolate(InlineBidiResolver& resolver,
RenderObject* root, RenderObject* startObject) |
| 1254 { | 1213 { |
| 1255 if (root != startObject) { | 1214 if (root != startObject) { |
| 1256 RenderObject* parent = startObject->parent(); | 1215 RenderObject* parent = startObject->parent(); |
| 1257 setupResolverToResumeInIsolate(resolver, root, parent); | 1216 setupResolverToResumeInIsolate(resolver, root, parent); |
| 1258 notifyObserverEnteredObject(&resolver, startObject); | 1217 notifyObserverEnteredObject(&resolver, startObject); |
| 1259 } | 1218 } |
| 1260 } | 1219 } |
| 1261 | 1220 |
| 1221 static void restoreIsolatedMidpointStates(InlineBidiResolver& topResolver, Inlin
eBidiResolver& isolatedResolver) |
| 1222 { |
| 1223 while (!isolatedResolver.isolatedRuns().isEmpty()) { |
| 1224 BidiRun* run = isolatedResolver.isolatedRuns().last(); |
| 1225 isolatedResolver.isolatedRuns().removeLast(); |
| 1226 topResolver.setMidpointStateForIsolatedRun(run, isolatedResolver.midpoin
tStateForIsolatedRun(run)); |
| 1227 } |
| 1228 } |
| 1229 |
| 1262 // FIXME: BidiResolver should have this logic. | 1230 // FIXME: BidiResolver should have this logic. |
| 1263 static inline void constructBidiRunsForSegment(InlineBidiResolver& topResolver,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& endOfRuns, VisualDirection
Override override, bool previousLineBrokeCleanly, bool isNewUBAParagraph) | 1231 static inline void constructBidiRunsForSegment(InlineBidiResolver& topResolver,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& endOfRuns, VisualDirection
Override override, bool previousLineBrokeCleanly, bool isNewUBAParagraph) |
| 1264 { | 1232 { |
| 1265 // FIXME: We should pass a BidiRunList into createBidiRunsForLine instead | 1233 // FIXME: We should pass a BidiRunList into createBidiRunsForLine instead |
| 1266 // of the resolver owning the runs. | 1234 // of the resolver owning the runs. |
| 1267 ASSERT(&topResolver.runs() == &bidiRuns); | 1235 ASSERT(&topResolver.runs() == &bidiRuns); |
| 1268 ASSERT(topResolver.position() != endOfRuns); | 1236 ASSERT(topResolver.position() != endOfRuns); |
| 1269 RenderObject* currentRoot = topResolver.position().root(); | 1237 RenderObject* currentRoot = topResolver.position().root(); |
| 1270 topResolver.createBidiRunsForLine(endOfRuns, override, previousLineBrokeClea
nly); | 1238 topResolver.createBidiRunsForLine(endOfRuns, override, previousLineBrokeClea
nly); |
| 1271 | 1239 |
| 1272 while (!topResolver.isolatedRuns().isEmpty()) { | 1240 while (!topResolver.isolatedRuns().isEmpty()) { |
| 1273 // It does not matter which order we resolve the runs as long as we reso
lve them all. | 1241 // It does not matter which order we resolve the runs as long as we reso
lve them all. |
| 1274 BidiRun* isolatedRun = topResolver.isolatedRuns().last(); | 1242 BidiRun* isolatedRun = topResolver.isolatedRuns().last(); |
| 1275 topResolver.isolatedRuns().removeLast(); | 1243 topResolver.isolatedRuns().removeLast(); |
| 1276 | 1244 |
| 1277 RenderObject* startObj = isolatedRun->object(); | 1245 RenderObject* startObj = isolatedRun->object(); |
| 1278 | 1246 |
| 1279 // Only inlines make sense with unicode-bidi: isolate (blocks are alread
y isolated). | 1247 // Only inlines make sense with unicode-bidi: isolate (blocks are alread
y isolated). |
| 1280 // FIXME: Because enterIsolate is not passed a RenderObject, we have to
crawl up the | 1248 // FIXME: Because enterIsolate is not passed a RenderObject, we have to
crawl up the |
| 1281 // tree to see which parent inline is the isolate. We could change enter
Isolate | 1249 // tree to see which parent inline is the isolate. We could change enter
Isolate |
| 1282 // to take a RenderObject and do this logic there, but that would be a l
ayering | 1250 // to take a RenderObject and do this logic there, but that would be a l
ayering |
| 1283 // violation for BidiResolver (which knows nothing about RenderObject). | 1251 // violation for BidiResolver (which knows nothing about RenderObject). |
| 1284 RenderInline* isolatedInline = toRenderInline(highestContainingIsolateWi
thinRoot(startObj, currentRoot)); | 1252 RenderInline* isolatedInline = toRenderInline(highestContainingIsolateWi
thinRoot(startObj, currentRoot)); |
| 1285 ASSERT(isolatedInline); | 1253 ASSERT(isolatedInline); |
| 1286 | 1254 |
| 1287 InlineBidiResolver isolatedResolver; | 1255 InlineBidiResolver isolatedResolver; |
| 1256 LineMidpointState& isolatedLineMidpointState = isolatedResolver.midpoint
State(); |
| 1257 isolatedLineMidpointState = topResolver.midpointStateForIsolatedRun(isol
atedRun); |
| 1288 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); | 1258 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); |
| 1289 TextDirection direction = isolatedInline->style()->direction(); | 1259 TextDirection direction = isolatedInline->style()->direction(); |
| 1290 if (unicodeBidi == Plaintext) { | 1260 if (unicodeBidi == Plaintext) { |
| 1291 if (isNewUBAParagraph) | 1261 if (isNewUBAParagraph) |
| 1292 direction = determinePlaintextDirectionality(isolatedInline, sta
rtObj); | 1262 direction = determinePlaintextDirectionality(isolatedInline, sta
rtObj); |
| 1293 else | 1263 else |
| 1294 direction = determinePlaintextDirectionality(isolatedInline); | 1264 direction = determinePlaintextDirectionality(isolatedInline); |
| 1295 } else { | 1265 } else { |
| 1296 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); | 1266 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); |
| 1297 direction = isolatedInline->style()->direction(); | 1267 direction = isolatedInline->style()->direction(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1314 // We're not guaranteed to get any BidiRuns in the previous step. If we
don't, we allow the placeholder | 1284 // We're not guaranteed to get any BidiRuns in the previous step. If we
don't, we allow the placeholder |
| 1315 // itself to be turned into an InlineBox. We can't remove it here withou
t potentially losing track of | 1285 // itself to be turned into an InlineBox. We can't remove it here withou
t potentially losing track of |
| 1316 // the logically last run. | 1286 // the logically last run. |
| 1317 if (isolatedResolver.runs().runCount()) | 1287 if (isolatedResolver.runs().runCount()) |
| 1318 bidiRuns.replaceRunWithRuns(isolatedRun, isolatedResolver.runs()); | 1288 bidiRuns.replaceRunWithRuns(isolatedRun, isolatedResolver.runs()); |
| 1319 | 1289 |
| 1320 // If we encountered any nested isolate runs, just move them | 1290 // If we encountered any nested isolate runs, just move them |
| 1321 // to the top resolver's list for later processing. | 1291 // to the top resolver's list for later processing. |
| 1322 if (!isolatedResolver.isolatedRuns().isEmpty()) { | 1292 if (!isolatedResolver.isolatedRuns().isEmpty()) { |
| 1323 topResolver.isolatedRuns().append(isolatedResolver.isolatedRuns()); | 1293 topResolver.isolatedRuns().append(isolatedResolver.isolatedRuns()); |
| 1324 isolatedResolver.isolatedRuns().clear(); | |
| 1325 currentRoot = isolatedInline; | 1294 currentRoot = isolatedInline; |
| 1295 restoreIsolatedMidpointStates(topResolver, isolatedResolver); |
| 1326 } | 1296 } |
| 1327 } | 1297 } |
| 1328 } | 1298 } |
| 1329 | 1299 |
| 1330 static inline bool segmentIsEmpty(const InlineIterator& segmentStart, const Inli
neIterator& segmentEnd) | 1300 static inline bool segmentIsEmpty(const InlineIterator& segmentStart, const Inli
neIterator& segmentEnd) |
| 1331 { | 1301 { |
| 1332 return segmentStart == segmentEnd; | 1302 return segmentStart == segmentEnd; |
| 1333 } | 1303 } |
| 1334 | 1304 |
| 1335 static inline void constructBidiRunsForLine(const RenderBlockFlow* block, Inline
BidiResolver& topResolver, BidiRunList<BidiRun>& bidiRuns, const InlineIterator&
endOfLine, VisualDirectionOverride override, bool previousLineBrokeCleanly, boo
l isNewUBAParagraph) | 1305 static inline void constructBidiRunsForLine(const RenderBlockFlow* block, Inline
BidiResolver& topResolver, BidiRunList<BidiRun>& bidiRuns, const InlineIterator&
endOfLine, VisualDirectionOverride override, bool previousLineBrokeCleanly, boo
l isNewUBAParagraph) |
| (...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3548 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); | 3518 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); |
| 3549 | 3519 |
| 3550 setLineGridBox(lineGridBox); | 3520 setLineGridBox(lineGridBox); |
| 3551 | 3521 |
| 3552 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying | 3522 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying |
| 3553 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping | 3523 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping |
| 3554 // to this grid. | 3524 // to this grid. |
| 3555 } | 3525 } |
| 3556 | 3526 |
| 3557 } | 3527 } |
| OLD | NEW |