Commit 83bfaff8 authored by kouhei@chromium.org's avatar kouhei@chromium.org

[SVG] Move negative viewBox width/height reporting to SVGAnimatedViewBoxRect

Before this CL, SVGFitToViewBox::parseAttribute handled negative width, height
errors inline. To migrate parsing to property map (crbug.com/397902), we want
to delegate this to SVGAnimatedProperty::setBaseValueToString implementation.

This CL introduces SVGAnimatedViewBoxRect which is a SVGAnimatedRect implements
handling of negative width/height.

TEST=svg/custom/viewbox-syntax.svg
BUG=397902

Review URL: https://codereview.chromium.org/664433002

git-svn-id: svn://svn.chromium.org/blink/trunk@183802 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7ef38961
...@@ -1313,6 +1313,8 @@ crbug.com/418864 [ Win ] http/tests/serviceworker/chromium/registration-stress.h ...@@ -1313,6 +1313,8 @@ crbug.com/418864 [ Win ] http/tests/serviceworker/chromium/registration-stress.h
crbug.com/418868 [ XP ] http/tests/serviceworker/ready.html [ Pass Timeout ] crbug.com/418868 [ XP ] http/tests/serviceworker/ready.html [ Pass Timeout ]
crbug.com/418869 [ Win ] http/tests/serviceworker/register-same-scope-different-script-url.html [ Pass Timeout ] crbug.com/418869 [ Win ] http/tests/serviceworker/register-same-scope-different-script-url.html [ Pass Timeout ]
crbug.com/397902 svg/custom/viewbox-syntax.svg [ NeedsRebaseline ]
crbug.com/399507 inspector/tracing/update-layer-tree.html [ Failure Pass ] crbug.com/399507 inspector/tracing/update-layer-tree.html [ Failure Pass ]
crbug.com/399507 virtual/deferred/inspector/tracing/update-layer-tree.html [ Failure Pass ] crbug.com/399507 virtual/deferred/inspector/tracing/update-layer-tree.html [ Failure Pass ]
crbug.com/399507 virtual/implsidepainting/inspector/tracing/update-layer-tree.html [ Failure Pass ] crbug.com/399507 virtual/implsidepainting/inspector/tracing/update-layer-tree.html [ Failure Pass ]
......
...@@ -4,8 +4,8 @@ CONSOLE ERROR: line 26: Error: Invalid value for <svg> attribute viewBox="0 0 30 ...@@ -4,8 +4,8 @@ CONSOLE ERROR: line 26: Error: Invalid value for <svg> attribute viewBox="0 0 30
CONSOLE ERROR: line 29: Error: Invalid value for <svg> attribute viewBox="0 0 30 40 50" CONSOLE ERROR: line 29: Error: Invalid value for <svg> attribute viewBox="0 0 30 40 50"
CONSOLE ERROR: line 32: Error: Invalid value for <svg> attribute viewBox="0 0 30 40," CONSOLE ERROR: line 32: Error: Invalid value for <svg> attribute viewBox="0 0 30 40,"
CONSOLE ERROR: line 35: Error: Invalid value for <svg> attribute viewBox=",0 0 30 40" CONSOLE ERROR: line 35: Error: Invalid value for <svg> attribute viewBox=",0 0 30 40"
CONSOLE ERROR: line 38: Error: A negative value for ViewBox width is not allowed CONSOLE ERROR: line 38: Error: Invalid negative value for <svg> attribute viewBox="0 0 -30 40"
CONSOLE ERROR: line 41: Error: A negative value for ViewBox height is not allowed CONSOLE ERROR: line 41: Error: Invalid negative value for <svg> attribute viewBox="0 0 30 -40"
CONSOLE ERROR: line 44: Error: Invalid value for <svg> attribute viewBox="0 0 30, , 40" CONSOLE ERROR: line 44: Error: Invalid value for <svg> attribute viewBox="0 0 30, , 40"
CONSOLE ERROR: line 47: Error: Invalid value for <svg> attribute viewBox="0 0 30% 40" CONSOLE ERROR: line 47: Error: Invalid value for <svg> attribute viewBox="0 0 30% 40"
layer at (0,0) size 800x600 layer at (0,0) size 800x600
......
...@@ -33,8 +33,41 @@ ...@@ -33,8 +33,41 @@
namespace blink { namespace blink {
class SVGAnimatedViewBoxRect : public SVGAnimatedRect {
public:
static PassRefPtr<SVGAnimatedRect> create(SVGElement* contextElement)
{
return adoptRef(new SVGAnimatedViewBoxRect(contextElement));
}
void setBaseValueAsString(const String&, SVGParsingError&) override;
protected:
SVGAnimatedViewBoxRect(SVGElement* contextElement)
: SVGAnimatedRect(contextElement, SVGNames::viewBoxAttr)
{
}
};
void SVGAnimatedViewBoxRect::setBaseValueAsString(const String& value, SVGParsingError& parseError)
{
TrackExceptionState es;
baseValue()->setValueAsString(value, es);
if (es.hadException()) {
parseError = ParsingAttributeFailedError;
return;
}
if (baseValue()->width() < 0 || baseValue()->height() < 0) {
parseError = NegativeValueForbiddenError;
baseValue()->setInvalid();
}
}
SVGFitToViewBox::SVGFitToViewBox(SVGElement* element, PropertyMapPolicy propertyMapPolicy) SVGFitToViewBox::SVGFitToViewBox(SVGElement* element, PropertyMapPolicy propertyMapPolicy)
: m_viewBox(SVGAnimatedRect::create(element, SVGNames::viewBoxAttr)) : m_viewBox(SVGAnimatedViewBoxRect::create(element))
, m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(element, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(element, SVGNames::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()))
{ {
ASSERT(element); ASSERT(element);
......
...@@ -54,14 +54,6 @@ public: ...@@ -54,14 +54,6 @@ public:
{ {
if (name == SVGNames::viewBoxAttr) { if (name == SVGNames::viewBoxAttr) {
m_viewBox->setBaseValueAsString(value, parseError); m_viewBox->setBaseValueAsString(value, parseError);
if (m_viewBox->baseValue()->width() < 0.0f) {
document.accessSVGExtensions().reportError("A negative value for ViewBox width is not allowed");
m_viewBox->baseValue()->setInvalid();
}
if (m_viewBox->baseValue()->height() < 0.0f) {
document.accessSVGExtensions().reportError("A negative value for ViewBox height is not allowed");
m_viewBox->baseValue()->setInvalid();
}
return true; return true;
} }
if (name == SVGNames::preserveAspectRatioAttr) { if (name == SVGNames::preserveAspectRatioAttr) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment