<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[20709] trunk/WebCore</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20709">20709</a></dd>
<dt>Author</dt> <dd>adele</dd>
<dt>Date</dt> <dd>2007-04-04 18:05:49 -0700 (Wed, 04 Apr 2007)</dd>
</dl>
<h3>Log Message</h3>
<pre> Reviewed by Oliver.
Fix for <rdar://5105009> Prepare for fix to send mousedown and mouseup (but not click) events when right-clicking
* page/EventHandler.cpp: Don't ever send click events for right-clicks.
(WebCore::EventHandler::handleMouseDoubleClickEvent):
(WebCore::EventHandler::handleMouseReleaseEvent):
Check that the mousedown and mouseup are not with the right button before performing default behavior.
* html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::defaultEventHandler):
* html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::defaultEventHandler):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::menuListDefaultEventHandler):
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
* html/HTMLTextFieldInnerElement.cpp:
(WebCore::HTMLSearchFieldResultsButtonElement::defaultEventHandler):
(WebCore::HTMLSearchFieldCancelButtonElement::defaultEventHandler):
* ksvg2/svg/SVGAElement.cpp:(WebCore::SVGAElement::defaultEventHandler):
* rendering/RenderFrameSet.cpp: (WebCore::RenderFrameSet::userResize):
* rendering/RenderSlider.cpp: (WebCore::HTMLSliderThumbElement::defaultEventHandler):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorehtmlHTMLAnchorElementcpp">trunk/WebCore/html/HTMLAnchorElement.cpp</a></li>
<li><a href="#trunkWebCorehtmlHTMLInputElementcpp">trunk/WebCore/html/HTMLInputElement.cpp</a></li>
<li><a href="#trunkWebCorehtmlHTMLSelectElementcpp">trunk/WebCore/html/HTMLSelectElement.cpp</a></li>
<li><a href="#trunkWebCorehtmlHTMLTextFieldInnerElementcpp">trunk/WebCore/html/HTMLTextFieldInnerElement.cpp</a></li>
<li><a href="#trunkWebCoreksvg2svgSVGAElementcpp">trunk/WebCore/ksvg2/svg/SVGAElement.cpp</a></li>
<li><a href="#trunkWebCorepageEventHandlercpp">trunk/WebCore/page/EventHandler.cpp</a></li>
<li><a href="#trunkWebCorerenderingRenderFrameSetcpp">trunk/WebCore/rendering/RenderFrameSet.cpp</a></li>
<li><a href="#trunkWebCorerenderingRenderSlidercpp">trunk/WebCore/rendering/RenderSlider.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/ChangeLog        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2007-04-04 Adele Peterson <adele@apple.com>
+
+ Reviewed by Oliver.
+
+ Fix for <rdar://5105009> Prepare for fix to send mousedown and mouseup (but not click) events when right-clicking
+
+ * page/EventHandler.cpp: Don't ever send click events for right-clicks.
+ (WebCore::EventHandler::handleMouseDoubleClickEvent):
+ (WebCore::EventHandler::handleMouseReleaseEvent):
+
+ Check that the mousedown and mouseup are not with the right button before performing default behavior.
+ * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::defaultEventHandler):
+ * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::defaultEventHandler):
+ * html/HTMLSelectElement.cpp:
+ (WebCore::HTMLSelectElement::menuListDefaultEventHandler):
+ (WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
+ * html/HTMLTextFieldInnerElement.cpp:
+ (WebCore::HTMLSearchFieldResultsButtonElement::defaultEventHandler):
+ (WebCore::HTMLSearchFieldCancelButtonElement::defaultEventHandler):
+ * ksvg2/svg/SVGAElement.cpp:(WebCore::SVGAElement::defaultEventHandler):
+ * rendering/RenderFrameSet.cpp: (WebCore::RenderFrameSet::userResize):
+ * rendering/RenderSlider.cpp: (WebCore::HTMLSliderThumbElement::defaultEventHandler):
+
</ins><span class="cx"> 2007-04-03 Justin Garcia <justin.garcia@apple.com>
</span><span class="cx">
</span><span class="cx"> Reviewed by darin
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLAnchorElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLAnchorElement.cpp (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLAnchorElement.cpp        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/html/HTMLAnchorElement.cpp        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -221,7 +221,7 @@
</span><span class="cx"> } else if (m_isLink && isContentEditable()) {
</span><span class="cx"> // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked
</span><span class="cx"> // for the LiveWhenNotFocused editable link behavior
</span><del>- if (evt->type() == mousedownEvent && document()->frame() && document()->frame()->selectionController()) {
</del><ins>+ if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() != RightButton && document()->frame() && document()->frame()->selectionController()) {
</ins><span class="cx"> MouseEvent* e = static_cast<MouseEvent*>(evt);
</span><span class="cx">
</span><span class="cx"> m_rootEditableElementForSelectionOnMouseDown = document()->frame()->selectionController()->rootEditableElement();
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLInputElement.cpp (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLInputElement.cpp        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/html/HTMLInputElement.cpp        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -1046,7 +1046,7 @@
</span><span class="cx"> // This result gives us enough info to perform the "undo" in postDispatch of the action we take here.
</span><span class="cx"> void* result = 0;
</span><span class="cx"> if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->isMouseEvent()
</span><del>- && evt->type() == clickEvent && static_cast<MouseEvent*>(evt)->button() == 0) {
</del><ins>+ && evt->type() == clickEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
</ins><span class="cx"> if (inputType() == CHECKBOX) {
</span><span class="cx"> // As a way to store the state, we return 0 if we were unchecked, 1 if we were checked, and 2 for
</span><span class="cx"> // indeterminate.
</span><span class="lines">@@ -1084,7 +1084,7 @@
</span><span class="cx"> void HTMLInputElement::postDispatchEventHandler(Event *evt, void* data)
</span><span class="cx"> {
</span><span class="cx"> if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->isMouseEvent()
</span><del>- && evt->type() == clickEvent && static_cast<MouseEvent*>(evt)->button() == 0) {
</del><ins>+ && evt->type() == clickEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
</ins><span class="cx"> if (inputType() == CHECKBOX) {
</span><span class="cx"> // Reverse the checking we did in preDispatch.
</span><span class="cx"> if (evt->defaultPrevented() || evt->defaultHandled()) {
</span><span class="lines">@@ -1309,7 +1309,7 @@
</span><span class="cx">
</span><span class="cx"> if (inputType() == RANGE && renderer()) {
</span><span class="cx"> RenderSlider* slider = static_cast<RenderSlider*>(renderer());
</span><del>- if (evt->isMouseEvent() && evt->type() == mousedownEvent) {
</del><ins>+ if (evt->isMouseEvent() && evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
</ins><span class="cx"> MouseEvent* mEvt = static_cast<MouseEvent*>(evt);
</span><span class="cx"> if (!slider->mouseEventIsInThumb(mEvt)) {
</span><span class="cx"> slider->setValueForPosition(slider->positionForOffset(IntPoint(mEvt->offsetX(), mEvt->offsetY())));
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLSelectElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLSelectElement.cpp (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLSelectElement.cpp        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/html/HTMLSelectElement.cpp        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -672,7 +672,7 @@
</span><span class="cx"> evt->setDefaultHandled();
</span><span class="cx">
</span><span class="cx"> }
</span><del>- if (evt->type() == mousedownEvent) {
</del><ins>+ if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
</ins><span class="cx"> focus();
</span><span class="cx"> if (menuList->popupIsVisible())
</span><span class="cx"> menuList->hidePopup();
</span><span class="lines">@@ -691,7 +691,7 @@
</span><span class="cx"> if (!renderer() || !renderer()->canSelect())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (evt->type() == mousedownEvent) {
</del><ins>+ if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
</ins><span class="cx"> focus();
</span><span class="cx">
</span><span class="cx"> MouseEvent* mEvt = static_cast<MouseEvent*>(evt);
</span><span class="lines">@@ -751,7 +751,7 @@
</span><span class="cx">
</span><span class="cx"> evt->setDefaultHandled();
</span><span class="cx"> }
</span><del>- } else if (evt->type() == mouseupEvent && document()->frame()->eventHandler()->autoscrollRenderer() != renderer())
</del><ins>+ } else if (evt->type() == mouseupEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton && document()->frame()->eventHandler()->autoscrollRenderer() != renderer())
</ins><span class="cx"> // This makes sure we fire onChange for a single click. For drag selection, onChange will fire when the autoscroll timer stops.
</span><span class="cx"> listBoxOnChange();
</span><span class="cx"> else if (evt->type() == keypressEvent) {
</span></span></pre></div>
<a id="trunkWebCorehtmlHTMLTextFieldInnerElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/html/HTMLTextFieldInnerElement.cpp (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/HTMLTextFieldInnerElement.cpp        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/html/HTMLTextFieldInnerElement.cpp        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "Frame.h"
</span><span class="cx"> #include "HTMLInputElement.h"
</span><span class="cx"> #include "HTMLTextAreaElement.h"
</span><ins>+#include "MouseEvent.h"
</ins><span class="cx"> #include "RenderTextControl.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -76,7 +77,7 @@
</span><span class="cx"> {
</span><span class="cx"> // On mousedown, bring up a menu, if needed
</span><span class="cx"> HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
</span><del>- if (evt->type() == mousedownEvent) {
</del><ins>+ if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
</ins><span class="cx"> input->focus();
</span><span class="cx"> input->select();
</span><span class="cx"> if (input && input->renderer() && static_cast<RenderTextControl*>(input->renderer())->popupIsVisible())
</span><span class="lines">@@ -99,14 +100,14 @@
</span><span class="cx"> {
</span><span class="cx"> // If the element is visible, on mouseup, clear the value, and set selection
</span><span class="cx"> HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
</span><del>- if (evt->type() == mousedownEvent) {
</del><ins>+ if (evt->type() == mousedownEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
</ins><span class="cx"> input->focus();
</span><span class="cx"> input->select();
</span><span class="cx"> evt->setDefaultHandled();
</span><span class="cx"> if (Frame* frame = document()->frame())
</span><span class="cx"> frame->eventHandler()->setCapturingMouseEventsNode(this);
</span><span class="cx"> m_capturing = true;
</span><del>- } else if (evt->type() == mouseupEvent) {
</del><ins>+ } else if (evt->type() == mouseupEvent && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
</ins><span class="cx"> if (m_capturing && renderer() && renderer()->style()->visibility() == VISIBLE) {
</span><span class="cx"> if (hovered()) {
</span><span class="cx"> input->setValue("");
</span></span></pre></div>
<a id="trunkWebCoreksvg2svgSVGAElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ksvg2/svg/SVGAElement.cpp (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ksvg2/svg/SVGAElement.cpp        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/ksvg2/svg/SVGAElement.cpp        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -95,7 +95,7 @@
</span><span class="cx"> void SVGAElement::defaultEventHandler(Event* evt)
</span><span class="cx"> {
</span><span class="cx"> // TODO : should use CLICK instead
</span><del>- if ((evt->type() == EventNames::mouseupEvent && m_isLink)) {
</del><ins>+ if ((evt->type() == EventNames::mouseupEvent && static_cast<MouseEvent*>(evt)->button() != RightButton && m_isLink)) {
</ins><span class="cx"> MouseEvent* e = static_cast<MouseEvent*>(evt);
</span><span class="cx">
</span><span class="cx"> if (e && e->button() == RightButton) {
</span></span></pre></div>
<a id="trunkWebCorepageEventHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/page/EventHandler.cpp (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/page/EventHandler.cpp        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/page/EventHandler.cpp        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -849,7 +849,8 @@
</span><span class="cx"> bool swallowMouseUpEvent = dispatchMouseEvent(mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false);
</span><span class="cx">
</span><span class="cx"> bool swallowClickEvent = false;
</span><del>- if (mev.targetNode() == m_clickNode)
</del><ins>+ // Don't ever dispatch click events for right clicks
+ if (mouseEvent.button() != RightButton && mev.targetNode() == m_clickNode)
</ins><span class="cx"> swallowClickEvent = dispatchMouseEvent(clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
</span><span class="cx">
</span><span class="cx"> bool swallowMouseReleaseEvent = false;
</span><span class="lines">@@ -954,8 +955,9 @@
</span><span class="cx">
</span><span class="cx"> bool swallowMouseUpEvent = dispatchMouseEvent(mouseupEvent, mev.targetNode(), true, m_clickCount, mouseEvent, false);
</span><span class="cx">
</span><ins>+ // Don't ever dispatch click events for right clicks
</ins><span class="cx"> bool swallowClickEvent = false;
</span><del>- if (m_clickCount > 0 && mev.targetNode() == m_clickNode)
</del><ins>+ if (m_clickCount > 0 && mouseEvent.button() != RightButton && mev.targetNode() == m_clickNode)
</ins><span class="cx"> swallowClickEvent = dispatchMouseEvent(clickEvent, mev.targetNode(), true, m_clickCount, mouseEvent, true);
</span><span class="cx">
</span><span class="cx"> if (m_resizeLayer) {
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderFrameSetcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderFrameSet.cpp (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderFrameSet.cpp        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/rendering/RenderFrameSet.cpp        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -556,7 +556,7 @@
</span><span class="cx"> if (!m_isResizing) {
</span><span class="cx"> if (needsLayout())
</span><span class="cx"> return false;
</span><del>- if (evt->type() == mousedownEvent) {
</del><ins>+ if (evt->type() == mousedownEvent && evt->button() == LeftButton) {
</ins><span class="cx"> startResizing(m_cols, evt->pageX() - xPos());
</span><span class="cx"> startResizing(m_rows, evt->pageY() - yPos());
</span><span class="cx"> if (m_cols.m_splitBeingResized != noSplit || m_rows.m_splitBeingResized != noSplit) {
</span><span class="lines">@@ -565,10 +565,10 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> } else {
</span><del>- if (evt->type() == mousemoveEvent || evt->type() == mouseupEvent) {
</del><ins>+ if (evt->type() == mousemoveEvent || (evt->type() == mouseupEvent && evt->button() == LeftButton)) {
</ins><span class="cx"> continueResizing(m_cols, evt->pageX() - xPos());
</span><span class="cx"> continueResizing(m_rows, evt->pageY() - yPos());
</span><del>- if (evt->type() == mouseupEvent) {
</del><ins>+ if (evt->type() == mouseupEvent && evt->button() == 0) {
</ins><span class="cx"> setIsResizing(false);
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebCorerenderingRenderSlidercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderSlider.cpp (20708 => 20709)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderSlider.cpp        2007-04-04 20:52:39 UTC (rev 20708)
+++ trunk/WebCore/rendering/RenderSlider.cpp        2007-04-05 01:05:49 UTC (rev 20709)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> void HTMLSliderThumbElement::defaultEventHandler(Event* event)
</span><span class="cx"> {
</span><span class="cx"> const AtomicString& eventType = event->type();
</span><del>- if (eventType == mousedownEvent && event->isMouseEvent()) {
</del><ins>+ if (eventType == mousedownEvent && event->isMouseEvent() && static_cast<MouseEvent*>(event)->button() == LeftButton) {
</ins><span class="cx"> MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
</span><span class="cx"> if (document()->frame() && renderer() && renderer()->parent()
</span><span class="cx"> && static_cast<RenderSlider*>(renderer()->parent())->mouseEventIsInThumb(mouseEvent)) {
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx"> event->setDefaultHandled();
</span><span class="cx"> return;
</span><span class="cx"> }
</span><del>- } else if (eventType == mouseupEvent) {
</del><ins>+ } else if (eventType == mouseupEvent && static_cast<MouseEvent*>(event)->button() == LeftButton) {
</ins><span class="cx"> if (m_inDragMode) {
</span><span class="cx"> if (Frame* frame = document()->frame())
</span><span class="cx"> frame->eventHandler()->setCapturingMouseEventsNode(0);
</span></span></pre>
</div>
</div>
</body>
</html>