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

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

Issue 176763011: Revert "Consider text alignment and direction when computing the left offset for horizontal writing… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 528 }
529 expansionOpportunityCount -= opportunitiesInRun; 529 expansionOpportunityCount -= opportunitiesInRun;
530 if (!expansionOpportunityCount) 530 if (!expansionOpportunityCount)
531 break; 531 break;
532 } 532 }
533 } 533 }
534 } 534 }
535 535
536 void RenderBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign , const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalL eft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpport unityCount) 536 void RenderBlockFlow::updateLogicalWidthForAlignment(const ETextAlign& textAlign , const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalL eft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpport unityCount)
537 { 537 {
538 TextDirection direction;
539 if (rootInlineBox && rootInlineBox->renderer().style()->unicodeBidi() == Pla intext)
540 direction = rootInlineBox->direction();
541 else
542 direction = style()->direction();
543
538 // Armed with the total width of the line (without justification), 544 // Armed with the total width of the line (without justification),
539 // we now examine our text-align property in order to determine where to pos ition the 545 // we now examine our text-align property in order to determine where to pos ition the
540 // objects horizontally. The total width of the line can be increased if we end up 546 // objects horizontally. The total width of the line can be increased if we end up
541 // justifying text. 547 // justifying text.
542 switch (simplifiedTextAlign(textAlign, rootInlineBox)) { 548 switch (textAlign) {
543 case LEFT: 549 case LEFT:
550 case WEBKIT_LEFT:
544 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); 551 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
545 break; 552 break;
546 case RIGHT: 553 case RIGHT:
554 case WEBKIT_RIGHT:
547 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirection() , trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); 555 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirection() , trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
548 break; 556 break;
549 case CENTER: 557 case CENTER:
558 case WEBKIT_CENTER:
550 updateLogicalWidthForCenterAlignedBlock(style()->isLeftToRightDirection( ), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth); 559 updateLogicalWidthForCenterAlignedBlock(style()->isLeftToRightDirection( ), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
551 break; 560 break;
552 case JUSTIFY: 561 case JUSTIFY:
553 adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, availableLogicalWidth); 562 adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, availableLogicalWidth);
554 if (expansionOpportunityCount) { 563 if (expansionOpportunityCount) {
555 if (trailingSpaceRun) { 564 if (trailingSpaceRun) {
556 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth(); 565 totalLogicalWidth -= trailingSpaceRun->m_box->logicalWidth();
557 trailingSpaceRun->m_box->setLogicalWidth(0); 566 trailingSpaceRun->m_box->setLogicalWidth(0);
558 } 567 }
559 } else { 568 break;
560 ETextAlign adjustedTextAlign = style()->isLeftToRightDirection() ? L EFT : RIGHT;
561 updateLogicalWidthForAlignment(adjustedTextAlign, rootInlineBox, tra ilingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionO pportunityCount);
562 } 569 }
570 // Fall through
571 case TASTART:
572 if (direction == LTR)
573 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirectio n(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
574 else
575 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirecti on(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
563 break; 576 break;
564 default: 577 case TAEND:
565 ASSERT_NOT_REACHED(); 578 if (direction == LTR)
579 updateLogicalWidthForRightAlignedBlock(style()->isLeftToRightDirecti on(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
580 else
581 updateLogicalWidthForLeftAlignedBlock(style()->isLeftToRightDirectio n(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
566 break; 582 break;
567 } 583 }
568 } 584 }
569 585
570 static void updateLogicalInlinePositions(RenderBlockFlow* block, float& lineLogi calLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight) 586 static void updateLogicalInlinePositions(RenderBlockFlow* block, float& lineLogi calLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine, IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight)
571 { 587 {
572 LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedRenderer(first Line, boxLogicalHeight); 588 LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedRenderer(first Line, boxLogicalHeight);
573 lineLogicalLeft = block->logicalLeftOffsetForLine(block->logicalHeight(), sh ouldIndentText == IndentText, lineLogicalHeight); 589 lineLogicalLeft = block->logicalLeftOffsetForLine(block->logicalHeight(), sh ouldIndentText == IndentText, lineLogicalHeight);
574 // FIXME: This shouldn't be pixel snapped once multicolumn layout has been u pdated to correctly carry over subpixel values. 590 // FIXME: This shouldn't be pixel snapped once multicolumn layout has been u pdated to correctly carry over subpixel values.
575 // https://bugs.webkit.org/show_bug.cgi?id=105461 591 // https://bugs.webkit.org/show_bug.cgi?id=105461
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); 2450 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
2435 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; 2451 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft;
2436 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2452 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2437 2453
2438 if (!style()->isLeftToRightDirection()) 2454 if (!style()->isLeftToRightDirection())
2439 return logicalWidth() - logicalLeft; 2455 return logicalWidth() - logicalLeft;
2440 return logicalLeft; 2456 return logicalLeft;
2441 } 2457 }
2442 2458
2443 } 2459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698