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 void determinePlaintextDirectionality(TextDirection& dir, RenderObject* r oot, RenderObject* current = 0, unsigned pos = 0) |
348 { | 348 { |
349 RenderObject* next = current; | |
eseidel
2013/08/21 20:52:29
OK, so Levi's suggestion was good, but I still thi
| |
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 InlineIterator iter(root, current, pos); | |
389 InlineBidiResolver observer; | |
390 observer.setPositionIgnoringNestedIsolates(iter); | |
391 observer.setStatus(BidiStatus(root->style()->direction(), isOverride(root->s tyle()->unicodeBidi()))); | |
349 while (!iter.atEnd()) { | 392 while (!iter.atEnd()) { |
393 if (observer.inIsolate()) { | |
394 iter.increment(&observer); | |
395 continue; | |
396 } | |
350 if (iter.atParagraphSeparator()) | 397 if (iter.atParagraphSeparator()) |
351 return; | 398 return; |
352 if (UChar current = iter.current()) { | 399 if (UChar current = iter.current()) { |
353 Direction charDirection = direction(current); | 400 Direction charDirection = direction(current); |
354 if (charDirection == LeftToRight) { | 401 if (charDirection == LeftToRight) { |
355 dir = LTR; | 402 dir = LTR; |
356 return; | 403 return; |
357 } | 404 } |
358 if (charDirection == RightToLeft || charDirection == RightToLeftArab ic) { | 405 if (charDirection == RightToLeft || charDirection == RightToLeftArab ic) { |
359 dir = RTL; | 406 dir = RTL; |
360 return; | 407 return; |
361 } | 408 } |
362 } | 409 } |
363 iter.increment(); | 410 iter.increment(&observer); |
364 } | 411 } |
365 } | 412 } |
366 | 413 |
367 static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator& lBreak) | 414 static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator& lBreak) |
368 { | 415 { |
369 // Check to see if our last midpoint is a start point beyond the line break. If so, | 416 // 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 | 417 // shave it off the list, and shave off a trailing space if the previous end point doesn't |
371 // preserve whitespace. | 418 // preserve whitespace. |
372 if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.nu mMidpoints % 2)) { | 419 if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.nu mMidpoints % 2)) { |
373 InlineIterator* midpoints = lineMidpointState.midpoints.data(); | 420 InlineIterator* midpoints = lineMidpointState.midpoints.data(); |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1269 | 1316 |
1270 // Only inlines make sense with unicode-bidi: isolate (blocks are alread y isolated). | 1317 // 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 | 1318 // 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 | 1319 // 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 | 1320 // 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). | 1321 // violation for BidiResolver (which knows nothing about RenderObject). |
1275 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj , currentRoot)); | 1322 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj , currentRoot)); |
1276 | 1323 |
1277 InlineBidiResolver isolatedResolver; | 1324 InlineBidiResolver isolatedResolver; |
1278 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); | 1325 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); |
1279 TextDirection direction; | 1326 TextDirection direction = isolatedInline->style()->direction(); |
1280 if (unicodeBidi == Plaintext) | 1327 if (unicodeBidi == Plaintext) |
1281 determineDirectionality(direction, InlineIterator(isolatedInline, is olatedRun->object(), 0)); | 1328 determinePlaintextDirectionality(direction, isolatedInline, startObj ); |
1282 else { | 1329 else { |
1283 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); | 1330 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); |
1284 direction = isolatedInline->style()->direction(); | 1331 direction = isolatedInline->style()->direction(); |
1285 } | 1332 } |
1286 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni codeBidi))); | 1333 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni codeBidi))); |
1287 | 1334 |
1288 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb j); | 1335 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb j); |
1289 | 1336 |
1290 // The starting position is the beginning of the first run within the is olate that was identified | 1337 // 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 | 1338 // 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 | 1845 |
1799 // This is a short-cut for empty lines. | 1846 // This is a short-cut for empty lines. |
1800 if (layoutState.lineInfo().isEmpty()) { | 1847 if (layoutState.lineInfo().isEmpty()) { |
1801 if (lastRootBox()) | 1848 if (lastRootBox()) |
1802 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s tatus()); | 1849 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s tatus()); |
1803 } else { | 1850 } else { |
1804 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride); | 1851 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride); |
1805 | 1852 |
1806 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && ! resolver.context()->parent()) { | 1853 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && ! resolver.context()->parent()) { |
1807 TextDirection direction = styleToUse->direction(); | 1854 TextDirection direction = styleToUse->direction(); |
1808 determineDirectionality(direction, resolver.position()); | 1855 determinePlaintextDirectionality(direction, resolver.position(). root(), resolver.position().object(), resolver.position().offset()); |
1809 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse-> unicodeBidi()))); | 1856 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse-> unicodeBidi()))); |
1810 } | 1857 } |
1811 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. | 1858 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. |
1812 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); | 1859 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); |
1813 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la youtState.lineInfo().previousLineBrokeCleanly()); | 1860 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la youtState.lineInfo().previousLineBrokeCleanly()); |
1814 ASSERT(resolver.position() == end); | 1861 ASSERT(resolver.position() == end); |
1815 | 1862 |
1816 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; | 1863 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; |
1817 | 1864 |
1818 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { | 1865 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()); | 2332 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr eak()); |
2286 | 2333 |
2287 if (last) { | 2334 if (last) { |
2288 setLogicalHeight(last->lineBottomWithLeading()); | 2335 setLogicalHeight(last->lineBottomWithLeading()); |
2289 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l ineBreakPos()); | 2336 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l ineBreakPos()); |
2290 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 2337 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
2291 resolver.setStatus(last->lineBreakBidiStatus()); | 2338 resolver.setStatus(last->lineBreakBidiStatus()); |
2292 } else { | 2339 } else { |
2293 TextDirection direction = style()->direction(); | 2340 TextDirection direction = style()->direction(); |
2294 if (style()->unicodeBidi() == Plaintext) | 2341 if (style()->unicodeBidi() == Plaintext) |
2295 determineDirectionality(direction, InlineIterator(this, bidiFirstSki ppingEmptyInlines(this), 0)); | 2342 determinePlaintextDirectionality(direction, this); |
2296 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); | 2343 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); |
2297 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, &resolver), 0); | 2344 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, &resolver), 0); |
2298 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 2345 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
2299 } | 2346 } |
2300 return curr; | 2347 return curr; |
2301 } | 2348 } |
2302 | 2349 |
2303 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) | 2350 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) |
2304 { | 2351 { |
2305 ASSERT(!layoutState.endLine()); | 2352 ASSERT(!layoutState.endLine()); |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3481 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); | 3528 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); |
3482 | 3529 |
3483 setLineGridBox(lineGridBox); | 3530 setLineGridBox(lineGridBox); |
3484 | 3531 |
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 | 3532 // 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 | 3533 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping |
3487 // to this grid. | 3534 // to this grid. |
3488 } | 3535 } |
3489 | 3536 |
3490 } | 3537 } |
OLD | NEW |