summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGFitToViewBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGFitToViewBox.cpp')
-rw-r--r--Source/WebCore/svg/SVGFitToViewBox.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/Source/WebCore/svg/SVGFitToViewBox.cpp b/Source/WebCore/svg/SVGFitToViewBox.cpp
index 13b04c81c..770f1f419 100644
--- a/Source/WebCore/svg/SVGFitToViewBox.cpp
+++ b/Source/WebCore/svg/SVGFitToViewBox.cpp
@@ -19,27 +19,24 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGFitToViewBox.h"
#include "AffineTransform.h"
-#include "Attribute.h"
#include "Document.h"
#include "FloatRect.h"
#include "SVGDocumentExtensions.h"
#include "SVGNames.h"
#include "SVGParserUtilities.h"
-#include "SVGPreserveAspectRatio.h"
-#include <wtf/text/StringImpl.h>
+#include "SVGPreserveAspectRatioValue.h"
+#include <wtf/text/StringView.h>
namespace WebCore {
bool SVGFitToViewBox::parseViewBox(Document* doc, const String& s, FloatRect& viewBox)
{
- const UChar* c = s.deprecatedCharacters();
- const UChar* end = c + s.length();
- return parseViewBox(doc, c, end, viewBox, true);
+ auto upconvertedCharacters = StringView(s).upconvertedCharacters();
+ const UChar* characters = upconvertedCharacters;
+ return parseViewBox(doc, characters, characters + s.length(), viewBox, true);
}
bool SVGFitToViewBox::parseViewBox(Document* doc, const UChar*& c, const UChar* end, FloatRect& viewBox, bool validate)
@@ -58,21 +55,21 @@ bool SVGFitToViewBox::parseViewBox(Document* doc, const UChar*& c, const UChar*
return true;
}
if (!valid) {
- doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
+ doc->accessSVGExtensions().reportWarning("Problem parsing viewBox=\"" + str + "\"");
return false;
}
if (width < 0.0) { // check that width is positive
- doc->accessSVGExtensions()->reportError("A negative value for ViewBox width is not allowed");
+ doc->accessSVGExtensions().reportError("A negative value for ViewBox width is not allowed");
return false;
}
if (height < 0.0) { // check that height is positive
- doc->accessSVGExtensions()->reportError("A negative value for ViewBox height is not allowed");
+ doc->accessSVGExtensions().reportError("A negative value for ViewBox height is not allowed");
return false;
}
skipOptionalSVGSpaces(c, end);
if (c < end) { // nothing should come after the last, fourth number
- doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\"");
+ doc->accessSVGExtensions().reportWarning("Problem parsing viewBox=\"" + str + "\"");
return false;
}
@@ -80,9 +77,9 @@ bool SVGFitToViewBox::parseViewBox(Document* doc, const UChar*& c, const UChar*
return true;
}
-AffineTransform SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatio& preserveAspectRatio, float viewWidth, float viewHeight)
+AffineTransform SVGFitToViewBox::viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatioValue& preserveAspectRatio, float viewWidth, float viewHeight)
{
- if (!viewBoxRect.width() || !viewBoxRect.height())
+ if (!viewBoxRect.width() || !viewBoxRect.height() || !viewWidth || !viewHeight)
return AffineTransform();
return preserveAspectRatio.getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), viewWidth, viewHeight);
@@ -100,5 +97,3 @@ void SVGFitToViewBox::addSupportedAttributes(HashSet<QualifiedName>& supportedAt
}
}
-
-#endif // ENABLE(SVG)