Diff
Copied: branches/chromium/782/LayoutTests/svg/text/svg-zoom-large-value-expected.txt (from rev 89705, trunk/LayoutTests/svg/text/svg-zoom-large-value-expected.txt) (0 => 90170)
--- branches/chromium/782/LayoutTests/svg/text/svg-zoom-large-value-expected.txt (rev 0)
+++ branches/chromium/782/LayoutTests/svg/text/svg-zoom-large-value-expected.txt 2011-06-30 22:17:08 UTC (rev 90170)
@@ -0,0 +1,2 @@
+PASS
+
Copied: branches/chromium/782/LayoutTests/svg/text/svg-zoom-large-value.xhtml (from rev 89705, trunk/LayoutTests/svg/text/svg-zoom-large-value.xhtml) (0 => 90170)
--- branches/chromium/782/LayoutTests/svg/text/svg-zoom-large-value.xhtml (rev 0)
+++ branches/chromium/782/LayoutTests/svg/text/svg-zoom-large-value.xhtml 2011-06-30 22:17:08 UTC (rev 90170)
@@ -0,0 +1,16 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<style>
+#svg1 { zoom: 10000000044444535353444433333333333333333333333333333333333333333333333333333330000000 }
+</style>
+</head>
+<body>
+<svg id="svg1" xmlns="http://www.w3.org/2000/svg">
+<text x="50" y="50">PASS</text>
+</svg>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+</body>
+</html>
Modified: branches/chromium/782/Source/_javascript_Core/wtf/MathExtras.h (90169 => 90170)
--- branches/chromium/782/Source/_javascript_Core/wtf/MathExtras.h 2011-06-30 22:15:25 UTC (rev 90169)
+++ branches/chromium/782/Source/_javascript_Core/wtf/MathExtras.h 2011-06-30 22:17:08 UTC (rev 90170)
@@ -207,45 +207,71 @@
inline float rad2grad(float r) { return r * 200.0f / piFloat; }
inline float grad2rad(float g) { return g * piFloat / 200.0f; }
-inline int clampToInteger(double d)
+inline int clampToInteger(double x)
{
- const double minIntAsDouble = std::numeric_limits<int>::min();
- const double maxIntAsDouble = std::numeric_limits<int>::max();
- return static_cast<int>(std::max(std::min(d, maxIntAsDouble), minIntAsDouble));
+ const double intMax = static_cast<double>(std::numeric_limits<int>::max());
+ const double intMin = static_cast<double>(std::numeric_limits<int>::min());
+
+ if (x >= intMax)
+ return std::numeric_limits<int>::max();
+ if (x <= intMin)
+ return std::numeric_limits<int>::min();
+ return static_cast<int>(x);
}
-inline int clampToPositiveInteger(double d)
+inline float clampToFloat(double x)
{
- const double maxIntAsDouble = std::numeric_limits<int>::max();
- return static_cast<int>(std::max<double>(std::min(d, maxIntAsDouble), 0));
+ const double floatMax = static_cast<double>(std::numeric_limits<float>::max());
+ const double floatMin = -static_cast<double>(std::numeric_limits<float>::max());
+
+ if (x >= floatMax)
+ return std::numeric_limits<float>::max();
+ if (x <= floatMin)
+ return -std::numeric_limits<float>::max();
+ return static_cast<float>(x);
}
+inline int clampToPositiveInteger(double x)
+{
+ const double intMax = static_cast<double>(std::numeric_limits<int>::max());
+
+ if (x >= intMax)
+ return std::numeric_limits<int>::max();
+ if (x <= 0)
+ return 0;
+ return static_cast<int>(x);
+}
+
inline int clampToInteger(float x)
{
- static const int s_intMax = std::numeric_limits<int>::max();
- static const int s_intMin = std::numeric_limits<int>::min();
+ const float intMax = static_cast<float>(std::numeric_limits<int>::max());
+ const float intMin = static_cast<float>(std::numeric_limits<int>::min());
- if (x >= static_cast<float>(s_intMax))
- return s_intMax;
- if (x < static_cast<float>(s_intMin))
- return s_intMin;
+ if (x >= intMax)
+ return std::numeric_limits<int>::max();
+ if (x <= intMin)
+ return std::numeric_limits<int>::min();
return static_cast<int>(x);
}
inline int clampToPositiveInteger(float x)
{
- static const int s_intMax = std::numeric_limits<int>::max();
+ const float intMax = static_cast<float>(std::numeric_limits<int>::max());
- if (x >= static_cast<float>(s_intMax))
- return s_intMax;
- if (x < 0)
+ if (x >= intMax)
+ return std::numeric_limits<int>::max();
+ if (x <= 0)
return 0;
return static_cast<int>(x);
}
-inline int clampToInteger(unsigned value)
+inline int clampToInteger(unsigned x)
{
- return static_cast<int>(std::min(value, static_cast<unsigned>(std::numeric_limits<int>::max())));
+ const unsigned intMax = static_cast<unsigned>(std::numeric_limits<int>::max());
+
+ if (x >= intMax)
+ return std::numeric_limits<int>::max();
+ return static_cast<int>(x);
}
#if !COMPILER(MSVC) && !(COMPILER(RVCT) && PLATFORM(BREWMP)) && !OS(SOLARIS) && !OS(SYMBIAN)
Modified: branches/chromium/782/Source/WebCore/css/CSSPrimitiveValue.cpp (90169 => 90170)
--- branches/chromium/782/Source/WebCore/css/CSSPrimitiveValue.cpp 2011-06-30 22:15:25 UTC (rev 90169)
+++ branches/chromium/782/Source/WebCore/css/CSSPrimitiveValue.cpp 2011-06-30 22:17:08 UTC (rev 90170)
@@ -36,7 +36,6 @@
#include "RenderStyle.h"
#include <wtf/ASCIICType.h>
#include <wtf/DecimalNumber.h>
-#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/StringBuffer.h>
@@ -130,6 +129,7 @@
: m_type(type)
, m_hasCachedCSSText(false)
{
+ ASSERT(isfinite(num));
m_value.num = num;
}
@@ -158,6 +158,7 @@
break;
case WebCore::Fixed:
m_type = CSS_PX;
+ ASSERT(isfinite(length.value()));
m_value.num = length.value();
break;
case Intrinsic:
@@ -170,6 +171,7 @@
break;
case Percent:
m_type = CSS_PERCENTAGE;
+ ASSERT(isfinite(length.percent()));
m_value.num = length.percent();
break;
case Relative:
Modified: branches/chromium/782/Source/WebCore/css/CSSPrimitiveValue.h (90169 => 90170)
--- branches/chromium/782/Source/WebCore/css/CSSPrimitiveValue.h 2011-06-30 22:15:25 UTC (rev 90169)
+++ branches/chromium/782/Source/WebCore/css/CSSPrimitiveValue.h 2011-06-30 22:17:08 UTC (rev 90170)
@@ -25,6 +25,7 @@
#include "CSSValue.h"
#include "Color.h"
#include <wtf/Forward.h>
+#include <wtf/MathExtras.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
@@ -154,13 +155,13 @@
double getDoubleValue() const { return m_value.num; }
void setFloatValue(unsigned short unitType, double floatValue, ExceptionCode&);
- float getFloatValue(unsigned short unitType, ExceptionCode& ec) const { return static_cast<float>(getDoubleValue(unitType, ec)); }
- float getFloatValue(unsigned short unitType) const { return static_cast<float>(getDoubleValue(unitType)); }
- float getFloatValue() const { return static_cast<float>(m_value.num); }
+ float getFloatValue(unsigned short unitType, ExceptionCode& ec) const { return clampToFloat(getDoubleValue(unitType, ec)); }
+ float getFloatValue(unsigned short unitType) const { return clampToFloat(getDoubleValue(unitType)); }
+ float getFloatValue() const { return clampToFloat(m_value.num); }
- int getIntValue(unsigned short unitType, ExceptionCode& ec) const { return static_cast<int>(getDoubleValue(unitType, ec)); }
- int getIntValue(unsigned short unitType) const { return static_cast<int>(getDoubleValue(unitType)); }
- int getIntValue() const { return static_cast<int>(m_value.num); }
+ int getIntValue(unsigned short unitType, ExceptionCode& ec) const { return clampToInteger(getDoubleValue(unitType, ec)); }
+ int getIntValue(unsigned short unitType) const { return clampToInteger(getDoubleValue(unitType)); }
+ int getIntValue() const { return clampToInteger(m_value.num); }
void setStringValue(unsigned short stringType, const String& stringValue, ExceptionCode&);
String getStringValue(ExceptionCode&) const;
Modified: branches/chromium/782/Source/WebCore/css/CSSStyleSelector.cpp (90169 => 90170)
--- branches/chromium/782/Source/WebCore/css/CSSStyleSelector.cpp 2011-06-30 22:15:25 UTC (rev 90169)
+++ branches/chromium/782/Source/WebCore/css/CSSStyleSelector.cpp 2011-06-30 22:17:08 UTC (rev 90170)
@@ -6177,6 +6177,18 @@
float CSSStyleSelector::getComputedSizeFromSpecifiedSize(Document* document, RenderStyle* style, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules)
{
+ float zoomFactor = 1.0f;
+ if (!useSVGZoomRules) {
+ zoomFactor = style->effectiveZoom();
+ if (Frame* frame = document->frame())
+ zoomFactor *= frame->textZoomFactor();
+ }
+
+ return CSSStyleSelector::getComputedSizeFromSpecifiedSize(document, zoomFactor, isAbsoluteSize, specifiedSize);
+}
+
+float CSSStyleSelector::getComputedSizeFromSpecifiedSize(Document* document, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize useSmartMinimumForFontSize)
+{
// Text with a 0px font size should not be visible and therefore needs to be
// exempt from minimum font size rules. Acid3 relies on this for pixel-perfect
// rendering. This is also compatible with other browsers that have minimum
@@ -6184,13 +6196,6 @@
if (fabsf(specifiedSize) < std::numeric_limits<float>::epsilon())
return 0.0f;
- float zoomFactor = 1.0f;
- if (!useSVGZoomRules) {
- zoomFactor = style->effectiveZoom();
- if (Frame* frame = document->frame())
- zoomFactor *= frame->textZoomFactor();
- }
-
// We support two types of minimum font size. The first is a hard override that applies to
// all fonts. This is "minSize." The second type of minimum font size is a "smart minimum"
// that is applied only when the Web page can't know what size it really asked for, e.g.,
@@ -6217,7 +6222,7 @@
// after zooming. The font size must either be relative to the user default or the original size
// must have been acceptable. In other words, we only apply the smart minimum whenever we're positive
// doing so won't disrupt the layout.
- if (zoomedSize < minLogicalSize && (specifiedSize >= minLogicalSize || !isAbsoluteSize))
+ if (useSmartMinimumForFontSize && zoomedSize < minLogicalSize && (specifiedSize >= minLogicalSize || !isAbsoluteSize))
zoomedSize = minLogicalSize;
// Also clamp to a reasonable maximum to prevent insane font sizes from causing crashes on various
Modified: branches/chromium/782/Source/WebCore/css/CSSStyleSelector.h (90169 => 90170)
--- branches/chromium/782/Source/WebCore/css/CSSStyleSelector.h 2011-06-30 22:15:25 UTC (rev 90169)
+++ branches/chromium/782/Source/WebCore/css/CSSStyleSelector.h 2011-06-30 22:17:08 UTC (rev 90170)
@@ -35,6 +35,8 @@
namespace WebCore {
+enum ESmartMinimumForFontSize { DoNotUseSmartMinimumForFontSize, UseSmartMinimumForFontFize };
+
class CSSFontSelector;
class CSSMutableStyleDeclaration;
class CSSPageRule;
@@ -162,9 +164,12 @@
void setStyle(PassRefPtr<RenderStyle> s) { m_style = s; } // Used by the document when setting up its root style.
void applyPropertyToStyle(int id, CSSValue*, RenderStyle*);
+
+ static float getComputedSizeFromSpecifiedSize(Document*, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize = UseSmartMinimumForFontFize);
private:
void setFontSize(FontDescription&, float size);
+
static float getComputedSizeFromSpecifiedSize(Document*, RenderStyle*, bool isAbsoluteSize, float specifiedSize, bool useSVGZoomRules);
public:
Color getColorFromPrimitiveValue(CSSPrimitiveValue*) const;
Modified: branches/chromium/782/Source/WebCore/platform/graphics/FontDescription.h (90169 => 90170)
--- branches/chromium/782/Source/WebCore/platform/graphics/FontDescription.h 2011-06-30 22:15:25 UTC (rev 90169)
+++ branches/chromium/782/Source/WebCore/platform/graphics/FontDescription.h 2011-06-30 22:17:08 UTC (rev 90170)
@@ -33,6 +33,7 @@
#include "FontWidthVariant.h"
#include "TextOrientation.h"
#include "TextRenderingMode.h"
+#include <wtf/MathExtras.h>
namespace WebCore {
@@ -115,8 +116,8 @@
FontWidthVariant widthVariant() const { return m_widthVariant; }
void setFamily(const FontFamily& family) { m_familyList = family; }
- void setComputedSize(float s) { m_computedSize = s; }
- void setSpecifiedSize(float s) { m_specifiedSize = s; }
+ void setComputedSize(float s) { ASSERT(isfinite(s)); m_computedSize = s; }
+ void setSpecifiedSize(float s) { ASSERT(isfinite(s)); m_specifiedSize = s; }
void setItalic(FontItalic i) { m_italic = i; }
void setItalic(bool i) { setItalic(i ? FontItalicOn : FontItalicOff); }
void setSmallCaps(FontSmallCaps c) { m_smallCaps = c; }
Modified: branches/chromium/782/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp (90169 => 90170)
--- branches/chromium/782/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2011-06-30 22:15:25 UTC (rev 90169)
+++ branches/chromium/782/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2011-06-30 22:17:08 UTC (rev 90170)
@@ -250,7 +250,7 @@
}
FontDescription fontDescription(style->fontDescription());
- fontDescription.setComputedSize(fontDescription.computedSize() * scalingFactor);
+ fontDescription.setComputedSize(CSSStyleSelector::getComputedSizeFromSpecifiedSize(document, scalingFactor, fontDescription.isAbsoluteSize(), fontDescription.computedSize(), DoNotUseSmartMinimumForFontSize));
scaledFont = Font(fontDescription, 0, 0);
scaledFont.update(styleSelector->fontSelector());