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

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: WIP Patch 3 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
Index: Source/core/rendering/RenderBoxModelObject.cpp
diff --git a/Source/core/rendering/RenderBoxModelObject.cpp b/Source/core/rendering/RenderBoxModelObject.cpp
index bcc69eaf063c4a50529ed50bbbfba50060a1a197..320f0e2975b271212243cdb58fb4bf2ed45eb7bf 100644
--- a/Source/core/rendering/RenderBoxModelObject.cpp
+++ b/Source/core/rendering/RenderBoxModelObject.cpp
@@ -310,11 +310,15 @@ 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() && (type == TopPadding || type == BottomPadding || type == BeforePadding || type == AfterPadding))
ojan 2014/07/15 20:33:25 This isn't correct for vertical writing mode. TopP
harpreet.sk 2014/07/16 15:43:02 Done.
+ w = containingBlockLogicalHeightForContent();
+ else
+ w = containingBlockLogicalWidthForContent();
+ }
return minimumValueForLength(padding, w);
}
@@ -2507,6 +2511,36 @@ LayoutUnit RenderBoxModelObject::containingBlockLogicalWidthForContent() const
return containingBlock()->availableLogicalWidth();
}
+LayoutUnit RenderBoxModelObject::containingBlockLogicalHeightForContent() const
leviw_travelin_and_unemployed 2014/07/15 20:08:29 This is different than RenderBox::containingBlockL
harpreet.sk 2014/07/16 15:43:01 Renamed.
+{
+ if (containingBlock()->style()->logicalHeight().isIntrinsicOrAuto())
+ return 0;
+
+ if (containingBlock()->style()->logicalHeight().isPercent())
+ return containingBlock()->computePercentLogicalHeight();
+
+ return containingBlock()->style()->logicalHeight().value();
ojan 2014/07/15 20:33:25 Please ASSERT(containingBlock()->style()->logicalH
harpreet.sk 2014/07/16 15:43:01 Replaced if's with switch
+}
+
+LayoutUnit RenderBoxModelObject::computePercentLogicalHeight() const
ojan 2014/07/15 20:33:25 This also is duplicating a method on RenderBox but
harpreet.sk 2014/07/16 15:43:01 Renamed the function. The reason why i am not usin
+{
+ float percentHeightFactor = style()->logicalHeight().value() / 100;
ojan 2014/07/15 20:33:25 ASSERT(style()->logicalHeight().isPercent());
harpreet.sk 2014/07/16 15:43:01 Done.
+ RenderBlock* cb = containingBlock();
+ while (cb) {
+ if (cb->style()->logicalHeight().isIntrinsicOrAuto())
+ return 0;
+ if (cb->style()->logicalHeight().isFixed() || cb->style()->logicalHeight().isCalculated())
ojan 2014/07/15 20:33:25 This should use skipContainingBlockForPercentHeigh
harpreet.sk 2014/07/16 15:43:01 Done.
+ break;
+ 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)

Powered by Google App Engine
This is Rietveld 408576698