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

Side by Side Diff: Source/core/html/forms/InputType.cpp

Issue 196933006: Do not dispatch 'change' events during pressing spin buttons for input[type=number]. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test code updated Created 6 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
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) 2009, 2010, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2009, 2010, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 9 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
10 * 10 *
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 if (!current.isFinite()) { 937 if (!current.isFinite()) {
938 current = defaultValueForStepUp(); 938 current = defaultValueForStepUp();
939 const Decimal nextDiff = step * n; 939 const Decimal nextDiff = step * n;
940 if (current < stepRange.minimum() - nextDiff) 940 if (current < stepRange.minimum() - nextDiff)
941 current = stepRange.minimum() - nextDiff; 941 current = stepRange.minimum() - nextDiff;
942 if (current > stepRange.maximum() - nextDiff) 942 if (current > stepRange.maximum() - nextDiff)
943 current = stepRange.maximum() - nextDiff; 943 current = stepRange.maximum() - nextDiff;
944 setValueAsDecimal(current, DispatchNoEvent, IGNORE_EXCEPTION); 944 setValueAsDecimal(current, DispatchNoEvent, IGNORE_EXCEPTION);
945 } 945 }
946 if ((sign > 0 && current < stepRange.minimum()) || (sign < 0 && current > st epRange.maximum())) { 946 if ((sign > 0 && current < stepRange.minimum()) || (sign < 0 && current > st epRange.maximum())) {
947 setValueAsDecimal(sign > 0 ? stepRange.minimum() : stepRange.maximum(), DispatchInputAndChangeEvent, IGNORE_EXCEPTION); 947 setValueAsDecimal(sign > 0 ? stepRange.minimum() : stepRange.maximum(), DispatchChangeEvent, IGNORE_EXCEPTION);
948 return; 948 return;
949 } 949 }
950 applyStep(current, n, AnyIsDefaultStep, DispatchInputAndChangeEvent, IGNORE_ EXCEPTION); 950 applyStep(current, n, AnyIsDefaultStep, DispatchChangeEvent, IGNORE_EXCEPTIO N);
951 } 951 }
952 952
953 void InputType::countUsageIfVisible(UseCounter::Feature feature) const 953 void InputType::countUsageIfVisible(UseCounter::Feature feature) const
954 { 954 {
955 if (RenderStyle* style = element().renderStyle()) { 955 if (RenderStyle* style = element().renderStyle()) {
956 if (style->visibility() != HIDDEN) 956 if (style->visibility() != HIDDEN)
957 UseCounter::count(element().document(), feature); 957 UseCounter::count(element().document(), feature);
958 } 958 }
959 } 959 }
960 960
961 Decimal InputType::findStepBase(const Decimal& defaultValue) const 961 Decimal InputType::findStepBase(const Decimal& defaultValue) const
962 { 962 {
963 Decimal stepBase = parseToNumber(element().fastGetAttribute(minAttr), Decima l::nan()); 963 Decimal stepBase = parseToNumber(element().fastGetAttribute(minAttr), Decima l::nan());
964 if (!stepBase.isFinite()) 964 if (!stepBase.isFinite())
965 stepBase = parseToNumber(element().fastGetAttribute(valueAttr), defaultV alue); 965 stepBase = parseToNumber(element().fastGetAttribute(valueAttr), defaultV alue);
966 return stepBase; 966 return stepBase;
967 } 967 }
968 968
969 StepRange InputType::createStepRange(AnyStepHandling anyStepHandling, const Deci mal& stepBaseDefault, const Decimal& minimumDefault, const Decimal& maximumDefau lt, const StepRange::StepDescription& stepDescription) const 969 StepRange InputType::createStepRange(AnyStepHandling anyStepHandling, const Deci mal& stepBaseDefault, const Decimal& minimumDefault, const Decimal& maximumDefau lt, const StepRange::StepDescription& stepDescription) const
970 { 970 {
971 const Decimal stepBase = findStepBase(stepBaseDefault); 971 const Decimal stepBase = findStepBase(stepBaseDefault);
972 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), m inimumDefault); 972 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), m inimumDefault);
973 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), m aximumDefault); 973 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), m aximumDefault);
974 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 974 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
975 return StepRange(stepBase, minimum, maximum, step, stepDescription); 975 return StepRange(stepBase, minimum, maximum, step, stepDescription);
976 } 976 }
977 977
978 } // namespace WebCore 978 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/forms/BaseMultipleFieldsDateAndTimeInputType.cpp ('k') | Source/core/html/forms/TextFieldInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698