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

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

Issue 842153002: 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, 8 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 setTextAsOfLastFormControlChangeEvent(String());
903 if (inDocument() && m_inputType->shouldSendChangeEventAfterCheckedChanged())
904 dispatchFormControlChangeEvent();
905 }
906
900 void HTMLInputElement::setChecked(bool nowChecked, TextFieldEventBehavior eventB ehavior) 907 void HTMLInputElement::setChecked(bool nowChecked, TextFieldEventBehavior eventB ehavior)
901 { 908 {
902 if (checked() == nowChecked) 909 if (checked() == nowChecked)
903 return; 910 return;
904 911
905 RefPtrWillBeRawPtr<HTMLInputElement> protector(this); 912 RefPtrWillBeRawPtr<HTMLInputElement> protector(this);
906 m_reflectsCheckedAttribute = false; 913 m_reflectsCheckedAttribute = false;
907 m_isChecked = nowChecked; 914 m_isChecked = nowChecked;
908 915
909 if (RadioButtonGroupScope* scope = radioButtonGroupScope()) 916 if (RadioButtonGroupScope* scope = radioButtonGroupScope())
(...skipping 13 matching lines...) Expand all
923 930
924 // Only send a change event for items in the document (avoid firing during 931 // 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 932 // 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 933 // 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 934 // because it says only to fire change events at "lose focus" time, which is
928 // definitely wrong in practice for these types of elements. 935 // definitely wrong in practice for these types of elements.
929 if (eventBehavior != DispatchNoEvent && inDocument() && m_inputType->shouldS endChangeEventAfterCheckedChanged()) { 936 if (eventBehavior != DispatchNoEvent && inDocument() && m_inputType->shouldS endChangeEventAfterCheckedChanged()) {
930 setTextAsOfLastFormControlChangeEvent(String()); 937 setTextAsOfLastFormControlChangeEvent(String());
931 if (eventBehavior == DispatchInputAndChangeEvent) 938 if (eventBehavior == DispatchInputAndChangeEvent)
932 dispatchFormControlInputEvent(); 939 dispatchFormControlInputEvent();
933 dispatchFormControlChangeEvent();
934 } 940 }
935 941
936 pseudoStateChanged(CSSSelector::PseudoChecked); 942 pseudoStateChanged(CSSSelector::PseudoChecked);
937 } 943 }
938 944
939 void HTMLInputElement::setIndeterminate(bool newValue) 945 void HTMLInputElement::setIndeterminate(bool newValue)
940 { 946 {
941 if (indeterminate() == newValue) 947 if (indeterminate() == newValue)
942 return; 948 return;
943 949
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 void HTMLInputElement::ensurePrimaryContent() 1915 void HTMLInputElement::ensurePrimaryContent()
1910 { 1916 {
1911 m_inputTypeView->ensurePrimaryContent(); 1917 m_inputTypeView->ensurePrimaryContent();
1912 } 1918 }
1913 1919
1914 bool HTMLInputElement::hasFallbackContent() const 1920 bool HTMLInputElement::hasFallbackContent() const
1915 { 1921 {
1916 return m_inputTypeView->hasFallbackContent(); 1922 return m_inputTypeView->hasFallbackContent();
1917 } 1923 }
1918 } // namespace 1924 } // 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