<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[55389] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/55389">55389</a></dd>
<dt>Author</dt> <dd>eric@webkit.org</dd>
<dt>Date</dt> <dd>2010-03-01 17:12:16 -0800 (Mon, 01 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>2010-03-01  Jos?\195?\169 Mill?\195?\161n Soto  &lt;jmillan@igalia.com&gt;

        Reviewed by Gustavo Noronha Silva.

        [GTK] Right click does not activate text entry
        https://bugs.webkit.org/show_bug.cgi?id=29177

        Stop skipping some tests which where failing because of right click
        not being correct handled.

        * platform/gtk/Skipped:
2010-03-01  Jos?\195?\169 Mill?\195?\161n Soto  &lt;jmillan@igalia.com&gt;

        Reviewed by Gustavo Noronha Silva.

        [GTK] Right click does not activate text entry
        https://bugs.webkit.org/show_bug.cgi?id=29177

        Makes the frame handle the mouse click event before sending the
        context menu event.

        * webkit/webkitwebview.cpp:
        (PopupMenuPositionFunc):
        Function created to make the popup menu appear in the correct position, especially
        when invoked from the keyboard.
        (webkit_web_view_forward_context_menu_event):
        Mouse click event is sent to frame before creating context menu,
        PopupMenuPositionFunc used to determine the position where the menu should appear.
        (webkit_web_view_popup_menu_handler):
        Improved focused node position detection. Event button set to right button.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformgtkSkipped">trunk/LayoutTests/platform/gtk/Skipped</a></li>
<li><a href="#trunkWebKitgtkChangeLog">trunk/WebKit/gtk/ChangeLog</a></li>
<li><a href="#trunkWebKitgtkwebkitwebkitwebviewcpp">trunk/WebKit/gtk/webkit/webkitwebview.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (55388 => 55389)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2010-03-02 01:07:09 UTC (rev 55388)
+++ trunk/LayoutTests/ChangeLog        2010-03-02 01:12:16 UTC (rev 55389)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2010-03-01  José Millán Soto  &lt;jmillan@igalia.com&gt;
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] Right click does not activate text entry
+        https://bugs.webkit.org/show_bug.cgi?id=29177
+
+        Stop skipping some tests which where failing because of right click
+        not being correct handled.
+
+        * platform/gtk/Skipped:
+
</ins><span class="cx"> 2010-03-01  Alex Milowski  &lt;alex@milowski.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Kenneth Rohde Christiansen.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkSkipped"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/Skipped (55388 => 55389)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/Skipped        2010-03-02 01:07:09 UTC (rev 55388)
+++ trunk/LayoutTests/platform/gtk/Skipped        2010-03-02 01:12:16 UTC (rev 55389)
</span><span class="lines">@@ -1336,7 +1336,6 @@
</span><span class="cx"> fast/events/frame-tab-focus.html
</span><span class="cx"> fast/events/js-keyboard-event-creation.html
</span><span class="cx"> fast/events/mouse-click-events.html
</span><del>-fast/events/mouseclick-target-and-positioning.html
</del><span class="cx"> fast/events/mouseup-from-button2.html
</span><span class="cx"> fast/events/offsetX-offsetY.html
</span><span class="cx"> fast/events/onchange-passwordfield.html
</span><span class="lines">@@ -1351,7 +1350,6 @@
</span><span class="cx"> fast/events/pageshow-pagehide-on-back-cached-with-frames.html
</span><span class="cx"> fast/events/pointer-events-2.html
</span><span class="cx"> fast/events/popup-blocking-click-in-iframe.html
</span><del>-fast/events/right-click-focus.html
</del><span class="cx"> fast/events/scrollbar-double-click.html
</span><span class="cx"> fast/events/stop-load-in-unload-handler-using-document-write.html
</span><span class="cx"> fast/events/stop-load-in-unload-handler-using-window-stop.html
</span></span></pre></div>
<a id="trunkWebKitgtkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/gtk/ChangeLog (55388 => 55389)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/gtk/ChangeLog        2010-03-02 01:07:09 UTC (rev 55388)
+++ trunk/WebKit/gtk/ChangeLog        2010-03-02 01:12:16 UTC (rev 55389)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2010-03-01  José Millán Soto  &lt;jmillan@igalia.com&gt;
+
+        Reviewed by Gustavo Noronha Silva.
+
+        [GTK] Right click does not activate text entry
+        https://bugs.webkit.org/show_bug.cgi?id=29177
+
+        Makes the frame handle the mouse click event before sending the
+        context menu event.
+
+        * webkit/webkitwebview.cpp:
+        (PopupMenuPositionFunc):
+        Function created to make the popup menu appear in the correct position, especially
+        when invoked from the keyboard.
+        (webkit_web_view_forward_context_menu_event):
+        Mouse click event is sent to frame before creating context menu,
+        PopupMenuPositionFunc used to determine the position where the menu should appear.
+        (webkit_web_view_popup_menu_handler):
+        Improved focused node position detection. Event button set to right button.
+
</ins><span class="cx"> 2010-03-01  Jakob Petsovits  &lt;jpetsovits@rim.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Adam Barth.
</span></span></pre></div>
<a id="trunkWebKitgtkwebkitwebkitwebviewcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/gtk/webkit/webkitwebview.cpp (55388 => 55389)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/gtk/webkit/webkitwebview.cpp        2010-03-02 01:07:09 UTC (rev 55388)
+++ trunk/WebKit/gtk/webkit/webkitwebview.cpp        2010-03-02 01:12:16 UTC (rev 55389)
</span><span class="lines">@@ -202,34 +202,70 @@
</span><span class="cx">     priv-&gt;currentMenu = NULL;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData)
+{
+    WebKitWebView* view = WEBKIT_WEB_VIEW(userData);
+    WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(view);
+    GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view));
+    GtkRequisition menuSize;
+
+    gtk_widget_size_request(GTK_WIDGET(menu), &amp;menuSize);
+
+    *x = priv-&gt;lastPopupXPosition;
+    if ((*x + menuSize.width) &gt;= gdk_screen_get_width(screen))
+      *x -= menuSize.width;
+
+    *y = priv-&gt;lastPopupYPosition;
+    if ((*y + menuSize.height) &gt;= gdk_screen_get_height(screen))
+      *y -= menuSize.height;
+
+    *pushIn = FALSE;
+}
+
</ins><span class="cx"> static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent&amp; event)
</span><span class="cx"> {
</span><span class="cx">     Page* page = core(webView);
</span><span class="cx">     page-&gt;contextMenuController()-&gt;clearContextMenu();
</span><del>-    Frame* focusedFrame = page-&gt;focusController()-&gt;focusedOrMainFrame();
</del><ins>+    Frame* focusedFrame;
+    Frame* mainFrame = page-&gt;mainFrame();
+    gboolean mousePressEventResult = FALSE;
</ins><span class="cx"> 
</span><del>-    if (!focusedFrame-&gt;view())
</del><ins>+    if (!mainFrame-&gt;view())
</ins><span class="cx">         return FALSE;
</span><span class="cx"> 
</span><del>-    focusedFrame-&gt;view()-&gt;setCursor(pointerCursor());
</del><ins>+    mainFrame-&gt;view()-&gt;setCursor(pointerCursor());
+    if (page-&gt;frameCount()) {
+        HitTestRequest request(HitTestRequest::Active);
+        IntPoint point = mainFrame-&gt;view()-&gt;windowToContents(event.pos());
+        MouseEventWithHitTestResults mev = mainFrame-&gt;document()-&gt;prepareMouseEvent(request, point, event);
+
+        Frame* targetFrame = EventHandler::subframeForTargetNode(mev.targetNode());
+        if (!targetFrame)
+            targetFrame = mainFrame;
+
+        focusedFrame = page-&gt;focusController()-&gt;focusedOrMainFrame();
+        if (targetFrame != focusedFrame) {
+            page-&gt;focusController()-&gt;setFocusedFrame(targetFrame);
+            focusedFrame = targetFrame;
+        }
+    } else
+        focusedFrame = mainFrame;
+
+    if (focusedFrame-&gt;view() &amp;&amp; focusedFrame-&gt;eventHandler()-&gt;handleMousePressEvent(event))
+        mousePressEventResult = TRUE;
+
+
</ins><span class="cx">     bool handledEvent = focusedFrame-&gt;eventHandler()-&gt;sendContextMenuEvent(event);
</span><span class="cx">     if (!handledEvent)
</span><span class="cx">         return FALSE;
</span><span class="cx"> 
</span><span class="cx">     // If coreMenu is NULL, this means WebCore decided to not create
</span><del>-    // the default context menu; this may still mean that the frame
-    // wants to consume the event - this happens when the page is
-    // handling the right-click for reasons other than a context menu,
-    // so we give it to it.
</del><ins>+    // the default context menu; this may happen when the page is
+    // handling the right-click for reasons other than the context menu.
</ins><span class="cx">     ContextMenu* coreMenu = page-&gt;contextMenuController()-&gt;contextMenu();
</span><del>-    if (!coreMenu) {
-        Frame* frame = core(webView)-&gt;mainFrame();
-        if (frame-&gt;view() &amp;&amp; frame-&gt;eventHandler()-&gt;handleMousePressEvent(PlatformMouseEvent(event)))
-            return TRUE;
</del><ins>+    if (!coreMenu)
+        return mousePressEventResult;
</ins><span class="cx"> 
</span><del>-        return FALSE;
-    }
-
</del><span class="cx">     // If we reach here, it's because WebCore is going to show the
</span><span class="cx">     // default context menu. We check our setting to figure out
</span><span class="cx">     // whether we want it or not.
</span><span class="lines">@@ -262,8 +298,8 @@
</span><span class="cx">                      NULL);
</span><span class="cx"> 
</span><span class="cx">     gtk_menu_popup(menu, NULL, NULL,
</span><del>-                   NULL,
-                   priv, event.button() + 1, gtk_get_current_event_time());
</del><ins>+                   &amp;PopupMenuPositionFunc,
+                   webView, event.button() + 1, gtk_get_current_event_time());
</ins><span class="cx">     return TRUE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -273,17 +309,19 @@
</span><span class="cx"> 
</span><span class="cx">     // The context menu event was generated from the keyboard, so show the context menu by the current selection.
</span><span class="cx">     Page* page = core(WEBKIT_WEB_VIEW(widget));
</span><del>-    FrameView* view = page-&gt;mainFrame()-&gt;view();
</del><ins>+    Frame* frame = page-&gt;focusController()-&gt;focusedOrMainFrame();
+    FrameView* view = frame-&gt;view();
</ins><span class="cx">     if (!view)
</span><span class="cx">         return FALSE;    
</span><span class="cx"> 
</span><del>-    Position start = page-&gt;mainFrame()-&gt;selection()-&gt;selection().start();
-    Position end = page-&gt;mainFrame()-&gt;selection()-&gt;selection().end();
</del><ins>+    Position start = frame-&gt;selection()-&gt;selection().start();
+    Position end = frame-&gt;selection()-&gt;selection().end();
</ins><span class="cx"> 
</span><span class="cx">     int rightAligned = FALSE;
</span><span class="cx">     IntPoint location;
</span><span class="cx"> 
</span><del>-    if (!start.node() || !end.node())
</del><ins>+    if (!start.node() || !end.node()
+        || (frame-&gt;selection()-&gt;selection().isCaret() &amp;&amp; !frame-&gt;selection()-&gt;selection().isContentEditable()))
</ins><span class="cx">         location = IntPoint(rightAligned ? view-&gt;contentsWidth() - contextMenuMargin : contextMenuMargin, contextMenuMargin);
</span><span class="cx">     else {
</span><span class="cx">         RenderObject* renderer = start.node()-&gt;renderer();
</span><span class="lines">@@ -329,9 +367,18 @@
</span><span class="cx">     // FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in the selected element.
</span><span class="cx">     // Ideally we'd have the position of a context menu event be separate from its target node.
</span><span class="cx">     location = view-&gt;contentsToWindow(location) + IntSize(0, -1);
</span><ins>+    if (location.y() &lt; 0)
+        location.setY(contextMenuMargin);
+    else if (location.y() &gt; view-&gt;height())
+        location.setY(view-&gt;height() - contextMenuMargin);
+    if (location.x() &lt; 0)
+        location.setX(contextMenuMargin);
+    else if (location.x() &gt; view-&gt;width())
+        location.setX(view-&gt;width() - contextMenuMargin);
</ins><span class="cx">     IntPoint global = location + IntSize(x, y);
</span><del>-    PlatformMouseEvent event(location, global, NoButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time());
</del><span class="cx"> 
</span><ins>+    PlatformMouseEvent event(location, global, RightButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time());
+
</ins><span class="cx">     return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>