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

Unified Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 385583005: For flex items, percent paddings should resolve against their respective dimension Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderThemeChromiumSkia.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBoxModelObject.cpp
diff --git a/Source/core/rendering/RenderBoxModelObject.cpp b/Source/core/rendering/RenderBoxModelObject.cpp
index 52e24c03bb01037583c82081dd5eea85cb4f9bb0..a702ae99aef40f3636421fcfd90c521a45f74186 100644
--- a/Source/core/rendering/RenderBoxModelObject.cpp
+++ b/Source/core/rendering/RenderBoxModelObject.cpp
@@ -310,11 +310,19 @@ int RenderBoxModelObject::pixelSnappedOffsetHeight() const
return snapSizeToPixel(offsetHeight(), offsetTop());
}
-LayoutUnit RenderBoxModelObject::computedCSSPadding(const Length& padding) const
+LayoutUnit RenderBoxModelObject::computedCSSPadding(const Length& padding, PaddingType type) const
{
LayoutUnit w = 0;
- if (padding.isPercent())
- w = containingBlockLogicalWidthForContent();
+ if (padding.isPercent()) {
+ if (containingBlock()->isFlexibleBox() && RuntimeEnabledFeatures::verticalPaddingEnabled()) {
+ if (type == TopPadding || type == BottomPadding || type == BeforePadding || type == AfterPadding)
+ w = isHorizontalWritingMode() ? containingBlockLogicalHeightForPadding() : containingBlockLogicalWidthForContent();
+ else
+ w = isHorizontalWritingMode() ? containingBlockLogicalWidthForContent() : containingBlockLogicalHeightForPadding();
+ } else {
+ w = containingBlockLogicalWidthForContent();
+ }
+ }
return minimumValueForLength(padding, w);
}
@@ -2507,6 +2515,47 @@ LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const
return containingBlock()->availableLogicalWidth();
}
+LayoutUnit RenderBoxModelObject::containingBlockLogicalHeightForPadding() const
+{
+ switch (containingBlock()->style()->logicalHeight().type()) {
+ case Auto:
+ case MinContent:
+ case MaxContent:
+ case FitContent:
+ case FillAvailable:
+ return 0;
+ case Fixed:
+ case Calculated:
+ return containingBlock()->style()->logicalHeight().value();
+ case Percent:
+ return computePercentLogicalHeightForPadding(containingBlock());
+ default:
tony 2014/07/16 16:57:23 One of the reasons to use a switch statement is so
harpreet.sk 2014/07/17 14:36:53 Done.
+ return 0;
+ }
+}
+
+LayoutUnit RenderBoxModelObject::computePercentLogicalHeightForPadding(RenderBlock* block) const
+{
+ ASSERT(block->style()->logicalHeight().isPercent());
+
+ float percentHeightFactor = block->style()->logicalHeight().value() / 100;
+ RenderBlock* cb = block->containingBlock();
+ while (cb) {
+ if (cb->style()->logicalHeight().isIntrinsicOrAuto())
+ return 0;
+ if (!block->skipContainingBlockForPercentHeightCalculation(cb) && (cb->style()->logicalHeight().isFixed() || cb->style()->logicalHeight().isCalculated()))
+ break;
+ if (cb->style()->logicalHeight().isPercent())
+ percentHeightFactor *= cb->style()->logicalHeight().value() / 100;
+ cb = cb->containingBlock();
+ }
+
+ if (cb)
+ return percentHeightFactor * cb->style()->logicalHeight().value();
+
+ return 0;
+}
+
RenderBoxModelObject* RenderBoxModelObject::continuation() const
{
if (!continuationMap)
« no previous file with comments | « Source/core/rendering/RenderBoxModelObject.h ('k') | Source/core/rendering/RenderThemeChromiumSkia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698