Phone number highlights should always be visible if the mouse hovers over.
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / ServicesOverlayController.h
index 06f289ac527ab5de9fcef42dcbc8c564ea47ed1c..e6780a091f9e4ca7a7b275e90bcf75043f648963 100644 (file)
@@ -44,6 +44,17 @@ class WebPage;
 
 typedef void* DDHighlightRef;
 
+struct TelephoneNumberData {
+    TelephoneNumberData(RetainPtr<DDHighlightRef> highlight, PassRefPtr<WebCore::Range> range)
+        : highlight(highlight)
+        , range(range)
+    {
+    }
+
+    RetainPtr<DDHighlightRef> highlight;
+    RefPtr<WebCore::Range> range;
+};
+
 class ServicesOverlayController : private PageOverlay::Client {
 public:
     ServicesOverlayController(WebPage&);
@@ -54,32 +65,39 @@ public:
 
 private:
     void createOverlayIfNeeded();
-    void handleClick(const WebCore::IntPoint&);
+    void handleClick(const WebCore::IntPoint&, DDHighlightRef);
     void clearHighlightState();
-    
+
     virtual void pageOverlayDestroyed(PageOverlay*) override;
     virtual void willMoveToWebPage(PageOverlay*, WebPage*) override;
     virtual void didMoveToWebPage(PageOverlay*, WebPage*) override;
     virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect) override;
     virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&) override;
 
-    void drawTelephoneNumberHighlight(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
+    bool drawTelephoneNumberHighlightIfVisible(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
     void drawSelectionHighlight(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
-    void drawCurrentHighlight(WebCore::GraphicsContext&);
+    void drawHighlight(DDHighlightRef, WebCore::GraphicsContext&);
+
+    void establishHoveredTelephoneHighlight(Boolean& onButton);
+    void maybeCreateSelectionHighlight();
+
+    void clearSelectionHighlight();
+    void clearHoveredTelephoneNumberHighlight();
 
     WebPage* m_webPage;
     PageOverlay* m_servicesOverlay;
     
     Vector<WebCore::LayoutRect> m_currentSelectionRects;
+    RetainPtr<DDHighlightRef> m_selectionHighlight;
+
     Vector<RefPtr<WebCore::Range>> m_currentTelephoneNumberRanges;
+    Vector<RetainPtr<DDHighlightRef>> m_telephoneNumberHighlights;
+    std::unique_ptr<TelephoneNumberData> m_hoveredTelephoneNumberData;
 
-    WebCore::IntPoint m_mousePosition;
-    bool m_mouseIsDownOnButton;
-    bool m_mouseIsOverHighlight;
-    bool m_drawingTelephoneNumberHighlight;
+    RetainPtr<DDHighlightRef> m_currentHoveredHighlight;
+    RetainPtr<DDHighlightRef> m_currentMouseDownOnButtonHighlight;
 
-    RetainPtr<DDHighlightRef> m_currentHighlight;
-    bool m_currentHighlightIsDirty;
+    WebCore::IntPoint m_mousePosition;
 };
 
 } // namespace WebKit