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

Unified Diff: Source/core/html/forms/NumberInputType.cpp

Issue 27746003: Have InputType factories take an HTMLInputElement reference in parameter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/forms/NumberInputType.h ('k') | Source/core/html/forms/PasswordInputType.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/forms/NumberInputType.cpp
diff --git a/Source/core/html/forms/NumberInputType.cpp b/Source/core/html/forms/NumberInputType.cpp
index 925e86c3798f85d1596a22b51bbe9eb690a6f848..26e5e40b455f94e59dcff7aba3871bd3ceac5562 100644
--- a/Source/core/html/forms/NumberInputType.cpp
+++ b/Source/core/html/forms/NumberInputType.cpp
@@ -94,7 +94,7 @@ static RealNumberRenderSize calculateRenderSize(const Decimal& value)
return RealNumberRenderSize(sizeOfSign + sizeOfZero , numberOfZeroAfterDecimalPoint + sizeOfDigits);
}
-PassRefPtr<InputType> NumberInputType::create(HTMLInputElement* element)
+PassRefPtr<InputType> NumberInputType::create(HTMLInputElement& element)
{
return adoptRef(new NumberInputType(element));
}
@@ -111,14 +111,14 @@ const AtomicString& NumberInputType::formControlType() const
void NumberInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
{
- if (!valueChanged && sanitizedValue.isEmpty() && !element()->innerTextValue().isEmpty())
+ if (!valueChanged && sanitizedValue.isEmpty() && !element().innerTextValue().isEmpty())
updateInnerTextValue();
TextFieldInputType::setValue(sanitizedValue, valueChanged, eventBehavior);
}
double NumberInputType::valueAsDouble() const
{
- return parseToDoubleForNumberType(element()->value());
+ return parseToDoubleForNumberType(element().value());
}
void NumberInputType::setValueAsDouble(double newValue, TextFieldEventBehavior eventBehavior, ExceptionState& es) const
@@ -133,7 +133,7 @@ void NumberInputType::setValueAsDouble(double newValue, TextFieldEventBehavior e
es.throwUninformativeAndGenericDOMException(InvalidStateError);
return;
}
- element()->setValue(serializeForNumberType(newValue), eventBehavior);
+ element().setValue(serializeForNumberType(newValue), eventBehavior);
}
void NumberInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventBehavior eventBehavior, ExceptionState& es) const
@@ -148,7 +148,7 @@ void NumberInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventB
es.throwUninformativeAndGenericDOMException(InvalidStateError);
return;
}
- element()->setValue(serializeForNumberType(newValue), eventBehavior);
+ element().setValue(serializeForNumberType(newValue), eventBehavior);
}
bool NumberInputType::typeMismatchFor(const String& value) const
@@ -158,19 +158,19 @@ bool NumberInputType::typeMismatchFor(const String& value) const
bool NumberInputType::typeMismatch() const
{
- ASSERT(!typeMismatchFor(element()->value()));
+ ASSERT(!typeMismatchFor(element().value()));
return false;
}
StepRange NumberInputType::createStepRange(AnyStepHandling anyStepHandling) const
{
DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (numberDefaultStep, numberDefaultStepBase, numberStepScaleFactor));
- const Decimal stepBase = parseToDecimalForNumberType(element()->fastGetAttribute(minAttr), numberDefaultStepBase);
+ const Decimal stepBase = parseToDecimalForNumberType(element().fastGetAttribute(minAttr), numberDefaultStepBase);
// FIXME: We should use numeric_limits<double>::max for number input type.
const Decimal floatMax = Decimal::fromDouble(numeric_limits<float>::max());
- const Decimal minimum = parseToNumber(element()->fastGetAttribute(minAttr), -floatMax);
- const Decimal maximum = parseToNumber(element()->fastGetAttribute(maxAttr), floatMax);
- const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element()->fastGetAttribute(stepAttr));
+ const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), -floatMax);
+ const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), floatMax);
+ const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
@@ -178,15 +178,15 @@ bool NumberInputType::sizeShouldIncludeDecoration(int defaultSize, int& preferre
{
preferredSize = defaultSize;
- const String stepString = element()->fastGetAttribute(stepAttr);
+ const String stepString = element().fastGetAttribute(stepAttr);
if (equalIgnoringCase(stepString, "any"))
return false;
- const Decimal minimum = parseToDecimalForNumberType(element()->fastGetAttribute(minAttr));
+ const Decimal minimum = parseToDecimalForNumberType(element().fastGetAttribute(minAttr));
if (!minimum.isFinite())
return false;
- const Decimal maximum = parseToDecimalForNumberType(element()->fastGetAttribute(maxAttr));
+ const Decimal maximum = parseToDecimalForNumberType(element().fastGetAttribute(maxAttr));
if (!maximum.isFinite())
return false;
@@ -236,12 +236,12 @@ String NumberInputType::localizeValue(const String& proposedValue) const
// We don't localize scientific notations.
if (proposedValue.find(isE) != kNotFound)
return proposedValue;
- return element()->locale().convertToLocalizedNumber(proposedValue);
+ return element().locale().convertToLocalizedNumber(proposedValue);
}
String NumberInputType::visibleValue() const
{
- return localizeValue(element()->value());
+ return localizeValue(element().value());
}
String NumberInputType::convertFromVisibleValue(const String& visibleValue) const
@@ -251,7 +251,7 @@ String NumberInputType::convertFromVisibleValue(const String& visibleValue) cons
// We don't localize scientific notations.
if (visibleValue.find(isE) != kNotFound)
return visibleValue;
- return element()->locale().convertFromLocalizedNumber(visibleValue);
+ return element().locale().convertFromLocalizedNumber(visibleValue);
}
String NumberInputType::sanitizeValue(const String& proposedValue) const
@@ -263,7 +263,7 @@ String NumberInputType::sanitizeValue(const String& proposedValue) const
bool NumberInputType::hasBadInput() const
{
- String standardValue = convertFromVisibleValue(element()->innerTextValue());
+ String standardValue = convertFromVisibleValue(element().innerTextValue());
return !standardValue.isEmpty() && !std::isfinite(parseToDoubleForNumberType(standardValue));
}
@@ -301,16 +301,16 @@ void NumberInputType::minOrMaxAttributeChanged()
{
InputType::minOrMaxAttributeChanged();
- if (element()->renderer())
- element()->renderer()->setNeedsLayoutAndPrefWidthsRecalc();
+ if (element().renderer())
+ element().renderer()->setNeedsLayoutAndPrefWidthsRecalc();
}
void NumberInputType::stepAttributeChanged()
{
InputType::stepAttributeChanged();
- if (element()->renderer())
- element()->renderer()->setNeedsLayoutAndPrefWidthsRecalc();
+ if (element().renderer())
+ element().renderer()->setNeedsLayoutAndPrefWidthsRecalc();
}
} // namespace WebCore
« no previous file with comments | « Source/core/html/forms/NumberInputType.h ('k') | Source/core/html/forms/PasswordInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698