Changeset 242669 in webkit
- Timestamp:
- Mar 8, 2019, 6:35:54 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
page/scrolling/cocoa/ScrollingTreeFixedNode.mm (modified) (3 diffs)
-
page/scrolling/cocoa/ScrollingTreeStickyNode.mm (modified) (3 diffs)
-
platform/graphics/cocoa/WebCoreCALayerExtras.h (modified) (1 diff)
-
platform/graphics/cocoa/WebCoreCALayerExtras.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242664 r242669 1 2019-03-08 Simon Fraser <simon.fraser@apple.com> 2 3 Share some code that sets CALayer positions 4 https://bugs.webkit.org/show_bug.cgi?id=195485 5 6 Reviewed by Zalan Bujtas. 7 8 Share some code between ScrollingTreeStickyNode and ScrollingTreeFixedNode that sets the position 9 of a CALayer given the top-left location. 10 11 * page/scrolling/cocoa/ScrollingTreeFixedNode.mm: 12 (WebCore::ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange): 13 (WebCore::ScrollingTreeFixedNodeInternal::operator*): Deleted. 14 * page/scrolling/cocoa/ScrollingTreeStickyNode.mm: 15 (WebCore::ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange): 16 (WebCore::ScrollingTreeStickyNodeInternal::operator*): Deleted. 17 * platform/graphics/cocoa/WebCoreCALayerExtras.h: 18 * platform/graphics/cocoa/WebCoreCALayerExtras.mm: 19 (-[CALayer _web_setLayerTopLeftPosition:]): 20 1 21 2019-03-08 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm
r242132 r242669 32 32 #import "ScrollingStateFixedNode.h" 33 33 #import "ScrollingTree.h" 34 #import <QuartzCore/CALayer.h>34 #import "WebCoreCALayerExtras.h" 35 35 #import <wtf/text/TextStream.h> 36 36 … … 64 64 } 65 65 66 namespace ScrollingTreeFixedNodeInternal {67 static inline CGPoint operator*(CGPoint& a, const CGSize& b)68 {69 return CGPointMake(a.x * b.width, a.y * b.height);70 }71 }72 73 66 void ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) 74 67 { 75 using namespace ScrollingTreeFixedNodeInternal;76 68 FloatPoint layerPosition = m_constraints.layerPositionForViewportRect(layoutViewport); 77 69 … … 80 72 layerPosition -= cumulativeDelta; 81 73 82 CGRect layerBounds = [m_layer bounds]; 83 CGPoint anchorPoint = [m_layer anchorPoint]; 84 CGPoint newPosition = layerPosition - m_constraints.alignmentOffset() + anchorPoint * layerBounds.size; 85 86 if (isnan(newPosition.x) || isnan(newPosition.y)) { 87 WTFLogAlways("Attempt to call [CALayer setPosition] with NaN: newPosition=(%f, %f) layerPosition=(%f, %f) alignmentOffset=(%f, %f)", 88 newPosition.x, newPosition.y, layerPosition.x(), layerPosition.y(), 89 m_constraints.alignmentOffset().width(), m_constraints.alignmentOffset().height()); 90 ASSERT_NOT_REACHED(); 91 return; 92 } 93 94 [m_layer setPosition:newPosition]; 74 [m_layer _web_setLayerTopLeftPosition:layerPosition - m_constraints.alignmentOffset()]; 95 75 cumulativeDelta += layerPosition - m_constraints.layerPositionAtLastLayout(); 96 76 } -
trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm
r242132 r242669 34 34 #import "ScrollingTreeFrameScrollingNode.h" 35 35 #import "ScrollingTreeOverflowScrollingNode.h" 36 #import <QuartzCore/CALayer.h>36 #import "WebCoreCALayerExtras.h" 37 37 #import <wtf/text/TextStream.h> 38 38 … … 66 66 } 67 67 68 namespace ScrollingTreeStickyNodeInternal {69 static inline CGPoint operator*(CGPoint& a, const CGSize& b)70 {71 return CGPointMake(a.x * b.width, a.y * b.height);72 }73 }74 75 68 void ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) 76 69 { 77 using namespace ScrollingTreeStickyNodeInternal;78 70 FloatRect constrainingRect; 79 71 … … 88 80 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNode " << scrollingNodeID() << " relatedNodeScrollPositionDidChange: new viewport " << layoutViewport << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout()); 89 81 90 FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(constrainingRect); 91 92 CGRect layerBounds = [m_layer bounds]; 93 CGPoint anchorPoint = [m_layer anchorPoint]; 94 CGPoint newPosition = layerPosition - m_constraints.alignmentOffset() + anchorPoint * layerBounds.size; 95 [m_layer setPosition:newPosition]; 82 FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(constrainingRect) - m_constraints.alignmentOffset(); 83 [m_layer _web_setLayerTopLeftPosition:layerPosition]; 96 84 97 85 cumulativeDelta += layerPosition - m_constraints.layerPositionAtLastLayout(); -
trunk/Source/WebCore/platform/graphics/cocoa/WebCoreCALayerExtras.h
r221543 r242669 29 29 30 30 - (void)web_disableAllActions; 31 - (void)_web_setLayerTopLeftPosition:(CGPoint)position; 31 32 + (CALayer *)_web_renderLayerWithContextID:(uint32_t)contextID; 32 33 -
trunk/Source/WebCore/platform/graphics/cocoa/WebCoreCALayerExtras.mm
r221543 r242669 57 57 } 58 58 59 - (void)_web_setLayerTopLeftPosition:(CGPoint)position 60 { 61 CGSize layerSize = [self bounds].size; 62 CGPoint anchorPoint = [self anchorPoint]; 63 CGPoint newPosition = CGPointMake(position.x + anchorPoint.x * layerSize.width, position.y + anchorPoint.y * layerSize.height); 64 if (isnan(newPosition.x) || isnan(newPosition.y)) { 65 WTFLogAlways("Attempt to call [CALayer setPosition] with NaN: newPosition=(%f, %f) position=(%f, %f) anchorPoint=(%f, %f)", 66 newPosition.x, newPosition.y, position.x, position.y, anchorPoint.x, anchorPoint.y); 67 ASSERT_NOT_REACHED(); 68 return; 69 } 70 71 [self setPosition:newPosition]; 72 } 73 59 74 + (CALayer *)_web_renderLayerWithContextID:(uint32_t)contextID 60 75 {
Note:
See TracChangeset
for help on using the changeset viewer.