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

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: Avoid extra change event Created 6 years, 9 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 if (!current.isFinite()) { 927 if (!current.isFinite()) {
928 current = defaultValueForStepUp(); 928 current = defaultValueForStepUp();
929 const Decimal nextDiff = step * n; 929 const Decimal nextDiff = step * n;
930 if (current < stepRange.minimum() - nextDiff) 930 if (current < stepRange.minimum() - nextDiff)
931 current = stepRange.minimum() - nextDiff; 931 current = stepRange.minimum() - nextDiff;
932 if (current > stepRange.maximum() - nextDiff) 932 if (current > stepRange.maximum() - nextDiff)
933 current = stepRange.maximum() - nextDiff; 933 current = stepRange.maximum() - nextDiff;
934 setValueAsDecimal(current, DispatchNoEvent, IGNORE_EXCEPTION); 934 setValueAsDecimal(current, DispatchNoEvent, IGNORE_EXCEPTION);
935 } 935 }
936 if ((sign > 0 && current < stepRange.minimum()) || (sign < 0 && current > st epRange.maximum())) { 936 if ((sign > 0 && current < stepRange.minimum()) || (sign < 0 && current > st epRange.maximum())) {
937 setValueAsDecimal(sign > 0 ? stepRange.minimum() : stepRange.maximum(), DispatchInputAndChangeEvent, IGNORE_EXCEPTION); 937 setValueAsDecimal(sign > 0 ? stepRange.minimum() : stepRange.maximum(), DispatchChangeEvent, IGNORE_EXCEPTION);
938 return; 938 return;
939 } 939 }
940 applyStep(current, n, AnyIsDefaultStep, DispatchInputAndChangeEvent, IGNORE_ EXCEPTION); 940 applyStep(current, n, AnyIsDefaultStep, DispatchChangeEvent, IGNORE_EXCEPTIO N);
941 } 941 }
942 942
943 void InputType::countUsageIfVisible(UseCounter::Feature feature) const 943 void InputType::countUsageIfVisible(UseCounter::Feature feature) const
944 { 944 {
945 if (RenderStyle* style = element().renderStyle()) { 945 if (RenderStyle* style = element().renderStyle()) {
946 if (style->visibility() != HIDDEN) 946 if (style->visibility() != HIDDEN)
947 UseCounter::count(element().document(), feature); 947 UseCounter::count(element().document(), feature);
948 } 948 }
949 } 949 }
950 950
951 Decimal InputType::findStepBase(const Decimal& defaultValue) const 951 Decimal InputType::findStepBase(const Decimal& defaultValue) const
952 { 952 {
953 Decimal stepBase = parseToNumber(element().fastGetAttribute(minAttr), Decima l::nan()); 953 Decimal stepBase = parseToNumber(element().fastGetAttribute(minAttr), Decima l::nan());
954 if (!stepBase.isFinite()) 954 if (!stepBase.isFinite())
955 stepBase = parseToNumber(element().fastGetAttribute(valueAttr), defaultV alue); 955 stepBase = parseToNumber(element().fastGetAttribute(valueAttr), defaultV alue);
956 return stepBase; 956 return stepBase;
957 } 957 }
958 958
959 StepRange InputType::createStepRange(AnyStepHandling anyStepHandling, const Deci mal& stepBaseDefault, const Decimal& minimumDefault, const Decimal& maximumDefau lt, const StepRange::StepDescription& stepDescription) const 959 StepRange InputType::createStepRange(AnyStepHandling anyStepHandling, const Deci mal& stepBaseDefault, const Decimal& minimumDefault, const Decimal& maximumDefau lt, const StepRange::StepDescription& stepDescription) const
960 { 960 {
961 const Decimal stepBase = findStepBase(stepBaseDefault); 961 const Decimal stepBase = findStepBase(stepBaseDefault);
962 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), m inimumDefault); 962 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), m inimumDefault);
963 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), m aximumDefault); 963 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), m aximumDefault);
964 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 964 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
965 return StepRange(stepBase, minimum, maximum, step, stepDescription); 965 return StepRange(stepBase, minimum, maximum, step, stepDescription);
966 } 966 }
967 967
968 } // namespace WebCore 968 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698