Changeset 136150 in webkit
- Timestamp:
- Nov 29, 2012, 12:26:29 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 11 edited
-
ChangeLog (modified) (1 diff)
-
GNUmakefile.list.am (modified) (1 diff)
-
Target.pri (modified) (1 diff)
-
WebCore.gypi (modified) (1 diff)
-
WebCore.vcproj/WebCore.vcproj (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
css/CSSComputedStyleDeclaration.cpp (modified) (1 diff)
-
css/StyleResolver.cpp (modified) (4 diffs)
-
rendering/RenderGrid.cpp (modified) (3 diffs)
-
rendering/style/GridTrackSize.h (added)
-
rendering/style/RenderStyle.h (modified) (3 diffs)
-
rendering/style/StyleGridData.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r136149 r136150 1 2012-11-29 Julien Chaffraix <jchaffraix@webkit.org> 2 3 [CSS Grid Layout] track sizing functions should have their own type 4 https://bugs.webkit.org/show_bug.cgi?id=103343 5 6 Reviewed by Tony Chang. 7 8 The current code uses a Length to represent the track sizing function. This is 9 fine as we only parse <length> | <percentage> but in order to support minmax 10 sizing, we have to store 2 Lengths. We could go with a pair but that would make 11 the code not very readable so this change introduces GridTrackSize. 12 13 Refactoring, covered by existing tests. 14 15 * GNUmakefile.list.am: 16 * Target.pri: 17 * WebCore.gypi: 18 * WebCore.vcproj/WebCore.vcproj: 19 * WebCore.xcodeproj/project.pbxproj: 20 Added GridTrackSize.h to all our build systems. 21 22 * css/CSSComputedStyleDeclaration.cpp: 23 (WebCore::valueForGridTrackBreadth): 24 (WebCore::valueForGridTrackList): 25 * css/StyleResolver.cpp: 26 (WebCore::createGridTrackBreadth): 27 (WebCore::createGridTrackList): 28 (WebCore::StyleResolver::applyProperty): 29 * rendering/RenderGrid.cpp: 30 (WebCore::RenderGrid::computePreferredLogicalWidths): 31 (WebCore::RenderGrid::computedUsedBreadthOfGridTracks): 32 * rendering/style/RenderStyle.h: 33 Updated the above call sites to use GridTrackSize. While 34 touching them, changed the code to use an empty Vector to represent 35 'none' instead of Length(Undefined). 36 37 * rendering/style/StyleGridData.h: 38 Updated #include, removed a comment as it would have gone stale after 39 adding more grammar support and added a FIXME to rename some variables. 40 41 * rendering/RenderGrid.cpp: 42 (WebCore::RenderGrid::layoutGridItems): 43 Implemented a work-around to avoid crashing due to implicit columns / rows. 44 45 * rendering/style/GridTrackSize.h: Added. 46 (WebCore::GridTrackSize::GridTrackSize): 47 (WebCore::GridTrackSize::length): 48 (WebCore::GridTrackSize::setLength): 49 (WebCore::GridTrackSize::type): 50 (WebCore::GridTrackSize::operator==): 51 New class, it now only wraps a single Length. 52 1 53 2012-11-29 Helder Correia <helder.correia@nokia.com> 2 54 -
trunk/Source/WebCore/GNUmakefile.list.am
r136113 r136150 4505 4505 Source/WebCore/rendering/style/StyleVisualData.cpp \ 4506 4506 Source/WebCore/rendering/style/StyleVisualData.h \ 4507 Source/WebCore/rendering/style/GridTrackSize.h \ 4507 4508 Source/WebCore/rendering/TableLayout.h \ 4508 4509 Source/WebCore/rendering/TrailingFloatsRootInlineBox.h \ -
trunk/Source/WebCore/Target.pri
r136113 r136150 2477 2477 rendering/style/StyleVariableData.h \ 2478 2478 rendering/style/StyleVisualData.h \ 2479 rendering/style/GridTrackSize.h \ 2479 2480 rendering/style/SVGRenderStyleDefs.h \ 2480 2481 rendering/style/SVGRenderStyle.h \ -
trunk/Source/WebCore/WebCore.gypi
r136113 r136150 629 629 'rendering/style/StyleVariableData.h', 630 630 'rendering/style/StyleVisualData.h', 631 'rendering/style/GridTrackSizes.h', 631 632 'rendering/svg/SVGResourcesCache.h', 632 633 'workers/SharedWorkerStrategy.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r136113 r136150 46852 46852 </File> 46853 46853 <File 46854 RelativePath="..\rendering\style\GridTrackSize.h" 46855 > 46856 </File> 46857 <File 46854 46858 RelativePath="..\rendering\style\SVGRenderStyle.cpp" 46855 46859 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r136113 r136150 3822 3822 A12538D413F9B60A00024754 /* LayoutRepainter.h in Headers */ = {isa = PBXBuildFile; fileRef = A120ACA013F9983700FE4AC7 /* LayoutRepainter.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3823 3823 A12705C31656BD6500C2E27C /* GridPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = A12705C21656BD6500C2E27C /* GridPosition.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3824 A12A1050166444FD008FA311 /* GridTrackSize.h in Headers */ = {isa = PBXBuildFile; fileRef = A12A104E166444DC008FA311 /* GridTrackSize.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3824 3825 A136A00C1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */; }; 3825 3826 A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */ = {isa = PBXBuildFile; fileRef = A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */; }; … … 11137 11138 A120ACA113F9984600FE4AC7 /* LayoutRepainter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutRepainter.cpp; sourceTree = "<group>"; }; 11138 11139 A12705C21656BD6500C2E27C /* GridPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GridPosition.h; path = style/GridPosition.h; sourceTree = "<group>"; }; 11140 A12A104E166444DC008FA311 /* GridTrackSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GridTrackSize.h; path = style/GridTrackSize.h; sourceTree = "<group>"; }; 11139 11141 A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequestProgressEventThrottle.cpp; sourceTree = "<group>"; }; 11140 11142 A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHttpRequestProgressEventThrottle.h; sourceTree = "<group>"; }; … … 20743 20745 BC2274760E8366E200E7F975 /* SVGRenderStyleDefs.cpp */, 20744 20746 BC2274770E8366E200E7F975 /* SVGRenderStyleDefs.h */, 20747 A12A104E166444DC008FA311 /* GridTrackSize.h */, 20745 20748 ); 20746 20749 name = style; … … 25605 25608 49E912AE0EFAC906009D0CAF /* TimingFunction.h in Headers */, 25606 25609 070334D71459FFD5008D8D45 /* TrackBase.h in Headers */, 25610 A12A1050166444FD008FA311 /* GridTrackSize.h in Headers */, 25607 25611 49E911C40EF86D47009D0CAF /* TransformationMatrix.h in Headers */, 25608 25612 49E911CE0EF86D47009D0CAF /* TransformOperation.h in Headers */, -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r136142 r136150 984 984 #endif 985 985 986 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const Length& trackLength, const RenderStyle* style)987 { 988 if (track Length.isPercent())989 return cssValuePool().createValue(track Length);990 if (track Length.isAuto())986 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const GridTrackSize& trackSize, const RenderStyle* style) 987 { 988 if (trackSize.length().isPercent()) 989 return cssValuePool().createValue(trackSize.length()); 990 if (trackSize.length().isAuto()) 991 991 return cssValuePool().createIdentifierValue(CSSValueAuto); 992 return zoomAdjustedPixelValue(trackLength.value(), style); 993 } 994 995 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<Length>& trackLengths, const RenderStyle* style) 996 { 997 // We should have at least an element! 998 ASSERT(trackLengths.size()); 999 992 return zoomAdjustedPixelValue(trackSize.length().value(), style); 993 } 994 995 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const RenderStyle* style) 996 { 1000 997 // Handle the 'none' case here. 1001 if ( trackLengths.size() == 1 && trackLengths[0].isUndefined())998 if (!trackSizes.size()) 1002 999 return cssValuePool().createIdentifierValue(CSSValueNone); 1003 1000 1004 1001 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1005 for (size_t i = 0; i < track Lengths.size(); ++i)1006 list->append(valueForGridTrackBreadth(track Lengths[i], style));1002 for (size_t i = 0; i < trackSizes.size(); ++i) 1003 list->append(valueForGridTrackBreadth(trackSizes[i], style)); 1007 1004 return list.release(); 1008 1005 } -
trunk/Source/WebCore/css/StyleResolver.cpp
r136142 r136150 2660 2660 } 2661 2661 2662 static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, Length& length)2662 static bool createGridTrackBreadth(CSSPrimitiveValue* primitiveValue, StyleResolver* selector, GridTrackSize& trackSize) 2663 2663 { 2664 2664 Length workingLength = primitiveValue->convertToLength<FixedIntegerConversion | PercentConversion | ViewportPercentageConversion | AutoConversion>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()); … … 2669 2669 workingLength.setQuirk(primitiveValue->isQuirkValue()); 2670 2670 2671 length = workingLength;2671 trackSize.setLength(workingLength); 2672 2672 return true; 2673 2673 } 2674 2674 2675 static bool createGridTrackList(CSSValue* value, Vector< Length>& lengths, StyleResolver* selector)2675 static bool createGridTrackList(CSSValue* value, Vector<GridTrackSize>& trackSizes, StyleResolver* selector) 2676 2676 { 2677 2677 // Handle 'none'. 2678 2678 if (value->isPrimitiveValue()) { 2679 2679 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 2680 if (primitiveValue->getIdent() == CSSValueNone) { 2681 lengths.append(Length(Undefined)); 2682 return true; 2683 } 2684 return false; 2680 return primitiveValue->getIdent() == CSSValueNone; 2685 2681 } 2686 2682 … … 2691 2687 return false; 2692 2688 2693 Length length;2694 if (!createGridTrackBreadth(static_cast<CSSPrimitiveValue*>(currValue), selector, length))2689 GridTrackSize trackSize; 2690 if (!createGridTrackBreadth(static_cast<CSSPrimitiveValue*>(currValue), selector, trackSize)) 2695 2691 return false; 2696 2692 2697 lengths.append(length);2693 trackSizes.append(trackSize); 2698 2694 } 2699 2695 return true; … … 3545 3541 #endif 3546 3542 case CSSPropertyWebkitGridColumns: { 3547 Vector< Length> lengths;3548 if (!createGridTrackList(value, lengths, this))3543 Vector<GridTrackSize> trackSizes; 3544 if (!createGridTrackList(value, trackSizes, this)) 3549 3545 return; 3550 m_style->setGridColumns( lengths);3546 m_style->setGridColumns(trackSizes); 3551 3547 return; 3552 3548 } 3553 3549 case CSSPropertyWebkitGridRows: { 3554 Vector< Length> lengths;3555 if (!createGridTrackList(value, lengths, this))3550 Vector<GridTrackSize> trackSizes; 3551 if (!createGridTrackList(value, trackSizes, this)) 3556 3552 return; 3557 m_style->setGridRows( lengths);3553 m_style->setGridRows(trackSizes); 3558 3554 return; 3559 3555 } -
trunk/Source/WebCore/rendering/RenderGrid.cpp
r135965 r136150 117 117 // FIXME: We don't take our own logical width into account. 118 118 119 const Vector< Length>& trackStyles = style()->gridColumns();119 const Vector<GridTrackSize>& trackStyles = style()->gridColumns(); 120 120 121 121 for (size_t i = 0; i < trackStyles.size(); ++i) { 122 Length trackLength = trackStyles[i] ;122 Length trackLength = trackStyles[i].length(); 123 123 if (!trackLength.isFixed()) { 124 124 notImplemented(); … … 139 139 void RenderGrid::computedUsedBreadthOfGridTracks(TrackSizingDirection direction, Vector<GridTrack>& tracks) 140 140 { 141 const Vector< Length>& trackStyles = (direction == ForColumns) ? style()->gridColumns() : style()->gridRows();141 const Vector<GridTrackSize>& trackStyles = (direction == ForColumns) ? style()->gridColumns() : style()->gridRows(); 142 142 for (size_t i = 0; i < trackStyles.size(); ++i) { 143 143 GridTrack track; 144 if (trackStyles[i]. isFixed())145 track.m_usedBreadth = trackStyles[i]. getFloatValue();144 if (trackStyles[i].length().isFixed()) 145 track.m_usedBreadth = trackStyles[i].length().getFloatValue(); 146 146 else 147 147 notImplemented(); … … 166 166 size_t rowTrack = resolveGridPosition(child->style()->gridItemRow()); 167 167 168 // Because the grid area cannot be styled, we don't need to adjust 169 // the grid breadth to account for 'box-sizing'. 170 child->setOverrideContainingBlockContentLogicalWidth(columnTracks[columnTrack].m_usedBreadth); 171 child->setOverrideContainingBlockContentLogicalHeight(rowTracks[rowTrack].m_usedBreadth); 168 // FIXME: Properly support implicit rows and columns (bug 103573). 169 if (columnTrack < columnTracks.size() && rowTrack < rowTracks.size()) { 170 // Because the grid area cannot be styled, we don't need to adjust 171 // the grid breadth to account for 'box-sizing'. 172 child->setOverrideContainingBlockContentLogicalWidth(columnTracks[columnTrack].m_usedBreadth); 173 child->setOverrideContainingBlockContentLogicalHeight(rowTracks[rowTrack].m_usedBreadth); 174 } 172 175 173 176 // FIXME: Grid items should stretch to fill their cells. Once we -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r136142 r136150 759 759 EJustifyContent justifyContent() const { return static_cast<EJustifyContent>(rareNonInheritedData->m_justifyContent); } 760 760 761 const Vector< Length>& gridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; }762 const Vector< Length>& gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; }761 const Vector<GridTrackSize>& gridColumns() const { return rareNonInheritedData->m_grid->m_gridColumns; } 762 const Vector<GridTrackSize>& gridRows() const { return rareNonInheritedData->m_grid->m_gridRows; } 763 763 764 764 const GridPosition& gridItemColumn() const { return rareNonInheritedData->m_gridItem->m_gridColumn; } … … 1241 1241 void setFlexWrap(EFlexWrap w) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexWrap, w); } 1242 1242 void setJustifyContent(EJustifyContent p) { SET_VAR(rareNonInheritedData, m_justifyContent, p); } 1243 void setGridColumns(const Vector< Length>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, lengths); }1244 void setGridRows(const Vector< Length>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, lengths); }1243 void setGridColumns(const Vector<GridTrackSize>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridColumns, lengths); } 1244 void setGridRows(const Vector<GridTrackSize>& lengths) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridRows, lengths); } 1245 1245 void setGridItemColumn(const GridPosition& columnPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridColumn, columnPosition); } 1246 1246 void setGridItemRow(const GridPosition& rowPosition) { SET_VAR(rareNonInheritedData.access()->m_gridItem, m_gridRow, rowPosition); } … … 1633 1633 1634 1634 // The initial value is 'none' for grid tracks. 1635 static Vector<Length> initialGridTrackValue() 1636 { 1637 DEFINE_STATIC_LOCAL(Vector<Length>, defaultLength, ()); 1638 // We need to manually add the Length here as the Length(0) is 'auto'. 1639 if (!defaultLength.size()) 1640 defaultLength.append(Length(Undefined)); 1641 return defaultLength; 1642 } 1643 static Vector<Length> initialGridColumns() { return initialGridTrackValue(); } 1644 static Vector<Length> initialGridRows() { return initialGridTrackValue(); } 1635 static Vector<GridTrackSize> initialGridColumns() { return Vector<GridTrackSize>(); } 1636 static Vector<GridTrackSize> initialGridRows() { return Vector<GridTrackSize>(); } 1645 1637 1646 1638 // 'auto' is the default. -
trunk/Source/WebCore/rendering/style/StyleGridData.h
r117613 r136150 27 27 #define StyleGridData_h 28 28 29 #include " Length.h"29 #include "GridTrackSize.h" 30 30 #include <wtf/PassRefPtr.h> 31 31 #include <wtf/RefCounted.h> … … 49 49 } 50 50 51 // FIXME: For the moment, we only support a subset of the grammar which correspond to: 52 // 'auto' | <length> | <percentage> | 'none' 53 Vector<Length> m_gridColumns; 54 Vector<Length> m_gridRows; 51 // FIXME: Update the naming of the following variables. 52 Vector<GridTrackSize> m_gridColumns; 53 Vector<GridTrackSize> m_gridRows; 55 54 56 55 private:
Note:
See TracChangeset
for help on using the changeset viewer.