Changeset 181855 in webkit
- Timestamp:
- Mar 23, 2015, 9:57:06 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
css/CSSParser.cpp (modified) (1 diff)
-
page/scrolling/AxisScrollSnapOffsets.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r181849 r181855 1 2015-03-23 Brent Fulgham <bfulgham@apple.com> 2 3 scroll-snap-destination and scroll-snap-coordinate do not seem to work together properly 4 https://bugs.webkit.org/show_bug.cgi?id=142552 5 <rdar://problem/20114743> 6 7 Reviewed by Dean Jackson. 8 9 Revise the snap point logic as follows: 10 (1) Put the snap point destination handling in a helper function to make the rest of the code 11 easier to read. 12 (2) Make sure we always have a left-hand snap point (i.e., position 0), but don't add multiple 13 left-hand snap points. 14 (3) Create a helper function to determine if we should be working with the scroll snap 'elements' 15 behavior. We want to use this for scroll-snap-destination/scroll-snap-coordinate markup. 16 (4) Create per-element snap point offsets when using scroll-snap-destination/scroll-snap-coordinate. 17 18 * css/CSSParser.cpp: 19 (WebCore::CSSParser::parseScrollSnapDestination): Add assertion to try to catch bad parser state. 20 * page/scrolling/AxisScrollSnapOffsets.cpp: 21 (WebCore::destinationOffsetForViewSize): Added helper function to consolidate logic for handling 22 destination coordinates. 23 (WebCore::updateFromStyle): Make sure a left-hand snap point is always provided. 24 (WebCore::styleUsesElements): Added helper function. 25 (WebCore::updateSnapOffsetsForScrollableArea): Revise logic to generate 'per-element' snap point 26 offsets. 27 1 28 2015-03-23 Yoav Weiss <yoav@yoav.ws> 2 29 -
trunk/Source/WebCore/css/CSSParser.cpp
r181832 r181855 3354 3354 { 3355 3355 RefPtr<CSSValueList> position = CSSValueList::createSpaceSeparated(); 3356 ASSERT(m_valueList->size() == 2); 3356 3357 if (m_valueList->size() != 2) 3357 3358 return false; -
trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp
r181504 r181855 30 30 #include "HTMLCollection.h" 31 31 #include "HTMLElement.h" 32 #include "Length.h" 32 33 #include "RenderBox.h" 33 34 #include "ScrollableArea.h" … … 69 70 } 70 71 72 static LayoutUnit destinationOffsetForViewSize(ScrollEventAxis axis, const LengthSize& destination, LayoutUnit viewSize) 73 { 74 const Length& dimension = (axis == ScrollEventAxis::Horizontal) ? destination.width() : destination.height(); 75 return valueForLength(dimension, viewSize); 76 } 77 71 78 static void updateFromStyle(Vector<LayoutUnit>& snapOffsets, const RenderStyle& style, ScrollEventAxis axis, LayoutUnit viewSize, LayoutUnit scrollSize, Vector<LayoutUnit>& snapOffsetSubsequence) 72 79 { … … 75 82 snapOffsetSubsequence.append(0); 76 83 77 bool isHorizontalAxis = axis == ScrollEventAxis::Horizontal; 78 auto* points = isHorizontalAxis ? style.scrollSnapPointsX() : style.scrollSnapPointsY(); 79 auto& destination = style.scrollSnapDestination(); 84 // Always put a snap point on the zero offset. 85 snapOffsets.append(0); 86 87 auto* points = (axis == ScrollEventAxis::Horizontal) ? style.scrollSnapPointsX() : style.scrollSnapPointsY(); 80 88 bool hasRepeat = points ? points->hasRepeat : false; 81 89 LayoutUnit repeatOffset = points ? valueForLength(points->repeatOffset, viewSize) : LayoutUnit(); 82 LayoutUnit destinationOffset = valueForLength(isHorizontalAxis ? destination.width() : destination.height(), viewSize);90 LayoutUnit destinationOffset = destinationOffsetForViewSize(axis, style.scrollSnapDestination(), viewSize); 83 91 LayoutUnit curSnapPositionShift = 0; 84 92 LayoutUnit maxScrollOffset = scrollSize - viewSize; … … 93 101 break; 94 102 95 snapOffsets.append(potentialSnapPosition); 103 // Don't add another zero offset value. 104 if (potentialSnapPosition) 105 snapOffsets.append(potentialSnapPosition); 106 96 107 lastSnapPosition = potentialSnapPosition + destinationOffset; 97 108 } 98 109 curSnapPositionShift = lastSnapPosition + repeatOffset; 99 110 } while (hasRepeat && curSnapPositionShift < maxScrollOffset); 100 101 if (snapOffsets.isEmpty())102 snapOffsets.append(0);103 111 104 112 // Always put a snap point on the maximum scroll offset. … … 108 116 } 109 117 118 static bool styleUsesElements(ScrollEventAxis axis, const RenderStyle& style) 119 { 120 const ScrollSnapPoints* scrollSnapPoints = (axis == ScrollEventAxis::Horizontal) ? style.scrollSnapPointsX() : style.scrollSnapPointsY(); 121 if (scrollSnapPoints) 122 return scrollSnapPoints->usesElements; 123 124 const Length& destination = (axis == ScrollEventAxis::Horizontal) ? style.scrollSnapDestination().width() : style.scrollSnapDestination().height(); 125 126 return !destination.isUndefined(); 127 } 128 110 129 void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, HTMLElement& scrollingElement, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle) 111 130 { … … 134 153 Vector<LayoutUnit> verticalSnapOffsetSubsequence; 135 154 136 bool scrollSnapPointsXUsesElements = s crollingElementStyle.scrollSnapPointsX() ? scrollingElementStyle.scrollSnapPointsX()->usesElements : false;137 bool scrollSnapPointsYUsesElements = s crollingElementStyle.scrollSnapPointsY() ? scrollingElementStyle.scrollSnapPointsY()->usesElements : false;155 bool scrollSnapPointsXUsesElements = styleUsesElements(ScrollEventAxis::Horizontal, scrollingElementStyle); 156 bool scrollSnapPointsYUsesElements = styleUsesElements(ScrollEventAxis::Vertical , scrollingElementStyle); 138 157 139 158 if (scrollSnapPointsXUsesElements || scrollSnapPointsYUsesElements) {
Note:
See TracChangeset
for help on using the changeset viewer.