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

Side by Side Diff: Source/core/layout/LayoutBox.cpp

Issue 1043643002: Switch line layout to LayoutUnit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaseline Created 5 years, 7 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 | Annotate | Revision Log
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 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 void LayoutBox::positionLineBox(InlineBox* box) 1726 void LayoutBox::positionLineBox(InlineBox* box)
1727 { 1727 {
1728 if (isOutOfFlowPositioned()) { 1728 if (isOutOfFlowPositioned()) {
1729 // Cache the x position only if we were an INLINE type originally. 1729 // Cache the x position only if we were an INLINE type originally.
1730 bool originallyInline = style()->isOriginalDisplayInlineType(); 1730 bool originallyInline = style()->isOriginalDisplayInlineType();
1731 if (originallyInline) { 1731 if (originallyInline) {
1732 // The value is cached in the xPos of the box. We only need this va lue if 1732 // The value is cached in the xPos of the box. We only need this va lue if
1733 // our object was inline originally, since otherwise it would have e nded up underneath 1733 // our object was inline originally, since otherwise it would have e nded up underneath
1734 // the inlines. 1734 // the inlines.
1735 RootInlineBox& root = box->root(); 1735 RootInlineBox& root = box->root();
1736 root.block().setStaticInlinePositionForChild(*this, LayoutUnit::from FloatRound(box->logicalLeft())); 1736 root.block().setStaticInlinePositionForChild(*this, box->logicalLeft ());
1737 } else { 1737 } else {
1738 // Our object was a block originally, so we make our normal flow pos ition be 1738 // Our object was a block originally, so we make our normal flow pos ition be
1739 // just below the line box (as though all the inlines that came befo re us got 1739 // just below the line box (as though all the inlines that came befo re us got
1740 // wrapped in an anonymous block, which is what would have happened had we been 1740 // wrapped in an anonymous block, which is what would have happened had we been
1741 // in flow). This value was cached in the y() of the box. 1741 // in flow). This value was cached in the y() of the box.
1742 layer()->setStaticBlockPosition(box->logicalTop()); 1742 layer()->setStaticBlockPosition(box->logicalTop());
1743 } 1743 }
1744 1744
1745 if (container()->isLayoutInline()) 1745 if (container()->isLayoutInline())
1746 moveWithEdgeOfInlineContainerIfNecessary(box->isHorizontal()); 1746 moveWithEdgeOfInlineContainerIfNecessary(box->isHorizontal());
1747 1747
1748 // Nuke the box. 1748 // Nuke the box.
1749 box->remove(DontMarkLineBoxes); 1749 box->remove(DontMarkLineBoxes);
1750 box->destroy(); 1750 box->destroy();
1751 } else if (isReplaced()) { 1751 } else if (isReplaced()) {
1752 // FIXME: the call to roundedLayoutPoint() below is temporary and should be removed once 1752 // FIXME: the call to roundedLayoutPoint() below is temporary and should be removed once
1753 // the transition to LayoutUnit-based types is complete (crbug.com/32123 7) 1753 // the transition to LayoutUnit-based types is complete (crbug.com/32123 7)
1754 setLocationAndUpdateOverflowControlsIfNeeded(box->topLeft().roundedLayou tPoint()); 1754 setLocationAndUpdateOverflowControlsIfNeeded(box->topLeft());
1755 setInlineBoxWrapper(box); 1755 setInlineBoxWrapper(box);
1756 } 1756 }
1757 } 1757 }
1758 1758
1759 void LayoutBox::moveWithEdgeOfInlineContainerIfNecessary(bool isHorizontal) 1759 void LayoutBox::moveWithEdgeOfInlineContainerIfNecessary(bool isHorizontal)
1760 { 1760 {
1761 ASSERT(isOutOfFlowPositioned() && container()->isLayoutInline() && container ()->isRelPositioned()); 1761 ASSERT(isOutOfFlowPositioned() && container()->isLayoutInline() && container ()->isRelPositioned());
1762 // If this object is inside a relative positioned inline and its inline posi tion is an explicit offset from the edge of its container 1762 // If this object is inside a relative positioned inline and its inline posi tion is an explicit offset from the edge of its container
1763 // then it will need to move if its inline container has changed width. We d o not track if the width has changed 1763 // then it will need to move if its inline container has changed width. We d o not track if the width has changed
1764 // but if we are here then we are laying out lines inside it, so it probably has - mark our object for layout so that it can 1764 // but if we are here then we are laying out lines inside it, so it probably has - mark our object for layout so that it can
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
3795 computedValues.m_position = logicalTopPos; 3795 computedValues.m_position = logicalTopPos;
3796 } 3796 }
3797 3797
3798 LayoutRect LayoutBox::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit * extraWidthToEndOfLine) 3798 LayoutRect LayoutBox::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit * extraWidthToEndOfLine)
3799 { 3799 {
3800 // VisiblePositions at offsets inside containers either a) refer to the posi tions before/after 3800 // VisiblePositions at offsets inside containers either a) refer to the posi tions before/after
3801 // those containers (tables and select elements) or b) refer to the position inside an empty block. 3801 // those containers (tables and select elements) or b) refer to the position inside an empty block.
3802 // They never refer to children. 3802 // They never refer to children.
3803 // FIXME: Paint the carets inside empty blocks differently than the carets b efore/after elements. 3803 // FIXME: Paint the carets inside empty blocks differently than the carets b efore/after elements.
3804 3804
3805 LayoutRect rect(location(), LayoutSize(caretWidth, size().height())); 3805 LayoutRect rect(location(), LayoutSize(caretWidth(), size().height()));
3806 bool ltr = box ? box->isLeftToRightDirection() : style()->isLeftToRightDirec tion(); 3806 bool ltr = box ? box->isLeftToRightDirection() : style()->isLeftToRightDirec tion();
3807 3807
3808 if ((!caretOffset) ^ ltr) 3808 if ((!caretOffset) ^ ltr)
3809 rect.move(LayoutSize(size().width() - caretWidth, 0)); 3809 rect.move(LayoutSize(size().width() - caretWidth(), 0));
3810 3810
3811 if (box) { 3811 if (box) {
3812 RootInlineBox& rootBox = box->root(); 3812 RootInlineBox& rootBox = box->root();
3813 LayoutUnit top = rootBox.lineTop(); 3813 LayoutUnit top = rootBox.lineTop();
3814 rect.setY(top); 3814 rect.setY(top);
3815 rect.setHeight(rootBox.lineBottom() - top); 3815 rect.setHeight(rootBox.lineBottom() - top);
3816 } 3816 }
3817 3817
3818 // If height of box is smaller than font height, use the latter one, 3818 // If height of box is smaller than font height, use the latter one,
3819 // otherwise the caret might become invisible. 3819 // otherwise the caret might become invisible.
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
4796 bool LayoutBox::canRenderBorderImage() const 4796 bool LayoutBox::canRenderBorderImage() const
4797 { 4797 {
4798 if (!style()->hasBorder()) 4798 if (!style()->hasBorder())
4799 return false; 4799 return false;
4800 4800
4801 StyleImage* borderImage = style()->borderImage().image(); 4801 StyleImage* borderImage = style()->borderImage().image();
4802 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); 4802 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded();
4803 } 4803 }
4804 4804
4805 } // namespace blink 4805 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698