- Revision
- 276397
- Author
- [email protected]
- Date
- 2021-04-21 16:06:48 -0700 (Wed, 21 Apr 2021)
Log Message
Introduce helper methods to map FloatQuads to and from content and root view coordinates
https://bugs.webkit.org/show_bug.cgi?id=224883
Reviewed by Tim Horton.
Source/WebCore:
Add new helper methods to transform FloatQuads from content coordinates to root view coordinates, and vice
versa; use these methods in several places throughout WebKit to avoid code duplication.
No change in behavior.
* inspector/agents/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didPaint):
(WebCore::InspectorTimelineAgent::localToPageQuad): Deleted.
* inspector/agents/InspectorTimelineAgent.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::rootViewToContents const):
(WebCore::ScrollView::contentsToRootView const):
* platform/ScrollView.h:
Source/WebKit:
Use the new helper methods.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::convertContentToRootView):
(WebKit::WebPage::sendTapHighlightForNodeIfNecessary):
Note that we previously rounded absolute quads to the nearest integer when mapping through root view
coordinates. From <https://bugs.webkit.org/show_bug.cgi?id=128277#c2>, this seemed unintentional to begin with,
and we should be able to use the `FloatPoint` conversion methods instead.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (276396 => 276397)
--- trunk/Source/WebCore/ChangeLog 2021-04-21 23:01:22 UTC (rev 276396)
+++ trunk/Source/WebCore/ChangeLog 2021-04-21 23:06:48 UTC (rev 276397)
@@ -1,3 +1,24 @@
+2021-04-21 Wenson Hsieh <[email protected]>
+
+ Introduce helper methods to map FloatQuads to and from content and root view coordinates
+ https://bugs.webkit.org/show_bug.cgi?id=224883
+
+ Reviewed by Tim Horton.
+
+ Add new helper methods to transform FloatQuads from content coordinates to root view coordinates, and vice
+ versa; use these methods in several places throughout WebKit to avoid code duplication.
+
+ No change in behavior.
+
+ * inspector/agents/InspectorTimelineAgent.cpp:
+ (WebCore::InspectorTimelineAgent::didPaint):
+ (WebCore::InspectorTimelineAgent::localToPageQuad): Deleted.
+ * inspector/agents/InspectorTimelineAgent.h:
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::rootViewToContents const):
+ (WebCore::ScrollView::contentsToRootView const):
+ * platform/ScrollView.h:
+
2021-04-21 Julian Gonzalez <[email protected]>
Crash in StyledMarkupAccumulator::traverseNodesForSerialization()
Modified: trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp (276396 => 276397)
--- trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp 2021-04-21 23:01:22 UTC (rev 276396)
+++ trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.cpp 2021-04-21 23:06:48 UTC (rev 276397)
@@ -432,9 +432,8 @@
TimelineRecordEntry& entry = m_recordStack.last();
ASSERT(entry.type == TimelineRecordType::Paint);
- FloatQuad quad;
- localToPageQuad(renderer, clipRect, &quad);
- entry.data = ""
+ auto clipQuadInRootView = renderer.view().frameView().contentsToRootView(renderer.localToAbsoluteQuad({ clipRect }));
+ entry.data = ""
didCompleteCurrentRecord(TimelineRecordType::Paint);
}
@@ -821,14 +820,4 @@
pushCurrentRecord(createRecordEntry(WTFMove(data), type, captureCallStack, frame));
}
-void InspectorTimelineAgent::localToPageQuad(const RenderObject& renderer, const LayoutRect& rect, FloatQuad* quad)
-{
- const FrameView& frameView = renderer.view().frameView();
- FloatQuad absolute = renderer.localToAbsoluteQuad(FloatQuad(rect));
- quad->setP1(frameView.contentsToRootView(roundedIntPoint(absolute.p1())));
- quad->setP2(frameView.contentsToRootView(roundedIntPoint(absolute.p2())));
- quad->setP3(frameView.contentsToRootView(roundedIntPoint(absolute.p3())));
- quad->setP4(frameView.contentsToRootView(roundedIntPoint(absolute.p4())));
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h (276396 => 276397)
--- trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h 2021-04-21 23:01:22 UTC (rev 276396)
+++ trunk/Source/WebCore/inspector/agents/InspectorTimelineAgent.h 2021-04-21 23:06:48 UTC (rev 276397)
@@ -190,8 +190,6 @@
void addRecordToTimeline(Ref<JSON::Object>&&, TimelineRecordType);
- void localToPageQuad(const RenderObject&, const LayoutRect&, FloatQuad*);
-
std::unique_ptr<Inspector::TimelineFrontendDispatcher> m_frontendDispatcher;
RefPtr<Inspector::TimelineBackendDispatcher> m_backendDispatcher;
Page& m_inspectedPage;
Modified: trunk/Source/WebCore/platform/ScrollView.cpp (276396 => 276397)
--- trunk/Source/WebCore/platform/ScrollView.cpp 2021-04-21 23:01:22 UTC (rev 276396)
+++ trunk/Source/WebCore/platform/ScrollView.cpp 2021-04-21 23:06:48 UTC (rev 276397)
@@ -26,6 +26,7 @@
#include "config.h"
#include "ScrollView.h"
+#include "FloatQuad.h"
#include "GraphicsContext.h"
#include "GraphicsLayer.h"
#include "HostWindow.h"
@@ -984,6 +985,30 @@
return convertToRootView(contentsToView(contentsRect));
}
+FloatQuad ScrollView::rootViewToContents(const FloatQuad& quad) const
+{
+ // FIXME: This could be optimized by adding and adopting a version of rootViewToContents() that
+ // maps multiple FloatPoints to content coordinates at the same time.
+ auto result = quad;
+ result.setP1(rootViewToContents(result.p1()));
+ result.setP2(rootViewToContents(result.p2()));
+ result.setP3(rootViewToContents(result.p3()));
+ result.setP4(rootViewToContents(result.p4()));
+ return result;
+}
+
+FloatQuad ScrollView::contentsToRootView(const FloatQuad& quad) const
+{
+ // FIXME: This could be optimized by adding and adopting a version of contentsToRootView() that
+ // maps multiple FloatPoints to root view coordinates at the same time.
+ auto result = quad;
+ result.setP1(contentsToRootView(result.p1()));
+ result.setP2(contentsToRootView(result.p2()));
+ result.setP3(contentsToRootView(result.p3()));
+ result.setP4(contentsToRootView(result.p4()));
+ return result;
+}
+
IntPoint ScrollView::rootViewToTotalContents(const IntPoint& rootViewPoint) const
{
if (delegatesScrolling())
Modified: trunk/Source/WebCore/platform/ScrollView.h (276396 => 276397)
--- trunk/Source/WebCore/platform/ScrollView.h 2021-04-21 23:01:22 UTC (rev 276396)
+++ trunk/Source/WebCore/platform/ScrollView.h 2021-04-21 23:06:48 UTC (rev 276397)
@@ -58,6 +58,7 @@
namespace WebCore {
class EventRegionContext;
+class FloatQuad;
class HostWindow;
class LegacyTileCache;
class Scrollbar;
@@ -299,6 +300,8 @@
WEBCORE_EXPORT IntRect contentsToRootView(const IntRect&) const;
WEBCORE_EXPORT FloatRect rootViewToContents(const FloatRect&) const;
WEBCORE_EXPORT FloatRect contentsToRootView(const FloatRect&) const;
+ WEBCORE_EXPORT FloatQuad rootViewToContents(const FloatQuad&) const;
+ WEBCORE_EXPORT FloatQuad contentsToRootView(const FloatQuad&) const;
IntPoint viewToContents(const IntPoint&) const;
IntPoint contentsToView(const IntPoint&) const;
Modified: trunk/Source/WebKit/ChangeLog (276396 => 276397)
--- trunk/Source/WebKit/ChangeLog 2021-04-21 23:01:22 UTC (rev 276396)
+++ trunk/Source/WebKit/ChangeLog 2021-04-21 23:06:48 UTC (rev 276397)
@@ -1,3 +1,20 @@
+2021-04-21 Wenson Hsieh <[email protected]>
+
+ Introduce helper methods to map FloatQuads to and from content and root view coordinates
+ https://bugs.webkit.org/show_bug.cgi?id=224883
+
+ Reviewed by Tim Horton.
+
+ Use the new helper methods.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::convertContentToRootView):
+ (WebKit::WebPage::sendTapHighlightForNodeIfNecessary):
+
+ Note that we previously rounded absolute quads to the nearest integer when mapping through root view
+ coordinates. From <https://bugs.webkit.org/show_bug.cgi?id=128277#c2>, this seemed unintentional to begin with,
+ and we should be able to use the `FloatPoint` conversion methods instead.
+
2021-04-21 Aditya Keerthi <[email protected]>
[iOS] Fix internal builds after r276325
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (276396 => 276397)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-04-21 23:01:22 UTC (rev 276396)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-04-21 23:06:48 UTC (rev 276397)
@@ -260,14 +260,8 @@
static void convertContentToRootView(const FrameView& view, Vector<SelectionGeometry>& geometries)
{
- for (auto& geometry : geometries) {
- auto convertedQuad = geometry.quad();
- convertedQuad.setP1(view.contentsToRootView(convertedQuad.p1()));
- convertedQuad.setP2(view.contentsToRootView(convertedQuad.p2()));
- convertedQuad.setP3(view.contentsToRootView(convertedQuad.p3()));
- convertedQuad.setP4(view.contentsToRootView(convertedQuad.p4()));
- geometry.setQuad(convertedQuad);
- }
+ for (auto& geometry : geometries)
+ geometry.setQuad(view.contentsToRootView(geometry.quad()));
}
void WebPage::getPlatformEditorState(Frame& frame, EditorState& result) const
@@ -1078,13 +1072,8 @@
Color highlightColor = renderer->style().tapHighlightColor();
if (!node->document().frame()->isMainFrame()) {
FrameView* view = node->document().frame()->view();
- for (size_t i = 0; i < quads.size(); ++i) {
- FloatQuad& currentQuad = quads[i];
- currentQuad.setP1(view->contentsToRootView(roundedIntPoint(currentQuad.p1())));
- currentQuad.setP2(view->contentsToRootView(roundedIntPoint(currentQuad.p2())));
- currentQuad.setP3(view->contentsToRootView(roundedIntPoint(currentQuad.p3())));
- currentQuad.setP4(view->contentsToRootView(roundedIntPoint(currentQuad.p4())));
- }
+ for (size_t i = 0; i < quads.size(); ++i)
+ quads[i] = view->contentsToRootView(quads[i]);
}
RoundedRect::Radii borderRadii;