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

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

Issue 1007623003: Fix incorrect percentage top for positioned elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: New approach by adding a more simple api to get containingBlock's height Created 5 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) 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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 // We need to see if margins on either the start side or the end side can co ntain the floats in question. If they can, 1514 // We need to see if margins on either the start side or the end side can co ntain the floats in question. If they can,
1515 // then just using the line width is inaccurate. In the case where a float c ompletely fits, we don't need to use the line 1515 // then just using the line width is inaccurate. In the case where a float c ompletely fits, we don't need to use the line
1516 // offset at all, but can instead push all the way to the content edge of th e containing block. In the case where the float 1516 // offset at all, but can instead push all the way to the content edge of th e containing block. In the case where the float
1517 // doesn't fit, we can use the line offset, but we need to grow it by the ma rgin to reflect the fact that the margin was 1517 // doesn't fit, we can use the line offset, but we need to grow it by the ma rgin to reflect the fact that the margin was
1518 // "consumed" by the float. Negative margins aren't consumed by the float, a nd so we ignore them. 1518 // "consumed" by the float. Negative margins aren't consumed by the float, a nd so we ignore them.
1519 width += portionOfMarginNotConsumedByFloat(childMarginStart, startOffsetForC ontent, startOffsetForLine); 1519 width += portionOfMarginNotConsumedByFloat(childMarginStart, startOffsetForC ontent, startOffsetForLine);
1520 width += portionOfMarginNotConsumedByFloat(childMarginEnd, endOffsetForConte nt, endOffsetForLine); 1520 width += portionOfMarginNotConsumedByFloat(childMarginEnd, endOffsetForConte nt, endOffsetForLine);
1521 return width; 1521 return width;
1522 } 1522 }
1523 1523
1524 LayoutUnit LayoutBox::containingBlockLogicalHeight() const
1525 {
1526 if (hasOverrideContainingBlockLogicalHeight())
1527 return overrideContainingBlockContentLogicalHeight();
1528
1529 // http://www.w3.org/TR/CSS21/visudet.html#containing-block-details
mstensho (USE GERRIT) 2015/03/26 12:53:37 Better omit this text. This is not completely spec
changseok 2015/03/30 07:17:57 Good point. containingBlock never return inline bl
changseok 2015/03/30 18:03:34 Well. we don't need to create a new api. container
1530 LayoutBlock* cb = containingBlock();
1531 LayoutUnit height = cb->isPositioned() ? containingBlockLogicalHeightForPosi tioned(cb) : cb->clientLogicalHeight();
1532 if (styleRef().position() != AbsolutePosition)
1533 height -= cb->paddingLogicalHeight();
1534 return height;
1535 }
1536
1524 LayoutUnit LayoutBox::containingBlockLogicalWidthForContent() const 1537 LayoutUnit LayoutBox::containingBlockLogicalWidthForContent() const
1525 { 1538 {
1526 if (hasOverrideContainingBlockLogicalWidth()) 1539 if (hasOverrideContainingBlockLogicalWidth())
1527 return overrideContainingBlockContentLogicalWidth(); 1540 return overrideContainingBlockContentLogicalWidth();
1528 1541
1529 LayoutBlock* cb = containingBlock(); 1542 LayoutBlock* cb = containingBlock();
1530 return cb->availableLogicalWidth(); 1543 return cb->availableLogicalWidth();
1531 } 1544 }
1532 1545
1533 LayoutUnit LayoutBox::containingBlockLogicalHeightForContent(AvailableLogicalHei ghtType heightType) const 1546 LayoutUnit LayoutBox::containingBlockLogicalHeightForContent(AvailableLogicalHei ghtType heightType) const
(...skipping 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4641 computedValues.m_margins.m_end = marginEnd(); 4654 computedValues.m_margins.m_end = marginEnd();
4642 4655
4643 setLogicalTop(oldLogicalTop); 4656 setLogicalTop(oldLogicalTop);
4644 setLogicalWidth(oldLogicalWidth); 4657 setLogicalWidth(oldLogicalWidth);
4645 setLogicalLeft(oldLogicalLeft); 4658 setLogicalLeft(oldLogicalLeft);
4646 setMarginLeft(oldMarginLeft); 4659 setMarginLeft(oldMarginLeft);
4647 setMarginRight(oldMarginRight); 4660 setMarginRight(oldMarginRight);
4648 } 4661 }
4649 4662
4650 } // namespace blink 4663 } // namespace blink
OLDNEW
« Source/core/layout/LayoutBox.h ('K') | « Source/core/layout/LayoutBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698