Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: WebCore/html/HTMLInputElement.cpp

Issue 3325025: Merge 67261 - Make middle clicks not fire DOM onclick events.... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/517/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « WebCore/html/HTMLAnchorElement.cpp ('k') | WebCore/page/EventHandler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2139 struct EventHandlingState : FastAllocBase { 2139 struct EventHandlingState : FastAllocBase {
2140 RefPtr<HTMLInputElement> m_currRadio; 2140 RefPtr<HTMLInputElement> m_currRadio;
2141 bool m_indeterminate; 2141 bool m_indeterminate;
2142 bool m_checked; 2142 bool m_checked;
2143 2143
2144 EventHandlingState(bool indeterminate, bool checked) 2144 EventHandlingState(bool indeterminate, bool checked)
2145 : m_indeterminate(indeterminate) 2145 : m_indeterminate(indeterminate)
2146 , m_checked(checked) { } 2146 , m_checked(checked) { }
2147 }; 2147 };
2148 2148
2149 void* HTMLInputElement::preDispatchEventHandler(Event *evt) 2149 void* HTMLInputElement::preDispatchEventHandler(Event* evt)
2150 { 2150 {
2151 // preventDefault or "return false" are used to reverse the automatic checki ng/selection we do here. 2151 // preventDefault or "return false" are used to reverse the automatic checki ng/selection we do here.
2152 // This result gives us enough info to perform the "undo" in postDispatch of the action we take here. 2152 // This result gives us enough info to perform the "undo" in postDispatch of the action we take here.
2153 void* result = 0; 2153 void* result = 0;
2154 if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->isMouseEvent() 2154 if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->type() == even tNames().clickEvent) {
2155 && evt->type() == eventNames().clickEvent && static_cast<MouseEvent* >(evt)->button() == LeftButton) {
2156
2157 OwnPtr<EventHandlingState> state = adoptPtr(new EventHandlingState(indet erminate(), checked())); 2155 OwnPtr<EventHandlingState> state = adoptPtr(new EventHandlingState(indet erminate(), checked()));
2158
2159 if (inputType() == CHECKBOX) { 2156 if (inputType() == CHECKBOX) {
2160 if (indeterminate()) 2157 if (indeterminate())
2161 setIndeterminate(false); 2158 setIndeterminate(false);
2162 else 2159 else
2163 setChecked(!checked(), true); 2160 setChecked(!checked(), true);
2164 } else { 2161 } else {
2165 // For radio buttons, store the current selected radio object. 2162 // For radio buttons, store the current selected radio object.
2166 // We really want radio groups to end up in sane states, i.e., to ha ve something checked. 2163 // We really want radio groups to end up in sane states, i.e., to ha ve something checked.
2167 // Therefore if nothing is currently selected, we won't allow this a ction to be "undone", since 2164 // Therefore if nothing is currently selected, we won't allow this a ction to be "undone", since
2168 // we want some object in the radio group to actually get selected. 2165 // we want some object in the radio group to actually get selected.
2169 HTMLInputElement* currRadio = checkedRadioButtons(this).checkedButto nForGroup(name()); 2166 HTMLInputElement* currRadio = checkedRadioButtons(this).checkedButto nForGroup(name());
2170 if (currRadio) { 2167 if (currRadio) {
2171 // We have a radio button selected that is not us. Cache it in our result field and ref it so 2168 // We have a radio button selected that is not us. Cache it in our result field and ref it so
2172 // that it can't be destroyed. 2169 // that it can't be destroyed.
2173 state->m_currRadio = currRadio; 2170 state->m_currRadio = currRadio;
2174 } 2171 }
2175 if (indeterminate()) 2172 if (indeterminate())
2176 setIndeterminate(false); 2173 setIndeterminate(false);
2177 setChecked(true, true); 2174 setChecked(true, true);
2178 } 2175 }
2179 result = state.leakPtr(); // FIXME: Check whether this actually ends up leaking. 2176 result = state.leakPtr(); // FIXME: Check whether this actually ends up leaking.
2180 } 2177 }
2181 return result; 2178 return result;
2182 } 2179 }
2183 2180
2184 void HTMLInputElement::postDispatchEventHandler(Event *evt, void* data) 2181 void HTMLInputElement::postDispatchEventHandler(Event *evt, void* data)
2185 { 2182 {
2186 if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->isMouseEvent() 2183 if ((inputType() == CHECKBOX || inputType() == RADIO) && evt->type() == even tNames().clickEvent) {
2187 && evt->type() == eventNames().clickEvent && static_cast<MouseEvent* >(evt)->button() == LeftButton) {
2188 2184
2189 if (EventHandlingState* state = reinterpret_cast<EventHandlingState*>(da ta)) { 2185 if (EventHandlingState* state = reinterpret_cast<EventHandlingState*>(da ta)) {
2190 if (inputType() == CHECKBOX) { 2186 if (inputType() == CHECKBOX) {
2191 // Reverse the checking we did in preDispatch. 2187 // Reverse the checking we did in preDispatch.
2192 if (evt->defaultPrevented() || evt->defaultHandled()) { 2188 if (evt->defaultPrevented() || evt->defaultHandled()) {
2193 setIndeterminate(state->m_indeterminate); 2189 setIndeterminate(state->m_indeterminate);
2194 setChecked(state->m_checked); 2190 setChecked(state->m_checked);
2195 } 2191 }
2196 } else { 2192 } else {
2197 HTMLInputElement* input = state->m_currRadio.get(); 2193 HTMLInputElement* input = state->m_currRadio.get();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 if (isTextField() 2256 if (isTextField()
2261 && evt->type() == eventNames().keydownEvent 2257 && evt->type() == eventNames().keydownEvent
2262 && evt->isKeyboardEvent() 2258 && evt->isKeyboardEvent()
2263 && focused() 2259 && focused()
2264 && document()->frame() 2260 && document()->frame()
2265 && document()->frame()->doTextFieldCommandFromEvent(this, static_cas t<KeyboardEvent*>(evt))) { 2261 && document()->frame()->doTextFieldCommandFromEvent(this, static_cas t<KeyboardEvent*>(evt))) {
2266 evt->setDefaultHandled(); 2262 evt->setDefaultHandled();
2267 return; 2263 return;
2268 } 2264 }
2269 2265
2270 if (inputType() == RADIO 2266 if (inputType() == RADIO && evt->type() == eventNames().clickEvent) {
2271 && evt->isMouseEvent()
2272 && evt->type() == eventNames().clickEvent
2273 && static_cast<MouseEvent*>(evt)->button() == LeftButton) {
2274 evt->setDefaultHandled(); 2267 evt->setDefaultHandled();
2275 return; 2268 return;
2276 } 2269 }
2277 2270
2278 // Call the base event handler before any of our own event handling for almo st all events in text fields. 2271 // Call the base event handler before any of our own event handling for almo st all events in text fields.
2279 // Makes editing keyboard handling take precedence over the keydown and keyp ress handling in this function. 2272 // Makes editing keyboard handling take precedence over the keydown and keyp ress handling in this function.
2280 bool callBaseClassEarly = isTextField() && !implicitSubmission 2273 bool callBaseClassEarly = isTextField() && !implicitSubmission
2281 && (evt->type() == eventNames().keydownEvent || evt->type() == eventName s().keypressEvent); 2274 && (evt->type() == eventNames().keydownEvent || evt->type() == eventName s().keypressEvent);
2282 if (callBaseClassEarly) { 2275 if (callBaseClassEarly) {
2283 HTMLFormControlElementWithState::defaultEventHandler(evt); 2276 HTMLFormControlElementWithState::defaultEventHandler(evt);
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
2997 case TIME: 2990 case TIME:
2998 case URL: 2991 case URL:
2999 case WEEK: 2992 case WEEK:
3000 return false; 2993 return false;
3001 } 2994 }
3002 return false; 2995 return false;
3003 } 2996 }
3004 #endif 2997 #endif
3005 2998
3006 } // namespace 2999 } // namespace
OLDNEW
« no previous file with comments | « WebCore/html/HTMLAnchorElement.cpp ('k') | WebCore/page/EventHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698