Fix for Selection and showing context menu in the IFrame , when focused frame is...
authorManish R Gurnaney <m.gurnaney@samsung.com>
Mon, 16 Sep 2013 22:07:16 +0000 (03:37 +0530)
committerTaeyun An <ty.an@samsung.com>
Thu, 10 Oct 2013 08:02:42 +0000 (17:02 +0900)
[Version] common
[Title] Context Menu not shown when do selectAll in IFrame.
[BinType] N/A
[Customer] HQ
[Issue#] DCM-2417
[Problem] Context Menu not shown when do selectAll in IFrame.
[Cause] In TextSelection::showContextMenu we always take ViewPort as MainFrame, not as FocusedFrame.
[Solution] Condition added so that when we ask to show the ContextMenu we will take view port as FocusedFrame in case SubFrame is selected.
[Team] WebCoreSupport
[Developer] m.gurnaney@samsung.com
[Request] N/A
[Horizontal expansion] N/A
[SCMRequest] NA

Change-Id: Ia67e11e0f701c788d9dee0f98f8199b5aab759c5

Source/WebKit2/UIProcess/API/efl/tizen/TextSelection.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp

index 9350d4d..68247ff 100755 (executable)
@@ -313,9 +313,21 @@ void TextSelection::showContextMenu()
         // Checking if this point is in viewport area. If the calcualated
         // point/Left/Right point are in view port then draw else do not draw the
         // context menu. Only draw the selection points.
+        bool isSubFrameFocused = false;
+        IntRect focusedFrameViewPort;
+        IntRect viewportRect;
         FloatRect unscaledRect = FloatRect(m_viewImpl->pageClient->visibleContentRect());
         unscaledRect.scale(1 / m_viewImpl->pageClient->scaleFactor());
-        IntRect viewportRect = enclosingIntRect(unscaledRect);
+
+        isSubFrameFocused = m_viewImpl->page()->getFocusedSubFrameRect(focusedFrameViewPort);
+        if (isSubFrameFocused) {
+            // Intersecting FocusedSubFrame with MainFrame visibleContentRect.
+            IntRect mainFrameViewPort = enclosedIntRect(unscaledRect);
+            if (focusedFrameViewPort.intersects(mainFrameViewPort))
+                focusedFrameViewPort.intersect(mainFrameViewPort);
+            viewportRect = focusedFrameViewPort;
+        } else
+            viewportRect = enclosingIntRect(unscaledRect);
 
         WebCore::IntPoint visiblePoint = leftRect.center();
         if (viewportRect.contains(visiblePoint)) {
@@ -336,8 +348,7 @@ void TextSelection::showContextMenu()
             // draw context menu at right point if visible
             point = rightRect.maxXMinYCorner();
             isPresentInViewPort = true;
-        }
-        else if (leftRect.y() < viewportRect.y() && rightRect.maxY() > viewportRect.maxY()) {
+        } else if (leftRect.y() < viewportRect.y() && rightRect.maxY() > viewportRect.maxY()) {
             // If left and right selection handler is not present in the view port,
             // always context menu shows middle of the view port.
             // Selection on position element in case of selectAll handled same
index 8bc5cb2..b30028c 100755 (executable)
@@ -1010,6 +1010,7 @@ public:
     bool selectionRangeClear();
     bool scrollContentByCharacter(const WebCore::IntPoint&, WebCore::SelectionDirection direction);
     bool scrollContentByLine(const WebCore::IntPoint&, WebCore::SelectionDirection direction);
+    bool getFocusedSubFrameRect(WebCore::IntRect&);
 #endif
 
 #if ENABLE(TIZEN_LINK_MAGNIFIER)
index 822a8ab..aa298aa 100755 (executable)
@@ -942,6 +942,16 @@ bool WebPageProxy::getSelectionHandlers(IntRect& leftRect, IntRect& rightRect, i
     return result;
 }
 
+bool WebPageProxy::getFocusedSubFrameRect(IntRect& focusedFrameViewRect) {
+    if (!isValid())
+        return false;
+
+    bool isSubFrameFocused = false;
+
+    process()->sendSync(Messages::WebPage::GetFocusedSubFrameRect(), Messages::WebPage::GetFocusedSubFrameRect::Reply(focusedFrameViewRect, isSubFrameFocused), m_pageID);
+    return isSubFrameFocused;
+}
+
 String WebPageProxy::getSelectionText()
 {
     String ret;
index b8dd229..6a1aafc 100755 (executable)
@@ -351,6 +351,7 @@ public:
     void selectionClearAllSelection(WebCore::Frame* frame);
     void scrollContentByCharacter(const WebCore::IntPoint&, int direction, bool& result);
     void scrollContentByLine(const WebCore::IntPoint&, int direction, bool& result);
+    void getFocusedSubFrameRect(WebCore::IntRect&, bool&);
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
index 965949a..a6cc940 100755 (executable)
@@ -387,6 +387,7 @@ messages -> WebPage {
     SelectionRangeClear() -> (bool result)
     ScrollContentByCharacter(WebCore::IntPoint point, int direction) -> (bool result)
     ScrollContentByLine(WebCore::IntPoint point, int direction) -> (bool result)
+    GetFocusedSubFrameRect() -> (WebCore::IntRect focusedFrameViewRect, bool isSubFrameFocused)
 #endif
 
 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
index 8336d69..61d157a 100644 (file)
 
 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
 #include "htmlediting.h"
+#include "RenderIFrame.h"
 #endif
 
 #if ENABLE(TIZEN_LINK_MAGNIFIER)
@@ -1719,6 +1720,31 @@ void WebPage::scrollContentByLine(const IntPoint&, int direction, bool& result)
         focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, LineGranularity, UserTriggered);
     }
 }
+
+void WebPage::getFocusedSubFrameRect(IntRect& focusedFrameRect, bool& isFocusedSubFrame)
+{
+    isFocusedSubFrame = false;
+
+    Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
+    if (!focusedFrame)
+        return;
+
+    if (focusedFrame != m_page->mainFrame()) {
+        FrameView* frameView = focusedFrame->view();
+        HTMLFrameOwnerElement* ownerElement = focusedFrame->ownerElement();
+
+        if (!frameView)
+            return;
+
+        if (ownerElement && ownerElement->hasTagName(HTMLNames::iframeTag)){
+            RenderIFrame* renderIframe = static_cast<RenderIFrame*>(ownerElement->renderer());
+            if (renderIframe) {
+                focusedFrameRect = renderIframe->windowClipRect();
+                isFocusedSubFrame = true;
+            }
+        }
+    }
+}
 #endif
 
 #if ENABLE(TIZEN_LINK_MAGNIFIER)