| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 381 |
| 382 if (!next) | 382 if (!next) |
| 383 break; | 383 break; |
| 384 | 384 |
| 385 current = next; | 385 current = next; |
| 386 } | 386 } |
| 387 | 387 |
| 388 return current; | 388 return current; |
| 389 } | 389 } |
| 390 | 390 |
| 391 static void determinePlaintextDirectionality(TextDirection& dir, RenderObject* r
oot, RenderObject* current = 0, unsigned pos = 0) | 391 static TextDirection determinePlaintextDirectionality(RenderObject* root, Render
Object* current = 0, unsigned pos = 0) |
| 392 { | 392 { |
| 393 InlineIterator iter(root, firstRenderObjectForDirectionalityDetermination(ro
ot, current), pos); | 393 InlineIterator iter(root, firstRenderObjectForDirectionalityDetermination(ro
ot, current), pos); |
| 394 InlineBidiResolver observer; | 394 InlineBidiResolver observer; |
| 395 observer.setPositionIgnoringNestedIsolates(iter); | 395 observer.setPositionIgnoringNestedIsolates(iter); |
| 396 observer.setStatus(BidiStatus(root->style()->direction(), isOverride(root->s
tyle()->unicodeBidi()))); | 396 observer.setStatus(BidiStatus(root->style()->direction(), isOverride(root->s
tyle()->unicodeBidi()))); |
| 397 while (!iter.atEnd()) { | 397 while (!iter.atEnd()) { |
| 398 if (observer.inIsolate()) { | 398 if (observer.inIsolate()) { |
| 399 iter.increment(&observer); | 399 iter.increment(&observer); |
| 400 continue; | 400 continue; |
| 401 } | 401 } |
| 402 if (iter.atParagraphSeparator()) | 402 if (iter.atParagraphSeparator()) |
| 403 return; | 403 break; |
| 404 if (UChar current = iter.current()) { | 404 if (UChar current = iter.current()) { |
| 405 Direction charDirection = direction(current); | 405 Direction charDirection = direction(current); |
| 406 if (charDirection == LeftToRight) { | 406 if (charDirection == LeftToRight) |
| 407 dir = LTR; | 407 return LTR; |
| 408 return; | 408 if (charDirection == RightToLeft || charDirection == RightToLeftArab
ic) |
| 409 } | 409 return RTL; |
| 410 if (charDirection == RightToLeft || charDirection == RightToLeftArab
ic) { | |
| 411 dir = RTL; | |
| 412 return; | |
| 413 } | |
| 414 } | 410 } |
| 415 iter.increment(&observer); | 411 iter.increment(&observer); |
| 416 } | 412 } |
| 413 return LTR; |
| 417 } | 414 } |
| 418 | 415 |
| 419 static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator&
lBreak) | 416 static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator&
lBreak) |
| 420 { | 417 { |
| 421 // Check to see if our last midpoint is a start point beyond the line break.
If so, | 418 // Check to see if our last midpoint is a start point beyond the line break.
If so, |
| 422 // shave it off the list, and shave off a trailing space if the previous end
point doesn't | 419 // shave it off the list, and shave off a trailing space if the previous end
point doesn't |
| 423 // preserve whitespace. | 420 // preserve whitespace. |
| 424 if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.nu
mMidpoints % 2)) { | 421 if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.nu
mMidpoints % 2)) { |
| 425 InlineIterator* midpoints = lineMidpointState.midpoints.data(); | 422 InlineIterator* midpoints = lineMidpointState.midpoints.data(); |
| 426 InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2]
; | 423 InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2]
; |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 // FIXME: Because enterIsolate is not passed a RenderObject, we have to
crawl up the | 1320 // FIXME: Because enterIsolate is not passed a RenderObject, we have to
crawl up the |
| 1324 // tree to see which parent inline is the isolate. We could change enter
Isolate | 1321 // tree to see which parent inline is the isolate. We could change enter
Isolate |
| 1325 // to take a RenderObject and do this logic there, but that would be a l
ayering | 1322 // to take a RenderObject and do this logic there, but that would be a l
ayering |
| 1326 // violation for BidiResolver (which knows nothing about RenderObject). | 1323 // violation for BidiResolver (which knows nothing about RenderObject). |
| 1327 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj
, currentRoot)); | 1324 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj
, currentRoot)); |
| 1328 | 1325 |
| 1329 InlineBidiResolver isolatedResolver; | 1326 InlineBidiResolver isolatedResolver; |
| 1330 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); | 1327 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); |
| 1331 TextDirection direction = isolatedInline->style()->direction(); | 1328 TextDirection direction = isolatedInline->style()->direction(); |
| 1332 if (unicodeBidi == Plaintext) | 1329 if (unicodeBidi == Plaintext) |
| 1333 determinePlaintextDirectionality(direction, isolatedInline, startObj
); | 1330 direction = determinePlaintextDirectionality(isolatedInline, startOb
j); |
| 1334 else { | 1331 else { |
| 1335 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); | 1332 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); |
| 1336 direction = isolatedInline->style()->direction(); | 1333 direction = isolatedInline->style()->direction(); |
| 1337 } | 1334 } |
| 1338 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni
codeBidi))); | 1335 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni
codeBidi))); |
| 1339 | 1336 |
| 1340 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb
j); | 1337 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb
j); |
| 1341 | 1338 |
| 1342 // The starting position is the beginning of the first run within the is
olate that was identified | 1339 // The starting position is the beginning of the first run within the is
olate that was identified |
| 1343 // during the earlier call to createBidiRunsForLine. This can be but is
not necessarily the | 1340 // during the earlier call to createBidiRunsForLine. This can be but is
not necessarily the |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 ASSERT(end != resolver.position()); | 1846 ASSERT(end != resolver.position()); |
| 1850 | 1847 |
| 1851 // This is a short-cut for empty lines. | 1848 // This is a short-cut for empty lines. |
| 1852 if (layoutState.lineInfo().isEmpty()) { | 1849 if (layoutState.lineInfo().isEmpty()) { |
| 1853 if (lastRootBox()) | 1850 if (lastRootBox()) |
| 1854 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s
tatus()); | 1851 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s
tatus()); |
| 1855 } else { | 1852 } else { |
| 1856 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis
ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR
ightToLeftOverride) : NoVisualOverride); | 1853 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis
ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR
ightToLeftOverride) : NoVisualOverride); |
| 1857 | 1854 |
| 1858 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && !
resolver.context()->parent()) { | 1855 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && !
resolver.context()->parent()) { |
| 1859 TextDirection direction = styleToUse->direction(); | 1856 TextDirection direction = determinePlaintextDirectionality(resol
ver.position().root(), resolver.position().object(), resolver.position().offset(
)); |
| 1860 determinePlaintextDirectionality(direction, resolver.position().
root(), resolver.position().object(), resolver.position().offset()); | |
| 1861 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->
unicodeBidi()))); | 1857 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->
unicodeBidi()))); |
| 1862 } | 1858 } |
| 1863 // FIXME: This ownership is reversed. We should own the BidiRunList
and pass it to createBidiRunsForLine. | 1859 // FIXME: This ownership is reversed. We should own the BidiRunList
and pass it to createBidiRunsForLine. |
| 1864 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); | 1860 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); |
| 1865 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la
youtState.lineInfo().previousLineBrokeCleanly()); | 1861 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la
youtState.lineInfo().previousLineBrokeCleanly()); |
| 1866 ASSERT(resolver.position() == end); | 1862 ASSERT(resolver.position() == end); |
| 1867 | 1863 |
| 1868 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok
eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; | 1864 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok
eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; |
| 1869 | 1865 |
| 1870 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { | 1866 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2337 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr
eak()); | 2333 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr
eak()); |
| 2338 | 2334 |
| 2339 if (last) { | 2335 if (last) { |
| 2340 setLogicalHeight(last->lineBottomWithLeading()); | 2336 setLogicalHeight(last->lineBottomWithLeading()); |
| 2341 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l
ineBreakPos()); | 2337 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l
ineBreakPos()); |
| 2342 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 2338 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
| 2343 resolver.setStatus(last->lineBreakBidiStatus()); | 2339 resolver.setStatus(last->lineBreakBidiStatus()); |
| 2344 } else { | 2340 } else { |
| 2345 TextDirection direction = style()->direction(); | 2341 TextDirection direction = style()->direction(); |
| 2346 if (style()->unicodeBidi() == Plaintext) | 2342 if (style()->unicodeBidi() == Plaintext) |
| 2347 determinePlaintextDirectionality(direction, this); | 2343 direction = determinePlaintextDirectionality(this); |
| 2348 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi
()))); | 2344 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi
()))); |
| 2349 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines
(this, &resolver), 0); | 2345 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines
(this, &resolver), 0); |
| 2350 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 2346 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
| 2351 } | 2347 } |
| 2352 return curr; | 2348 return curr; |
| 2353 } | 2349 } |
| 2354 | 2350 |
| 2355 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB
ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) | 2351 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB
ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) |
| 2356 { | 2352 { |
| 2357 ASSERT(!layoutState.endLine()); | 2353 ASSERT(!layoutState.endLine()); |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3533 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); | 3529 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); |
| 3534 | 3530 |
| 3535 setLineGridBox(lineGridBox); | 3531 setLineGridBox(lineGridBox); |
| 3536 | 3532 |
| 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 | 3533 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying |
| 3538 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping | 3534 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping |
| 3539 // to this grid. | 3535 // to this grid. |
| 3540 } | 3536 } |
| 3541 | 3537 |
| 3542 } | 3538 } |
| OLD | NEW |