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/RenderBox.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 3430 matching lines...) Expand 10 before | Expand all | Expand 10 after
3441 } 3441 }
3442 } 3442 }
3443 3443
3444 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const RenderBox* child, LayoutUnit logicalWidthValue, const RenderBoxModelObject* con tainerBlock, LayoutUnit containerLogicalWidth) 3444 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const RenderBox* child, LayoutUnit logicalWidthValue, const RenderBoxModelObject* con tainerBlock, LayoutUnit containerLogicalWidth)
3445 { 3445 {
3446 // Deal with differing writing modes here. Our offset needs to be in the co ntaining block's coordinate space. If the containing block is flipped 3446 // Deal with differing writing modes here. Our offset needs to be in the co ntaining block's coordinate space. If the containing block is flipped
3447 // along this axis, then we need to flip the coordinate. This can only happ en if the containing block is both a flipped mode and perpendicular to us. 3447 // along this axis, then we need to flip the coordinate. This can only happ en if the containing block is both a flipped mode and perpendicular to us.
3448 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM ode() && containerBlock->style()->isFlippedBlocksWritingMode()) { 3448 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM ode() && containerBlock->style()->isFlippedBlocksWritingMode()) {
3449 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft Pos; 3449 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft Pos;
3450 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo rderRight() : containerBlock->borderBottom()); 3450 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo rderRight() : containerBlock->borderBottom());
3451 } else 3451 } else if (child->isHorizontalWritingMode()) {
3452 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo rderLeft() : containerBlock->borderTop()); 3452 RenderStyle* blockStyle = containerBlock->style();
3453 bool containerBlockIsLTR = isLeftToRightDirection(blockStyle->direction( ));
3454 if (containerBlockIsLTR && containerBlock->simplifiedTextAlign(blockStyl e->textAlign()) == RIGHT) {
eae 2014/01/30 18:38:27 How about using a local variable to hold the conta
mario.prada 2014/02/04 14:30:13 Ok
3455 logicalLeftPos = containerLogicalWidth - (logicalWidthValue + child- >style()->logicalRight().value());
3456 logicalLeftPos += containerBlock->borderLogicalRight();
eae 2014/01/30 18:38:27 Shouldn't this be borderAndPaddingLogicalRight?
mario.prada 2014/02/04 14:30:13 I've thought the same and actually tried it, but t
3457 } else if (!containerBlockIsLTR && containerBlock->simplifiedTextAlign(b lockStyle->textAlign()) == LEFT) {
3458 logicalLeftPos += containerBlock->borderAndPaddingLogicalLeft() + lo gicalWidthValue;
3459 } else {
3460 logicalLeftPos += containerBlock->borderLeft();
3461 }
3462 } else {
3463 logicalLeftPos += containerBlock->borderTop();
3464 }
3453 } 3465 }
3454 3466
3455 void RenderBox::shrinkToFitWidth(const LayoutUnit availableSpace, const LayoutUn it logicalLeftValue, const LayoutUnit bordersPlusPadding, LogicalExtentComputedV alues& computedValues) const 3467 void RenderBox::shrinkToFitWidth(const LayoutUnit availableSpace, const LayoutUn it logicalLeftValue, const LayoutUnit bordersPlusPadding, LogicalExtentComputedV alues& computedValues) const
3456 { 3468 {
3457 // FIXME: would it be better to have shrink-to-fit in one step? 3469 // FIXME: would it be better to have shrink-to-fit in one step?
3458 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlusPadding; 3470 LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlusPadding;
3459 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersPlusPaddi ng; 3471 LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersPlusPaddi ng;
3460 LayoutUnit availableWidth = availableSpace - logicalLeftValue; 3472 LayoutUnit availableWidth = availableSpace - logicalLeftValue;
3461 computedValues.m_extent = min(max(preferredMinWidth, availableWidth), prefer redWidth); 3473 computedValues.m_extent = min(max(preferredMinWidth, availableWidth), prefer redWidth);
3462 } 3474 }
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
4911 return 0; 4923 return 0;
4912 4924
4913 if (!layoutState && !flowThreadContainingBlock()) 4925 if (!layoutState && !flowThreadContainingBlock())
4914 return 0; 4926 return 0;
4915 4927
4916 RenderBlock* containerBlock = containingBlock(); 4928 RenderBlock* containerBlock = containingBlock();
4917 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); 4929 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop();
4918 } 4930 }
4919 4931
4920 } // namespace WebCore 4932 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698