Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (208580 => 208581)
--- trunk/Source/WebCore/CMakeLists.txt 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-11-11 06:29:44 UTC (rev 208581)
@@ -2802,7 +2802,7 @@
svg/SVGPolyElement.cpp
svg/SVGPolygonElement.cpp
svg/SVGPolylineElement.cpp
- svg/SVGPreserveAspectRatio.cpp
+ svg/SVGPreserveAspectRatioValue.cpp
svg/SVGRadialGradientElement.cpp
svg/SVGRectElement.cpp
svg/SVGSVGElement.cpp
Modified: trunk/Source/WebCore/ChangeLog (208580 => 208581)
--- trunk/Source/WebCore/ChangeLog 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/ChangeLog 2016-11-11 06:29:44 UTC (rev 208581)
@@ -1,3 +1,77 @@
+2016-11-10 Sam Weinig <[email protected]>
+
+ [SVG] Start moving special casing of SVG out of the bindings - SVGPreserveAspectRatio
+ https://bugs.webkit.org/show_bug.cgi?id=164622
+
+ Reviewed by Darin Adler.
+
+ Part 2 of moving special casing of SVG out of the bindings.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new files.
+
+ * bindings/scripts/CodeGenerator.pm:
+ (GenerateCompileTimeCheckForEnumsIfNeeded):
+ * bindings/scripts/IDLAttributes.txt:
+ Allow specifying a different scope for the constants to be declared in.
+ This allows us to have only one copy of the constants in the implementation
+ of SVGAngle/SVGAngleValue and SVGPreserveAspectRatio/SVGPreserveAspectRatioValue.
+
+ * loader/FrameLoader.cpp:
+ * rendering/svg/RenderSVGImage.h:
+ Remove unnecessary #include.
+
+ * svg/SVGAngle.h:
+ Remove redundant enum declaration.
+
+ * svg/SVGAngle.idl:
+ Specify a ConstantsScope of SVGAngleValue.
+
+ * rendering/svg/RenderSVGImage.cpp:
+ (WebCore::RenderSVGImage::updateImageViewport):
+ * svg/PatternAttributes.h:
+ (WebCore::PatternAttributes::preserveAspectRatio):
+ (WebCore::PatternAttributes::setPreserveAspectRatio):
+ * svg/SVGAnimatedPreserveAspectRatio.cpp:
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::constructFromString):
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateAnimatedValue):
+ * svg/SVGAnimatedPreserveAspectRatio.h:
+ * svg/SVGAnimatedType.cpp:
+ (WebCore::SVGAnimatedType::createPreserveAspectRatio):
+ * svg/SVGAnimatedType.h:
+ (WebCore::SVGAnimatedType::preserveAspectRatio):
+ * svg/SVGFEImageElement.cpp:
+ (WebCore::SVGFEImageElement::parseAttribute):
+ * svg/SVGFitToViewBox.cpp:
+ (WebCore::SVGFitToViewBox::viewBoxToViewTransform):
+ * svg/SVGFitToViewBox.h:
+ (WebCore::SVGFitToViewBox::parseAttribute):
+ * svg/SVGImageElement.cpp:
+ (WebCore::SVGImageElement::parseAttribute):
+ * svg/SVGViewSpec.cpp:
+ (WebCore::SVGViewSpec::preserveAspectRatioString):
+ (WebCore::SVGViewSpec::lookupOrCreatePreserveAspectRatioWrapper):
+ (WebCore::SVGViewSpec::reset):
+ (WebCore::SVGViewSpec::parseViewSpec):
+ * svg/SVGViewSpec.h:
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::computeIntrinsicDimensions):
+ * svg/graphics/filters/SVGFEImage.cpp:
+ (WebCore::FEImage::FEImage):
+ (WebCore::FEImage::createWithImage):
+ (WebCore::FEImage::createWithIRIReference):
+ * svg/graphics/filters/SVGFEImage.h:
+ Replace SVGPreserveAspectRatio usage with SVGPreserveAspectRatioValue.
+
+ * svg/SVGPreserveAspectRatio.cpp: Removed.
+ * svg/SVGPreserveAspectRatio.h: Replaced.
+ * svg/SVGPreserveAspectRatio.idl:
+ * svg/SVGPreserveAspectRatioValue.cpp: Copied from Source/WebCore/svg/SVGPreserveAspectRatio.cpp.
+ * svg/SVGPreserveAspectRatioValue.h: Copied from Source/WebCore/svg/SVGPreserveAspectRatio.h.
+ Rename SVGPreserveAspectRatio to SVGPreserveAspectRatioValue and add a new SVGPreserveAspectRatio
+ that acts as the binding object.
+
2016-11-10 Yusuke Suzuki <[email protected]>
[DOMJIT] Document#body should have DOMJIT patchpoint
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208580 => 208581)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-11-11 06:29:44 UTC (rev 208581)
@@ -2878,6 +2878,7 @@
7C7941E51C56C29300A4C58E /* DataDetectorsCoreSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C7941E31C56C29300A4C58E /* DataDetectorsCoreSoftLink.h */; };
7C83DE861D04CC5D00FEBCF3 /* SpringSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */; };
7C8F22441DD3C2F600E92DA3 /* SVGAngleValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8F22421DD3B3B900E92DA3 /* SVGAngleValue.cpp */; };
+ 7C8F22471DD3D1CA00E92DA3 /* SVGPreserveAspectRatioValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8F22451DD3D1C500E92DA3 /* SVGPreserveAspectRatioValue.cpp */; };
7C93F3491AA6BA5E00A98BAB /* CompiledContentExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */; };
7C93F34A1AA6BA5E00A98BAB /* CompiledContentExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
7C93F34D1AA6BF0700A98BAB /* ContentExtensionCompiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C93F34B1AA6BF0700A98BAB /* ContentExtensionCompiler.cpp */; };
@@ -4663,7 +4664,6 @@
B2227A910D00BF220071B782 /* SVGPolygonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278FB0D00BF210071B782 /* SVGPolygonElement.h */; };
B2227A930D00BF220071B782 /* SVGPolylineElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22278FD0D00BF210071B782 /* SVGPolylineElement.cpp */; };
B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22278FE0D00BF210071B782 /* SVGPolylineElement.h */; };
- B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22279000D00BF210071B782 /* SVGPreserveAspectRatio.cpp */; };
B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279010D00BF210071B782 /* SVGPreserveAspectRatio.h */; settings = {ATTRIBUTES = (Private, ); }; };
B2227A990D00BF220071B782 /* SVGRadialGradientElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22279030D00BF210071B782 /* SVGRadialGradientElement.cpp */; };
B2227A9A0D00BF220071B782 /* SVGRadialGradientElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B22279040D00BF210071B782 /* SVGRadialGradientElement.h */; };
@@ -10315,6 +10315,8 @@
7C83DE851D04CBD400FEBCF3 /* SpringSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpringSolver.h; sourceTree = "<group>"; };
7C8F22421DD3B3B900E92DA3 /* SVGAngleValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAngleValue.cpp; sourceTree = "<group>"; };
7C8F22431DD3B3B900E92DA3 /* SVGAngleValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAngleValue.h; sourceTree = "<group>"; };
+ 7C8F22451DD3D1C500E92DA3 /* SVGPreserveAspectRatioValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPreserveAspectRatioValue.cpp; sourceTree = "<group>"; };
+ 7C8F22461DD3D1C500E92DA3 /* SVGPreserveAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPreserveAspectRatioValue.h; sourceTree = "<group>"; };
7C93F3471AA6BA5E00A98BAB /* CompiledContentExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompiledContentExtension.cpp; sourceTree = "<group>"; };
7C93F3481AA6BA5E00A98BAB /* CompiledContentExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompiledContentExtension.h; sourceTree = "<group>"; };
7C93F34B1AA6BF0700A98BAB /* ContentExtensionCompiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentExtensionCompiler.cpp; sourceTree = "<group>"; };
@@ -12424,7 +12426,6 @@
B22278FD0D00BF210071B782 /* SVGPolylineElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPolylineElement.cpp; sourceTree = "<group>"; };
B22278FE0D00BF210071B782 /* SVGPolylineElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGPolylineElement.h; sourceTree = "<group>"; };
B22278FF0D00BF210071B782 /* SVGPolylineElement.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SVGPolylineElement.idl; sourceTree = "<group>"; };
- B22279000D00BF210071B782 /* SVGPreserveAspectRatio.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPreserveAspectRatio.cpp; sourceTree = "<group>"; };
B22279010D00BF210071B782 /* SVGPreserveAspectRatio.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGPreserveAspectRatio.h; sourceTree = "<group>"; };
B22279020D00BF210071B782 /* SVGPreserveAspectRatio.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SVGPreserveAspectRatio.idl; sourceTree = "<group>"; };
B22279030D00BF210071B782 /* SVGRadialGradientElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGRadialGradientElement.cpp; sourceTree = "<group>"; };
@@ -21184,9 +21185,10 @@
B22278FD0D00BF210071B782 /* SVGPolylineElement.cpp */,
B22278FE0D00BF210071B782 /* SVGPolylineElement.h */,
B22278FF0D00BF210071B782 /* SVGPolylineElement.idl */,
- B22279000D00BF210071B782 /* SVGPreserveAspectRatio.cpp */,
B22279010D00BF210071B782 /* SVGPreserveAspectRatio.h */,
B22279020D00BF210071B782 /* SVGPreserveAspectRatio.idl */,
+ 7C8F22451DD3D1C500E92DA3 /* SVGPreserveAspectRatioValue.cpp */,
+ 7C8F22461DD3D1C500E92DA3 /* SVGPreserveAspectRatioValue.h */,
B22279030D00BF210071B782 /* SVGRadialGradientElement.cpp */,
B22279040D00BF210071B782 /* SVGRadialGradientElement.h */,
B22279050D00BF210071B782 /* SVGRadialGradientElement.idl */,
@@ -28699,6 +28701,7 @@
1C0939EA1A13E12900B788E5 /* CachedSVGFont.cpp in Sources */,
0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */,
BCB16C270979C3BD00467741 /* CachedXSLStyleSheet.cpp in Sources */,
+ 7C8F22471DD3D1CA00E92DA3 /* SVGPreserveAspectRatioValue.cpp in Sources */,
E43AF8E61AC5B7E800CA717E /* CacheValidation.cpp in Sources */,
49AE2D96134EE5F90072920A /* CalculationValue.cpp in Sources */,
B1827493134CA4C100B98C2D /* CallbackFunction.cpp in Sources */,
@@ -31269,7 +31272,6 @@
B2227A8E0D00BF220071B782 /* SVGPolyElement.cpp in Sources */,
B2227A900D00BF220071B782 /* SVGPolygonElement.cpp in Sources */,
B2227A930D00BF220071B782 /* SVGPolylineElement.cpp in Sources */,
- B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */,
B543B85717EB758F003BE93A /* SVGPropertyInfo.cpp in Sources */,
B2227A990D00BF220071B782 /* SVGRadialGradientElement.cpp in Sources */,
B2227A9D0D00BF220071B782 /* SVGRectElement.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (208580 => 208581)
--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm 2016-11-11 06:29:44 UTC (rev 208581)
@@ -127,7 +127,6 @@
"SVGPathSegList" => "SVGPathSegListPropertyTearOff",
"SVGPoint" => "SVGPropertyTearOff<SVGPoint>",
"SVGPointList" => "SVGListPropertyTearOff<SVGPointList>",
- "SVGPreserveAspectRatio" => "SVGPropertyTearOff<SVGPreserveAspectRatio>",
"SVGRect" => "SVGPropertyTearOff<FloatRect>",
"SVGStringList" => "SVGStaticListPropertyTearOff<SVGStringList>",
"SVGTransform" => "SVGPropertyTearOff<SVGTransform>",
@@ -1127,14 +1126,16 @@
return () if $interface->extendedAttributes->{"DoNotCheckConstants"} || !@{$interface->constants};
+ my $baseScope = $interface->extendedAttributes->{"ConstantsScope"} || $interface->type->name;
+
my @checks = ();
foreach my $constant (@{$interface->constants}) {
- my $className = $constant->extendedAttributes->{"ImplementedBy"} || $interface->type->name;
+ my $scope = $constant->extendedAttributes->{"ImplementedBy"} || $baseScope;
my $name = $constant->extendedAttributes->{"Reflect"} || $constant->name;
my $value = $constant->value;
my $conditional = $constant->extendedAttributes->{"Conditional"};
push(@checks, "#if " . $generator->GenerateConditionalStringFromAttributeValue($conditional) . "\n") if $conditional;
- push(@checks, "static_assert(${className}::$name == $value, \"$name in $className does not match value from IDL\");\n");
+ push(@checks, "static_assert(${scope}::${name} == ${value}, \"${name} in ${scope} does not match value from IDL\");\n");
push(@checks, "#endif\n") if $conditional;
}
push(@checks, "\n");
Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt (208580 => 208581)
--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt 2016-11-11 06:29:44 UTC (rev 208581)
@@ -29,6 +29,7 @@
CheckSecurityForNode
Clamp
Conditional=*
+ConstantsScope=*
Constructor
ConstructorCallWith=Document|ScriptExecutionContext|ScriptState
ConstructorMayThrowException
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (208580 => 208581)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -101,7 +101,6 @@
#include "SVGDocument.h"
#include "SVGLocatable.h"
#include "SVGNames.h"
-#include "SVGPreserveAspectRatio.h"
#include "SVGViewElement.h"
#include "SVGViewSpec.h"
#include "SchemeRegistry.h"
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp (208580 => 208581)
--- trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGImage.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -73,7 +73,7 @@
// Images with preserveAspectRatio=none should force non-uniform scaling. This can be achieved
// by setting the image's container size to its intrinsic size.
// See: http://www.w3.org/TR/SVG/single-page.html, 7.8 The ‘preserveAspectRatio’ attribute.
- if (imageElement().preserveAspectRatio().align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) {
+ if (imageElement().preserveAspectRatio().align() == SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_NONE) {
if (CachedImage* cachedImage = imageResource().cachedImage()) {
LayoutSize intrinsicSize = cachedImage->imageSizeForRenderer(0, style().effectiveZoom());
if (intrinsicSize != imageResource().imageSize(style().effectiveZoom())) {
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGImage.h (208580 => 208581)
--- trunk/Source/WebCore/rendering/svg/RenderSVGImage.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGImage.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -27,7 +27,6 @@
#include "AffineTransform.h"
#include "FloatRect.h"
#include "RenderSVGModelObject.h"
-#include "SVGPreserveAspectRatio.h"
namespace WebCore {
Modified: trunk/Source/WebCore/svg/PatternAttributes.h (208580 => 208581)
--- trunk/Source/WebCore/svg/PatternAttributes.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/PatternAttributes.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -56,7 +56,7 @@
SVGLength width() const { return m_width; }
SVGLength height() const { return m_height; }
FloatRect viewBox() const { return m_viewBox; }
- SVGPreserveAspectRatio preserveAspectRatio() const { return m_preserveAspectRatio; }
+ SVGPreserveAspectRatioValue preserveAspectRatio() const { return m_preserveAspectRatio; }
SVGUnitTypes::SVGUnitType patternUnits() const { return m_patternUnits; }
SVGUnitTypes::SVGUnitType patternContentUnits() const { return m_patternContentUnits; }
AffineTransform patternTransform() const { return m_patternTransform; }
@@ -92,7 +92,7 @@
m_viewBoxSet = true;
}
- void setPreserveAspectRatio(const SVGPreserveAspectRatio& value)
+ void setPreserveAspectRatio(const SVGPreserveAspectRatioValue& value)
{
m_preserveAspectRatio = value;
m_preserveAspectRatioSet = true;
@@ -140,7 +140,7 @@
SVGLength m_width;
SVGLength m_height;
FloatRect m_viewBox;
- SVGPreserveAspectRatio m_preserveAspectRatio;
+ SVGPreserveAspectRatioValue m_preserveAspectRatio;
SVGUnitTypes::SVGUnitType m_patternUnits;
SVGUnitTypes::SVGUnitType m_patternContentUnits;
AffineTransform m_patternTransform;
Modified: trunk/Source/WebCore/svg/SVGAllInOne.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGAllInOne.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGAllInOne.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -144,7 +144,7 @@
#include "SVGPolyElement.cpp"
#include "SVGPolygonElement.cpp"
#include "SVGPolylineElement.cpp"
-#include "SVGPreserveAspectRatio.cpp"
+#include "SVGPreserveAspectRatioValue.cpp"
#include "SVGRadialGradientElement.cpp"
#include "SVGRectElement.cpp"
#include "SVGSVGElement.cpp"
Modified: trunk/Source/WebCore/svg/SVGAngle.h (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGAngle.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGAngle.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -32,16 +32,6 @@
class SVGAngle : public SVGPropertyTearOff<SVGAngleValue> {
public:
- // FIXME: This is duplicated in SVGAngleValue. We should find someway to have
- // only one copy, but for now, this one is needed to satisfy the bindings.
- enum SVGAngleType {
- SVG_ANGLETYPE_UNKNOWN = 0,
- SVG_ANGLETYPE_UNSPECIFIED = 1,
- SVG_ANGLETYPE_DEG = 2,
- SVG_ANGLETYPE_RAD = 3,
- SVG_ANGLETYPE_GRAD = 4
- };
-
static Ref<SVGAngle> create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, SVGAngleValue& value)
{
ASSERT(animatedProperty);
Modified: trunk/Source/WebCore/svg/SVGAngle.idl (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGAngle.idl 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGAngle.idl 2016-11-11 06:29:44 UTC (rev 208581)
@@ -20,7 +20,9 @@
* Boston, MA 02110-1301, USA.
*/
-interface SVGAngle {
+[
+ ConstantsScope=SVGAngleValue
+] interface SVGAngle {
// Angle Unit Types
const unsigned short SVG_ANGLETYPE_UNKNOWN = 0;
const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1;
Modified: trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -31,7 +31,7 @@
std::unique_ptr<SVGAnimatedType> SVGAnimatedPreserveAspectRatioAnimator::constructFromString(const String& string)
{
- auto animatedType = SVGAnimatedType::createPreserveAspectRatio(std::make_unique<SVGPreserveAspectRatio>());
+ auto animatedType = SVGAnimatedType::createPreserveAspectRatio(std::make_unique<SVGPreserveAspectRatioValue>());
animatedType->preserveAspectRatio().parse(string);
return animatedType;
}
@@ -71,11 +71,11 @@
ASSERT(m_animationElement);
ASSERT(m_contextElement);
- const SVGPreserveAspectRatio& fromPreserveAspectRatio = m_animationElement->animationMode() == ToAnimation ? animated->preserveAspectRatio() : from->preserveAspectRatio();
- const SVGPreserveAspectRatio& toPreserveAspectRatio = to->preserveAspectRatio();
- SVGPreserveAspectRatio& animatedPreserveAspectRatio = animated->preserveAspectRatio();
+ const auto& fromPreserveAspectRatio = m_animationElement->animationMode() == ToAnimation ? animated->preserveAspectRatio() : from->preserveAspectRatio();
+ const auto& toPreserveAspectRatio = to->preserveAspectRatio();
+ auto& animatedPreserveAspectRatio = animated->preserveAspectRatio();
- m_animationElement->animateDiscreteType<SVGPreserveAspectRatio>(percentage, fromPreserveAspectRatio, toPreserveAspectRatio, animatedPreserveAspectRatio);
+ m_animationElement->animateDiscreteType<SVGPreserveAspectRatioValue>(percentage, fromPreserveAspectRatio, toPreserveAspectRatio, animatedPreserveAspectRatio);
}
float SVGAnimatedPreserveAspectRatioAnimator::calculateDistance(const String&, const String&)
Modified: trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -29,11 +29,11 @@
template<typename T>
class SVGPropertyTearOff;
-using SVGAnimatedPreserveAspectRatio = SVGAnimatedPropertyTearOff<SVGPropertyTearOff<SVGPreserveAspectRatio>>;
+using SVGAnimatedPreserveAspectRatio = SVGAnimatedPropertyTearOff<SVGPreserveAspectRatio>;
// Helper macros to declare/define a SVGAnimatedPreserveAspectRatio object
#define DECLARE_ANIMATED_PRESERVEASPECTRATIO(UpperProperty, LowerProperty) \
-DECLARE_ANIMATED_PROPERTY(SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatio, UpperProperty, LowerProperty, )
+DECLARE_ANIMATED_PROPERTY(SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatioValue, UpperProperty, LowerProperty, )
#define DEFINE_ANIMATED_PRESERVEASPECTRATIO(OwnerType, DOMAttribute, UpperProperty, LowerProperty) \
DEFINE_ANIMATED_PROPERTY(AnimatedPreserveAspectRatio, OwnerType, DOMAttribute, DOMAttribute.localName(), UpperProperty, LowerProperty)
Modified: trunk/Source/WebCore/svg/SVGAnimatedType.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGAnimatedType.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -194,7 +194,7 @@
return animatedType;
}
-std::unique_ptr<SVGAnimatedType> SVGAnimatedType::createPreserveAspectRatio(std::unique_ptr<SVGPreserveAspectRatio> preserveAspectRatio)
+std::unique_ptr<SVGAnimatedType> SVGAnimatedType::createPreserveAspectRatio(std::unique_ptr<SVGPreserveAspectRatioValue> preserveAspectRatio)
{
ASSERT(preserveAspectRatio);
auto animatedType = std::make_unique<SVGAnimatedType>(AnimatedPreserveAspectRatio);
Modified: trunk/Source/WebCore/svg/SVGAnimatedType.h (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGAnimatedType.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -27,7 +27,7 @@
#include "SVGLengthList.h"
#include "SVGNumberList.h"
#include "SVGPointList.h"
-#include "SVGPreserveAspectRatio.h"
+#include "SVGPreserveAspectRatioValue.h"
#include "SVGPropertyInfo.h"
#include "SVGTransformList.h"
@@ -54,7 +54,7 @@
static std::unique_ptr<SVGAnimatedType> createNumberOptionalNumber(std::unique_ptr<std::pair<float, float>>);
static std::unique_ptr<SVGAnimatedType> createPath(std::unique_ptr<SVGPathByteStream>);
static std::unique_ptr<SVGAnimatedType> createPointList(std::unique_ptr<SVGPointList>);
- static std::unique_ptr<SVGAnimatedType> createPreserveAspectRatio(std::unique_ptr<SVGPreserveAspectRatio>);
+ static std::unique_ptr<SVGAnimatedType> createPreserveAspectRatio(std::unique_ptr<SVGPreserveAspectRatioValue>);
static std::unique_ptr<SVGAnimatedType> createRect(std::unique_ptr<FloatRect>);
static std::unique_ptr<SVGAnimatedType> createString(std::unique_ptr<String>);
static std::unique_ptr<SVGAnimatedType> createTransformList(std::unique_ptr<SVGTransformList>);
@@ -141,7 +141,7 @@
return *m_data.pointList;
}
- const SVGPreserveAspectRatio& preserveAspectRatio() const
+ const SVGPreserveAspectRatioValue& preserveAspectRatio() const
{
ASSERT(m_type == AnimatedPreserveAspectRatio);
return *m_data.preserveAspectRatio;
@@ -244,7 +244,7 @@
return *m_data.pointList;
}
- SVGPreserveAspectRatio& preserveAspectRatio()
+ SVGPreserveAspectRatioValue& preserveAspectRatio()
{
ASSERT(m_type == AnimatedPreserveAspectRatio);
return *m_data.preserveAspectRatio;
@@ -292,7 +292,7 @@
SVGNumberList* numberList;
std::pair<float, float>* numberOptionalNumber;
SVGPathByteStream* path;
- SVGPreserveAspectRatio* preserveAspectRatio;
+ SVGPreserveAspectRatioValue* preserveAspectRatio;
SVGPointList* pointList;
FloatRect* rect;
String* string;
Modified: trunk/Source/WebCore/svg/SVGFEImageElement.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGFEImageElement.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGFEImageElement.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -30,7 +30,7 @@
#include "RenderObject.h"
#include "RenderSVGResource.h"
#include "SVGNames.h"
-#include "SVGPreserveAspectRatio.h"
+#include "SVGPreserveAspectRatioValue.h"
#include "XLinkNames.h"
namespace WebCore {
@@ -122,7 +122,7 @@
void SVGFEImageElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == SVGNames::preserveAspectRatioAttr) {
- SVGPreserveAspectRatio preserveAspectRatio;
+ SVGPreserveAspectRatioValue preserveAspectRatio;
preserveAspectRatio.parse(value);
setPreserveAspectRatioBaseValue(preserveAspectRatio);
return;
Modified: trunk/Source/WebCore/svg/SVGFitToViewBox.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGFitToViewBox.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGFitToViewBox.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -27,7 +27,7 @@
#include "SVGDocumentExtensions.h"
#include "SVGNames.h"
#include "SVGParserUtilities.h"
-#include "SVGPreserveAspectRatio.h"
+#include "SVGPreserveAspectRatioValue.h"
#include <wtf/text/StringView.h>
namespace WebCore {
@@ -77,7 +77,7 @@
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() || !viewWidth || !viewHeight)
return AffineTransform();
Modified: trunk/Source/WebCore/svg/SVGFitToViewBox.h (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGFitToViewBox.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGFitToViewBox.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -34,7 +34,7 @@
class SVGFitToViewBox {
public:
- static AffineTransform viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatio&, float viewWidth, float viewHeight);
+ static AffineTransform viewBoxToViewTransform(const FloatRect& viewBoxRect, const SVGPreserveAspectRatioValue&, float viewWidth, float viewHeight);
static bool isKnownAttribute(const QualifiedName&);
static void addSupportedAttributes(HashSet<QualifiedName>&);
@@ -51,7 +51,7 @@
}
if (name == SVGNames::preserveAspectRatioAttr) {
- SVGPreserveAspectRatio preserveAspectRatio;
+ SVGPreserveAspectRatioValue preserveAspectRatio;
preserveAspectRatio.parse(value);
target->setPreserveAspectRatioBaseValue(preserveAspectRatio);
return true;
Modified: trunk/Source/WebCore/svg/SVGImageElement.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGImageElement.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGImageElement.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -97,7 +97,7 @@
void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == SVGNames::preserveAspectRatioAttr) {
- SVGPreserveAspectRatio preserveAspectRatio;
+ SVGPreserveAspectRatioValue preserveAspectRatio;
preserveAspectRatio.parse(value);
setPreserveAspectRatioBaseValue(preserveAspectRatio);
return;
Deleted: trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -1,375 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <[email protected]>
- * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <[email protected]>
- * Copyright (C) 2010 Dirk Schulze <[email protected]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "SVGPreserveAspectRatio.h"
-
-#include "AffineTransform.h"
-#include "ExceptionCode.h"
-#include "FloatRect.h"
-#include "SVGParserUtilities.h"
-#include <wtf/text/StringView.h>
-
-namespace WebCore {
-
-SVGPreserveAspectRatio::SVGPreserveAspectRatio()
- : m_align(SVG_PRESERVEASPECTRATIO_XMIDYMID)
- , m_meetOrSlice(SVG_MEETORSLICE_MEET)
-{
-}
-
-ExceptionOr<void> SVGPreserveAspectRatio::setAlign(unsigned short align)
-{
- if (align == SVG_PRESERVEASPECTRATIO_UNKNOWN || align > SVG_PRESERVEASPECTRATIO_XMAXYMAX)
- return Exception { NOT_SUPPORTED_ERR };
-
- m_align = static_cast<SVGPreserveAspectRatioType>(align);
- return { };
-}
-
-ExceptionOr<void> SVGPreserveAspectRatio::setMeetOrSlice(unsigned short meetOrSlice)
-{
- if (meetOrSlice == SVG_MEETORSLICE_UNKNOWN || meetOrSlice > SVG_MEETORSLICE_SLICE)
- return Exception { NOT_SUPPORTED_ERR };
-
- m_meetOrSlice = static_cast<SVGMeetOrSliceType>(meetOrSlice);
- return { };
-}
-
-void SVGPreserveAspectRatio::parse(const String& value)
-{
- auto upconvertedCharacters = StringView(value).upconvertedCharacters();
- const UChar* begin = upconvertedCharacters;
- parseInternal(begin, begin + value.length(), true);
-}
-
-bool SVGPreserveAspectRatio::parse(const UChar*& currParam, const UChar* end, bool validate)
-{
- return parseInternal(currParam, end, validate);
-}
-
-bool SVGPreserveAspectRatio::parseInternal(const UChar*& currParam, const UChar* end, bool validate)
-{
- SVGPreserveAspectRatioType align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
- SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET;
-
- m_align = align;
- m_meetOrSlice = meetOrSlice;
-
- if (!skipOptionalSVGSpaces(currParam, end))
- return false;
-
- if (*currParam == 'd') {
- if (!skipString(currParam, end, "defer")) {
- LOG_ERROR("Skipped to parse except for *defer* value.");
- return false;
- }
-
- // FIXME: We just ignore the "defer" here.
- if (currParam == end)
- return true;
-
- if (!skipOptionalSVGSpaces(currParam, end))
- return false;
- }
-
- if (*currParam == 'n') {
- if (!skipString(currParam, end, "none")) {
- LOG_ERROR("Skipped to parse except for *none* value.");
- return false;
- }
- align = SVG_PRESERVEASPECTRATIO_NONE;
- skipOptionalSVGSpaces(currParam, end);
- } else if (*currParam == 'x') {
- if ((end - currParam) < 8)
- return false;
- if (currParam[1] != 'M' || currParam[4] != 'Y' || currParam[5] != 'M')
- return false;
- if (currParam[2] == 'i') {
- if (currParam[3] == 'n') {
- if (currParam[6] == 'i') {
- if (currParam[7] == 'n')
- align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
- else if (currParam[7] == 'd')
- align = SVG_PRESERVEASPECTRATIO_XMINYMID;
- else
- return false;
- } else if (currParam[6] == 'a' && currParam[7] == 'x')
- align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
- else
- return false;
- } else if (currParam[3] == 'd') {
- if (currParam[6] == 'i') {
- if (currParam[7] == 'n')
- align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
- else if (currParam[7] == 'd')
- align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
- else
- return false;
- } else if (currParam[6] == 'a' && currParam[7] == 'x')
- align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
- else
- return false;
- } else
- return false;
- } else if (currParam[2] == 'a' && currParam[3] == 'x') {
- if (currParam[6] == 'i') {
- if (currParam[7] == 'n')
- align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
- else if (currParam[7] == 'd')
- align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
- else
- return false;
- } else if (currParam[6] == 'a' && currParam[7] == 'x')
- align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
- else
- return false;
- } else
- return false;
- currParam += 8;
- skipOptionalSVGSpaces(currParam, end);
- } else
- return false;
-
- if (currParam < end) {
- if (*currParam == 'm') {
- if (!skipString(currParam, end, "meet")) {
- LOG_ERROR("Skipped to parse except for *meet* or *slice* value.");
- return false;
- }
- skipOptionalSVGSpaces(currParam, end);
- } else if (*currParam == 's') {
- if (!skipString(currParam, end, "slice")) {
- LOG_ERROR("Skipped to parse except for *meet* or *slice* value.");
- return false;
- }
- skipOptionalSVGSpaces(currParam, end);
- if (align != SVG_PRESERVEASPECTRATIO_NONE)
- meetOrSlice = SVG_MEETORSLICE_SLICE;
- }
- }
-
- if (end != currParam && validate)
- return false;
-
- m_align = align;
- m_meetOrSlice = meetOrSlice;
-
- return true;
-}
-
-void SVGPreserveAspectRatio::transformRect(FloatRect& destRect, FloatRect& srcRect)
-{
- if (m_align == SVG_PRESERVEASPECTRATIO_NONE)
- return;
-
- FloatSize imageSize = srcRect.size();
- float origDestWidth = destRect.width();
- float origDestHeight = destRect.height();
- switch (m_meetOrSlice) {
- case SVGPreserveAspectRatio::SVG_MEETORSLICE_UNKNOWN:
- break;
- case SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET: {
- float widthToHeightMultiplier = srcRect.height() / srcRect.width();
- if (origDestHeight > origDestWidth * widthToHeightMultiplier) {
- destRect.setHeight(origDestWidth * widthToHeightMultiplier);
- switch (m_align) {
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
- destRect.setY(destRect.y() + origDestHeight / 2 - destRect.height() / 2);
- break;
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
- destRect.setY(destRect.y() + origDestHeight - destRect.height());
- break;
- default:
- break;
- }
- }
- if (origDestWidth > origDestHeight / widthToHeightMultiplier) {
- destRect.setWidth(origDestHeight / widthToHeightMultiplier);
- switch (m_align) {
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
- destRect.setX(destRect.x() + origDestWidth / 2 - destRect.width() / 2);
- break;
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
- destRect.setX(destRect.x() + origDestWidth - destRect.width());
- break;
- default:
- break;
- }
- }
- break;
- }
- case SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE: {
- float widthToHeightMultiplier = srcRect.height() / srcRect.width();
- // if the destination height is less than the height of the image we'll be drawing
- if (origDestHeight < origDestWidth * widthToHeightMultiplier) {
- float destToSrcMultiplier = srcRect.width() / destRect.width();
- srcRect.setHeight(destRect.height() * destToSrcMultiplier);
- switch (m_align) {
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
- srcRect.setY(srcRect.y() + imageSize.height() / 2 - srcRect.height() / 2);
- break;
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
- srcRect.setY(srcRect.y() + imageSize.height() - srcRect.height());
- break;
- default:
- break;
- }
- }
- // if the destination width is less than the width of the image we'll be drawing
- if (origDestWidth < origDestHeight / widthToHeightMultiplier) {
- float destToSrcMultiplier = srcRect.height() / destRect.height();
- srcRect.setWidth(destRect.width() * destToSrcMultiplier);
- switch (m_align) {
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
- srcRect.setX(srcRect.x() + imageSize.width() / 2 - srcRect.width() / 2);
- break;
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
- case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
- srcRect.setX(srcRect.x() + imageSize.width() - srcRect.width());
- break;
- default:
- break;
- }
- }
- break;
- }
- }
-}
-
-AffineTransform SVGPreserveAspectRatio::getCTM(float logicalX, float logicalY, float logicalWidth, float logicalHeight, float physicalWidth, float physicalHeight) const
-{
- AffineTransform transform;
- if (!logicalWidth || !logicalHeight || !physicalWidth || !physicalHeight) {
- ASSERT_NOT_REACHED();
- return transform;
- }
-
- if (m_align == SVG_PRESERVEASPECTRATIO_UNKNOWN)
- return transform;
-
- double extendedLogicalX = logicalX;
- double extendedLogicalY = logicalY;
- double extendedLogicalWidth = logicalWidth;
- double extendedLogicalHeight = logicalHeight;
- double extendedPhysicalWidth = physicalWidth;
- double extendedPhysicalHeight = physicalHeight;
- double logicalRatio = extendedLogicalWidth / extendedLogicalHeight;
- double physicalRatio = extendedPhysicalWidth / extendedPhysicalHeight;
-
- if (m_align == SVG_PRESERVEASPECTRATIO_NONE) {
- transform.scaleNonUniform(extendedPhysicalWidth / extendedLogicalWidth, extendedPhysicalHeight / extendedLogicalHeight);
- transform.translate(-extendedLogicalX, -extendedLogicalY);
- return transform;
- }
-
- if ((logicalRatio < physicalRatio && (m_meetOrSlice == SVG_MEETORSLICE_MEET)) || (logicalRatio >= physicalRatio && (m_meetOrSlice == SVG_MEETORSLICE_SLICE))) {
- transform.scaleNonUniform(extendedPhysicalHeight / extendedLogicalHeight, extendedPhysicalHeight / extendedLogicalHeight);
-
- if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMINYMID || m_align == SVG_PRESERVEASPECTRATIO_XMINYMAX)
- transform.translate(-extendedLogicalX, -extendedLogicalY);
- else if (m_align == SVG_PRESERVEASPECTRATIO_XMIDYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMID || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMAX)
- transform.translate(-extendedLogicalX - (extendedLogicalWidth - extendedPhysicalWidth * extendedLogicalHeight / extendedPhysicalHeight) / 2, -extendedLogicalY);
- else
- transform.translate(-extendedLogicalX - (extendedLogicalWidth - extendedPhysicalWidth * extendedLogicalHeight / extendedPhysicalHeight), -extendedLogicalY);
-
- return transform;
- }
-
- transform.scaleNonUniform(extendedPhysicalWidth / extendedLogicalWidth, extendedPhysicalWidth / extendedLogicalWidth);
-
- if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMAXYMIN)
- transform.translate(-extendedLogicalX, -extendedLogicalY);
- else if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMID || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMID || m_align == SVG_PRESERVEASPECTRATIO_XMAXYMID)
- transform.translate(-extendedLogicalX, -extendedLogicalY - (extendedLogicalHeight - extendedPhysicalHeight * extendedLogicalWidth / extendedPhysicalWidth) / 2);
- else
- transform.translate(-extendedLogicalX, -extendedLogicalY - (extendedLogicalHeight - extendedPhysicalHeight * extendedLogicalWidth / extendedPhysicalWidth));
-
- return transform;
-}
-
-String SVGPreserveAspectRatio::valueAsString() const
-{
- String alignType;
-
- switch (m_align) {
- case SVG_PRESERVEASPECTRATIO_NONE:
- alignType = "none";
- break;
- case SVG_PRESERVEASPECTRATIO_XMINYMIN:
- alignType = "xMinYMin";
- break;
- case SVG_PRESERVEASPECTRATIO_XMIDYMIN:
- alignType = "xMidYMin";
- break;
- case SVG_PRESERVEASPECTRATIO_XMAXYMIN:
- alignType = "xMaxYMin";
- break;
- case SVG_PRESERVEASPECTRATIO_XMINYMID:
- alignType = "xMinYMid";
- break;
- case SVG_PRESERVEASPECTRATIO_XMIDYMID:
- alignType = "xMidYMid";
- break;
- case SVG_PRESERVEASPECTRATIO_XMAXYMID:
- alignType = "xMaxYMid";
- break;
- case SVG_PRESERVEASPECTRATIO_XMINYMAX:
- alignType = "xMinYMax";
- break;
- case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
- alignType = "xMidYMax";
- break;
- case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
- alignType = "xMaxYMax";
- break;
- case SVG_PRESERVEASPECTRATIO_UNKNOWN:
- alignType = "unknown";
- break;
- };
-
- switch (m_meetOrSlice) {
- default:
- case SVG_MEETORSLICE_UNKNOWN:
- return alignType;
- case SVG_MEETORSLICE_MEET:
- return alignType + " meet";
- case SVG_MEETORSLICE_SLICE:
- return alignType + " slice";
- }
-}
-
-}
Modified: trunk/Source/WebCore/svg/SVGPreserveAspectRatio.h (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGPreserveAspectRatio.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGPreserveAspectRatio.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -1,83 +1,111 @@
/*
- * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <[email protected]>
- * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <[email protected]>
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#pragma once
-#include "ExceptionOr.h"
-#include "SVGPropertyTraits.h"
+#include "ExceptionCode.h"
+#include "SVGPreserveAspectRatioValue.h"
+#include "SVGPropertyTearOff.h"
namespace WebCore {
-class AffineTransform;
-class FloatRect;
-
-class SVGPreserveAspectRatio {
- WTF_MAKE_FAST_ALLOCATED;
+class SVGPreserveAspectRatio : public SVGPropertyTearOff<SVGPreserveAspectRatioValue> {
public:
- enum SVGPreserveAspectRatioType {
- SVG_PRESERVEASPECTRATIO_UNKNOWN = 0,
- SVG_PRESERVEASPECTRATIO_NONE = 1,
- SVG_PRESERVEASPECTRATIO_XMINYMIN = 2,
- SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3,
- SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4,
- SVG_PRESERVEASPECTRATIO_XMINYMID = 5,
- SVG_PRESERVEASPECTRATIO_XMIDYMID = 6,
- SVG_PRESERVEASPECTRATIO_XMAXYMID = 7,
- SVG_PRESERVEASPECTRATIO_XMINYMAX = 8,
- SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9,
- SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10
- };
+ static Ref<SVGPreserveAspectRatio> create(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, SVGPreserveAspectRatioValue& value)
+ {
+ ASSERT(animatedProperty);
+ return adoptRef(*new SVGPreserveAspectRatio(animatedProperty, role, value));
+ }
- enum SVGMeetOrSliceType {
- SVG_MEETORSLICE_UNKNOWN = 0,
- SVG_MEETORSLICE_MEET = 1,
- SVG_MEETORSLICE_SLICE = 2
- };
+ static Ref<SVGPreserveAspectRatio> create(const SVGPreserveAspectRatioValue& initialValue = { })
+ {
+ return adoptRef(*new SVGPreserveAspectRatio(initialValue));
+ }
- SVGPreserveAspectRatio();
+ static Ref<SVGPreserveAspectRatio> create(const SVGPreserveAspectRatioValue* initialValue)
+ {
+ return adoptRef(*new SVGPreserveAspectRatio(initialValue));
+ }
- ExceptionOr<void> setAlign(unsigned short);
- unsigned short align() const { return m_align; }
+ template<typename T> static ExceptionOr<Ref<SVGPreserveAspectRatio>> create(ExceptionOr<T>&& initialValue)
+ {
+ if (initialValue.hasException())
+ return initialValue.releaseException();
+ return create(initialValue.releaseReturnValue());
+ }
- ExceptionOr<void> setMeetOrSlice(unsigned short);
- unsigned short meetOrSlice() const { return m_meetOrSlice; }
+ unsigned short align()
+ {
+ return propertyReference().align();
+ }
- void transformRect(FloatRect& destRect, FloatRect& srcRect);
+ ExceptionOr<void> setAlign(float value)
+ {
+ if (isReadOnly())
+ return Exception { NO_MODIFICATION_ALLOWED_ERR };
- AffineTransform getCTM(float logicalX, float logicalY, float logicalWidth, float logicalHeight, float physicalWidth, float physicalHeight) const;
+ auto result = propertyReference().setAlign(value);
+ if (result.hasException())
+ return result;
- void parse(const String&);
- bool parse(const UChar*& currParam, const UChar* end, bool validate);
+ commitChange();
+ return result;
+ }
- String valueAsString() const;
+ unsigned short meetOrSlice()
+ {
+ return propertyReference().meetOrSlice();
+ }
+ ExceptionOr<void> setMeetOrSlice(float value)
+ {
+ if (isReadOnly())
+ return Exception { NO_MODIFICATION_ALLOWED_ERR };
+
+ auto result = propertyReference().setMeetOrSlice(value);
+ if (result.hasException())
+ return result;
+
+ commitChange();
+ return result;
+ }
+
private:
- SVGPreserveAspectRatioType m_align;
- SVGMeetOrSliceType m_meetOrSlice;
+ SVGPreserveAspectRatio(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, SVGPreserveAspectRatioValue& value)
+ : SVGPropertyTearOff<SVGPreserveAspectRatioValue>(animatedProperty, role, value)
+ {
+ }
- bool parseInternal(const UChar*& currParam, const UChar* end, bool validate);
-};
+ explicit SVGPreserveAspectRatio(const SVGPreserveAspectRatioValue& initialValue)
+ : SVGPropertyTearOff<SVGPreserveAspectRatioValue>(initialValue)
+ {
+ }
-template<> struct SVGPropertyTraits<SVGPreserveAspectRatio> {
- static SVGPreserveAspectRatio initialValue() { return SVGPreserveAspectRatio(); }
- static String toString(const SVGPreserveAspectRatio& type) { return type.valueAsString(); }
+ explicit SVGPreserveAspectRatio(const SVGPreserveAspectRatioValue* initialValue)
+ : SVGPropertyTearOff<SVGPreserveAspectRatioValue>(initialValue)
+ {
+ }
};
} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGPreserveAspectRatio.idl (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGPreserveAspectRatio.idl 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGPreserveAspectRatio.idl 2016-11-11 06:29:44 UTC (rev 208581)
@@ -23,7 +23,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-interface SVGPreserveAspectRatio {
+[
+ ConstantsScope=SVGPreserveAspectRatioValue
+] interface SVGPreserveAspectRatio {
// Alignment Types
const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1;
Copied: trunk/Source/WebCore/svg/SVGPreserveAspectRatioValue.cpp (from rev 208580, trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp) (0 => 208581)
--- trunk/Source/WebCore/svg/SVGPreserveAspectRatioValue.cpp (rev 0)
+++ trunk/Source/WebCore/svg/SVGPreserveAspectRatioValue.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -0,0 +1,375 @@
+/*
+ * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <[email protected]>
+ * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <[email protected]>
+ * Copyright (C) 2010 Dirk Schulze <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "SVGPreserveAspectRatioValue.h"
+
+#include "AffineTransform.h"
+#include "ExceptionCode.h"
+#include "FloatRect.h"
+#include "SVGParserUtilities.h"
+#include <wtf/text/StringView.h>
+
+namespace WebCore {
+
+SVGPreserveAspectRatioValue::SVGPreserveAspectRatioValue()
+ : m_align(SVG_PRESERVEASPECTRATIO_XMIDYMID)
+ , m_meetOrSlice(SVG_MEETORSLICE_MEET)
+{
+}
+
+ExceptionOr<void> SVGPreserveAspectRatioValue::setAlign(unsigned short align)
+{
+ if (align == SVG_PRESERVEASPECTRATIO_UNKNOWN || align > SVG_PRESERVEASPECTRATIO_XMAXYMAX)
+ return Exception { NOT_SUPPORTED_ERR };
+
+ m_align = static_cast<SVGPreserveAspectRatioType>(align);
+ return { };
+}
+
+ExceptionOr<void> SVGPreserveAspectRatioValue::setMeetOrSlice(unsigned short meetOrSlice)
+{
+ if (meetOrSlice == SVG_MEETORSLICE_UNKNOWN || meetOrSlice > SVG_MEETORSLICE_SLICE)
+ return Exception { NOT_SUPPORTED_ERR };
+
+ m_meetOrSlice = static_cast<SVGMeetOrSliceType>(meetOrSlice);
+ return { };
+}
+
+void SVGPreserveAspectRatioValue::parse(const String& value)
+{
+ auto upconvertedCharacters = StringView(value).upconvertedCharacters();
+ const UChar* begin = upconvertedCharacters;
+ parseInternal(begin, begin + value.length(), true);
+}
+
+bool SVGPreserveAspectRatioValue::parse(const UChar*& currParam, const UChar* end, bool validate)
+{
+ return parseInternal(currParam, end, validate);
+}
+
+bool SVGPreserveAspectRatioValue::parseInternal(const UChar*& currParam, const UChar* end, bool validate)
+{
+ SVGPreserveAspectRatioType align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
+ SVGMeetOrSliceType meetOrSlice = SVG_MEETORSLICE_MEET;
+
+ m_align = align;
+ m_meetOrSlice = meetOrSlice;
+
+ if (!skipOptionalSVGSpaces(currParam, end))
+ return false;
+
+ if (*currParam == 'd') {
+ if (!skipString(currParam, end, "defer")) {
+ LOG_ERROR("Skipped to parse except for *defer* value.");
+ return false;
+ }
+
+ // FIXME: We just ignore the "defer" here.
+ if (currParam == end)
+ return true;
+
+ if (!skipOptionalSVGSpaces(currParam, end))
+ return false;
+ }
+
+ if (*currParam == 'n') {
+ if (!skipString(currParam, end, "none")) {
+ LOG_ERROR("Skipped to parse except for *none* value.");
+ return false;
+ }
+ align = SVG_PRESERVEASPECTRATIO_NONE;
+ skipOptionalSVGSpaces(currParam, end);
+ } else if (*currParam == 'x') {
+ if ((end - currParam) < 8)
+ return false;
+ if (currParam[1] != 'M' || currParam[4] != 'Y' || currParam[5] != 'M')
+ return false;
+ if (currParam[2] == 'i') {
+ if (currParam[3] == 'n') {
+ if (currParam[6] == 'i') {
+ if (currParam[7] == 'n')
+ align = SVG_PRESERVEASPECTRATIO_XMINYMIN;
+ else if (currParam[7] == 'd')
+ align = SVG_PRESERVEASPECTRATIO_XMINYMID;
+ else
+ return false;
+ } else if (currParam[6] == 'a' && currParam[7] == 'x')
+ align = SVG_PRESERVEASPECTRATIO_XMINYMAX;
+ else
+ return false;
+ } else if (currParam[3] == 'd') {
+ if (currParam[6] == 'i') {
+ if (currParam[7] == 'n')
+ align = SVG_PRESERVEASPECTRATIO_XMIDYMIN;
+ else if (currParam[7] == 'd')
+ align = SVG_PRESERVEASPECTRATIO_XMIDYMID;
+ else
+ return false;
+ } else if (currParam[6] == 'a' && currParam[7] == 'x')
+ align = SVG_PRESERVEASPECTRATIO_XMIDYMAX;
+ else
+ return false;
+ } else
+ return false;
+ } else if (currParam[2] == 'a' && currParam[3] == 'x') {
+ if (currParam[6] == 'i') {
+ if (currParam[7] == 'n')
+ align = SVG_PRESERVEASPECTRATIO_XMAXYMIN;
+ else if (currParam[7] == 'd')
+ align = SVG_PRESERVEASPECTRATIO_XMAXYMID;
+ else
+ return false;
+ } else if (currParam[6] == 'a' && currParam[7] == 'x')
+ align = SVG_PRESERVEASPECTRATIO_XMAXYMAX;
+ else
+ return false;
+ } else
+ return false;
+ currParam += 8;
+ skipOptionalSVGSpaces(currParam, end);
+ } else
+ return false;
+
+ if (currParam < end) {
+ if (*currParam == 'm') {
+ if (!skipString(currParam, end, "meet")) {
+ LOG_ERROR("Skipped to parse except for *meet* or *slice* value.");
+ return false;
+ }
+ skipOptionalSVGSpaces(currParam, end);
+ } else if (*currParam == 's') {
+ if (!skipString(currParam, end, "slice")) {
+ LOG_ERROR("Skipped to parse except for *meet* or *slice* value.");
+ return false;
+ }
+ skipOptionalSVGSpaces(currParam, end);
+ if (align != SVG_PRESERVEASPECTRATIO_NONE)
+ meetOrSlice = SVG_MEETORSLICE_SLICE;
+ }
+ }
+
+ if (end != currParam && validate)
+ return false;
+
+ m_align = align;
+ m_meetOrSlice = meetOrSlice;
+
+ return true;
+}
+
+void SVGPreserveAspectRatioValue::transformRect(FloatRect& destRect, FloatRect& srcRect)
+{
+ if (m_align == SVG_PRESERVEASPECTRATIO_NONE)
+ return;
+
+ FloatSize imageSize = srcRect.size();
+ float origDestWidth = destRect.width();
+ float origDestHeight = destRect.height();
+ switch (m_meetOrSlice) {
+ case SVGPreserveAspectRatioValue::SVG_MEETORSLICE_UNKNOWN:
+ break;
+ case SVGPreserveAspectRatioValue::SVG_MEETORSLICE_MEET: {
+ float widthToHeightMultiplier = srcRect.height() / srcRect.width();
+ if (origDestHeight > origDestWidth * widthToHeightMultiplier) {
+ destRect.setHeight(origDestWidth * widthToHeightMultiplier);
+ switch (m_align) {
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMINYMID:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMID:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMID:
+ destRect.setY(destRect.y() + origDestHeight / 2 - destRect.height() / 2);
+ break;
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMINYMAX:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+ destRect.setY(destRect.y() + origDestHeight - destRect.height());
+ break;
+ default:
+ break;
+ }
+ }
+ if (origDestWidth > origDestHeight / widthToHeightMultiplier) {
+ destRect.setWidth(origDestHeight / widthToHeightMultiplier);
+ switch (m_align) {
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMID:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+ destRect.setX(destRect.x() + origDestWidth / 2 - destRect.width() / 2);
+ break;
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMID:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+ destRect.setX(destRect.x() + origDestWidth - destRect.width());
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ case SVGPreserveAspectRatioValue::SVG_MEETORSLICE_SLICE: {
+ float widthToHeightMultiplier = srcRect.height() / srcRect.width();
+ // if the destination height is less than the height of the image we'll be drawing
+ if (origDestHeight < origDestWidth * widthToHeightMultiplier) {
+ float destToSrcMultiplier = srcRect.width() / destRect.width();
+ srcRect.setHeight(destRect.height() * destToSrcMultiplier);
+ switch (m_align) {
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMINYMID:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMID:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMID:
+ srcRect.setY(srcRect.y() + imageSize.height() / 2 - srcRect.height() / 2);
+ break;
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMINYMAX:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+ srcRect.setY(srcRect.y() + imageSize.height() - srcRect.height());
+ break;
+ default:
+ break;
+ }
+ }
+ // if the destination width is less than the width of the image we'll be drawing
+ if (origDestWidth < origDestHeight / widthToHeightMultiplier) {
+ float destToSrcMultiplier = srcRect.height() / destRect.height();
+ srcRect.setWidth(destRect.width() * destToSrcMultiplier);
+ switch (m_align) {
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMID:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+ srcRect.setX(srcRect.x() + imageSize.width() / 2 - srcRect.width() / 2);
+ break;
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMID:
+ case SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+ srcRect.setX(srcRect.x() + imageSize.width() - srcRect.width());
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ }
+}
+
+AffineTransform SVGPreserveAspectRatioValue::getCTM(float logicalX, float logicalY, float logicalWidth, float logicalHeight, float physicalWidth, float physicalHeight) const
+{
+ AffineTransform transform;
+ if (!logicalWidth || !logicalHeight || !physicalWidth || !physicalHeight) {
+ ASSERT_NOT_REACHED();
+ return transform;
+ }
+
+ if (m_align == SVG_PRESERVEASPECTRATIO_UNKNOWN)
+ return transform;
+
+ double extendedLogicalX = logicalX;
+ double extendedLogicalY = logicalY;
+ double extendedLogicalWidth = logicalWidth;
+ double extendedLogicalHeight = logicalHeight;
+ double extendedPhysicalWidth = physicalWidth;
+ double extendedPhysicalHeight = physicalHeight;
+ double logicalRatio = extendedLogicalWidth / extendedLogicalHeight;
+ double physicalRatio = extendedPhysicalWidth / extendedPhysicalHeight;
+
+ if (m_align == SVG_PRESERVEASPECTRATIO_NONE) {
+ transform.scaleNonUniform(extendedPhysicalWidth / extendedLogicalWidth, extendedPhysicalHeight / extendedLogicalHeight);
+ transform.translate(-extendedLogicalX, -extendedLogicalY);
+ return transform;
+ }
+
+ if ((logicalRatio < physicalRatio && (m_meetOrSlice == SVG_MEETORSLICE_MEET)) || (logicalRatio >= physicalRatio && (m_meetOrSlice == SVG_MEETORSLICE_SLICE))) {
+ transform.scaleNonUniform(extendedPhysicalHeight / extendedLogicalHeight, extendedPhysicalHeight / extendedLogicalHeight);
+
+ if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMINYMID || m_align == SVG_PRESERVEASPECTRATIO_XMINYMAX)
+ transform.translate(-extendedLogicalX, -extendedLogicalY);
+ else if (m_align == SVG_PRESERVEASPECTRATIO_XMIDYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMID || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMAX)
+ transform.translate(-extendedLogicalX - (extendedLogicalWidth - extendedPhysicalWidth * extendedLogicalHeight / extendedPhysicalHeight) / 2, -extendedLogicalY);
+ else
+ transform.translate(-extendedLogicalX - (extendedLogicalWidth - extendedPhysicalWidth * extendedLogicalHeight / extendedPhysicalHeight), -extendedLogicalY);
+
+ return transform;
+ }
+
+ transform.scaleNonUniform(extendedPhysicalWidth / extendedLogicalWidth, extendedPhysicalWidth / extendedLogicalWidth);
+
+ if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMIN || m_align == SVG_PRESERVEASPECTRATIO_XMAXYMIN)
+ transform.translate(-extendedLogicalX, -extendedLogicalY);
+ else if (m_align == SVG_PRESERVEASPECTRATIO_XMINYMID || m_align == SVG_PRESERVEASPECTRATIO_XMIDYMID || m_align == SVG_PRESERVEASPECTRATIO_XMAXYMID)
+ transform.translate(-extendedLogicalX, -extendedLogicalY - (extendedLogicalHeight - extendedPhysicalHeight * extendedLogicalWidth / extendedPhysicalWidth) / 2);
+ else
+ transform.translate(-extendedLogicalX, -extendedLogicalY - (extendedLogicalHeight - extendedPhysicalHeight * extendedLogicalWidth / extendedPhysicalWidth));
+
+ return transform;
+}
+
+String SVGPreserveAspectRatioValue::valueAsString() const
+{
+ String alignType;
+
+ switch (m_align) {
+ case SVG_PRESERVEASPECTRATIO_NONE:
+ alignType = "none";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMINYMIN:
+ alignType = "xMinYMin";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMIDYMIN:
+ alignType = "xMidYMin";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMAXYMIN:
+ alignType = "xMaxYMin";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMINYMID:
+ alignType = "xMinYMid";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMIDYMID:
+ alignType = "xMidYMid";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMAXYMID:
+ alignType = "xMaxYMid";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMINYMAX:
+ alignType = "xMinYMax";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+ alignType = "xMidYMax";
+ break;
+ case SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+ alignType = "xMaxYMax";
+ break;
+ case SVG_PRESERVEASPECTRATIO_UNKNOWN:
+ alignType = "unknown";
+ break;
+ };
+
+ switch (m_meetOrSlice) {
+ default:
+ case SVG_MEETORSLICE_UNKNOWN:
+ return alignType;
+ case SVG_MEETORSLICE_MEET:
+ return alignType + " meet";
+ case SVG_MEETORSLICE_SLICE:
+ return alignType + " slice";
+ }
+}
+
+}
Copied: trunk/Source/WebCore/svg/SVGPreserveAspectRatioValue.h (from rev 208580, trunk/Source/WebCore/svg/SVGPreserveAspectRatio.h) (0 => 208581)
--- trunk/Source/WebCore/svg/SVGPreserveAspectRatioValue.h (rev 0)
+++ trunk/Source/WebCore/svg/SVGPreserveAspectRatioValue.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <[email protected]>
+ * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "ExceptionOr.h"
+#include "SVGPropertyTraits.h"
+
+namespace WebCore {
+
+class AffineTransform;
+class FloatRect;
+
+class SVGPreserveAspectRatioValue {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ enum SVGPreserveAspectRatioType {
+ SVG_PRESERVEASPECTRATIO_UNKNOWN = 0,
+ SVG_PRESERVEASPECTRATIO_NONE = 1,
+ SVG_PRESERVEASPECTRATIO_XMINYMIN = 2,
+ SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3,
+ SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4,
+ SVG_PRESERVEASPECTRATIO_XMINYMID = 5,
+ SVG_PRESERVEASPECTRATIO_XMIDYMID = 6,
+ SVG_PRESERVEASPECTRATIO_XMAXYMID = 7,
+ SVG_PRESERVEASPECTRATIO_XMINYMAX = 8,
+ SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9,
+ SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10
+ };
+
+ enum SVGMeetOrSliceType {
+ SVG_MEETORSLICE_UNKNOWN = 0,
+ SVG_MEETORSLICE_MEET = 1,
+ SVG_MEETORSLICE_SLICE = 2
+ };
+
+ SVGPreserveAspectRatioValue();
+
+ ExceptionOr<void> setAlign(unsigned short);
+ unsigned short align() const { return m_align; }
+
+ ExceptionOr<void> setMeetOrSlice(unsigned short);
+ unsigned short meetOrSlice() const { return m_meetOrSlice; }
+
+ void transformRect(FloatRect& destRect, FloatRect& srcRect);
+
+ AffineTransform getCTM(float logicalX, float logicalY, float logicalWidth, float logicalHeight, float physicalWidth, float physicalHeight) const;
+
+ void parse(const String&);
+ bool parse(const UChar*& currParam, const UChar* end, bool validate);
+
+ String valueAsString() const;
+
+private:
+ SVGPreserveAspectRatioType m_align;
+ SVGMeetOrSliceType m_meetOrSlice;
+
+ bool parseInternal(const UChar*& currParam, const UChar* end, bool validate);
+};
+
+template<> struct SVGPropertyTraits<SVGPreserveAspectRatioValue> {
+ static SVGPreserveAspectRatioValue initialValue() { return SVGPreserveAspectRatioValue(); }
+ static String toString(const SVGPreserveAspectRatioValue& type) { return type.valueAsString(); }
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/svg/SVGViewSpec.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGViewSpec.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGViewSpec.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -117,7 +117,7 @@
String SVGViewSpec::preserveAspectRatioString() const
{
- return SVGPropertyTraits<SVGPreserveAspectRatio>::toString(m_preserveAspectRatio);
+ return SVGPropertyTraits<SVGPreserveAspectRatioValue>::toString(m_preserveAspectRatio);
}
SVGElement* SVGViewSpec::viewTarget() const
@@ -163,7 +163,7 @@
{
ASSERT(ownerType);
ASSERT(ownerType->m_contextElement);
- return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatio>(ownerType->m_contextElement, preserveAspectRatioPropertyInfo(), ownerType->m_preserveAspectRatio);
+ return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatioValue>(ownerType->m_contextElement, preserveAspectRatioPropertyInfo(), ownerType->m_preserveAspectRatio);
}
Ref<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateTransformWrapper(SVGViewSpec* ownerType)
@@ -178,7 +178,7 @@
m_zoomAndPan = SVGZoomAndPanMagnify;
m_transform.clear();
m_viewBox = FloatRect();
- m_preserveAspectRatio = SVGPreserveAspectRatio();
+ m_preserveAspectRatio = SVGPreserveAspectRatioValue();
m_viewTargetString = emptyString();
}
@@ -247,7 +247,7 @@
if (currViewSpec >= end || *currViewSpec != '(')
return false;
currViewSpec++;
- SVGPreserveAspectRatio preserveAspectRatio;
+ SVGPreserveAspectRatioValue preserveAspectRatio;
if (!preserveAspectRatio.parse(currViewSpec, end, false))
return false;
setPreserveAspectRatioBaseValue(preserveAspectRatio);
Modified: trunk/Source/WebCore/svg/SVGViewSpec.h (208580 => 208581)
--- trunk/Source/WebCore/svg/SVGViewSpec.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/SVGViewSpec.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -64,8 +64,8 @@
// Custom animated 'preserveAspectRatio' property.
RefPtr<SVGAnimatedPreserveAspectRatio> preserveAspectRatioAnimated();
- SVGPreserveAspectRatio& preserveAspectRatio() { return m_preserveAspectRatio; }
- void setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatio& preserveAspectRatio) { m_preserveAspectRatio = preserveAspectRatio; }
+ SVGPreserveAspectRatioValue& preserveAspectRatio() { return m_preserveAspectRatio; }
+ void setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatioValue& preserveAspectRatio) { m_preserveAspectRatio = preserveAspectRatio; }
private:
explicit SVGViewSpec(SVGElement&);
@@ -86,7 +86,7 @@
SVGZoomAndPanType m_zoomAndPan { SVGZoomAndPanMagnify };
SVGTransformList m_transform;
FloatRect m_viewBox;
- SVGPreserveAspectRatio m_preserveAspectRatio;
+ SVGPreserveAspectRatioValue m_preserveAspectRatio;
String m_viewTargetString;
};
Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -359,7 +359,7 @@
intrinsicWidth = rootElement->intrinsicWidth();
intrinsicHeight = rootElement->intrinsicHeight();
- if (rootElement->preserveAspectRatio().align() == SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
+ if (rootElement->preserveAspectRatio().align() == SVGPreserveAspectRatioValue::SVG_PRESERVEASPECTRATIO_NONE)
return;
intrinsicRatio = rootElement->viewBox().size();
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp (208580 => 208581)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp 2016-11-11 06:29:44 UTC (rev 208581)
@@ -29,7 +29,6 @@
#include "RenderElement.h"
#include "RenderTreeAsText.h"
#include "SVGElement.h"
-#include "SVGPreserveAspectRatio.h"
#include "SVGRenderingContext.h"
#include "SVGURIReference.h"
#include "TextStream.h"
@@ -36,7 +35,7 @@
namespace WebCore {
-FEImage::FEImage(Filter& filter, RefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio)
+FEImage::FEImage(Filter& filter, RefPtr<Image> image, const SVGPreserveAspectRatioValue& preserveAspectRatio)
: FilterEffect(filter)
, m_image(image)
, m_document(nullptr)
@@ -44,7 +43,7 @@
{
}
-FEImage::FEImage(Filter& filter, Document& document, const String& href, const SVGPreserveAspectRatio& preserveAspectRatio)
+FEImage::FEImage(Filter& filter, Document& document, const String& href, const SVGPreserveAspectRatioValue& preserveAspectRatio)
: FilterEffect(filter)
, m_document(&document)
, m_href(href)
@@ -52,12 +51,12 @@
{
}
-Ref<FEImage> FEImage::createWithImage(Filter& filter, RefPtr<Image> image, const SVGPreserveAspectRatio& preserveAspectRatio)
+Ref<FEImage> FEImage::createWithImage(Filter& filter, RefPtr<Image> image, const SVGPreserveAspectRatioValue& preserveAspectRatio)
{
return adoptRef(*new FEImage(filter, image, preserveAspectRatio));
}
-Ref<FEImage> FEImage::createWithIRIReference(Filter& filter, Document& document, const String& href, const SVGPreserveAspectRatio& preserveAspectRatio)
+Ref<FEImage> FEImage::createWithIRIReference(Filter& filter, Document& document, const String& href, const SVGPreserveAspectRatioValue& preserveAspectRatio)
{
return adoptRef(*new FEImage(filter, document, href, preserveAspectRatio));
}
Modified: trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.h (208580 => 208581)
--- trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.h 2016-11-11 06:16:08 UTC (rev 208580)
+++ trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.h 2016-11-11 06:29:44 UTC (rev 208581)
@@ -24,7 +24,7 @@
#define SVGFEImage_h
#include "FilterEffect.h"
-#include "SVGPreserveAspectRatio.h"
+#include "SVGPreserveAspectRatioValue.h"
namespace WebCore {
@@ -34,8 +34,8 @@
class FEImage final : public FilterEffect {
public:
- static Ref<FEImage> createWithImage(Filter&, RefPtr<Image>, const SVGPreserveAspectRatio&);
- static Ref<FEImage> createWithIRIReference(Filter&, Document&, const String&, const SVGPreserveAspectRatio&);
+ static Ref<FEImage> createWithImage(Filter&, RefPtr<Image>, const SVGPreserveAspectRatioValue&);
+ static Ref<FEImage> createWithIRIReference(Filter&, Document&, const String&, const SVGPreserveAspectRatioValue&);
void platformApplySoftware() final;
void dump() final;
@@ -48,8 +48,8 @@
private:
virtual ~FEImage() { }
- FEImage(Filter&, RefPtr<Image>, const SVGPreserveAspectRatio&);
- FEImage(Filter&, Document&, const String&, const SVGPreserveAspectRatio&);
+ FEImage(Filter&, RefPtr<Image>, const SVGPreserveAspectRatioValue&);
+ FEImage(Filter&, Document&, const String&, const SVGPreserveAspectRatioValue&);
RenderElement* referencedRenderer() const;
RefPtr<Image> m_image;
@@ -57,7 +57,7 @@
// m_document will never be a dangling reference. See https://bugs.webkit.org/show_bug.cgi?id=99243
Document* m_document;
String m_href;
- SVGPreserveAspectRatio m_preserveAspectRatio;
+ SVGPreserveAspectRatioValue m_preserveAspectRatio;
};
} // namespace WebCore