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

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

Issue 343443002: Word spacing in RTL for segments (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added antialiased test in test expectaions Created 6 years, 6 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 | « LayoutTests/platform/linux/fast/text/international/bidi-word-spacing-rtl-expected.txt ('k') | no next file » | 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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 // The widths of all runs are now known. We can now place every inline box ( and 619 // The widths of all runs are now known. We can now place every inline box ( and
620 // compute accurate widths for the inline flow boxes). 620 // compute accurate widths for the inline flow boxes).
621 needsWordSpacing = false; 621 needsWordSpacing = false;
622 lineBox->placeBoxesInInlineDirection(lineLogicalLeft, needsWordSpacing, text BoxDataMap); 622 lineBox->placeBoxesInInlineDirection(lineLogicalLeft, needsWordSpacing, text BoxDataMap);
623 } 623 }
624 624
625 BidiRun* RenderBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo x* lineBox, const LineInfo& lineInfo, ETextAlign textAlign, float& logicalLeft, 625 BidiRun* RenderBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo x* lineBox, const LineInfo& lineInfo, ETextAlign textAlign, float& logicalLeft,
626 float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertica lPositionCache, 626 float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertica lPositionCache,
627 WordMeasurements& wordMeasurements) 627 WordMeasurements& wordMeasurements)
628 { 628 {
629 bool needsWordSpacing = false; 629 bool needsWordSpacing = true;
630 float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth().toFloat(); 630 float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth().toFloat();
631 unsigned expansionOpportunityCount = 0; 631 unsigned expansionOpportunityCount = 0;
632 bool isAfterExpansion = true; 632 bool isAfterExpansion = true;
633 Vector<unsigned, 16> expansionOpportunities; 633 Vector<unsigned, 16> expansionOpportunities;
634 RenderObject* previousObject = 0; 634 RenderObject* previousObject = 0;
635 TextJustify textJustify = style()->textJustify(); 635 TextJustify textJustify = style()->textJustify();
636 636
637 BidiRun* r = firstRun; 637 BidiRun* r = firstRun;
638 for (; r; r = r->next()) { 638 for (; r; r = r->next()) {
639 if (!r->m_box || r->m_object->isOutOfFlowPositioned() || r->m_box->isLin eBreak()) 639 if (!r->m_box || r->m_object->isOutOfFlowPositioned() || r->m_box->isLin eBreak())
640 continue; // Positioned objects are only participating to figure out their 640 continue; // Positioned objects are only participating to figure out their
641 // correct static x position. They have no effect on the width. 641 // correct static x position. They have no effect on the width.
642 // Similarly, line break boxes have no effect on the width . 642 // Similarly, line break boxes have no effect on the width .
643 if (r->m_object->isText()) { 643 if (r->m_object->isText()) {
644 RenderText* rt = toRenderText(r->m_object); 644 RenderText* rt = toRenderText(r->m_object);
645 if (textAlign == JUSTIFY && r != trailingSpaceRun && textJustify != TextJustifyNone) { 645 if (textAlign == JUSTIFY && r != trailingSpaceRun && textJustify != TextJustifyNone) {
646 if (!isAfterExpansion) 646 if (!isAfterExpansion)
647 toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true); 647 toInlineTextBox(r->m_box)->setCanHaveLeadingExpansion(true);
648 unsigned opportunitiesInRun; 648 unsigned opportunitiesInRun;
649 if (rt->is8Bit()) 649 if (rt->is8Bit())
650 opportunitiesInRun = Character::expansionOpportunityCount(rt ->characters8() + r->m_start, r->m_stop - r->m_start, r->m_box->direction(), isA fterExpansion); 650 opportunitiesInRun = Character::expansionOpportunityCount(rt ->characters8() + r->m_start, r->m_stop - r->m_start, r->m_box->direction(), isA fterExpansion);
651 else 651 else
652 opportunitiesInRun = Character::expansionOpportunityCount(rt ->characters16() + r->m_start, r->m_stop - r->m_start, r->m_box->direction(), is AfterExpansion); 652 opportunitiesInRun = Character::expansionOpportunityCount(rt ->characters16() + r->m_start, r->m_stop - r->m_start, r->m_box->direction(), is AfterExpansion);
653 expansionOpportunities.append(opportunitiesInRun); 653 expansionOpportunities.append(opportunitiesInRun);
654 expansionOpportunityCount += opportunitiesInRun; 654 expansionOpportunityCount += opportunitiesInRun;
655 } 655 }
656 656
657 if (int length = rt->textLength()) { 657 if (rt->textLength()) {
658 if (!r->m_start && needsWordSpacing && isSpaceOrNewline(rt->char acterAt(r->m_start))) 658 if (!r->m_start && needsWordSpacing && isSpaceOrNewline(rt->char acterAt(r->m_start)))
659 totalLogicalWidth += rt->style(lineInfo.isFirstLine())->font ().fontDescription().wordSpacing(); 659 totalLogicalWidth += rt->style(lineInfo.isFirstLine())->font ().fontDescription().wordSpacing();
660 needsWordSpacing = !isSpaceOrNewline(rt->characterAt(r->m_stop - 1)) && r->m_stop == length; 660 needsWordSpacing = !isSpaceOrNewline(rt->characterAt(r->m_stop - 1));
661 } 661 }
662 662
663 setLogicalWidthForTextRun(lineBox, r, rt, totalLogicalWidth, lineInf o, textBoxDataMap, verticalPositionCache, wordMeasurements); 663 setLogicalWidthForTextRun(lineBox, r, rt, totalLogicalWidth, lineInf o, textBoxDataMap, verticalPositionCache, wordMeasurements);
664 } else { 664 } else {
665 isAfterExpansion = false; 665 isAfterExpansion = false;
666 if (!r->m_object->isRenderInline()) { 666 if (!r->m_object->isRenderInline()) {
667 RenderBox* renderBox = toRenderBox(r->m_object); 667 RenderBox* renderBox = toRenderBox(r->m_object);
668 if (renderBox->isRubyRun()) 668 if (renderBox->isRubyRun())
669 setMarginsForRubyRun(r, toRenderRubyRun(renderBox), previous Object, lineInfo); 669 setMarginsForRubyRun(r, toRenderRubyRun(renderBox), previous Object, lineInfo);
670 r->m_box->setLogicalWidth(logicalWidthForChild(renderBox).toFloa t()); 670 r->m_box->setLogicalWidth(logicalWidthForChild(renderBox).toFloa t());
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); 2182 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat ();
2183 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; 2183 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft;
2184 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2184 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2185 2185
2186 if (!style()->isLeftToRightDirection()) 2186 if (!style()->isLeftToRightDirection())
2187 return logicalWidth() - logicalLeft; 2187 return logicalWidth() - logicalLeft;
2188 return logicalLeft; 2188 return logicalLeft;
2189 } 2189 }
2190 2190
2191 } 2191 }
OLDNEW
« no previous file with comments | « LayoutTests/platform/linux/fast/text/international/bidi-word-spacing-rtl-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698