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

Side by Side Diff: Source/core/html/HTMLInputElement.cpp

Issue 1188763002: Click event should be fired before change events for checkbox and radio button. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « Source/core/html/HTMLInputElement.h ('k') | Source/core/html/forms/CheckboxInputType.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, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights 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 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 10 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 890
891 setChecked(hasAttribute(checkedAttr)); 891 setChecked(hasAttribute(checkedAttr));
892 m_reflectsCheckedAttribute = true; 892 m_reflectsCheckedAttribute = true;
893 } 893 }
894 894
895 bool HTMLInputElement::isTextField() const 895 bool HTMLInputElement::isTextField() const
896 { 896 {
897 return m_inputType->isTextField(); 897 return m_inputType->isTextField();
898 } 898 }
899 899
900 void HTMLInputElement::dispatchChangeEventIfNeeded()
901 {
902 if (inDocument() && m_inputType->shouldSendChangeEventAfterCheckedChanged())
903 dispatchFormControlChangeEvent();
904 }
905
900 void HTMLInputElement::setChecked(bool nowChecked, TextFieldEventBehavior eventB ehavior) 906 void HTMLInputElement::setChecked(bool nowChecked, TextFieldEventBehavior eventB ehavior)
901 { 907 {
902 if (checked() == nowChecked) 908 if (checked() == nowChecked)
903 return; 909 return;
904 910
905 RefPtrWillBeRawPtr<HTMLInputElement> protector(this); 911 RefPtrWillBeRawPtr<HTMLInputElement> protector(this);
906 m_reflectsCheckedAttribute = false; 912 m_reflectsCheckedAttribute = false;
907 m_isChecked = nowChecked; 913 m_isChecked = nowChecked;
908 914
909 if (RadioButtonGroupScope* scope = radioButtonGroupScope()) 915 if (RadioButtonGroupScope* scope = radioButtonGroupScope())
(...skipping 13 matching lines...) Expand all
923 929
924 // Only send a change event for items in the document (avoid firing during 930 // Only send a change event for items in the document (avoid firing during
925 // parsing) and don't send a change event for a radio button that's getting 931 // parsing) and don't send a change event for a radio button that's getting
926 // unchecked to match other browsers. DOM is not a useful standard for this 932 // unchecked to match other browsers. DOM is not a useful standard for this
927 // because it says only to fire change events at "lose focus" time, which is 933 // because it says only to fire change events at "lose focus" time, which is
928 // definitely wrong in practice for these types of elements. 934 // definitely wrong in practice for these types of elements.
929 if (eventBehavior != DispatchNoEvent && inDocument() && m_inputType->shouldS endChangeEventAfterCheckedChanged()) { 935 if (eventBehavior != DispatchNoEvent && inDocument() && m_inputType->shouldS endChangeEventAfterCheckedChanged()) {
930 setTextAsOfLastFormControlChangeEvent(String()); 936 setTextAsOfLastFormControlChangeEvent(String());
931 if (eventBehavior == DispatchInputAndChangeEvent) 937 if (eventBehavior == DispatchInputAndChangeEvent)
932 dispatchFormControlInputEvent(); 938 dispatchFormControlInputEvent();
933 dispatchFormControlChangeEvent();
934 } 939 }
935 940
936 pseudoStateChanged(CSSSelector::PseudoChecked); 941 pseudoStateChanged(CSSSelector::PseudoChecked);
937 } 942 }
938 943
939 void HTMLInputElement::setIndeterminate(bool newValue) 944 void HTMLInputElement::setIndeterminate(bool newValue)
940 { 945 {
941 if (indeterminate() == newValue) 946 if (indeterminate() == newValue)
942 return; 947 return;
943 948
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 void HTMLInputElement::ensurePrimaryContent() 1925 void HTMLInputElement::ensurePrimaryContent()
1921 { 1926 {
1922 m_inputTypeView->ensurePrimaryContent(); 1927 m_inputTypeView->ensurePrimaryContent();
1923 } 1928 }
1924 1929
1925 bool HTMLInputElement::hasFallbackContent() const 1930 bool HTMLInputElement::hasFallbackContent() const
1926 { 1931 {
1927 return m_inputTypeView->hasFallbackContent(); 1932 return m_inputTypeView->hasFallbackContent();
1928 } 1933 }
1929 } // namespace 1934 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/HTMLInputElement.h ('k') | Source/core/html/forms/CheckboxInputType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698