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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc

Issue 2679343004: Add left_offset to NGFloatingObject and set it on legacy FloatingObject (Closed)
Patch Set: fix comments Created 3 years, 10 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ng/ng_block_layout_algorithm.h" 5 #include "core/layout/ng/ng_block_layout_algorithm.h"
6 6
7 #include "core/dom/NodeComputedStyle.h" 7 #include "core/dom/NodeComputedStyle.h"
8 #include "core/dom/TagCollection.h" 8 #include "core/dom/TagCollection.h"
9 #include "core/layout/ng/layout_ng_block_flow.h" 9 #include "core/layout/ng/layout_ng_block_flow.h"
10 #include "core/layout/ng/ng_block_node.h" 10 #include "core/layout/ng/ng_block_node.h"
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 ASSERT_EQ(1UL, frag->Children().size()); 806 ASSERT_EQ(1UL, frag->Children().size());
807 807
808 const NGPhysicalFragment* child = frag->Children()[0].get(); 808 const NGPhysicalFragment* child = frag->Children()[0].get();
809 EXPECT_EQ(LayoutUnit(kChildWidth), child->Width()); 809 EXPECT_EQ(LayoutUnit(kChildWidth), child->Width());
810 EXPECT_EQ(LayoutUnit(kPaddingLeft + 10), child->LeftOffset()); 810 EXPECT_EQ(LayoutUnit(kPaddingLeft + 10), child->LeftOffset());
811 EXPECT_EQ(LayoutUnit(0), child->TopOffset()); 811 EXPECT_EQ(LayoutUnit(0), child->TopOffset());
812 } 812 }
813 813
814 // Verifies that floats can be correctly positioned if they are inside of nested 814 // Verifies that floats can be correctly positioned if they are inside of nested
815 // empty blocks. 815 // empty blocks.
816 // TODO(glebl): Enable with new the float/margins collapsing algorithm. 816 TEST_F(NGBlockLayoutAlgorithmTest, PositionFloatInsideEmptyBlocks) {
817 TEST_F(NGBlockLayoutAlgorithmTest, DISABLED_PositionFloatInsideEmptyBlocks) {
818 setBodyInnerHTML( 817 setBodyInnerHTML(
819 "<!DOCTYPE html>" 818 "<!DOCTYPE html>"
820 "<style>" 819 "<style>"
821 " #container {" 820 " #container {"
822 " height: 200px;" 821 " height: 200px;"
823 " width: 200px;" 822 " width: 200px;"
824 " }" 823 " }"
825 " #empty1 {" 824 " #empty1 {"
826 " margin: 20px;" 825 " margin: 20px;"
827 " padding: 0 20px;" 826 " padding: 0 20px;"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 ASSERT_EQ(empty1_fragment->Children().size(), 1UL); 871 ASSERT_EQ(empty1_fragment->Children().size(), 1UL);
873 872
874 auto* empty2_fragment = 873 auto* empty2_fragment =
875 toNGPhysicalBoxFragment(empty1_fragment->Children()[0].get()); 874 toNGPhysicalBoxFragment(empty1_fragment->Children()[0].get());
876 // 0, vertical margins got collapsed 875 // 0, vertical margins got collapsed
877 EXPECT_THAT(LayoutUnit(), empty2_fragment->TopOffset()); 876 EXPECT_THAT(LayoutUnit(), empty2_fragment->TopOffset());
878 // 35 = empty1's padding(20) + empty2's padding(15) 877 // 35 = empty1's padding(20) + empty2's padding(15)
879 int empty2_inline_offset = 35; 878 int empty2_inline_offset = 35;
880 EXPECT_THAT(LayoutUnit(empty2_inline_offset), empty2_fragment->LeftOffset()); 879 EXPECT_THAT(LayoutUnit(empty2_inline_offset), empty2_fragment->LeftOffset());
881 880
882 ASSERT_EQ(1UL, body_fragment->PositionedFloats().size()); 881 ASSERT_EQ(1UL, container_fragment->PositionedFloats().size());
883 auto float_fragment = body_fragment->PositionedFloats().at(0)->fragment; 882 auto float_fragment = container_fragment->PositionedFloats().at(0)->fragment;
884 // 10 = float's padding 883 // 10 = float's padding
885 EXPECT_THAT(LayoutUnit(10), float_fragment->TopOffset()); 884 EXPECT_THAT(LayoutUnit(10), float_fragment->TopOffset());
886 // 25 = empty2's padding(15) + float's padding(10) 885 // 25 = empty2's padding(15) + float's padding(10)
887 int float_inline_offset = 25; 886 int float_inline_offset = 25;
888 EXPECT_THAT(float_fragment->LeftOffset(), LayoutUnit(float_inline_offset)); 887 EXPECT_THAT(float_fragment->LeftOffset(), LayoutUnit(float_inline_offset));
889 888
890 // ** Verify layout tree ** 889 // ** Verify layout tree **
891 Element* left_float = document().getElementById("float"); 890 Element* left_float = document().getElementById("float");
892 // 88 = body's margin(8) + 891 // 88 = body's margin(8) +
893 // empty1's padding and margin + empty2's padding and margins + float's 892 // empty1's padding and margin + empty2's padding and margins + float's
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 EXPECT_EQ(LayoutUnit(194), fragment->LeftOffset()); 2001 EXPECT_EQ(LayoutUnit(194), fragment->LeftOffset());
2003 EXPECT_EQ(LayoutUnit(), fragment->TopOffset()); 2002 EXPECT_EQ(LayoutUnit(), fragment->TopOffset());
2004 EXPECT_EQ(LayoutUnit(16), fragment->Width()); 2003 EXPECT_EQ(LayoutUnit(16), fragment->Width());
2005 EXPECT_EQ(LayoutUnit(50), fragment->Height()); 2004 EXPECT_EQ(LayoutUnit(50), fragment->Height());
2006 EXPECT_EQ(0UL, fragment->Children().size()); 2005 EXPECT_EQ(0UL, fragment->Children().size());
2007 EXPECT_FALSE(iterator.NextChild()); 2006 EXPECT_FALSE(iterator.NextChild());
2008 } 2007 }
2009 2008
2010 } // namespace 2009 } // namespace
2011 } // namespace blink 2010 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698