Index: third_party/WebKit/Source/core/layout/ng/inline/ng_baseline.cc |
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_baseline.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_baseline.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b85f3730897b5cdfc28924ab5d0868b5bd0d5b52 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_baseline.cc |
@@ -0,0 +1,42 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "core/layout/ng/inline/ng_baseline.h" |
+ |
+#include "core/layout/LayoutBlock.h" |
+#include "core/layout/ng/ng_block_node.h" |
+#include "core/layout/ng/ng_layout_input_node.h" |
+ |
+namespace blink { |
+ |
+bool NGBaseline::ShouldPropagateBaselines(const NGLayoutInputNode node) { |
+ if (node.IsInline()) |
+ return true; |
+ |
+ return ShouldPropagateBaselines(ToLayoutBox(node.GetLayoutObject())); |
+} |
+ |
+bool NGBaseline::ShouldPropagateBaselines(LayoutBox* layout_box) { |
+ // Test if this node should use its own box to synthesize the baseline. |
+ if (!layout_box->IsLayoutBlock() || |
+ layout_box->IsFloatingOrOutOfFlowPositioned() || |
+ layout_box->IsWritingModeRoot()) |
+ return false; |
+ |
+ // If this node is LayoutBlock that uses old layout, this may be a subclass |
+ // that overrides baseline functions. Propagate baseline requests so that we |
+ // call virtual functions. |
+ if (!NGBlockNode(layout_box).CanUseNewLayout()) |
+ return true; |
+ |
+ // CSS defines certain cases to synthesize baselines from box. See comments in |
+ // UseLogicalBottomMarginEdgeForInlineBlockBaseline(). |
+ const LayoutBlock* layout_block = ToLayoutBlock(layout_box); |
+ if (layout_block->UseLogicalBottomMarginEdgeForInlineBlockBaseline()) |
+ return false; |
+ |
+ return true; |
+} |
+ |
+} // namespace blink |