Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: Source/core/rendering/RenderBlockLineLayout.cpp

Issue 119853004: Blink Unicode Bidi implementation does not support L1 rule. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/rendering/InlineIterator.h ('k') | Source/platform/text/BidiResolver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 if (r->m_object->isText()) 774 if (r->m_object->isText())
775 toRenderText(r->m_object)->positionLineBox(r->m_box); 775 toRenderText(r->m_object)->positionLineBox(r->m_box);
776 else if (r->m_object->isBox()) 776 else if (r->m_object->isBox())
777 toRenderBox(r->m_object)->positionLineBox(r->m_box); 777 toRenderBox(r->m_object)->positionLineBox(r->m_box);
778 } 778 }
779 // Positioned objects and zero-length text nodes destroy their boxes in 779 // Positioned objects and zero-length text nodes destroy their boxes in
780 // position(), which unnecessarily dirties the line. 780 // position(), which unnecessarily dirties the line.
781 lineBox->markDirty(false); 781 lineBox->markDirty(false);
782 } 782 }
783 783
784 static inline bool isCollapsibleSpace(UChar character, RenderText* renderer)
785 {
786 if (character == ' ' || character == '\t' || character == softHyphen)
787 return true;
788 if (character == '\n')
789 return !renderer->style()->preserveNewline();
790 return false;
791 }
792
793 template <typename CharacterType>
794 static inline int findFirstTrailingSpace(RenderText* lastText, const CharacterTy pe* characters, int start, int stop)
795 {
796 int firstSpace = stop;
797 while (firstSpace > start) {
798 UChar current = characters[firstSpace - 1];
799 if (!isCollapsibleSpace(current, lastText))
800 break;
801 firstSpace--;
802 }
803
804 return firstSpace;
805 }
806
807 inline BidiRun* RenderBlockFlow::handleTrailingSpaces(BidiRunList<BidiRun>& bidi Runs, BidiContext* currentContext)
808 {
809 if (!bidiRuns.runCount()
810 || !bidiRuns.logicallyLastRun()->m_object->style()->breakOnlyAfterWhiteS pace()
811 || !bidiRuns.logicallyLastRun()->m_object->style()->autoWrap())
812 return 0;
813
814 BidiRun* trailingSpaceRun = bidiRuns.logicallyLastRun();
815 RenderObject* lastObject = trailingSpaceRun->m_object;
816 if (!lastObject->isText())
817 return 0;
818
819 RenderText* lastText = toRenderText(lastObject);
820 int firstSpace;
821 if (lastText->is8Bit())
822 firstSpace = findFirstTrailingSpace(lastText, lastText->characters8(), t railingSpaceRun->start(), trailingSpaceRun->stop());
823 else
824 firstSpace = findFirstTrailingSpace(lastText, lastText->characters16(), trailingSpaceRun->start(), trailingSpaceRun->stop());
825
826 if (firstSpace == trailingSpaceRun->stop())
827 return 0;
828
829 TextDirection direction = style()->direction();
830 bool shouldReorder = trailingSpaceRun != (direction == LTR ? bidiRuns.lastRu n() : bidiRuns.firstRun());
831 if (firstSpace != trailingSpaceRun->start()) {
832 BidiContext* baseContext = currentContext;
833 while (BidiContext* parent = baseContext->parent())
834 baseContext = parent;
835
836 BidiRun* newTrailingRun = new BidiRun(firstSpace, trailingSpaceRun->m_st op, trailingSpaceRun->m_object, baseContext, OtherNeutral);
837 trailingSpaceRun->m_stop = firstSpace;
838 if (direction == LTR)
839 bidiRuns.addRun(newTrailingRun);
840 else
841 bidiRuns.prependRun(newTrailingRun);
842 trailingSpaceRun = newTrailingRun;
843 return trailingSpaceRun;
844 }
845 if (!shouldReorder)
846 return trailingSpaceRun;
847
848 if (direction == LTR) {
849 bidiRuns.moveRunToEnd(trailingSpaceRun);
850 trailingSpaceRun->m_level = 0;
851 } else {
852 bidiRuns.moveRunToBeginning(trailingSpaceRun);
853 trailingSpaceRun->m_level = 1;
854 }
855 return trailingSpaceRun;
856 }
857
858 void RenderBlockFlow::appendFloatingObjectToLastLine(FloatingObject* floatingObj ect) 784 void RenderBlockFlow::appendFloatingObjectToLastLine(FloatingObject* floatingObj ect)
859 { 785 {
860 ASSERT(!floatingObject->originatingLine()); 786 ASSERT(!floatingObject->originatingLine());
861 floatingObject->setOriginatingLine(lastRootBox()); 787 floatingObject->setOriginatingLine(lastRootBox());
862 lastRootBox()->appendFloat(floatingObject->renderer()); 788 lastRootBox()->appendFloat(floatingObject->renderer());
863 } 789 }
864 790
865 // FIXME: This should be a BidiStatus constructor or create method. 791 // FIXME: This should be a BidiStatus constructor or create method.
866 static inline BidiStatus statusWithDirection(TextDirection textDirection, bool i sOverride) 792 static inline BidiStatus statusWithDirection(TextDirection textDirection, bool i sOverride)
867 { 793 {
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 continue; 1377 continue;
1452 1378
1453 ASSERT(endOfLine != resolver.position()); 1379 ASSERT(endOfLine != resolver.position());
1454 1380
1455 // This is a short-cut for empty lines. 1381 // This is a short-cut for empty lines.
1456 if (layoutState.lineInfo().isEmpty()) { 1382 if (layoutState.lineInfo().isEmpty()) {
1457 if (lastRootBox()) 1383 if (lastRootBox())
1458 lastRootBox()->setLineBreakInfo(endOfLine.object(), endOfLine.of fset(), resolver.status()); 1384 lastRootBox()->setLineBreakInfo(endOfLine.object(), endOfLine.of fset(), resolver.status());
1459 } else { 1385 } else {
1460 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride); 1386 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride);
1461
1462 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && ! resolver.context()->parent()) { 1387 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && ! resolver.context()->parent()) {
1463 TextDirection direction = determinePlaintextDirectionality(resol ver.position().root(), resolver.position().object(), resolver.position().offset( )); 1388 TextDirection direction = determinePlaintextDirectionality(resol ver.position().root(), resolver.position().object(), resolver.position().offset( ));
1464 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse-> unicodeBidi()))); 1389 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse-> unicodeBidi())));
1465 } 1390 }
1466 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. 1391 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine.
1467 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); 1392 BidiRunList<BidiRun>& bidiRuns = resolver.runs();
1468 constructBidiRunsForLine(this, resolver, bidiRuns, endOfLine, overri de, layoutState.lineInfo().previousLineBrokeCleanly(), isNewUBAParagraph); 1393 constructBidiRunsForLine(this, resolver, bidiRuns, endOfLine, overri de, layoutState.lineInfo().previousLineBrokeCleanly(), isNewUBAParagraph);
1469 ASSERT(resolver.position() == endOfLine); 1394 ASSERT(resolver.position() == endOfLine);
1470 1395
1471 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; 1396 BidiRun* trailingSpaceRun = resolver.trailingSpaceRun();
1472 1397
1473 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { 1398 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) {
1474 bidiRuns.logicallyLastRun()->m_hasHyphen = true; 1399 bidiRuns.logicallyLastRun()->m_hasHyphen = true;
1475 consecutiveHyphenatedLines++; 1400 consecutiveHyphenatedLines++;
1476 } else 1401 } else
1477 consecutiveHyphenatedLines = 0; 1402 consecutiveHyphenatedLines = 0;
1478 1403
1479 // Now that the runs have been ordered, we create the line boxes. 1404 // Now that the runs have been ordered, we create the line boxes.
1480 // At the same time we figure out where border/padding/margin should be applied for 1405 // At the same time we figure out where border/padding/margin should be applied for
1481 // inline flow boxes. 1406 // inline flow boxes.
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 2340 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
2416 2341
2417 setLineGridBox(lineGridBox); 2342 setLineGridBox(lineGridBox);
2418 2343
2419 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 2344 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
2420 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 2345 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
2421 // to this grid. 2346 // to this grid.
2422 } 2347 }
2423 2348
2424 } 2349 }
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineIterator.h ('k') | Source/platform/text/BidiResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698