Changeset 158115 in webkit
- Timestamp:
- Oct 28, 2013 10:35:52 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r158113 r158115 1 2013-10-28 Sergio Villar Senin <svillar@igalia.com> 2 3 [CSS Grid Layout] Add support for order inside grid items 4 https://bugs.webkit.org/show_bug.cgi?id=123208 5 6 Reviewed by Antti Koivisto. 7 8 From Blink r153536 by <jchaffraix@chromium.org> 9 10 Added a couple of tests to verify that we respect the specified 11 order of grid items both in the auto-placement algorithm and in 12 the final painting. 13 14 * fast/css-grid-layout/grid-item-order-auto-flow-resolution-expected.txt: Added. 15 * fast/css-grid-layout/grid-item-order-auto-flow-resolution.html: Added. 16 * fast/css-grid-layout/grid-item-order-paint-order-expected.html: Added. 17 * fast/css-grid-layout/grid-item-order-paint-order.html: Added. 18 1 19 2013-10-28 Afonso R. Costa Jr. <afonso.costa@samsung.com> 2 20 -
trunk/Source/WebCore/CMakeLists.txt
r158018 r158115 2088 2088 rendering/LayoutState.cpp 2089 2089 rendering/LineWidth.cpp 2090 rendering/OrderIterator.cpp 2090 2091 rendering/PointerEventsHitRules.cpp 2091 2092 rendering/RenderArena.cpp -
trunk/Source/WebCore/ChangeLog
r158113 r158115 1 2013-10-28 Sergio Villar Senin <svillar@igalia.com> 2 3 [CSS Grid Layout] Add support for order inside grid items 4 https://bugs.webkit.org/show_bug.cgi?id=123208 5 6 Reviewed by Antti Koivisto. 7 8 Based on Blink r153457 and r153536 by <jchaffraix@chromium.org> 9 10 Added support for sorting grid items by using -webkit-order 11 property. Used OrderIterator to implement it so it had to be moved 12 out of RenderFlexibleBox to be shared with RenderGrid. 13 14 Tests: fast/css-grid-layout/grid-item-order-auto-flow-resolution.html 15 fast/css-grid-layout/grid-item-order-paint-order.html 16 17 * CMakeLists.txt: Added new file. 18 * GNUmakefile.list.am: Ditto. 19 * WebCore.vcxproj/WebCore.vcxproj: Ditto. 20 * WebCore.xcodeproj/project.pbxproj: Ditto. 21 * rendering/OrderIterator.cpp: Added. Ripped out of RenderFlexibleBox. 22 (WebCore::OrderIterator::OrderIterator): 23 (WebCore::OrderIterator::setOrderValues): Use std::move semantics. 24 (WebCore::OrderIterator::first): Use an integer as iterator. 25 (WebCore::OrderIterator::next): Ditto. 26 (WebCore::OrderIterator::reset): Ditto. 27 * rendering/OrderIterator.h: Added. 28 (WebCore::OrderIterator::currentChild): 29 * rendering/RenderFlexibleBox.cpp: 30 (WebCore::RenderFlexibleBox::RenderFlexibleBox): 31 (WebCore::RenderFlexibleBox::layoutBlock): 32 * rendering/RenderFlexibleBox.h: 33 * rendering/RenderGrid.cpp: 34 (WebCore::RenderGrid::RenderGrid): 35 (WebCore::RenderGrid::placeItemsOnGrid): 36 (WebCore::RenderGrid::populateExplicitGridAndOrderIterator): 37 (WebCore::RenderGrid::paintChildren): 38 * rendering/RenderGrid.h: 39 1 40 2013-10-28 Afonso R. Costa Jr. <afonso.costa@samsung.com> 2 41 -
trunk/Source/WebCore/GNUmakefile.list.am
r157950 r158115 4299 4299 Source/WebCore/rendering/LineWidth.cpp \ 4300 4300 Source/WebCore/rendering/OverlapTestRequestClient.h \ 4301 Source/WebCore/rendering/OrderIterator.cpp \ 4302 Source/WebCore/rendering/OrderIterator.h \ 4301 4303 Source/WebCore/rendering/Pagination.h \ 4302 4304 Source/WebCore/rendering/PaintInfo.h \ -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r157950 r158115 9540 9540 </ClCompile> 9541 9541 <ClCompile Include="..\rendering\LineWidth.cpp" /> 9542 <ClCompile Include="..\rendering\OrderIterator.cpp" /> 9542 9543 <ClCompile Include="..\rendering\PointerEventsHitRules.cpp"> 9543 9544 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> … … 19566 19567 <ClInclude Include="..\rendering\LineLayoutState.h" /> 19567 19568 <ClInclude Include="..\rendering\LineWidth.h" /> 19569 <ClInclude Include="..\rendering\OrderIterator.h" /> 19568 19570 <ClInclude Include="..\rendering\PaintInfo.h" /> 19569 19571 <ClInclude Include="..\rendering\PaintPhase.h" /> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r158096 r158115 5368 5368 CDE3A85717F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */; }; 5369 5369 CDE3A85817F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE3A85617F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h */; }; 5370 CDE7FC44181904B1002BBB77 /* OrderIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDE7FC42181904B1002BBB77 /* OrderIterator.cpp */; }; 5371 CDE7FC45181904B1002BBB77 /* OrderIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE7FC43181904B1002BBB77 /* OrderIterator.h */; }; 5370 5372 CDEA763014608A53008B31F1 /* PlatformClockCA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDEA762E146084DE008B31F1 /* PlatformClockCA.cpp */; }; 5371 5373 CDEA76341460B56F008B31F1 /* ClockGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDEA76321460AE29008B31F1 /* ClockGeneric.cpp */; }; … … 12338 12340 CDE3A85617F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioTrackPrivateAVFObjC.h; path = objc/AudioTrackPrivateAVFObjC.h; sourceTree = "<group>"; }; 12339 12341 CDE6560E17CA6E7600526BA7 /* mediaControlsApple.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = mediaControlsApple.js; sourceTree = "<group>"; }; 12342 CDE7FC42181904B1002BBB77 /* OrderIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OrderIterator.cpp; sourceTree = "<group>"; }; 12343 CDE7FC43181904B1002BBB77 /* OrderIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderIterator.h; sourceTree = "<group>"; }; 12340 12344 CDEA762C14608224008B31F1 /* Clock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Clock.h; sourceTree = "<group>"; }; 12341 12345 CDEA762E146084DE008B31F1 /* PlatformClockCA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformClockCA.cpp; sourceTree = "<group>"; }; … … 20543 20547 isa = PBXGroup; 20544 20548 children = ( 20549 CDE7FC42181904B1002BBB77 /* OrderIterator.cpp */, 20550 CDE7FC43181904B1002BBB77 /* OrderIterator.h */, 20545 20551 439046C212DA25CE00AF80A2 /* mathml */, 20546 20552 FD08A879175D3926002CD360 /* shapes */, … … 24753 24759 CD3E252418046BCD00E27F56 /* CSSGridTemplateValue.h in Headers */, 24754 24760 CDEF4FD717E85C8F00AEE24B /* GridLength.h in Headers */, 24761 CDE7FC45181904B1002BBB77 /* OrderIterator.h in Headers */, 24755 24762 ); 24756 24763 runOnlyForDeploymentPostprocessing = 0; … … 27784 27791 A0CB002417DF82660017896B /* LineWidth.cpp in Sources */, 27785 27792 CD3E252318046BCD00E27F56 /* CSSGridTemplateValue.cpp in Sources */, 27793 CDE7FC44181904B1002BBB77 /* OrderIterator.cpp in Sources */, 27786 27794 ); 27787 27795 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r158097 r158115 40 40 namespace WebCore { 41 41 42 RenderFlexibleBox::OrderIterator::OrderIterator(const RenderFlexibleBox* flexibleBox)43 : m_flexibleBox(flexibleBox)44 , m_currentChild(0)45 , m_orderValuesIterator(0)46 {47 }48 49 void RenderFlexibleBox::OrderIterator::setOrderValues(const OrderValues& orderValues)50 {51 reset();52 m_orderValues = orderValues;53 if (m_orderValues.size() < 2)54 return;55 56 std::sort(m_orderValues.begin(), m_orderValues.end());57 auto nextElement = std::unique(m_orderValues.begin(), m_orderValues.end());58 m_orderValues.shrinkCapacity(nextElement - m_orderValues.begin());59 }60 61 RenderBox* RenderFlexibleBox::OrderIterator::first()62 {63 reset();64 return next();65 }66 67 RenderBox* RenderFlexibleBox::OrderIterator::next()68 {69 do {70 if (!m_currentChild) {71 if (m_orderValuesIterator == m_orderValues.end())72 return 0;73 if (m_orderValuesIterator) {74 ++m_orderValuesIterator;75 if (m_orderValuesIterator == m_orderValues.end())76 return 0;77 } else78 m_orderValuesIterator = m_orderValues.begin();79 80 m_currentChild = m_flexibleBox->firstChildBox();81 } else82 m_currentChild = m_currentChild->nextSiblingBox();83 } while (!m_currentChild || m_currentChild->style()->order() != *m_orderValuesIterator);84 85 return m_currentChild;86 }87 88 void RenderFlexibleBox::OrderIterator::reset()89 {90 m_currentChild = 0;91 m_orderValuesIterator = 0;92 }93 94 42 struct RenderFlexibleBox::LineContext { 95 43 LineContext(LayoutUnit crossAxisOffset, LayoutUnit crossAxisExtent, size_t numberOfChildren, LayoutUnit maxAscent) … … 121 69 RenderFlexibleBox::RenderFlexibleBox(Element& element, PassRef<RenderStyle> style) 122 70 : RenderBlock(element, std::move(style), 0) 123 , m_orderIterator( this)71 , m_orderIterator(*this) 124 72 , m_numberOfInFlowChildrenOnFirstLine(-1) 125 73 { … … 129 77 RenderFlexibleBox::RenderFlexibleBox(Document& document, PassRef<RenderStyle> style) 130 78 : RenderBlock(document, std::move(style), 0) 131 , m_orderIterator( this)79 , m_orderIterator(*this) 132 80 , m_numberOfInFlowChildrenOnFirstLine(-1) 133 81 { … … 346 294 OrderIterator::OrderValues orderValues; 347 295 computeMainAxisPreferredSizes(orderValues); 348 m_orderIterator.setOrderValues( orderValues);296 m_orderIterator.setOrderValues(std::move(orderValues)); 349 297 350 298 ChildFrameRects oldChildRects; -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r158097 r158115 32 32 #define RenderFlexibleBox_h 33 33 34 #include "OrderIterator.h" 34 35 #include "RenderBlock.h" 35 36 … … 72 73 FlipForRowReverse, 73 74 NoFlipForRowReverse, 74 };75 76 class OrderIterator {77 WTF_MAKE_NONCOPYABLE(OrderIterator);78 public:79 typedef Vector<int, 1> OrderValues;80 81 OrderIterator(const RenderFlexibleBox*);82 void setOrderValues(const OrderValues&);83 RenderBox* currentChild() const { return m_currentChild; }84 RenderBox* first();85 RenderBox* next();86 void reset();87 88 private:89 const RenderFlexibleBox* m_flexibleBox;90 RenderBox* m_currentChild;91 OrderValues m_orderValues;92 Vector<int>::const_iterator m_orderValuesIterator;93 75 }; 94 76 -
trunk/Source/WebCore/rendering/RenderGrid.cpp
r158097 r158115 1 1 /* 2 2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Igalia S.L. 3 * Copyright (C) 2013 Igalia S.L. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 144 144 RenderGrid::RenderGrid(Element& element, PassRef<RenderStyle> style) 145 145 : RenderBlock(element, std::move(style), 0) 146 , m_orderIterator(*this) 146 147 { 147 148 // All of our children must be block level. … … 428 429 } 429 430 430 size_t RenderGrid::maximumIndexInDirection(TrackSizingDirection direction) const431 {432 size_t maximumIndex = std::max<size_t>(1, (direction == ForColumns) ? explicitGridColumnCount() : explicitGridRowCount());433 434 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {435 OwnPtr<GridSpan> positions = resolveGridPositionsFromStyle(child, direction);436 437 // |positions| is null if we need to run the auto-placement algorithm. Our estimation ignores438 // this case as the auto-placement algorithm will grow the grid as needed.439 if (!positions)440 continue;441 442 maximumIndex = std::max(maximumIndex, positions->finalPositionIndex + 1);443 }444 445 return maximumIndex;446 }447 448 431 LayoutUnit RenderGrid::logicalContentHeightForChild(RenderBox* child, Vector<GridTrack>& columnTracks) 449 432 { … … 626 609 ASSERT(m_gridItemCoordinate.isEmpty()); 627 610 628 m_grid.grow(maximumIndexInDirection(ForRows)); 629 size_t maximumColumnIndex = maximumIndexInDirection(ForColumns); 630 for (size_t i = 0; i < m_grid.size(); ++i) 631 m_grid[i].grow(maximumColumnIndex); 611 populateExplicitGridAndOrderIterator(); 632 612 633 613 Vector<RenderBox*> autoMajorAxisAutoGridItems; 634 614 Vector<RenderBox*> specifiedMajorAxisAutoGridItems; 635 615 GridAutoFlow autoFlow = style()->gridAutoFlow(); 636 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {616 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next()) { 637 617 // FIXME: We never re-resolve positions if the grid is grown during auto-placement which may lead auto / <integer> 638 618 // positions to not match the author's intent. The specification is unclear on what should be done in this case. … … 662 642 placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems); 663 643 placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems); 644 } 645 646 void RenderGrid::populateExplicitGridAndOrderIterator() 647 { 648 // FIXME: We should find a way to share OrderValues's initialization code with RenderFlexibleBox. 649 OrderIterator::OrderValues orderValues; 650 size_t maximumRowIndex = std::max<size_t>(1, explicitGridRowCount()); 651 size_t maximumColumnIndex = std::max<size_t>(1, explicitGridColumnCount()); 652 653 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) { 654 // Avoid growing the vector for the common-case default value of 0. This optimizes the most common case which is 655 // one or a few values with the default order 0 656 int order = child->style()->order(); 657 if (orderValues.isEmpty() || orderValues.last() != order) 658 orderValues.append(order); 659 660 // This function bypasses the cache (cachedGridCoordinate()) as it is used to build it. 661 OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(child, ForRows); 662 OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(child, ForColumns); 663 664 // |positions| is 0 if we need to run the auto-placement algorithm. Our estimation ignores 665 // this case as the auto-placement algorithm will grow the grid as needed. 666 if (rowPositions) 667 maximumRowIndex = std::max(maximumRowIndex, rowPositions->finalPositionIndex + 1); 668 if (columnPositions) 669 maximumColumnIndex = std::max(maximumColumnIndex, columnPositions->finalPositionIndex + 1); 670 } 671 672 m_grid.grow(maximumRowIndex); 673 for (size_t i = 0; i < m_grid.size(); ++i) 674 m_grid[i].grow(maximumColumnIndex); 675 676 m_orderIterator.setOrderValues(std::move(orderValues)); 664 677 } 665 678 … … 1015 1028 } 1016 1029 1030 void RenderGrid::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& forChild, bool usePrintRect) 1031 { 1032 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next()) 1033 paintChild(*child, paintInfo, paintOffset, forChild, usePrintRect); 1034 } 1035 1017 1036 const char* RenderGrid::renderName() const 1018 1037 { -
trunk/Source/WebCore/rendering/RenderGrid.h
r158097 r158115 1 1 /* 2 2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Igalia S.L. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 #define RenderGrid_h 28 29 30 #include "OrderIterator.h" 29 31 #include "RenderBlock.h" 30 32 … … 74 76 void insertItemIntoGrid(RenderBox*, const GridCoordinate&); 75 77 void placeItemsOnGrid(); 78 void populateExplicitGridAndOrderIterator(); 76 79 void placeSpecifiedMajorAxisItemsOnGrid(Vector<RenderBox*>); 77 80 void placeAutoMajorAxisItemsOnGrid(Vector<RenderBox*>); … … 96 99 size_t explicitGridRowCount() const; 97 100 size_t explicitGridSizeForSide(GridPositionSide) const; 98 size_t maximumIndexInDirection(TrackSizingDirection) const;99 101 100 102 LayoutUnit logicalContentHeightForChild(RenderBox*, Vector<GridTrack>&); … … 114 116 115 117 LayoutUnit gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirection, const Vector<GridTrack>&) const; 118 119 virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint& paintOffset, PaintInfo& forChild, bool usePrintRect) OVERRIDE FINAL; 116 120 117 121 #ifndef NDEBUG … … 133 137 Vector<Vector<Vector<RenderBox*, 1>>> m_grid; 134 138 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate; 139 OrderIterator m_orderIterator; 135 140 }; 136 141
Note: See TracChangeset
for help on using the changeset viewer.