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

Side by Side Diff: Source/core/rendering/RenderBoxModelObject.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: Rebased patch against master 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
« no previous file with comments | « Source/core/rendering/RenderBox.cpp ('k') | Source/core/rendering/RenderObject.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) 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 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. 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 2610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2621 // However, as soon as some content is entered, the line boxes will be 2621 // However, as soon as some content is entered, the line boxes will be
2622 // constructed and this kludge is not called any more. So only the caret siz e 2622 // constructed and this kludge is not called any more. So only the caret siz e
2623 // of an empty :first-line'd block is wrong. I think we can live with that. 2623 // of an empty :first-line'd block is wrong. I think we can live with that.
2624 RenderStyle* currentStyle = firstLineStyle(); 2624 RenderStyle* currentStyle = firstLineStyle();
2625 LayoutUnit height = lineHeight(true, currentStyle->isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); 2625 LayoutUnit height = lineHeight(true, currentStyle->isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
2626 2626
2627 enum CaretAlignment { alignLeft, alignRight, alignCenter }; 2627 enum CaretAlignment { alignLeft, alignRight, alignCenter };
2628 2628
2629 CaretAlignment alignment = alignLeft; 2629 CaretAlignment alignment = alignLeft;
2630 2630
2631 switch (currentStyle->textAlign()) { 2631 switch (simplifiedTextAlign(currentStyle->textAlign())) {
2632 case LEFT: 2632 case LEFT:
2633 case WEBKIT_LEFT:
2634 break; 2633 break;
2635 case CENTER: 2634 case CENTER:
2636 case WEBKIT_CENTER:
2637 alignment = alignCenter; 2635 alignment = alignCenter;
2638 break; 2636 break;
2639 case RIGHT: 2637 case RIGHT:
2640 case WEBKIT_RIGHT:
2641 alignment = alignRight; 2638 alignment = alignRight;
2642 break; 2639 break;
2643 case JUSTIFY: 2640 case JUSTIFY:
2644 case TASTART:
2645 if (!currentStyle->isLeftToRightDirection()) 2641 if (!currentStyle->isLeftToRightDirection())
2646 alignment = alignRight; 2642 alignment = alignRight;
2647 break; 2643 break;
2648 case TAEND: 2644 default:
2649 if (currentStyle->isLeftToRightDirection()) 2645 ASSERT_NOT_REACHED();
2650 alignment = alignRight;
2651 break; 2646 break;
2652 } 2647 }
2653 2648
2654 LayoutUnit x = borderLeft() + paddingLeft(); 2649 LayoutUnit x = borderLeft() + paddingLeft();
2655 LayoutUnit maxX = width - borderRight() - paddingRight(); 2650 LayoutUnit maxX = width - borderRight() - paddingRight();
2656 2651
2657 switch (alignment) { 2652 switch (alignment) {
2658 case alignLeft: 2653 case alignLeft:
2659 if (currentStyle->isLeftToRightDirection()) 2654 if (currentStyle->isLeftToRightDirection())
2660 x += textIndentOffset; 2655 x += textIndentOffset;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2791 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2797 for (RenderObject* child = startChild; child && child != endChild; ) { 2792 for (RenderObject* child = startChild; child && child != endChild; ) {
2798 // Save our next sibling as moveChildTo will clear it. 2793 // Save our next sibling as moveChildTo will clear it.
2799 RenderObject* nextSibling = child->nextSibling(); 2794 RenderObject* nextSibling = child->nextSibling();
2800 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2795 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2801 child = nextSibling; 2796 child = nextSibling;
2802 } 2797 }
2803 } 2798 }
2804 2799
2805 } // namespace WebCore 2800 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBox.cpp ('k') | Source/core/rendering/RenderObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698