OLD | NEW |
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 Loading... |
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 } else { | 938 } else { |
939 if (stepMismatch(element().value())) { | 939 if (stepMismatch(element().value())) { |
940 ASSERT(!step.isZero()); | 940 ASSERT(!step.isZero()); |
941 const Decimal base = stepRange.stepBase(); | 941 const Decimal base = stepRange.stepBase(); |
942 Decimal newValue; | 942 Decimal newValue; |
943 if (sign < 0) | 943 if (sign < 0) |
944 newValue = base + ((current - base) / step).floor() * step; | 944 newValue = base + ((current - base) / step).floor() * step; |
945 else if (sign > 0) | 945 else if (sign > 0) |
946 newValue = base + ((current - base) / step).ceiling() * step; | 946 newValue = base + ((current - base) / step).ceiling() * step; |
947 else | 947 else |
948 newValue = current; | 948 newValue = current; |
949 | 949 |
950 if (newValue < stepRange.minimum()) | 950 if (newValue < stepRange.minimum()) |
951 newValue = stepRange.minimum(); | 951 newValue = stepRange.minimum(); |
952 if (newValue > stepRange.maximum()) | 952 if (newValue > stepRange.maximum()) |
953 newValue = stepRange.maximum(); | 953 newValue = stepRange.maximum(); |
954 | 954 |
955 setValueAsDecimal(newValue, n == 1 || n == -1 ? DispatchInputAndChan
geEvent : DispatchNoEvent, IGNORE_EXCEPTION); | 955 setValueAsDecimal(newValue, n == 1 || n == -1 ? DispatchChangeEvent
: DispatchNoEvent, IGNORE_EXCEPTION); |
956 if (n > 1) | 956 if (n > 1) |
957 applyStep(n - 1, AnyIsDefaultStep, DispatchInputAndChangeEvent,
IGNORE_EXCEPTION); | 957 applyStep(n - 1, AnyIsDefaultStep, DispatchChangeEvent, IGNORE_E
XCEPTION); |
958 else if (n < -1) | 958 else if (n < -1) |
959 applyStep(n + 1, AnyIsDefaultStep, DispatchInputAndChangeEvent,
IGNORE_EXCEPTION); | 959 applyStep(n + 1, AnyIsDefaultStep, DispatchChangeEvent, IGNORE_E
XCEPTION); |
960 } else { | 960 } else { |
961 applyStep(n, AnyIsDefaultStep, DispatchInputAndChangeEvent, IGNORE_E
XCEPTION); | 961 applyStep(n, AnyIsDefaultStep, DispatchChangeEvent, IGNORE_EXCEPTION
); |
962 } | 962 } |
963 } | 963 } |
964 } | 964 } |
965 | 965 |
966 void InputType::countUsageIfVisible(UseCounter::Feature feature) const | 966 void InputType::countUsageIfVisible(UseCounter::Feature feature) const |
967 { | 967 { |
968 if (RenderStyle* style = element().renderStyle()) { | 968 if (RenderStyle* style = element().renderStyle()) { |
969 if (style->visibility() != HIDDEN) | 969 if (style->visibility() != HIDDEN) |
970 UseCounter::count(element().document(), feature); | 970 UseCounter::count(element().document(), feature); |
971 } | 971 } |
(...skipping 10 matching lines...) Expand all Loading... |
982 StepRange InputType::createStepRange(AnyStepHandling anyStepHandling, const Deci
mal& stepBaseDefault, const Decimal& minimumDefault, const Decimal& maximumDefau
lt, const StepRange::StepDescription& stepDescription) const | 982 StepRange InputType::createStepRange(AnyStepHandling anyStepHandling, const Deci
mal& stepBaseDefault, const Decimal& minimumDefault, const Decimal& maximumDefau
lt, const StepRange::StepDescription& stepDescription) const |
983 { | 983 { |
984 const Decimal stepBase = findStepBase(stepBaseDefault); | 984 const Decimal stepBase = findStepBase(stepBaseDefault); |
985 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), m
inimumDefault); | 985 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), m
inimumDefault); |
986 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), m
aximumDefault); | 986 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), m
aximumDefault); |
987 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription,
element().fastGetAttribute(stepAttr)); | 987 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription,
element().fastGetAttribute(stepAttr)); |
988 return StepRange(stepBase, minimum, maximum, step, stepDescription); | 988 return StepRange(stepBase, minimum, maximum, step, stepDescription); |
989 } | 989 } |
990 | 990 |
991 } // namespace WebCore | 991 } // namespace WebCore |
OLD | NEW |