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 inline RenderObject* bidiFirstSkippingIsolated(RenderObject* root, Render Object* current = 0) | |
eseidel
2013/08/20 23:01:37
Bleh. All these bidiFirst* functions are ugly. I
leviw_travelin_and_unemployed
2013/08/21 02:04:37
I just talked to Eric about this, and this seems l
| |
348 { | |
349 RenderObject* next = current; | |
350 | |
351 while (current) { | |
352 if (isIsolated(current->style()->unicodeBidi()) | |
353 && (current->isRenderInline() || current->isRenderBlock())) { | |
354 if (current != root) | |
355 current = 0; | |
356 else | |
357 current = next; | |
358 break; | |
359 } | |
360 current = current->parent(); | |
361 } | |
362 | |
363 if (!current) | |
364 current = root->firstChild(); | |
365 | |
366 while (current) { | |
367 next = 0; | |
368 if (isIteratorTarget(current) && !(current->isText() && toRenderText(cur rent)->isAllCollapsibleWhitespace())) | |
369 break; | |
370 | |
371 if (!isIteratorTarget(current) && !isIsolated(current->style()->unicodeB idi())) | |
372 next = current->firstChild(); | |
373 | |
374 if (!next) { | |
375 while (current && current != root) { | |
376 next = current->nextSibling(); | |
377 if (next) | |
378 break; | |
379 current = current->parent(); | |
380 } | |
381 } | |
382 | |
383 if (!next) | |
384 break; | |
385 | |
386 current = next; | |
387 } | |
388 return current; | |
389 } | |
390 | |
347 static void determineDirectionality(TextDirection& dir, InlineIterator iter) | 391 static void determineDirectionality(TextDirection& dir, InlineIterator iter) |
348 { | 392 { |
349 while (!iter.atEnd()) { | 393 while (!iter.atEnd()) { |
350 if (iter.atParagraphSeparator()) | 394 if (iter.atParagraphSeparator()) |
351 return; | 395 return; |
352 if (UChar current = iter.current()) { | 396 if (UChar current = iter.current()) { |
353 Direction charDirection = direction(current); | 397 Direction charDirection = direction(current); |
354 if (charDirection == LeftToRight) { | 398 if (charDirection == LeftToRight) { |
355 dir = LTR; | 399 dir = LTR; |
356 return; | 400 return; |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1269 | 1313 |
1270 // Only inlines make sense with unicode-bidi: isolate (blocks are alread y isolated). | 1314 // 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 | 1315 // 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 | 1316 // 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 | 1317 // 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). | 1318 // violation for BidiResolver (which knows nothing about RenderObject). |
1275 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj , currentRoot)); | 1319 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj , currentRoot)); |
1276 | 1320 |
1277 InlineBidiResolver isolatedResolver; | 1321 InlineBidiResolver isolatedResolver; |
1278 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); | 1322 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); |
1279 TextDirection direction; | 1323 TextDirection direction = isolatedInline->style()->direction(); |
1280 if (unicodeBidi == Plaintext) | 1324 if (unicodeBidi == Plaintext) |
1281 determineDirectionality(direction, InlineIterator(isolatedInline, is olatedRun->object(), 0)); | 1325 determineDirectionality(direction, InlineIterator(isolatedInline, bi diFirstSkippingIsolated(isolatedInline, startObj), 0)); |
1282 else { | 1326 else { |
1283 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); | 1327 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); |
1284 direction = isolatedInline->style()->direction(); | 1328 direction = isolatedInline->style()->direction(); |
1285 } | 1329 } |
1286 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni codeBidi))); | 1330 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni codeBidi))); |
1287 | 1331 |
1288 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb j); | 1332 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb j); |
1289 | 1333 |
1290 // The starting position is the beginning of the first run within the is olate that was identified | 1334 // 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 | 1335 // 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 | 1842 |
1799 // This is a short-cut for empty lines. | 1843 // This is a short-cut for empty lines. |
1800 if (layoutState.lineInfo().isEmpty()) { | 1844 if (layoutState.lineInfo().isEmpty()) { |
1801 if (lastRootBox()) | 1845 if (lastRootBox()) |
1802 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s tatus()); | 1846 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s tatus()); |
1803 } else { | 1847 } else { |
1804 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride); | 1848 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride); |
1805 | 1849 |
1806 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && ! resolver.context()->parent()) { | 1850 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && ! resolver.context()->parent()) { |
1807 TextDirection direction = styleToUse->direction(); | 1851 TextDirection direction = styleToUse->direction(); |
1808 determineDirectionality(direction, resolver.position()); | 1852 determineDirectionality(direction, InlineIterator(resolver.posit ion().root(), bidiFirstSkippingIsolated(resolver.position().root(), resolver.pos ition().object()), resolver.position().offset())); |
1809 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse-> unicodeBidi()))); | 1853 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse-> unicodeBidi()))); |
1810 } | 1854 } |
1811 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. | 1855 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. |
1812 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); | 1856 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); |
1813 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la youtState.lineInfo().previousLineBrokeCleanly()); | 1857 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la youtState.lineInfo().previousLineBrokeCleanly()); |
1814 ASSERT(resolver.position() == end); | 1858 ASSERT(resolver.position() == end); |
1815 | 1859 |
1816 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; | 1860 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; |
1817 | 1861 |
1818 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { | 1862 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()); | 2329 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr eak()); |
2286 | 2330 |
2287 if (last) { | 2331 if (last) { |
2288 setLogicalHeight(last->lineBottomWithLeading()); | 2332 setLogicalHeight(last->lineBottomWithLeading()); |
2289 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l ineBreakPos()); | 2333 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l ineBreakPos()); |
2290 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 2334 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
2291 resolver.setStatus(last->lineBreakBidiStatus()); | 2335 resolver.setStatus(last->lineBreakBidiStatus()); |
2292 } else { | 2336 } else { |
2293 TextDirection direction = style()->direction(); | 2337 TextDirection direction = style()->direction(); |
2294 if (style()->unicodeBidi() == Plaintext) | 2338 if (style()->unicodeBidi() == Plaintext) |
2295 determineDirectionality(direction, InlineIterator(this, bidiFirstSki ppingEmptyInlines(this), 0)); | 2339 determineDirectionality(direction, InlineIterator(this, bidiFirstSki ppingIsolated(this), 0)); |
2296 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); | 2340 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); |
2297 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, &resolver), 0); | 2341 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, &resolver), 0); |
2298 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 2342 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
2299 } | 2343 } |
2300 return curr; | 2344 return curr; |
2301 } | 2345 } |
2302 | 2346 |
2303 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) | 2347 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) |
2304 { | 2348 { |
2305 ASSERT(!layoutState.endLine()); | 2349 ASSERT(!layoutState.endLine()); |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3481 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); | 3525 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); |
3482 | 3526 |
3483 setLineGridBox(lineGridBox); | 3527 setLineGridBox(lineGridBox); |
3484 | 3528 |
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 | 3529 // 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 | 3530 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping |
3487 // to this grid. | 3531 // to this grid. |
3488 } | 3532 } |
3489 | 3533 |
3490 } | 3534 } |
OLD | NEW |