<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>171841</bug_id>
          
          <creation_ts>2017-05-08 18:29:18 -0700</creation_ts>
          <short_desc>In a WKWebView app, window.screenX and window.screenY are garbage</short_desc>
          <delta_ts>2021-12-14 11:16:57 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit2</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=234256</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aideen</cc>
    
    <cc>sam</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1306190</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-08 18:29:18 -0700</bug_when>
    <thetext>In a WKWebView app on macOS, if a page reads window.screenX/window.screenY, they get back nonsensical data. This is because UIClient::windowFrame() returns an empty rect, which we then send through coordinate-flipping code. windowFrame() needs to work for the Objective-C API.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1306205</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-08 18:44:32 -0700</bug_when>
    <thetext>We may have done this on purpose for privacy reasons.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1306206</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-08 18:44:54 -0700</bug_when>
    <thetext>diff --git a/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h b/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h
index d9381d3d19b4f4533b02a0e04400da81f61dcb84..61fe613cbbddc7142ccb73e3aa360a4f280041fe 100644
--- a/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h
+++ b/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h
@@ -88,6 +88,7 @@ private:
         void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&amp;, const WTF::String&amp;, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&amp;, Function&lt;void (const WTF::String&amp;)&gt;&amp;&amp; completionHandler) override;
         void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const WTF::String&amp; databaseName, const WTF::String&amp; displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, Function&lt;void (unsigned long long)&gt;&amp;&amp; completionHandler) override;
         void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&amp;, uint64_t currentQuota, uint64_t totalBytesNeeded, Function&lt;void (unsigned long long)&gt;&amp;&amp; completionHandler) override;
+        WebCore::FloatRect windowFrame(WebKit::WebPageProxy*) override;
 #if PLATFORM(MAC)
         bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebCore::SecurityOriginData&amp;, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
 #endif
diff --git a/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm b/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
index 4f21e823301c3c6adcd39d6ce0b077ce7c4ca5b1..3a8e3c4ce5ac1a07d386898c1ef734b9d2cd6cb6 100644
--- a/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
+++ b/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
@@ -529,6 +529,15 @@ void UIDelegate::UIClient::reachedApplicationCacheOriginQuota(WebPageProxy*, con
     }).get()];
 }
 
+WebCore::FloatRect UIDelegate::UIClient::windowFrame(WebKit::WebPageProxy*)
+{
+    WKWebView *webView = m_uiDelegate.m_webView;
+    if (!webView.window)
+        return { };
+        
+    return webView.window.frame;
+}
+
 void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy)
 {
     ASSERT_ARG(webFrameProxy, webFrameProxy);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1339645</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-08-17 11:14:25 -0700</bug_when>
    <thetext>&lt;rdar://problem/33945134&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1824054</commentid>
    <comment_count>4</comment_count>
    <who name="Aidin NasiriShargh">aideen</who>
    <bug_when>2021-12-14 11:16:57 -0800</bug_when>
    <thetext>I am coming from https://bugs.webkit.org/show_bug.cgi?id=234256 that I filed yesterday.

As I mentioned there (and in my StackOverflow at https://stackoverflow.com/q/70339906) I can calculate these values on any touch event (MouseEvent.screenY - MouseEvent.clientY, or so).

So, it doesn&apos;t make much sense to me that it&apos;s not returned for &quot;privacy reasons&quot; only until the user touches anywhere on the page (even for scrolling), just once.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>