Title: [176338] branches/safari-600.3-branch/Source

Diff

Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-11-19 22:03:35 UTC (rev 176338)
@@ -1,3 +1,21 @@
+2014-11-19  Dana Burkart  <[email protected]>
+
+        Merge r176221. rdar://problem/18991369
+
+    2014-11-17  Tim Horton  <[email protected]>
+
+            DataDetectors PageOverlay callbacks can come in to the wrong overlay
+            https://bugs.webkit.org/show_bug.cgi?id=138801
+            <rdar://problem/18991369>
+
+            Reviewed by Anders Carlsson.
+
+            * page/PageOverlay.cpp:
+            (WebCore::generatePageOverlayID):
+            (WebCore::PageOverlay::PageOverlay):
+            * page/PageOverlay.h:
+            Give each PageOverlay a unique ID.
+
 2014-11-05  Simon Fraser  <[email protected]>
 
         Fix crash introduced in r175656

Modified: branches/safari-600.3-branch/Source/WebCore/page/PageOverlay.cpp (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebCore/page/PageOverlay.cpp	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebCore/page/PageOverlay.cpp	2014-11-19 22:03:35 UTC (rev 176338)
@@ -40,6 +40,12 @@
 static const double fadeAnimationDuration = 0.2;
 static const double fadeAnimationFrameRate = 30;
 
+static PageOverlay::PageOverlayID generatePageOverlayID()
+{
+    static PageOverlay::PageOverlayID pageOverlayID;
+    return ++pageOverlayID;
+}
+
 PassRefPtr<PageOverlay> PageOverlay::create(Client& client, OverlayType overlayType)
 {
     return adoptRef(new PageOverlay(client, overlayType));
@@ -55,6 +61,7 @@
     , m_fractionFadedIn(1)
     , m_overlayType(overlayType)
     , m_backgroundColor(Color::transparent)
+    , m_pageOverlayID(generatePageOverlayID())
 {
 }
 

Modified: branches/safari-600.3-branch/Source/WebCore/page/PageOverlay.h (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebCore/page/PageOverlay.h	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebCore/page/PageOverlay.h	2014-11-19 22:03:35 UTC (rev 176338)
@@ -74,6 +74,9 @@
 
     PageOverlayController* controller() const;
 
+    typedef uint64_t PageOverlayID;
+    virtual PageOverlayID pageOverlayID() const { return m_pageOverlayID; }
+
     void setPage(Page*);
     void setNeedsDisplay(const IntRect& dirtyRect);
     void setNeedsDisplay();
@@ -134,6 +137,7 @@
     IntRect m_overrideFrame;
 
     RGBA32 m_backgroundColor;
+    PageOverlayID m_pageOverlayID;
 };
 
 } // namespace WebKit

Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-11-19 22:03:35 UTC (rev 176338)
@@ -1,5 +1,43 @@
 2014-11-19  Dana Burkart  <[email protected]>
 
+        Merge r176221. rdar://problem/18991369
+
+    2014-11-17  Tim Horton  <[email protected]>
+
+            DataDetectors PageOverlay callbacks can come in to the wrong overlay
+            https://bugs.webkit.org/show_bug.cgi?id=138801
+            <rdar://problem/18991369>
+
+            Reviewed by Anders Carlsson.
+
+            We can call dataDetectorsDidHideUI on the wrong (or no) PageOverlay,
+            because it's possible to have another performActionMenuHitTestAtLocation
+            between the first one and the dataDetectorsDid*UI that correspond to it.
+
+            To make sure that the callbacks come to the right PageOverlay, plumb
+            an integer ID through all of the callbacks and find the overlay based on that.
+
+            * Shared/mac/ActionMenuHitTestResult.h:
+            Store the ID of the PageOverlay that overrode data detection.
+
+            * UIProcess/mac/WKActionMenuController.mm:
+            (-[WKActionMenuController _defaultMenuItemsForDataDetectedText]):
+            Send the ID back to the Web process when replying from DD callbacks.
+
+            * WebProcess/WebPage/WebPage.h:
+            * WebProcess/WebPage/WebPage.messages.in:
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+            (WebKit::WebPage::performActionMenuHitTestAtLocation):
+            Store the ID of the PageOverlay that overrode data detection instead of
+            keeping the PageOverlay itself.
+
+            (WebKit::WebPage::dataDetectorsDidPresentUI):
+            (WebKit::WebPage::dataDetectorsDidChangeUI):
+            (WebKit::WebPage::dataDetectorsDidHideUI):
+            Find and reply to the correct page overlay.
+
+2014-11-19  Dana Burkart  <[email protected]>
+
         Merge r176220. rdar://problem/18944893
 
     2014-11-17  Beth Dakin  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h	2014-11-19 22:03:35 UTC (rev 176338)
@@ -30,6 +30,7 @@
 #include "TextIndicator.h"
 #include "WebHitTestResult.h"
 #include <WebCore/FloatRect.h>
+#include <WebCore/PageOverlay.h>
 #include <wtf/text/WTFString.h>
 
 OBJC_CLASS DDActionContext;
@@ -54,6 +55,7 @@
     RetainPtr<DDActionContext> actionContext;
     WebCore::FloatRect detectedDataBoundingBox;
     RefPtr<TextIndicator> detectedDataTextIndicator;
+    WebCore::PageOverlay::PageOverlayID detectedDataOriginatingPageOverlay;
 };
 
 } // namespace WebKit

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-11-19 22:03:35 UTC (rev 176338)
@@ -578,14 +578,15 @@
 
     // Ref our WebPageProxy for use in the blocks below.
     RefPtr<WebPageProxy> page = _page;
