Changeset 274464 in webkit
- Timestamp:
- Mar 15, 2021 9:33:30 PM (16 months ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
inspector/InspectorOverlay.cpp (modified) (3 diffs)
-
page/FrameView.cpp (modified) (2 diffs)
-
page/FrameView.h (modified) (2 diffs)
-
platform/ScrollView.cpp (modified) (1 diff)
-
platform/ScrollView.h (modified) (1 diff)
-
platform/Widget.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r274461 r274464 1 2021-03-15 Patrick Angle <pangle@apple.com> 2 3 Web Inspector: Grid overlay does not adjust for element inside iframes 4 https://bugs.webkit.org/show_bug.cgi?id=222920 5 6 Reviewed by Simon Fraser. 7 8 Resolves an issue when overlays are applied to grids within iframes, which need to account for the 9 position/transform of their containing frame, and any other parent frames, to appear correctly in relation to 10 the root frame. This patch also has the side effect of changing how drawing the grid overlay while the page is 11 scrolled by allowing `localPointToRootPoint` to account for the scroll translation instead of explicitly 12 offsetting drawing by the scroll offset. 13 14 `Widget`, `ScrollView`, and `FrameView` are updated to retain floating-point precision where necessary. 15 16 * inspector/InspectorOverlay.cpp: 17 (WebCore::localPointToRootPoint): 18 - Use floating-point precision instead of integer precision. 19 (WebCore::InspectorOverlay::drawGridOverlay): 20 - Use `localPointToRootPoint` to calculate absolute points relative to a `renderGrid`'s parent hierarchy. 21 - Remove graphics context translation, as `localPointToRootPoint` will account for this translation. 22 * page/FrameView.cpp: 23 (WebCore::FrameView::convertFromRendererToContainingView const): 24 (WebCore::FrameView::convertToContainingView const): 25 * page/FrameView.h: 26 * platform/ScrollView.cpp: 27 (WebCore::ScrollView::contentsToView const): 28 * platform/ScrollView.h: 29 (WebCore::ScrollView::convertChildToSelf const): 30 * platform/Widget.cpp: 31 (WebCore::Widget::convertToContainingView const): 32 1 33 2021-03-15 Simon Fraser <simon.fraser@apple.com> 2 34 -
trunk/Source/WebCore/inspector/InspectorOverlay.cpp
r274096 r274464 100 100 static FloatPoint localPointToRootPoint(const FrameView* view, const FloatPoint& point) 101 101 { 102 return view->contentsToRootView( roundedIntPoint(point));102 return view->contentsToRootView(point); 103 103 } 104 104 … … 1401 1401 constexpr auto translucentLabelBackgroundColor = Color::white.colorWithAlphaByte(153); 1402 1402 1403 IntPoint scrollOffset;1404 1403 FrameView* pageView = m_page.mainFrame().view(); 1405 if (!pageView->delegatesScrolling()) 1406 scrollOffset = pageView->visibleContentRect().location(); 1407 1408 FloatSize contentInset(0, pageView->topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset)); 1409 float pageScaleFactor = m_page.pageScaleFactor(); 1410 1411 float scrollX = scrollOffset.x() * pageScaleFactor; 1412 float scrollY = scrollOffset.y() * pageScaleFactor; 1413 1414 FloatRect viewportBounds = { FloatPoint(scrollX, scrollY), pageView->sizeForVisibleContent() }; 1404 if (!pageView) 1405 return; 1406 FloatRect viewportBounds = { { 0, 0 }, pageView->sizeForVisibleContent() }; 1415 1407 1416 1408 auto& renderGrid = *downcast<RenderGrid>(renderer); … … 1424 1416 float gridStartY = rowPositions[0]; 1425 1417 float gridEndY = rowPositions[rowPositions.size() - 1]; 1426 1427 // FIXME: <webkit.org/b/222920> Grid overlay does not adjust for element inside iframes. 1418 1419 Frame* containingFrame = node->document().frame(); 1420 if (!containingFrame) 1421 return; 1422 FrameView* containingView = containingFrame->view(); 1423 1428 1424 auto columnLineAt = [&](int x) -> FloatLine { 1429 1425 return { 1430 renderGrid.localToContainerPoint(FloatPoint(x, gridStartY), nullptr),1431 renderGrid.localToContainerPoint(FloatPoint(x, gridEndY), nullptr),1426 localPointToRootPoint(containingView, renderGrid.localToContainerPoint(FloatPoint(x, gridStartY), nullptr)), 1427 localPointToRootPoint(containingView, renderGrid.localToContainerPoint(FloatPoint(x, gridEndY), nullptr)), 1432 1428 }; 1433 1429 }; 1434 1430 auto rowLineAt = [&](int y) -> FloatLine { 1435 1431 return { 1436 renderGrid.localToContainerPoint(FloatPoint(gridStartX, y), nullptr),1437 renderGrid.localToContainerPoint(FloatPoint(gridEndX, y), nullptr),1432 localPointToRootPoint(containingView, renderGrid.localToContainerPoint(FloatPoint(gridStartX, y), nullptr)), 1433 localPointToRootPoint(containingView, renderGrid.localToContainerPoint(FloatPoint(gridEndX, y), nullptr)), 1438 1434 }; 1439 1435 }; 1440 1436 1441 1437 GraphicsContextStateSaver saver(context); 1442 1443 // Drawing code is relative to the visible viewport area.1444 context.translate(0 - scrollX, contentInset.height() - scrollY);1445 1438 context.setStrokeThickness(1); 1446 1439 context.setStrokeColor(gridOverlay.config.gridColor); -
trunk/Source/WebCore/page/FrameView.cpp
r273812 r274464 4786 4786 } 4787 4787 4788 FloatPoint FrameView::convertFromRendererToContainingView(const RenderElement* renderer, const FloatPoint& rendererPoint) const 4789 { 4790 return contentsToView(renderer->localToAbsolute(rendererPoint, UseTransforms)); 4791 } 4792 4788 4793 IntPoint FrameView::convertFromContainingViewToRenderer(const RenderElement* renderer, const IntPoint& viewPoint) const 4789 4794 { … … 4884 4889 } 4885 4890 4891 FloatPoint FrameView::convertToContainingView(const FloatPoint& localPoint) const 4892 { 4893 if (const ScrollView* parentScrollView = parent()) { 4894 if (is<FrameView>(*parentScrollView)) { 4895 const FrameView& parentView = downcast<FrameView>(*parentScrollView); 4896 4897 // Get our renderer in the parent view 4898 RenderWidget* renderer = frame().ownerRenderer(); 4899 if (!renderer) 4900 return localPoint; 4901 4902 auto point = localPoint; 4903 point.moveBy(renderer->contentBoxLocation()); 4904 return parentView.convertFromRendererToContainingView(renderer, point); 4905 } 4906 4907 return Widget::convertToContainingView(localPoint); 4908 } 4909 4910 return localPoint; 4911 } 4912 4886 4913 IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const 4887 4914 { -
trunk/Source/WebCore/page/FrameView.h
r273275 r274464 482 482 WEBCORE_EXPORT FloatRect convertFromContainingViewToRenderer(const RenderElement*, const FloatRect&) const; 483 483 WEBCORE_EXPORT IntPoint convertFromRendererToContainingView(const RenderElement*, const IntPoint&) const; 484 WEBCORE_EXPORT FloatPoint convertFromRendererToContainingView(const RenderElement*, const FloatPoint&) const; 484 485 WEBCORE_EXPORT IntPoint convertFromContainingViewToRenderer(const RenderElement*, const IntPoint&) const; 485 486 … … 489 490 FloatRect convertFromContainingView(const FloatRect&) const final; 490 491 IntPoint convertToContainingView(const IntPoint&) const final; 492 FloatPoint convertToContainingView(const FloatPoint&) const final; 491 493 IntPoint convertFromContainingView(const IntPoint&) const final; 492 494 -
trunk/Source/WebCore/platform/ScrollView.cpp
r273275 r274464 891 891 if (delegatesScrolling()) 892 892 return point; 893 894 return contentsToView(IntPoint(point)); 893 return point - toFloatSize(documentScrollPositionRelativeToViewOrigin()); 895 894 } 896 895 -
trunk/Source/WebCore/platform/ScrollView.h
r271788 r274464 355 355 } 356 356 357 FloatPoint convertChildToSelf(const Widget* child, const FloatPoint& point) const 358 { 359 FloatPoint newPoint = point; 360 if (!isScrollViewScrollbar(child)) 361 newPoint -= toFloatSize(scrollPosition()); 362 newPoint.moveBy(child->location()); 363 return newPoint; 364 } 365 357 366 IntPoint convertSelfToChild(const Widget* child, const IntPoint& point) const 358 367 { -
trunk/Source/WebCore/platform/Widget.cpp
r271360 r274464 264 264 FloatPoint Widget::convertToContainingView(const FloatPoint& localPoint) const 265 265 { 266 return convertToContainingView(IntPoint(localPoint)); 266 if (const ScrollView* parentScrollView = parent()) 267 return parentScrollView->convertChildToSelf(this, localPoint); 268 269 return localPoint; 267 270 } 268 271
Note: See TracChangeset
for help on using the changeset viewer.