Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
browser(webkit): undo ios changes to frame.mm (#7774)
Joel Einbinderde5df934d481
diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBERindex 77ba4c95fe..cd1a665480 100644--- a/browser_patches/webkit/BUILD_NUMBER+++ b/browser_patches/webkit/BUILD_NUMBER@@ -1,2 +1,2 @@-1517-Changed: [email protected] Wed Jul 21 17:35:38 CEST 2021+1518+Changed: [email protected] Wed 21 Jul 2021 05:45:33 PM PDTdiff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diffindex ff0fa1ebb1..318c275775 100644--- a/browser_patches/webkit/patches/bootstrap.diff+++ b/browser_patches/webkit/patches/bootstrap.diff@@ -5732,7 +5732,7 @@ index 7b77e407ee5d08ab3784d0899cfa33f0177f0648..0060ebfb1128cc5eb28baa5ecf4538a2request.setHTTPHeaderField(HTTPHeaderName::Accept, "text/event-stream");request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "no-cache");diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp-index 7054acc90214eb817bd784298ce77f76d32c5dee..9d351c8950842f5c6a7e3871ee6b6f5174a69f2a 100644+index 7054acc90214eb817bd784298ce77f76d32c5dee..5a8d7af631d7f573575f633b906a0798103199c6 100644--- a/Source/WebCore/page/Frame.cpp+++ b/Source/WebCore/page/Frame.cpp@@ -39,6 +39,7 @@@@ -5768,10 +5768,12 @@ index 7054acc90214eb817bd784298ce77f76d32c5dee..9d351c8950842f5c6a7e3871ee6b6f51return 0;}#endif // ENABLE(ORIENTATION_EVENTS)-@@ -1139,6 +1142,358 @@ DataDetectionResultsStorage& Frame::dataDetectionResults()+@@ -1139,6 +1142,362 @@ DataDetectionResultsStorage& Frame::dataDetectionResults()#endif++#ifdef !PLATFORM(IOS_FAMILY)+++void Frame::betterApproximateNode(const IntPoint& testPoint, const NodeQualifier& nodeQualifierFunction, Node*& best, Node* failedNode, IntPoint& bestPoint, IntRect& bestRect, const IntRect& testRect)+{+ IntRect candidateRect;@@ -6123,6 +6125,8 @@ index 7054acc90214eb817bd784298ce77f76d32c5dee..9d351c8950842f5c6a7e3871ee6b6f51+ FloatPoint adjustedViewportLocation;+ return qualifyingNodeAtViewportLocation(viewportLocation, adjustedViewportLocation, WTFMove(ancestorRespondingToScrollWheelEvents), ShouldApproximate::No);+}++++#endif // !PLATFORM(IOS_FAMILY)+} // namespace WebCore@@ -6574,365 +6578,6 @@ index fc85fffa9b20cf5d3a2cff89b7d38ecf84aa0ff6..1070a1973d0ea23c6781df4269fc4349bool isAllowed = true;for (auto& policy : m_policies) {if (const ContentSecurityPolicyDirective* violatedDirective = (policy.get()->*predicate)(std::forward<Args>(args)...)) {-diff --git a/Source/WebCore/page/ios/FrameIOS.mm b/Source/WebCore/page/ios/FrameIOS.mm-index a4999e21fa2d912dc32ee39a7d1d32eefa2083c7..b97227e21bf9e7166980c20d2efdc24ea28058a2 100644---- a/Source/WebCore/page/ios/FrameIOS.mm-+++ b/Source/WebCore/page/ios/FrameIOS.mm-@@ -226,354 +226,6 @@ CGRect Frame::renderRectForPoint(CGPoint point, bool* isReplaced, float* fontSiz- return CGRectZero;- }---void Frame::betterApproximateNode(const IntPoint& testPoint, const NodeQualifier& nodeQualifierFunction, Node*& best, Node* failedNode, IntPoint& bestPoint, IntRect& bestRect, const IntRect& testRect)--{-- IntRect candidateRect;-- constexpr OptionSet<HitTestRequest::Type> hitType { HitTestRequest::Type::ReadOnly, HitTestRequest::Type::Active, HitTestRequest::Type::DisallowUserAgentShadowContent, HitTestRequest::Type::AllowVisibleChildFrameContentOnly };-- auto* candidate = nodeQualifierFunction(eventHandler().hitTestResultAtPoint(testPoint, hitType), failedNode, &candidateRect);---- // Bail if we have no candidate, or the candidate is already equal to our current best node,-- // or our candidate is the avoidedNode and there is a current best node.-- if (!candidate || candidate == best)-- return;---- // The document should never be considered the best alternative.-- if (candidate->isDocumentNode())-- return;---- if (best) {-- IntRect bestIntersect = intersection(testRect, bestRect);-- IntRect candidateIntersect = intersection(testRect, candidateRect);-- // if the candidate intersection is smaller than the current best intersection, bail.-- if (candidateIntersect.width() * candidateIntersect.height() <= bestIntersect.width() * bestIntersect.height())-- return;-- }---- // At this point we either don't have a previous best, or our current candidate has a better intersection.-- best = candidate;-- bestPoint = testPoint;-- bestRect = candidateRect;--}----bool Frame::hitTestResultAtViewportLocation(const FloatPoint& viewportLocation, HitTestResult& hitTestResult, IntPoint& center)--{-- if (!m_doc || !m_doc->renderView())-- return false;---- FrameView* view = m_view.get();-- if (!view)-- return false;---- center = view->windowToContents(roundedIntPoint(viewportLocation));-- constexpr OptionSet<HitTestRequest::Type> hitType { HitTestRequest::Type::ReadOnly, HitTestRequest::Type::Active, HitTestRequest::Type::DisallowUserAgentShadowContent, HitTestRequest::Type::AllowVisibleChildFrameContentOnly };-- hitTestResult = eventHandler().hitTestResultAtPoint(center, hitType);-- return true;--}----Node* Frame::qualifyingNodeAtViewportLocation(const FloatPoint& viewportLocation, FloatPoint& adjustedViewportLocation, const NodeQualifier& nodeQualifierFunction, ShouldApproximate shouldApproximate, ShouldFindRootEditableElement shouldFindRootEditableElement)--{-- adjustedViewportLocation = viewportLocation;---- IntPoint testCenter;-- HitTestResult candidateInfo;-- if (!hitTestResultAtViewportLocation(viewportLocation, candidateInfo, testCenter))-- return nullptr;---- IntPoint bestPoint = testCenter;---- // We have the candidate node at the location, check whether it or one of its ancestors passes-- // the qualifier function, which typically checks if the node responds to a particular event type.-- Node* approximateNode = nodeQualifierFunction(candidateInfo, 0, 0);---- if (shouldFindRootEditableElement == ShouldFindRootEditableElement::Yes && approximateNode && approximateNode->isContentEditable()) {-- // If we are in editable content, we look for the root editable element.-- approximateNode = approximateNode->rootEditableElement();-- // If we have a focusable node, there is no need to approximate.-- if (approximateNode)-- shouldApproximate = ShouldApproximate::No;-- }---- float scale = page() ? page()->pageScaleFactor() : 1;-- float ppiFactor = screenPPIFactor();---- static const float unscaledSearchRadius = 15;-- int searchRadius = static_cast<int>(unscaledSearchRadius * ppiFactor / scale);---- if (approximateNode && shouldApproximate == ShouldApproximate::Yes) {-- const float testOffsets[] = {-- -.3f, -.3f,-- -.6f, -.6f,-- +.3f, +.3f,-- -.9f, -.9f,-- };---- Node* originalApproximateNode = approximateNode;-- for (unsigned n = 0; n < WTF_ARRAY_LENGTH(testOffsets); n += 2) {-- IntSize testOffset(testOffsets[n] * searchRadius, testOffsets[n + 1] * searchRadius);-- IntPoint testPoint = testCenter + testOffset;---- constexpr OptionSet<HitTestRequest::Type> hitType { HitTestRequest::Type::ReadOnly, HitTestRequest::Type::Active, HitTestRequest::Type::DisallowUserAgentShadowContent, HitTestRequest::Type::AllowChildFrameContent };-- auto candidateInfo = eventHandler().hitTestResultAtPoint(testPoint, hitType);-- Node* candidateNode = nodeQualifierFunction(candidateInfo, 0, 0);-- if (candidateNode && candidateNode->isDescendantOf(originalApproximateNode)) {-- approximateNode = candidateNode;-- bestPoint = testPoint;-- break;-- }-- }-- } else if (!approximateNode && shouldApproximate == ShouldApproximate::Yes) {-- // Grab the closest parent element of our failed candidate node.-- Node* candidate = candidateInfo.innerNode();-- Node* failedNode = candidate;---- while (candidate && !candidate->isElementNode())-- candidate = candidate->parentInComposedTree();---- if (candidate)-- failedNode = candidate;---- // The center point was tested earlier.-- const float testOffsets[] = {-- -.3f, -.3f,-- +.3f, -.3f,-- -.3f, +.3f,-- +.3f, +.3f,-- -.6f, -.6f,-- +.6f, -.6f,-- -.6f, +.6f,-- +.6f, +.6f,-- -1.f, 0,-- +1.f, 0,-- 0, +1.f,-- 0, -1.f,-- };-- IntRect bestFrame;-- IntRect testRect(testCenter, IntSize());-- testRect.inflate(searchRadius);-- int currentTestRadius = 0;-- for (unsigned n = 0; n < WTF_ARRAY_LENGTH(testOffsets); n += 2) {-- IntSize testOffset(testOffsets[n] * searchRadius, testOffsets[n + 1] * searchRadius);-- IntPoint testPoint = testCenter + testOffset;-- int testRadius = std::max(abs(testOffset.width()), abs(testOffset.height()));-- if (testRadius > currentTestRadius) {-- // Bail out with the best match within a radius-- currentTestRadius = testRadius;-- if (approximateNode)-- break;-- }-- betterApproximateNode(testPoint, nodeQualifierFunction, approximateNode, failedNode, bestPoint, bestFrame, testRect);-- }-- }---- if (approximateNode) {-- IntPoint p = m_view->contentsToWindow(bestPoint);-- adjustedViewportLocation = p;-- if (shouldFindRootEditableElement == ShouldFindRootEditableElement::Yes && approximateNode->isContentEditable()) {-- // When in editable content, look for the root editable node again,-- // since this could be the node found with the approximation.-- approximateNode = approximateNode->rootEditableElement();-- }-- }---- return approximateNode;--}----Node* Frame::deepestNodeAtLocation(const FloatPoint& viewportLocation)--{-- IntPoint center;-- HitTestResult hitTestResult;-- if (!hitTestResultAtViewportLocation(viewportLocation, hitTestResult, center))-- return nullptr;---- return hitTestResult.innerNode();--}----static bool nodeIsMouseFocusable(Node& node)--{-- if (!is<Element>(node))-- return false;---- auto& element = downcast<Element>(node);-- if (element.isMouseFocusable())-- return true;---- if (auto shadowRoot = makeRefPtr(element.shadowRoot())) {-- if (shadowRoot->delegatesFocus()) {-- for (auto& node : composedTreeDescendants(element)) {-- if (is<Element>(node) && downcast<Element>(node).isMouseFocusable())-- return true;-- }-- }-- }---- return false;--}----static bool nodeWillRespondToMouseEvents(Node& node)--{-- return node.willRespondToMouseClickEvents() || node.willRespondToMouseMoveEvents() || nodeIsMouseFocusable(node);--}----Node* Frame::approximateNodeAtViewportLocationLegacy(const FloatPoint& viewportLocation, FloatPoint& adjustedViewportLocation)--{-- // This function is only used for UIWebView.-- auto&& ancestorRespondingToClickEvents = [](const HitTestResult& hitTestResult, Node* terminationNode, IntRect* nodeBounds) -> Node* {-- bool bodyHasBeenReached = false;-- bool pointerCursorStillValid = true;---- if (nodeBounds)-- *nodeBounds = IntRect();---- auto node = hitTestResult.innerNode();-- if (!node)-- return nullptr;---- Node* pointerCursorNode = nullptr;-- for (; node && node != terminationNode; node = node->parentInComposedTree()) {-- // We only accept pointer nodes before reaching the body tag.-- if (node->hasTagName(HTMLNames::bodyTag)) {-- // Make sure we cover the case of an empty editable body.-- if (!pointerCursorNode && node->isContentEditable())-- pointerCursorNode = node;-- bodyHasBeenReached = true;-- pointerCursorStillValid = false;-- }---- // If we already have a pointer, and we reach a table, don't accept it.-- if (pointerCursorNode && (node->hasTagName(HTMLNames::tableTag) || node->hasTagName(HTMLNames::tbodyTag)))-- pointerCursorStillValid = false;---- // If we haven't reached the body, and we are still paying attention to pointer cursors, and the node has a pointer cursor.-- if (pointerCursorStillValid && node->renderStyle() && node->renderStyle()->cursor() == CursorType::Pointer)-- pointerCursorNode = node;-- else if (pointerCursorNode) {-- // We want the lowest unbroken chain of pointer cursors.-- pointerCursorStillValid = false;-- }---- if (nodeWillRespondToMouseEvents(*node)) {-- // If we're at the body or higher, use the pointer cursor node (which may be null).-- if (bodyHasBeenReached)-- node = pointerCursorNode;---- // If we are interested about the frame, use it.-- if (nodeBounds) {-- // This is a check to see whether this node is an area element. The only way this can happen is if this is the first check.-- if (node == hitTestResult.innerNode() && node != hitTestResult.innerNonSharedNode() && is<HTMLAreaElement>(*node))-- *nodeBounds = snappedIntRect(downcast<HTMLAreaElement>(*node).computeRect(hitTestResult.innerNonSharedNode()->renderer()));-- else if (node && node->renderer())-- *nodeBounds = node->renderer()->absoluteBoundingBoxRect(true);-- }---- return node;-- }-- }---- return nullptr;-- };---- return qualifyingNodeAtViewportLocation(viewportLocation, adjustedViewportLocation, WTFMove(ancestorRespondingToClickEvents), ShouldApproximate::Yes);--}----static inline NodeQualifier ancestorRespondingToClickEventsNodeQualifier(SecurityOrigin* securityOrigin = nullptr)--{-- return [securityOrigin](const HitTestResult& hitTestResult, Node* terminationNode, IntRect* nodeBounds) -> Node* {-- if (nodeBounds)-- *nodeBounds = IntRect();---- auto node = hitTestResult.innerNode();-- if (!node || (securityOrigin && !securityOrigin->isSameOriginAs(node->document().securityOrigin())))-- return nullptr;---- for (; node && node != terminationNode; node = node->parentInComposedTree()) {-- if (nodeWillRespondToMouseEvents(*node)) {-- // If we are interested about the frame, use it.-- if (nodeBounds) {-- // This is a check to see whether this node is an area element. The only way this can happen is if this is the first check.-- if (node == hitTestResult.innerNode() && node != hitTestResult.innerNonSharedNode() && is<HTMLAreaElement>(*node))-- *nodeBounds = snappedIntRect(downcast<HTMLAreaElement>(*node).computeRect(hitTestResult.innerNonSharedNode()->renderer()));-- else if (node && node->renderer())-- *nodeBounds = node->renderer()->absoluteBoundingBoxRect(true);-- }---- return node;-- }-- }---- return nullptr;-- };--}----Node* Frame::nodeRespondingToClickEvents(const FloatPoint& viewportLocation, FloatPoint& adjustedViewportLocation, SecurityOrigin* securityOrigin)--{-- return qualifyingNodeAtViewportLocation(viewportLocation, adjustedViewportLocation, ancestorRespondingToClickEventsNodeQualifier(securityOrigin), ShouldApproximate::Yes);--}----Node* Frame::nodeRespondingToDoubleClickEvent(const FloatPoint& viewportLocation, FloatPoint& adjustedViewportLocation)--{-- auto&& ancestorRespondingToDoubleClickEvent = [](const HitTestResult& hitTestResult, Node* terminationNode, IntRect* nodeBounds) -> Node* {-- if (nodeBounds)-- *nodeBounds = IntRect();---- auto* node = hitTestResult.innerNode();-- if (!node)-- return nullptr;---- for (; node && node != terminationNode; node = node->parentInComposedTree()) {-- if (!node->hasEventListeners(eventNames().dblclickEvent))-- continue;--#if ENABLE(TOUCH_EVENTS)-- if (!node->allowsDoubleTapGesture())-- continue;--#endif-- if (nodeBounds && node->renderer())-- *nodeBounds = node->renderer()->absoluteBoundingBoxRect(true);-- return node;-- }-- return nullptr;-- };---- return qualifyingNodeAtViewportLocation(viewportLocation, adjustedViewportLocation, WTFMove(ancestorRespondingToDoubleClickEvent), ShouldApproximate::Yes);--}----Node* Frame::nodeRespondingToInteraction(const FloatPoint& viewportLocation, FloatPoint& adjustedViewportLocation)--{-- return qualifyingNodeAtViewportLocation(viewportLocation, adjustedViewportLocation, ancestorRespondingToClickEventsNodeQualifier(), ShouldApproximate::Yes, ShouldFindRootEditableElement::No);--}----Node* Frame::nodeRespondingToScrollWheelEvents(const FloatPoint& viewportLocation)--{-- auto&& ancestorRespondingToScrollWheelEvents = [](const HitTestResult& hitTestResult, Node* terminationNode, IntRect* nodeBounds) -> Node* {-- if (nodeBounds)-- *nodeBounds = IntRect();---- Node* scrollingAncestor = nullptr;-- for (Node* node = hitTestResult.innerNode(); node && node != terminationNode && !node->hasTagName(HTMLNames::bodyTag); node = node->parentNode()) {-- RenderObject* renderer = node->renderer();-- if (!renderer)-- continue;---- if ((renderer->isTextField() || renderer->isTextArea()) && downcast<RenderTextControl>(*renderer).canScroll()) {-- scrollingAncestor = node;-- continue;-- }---- auto& style = renderer->style();---- if (renderer->hasNonVisibleOverflow()-- && (style.overflowY() == Overflow::Auto || style.overflowY() == Overflow::Scroll-- || style.overflowX() == Overflow::Auto || style.overflowX() == Overflow::Scroll)) {-- scrollingAncestor = node;-- }-- }---- return scrollingAncestor;-- };---- FloatPoint adjustedViewportLocation;-- return qualifyingNodeAtViewportLocation(viewportLocation, adjustedViewportLocation, WTFMove(ancestorRespondingToScrollWheelEvents), ShouldApproximate::No);--}--- int Frame::preferredHeight() const- {- Document* document = this->document();diff --git a/Source/WebCore/page/wpe/DragControllerWPE.cpp b/Source/WebCore/page/wpe/DragControllerWPE.cppnew file mode 100644index 0000000000000000000000000000000000000000..3dedfa855f990643e3e7bbe7754abca4e88a0f1c