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

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc

Issue 2325073002: [LayoutNG] Handle border and padding when sizing a block and when placing its children. (Closed)
Patch Set: Use modern CSS terms, rather than old XSL terms, for box sides Created 4 years, 3 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 | « third_party/WebKit/Source/core/layout/ng/ng_length_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc b/third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc
index f01a9e9353c377e4ddb5b572c52ba2769d9ac944..93697ed744405fb978dc6e882394fc106a443f42 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_length_utils.cc
@@ -78,7 +78,8 @@ LayoutUnit computeInlineSizeForFragment(
extent = std::max(extent, min);
if (style.boxSizing() == BoxSizingContentBox) {
- // TODO(layout-ng): Compute border/padding size and add it
+ extent += computeBorderAndPaddingInlineStart(constraintSpace, style);
+ extent += computeBorderAndPaddingInlineEnd(constraintSpace, style);
}
return extent;
@@ -110,12 +111,53 @@ LayoutUnit computeBlockSizeForFragment(const NGConstraintSpace& constraintSpace,
extent = std::max(extent, min);
if (style.boxSizing() == BoxSizingContentBox) {
- // TODO(layout-ng): Compute border/padding size and add it
+ extent += computeBorderAndPaddingBlockStart(constraintSpace, style);
+ extent += computeBorderAndPaddingBlockEnd(constraintSpace, style);
}
return extent;
}
+LayoutUnit computeBorderAndPaddingBlockStart(
+ const NGConstraintSpace& constraintSpace,
+ const ComputedStyle& style) {
+ // Percentages on block-direction padding are resolved against the containing
+ // block *inline size* - hence the call to resolveInlineLength().
+ LayoutUnit padding =
+ resolveInlineLength(constraintSpace, style.paddingBefore(),
+ LengthResolveType::MarginBorderPaddingSize);
+ return padding + LayoutUnit(style.borderBeforeWidth());
+}
+
+LayoutUnit computeBorderAndPaddingBlockEnd(
+ const NGConstraintSpace& constraintSpace,
+ const ComputedStyle& style) {
+ // Percentages on block-direction padding are resolved against the containing
+ // block *inline size* - hence the call to resolveInlineLength().
+ LayoutUnit padding =
+ resolveInlineLength(constraintSpace, style.paddingAfter(),
+ LengthResolveType::MarginBorderPaddingSize);
+ return padding + LayoutUnit(style.borderAfterWidth());
+}
+
+LayoutUnit computeBorderAndPaddingInlineStart(
+ const NGConstraintSpace& constraintSpace,
+ const ComputedStyle& style) {
+ LayoutUnit padding =
+ resolveInlineLength(constraintSpace, style.paddingStart(),
+ LengthResolveType::MarginBorderPaddingSize);
+ return padding + LayoutUnit(style.borderStartWidth());
+}
+
+LayoutUnit computeBorderAndPaddingInlineEnd(
+ const NGConstraintSpace& constraintSpace,
+ const ComputedStyle& style) {
+ LayoutUnit padding =
+ resolveInlineLength(constraintSpace, style.paddingEnd(),
+ LengthResolveType::MarginBorderPaddingSize);
+ return padding + LayoutUnit(style.borderEndWidth());
+}
+
NGBoxStrut computeMargins(const NGConstraintSpace& constraintSpace,
const ComputedStyle& style) {
// Margins always get computed relative to the inline size:
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_length_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698