+    PageOverlay::PageOverlayID overlayID = _hitTestResult.detectedDataOriginatingPageOverlay;
     _currentActionContext = [actionContext contextForView:_wkView altMode:YES interactionStartedHandler:^() {
-        page->send(Messages::WebPage::DataDetectorsDidPresentUI());
+        page->send(Messages::WebPage::DataDetectorsDidPresentUI(overlayID));
     } interactionChangedHandler:^() {
         [self _showTextIndicator];
-        page->send(Messages::WebPage::DataDetectorsDidChangeUI());
+        page->send(Messages::WebPage::DataDetectorsDidChangeUI(overlayID));
     } interactionStoppedHandler:^() {
         [self _hideTextIndicator];
-        page->send(Messages::WebPage::DataDetectorsDidHideUI());
+        page->send(Messages::WebPage::DataDetectorsDidHideUI(overlayID));
     }];
 
     [_currentActionContext setHighlightFrame:[_wkView.window convertRectToScreen:[_wkView convertRect:_hitTestResult.detectedDataBoundingBox toView:nil]]];

Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-11-19 22:03:35 UTC (rev 176338)
@@ -52,6 +52,7 @@
 #include <WebCore/IntRect.h>
 #include <WebCore/IntSizeHash.h>
 #include <WebCore/Page.h>
+#include <WebCore/PageOverlay.h>
 #include <WebCore/PageVisibilityState.h>
 #include <WebCore/ScrollTypes.h>
 #include <WebCore/TextChecking.h>
@@ -1045,9 +1046,9 @@
     void selectLastActionMenuRange();
     void focusAndSelectLastActionMenuHitTestResult();
 
-    void dataDetectorsDidPresentUI();
-    void dataDetectorsDidChangeUI();
-    void dataDetectorsDidHideUI();
+    void dataDetectorsDidPresentUI(WebCore::PageOverlay::PageOverlayID);
+    void dataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID);
+    void dataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID);
 #endif
 
     uint64_t m_pageID;

Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2014-11-19 22:03:35 UTC (rev 176338)
@@ -391,8 +391,8 @@
     PerformActionMenuHitTestAtLocation(WebCore::FloatPoint location)
     SelectLastActionMenuRange()
     FocusAndSelectLastActionMenuHitTestResult()
-    DataDetectorsDidPresentUI()
-    DataDetectorsDidChangeUI()
-    DataDetectorsDidHideUI()
+    DataDetectorsDidPresentUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
+    DataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
+    DataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
 #endif
 }

Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (176337 => 176338)


--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-11-19 21:57:10 UTC (rev 176337)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-11-19 22:03:35 UTC (rev 176338)
@@ -969,8 +969,6 @@
 
 void WebPage::performActionMenuHitTestAtLocation(WebCore::FloatPoint locationInViewCooordinates)
 {
-    m_lastActionMenuHitPageOverlay = nullptr;
-
     layoutIfNeeded();
 
     MainFrame& mainFrame = corePage()->mainFrame();
@@ -1034,8 +1032,8 @@
 
         actionMenuResult.detectedDataBoundingBox = detectedDataBoundingBox;
         actionMenuResult.detectedDataTextIndicator = TextIndicator::createWithRange(*mainResultRange);
+        actionMenuResult.detectedDataOriginatingPageOverlay = overlay->pageOverlayID();
         m_lastActionMenuRangeForSelection = mainResultRange;
-        m_lastActionMenuHitPageOverlay = webOverlay;
 
         break;
     }
@@ -1095,23 +1093,40 @@
     element->document().frame()->selection().setSelection(position);
 }
 
-void WebPage::dataDetectorsDidPresentUI()
+void WebPage::dataDetectorsDidPresentUI(PageOverlay::PageOverlayID overlayID)
 {
-    if (m_lastActionMenuHitPageOverlay)
-        m_lastActionMenuHitPageOverlay->dataDetectorsDidPresentUI();
+    MainFrame& mainFrame = corePage()->mainFrame();
+    for (const auto& overlay : mainFrame.pageOverlayController().pageOverlays()) {
+        if (overlay->pageOverlayID() == overlayID) {
+            if (WebPageOverlay* webOverlay = WebPageOverlay::fromCoreOverlay(*overlay))
+                webOverlay->dataDetectorsDidPresentUI();
+            return;
+        }
+    }
 }
 
-void WebPage::dataDetectorsDidChangeUI()
+void WebPage::dataDetectorsDidChangeUI(PageOverlay::PageOverlayID overlayID)
 {
-    if (m_lastActionMenuHitPageOverlay)
-        m_lastActionMenuHitPageOverlay->dataDetectorsDidChangeUI();
+    MainFrame& mainFrame = corePage()->mainFrame();
+    for (const auto& overlay : mainFrame.pageOverlayController().pageOverlays()) {
+        if (overlay->pageOverlayID() == overlayID) {
+            if (WebPageOverlay* webOverlay = WebPageOverlay::fromCoreOverlay(*overlay))
+                webOverlay->dataDetectorsDidChangeUI();
+            return;
+        }
+    }
 }
 
-void WebPage::dataDetectorsDidHideUI()
+void WebPage::dataDetectorsDidHideUI(PageOverlay::PageOverlayID overlayID)
 {
-    if (m_lastActionMenuHitPageOverlay)
-        m_lastActionMenuHitPageOverlay->dataDetectorsDidHideUI();
-    m_lastActionMenuHitPageOverlay = nil;
+    MainFrame& mainFrame = corePage()->mainFrame();
+    for (const auto& overlay : mainFrame.pageOverlayController().pageOverlays()) {
+        if (overlay->pageOverlayID() == overlayID) {
+            if (WebPageOverlay* webOverlay = WebPageOverlay::fromCoreOverlay(*overlay))
+                webOverlay->dataDetectorsDidHideUI();
+            return;
+        }
+    }
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to