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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 extraWidth += borderPaddingMarginEnd(parentAsRenderInline); | 337 extraWidth += borderPaddingMarginEnd(parentAsRenderInline); |
338 if (!start && !end) | 338 if (!start && !end) |
339 return extraWidth; | 339 return extraWidth; |
340 } | 340 } |
341 child = parent; | 341 child = parent; |
342 parent = child->parent(); | 342 parent = child->parent(); |
343 } | 343 } |
344 return extraWidth; | 344 return extraWidth; |
345 } | 345 } |
346 | 346 |
347 static void determineDirectionality(TextDirection& dir, InlineIterator iter) | 347 static RenderObject* firstRenderObjectForDirectionalityDetermination(RenderObjec
t* root, RenderObject* current = 0) |
348 { | 348 { |
| 349 RenderObject* next = current; |
| 350 while (current) { |
| 351 if (isIsolated(current->style()->unicodeBidi()) |
| 352 && (current->isRenderInline() || current->isRenderBlock())) { |
| 353 if (current != root) |
| 354 current = 0; |
| 355 else |
| 356 current = next; |
| 357 break; |
| 358 } |
| 359 current = current->parent(); |
| 360 } |
| 361 |
| 362 if (!current) |
| 363 current = root->firstChild(); |
| 364 |
| 365 while (current) { |
| 366 next = 0; |
| 367 if (isIteratorTarget(current) && !(current->isText() && toRenderText(cur
rent)->isAllCollapsibleWhitespace())) |
| 368 break; |
| 369 |
| 370 if (!isIteratorTarget(current) && !isIsolated(current->style()->unicodeB
idi())) |
| 371 next = current->firstChild(); |
| 372 |
| 373 if (!next) { |
| 374 while (current && current != root) { |
| 375 next = current->nextSibling(); |
| 376 if (next) |
| 377 break; |
| 378 current = current->parent(); |
| 379 } |
| 380 } |
| 381 |
| 382 if (!next) |
| 383 break; |
| 384 |
| 385 current = next; |
| 386 } |
| 387 |
| 388 return current; |
| 389 } |
| 390 |
| 391 static void determinePlaintextDirectionality(TextDirection& dir, RenderObject* r
oot, RenderObject* current = 0, unsigned pos = 0) |
| 392 { |
| 393 InlineIterator iter(root, firstRenderObjectForDirectionalityDetermination(ro
ot, current), pos); |
| 394 InlineBidiResolver observer; |
| 395 observer.setPositionIgnoringNestedIsolates(iter); |
| 396 observer.setStatus(BidiStatus(root->style()->direction(), isOverride(root->s
tyle()->unicodeBidi()))); |
349 while (!iter.atEnd()) { | 397 while (!iter.atEnd()) { |
| 398 if (observer.inIsolate()) { |
| 399 iter.increment(&observer); |
| 400 continue; |
| 401 } |
350 if (iter.atParagraphSeparator()) | 402 if (iter.atParagraphSeparator()) |
351 return; | 403 return; |
352 if (UChar current = iter.current()) { | 404 if (UChar current = iter.current()) { |
353 Direction charDirection = direction(current); | 405 Direction charDirection = direction(current); |
354 if (charDirection == LeftToRight) { | 406 if (charDirection == LeftToRight) { |
355 dir = LTR; | 407 dir = LTR; |
356 return; | 408 return; |
357 } | 409 } |
358 if (charDirection == RightToLeft || charDirection == RightToLeftArab
ic) { | 410 if (charDirection == RightToLeft || charDirection == RightToLeftArab
ic) { |
359 dir = RTL; | 411 dir = RTL; |
360 return; | 412 return; |
361 } | 413 } |
362 } | 414 } |
363 iter.increment(); | 415 iter.increment(&observer); |
364 } | 416 } |
365 } | 417 } |
366 | 418 |
367 static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator&
lBreak) | 419 static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator&
lBreak) |
368 { | 420 { |
369 // Check to see if our last midpoint is a start point beyond the line break.
If so, | 421 // Check to see if our last midpoint is a start point beyond the line break.
If so, |
370 // shave it off the list, and shave off a trailing space if the previous end
point doesn't | 422 // shave it off the list, and shave off a trailing space if the previous end
point doesn't |
371 // preserve whitespace. | 423 // preserve whitespace. |
372 if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.nu
mMidpoints % 2)) { | 424 if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.nu
mMidpoints % 2)) { |
373 InlineIterator* midpoints = lineMidpointState.midpoints.data(); | 425 InlineIterator* midpoints = lineMidpointState.midpoints.data(); |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 | 1321 |
1270 // Only inlines make sense with unicode-bidi: isolate (blocks are alread
y isolated). | 1322 // Only inlines make sense with unicode-bidi: isolate (blocks are alread
y isolated). |
1271 // FIXME: Because enterIsolate is not passed a RenderObject, we have to
crawl up the | 1323 // FIXME: Because enterIsolate is not passed a RenderObject, we have to
crawl up the |
1272 // tree to see which parent inline is the isolate. We could change enter
Isolate | 1324 // tree to see which parent inline is the isolate. We could change enter
Isolate |
1273 // to take a RenderObject and do this logic there, but that would be a l
ayering | 1325 // to take a RenderObject and do this logic there, but that would be a l
ayering |
1274 // violation for BidiResolver (which knows nothing about RenderObject). | 1326 // violation for BidiResolver (which knows nothing about RenderObject). |
1275 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj
, currentRoot)); | 1327 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj
, currentRoot)); |
1276 | 1328 |
1277 InlineBidiResolver isolatedResolver; | 1329 InlineBidiResolver isolatedResolver; |
1278 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); | 1330 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); |
1279 TextDirection direction; | 1331 TextDirection direction = isolatedInline->style()->direction(); |
1280 if (unicodeBidi == Plaintext) | 1332 if (unicodeBidi == Plaintext) |
1281 determineDirectionality(direction, InlineIterator(isolatedInline, is
olatedRun->object(), 0)); | 1333 determinePlaintextDirectionality(direction, isolatedInline, startObj
); |
1282 else { | 1334 else { |
1283 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); | 1335 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); |
1284 direction = isolatedInline->style()->direction(); | 1336 direction = isolatedInline->style()->direction(); |
1285 } | 1337 } |
1286 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni
codeBidi))); | 1338 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni
codeBidi))); |
1287 | 1339 |
1288 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb
j); | 1340 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb
j); |
1289 | 1341 |
1290 // The starting position is the beginning of the first run within the is
olate that was identified | 1342 // The starting position is the beginning of the first run within the is
olate that was identified |
1291 // during the earlier call to createBidiRunsForLine. This can be but is
not necessarily the | 1343 // during the earlier call to createBidiRunsForLine. This can be but is
not necessarily the |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 | 1850 |
1799 // This is a short-cut for empty lines. | 1851 // This is a short-cut for empty lines. |
1800 if (layoutState.lineInfo().isEmpty()) { | 1852 if (layoutState.lineInfo().isEmpty()) { |
1801 if (lastRootBox()) | 1853 if (lastRootBox()) |
1802 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s
tatus()); | 1854 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s
tatus()); |
1803 } else { | 1855 } else { |
1804 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis
ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR
ightToLeftOverride) : NoVisualOverride); | 1856 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis
ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR
ightToLeftOverride) : NoVisualOverride); |
1805 | 1857 |
1806 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && !
resolver.context()->parent()) { | 1858 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && !
resolver.context()->parent()) { |
1807 TextDirection direction = styleToUse->direction(); | 1859 TextDirection direction = styleToUse->direction(); |
1808 determineDirectionality(direction, resolver.position()); | 1860 determinePlaintextDirectionality(direction, resolver.position().
root(), resolver.position().object(), resolver.position().offset()); |
1809 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->
unicodeBidi()))); | 1861 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->
unicodeBidi()))); |
1810 } | 1862 } |
1811 // FIXME: This ownership is reversed. We should own the BidiRunList
and pass it to createBidiRunsForLine. | 1863 // FIXME: This ownership is reversed. We should own the BidiRunList
and pass it to createBidiRunsForLine. |
1812 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); | 1864 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); |
1813 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la
youtState.lineInfo().previousLineBrokeCleanly()); | 1865 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la
youtState.lineInfo().previousLineBrokeCleanly()); |
1814 ASSERT(resolver.position() == end); | 1866 ASSERT(resolver.position() == end); |
1815 | 1867 |
1816 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok
eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; | 1868 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok
eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; |
1817 | 1869 |
1818 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { | 1870 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr
eak()); | 2337 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr
eak()); |
2286 | 2338 |
2287 if (last) { | 2339 if (last) { |
2288 setLogicalHeight(last->lineBottomWithLeading()); | 2340 setLogicalHeight(last->lineBottomWithLeading()); |
2289 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l
ineBreakPos()); | 2341 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l
ineBreakPos()); |
2290 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 2342 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
2291 resolver.setStatus(last->lineBreakBidiStatus()); | 2343 resolver.setStatus(last->lineBreakBidiStatus()); |
2292 } else { | 2344 } else { |
2293 TextDirection direction = style()->direction(); | 2345 TextDirection direction = style()->direction(); |
2294 if (style()->unicodeBidi() == Plaintext) | 2346 if (style()->unicodeBidi() == Plaintext) |
2295 determineDirectionality(direction, InlineIterator(this, bidiFirstSki
ppingEmptyInlines(this), 0)); | 2347 determinePlaintextDirectionality(direction, this); |
2296 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi
()))); | 2348 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi
()))); |
2297 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines
(this, &resolver), 0); | 2349 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines
(this, &resolver), 0); |
2298 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 2350 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
2299 } | 2351 } |
2300 return curr; | 2352 return curr; |
2301 } | 2353 } |
2302 | 2354 |
2303 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB
ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) | 2355 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB
ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) |
2304 { | 2356 { |
2305 ASSERT(!layoutState.endLine()); | 2357 ASSERT(!layoutState.endLine()); |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3481 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); | 3533 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); |
3482 | 3534 |
3483 setLineGridBox(lineGridBox); | 3535 setLineGridBox(lineGridBox); |
3484 | 3536 |
3485 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying | 3537 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying |
3486 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping | 3538 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping |
3487 // to this grid. | 3539 // to this grid. |
3488 } | 3540 } |
3489 | 3541 |
3490 } | 3542 } |
OLD | NEW |