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

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

Issue 150403003: Consider text alignment and direction when computing the left offset for horizontal writing modes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@issue313593
Patch Set: Created 6 years, 10 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
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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 560 }
561 expansionOpportunityCount -= opportunitiesInRun; 561 expansionOpportunityCount -= opportunitiesInRun;
562 if (!expansionOpportunityCount) 562 if (!expansionOpportunityCount)
563 break; 563 break;
564 } 564 }
565 } 565 }
566 } 566 }
567 567
568 void RenderBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign , const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalL eft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpport unityCount) 568 void RenderBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign , const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalL eft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpport unityCount)
569 { 569 {
570 TextDirection direction;
571 if (rootInlineBox && rootInlineBox->renderer()->style()->unicodeBidi() == Pl aintext)
572 direction = rootInlineBox->direction();
573 else
574 direction = style()->direction();
575
576 // Armed with the total width of the line (without justification), 570 // Armed with the total width of the line (without justification),
577 // we now examine our text-align property in order to determine where to pos ition the 571 // we now examine our text-align property in order to determine where to pos ition the
578 // objects horizontally. The total width of the line can be increased if we end up 572 // objects horizontally. The total width of the line can be increased if we end up
579 // justifying text. 573 // justifying text.
580 switch (textAlign) { 574 switch (simplifiedTextAlign(textAlign, rootInlineBox)) {
581 case LEFT: 575 case LEFT:
582 case WEBKIT_LEFT:
583 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); 576 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
584 break; 577 break;
585 case RIGHT: 578 case RIGHT:
586 case WEBKIT_RIGHT:
587 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirection() , trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); 579 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirection() , trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
588 break; 580 break;
589 case CENTER: 581 case CENTER:
590 case WEBKIT_CENTER:
591 updateLogicalWidthForCenterAlignedBlock(style()->isLeftToRightDirection( ), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); 582 updateLogicalWidthForCenterAlignedBlock(style()->isLeftToRightDirection( ), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
592 break; 583 break;
593 case JUSTIFY: 584 case JUSTIFY:
594 adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, availableLogicalWidth); 585 adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, availableLogicalWidth);
595 if (expansionOpportunityCount) { 586 if (expansionOpportunityCount) {
596 if (trailingSpaceRun) { 587 if (trailingSpaceRun) {
597 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); 588 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth();
598 trailingSpaceRun->m_box->setLogicalWidth(0); 589 trailingSpaceRun->m_box->setLogicalWidth(0);
599 } 590 }
600 break; 591 } else {
592 ETextAlign adjustedTextAlign = style()->isLeftToRightDirection() ? L EFT : RIGHT;
593 updateLogicalWidthForAlignment(adjustedTextAlign, rootInlineBox, tra ilingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionO pportunityCount);
601 } 594 }
602 // Fall through
603 case TASTART:
604 if (direction == LTR)
605 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirectio n(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
606 else
607 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirecti on(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
608 break; 595 break;
609 case TAEND: 596 default:
610 if (direction == LTR) 597 ASSERT_NOT_REACHED();
611 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirecti on(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
612 else
613 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirectio n(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
614 break; 598 break;
615 } 599 }
616 } 600 }
617 601
618 static void updateLogicalInlinePositions(RenderBlockFlow* block, float& lineLogi calLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight) 602 static void updateLogicalInlinePositions(RenderBlockFlow* block, float& lineLogi calLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight)
619 { 603 {
620 LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedRenderer(first Line, boxLogicalHeight); 604 LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedRenderer(first Line, boxLogicalHeight);
621 lineLogicalLeft = block->logicalLeftOffsetForLine(block->logicalHeight(), sh ouldIndentText == IndentText, lineLogicalHeight); 605 lineLogicalLeft = block->logicalLeftOffsetForLine(block->logicalHeight(), sh ouldIndentText == IndentText, lineLogicalHeight);
622 // FIXME: This shouldn't be pixel snapped once multicolumn layout has been u pdated to correctly carry over subpixel values. 606 // FIXME: This shouldn't be pixel snapped once multicolumn layout has been u pdated to correctly carry over subpixel values.
623 // https://bugs.webkit.org/show_bug.cgi?id=105461 607 // https://bugs.webkit.org/show_bug.cgi?id=105461
(...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 2229 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
2246 2230
2247 setLineGridBox(lineGridBox); 2231 setLineGridBox(lineGridBox);
2248 2232
2249 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 2233 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
2250 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 2234 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
2251 // to this grid. 2235 // to this grid.
2252 } 2236 }
2253 2237
2254 } 2238 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698