-
joepeck@webkit.org authored
Reviewed by Kenneth Rohde Christiansen. LayoutTests: 2011-02-23 Joseph Pecoraro <joepeck@webkit.org> Viewport parsing no longer accepts "1.0;" value as valid. https://bugs.webkit.org/show_bug.cgi?id=53705 Add a new test to check viewport argument parsing of value "123x456", which although not completely a number should return the numeric prefix "123" as the value. Note that this affects "semicolons as separators" even though semicolons are not valid separators. * fast/viewport/viewport-129.html: Added. Source/JavaScriptCore: 2011-02-23 Joseph Pecoraro <joepeck@webkit.org> Viewport parsing no longer accepts "1.0;" value as valid. https://bugs.webkit.org/show_bug.cgi?id=53705 Include a didReadNumber parameter to String -> float / double conversion functions. This way, if the "ok" boolean out parameter is false, you can check to see if there in fact was a valid number parsed with garbage at the end. Examples of that would be parsing "123x456" would have ok = false, but didReadNumber = true. * JavaScriptCore.exp: * wtf/text/StringImpl.cpp: (WTF::StringImpl::toDouble): (WTF::StringImpl::toFloat): * wtf/text/StringImpl.h: * wtf/text/WTFString.cpp: (WTF::String::toDouble): (WTF::String::toFloat): (WTF::charactersToDouble): (WTF::charactersToFloat): * wtf/text/WTFString.h: Source/WebCore: 2011-02-23 Joseph Pecoraro <joepeck@webkit.org> Viewport parsing no longer accepts "1.0;" value as valid. https://bugs.webkit.org/show_bug.cgi?id=53705 When parsing numeric values, the "css-viewport" spec says to use the number prefix, and the non numeric part of the string can be ignored. This matches our behavior before r67376. The change was that checking the error out condition of String::toFloat doesn't necessarily mean that there was a non-numeric prefix. This patch checks if there was or wasn't a non-numeric prefix. There is a console warning in any case where a numeric value is not parsed cleanly. There is an error warning when it is not a number at all, and a tip warning when it has been truncated. Error messages are slightly improved to provide more context, both the key and value, when an error happens. Test: fast/viewport/viewport-129.html * dom/ViewportArguments.cpp: (WebCore::numericPrefix): (WebCore::findSizeValue): (WebCore::findScaleValue): (WebCore::findUserScalableValue): (WebCore::findTargetDensityDPIValue): (WebCore::viewportErrorMessageTemplate): (WebCore::viewportErrorMessageLevel): (WebCore::reportViewportWarning): * dom/ViewportArguments.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@80012 268f45cc-cd09-0410-ab3c-d52691b4dbfc
b6b3e77f