diff --git a/submodules/Svg/BUCK b/submodules/Svg/BUCK index 29bf614a72..f8b2a7b112 100644 --- a/submodules/Svg/BUCK +++ b/submodules/Svg/BUCK @@ -8,23 +8,10 @@ static_library( "Sources/**/*.c", "Sources/**/*.cpp", ]), - compiler_flags = [ - "-DSVGKitLogVerbose(...)=1", - "-DSVGKitLogWarn(...)=1", - "-DSVGKitLogError(...)=1", - "-DSVGKitLogInfo(...)=1", - "-I$SDKROOT/usr/include/libxml2", - ], headers = glob([ "Sources/**/*.h", ]), - exported_headers = glob([ - "Sources/*.h", - ]), - exported_linker_flags = [ - "-lxml2", - ], - deps = [ - "//submodules/GZip:GZip", + exported_headers = [ + "Sources/Svg.h", ], ) diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/AppleSucksDOMImplementation.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/AppleSucksDOMImplementation.h deleted file mode 100644 index f684956c24..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/AppleSucksDOMImplementation.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - PLEASE NOTE: Apple has made a PRIVATE implementation of this class, and because of their - stupid App Store rules they ban everyone else in the world from using a class with the - same name. Instead of making the class public, they have stolen it out of the global - namespace. This is the wrong thing to do, but we are required to rename our classes - because of this. - - SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 - - interface DOMImplementation { - boolean hasFeature(in DOMString feature, - in DOMString version); - // Introduced in DOM Level 2: - DocumentType createDocumentType(in DOMString qualifiedName, - in DOMString publicId, - in DOMString systemId) - raises(DOMException); - // Introduced in DOM Level 2: - Document createDocument(in DOMString namespaceURI, - in DOMString qualifiedName, - in DocumentType doctype) - raises(DOMException); - }; -*/ - -#import - -#import "DocumentType.h" - -@interface AppleSucksDOMImplementation : NSObject - --(BOOL) hasFeature:(NSString*) feature version:(NSString*) version; - -// Introduced in DOM Level 2: --(DocumentType*) createDocumentType:(NSString*) qualifiedName publicId:(NSString*) publicId systemId:(NSString*) systemId; - -// Introduced in DOM Level 2: --(Document*) createDocument:(NSString*) namespaceURI qualifiedName:(NSString*) qualifiedName doctype:(DocumentType*) doctype; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/AppleSucksDOMImplementation.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/AppleSucksDOMImplementation.m deleted file mode 100644 index 40d34d7400..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/AppleSucksDOMImplementation.m +++ /dev/null @@ -1,33 +0,0 @@ - -#import "AppleSucksDOMImplementation.h" - -@implementation AppleSucksDOMImplementation - --(BOOL) hasFeature:(NSString*) feature version:(NSString*) version -{ - NSAssert( FALSE, @"Apple has made a private class with the same name as this class - we have to rename it because ObjectiveC sucks, and Apple used a foolish name, so we CANNOT adhere to the spec now" ); - - NSAssert( FALSE, @"Not implemented yet" ); - return FALSE; -} - -// Introduced in DOM Level 2: --(DocumentType*) createDocumentType:(NSString*) qualifiedName publicId:(NSString*) publicId systemId:(NSString*) systemId -{ - NSAssert( FALSE, @"Apple has made a private class with the same name as this class - we have to rename it because ObjectiveC sucks, and Apple used a foolish name, so we CANNOT adhere to the spec now" ); - - NSAssert( FALSE, @"Not implemented yet" ); - return nil; -} - - -// Introduced in DOM Level 2: --(Document*) createDocument:(NSString*) namespaceURI qualifiedName:(NSString*) qualifiedName doctype:(DocumentType*) doctype -{ - NSAssert( FALSE, @"Apple has made a private class with the same name as this class - we have to rename it because ObjectiveC sucks, and Apple used a foolish name, so we CANNOT adhere to the spec now" ); - - NSAssert( FALSE, @"Not implemented yet" ); - return nil; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Attr.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Attr.h deleted file mode 100644 index f387aed016..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Attr.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-637646024 - - interface Attr : Node { - readonly attribute DOMString name; - readonly attribute boolean specified; - attribute DOMString value; - // raises(DOMException) on setting - - // Introduced in DOM Level 2: - readonly attribute Element ownerElement; - }; -*/ -#import - -/** objc won't allow this: @class Node;*/ -#import "Node.h" -@class Element; - -@interface Attr : Node - -/*! NB: The official DOM spec FAILS TO SPECIFY what the value of "name" is */ -@property(nonatomic,strong,readonly) NSString* name; -@property(nonatomic,readonly) BOOL specified; -@property(nonatomic,strong,readonly) NSString* value; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readonly) Element* ownerElement; - -#pragma mark - ObjC methods - -- (id)initWithName:(NSString*) n value:(NSString*) v; -- (id)initWithNamespace:(NSString*) ns qualifiedName:(NSString*) qn value:(NSString*) v; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Attr.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Attr.m deleted file mode 100644 index 632b9b2d4b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Attr.m +++ /dev/null @@ -1,54 +0,0 @@ -// -// Attr.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "Attr.h" - -#import "Node+Mutable.h" - -@interface Attr() - @property(nonatomic,strong,readwrite) NSString* name; - @property(nonatomic,readwrite) BOOL specified; - @property(nonatomic,strong,readwrite) NSString* value; - - // Introduced in DOM Level 2: - @property(nonatomic,strong,readwrite) Element* ownerElement; -@end - -@implementation Attr - -@synthesize name; -@synthesize specified; -@synthesize value; - -// Introduced in DOM Level 2: -@synthesize ownerElement; - -- (id)initWithName:(NSString*) n value:(NSString*) v -{ - self = [super initType:DOMNodeType_ATTRIBUTE_NODE name:n value:v]; - if (self) - { - self.name = n; - self.value = v; - } - return self; -} - -- (id)initWithNamespace:(NSString*) ns qualifiedName:(NSString*) qn value:(NSString *)v -{ - self = [super initType:DOMNodeType_ATTRIBUTE_NODE name:qn value:v inNamespace:ns]; - if (self) - { - self.name = qn; - self.value = v; - } - return self; -} - - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CDATASection.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CDATASection.h deleted file mode 100644 index 36de5cf436..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CDATASection.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - From SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-667469212 - - interface CDATASection : Text { - }; - */ -#import - -@class Text; -#import "Text.h" - -@interface CDATASection : Text - -- (id)initWithValue:(NSString*) v; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CDATASection.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CDATASection.m deleted file mode 100644 index 12e9add3a9..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CDATASection.m +++ /dev/null @@ -1,20 +0,0 @@ -// -// CDATASection.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "CDATASection.h" - -@implementation CDATASection - -- (id)initWithValue:(NSString*) v -{ - self = [super initType:DOMNodeType_CDATA_SECTION_NODE name:@"#cdata-section" value:v]; - if (self) { - } - return self; -} -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue.h deleted file mode 100644 index 0c3b0e612c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSPrimitiveValue - - interface CSSPrimitiveValue : CSSValue { - - // UnitTypes - const unsigned short CSS_UNKNOWN = 0; - const unsigned short CSS_NUMBER = 1; - const unsigned short CSS_PERCENTAGE = 2; - const unsigned short CSS_EMS = 3; - const unsigned short CSS_EXS = 4; - const unsigned short CSS_PX = 5; - const unsigned short CSS_CM = 6; - const unsigned short CSS_MM = 7; - const unsigned short CSS_IN = 8; - const unsigned short CSS_PT = 9; - const unsigned short CSS_PC = 10; - const unsigned short CSS_DEG = 11; - const unsigned short CSS_RAD = 12; - const unsigned short CSS_GRAD = 13; - const unsigned short CSS_MS = 14; - const unsigned short CSS_S = 15; - const unsigned short CSS_HZ = 16; - const unsigned short CSS_KHZ = 17; - const unsigned short CSS_DIMENSION = 18; - const unsigned short CSS_STRING = 19; - const unsigned short CSS_URI = 20; - const unsigned short CSS_IDENT = 21; - const unsigned short CSS_ATTR = 22; - const unsigned short CSS_COUNTER = 23; - const unsigned short CSS_RECT = 24; - const unsigned short CSS_RGBCOLOR = 25; - - readonly attribute unsigned short primitiveType; - void setFloatValue(in unsigned short unitType, - in float floatValue) - raises(DOMException); - float getFloatValue(in unsigned short unitType) - raises(DOMException); - void setStringValue(in unsigned short stringType, - in DOMString stringValue) - raises(DOMException); - DOMString getStringValue() - raises(DOMException); - Counter getCounterValue() - raises(DOMException); - Rect getRectValue() - raises(DOMException); - RGBColor getRGBColorValue() - raises(DOMException); - */ -#import "CSSValue.h" - -typedef enum CSSPrimitiveType -{ - CSS_UNKNOWN = 0, - CSS_NUMBER = 1, - CSS_PERCENTAGE = 2, - CSS_EMS = 3, - CSS_EXS = 4, - CSS_PX = 5, - CSS_CM = 6, - CSS_MM = 7, - CSS_IN = 8, - CSS_PT = 9, - CSS_PC = 10, - CSS_DEG = 11, - CSS_RAD = 12, - CSS_GRAD = 13, - CSS_MS = 14, - CSS_S = 15, - CSS_HZ = 16, - CSS_KHZ = 17, - CSS_DIMENSION = 18, - CSS_STRING = 19, - CSS_URI = 20, - CSS_IDENT = 21, - CSS_ATTR = 22, - CSS_COUNTER = 23, - CSS_RECT = 24, - CSS_RGBCOLOR = 25 -} CSSPrimitiveType; - -@interface CSSPrimitiveValue : CSSValue - -@property(nonatomic) CSSPrimitiveType primitiveType; - --(void) setFloatValue:(CSSPrimitiveType) unitType floatValue:(float) floatValue; - --(float) getFloatValue:(CSSPrimitiveType) unitType; - --(void) setStringValue:(CSSPrimitiveType) stringType stringValue:(NSString*) stringValue; - --(NSString*) getStringValue; - --(/* FIXME: have to add this type: Counter*/ void) getCounterValue; - --(/* FIXME: have to add this type: Rect*/ void) getRectValue; - --(/* FIXME: have to add this type: RGBColor*/ void) getRGBColorValue; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue.m deleted file mode 100644 index 31ae25c036..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue.m +++ /dev/null @@ -1,296 +0,0 @@ -#import "CSSPrimitiveValue.h" -#import "CSSValue_ForSubclasses.h" -#import "CSSPrimitiveValue_ConfigurablePixelsPerInch.h" - -#import "DOMGlobalSettings.h" - -#define INCHES_PER_CENTIMETRE ( 0.393700787f ) -#define INCHES_PER_MILLIMETER ( 0.0393701f ) - -@interface CSSPrimitiveValue() - -@property(nonatomic) float internalValue; -@property(nonatomic,strong) NSString* internalString; - -@end - -@implementation CSSPrimitiveValue - -@synthesize pixelsPerInch; - -@synthesize internalValue; -@synthesize internalString; - -@synthesize primitiveType; - - -- (id)init -{ - self = [super initWithUnitType:CSS_PRIMITIVE_VALUE]; - if (self) { - self.pixelsPerInch = 1.0f; // this can be overridden by classes that import the CSSPrimitiveValue_ConfigurablePixelsPerInch.h header - } - return self; -} - --(void) setFloatValue:(CSSPrimitiveType) unitType floatValue:(float) floatValue -{ - self.primitiveType = unitType; - self.internalValue = floatValue; - - self.internalString = nil; -} - --(float) getFloatValue:(CSSPrimitiveType) unitType -{ - /** Easy case: you're asking for the same unit as the originally stored units */ - if( unitType == self.primitiveType ) - return self.internalValue; - - switch( self.primitiveType ) - { - case CSS_UNKNOWN: - { - if( self.internalValue == 0.0f ) - return self.internalValue; - else - { - NSAssert( FALSE, @"Asked to convert a UNKNOWN value to a different type (%i)", unitType ); - } - } - - case CSS_CM: - case CSS_IN: - case CSS_MM: - case CSS_PT: - case CSS_PC: - { - float valueAsInches; - switch( self.primitiveType ) - { - case CSS_CM: - { - valueAsInches = self.internalValue * INCHES_PER_CENTIMETRE; - }break; - case CSS_MM: - { - valueAsInches = self.internalValue * INCHES_PER_MILLIMETER; - }break; - case CSS_PT: - { - valueAsInches = self.internalValue / 72.0f; - }break; - case CSS_PC: - { - valueAsInches = self.internalValue * 12.0f / 72.0f; - }break; - case CSS_IN: - { - valueAsInches = self.internalValue; - }break; - - default: - { - valueAsInches = 0; - NSAssert( FALSE, @"This line is impossible but Apple's compiler is crap" ); - } - } - - switch( unitType ) - { - case CSS_CM: - { - return valueAsInches / INCHES_PER_CENTIMETRE; - }break; - case CSS_MM: - { - return valueAsInches / INCHES_PER_MILLIMETER; - }break; - case CSS_PT: - { - return valueAsInches * 72.0f; - }break; - case CSS_PC: - { - return valueAsInches / 12.0f * 72.0f; - }break; - case CSS_PX: - { - return valueAsInches * self.pixelsPerInch; - }break; - - default: - { - NSAssert( FALSE, @"Asked to convert a value in centimetres to an incompatible unit type (%i)", unitType ); - } - } - } break; - - case CSS_DEG: - case CSS_GRAD: - case CSS_RAD: - { - NSAssert( FALSE, @"Asked to convert an Angle value to a different type (NO conversions for this type are currently supported) (%i)", unitType ); - } break; - - case CSS_COUNTER: - { - NSAssert( FALSE, @"Asked to convert a Counter value to a different type (NO conversions for this type are currently supported) (%i)", unitType ); - } break; - - case CSS_DIMENSION: - { - NSAssert( FALSE, @"Asked to convert a Dimension value to a different type (NO conversions for this type are currently supported) (%i)", unitType ); - } break; - - case CSS_EMS: - case CSS_EXS: - case CSS_PX: - { - NSAssert( FALSE, @"Asked to convert a Relative Length value to a different type (NO conversions for this type are currently supported) (%i)", unitType ); - }break; - - case CSS_HZ: - case CSS_MS: - case CSS_KHZ: - case CSS_S: - { - NSAssert( FALSE, @"Asked to convert a Time or Frequency value to a different type (NO conversions for this type are currently supported) (%i)", unitType ); - }break; - - case CSS_NUMBER: - { - if( unitType == CSS_PX ) /** Dom 1 spec allows this, SVG Spec says "this is correct by spec", and DOM 2 spec says this is illegal. Most CSS interpreters do it... */ - { - return self.internalValue; - } - else - { - NSAssert( FALSE, @"Asked to convert a Number to a different type (NO conversions for this type are currently supported) (%i)", unitType ); - } - }break; - - case CSS_PERCENTAGE: - { - if( unitType == CSS_NUMBER ) - { - return self.internalValue / 100.0f; // convert percentages to values from 0.0 - 1.0 - } - else - NSAssert( FALSE, @"Asked to convert a Percentage value to a different type (%i)", unitType ); - }break; - - default: - { - NSAssert( FALSE, @"Asked to convert a (%i) value to a (%i) (couldn't find a valid conversion route). Float (4 d.p.) = %2.4f, String = %@", self.primitiveType, unitType, self.internalValue, self.internalString ); - } - } - - return 0.0f; // this will never happen. you should have Asserted by now, or else returned early with the correct value -} - --(void) setStringValue:(CSSPrimitiveType) stringType stringValue:(NSString*) stringValue -{ - self.primitiveType = stringType; - self.internalString = stringValue; - - self.internalValue = 0.0f; -} - --(NSString*) getStringValue -{ - return self.internalString; -} - --(/* FIXME: have to add this type: Counter*/ void) getCounterValue -{ - NSAssert(FALSE, @"This method not supported"); -} - --(/* FIXME: have to add this type: Rect*/ void) getRectValue -{ - NSAssert(FALSE, @"This method not supported"); -} - --(/* FIXME: have to add this type: RGBColor*/ void) getRGBColorValue -{ - NSAssert(FALSE, @"This method not supported"); -} - -#pragma mark - non DOM spec methods needed to implement Objective-C code for this class - --(void)setCssText:(NSString *)newCssText -{ - _cssText = newCssText; - - /** the css text value has been set, so we need to split the elements up and save them in the internal array */ - if( _cssText == nil - || _cssText.length == 0 ) - { - self.internalValue = 0.0f; - self.internalString = @""; - self.primitiveType = CSS_UNKNOWN; - } - else if( [_cssText hasSuffix:@"%"]) - [self setFloatValue:CSS_PERCENTAGE floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"em"]) - [self setFloatValue:CSS_EMS floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"ex"]) - [self setFloatValue:CSS_EXS floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"px"]) - [self setFloatValue:CSS_PX floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"cm"]) - [self setFloatValue:CSS_CM floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"mm"]) - [self setFloatValue:CSS_MM floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"in"]) - [self setFloatValue:CSS_IN floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"pt"]) - [self setFloatValue:CSS_PT floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"pc"]) - [self setFloatValue:CSS_PC floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"deg"]) - [self setFloatValue:CSS_DEG floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"rad"]) - [self setFloatValue:CSS_RAD floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"grad"]) - [self setFloatValue:CSS_GRAD floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"ms"]) - [self setFloatValue:CSS_MS floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"s"]) - [self setFloatValue:CSS_S floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"khz"]) // -----------NB: check this before checking HZ ! - [self setFloatValue:CSS_KHZ floatValue:[_cssText floatValue]]; - else if( [_cssText hasSuffix:@"hz"]) - [self setFloatValue:CSS_HZ floatValue:[_cssText floatValue]]; - else - { - /** - Three possible outcomes left: - - 1. It's a pure number, no units (in CSS, that's rare - but in SVG it's common, and defined by Spec to be "the same as PX") - 2. It's a string, one of many different CSS string types - 3. It's a corrupt file - */ - - /** - NSScaner is an Apple class that SPECIFICALLY will refuse to return a number if there are any non-numberic characters in the string */ - NSScanner *scanner = [NSScanner scannerWithString: _cssText]; - float floatToHoldTheOutput; - if( [scanner scanFloat:&floatToHoldTheOutput]) - { - /* Option 1: it's a pure number */ - [self setFloatValue:CSS_NUMBER floatValue:floatToHoldTheOutput]; - } - else - { - /* Option 2: it's a string - or corrupt, which we're not going to handle here */ -#if DEBUG_DOM_PARSING - SVGKitLogVerbose(@"[%@] WARNING: not bothering to work out 'what kind of CSS string' this string is. CSS is stupid. String = %@", [self class], _cssText ); -#endif - [self setStringValue:CSS_STRING stringValue:_cssText]; // -------- NB: we allow any string-to-string conversion, so it's not a huge problem that we dont correctly detect "url" versus "other kind of string". I hate CSS Parsing... - } - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue_ConfigurablePixelsPerInch.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue_ConfigurablePixelsPerInch.h deleted file mode 100644 index c640d15ad1..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSPrimitiveValue_ConfigurablePixelsPerInch.h +++ /dev/null @@ -1,7 +0,0 @@ -#import "CSSPrimitiveValue.h" - -@interface CSSPrimitiveValue () - -@property(nonatomic) float pixelsPerInch; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRule.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRule.h deleted file mode 100644 index dddcee8c0e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRule.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSRule - - interface CSSRule { - - // RuleType - const unsigned short UNKNOWN_RULE = 0; - const unsigned short STYLE_RULE = 1; - const unsigned short CHARSET_RULE = 2; - const unsigned short IMPORT_RULE = 3; - const unsigned short MEDIA_RULE = 4; - const unsigned short FONT_FACE_RULE = 5; - const unsigned short PAGE_RULE = 6; - - readonly attribute unsigned short type; - attribute DOMString cssText; - // raises(DOMException) on setting - - readonly attribute CSSStyleSheet parentStyleSheet; - readonly attribute CSSRule parentRule; - */ -#import - -@class CSSStyleSheet; - -typedef enum CSSRuleType -{ - UNKNOWN_RULE = 0, - STYLE_RULE = 1, - CHARSET_RULE = 2, - IMPORT_RULE = 3, - MEDIA_RULE = 4, - FONT_FACE_RULE = 5, - PAGE_RULE = 6 -} CSSRuleType; - -@interface CSSRule : NSObject - -@property(nonatomic) unsigned short type; -@property(nonatomic,strong) NSString* cssText; - -@property(nonatomic,strong) CSSStyleSheet* parentStyleSheet; -@property(nonatomic,strong) CSSRule* parentRule; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRule.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRule.m deleted file mode 100644 index 52a32624ea..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRule.m +++ /dev/null @@ -1,12 +0,0 @@ -#import "CSSRule.h" - -@implementation CSSRule - -@synthesize type; -@synthesize cssText; - -@synthesize parentStyleSheet; -@synthesize parentRule; - - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList+Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList+Mutable.h deleted file mode 100644 index cb0628092c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList+Mutable.h +++ /dev/null @@ -1,7 +0,0 @@ -#import "CSSRuleList.h" - -@interface CSSRuleList () - -@property(nonatomic,strong) NSMutableArray* internalArray; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList.h deleted file mode 100644 index c4382f8b55..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSRuleList - - interface CSSRuleList { - readonly attribute unsigned long length; - CSSRule item(in unsigned long index); - */ -#import - -#import "CSSRule.h" - -@interface CSSRuleList : NSObject - -@property(nonatomic,readonly) unsigned long length; - --(CSSRule*) item:(unsigned long) index; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList.m deleted file mode 100644 index f3c45adbf2..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSRuleList.m +++ /dev/null @@ -1,33 +0,0 @@ -#import "CSSRuleList.h" -#import "CSSRuleList+Mutable.h" - -@implementation CSSRuleList - -@synthesize internalArray; - - -- (id)init -{ - self = [super init]; - if (self) { - self.internalArray = [NSMutableArray array]; - } - return self; -} - --(unsigned long)length -{ - return self.internalArray.count; -} - --(CSSRule *)item:(unsigned long)index -{ - return [self.internalArray objectAtIndex:index]; -} - --(NSString *)description -{ - return [NSString stringWithFormat:@"CSSRuleList: array(%@)", self.internalArray]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleDeclaration.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleDeclaration.h deleted file mode 100644 index 3a5abbff68..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleDeclaration.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSStyleDeclaration - - interface CSSStyleDeclaration { - attribute DOMString cssText; - // raises(DOMException) on setting - - DOMString getPropertyValue(in DOMString propertyName); - CSSValue getPropertyCSSValue(in DOMString propertyName); - DOMString removeProperty(in DOMString propertyName) - raises(DOMException); - DOMString getPropertyPriority(in DOMString propertyName); - void setProperty(in DOMString propertyName, - in DOMString value, - in DOMString priority) - raises(DOMException); - readonly attribute unsigned long length; - DOMString item(in unsigned long index); - readonly attribute CSSRule parentRule; - */ -#import - -#import "CSSValue.h" -#import "CSSRule.h" - -@interface CSSStyleDeclaration : NSObject - -/** NOTE: requires special treatment! - - From spec: - - "The parsable textual representation of the declaration block (excluding the surrounding curly braces). Setting this attribute will result in the parsing of the new value and resetting of all the properties in the declaration block including the removal or addition of properties." - */ -@property(nonatomic,strong) NSString* cssText; - --(NSString*) getPropertyValue:(NSString*) propertyName; --(CSSValue*) getPropertyCSSValue:(NSString*) propertyName; --(NSString*) removeProperty:(NSString*) propertyName; - --(NSString*) getPropertyPriority:(NSString*) propertyName; --(void) setProperty:(NSString*) propertyName value:(NSString*) value priority:(NSString*) priority; - -@property(nonatomic) unsigned long length; - --(NSString*) item:(long) index; - -@property(nonatomic,strong) CSSRule* parentRule; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleDeclaration.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleDeclaration.m deleted file mode 100644 index d2072f5ce3..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleDeclaration.m +++ /dev/null @@ -1,162 +0,0 @@ -#import "CSSStyleDeclaration.h" - -#import "CSSValue.h" -#import "CSSValueList.h" -#import "CSSPrimitiveValue.h" - -@interface CSSStyleDeclaration() - -@property(nonatomic,strong) NSMutableDictionary* internalDictionaryOfStylesByCSSClass; - -@end - -@implementation CSSStyleDeclaration - -@synthesize internalDictionaryOfStylesByCSSClass; - -@synthesize cssText = _cssText; -@synthesize length; -@synthesize parentRule; - - -- (id)init -{ - self = [super init]; - if (self) { - self.internalDictionaryOfStylesByCSSClass = [NSMutableDictionary dictionary]; - } - return self; -} - -#define MAX_ACCUM 256 -#define MAX_NAME 256 - -/** From spec: - - "The parsable textual representation of the declaration block (excluding the surrounding curly braces). Setting this attribute will result in the parsing of the new value and resetting of all the properties in the declaration block including the removal or addition of properties." - */ --(void)setCssText:(NSString *)newCSSText -{ - _cssText = newCSSText; - - /** and now post-process it, *as required by* the CSS/DOM spec... */ - NSMutableDictionary* processedStyles = [self NSDictionaryFromCSSAttributes:_cssText]; - - self.internalDictionaryOfStylesByCSSClass = processedStyles; - -} - --(NSMutableDictionary *) NSDictionaryFromCSSAttributes: (NSString *)css { - NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; - NSCharacterSet* trimChars = [NSCharacterSet whitespaceAndNewlineCharacterSet]; - - const char *cstr = [css UTF8String]; - size_t len = strlen(cstr); - - char name[MAX_NAME]; - bzero(name, MAX_NAME); - - char accum[MAX_ACCUM]; - bzero(accum, MAX_ACCUM); - - size_t accumIdx = 0; - - for (size_t n = 0; n <= len; n++) { - char c = cstr[n]; - - if (c == ':') { - strncpy(name, accum, MAX_NAME); - name[accumIdx] = '\0'; - - bzero(accum, MAX_ACCUM); - accumIdx = 0; - - continue; - } - else if (c == ';' || c == '\0') { - if( accumIdx > 0 ) //if there is a ';' and '\0' to end the style, avoid adding an empty key-value pair - { - accum[accumIdx] = '\0'; - - NSString *keyString = [[NSString stringWithUTF8String:name] - stringByTrimmingCharactersInSet:trimChars]; - NSString *cssValueString = [[NSString stringWithUTF8String:accum] - stringByTrimmingCharactersInSet:trimChars]; - - CSSValue *cssValue; - if( [cssValueString rangeOfString:@" "].length > 0 ) - cssValue = [[CSSValueList alloc] init]; - else - cssValue = [[CSSPrimitiveValue alloc] init]; - cssValue.cssText = cssValueString; // has the side-effect of parsing, if required - - [dict setObject:cssValue - forKey:keyString]; - - bzero(name, MAX_NAME); - - bzero(accum, MAX_ACCUM); - accumIdx = 0; - } - - continue; - } - - accum[accumIdx++] = c; - if (accumIdx >= MAX_ACCUM) { - SVGKitLogWarn(@"Buffer ovverun while parsing style sheet - skipping"); - return dict; - } - } - - return dict; -} - --(NSString*) getPropertyValue:(NSString*) propertyName -{ - CSSValue* v = [self getPropertyCSSValue:propertyName]; - - if( v == nil ) - return nil; - else - return v.cssText; -} - --(CSSValue*) getPropertyCSSValue:(NSString*) propertyName -{ - return [self.internalDictionaryOfStylesByCSSClass objectForKey:propertyName]; -} - --(NSString*) removeProperty:(NSString*) propertyName -{ - NSString* oldValue = [self getPropertyValue:propertyName]; - [self.internalDictionaryOfStylesByCSSClass removeObjectForKey:propertyName]; - return oldValue; -} - --(NSString*) getPropertyPriority:(NSString*) propertyName -{ - NSAssert(FALSE, @"CSS 'property priorities' - Not supported"); - - return nil; -} - --(void) setProperty:(NSString*) propertyName value:(NSString*) value priority:(NSString*) priority -{ - NSAssert(FALSE, @"CSS 'property priorities' - Not supported"); -} - --(NSString*) item:(long) index -{ - /** this is stupid slow, but until Apple *can be bothered* to add a "stable-order" dictionary to their libraries, this is the only sensibly easy way of implementing this method */ - NSArray* sortedKeys = [[self.internalDictionaryOfStylesByCSSClass allKeys] sortedArrayUsingSelector:@selector(compare:)]; - CSSValue* v = [sortedKeys objectAtIndex:index]; - return v.cssText; -} - --(NSString *)description -{ - return [NSString stringWithFormat:@"CSSStyleDeclaration: dictionary(%@)", self.internalDictionaryOfStylesByCSSClass]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleRule.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleRule.h deleted file mode 100644 index 0e3fffb1d1..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleRule.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSStyleRule - - interface CSSStyleRule : CSSRule { - attribute DOMString selectorText; - // raises(DOMException) on setting - - readonly attribute CSSStyleDeclaration style; - */ -#import - -#import "CSSRule.h" -#import "CSSStyleDeclaration.h" - -@interface CSSStyleRule : CSSRule - -@property(nonatomic,strong) NSString* selectorText; -@property(nonatomic,strong) CSSStyleDeclaration* style; - -#pragma mark - methods needed for ObjectiveC implementation - -- (id)initWithSelectorText:(NSString*) selector styleText:(NSString*) styleText; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleRule.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleRule.m deleted file mode 100644 index 494ea9153e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleRule.m +++ /dev/null @@ -1,37 +0,0 @@ - -#import "CSSStyleRule.h" - -@implementation CSSStyleRule - -@synthesize selectorText; -@synthesize style; - - -- (id)init -{ - NSAssert(FALSE, @"Can't be init'd, use the right method, idiot"); - return nil; -} - -#pragma mark - methods needed for ObjectiveC implementation - -- (id)initWithSelectorText:(NSString*) selector styleText:(NSString*) styleText; -{ - self = [super init]; - if (self) { - self.selectorText = selector; - - CSSStyleDeclaration* styleDeclaration = [[CSSStyleDeclaration alloc] init]; - styleDeclaration.cssText = styleText; - - self.style = styleDeclaration; - } - return self; -} - --(NSString *)description -{ - return [NSString stringWithFormat:@"%@ : { %@ }", self.selectorText, self.style ]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleSheet.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleSheet.h deleted file mode 100644 index f2fa9c659c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleSheet.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSStyleSheet - - interface CSSStyleSheet : stylesheets::StyleSheet { - readonly attribute CSSRule ownerRule; - readonly attribute CSSRuleList cssRules; - unsigned long insertRule(in DOMString rule, - in unsigned long index) - raises(DOMException); - void deleteRule(in unsigned long index) - raises(DOMException); - */ -#import - -#import "CSSRule.h" -#import "CSSRuleList.h" - -@interface CSSStyleSheet : NSObject - - -@property(nonatomic,strong) CSSRule* ownerRule; -@property(nonatomic,strong) CSSRuleList* cssRules; - --(long) insertRule:(NSString*) rule index:(unsigned long) index; --(void) deleteRule:(unsigned long) index; - -#pragma mark - methods needed for ObjectiveC implementation - -- (id)initWithString:(NSString*) styleSheetBody; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleSheet.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleSheet.m deleted file mode 100644 index 31a49678aa..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSStyleSheet.m +++ /dev/null @@ -1,92 +0,0 @@ -#import "CSSStyleSheet.h" - -#import "CSSRuleList+Mutable.h" - -#import "CSSStyleRule.h" - -@implementation CSSStyleSheet - -@synthesize ownerRule; -@synthesize cssRules; - - -/** - Used to insert a new rule into the style sheet. The new rule now becomes part of the cascade. - - Parameters - - rule of type DOMString - The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content. - index of type unsigned long - The index within the style sheet's rule list of the rule before which to insert the specified rule. If the specified index is equal to the length of the style sheet's rule collection, the rule will be added to the end of the style sheet. - - Return Value - - unsigned long The index within the style sheet's rule collection of the newly inserted rule. - */ --(long)insertRule:(NSString *)rule index:(unsigned long)index -{ - if( index == self.cssRules.length ) - index = self.cssRules.length + 1; // forces it to insert "before the one that doesn't exist" (stupid API design!) - - NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceAndNewlineCharacterSet]; - rule = [rule stringByTrimmingCharactersInSet:whitespaceSet]; - - // SVGKitLogVerbose(@"A substringie %@", idStyleString); - - NSArray* stringSplitContainer = [rule componentsSeparatedByString:@"{"]; - if( [stringSplitContainer count] >= 2 ) //not necessary unless using shitty svgs - { - CSSStyleRule* newRule = [[CSSStyleRule alloc] initWithSelectorText:[stringSplitContainer objectAtIndex:0] styleText:[stringSplitContainer objectAtIndex:1]]; - - [self.cssRules.internalArray insertObject:newRule atIndex:index-1]; // CSS says you insert "BEFORE" the index, which is the opposite of most C-based programming languages - - return index-1; - } - else - NSAssert(FALSE, @"No idea what to do here"); - - - return -1; // failed, assert fired! -} - --(void)deleteRule:(unsigned long)index -{ - [self.cssRules.internalArray removeObjectAtIndex:index]; -} - -#pragma mark - methods needed for ObjectiveC implementation - -- (id)initWithString:(NSString*) styleSheetBody -{ - self = [super init]; - if (self) - { - self.cssRules = [[CSSRuleList alloc]init]; - @autoreleasepool { //creating lots of autoreleased strings, not helpful for older devices - - /** - We have to manually handle the "ignore anything that is between / * and * / because those are comments" - - NB: you NEED the NSRegularExpressionDotMatchesLineSeparators argument - which Apple DOES NOT HONOUR in NSString - hence have to use NSRegularExpression - */ - NSError* error; - NSRegularExpression* regexp = [NSRegularExpression regularExpressionWithPattern:@"/\\*.*?\\*/" options: NSRegularExpressionDotMatchesLineSeparators error:&error]; - styleSheetBody = [regexp stringByReplacingMatchesInString:styleSheetBody options:0 range:NSMakeRange(0,styleSheetBody.length) withTemplate:@""]; - - NSArray *classNameAndStyleStrings = [styleSheetBody componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"}"]]; - for( NSString *idStyleString in classNameAndStyleStrings ) - { - if( [idStyleString length] > 1 ) //not necessary unless using shitty svgs - { - [self insertRule:idStyleString index:self.cssRules.length]; - } - - } - } - - } - return self; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue.h deleted file mode 100644 index fe21548705..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSValue - - interface CSSValue { - - // UnitTypes - const unsigned short CSS_INHERIT = 0; - const unsigned short CSS_PRIMITIVE_VALUE = 1; - const unsigned short CSS_VALUE_LIST = 2; - const unsigned short CSS_CUSTOM = 3; - - attribute DOMString cssText; - // raises(DOMException) on setting - - readonly attribute unsigned short cssValueType; - */ -#import - -typedef enum CSSUnitType -{ - CSS_INHERIT = 0, - CSS_PRIMITIVE_VALUE = 1, - CSS_VALUE_LIST = 2, - CSS_CUSTOM = 3 -} CSSUnitType; - -@interface CSSValue : NSObject -{ - NSString* _cssText; // for subclasses to manually set -} - -@property(nonatomic,strong) NSString* cssText; -@property(nonatomic) CSSUnitType cssValueType; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue.m deleted file mode 100644 index d9314f442e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue.m +++ /dev/null @@ -1,25 +0,0 @@ -#import "CSSValue.h" -#import "CSSValue_ForSubclasses.h" - -@implementation CSSValue - -@synthesize cssText = _cssText; -@synthesize cssValueType; - - -- (id)init -{ - NSAssert(FALSE, @"This class cannot be init'd using init. It would break it, badly. Use the correct init call instead (if you don't know what that is, you shouldn't be init'ing this class)"); - - return nil; -} - -- (id)initWithUnitType:(CSSUnitType) t -{ - self = [super init]; - if (self) { - self.cssValueType = t; - } - return self; -} -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValueList.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValueList.h deleted file mode 100644 index 1fa2d22506..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValueList.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-CSSValueList - - interface CSSValueList : CSSValue { - readonly attribute unsigned long length; - CSSValue item(in unsigned long index); - */ - -#import "CSSValue.h" - -@interface CSSValueList : CSSValue - -@property(nonatomic,readonly) unsigned long length; - --(CSSValue*) item:(unsigned long) index; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValueList.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValueList.m deleted file mode 100644 index 665afcdc4c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValueList.m +++ /dev/null @@ -1,46 +0,0 @@ -#import "CSSValueList.h" -#import "CSSValue_ForSubclasses.h" - -@interface CSSValueList() - -@property(nonatomic,strong) NSArray* internalArray; - -@end - -@implementation CSSValueList - -@synthesize internalArray; - - -- (id)init -{ - self = [super initWithUnitType:CSS_VALUE_LIST]; - if (self) { - self.internalArray = [NSArray array]; - } - return self; -} - --(unsigned long)length -{ - return self.internalArray.count; -} - --(CSSValue*) item:(unsigned long) index -{ - return [self.internalArray objectAtIndex:index]; -} - -#pragma mark - non DOM spec methods needed to implement Objective-C code for this class - --(void)setCssText:(NSString *)newCssText -{ - _cssText = newCssText; - - /** the css text value has been set, so we need to split the elements up and save them in the internal array */ - SVGKitLogVerbose(@"[%@] received new CSS Text, need to split this and save as CSSValue instances: %@", [self class], _cssText); - - self.internalArray = [_cssText componentsSeparatedByString:@" "]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue_ForSubclasses.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue_ForSubclasses.h deleted file mode 100644 index 24993ebffa..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CSSValue_ForSubclasses.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -@interface CSSValue() - -- (id)initWithUnitType:(CSSUnitType) t; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CharacterData.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CharacterData.h deleted file mode 100644 index e377db3295..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CharacterData.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - From SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-FF21A306 - - interface CharacterData : Node { - attribute DOMString data; - // raises(DOMException) on setting - // raises(DOMException) on retrieval - - readonly attribute unsigned long length; - DOMString substringData(in unsigned long offset, - in unsigned long count) - raises(DOMException); - void appendData(in DOMString arg) - raises(DOMException); - void insertData(in unsigned long offset, - in DOMString arg) - raises(DOMException); - void deleteData(in unsigned long offset, - in unsigned long count) - raises(DOMException); - void replaceData(in unsigned long offset, - in unsigned long count, - in DOMString arg) - raises(DOMException); - }; - - */ - -#import - -/** objc won't allow this: @class Node;*/ -#import "Node.h" - -@interface CharacterData : Node - -@property(nonatomic,strong,readonly) NSString* data; - -@property(nonatomic,readonly) unsigned long length; - --(NSString*) substringData:(unsigned long) offset count:(unsigned long) count; --(void) appendData:(NSString*) arg; --(void) insertData:(unsigned long) offset arg:(NSString*) arg; --(void) deleteData:(unsigned long) offset count:(unsigned long) count; --(void) replaceData:(unsigned long) offset count:(unsigned long) count arg:(NSString*) arg; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CharacterData.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CharacterData.m deleted file mode 100644 index e46acb8e1e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/CharacterData.m +++ /dev/null @@ -1,41 +0,0 @@ -// -// CharacterData.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "CharacterData.h" - -@implementation CharacterData - -@synthesize data; - -@synthesize length; - - --(NSString*) substringData:(unsigned long) offset count:(unsigned long) count -{ - NSAssert( FALSE, @"Not implemented yet" ); - return nil; -} - --(void) appendData:(NSString*) arg -{ - NSAssert( FALSE, @"Not implemented yet" ); -} --(void) insertData:(unsigned long) offset arg:(NSString*) arg -{ - NSAssert( FALSE, @"Not implemented yet" ); -} --(void) deleteData:(unsigned long) offset count:(unsigned long) count -{ - NSAssert( FALSE, @"Not implemented yet" ); -} --(void) replaceData:(unsigned long) offset count:(unsigned long) count arg:(NSString*) arg -{ - NSAssert( FALSE, @"Not implemented yet" ); -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Comment.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Comment.h deleted file mode 100644 index de99baca16..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Comment.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - From SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1728279322 - - interface Comment : CharacterData { - }; -*/ - -#import - -#import "CharacterData.h" -#ifdef __CARBONCORE__ -// macOS's out-of-date Carbon API defined the `Comment` struct and cause naming conflict, so we need re-define it and use macro to avoid changing exist API -#define Comment SVGKComment -#endif -@interface Comment : CharacterData - -- (id)initWithValue:(NSString*) v; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Comment.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Comment.m deleted file mode 100644 index 42e8a3a716..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Comment.m +++ /dev/null @@ -1,21 +0,0 @@ -// -// Comment.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "Comment.h" - -@implementation Comment - -- (id)initWithValue:(NSString*) v -{ - self = [super initType:DOMNodeType_COMMENT_NODE name:@"#comment" value:v]; - if (self) { - } - return self; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMGlobalSettings.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMGlobalSettings.h deleted file mode 100644 index 661b128379..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMGlobalSettings.h +++ /dev/null @@ -1 +0,0 @@ -#define DEBUG_DOM_PARSING 0 diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMHelperUtilities.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMHelperUtilities.h deleted file mode 100644 index 10d6587e59..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMHelperUtilities.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - There are some shared methods in DOM specification, where two classes have the same method, but - are NOT subclass/superclass of each other. This is very bad from OOP design POV, because it means - we end up with copy/paste duplicated code, very VERY likely to gain long term bugs. - - Also, those methods REQUIRE a second, recursive, method or else you can't implement them easily. - - So, we move their implementations into this helper class, so they can share implementation. - - (c.f. Element vs Document - identical methods for getElementsByName) - */ -#import - -@class Node, NodeList, Element; // avoiding #import here, to avoid C header loop problems. - -#define DEBUG_DOM_MATCH_ELEMENTS_IDS_AND_NAMES 0 // For debugging SVGKit: causes debug output on getElementById etc - -@interface DOMHelperUtilities : NSObject - -/*! This useful method provides both the DOM level 1 and the DOM level 2 implementations of searching the tree for a node - because THEY ARE DIFFERENT - yet very similar - */ -+(void) privateGetElementsByName:(NSString*) name inNamespace:(NSString*) namespaceURI childrenOfElement:(Node*) parent addToList:(NodeList*) accumulator; - -/*! This is used in multiple base classes in DOM 1 and DOM 2 where they do NOT have shared superclasses, so we have to implement it here in a separate - clas as a standalone method */ -+(Element*) privateGetElementById:(NSString*) idValue childrenOfElement:(Node*) parent; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMHelperUtilities.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMHelperUtilities.m deleted file mode 100644 index 6bb2742720..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DOMHelperUtilities.m +++ /dev/null @@ -1,87 +0,0 @@ - -#import "DOMHelperUtilities.h" - -#import "Element.h" -#import "NodeList.h" -#import "NodeList+Mutable.h" // needed for access to underlying array, because SVG doesnt specify how lists are made mutable - -@implementation DOMHelperUtilities - -/*! This useful method provides both the DOM level 1 and the DOM level 2 implementations of searching the tree for a node - because THEY ARE DIFFERENT - yet very similar - */ -+(void) privateGetElementsByName:(NSString*) name inNamespace:(NSString*) namespaceURI childrenOfElement:(Node*) parent addToList:(NodeList*) accumulator -{ - /** According to spec, this is only valid for ELEMENT nodes */ - if( [parent isKindOfClass:[Element class]] ) - { - if( namespaceURI != nil && ! [parent.namespaceURI isEqualToString:namespaceURI] ) - { - // skip - } - else - { - Element* parentAsElement = (Element*) parent; - - /** According to spec, "tag name" for an Element is the value of its .nodeName property; that means SOMETIMES its a qualified name! */ - BOOL includeThisNode = FALSE; - - - if( [name isEqualToString:@"*"] ) - includeThisNode = TRUE; - - if( !includeThisNode ) - { - if( namespaceURI == nil ) // No namespace? then do a qualified compare - { - includeThisNode = [parentAsElement.tagName isEqualToString:name]; - } - else // namespace? then do an UNqualified compare - { - includeThisNode = [parentAsElement.localName isEqualToString:name]; - } - } - - if( includeThisNode ) - { - [accumulator.internalArray addObject:parent]; - } - } - } - - for( Node* childNode in parent.childNodes ) - { - [self privateGetElementsByName:name inNamespace:namespaceURI childrenOfElement:childNode addToList:accumulator]; - } -} - -+(Element*) privateGetElementById:(NSString*) idValue childrenOfElement:(Node*) parent -{ - /** According to spec, this is only valid for ELEMENT nodes */ - if( [parent isKindOfClass:[Element class]] ) - { - Element* parentAsElement = (Element*) parent; - - if( [[parentAsElement getAttribute:@"id"] isEqualToString:idValue]) - return parentAsElement; -#if DEBUG_DOM_MATCH_ELEMENTS_IDS_AND_NAMES - else - { - SVGKitLogVerbose(@"parent <%@ id='%@'..> does not match id='%@'", parentAsElement.nodeName, [parentAsElement getAttribute:@"id"], idValue ); - SVGKitLogVerbose(@"parent <%@ id='%@'..> has %li child nodes = %@", parentAsElement.nodeName, [parentAsElement getAttribute:@"id"], parent.childNodes.length, parent.childNodes ); - } -#endif - } - - for( Node* childNode in parent.childNodes ) - { - Element* childResult = [self privateGetElementById:idValue childrenOfElement:childNode]; - - if( childResult != nil ) - return childResult; - } - - return nil; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document+Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document+Mutable.h deleted file mode 100644 index 46631fce4e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document+Mutable.h +++ /dev/null @@ -1,7 +0,0 @@ -#import "Document.h" - -@interface Document () - -@property(nonatomic,strong,readwrite) Element* documentElement; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document.h deleted file mode 100644 index 9f69a72ec7..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -// Document.h - - NOT a Cocoa / Apple document, - NOT an SVG document, - BUT INSTEAD: a DOM document (blame w3.org for the too-generic name). - - Required for SVG-DOM - - c.f.: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#i-Document - - interface Document : Node { - readonly attribute DocumentType doctype; - readonly attribute DOMImplementation implementation; - readonly attribute Element documentElement; - Element createElement(in DOMString tagName) - raises(DOMException); - DocumentFragment createDocumentFragment(); - Text createTextNode(in DOMString data); - Comment createComment(in DOMString data); - CDATASection createCDATASection(in DOMString data) - raises(DOMException); - ProcessingInstruction createProcessingInstruction(in DOMString target, - in DOMString data) - raises(DOMException); - Attr createAttribute(in DOMString name) - raises(DOMException); - EntityReference createEntityReference(in DOMString name) - raises(DOMException); - NodeList getElementsByTagName(in DOMString tagname); - // Introduced in DOM Level 2: - Node importNode(in Node importedNode, - in boolean deep) - raises(DOMException); - // Introduced in DOM Level 2: - Element createElementNS(in DOMString namespaceURI, - in DOMString qualifiedName) - raises(DOMException); - // Introduced in DOM Level 2: - Attr createAttributeNS(in DOMString namespaceURI, - in DOMString qualifiedName) - raises(DOMException); - // Introduced in DOM Level 2: - NodeList getElementsByTagNameNS(in DOMString namespaceURI, - in DOMString localName); - // Introduced in DOM Level 2: - Element getElementById(in DOMString elementId); - }; - - - */ - -#import - -/** ObjectiveC won't allow this: @class Node; */ -#import "Node.h" -@class Element; -#import "Element.h" -//@class Comment; -#import "Comment.h" -@class CDATASection; -#import "CDATASection.h" -@class DocumentFragment; -#import "DocumentFragment.h" -@class EntityReference; -#import "EntityReference.h" -@class NodeList; -#import "NodeList.h" -@class ProcessingInstruction; -#import "ProcessingInstruction.h" -@class DocumentType; -#import "DocumentType.h" -@class AppleSucksDOMImplementation; -#import "AppleSucksDOMImplementation.h" - -@interface Document : Node - -@property(nonatomic,strong,readonly) DocumentType* doctype; -@property(nonatomic,strong,readonly) AppleSucksDOMImplementation* implementation; -@property(nonatomic,strong,readonly) Element* documentElement; - - --(Element*) createElement:(NSString*) tagName __attribute__((ns_returns_retained)); --(DocumentFragment*) createDocumentFragment __attribute__((ns_returns_retained)); --(Text*) createTextNode:(NSString*) data __attribute__((ns_returns_retained)); --(Comment*) createComment:(NSString*) data __attribute__((ns_returns_retained)); --(CDATASection*) createCDATASection:(NSString*) data __attribute__((ns_returns_retained)); --(ProcessingInstruction*) createProcessingInstruction:(NSString*) target data:(NSString*) data __attribute__((ns_returns_retained)); --(Attr*) createAttribute:(NSString*) data __attribute__((ns_returns_retained)); --(EntityReference*) createEntityReference:(NSString*) data __attribute__((ns_returns_retained)); - --(NodeList*) getElementsByTagName:(NSString*) data; - -// Introduced in DOM Level 2: --(Node*) importNode:(Node*) importedNode deep:(BOOL) deep; - -// Introduced in DOM Level 2: --(Element*) createElementNS:(NSString*) namespaceURI qualifiedName:(NSString*) qualifiedName __attribute__((ns_returns_retained)); - -// Introduced in DOM Level 2: --(Attr*) createAttributeNS:(NSString*) namespaceURI qualifiedName:(NSString*) qualifiedName; - -// Introduced in DOM Level 2: --(NodeList*) getElementsByTagNameNS:(NSString*) namespaceURI localName:(NSString*) localName; - -// Introduced in DOM Level 2: --(Element*) getElementById:(NSString*) elementId; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document.m deleted file mode 100644 index f9ce5facd5..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Document.m +++ /dev/null @@ -1,109 +0,0 @@ -#import "Document.h" -#import "Document+Mutable.h" - -#import "DOMHelperUtilities.h" - -#import "NodeList+Mutable.h" // needed for access to underlying array, because SVG doesnt specify how lists are made mutable - -@implementation Document - -@synthesize doctype; -@synthesize implementation; -@synthesize documentElement; - - - --(Element*) createElement:(NSString*) tagName -{ - Element* newElement = [[Element alloc] initWithLocalName:tagName attributes:nil]; - - SVGKitLogVerbose( @"[%@] WARNING: SVG Spec, missing feature: if there are known attributes with default values, Attr nodes representing them SHOULD BE automatically created and attached to the element.", [self class] ); - - return newElement; -} - --(DocumentFragment*) createDocumentFragment -{ - return [[DocumentFragment alloc] init]; -} - --(Text*) createTextNode:(NSString*) data -{ - return [[Text alloc] initWithValue:data]; -} - --(Comment*) createComment:(NSString*) data -{ - return [[Comment alloc] initWithValue:data]; -} - --(CDATASection*) createCDATASection:(NSString*) data -{ - return [[CDATASection alloc] initWithValue:data]; -} - --(ProcessingInstruction*) createProcessingInstruction:(NSString*) target data:(NSString*) data -{ - return [[ProcessingInstruction alloc] initProcessingInstruction:target value:data]; -} - --(Attr*) createAttribute:(NSString*) n -{ - return [[Attr alloc] initWithName:n value:@""]; -} - --(EntityReference*) createEntityReference:(NSString*) data -{ - NSAssert( FALSE, @"Not implemented. According to spec: Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node. Note: If any descendant of the Entity node has an unbound namespace prefix, the corresponding descendant of the created EntityReference node is also unbound; (its namespaceURI is null). The DOM Level 2 does not support any mechanism to resolve namespace prefixes." ); - return nil; -} - --(NodeList*) getElementsByTagName:(NSString*) data -{ - NodeList* accumulator = [[NodeList alloc] init]; - [DOMHelperUtilities privateGetElementsByName:data inNamespace:nil childrenOfElement:self.documentElement addToList:accumulator]; - - return accumulator; -} - -// Introduced in DOM Level 2: --(Node*) importNode:(Node*) importedNode deep:(BOOL) deep -{ - NSAssert( FALSE, @"Not implemented." ); - return nil; -} - -// Introduced in DOM Level 2: --(Element*) createElementNS:(NSString*) namespaceURI qualifiedName:(NSString*) qualifiedName -{ - Element* newElement = [[Element alloc] initWithQualifiedName:qualifiedName inNameSpaceURI:namespaceURI attributes:nil]; - - SVGKitLogVerbose( @"[%@] WARNING: SVG Spec, missing feature: if there are known attributes with default values, Attr nodes representing them SHOULD BE automatically created and attached to the element.", [self class] ); - - return newElement; -} - -// Introduced in DOM Level 2: --(Attr*) createAttributeNS:(NSString*) namespaceURI qualifiedName:(NSString*) qualifiedName -{ - NSAssert( FALSE, @"This should be re-implemented to share code with createElementNS: method above" ); - Attr* newAttr = [[Attr alloc] initWithNamespace:namespaceURI qualifiedName:qualifiedName value:@""]; - return newAttr; -} - -// Introduced in DOM Level 2: --(NodeList*) getElementsByTagNameNS:(NSString*) namespaceURI localName:(NSString*) localName -{ - NodeList* accumulator = [[NodeList alloc] init]; - [DOMHelperUtilities privateGetElementsByName:localName inNamespace:namespaceURI childrenOfElement:self.documentElement addToList:accumulator]; - - return accumulator; -} - -// Introduced in DOM Level 2: --(Element*) getElementById:(NSString*) elementId -{ - return [DOMHelperUtilities privateGetElementById:elementId childrenOfElement:self.documentElement]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentCSS.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentCSS.h deleted file mode 100644 index 523f568208..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentCSS.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-DocumentCSS - - interface DocumentCSS : stylesheets::DocumentStyle { - CSSStyleDeclaration getOverrideStyle(in Element elt, - in DOMString pseudoElt); - */ -#import -#import "DocumentStyle.h" - -#import "CSSStyleDeclaration.h" - -@class Element; - -@protocol DocumentCSS - --(CSSStyleDeclaration *)getOverrideStyle:(Element *)element pseudoElt:(NSString *)pseudoElt; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentFragment.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentFragment.h deleted file mode 100644 index c6bd6fcd05..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentFragment.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - From SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-B63ED1A3 - - interface DocumentFragment : Node { - }; -*/ - -#import - -/** objc won't allow this: @class Node;*/ -#import "Node.h" - -@interface DocumentFragment : Node - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentFragment.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentFragment.m deleted file mode 100644 index 2edcb99af9..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentFragment.m +++ /dev/null @@ -1,21 +0,0 @@ -// -// DocumentFragment.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "DocumentFragment.h" - -@implementation DocumentFragment - -- (id)init -{ - self = [super initType:DOMNodeType_DOCUMENT_FRAGMENT_NODE name:nil]; - if (self) { - - } - return self; -} -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentStyle.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentStyle.h deleted file mode 100644 index ae2685fc4d..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentStyle.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheet-DocumentStyle - - interface DocumentStyle { - readonly attribute StyleSheetList styleSheets; - */ - -#import - -#import "StyleSheetList.h" - -@protocol DocumentStyle - -@property(nonatomic,retain) StyleSheetList* styleSheets; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentType.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentType.h deleted file mode 100644 index 36b388af71..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentType.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - From SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-412266927 - - interface DocumentType : Node { - readonly attribute DOMString name; - readonly attribute NamedNodeMap entities; - readonly attribute NamedNodeMap notations; - // Introduced in DOM Level 2: - readonly attribute DOMString publicId; - // Introduced in DOM Level 2: - readonly attribute DOMString systemId; - // Introduced in DOM Level 2: - readonly attribute DOMString internalSubset; - }; -*/ -#import - -#import "Node.h" -#import "NamedNodeMap.h" - -@interface DocumentType : Node - -@property(nonatomic,strong,readonly) NSString* name; -@property(nonatomic,strong,readonly) NamedNodeMap* entities; -@property(nonatomic,strong,readonly) NamedNodeMap* notations; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readonly) NSString* publicId; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readonly) NSString* systemId; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readonly) NSString* internalSubset; - - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentType.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentType.m deleted file mode 100644 index 3878a2a912..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/DocumentType.m +++ /dev/null @@ -1,44 +0,0 @@ -// -// DocumentType.m -// SVGKit -// -// Created by adam on 23/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "DocumentType.h" - -/* - in case we need to redeclare them readwrite: - @property(nonatomic,retain,readonly) NSString* name; - @property(nonatomic,retain,readonly) NamedNodeMap* entities; - @property(nonatomic,retain,readonly) NamedNodeMap* notations; - - // Introduced in DOM Level 2: - @property(nonatomic,retain,readonly) NSString* publicId; - - // Introduced in DOM Level 2: - @property(nonatomic,retain,readonly) NSString* systemId; - - // Introduced in DOM Level 2: - @property(nonatomic,retain,readonly) NSString* internalSubset; - - */ - -@implementation DocumentType - -@synthesize name; -@synthesize entities; -@synthesize notations; - -// Introduced in DOM Level 2: -@synthesize publicId; - -// Introduced in DOM Level 2: -@synthesize systemId; - -// Introduced in DOM Level 2: -@synthesize internalSubset; - - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Element.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Element.h deleted file mode 100644 index e4182645d5..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Element.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - From SVG-DOM, via Core-DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-745549614 - - interface Element : Node { - readonly attribute DOMString tagName; - DOMString getAttribute(in DOMString name); - void setAttribute(in DOMString name, - in DOMString value) - raises(DOMException); - void removeAttribute(in DOMString name) - raises(DOMException); - Attr getAttributeNode(in DOMString name); - Attr setAttributeNode(in Attr newAttr) - raises(DOMException); - Attr removeAttributeNode(in Attr oldAttr) - raises(DOMException); - NodeList getElementsByTagName(in DOMString name); - // Introduced in DOM Level 2: - DOMString getAttributeNS(in DOMString namespaceURI, - in DOMString localName); - // Introduced in DOM Level 2: - void setAttributeNS(in DOMString namespaceURI, - in DOMString qualifiedName, - in DOMString value) - raises(DOMException); - // Introduced in DOM Level 2: - void removeAttributeNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - // Introduced in DOM Level 2: - Attr getAttributeNodeNS(in DOMString namespaceURI, - in DOMString localName); - // Introduced in DOM Level 2: - Attr setAttributeNodeNS(in Attr newAttr) - raises(DOMException); - // Introduced in DOM Level 2: - NodeList getElementsByTagNameNS(in DOMString namespaceURI, - in DOMString localName); - // Introduced in DOM Level 2: - boolean hasAttribute(in DOMString name); - // Introduced in DOM Level 2: - boolean hasAttributeNS(in DOMString namespaceURI, - in DOMString localName); - }; - */ - -#import - -/** objc won't allow this: @class Node;*/ -#import "Node.h" -@class Attr; -#import "Attr.h" -@class NodeList; -#import "NodeList.h" - -@interface Element : Node - -@property(nonatomic,strong,readonly) NSString* tagName; - --(NSString*) getAttribute:(NSString*) name; --(void) setAttribute:(NSString*) name value:(NSString*) value; --(void) removeAttribute:(NSString*) name; --(Attr*) getAttributeNode:(NSString*) name; --(Attr*) setAttributeNode:(Attr*) newAttr; --(Attr*) removeAttributeNode:(Attr*) oldAttr; --(NodeList*) getElementsByTagName:(NSString*) name; - -// Introduced in DOM Level 2: --(NSString*) getAttributeNS:(NSString*) namespaceURI localName:(NSString*) localName; - -// Introduced in DOM Level 2: --(void) setAttributeNS:(NSString*) namespaceURI qualifiedName:(NSString*) qualifiedName value:(NSString*) value; - -// Introduced in DOM Level 2: --(void) removeAttributeNS:(NSString*) namespaceURI localName:(NSString*) localName; - -// Introduced in DOM Level 2: --(Attr*) getAttributeNodeNS:(NSString*) namespaceURI localName:(NSString*) localName; - -// Introduced in DOM Level 2: --(Attr*) setAttributeNodeNS:(Attr*) newAttr; - -// Introduced in DOM Level 2: --(NodeList*) getElementsByTagNameNS:(NSString*) namespaceURI localName:(NSString*) localName; - -// Introduced in DOM Level 2: --(BOOL) hasAttribute:(NSString*) name; - -// Introduced in DOM Level 2: --(BOOL) hasAttributeNS:(NSString*) namespaceURI localName:(NSString*) localName; - -#pragma mark - Objective-C init methods (not in SVG Spec - you're supposed to use SVGDocument's createXXX methods instead) - -- (id)initWithLocalName:(NSString*) n attributes:(NSMutableDictionary*) attributes; -- (id)initWithQualifiedName:(NSString*) n inNameSpaceURI:(NSString*) nsURI attributes:(NSMutableDictionary*) attributes; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Element.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Element.m deleted file mode 100644 index b57c6cee85..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Element.m +++ /dev/null @@ -1,170 +0,0 @@ -#import "Element.h" - -#import "NamedNodeMap.h" -#import "DOMHelperUtilities.h" - -@interface Element() -@property(nonatomic,strong,readwrite) NSString* tagName; -@end - -@implementation Element - -@synthesize tagName; - - -- (id)initWithLocalName:(NSString*) n attributes:(NSMutableDictionary*) attributes { - self = [super initType:DOMNodeType_ELEMENT_NODE name:n]; - if (self) { - self.tagName = n; - - for( NSString* attributeName in attributes.allKeys ) - { - [self setAttribute:attributeName value:[attributes objectForKey:attributeName]]; - } - } - return self; -} -- (id)initWithQualifiedName:(NSString*) n inNameSpaceURI:(NSString*) nsURI attributes:(NSMutableDictionary *)attributes -{ - self = [super initType:DOMNodeType_ELEMENT_NODE name:n inNamespace:nsURI]; - if (self) { - self.tagName = n; - - for( Attr* attribute in attributes.allValues ) - { - [self.attributes setNamedItemNS:attribute inNodeNamespace:nsURI]; - } - } - return self; -} - --(NSString*) getAttribute:(NSString*) name -{ - /** - WARNING: the definition in the spec WILL CORRUPT unsuspecting Objective-C code (including a lot of the original SVGKit code!). - - The spec - instead of defining 'nil' - defines "" (empty string) as the - correct response. - - But in most of the modern, C-based, (non-scripting) languages, "" means 0. - - Very dangerous! - */ - Attr* result = (Attr*) [self.attributes getNamedItem:name]; - - if( result == nil || result.value == nil ) - return @""; // according to spec - else - return result.value; -} - --(void) setAttribute:(NSString*) name value:(NSString*) value -{ - Attr* att = [[Attr alloc] initWithName:name value:value]; - - [self.attributes setNamedItem:att]; -} - --(void) removeAttribute:(NSString*) name -{ - [self.attributes removeNamedItem:name]; - - NSAssert( FALSE, @"Not fully implemented. Spec says: If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable." ); -} - --(Attr*) getAttributeNode:(NSString*) name -{ - return (Attr*) [self.attributes getNamedItem:name]; -} - --(Attr*) setAttributeNode:(Attr*) newAttr -{ - Attr* oldAtt = (Attr*) [self.attributes getNamedItem:newAttr.nodeName]; - - [self.attributes setNamedItem:newAttr]; - - return oldAtt; -} - --(Attr*) removeAttributeNode:(Attr*) oldAttr -{ - [self.attributes removeNamedItem:oldAttr.nodeName]; - - NSAssert( FALSE, @"Not fully implemented. Spec: If the removed Attr has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable. " ); - - return oldAttr; -} - --(NodeList*) getElementsByTagName:(NSString*) name -{ - NodeList* accumulator = [[NodeList alloc] init]; - [DOMHelperUtilities privateGetElementsByName:name inNamespace:nil childrenOfElement:self addToList:accumulator]; - - return accumulator; -} - -// Introduced in DOM Level 2: --(NSString*) getAttributeNS:(NSString*) namespaceURI localName:(NSString*) localName -{ - Attr* result = (Attr*) [self.attributes getNamedItemNS:namespaceURI localName:localName]; - - if( result == nil || result.value == nil ) - return @""; // according to spec - else - return result.value; -} - -// Introduced in DOM Level 2: --(void) setAttributeNS:(NSString*) namespaceURI qualifiedName:(NSString*) qualifiedName value:(NSString*) value -{ - Attr* att = [[Attr alloc] initWithNamespace:namespaceURI qualifiedName:qualifiedName value:value]; - - [self.attributes setNamedItemNS:att]; -} - -// Introduced in DOM Level 2: --(void) removeAttributeNS:(NSString*) namespaceURI localName:(NSString*) localName -{ - NSAssert( FALSE, @"Not implemented yet" ); -} - -// Introduced in DOM Level 2: --(Attr*) getAttributeNodeNS:(NSString*) namespaceURI localName:(NSString*) localName -{ - Attr* result = (Attr*) [self.attributes getNamedItemNS:namespaceURI localName:localName]; - - return result; -} - -// Introduced in DOM Level 2: --(Attr*) setAttributeNodeNS:(Attr*) newAttr -{ - NSAssert( FALSE, @"Not implemented yet" ); - return nil; -} - -// Introduced in DOM Level 2: --(NodeList*) getElementsByTagNameNS:(NSString*) namespaceURI localName:(NSString*) localName -{ - NodeList* accumulator = [[NodeList alloc] init]; - [DOMHelperUtilities privateGetElementsByName:localName inNamespace:namespaceURI childrenOfElement:self addToList:accumulator]; - - return accumulator; -} - -// Introduced in DOM Level 2: --(BOOL) hasAttribute:(NSString*) name -{ - Attr* result = (Attr*) [self.attributes getNamedItem:name]; - - return result != nil; -} - -// Introduced in DOM Level 2: --(BOOL) hasAttributeNS:(NSString*) namespaceURI localName:(NSString*) localName -{ - NSAssert( FALSE, @"Not implemented yet" ); - return FALSE; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/EntityReference.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/EntityReference.h deleted file mode 100644 index bd8a6baad6..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/EntityReference.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - From SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-11C98490 - - interface EntityReference : Node { - }; - */ -#import - -/** objc won't allow this: @class Node; */ -#import "Node.h" - -@interface EntityReference : Node - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/EntityReference.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/EntityReference.m deleted file mode 100644 index 161bea906c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/EntityReference.m +++ /dev/null @@ -1,13 +0,0 @@ -// -// EntityReference.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "EntityReference.h" - -@implementation EntityReference - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/MediaList.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/MediaList.h deleted file mode 100644 index 0be89fa47b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/MediaList.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-MediaList - - interface MediaList { - attribute DOMString mediaText; - // raises(DOMException) on setting - - readonly attribute unsigned long length; - DOMString item(in unsigned long index); - void deleteMedium(in DOMString oldMedium) - raises(DOMException); - void appendMedium(in DOMString newMedium) - raises(DOMException); -*/ - -#import - -@interface MediaList : NSObject - -@property(nonatomic,strong) NSString* mediaText; -@property(nonatomic) unsigned long length; - --(NSString*) item:(unsigned long) index; --(void) deleteMedium:(NSString*) oldMedium; --(void) appendMedium:(NSString*) newMedium; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/MediaList.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/MediaList.m deleted file mode 100644 index 031d0f7184..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/MediaList.m +++ /dev/null @@ -1,23 +0,0 @@ -#import "MediaList.h" - -@implementation MediaList - -@synthesize mediaText; -@synthesize length; - - --(NSString*) item:(unsigned long) index -{ - NSAssert( FALSE, @"Not implemented yet"); - return nil; -} --(void) deleteMedium:(NSString*) oldMedium -{ - NSAssert( FALSE, @"Not implemented yet"); -} --(void) appendMedium:(NSString*) newMedium -{ - NSAssert( FALSE, @"Not implemented yet"); -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap.h deleted file mode 100644 index 7b737cbe13..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - From SVG-DOM, via Core-DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1780488922 - - interface NamedNodeMap { - Node getNamedItem(in DOMString name); - Node setNamedItem(in Node arg) - raises(DOMException); - Node removeNamedItem(in DOMString name) - raises(DOMException); - Node item(in unsigned long index); - readonly attribute unsigned long length; - // Introduced in DOM Level 2: - Node getNamedItemNS(in DOMString namespaceURI, - in DOMString localName); - // Introduced in DOM Level 2: - Node setNamedItemNS(in Node arg) - raises(DOMException); - // Introduced in DOM Level 2: - Node removeNamedItemNS(in DOMString namespaceURI, - in DOMString localName) - raises(DOMException); - }; - - */ - -#import - -@class Node; -#import "Node.h" - -@interface NamedNodeMap : NSObject - --(Node*) getNamedItem:(NSString*) name; --(Node*) setNamedItem:(Node*) arg; --(Node*) removeNamedItem:(NSString*) name; --(Node*) item:(unsigned long) index; - -@property(readonly) unsigned long length; - -// Introduced in DOM Level 2: --(Node*) getNamedItemNS:(NSString*) namespaceURI localName:(NSString*) localName; - -// Introduced in DOM Level 2: --(Node*) setNamedItemNS:(Node*) arg; - -// Introduced in DOM Level 2: --(Node*) removeNamedItemNS:(NSString*) namespaceURI localName:(NSString*) localName; - -#pragma mark - MISSING METHOD FROM SVG Spec, without which you cannot parse documents (don't understand how they intended you to fulfil the spec without this method) - --(Node*) setNamedItemNS:(Node*) arg inNodeNamespace:(NSString*) nodesNamespace; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap.m deleted file mode 100644 index 14507a7523..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap.m +++ /dev/null @@ -1,203 +0,0 @@ -// -// NamedNodeMap.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "NamedNodeMap.h" -#import "NamedNodeMap_Iterable.h" - -@interface NamedNodeMap() -@property(nonatomic,strong) NSMutableDictionary* internalDictionary; -@property(nonatomic,strong) NSMutableDictionary* internalDictionaryOfNamespaces; -@end - -@implementation NamedNodeMap - -@synthesize internalDictionary; -@synthesize internalDictionaryOfNamespaces; - -- (id)init { - self = [super init]; - if (self) { - self.internalDictionary = [NSMutableDictionary dictionary]; - self.internalDictionaryOfNamespaces = [NSMutableDictionary dictionary]; - } - return self; -} - - --(Node*) getNamedItem:(NSString*) name -{ - Node* simpleResult = [self.internalDictionary objectForKey:name]; - - if( simpleResult == nil ) - { - /** - Check the namespaces in turn, to see if we can find this node in one of them - - NB: according to spec, this behaviour is: - - "The result depends on the implementation" - - I've chosen to implement it the most user-friendly way possible. It is NOT the best - solution IMHO - the spec authors should have defined the outcome! - */ - - for( NSString* key in self.internalDictionaryOfNamespaces ) - { - simpleResult = [self getNamedItemNS:key localName:name]; - if( simpleResult != nil ) - break; - } - } - - return simpleResult; -} - --(Node*) setNamedItem:(Node*) arg -{ - NSAssert( [[self.internalDictionaryOfNamespaces allKeys] count] < 1, @"WARNING: you are using namespaced attributes in parallel with non-namespaced. According to the DOM Spec, this leads to UNDEFINED behaviour. This is insane - you do NOT want to be doing this! Crashing deliberately...." ); - - Node* oldNode = [self.internalDictionary objectForKey:arg.localName]; - - [self.internalDictionary setObject:arg forKey:arg.localName]; - - return oldNode; -} - --(Node*) removeNamedItem:(NSString*) name -{ - NSAssert( [[self.internalDictionaryOfNamespaces allKeys] count] < 1, @"WARNING: you are using namespaced attributes in parallel with non-namespaced. According to the DOM Spec, this leads to UNDEFINED behaviour. This is insane - you do NOT want to be doing this! Crashing deliberately...." ); - - Node* oldNode = [self.internalDictionary objectForKey:name]; - - [self.internalDictionary removeObjectForKey:name]; - - return oldNode; -} - --(unsigned long)length -{ - NSUInteger count = [self.internalDictionary count]; - - for( NSDictionary* namespaceDict in [self.internalDictionaryOfNamespaces allValues] ) - { - count += [namespaceDict count]; - } - - return count; -} - --(Node*) item:(unsigned long) index -{ - NSAssert(FALSE, @"This method is broken; Apple does not consistently return ordered values in dictionary.allValues. Apple DOES NOT SUPPORT ordered Maps/Hashes/Tables/Hashtables - we have to re-implement this wheel from scratch"); - - if( index < [self.internalDictionary count] ) - return [self.internalDictionary.allValues objectAtIndex:index]; - else - { - index -= self.internalDictionary.count; - - for( NSDictionary* namespaceDict in [self.internalDictionaryOfNamespaces allValues] ) - { - if( index < [namespaceDict count] ) - return [namespaceDict.allValues objectAtIndex:index]; - else - index -= [namespaceDict count]; - } - } - - return nil; -} - -// Introduced in DOM Level 2: --(Node*) getNamedItemNS:(NSString*) namespaceURI localName:(NSString*) localName -{ - NSMutableDictionary* namespaceDict = [self.internalDictionaryOfNamespaces objectForKey:namespaceURI]; - - return [namespaceDict objectForKey:localName]; -} - -// Introduced in DOM Level 2: --(Node*) setNamedItemNS:(Node*) arg -{ - return [self setNamedItemNS:arg inNodeNamespace:nil]; -} - -// Introduced in DOM Level 2: --(Node*) removeNamedItemNS:(NSString*) namespaceURI localName:(NSString*) localName -{ - NSMutableDictionary* namespaceDict = [self.internalDictionaryOfNamespaces objectForKey:namespaceURI]; - Node* oldNode = [namespaceDict objectForKey:localName]; - - [namespaceDict removeObjectForKey:localName]; - - return oldNode; -} - -#pragma mark - MISSING METHOD FROM SVG Spec, without which you cannot parse documents (don't understand how they intended you to fulfil the spec without this method) - --(Node*) setNamedItemNS:(Node*) arg inNodeNamespace:(NSString*) nodesNamespace -{ - NSString* effectiveNamespace = arg.namespaceURI != nil ? arg.namespaceURI : nodesNamespace; - if( effectiveNamespace == nil ) - { - return [self setNamedItem:arg]; // this should never happen, but there's a lot of malformed SVG files out in the wild - } - - NSMutableDictionary* namespaceDict = [self.internalDictionaryOfNamespaces objectForKey:effectiveNamespace]; - if( namespaceDict == nil ) - { - namespaceDict = [NSMutableDictionary dictionary]; - [self.internalDictionaryOfNamespaces setObject:namespaceDict forKey:effectiveNamespace]; - } - Node* oldNode = [namespaceDict objectForKey:arg.localName]; - - [namespaceDict setObject:arg forKey:arg.localName]; - - return oldNode; -} - -#pragma mark - ADDITIONAL to SVG Spec: useful debug / output / description methods - --(NSString *)description -{ - /** test (and output) both the "DOM 1" and "DOM 2" dictionaries, if they're non-empty */ - - NSString* dom1 = self.internalDictionary.count > 0 ? [NSString stringWithFormat:@"DOM-v1(%@)", self.internalDictionary] : nil; - NSString* dom2 = self.internalDictionaryOfNamespaces.count > 0 ? [NSString stringWithFormat:@"DOM-v2(%@)", self.internalDictionaryOfNamespaces] : nil; - - return [NSString stringWithFormat:@"NamedNodeMap: %@%@%@", dom1, dom1 != nil && dom2 != nil ? @"\n" : @"", dom2 ]; -} - -#pragma mark - Implementation of category: NamedNodeMap_Iterable - --(NSArray*) allNodesUnsortedDOM1 -{ - /** Using DOM1 - no namespace support */ - - return self.internalDictionary.allValues; -} - --(NSDictionary*) allNodesUnsortedDOM2 -{ - /** Using DOM2 - every item has a namespace*/ - - return self.internalDictionaryOfNamespaces; -} - -#pragma mark - Needed to implement XML DOM effectively: ability to shallow-Clone an instance - --(id)copyWithZone:(NSZone *)zone -{ - NamedNodeMap* clone = [[NamedNodeMap allocWithZone:zone] init]; - clone.internalDictionary = [self.internalDictionary copyWithZone:zone]; - clone.internalDictionaryOfNamespaces = [self.internalDictionaryOfNamespaces copyWithZone:zone]; - - return clone; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap_Iterable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap_Iterable.h deleted file mode 100644 index dc1fff7bed..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NamedNodeMap_Iterable.h +++ /dev/null @@ -1,17 +0,0 @@ -@interface NamedNodeMap () - -/** - DOM1 is very basic and ignores namespaces - dangerous! It's recommended to avoid DOM1 calls throughout your apps and code! - - @return an Array of "nodes from the nodemap (Node)" - */ --(NSArray*) allNodesUnsortedDOM1; - -/** - DOM2 requires everything to have a namespace - much better than DOM1 - - @return a Dictionary of "namespace (string)" mapped to "node from nodemap (Node)" - */ - -(NSDictionary*) allNodesUnsortedDOM2; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node+Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node+Mutable.h deleted file mode 100644 index 2767e1fd75..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node+Mutable.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - Makes the writable properties all package-private, effectively - */ -#import "Node.h" - -@interface Node() -@property(nonatomic,strong,readwrite) NSString* nodeName; -@property(nonatomic,strong,readwrite) NSString* nodeValue; - -@property(nonatomic,readwrite) DOMNodeType nodeType; -@property(nonatomic,weak,readwrite) Node* parentNode; -@property(nonatomic,strong,readwrite) NodeList* childNodes; -@property(nonatomic,strong,readwrite) NamedNodeMap* attributes; - -@property(nonatomic,weak,readwrite) Document* ownerDocument; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readwrite) NSString* namespaceURI; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readwrite) NSString* prefix; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readwrite) NSString* localName; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node.h deleted file mode 100644 index 0e65dab30e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node.h +++ /dev/null @@ -1,174 +0,0 @@ -/* -// Node.h -* - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247 - - interface Node { - - // NodeType - const unsigned short ELEMENT_NODE = 1; - const unsigned short ATTRIBUTE_NODE = 2; - const unsigned short TEXT_NODE = 3; - const unsigned short CDATA_SECTION_NODE = 4; - const unsigned short ENTITY_REFERENCE_NODE = 5; - const unsigned short ENTITY_NODE = 6; - const unsigned short PROCESSING_INSTRUCTION_NODE = 7; - const unsigned short COMMENT_NODE = 8; - const unsigned short DOCUMENT_NODE = 9; - const unsigned short DOCUMENT_TYPE_NODE = 10; - const unsigned short DOCUMENT_FRAGMENT_NODE = 11; - const unsigned short NOTATION_NODE = 12; - - readonly attribute DOMString nodeName; - attribute DOMString nodeValue; - // raises(DOMException) on setting - // raises(DOMException) on retrieval - - readonly attribute unsigned short nodeType; - readonly attribute Node parentNode; - readonly attribute NodeList childNodes; - readonly attribute Node firstChild; - readonly attribute Node lastChild; - readonly attribute Node previousSibling; - readonly attribute Node nextSibling; - readonly attribute NamedNodeMap attributes; - // Modified in DOM Level 2: - readonly attribute Document ownerDocument; - Node insertBefore(in Node newChild, - in Node refChild) - raises(DOMException); - Node replaceChild(in Node newChild, - in Node oldChild) - raises(DOMException); - Node removeChild(in Node oldChild) - raises(DOMException); - Node appendChild(in Node newChild) - raises(DOMException); - boolean hasChildNodes(); - Node cloneNode(in boolean deep); - // Modified in DOM Level 2: - void normalize(); - // Introduced in DOM Level 2: - boolean isSupported(in DOMString feature, - in DOMString version); - // Introduced in DOM Level 2: - readonly attribute DOMString namespaceURI; - // Introduced in DOM Level 2: - attribute DOMString prefix; - // raises(DOMException) on setting - - // Introduced in DOM Level 2: - readonly attribute DOMString localName; - // Introduced in DOM Level 2: - boolean hasAttributes(); - }; - - ------------------------------- - - // DOM Level 3 that we *need*, partly because SVG Spec makes one brief reference to it: http://www.w3.org/TR/SVG/text.html#InterfaceSVGTextContentElement - - http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent - - // Introduced in DOM Level 3: - attribute DOMString textContent; - -*/ - -#import - -@class Document; -/** objc won't allow this: #import "Document.h"*/ -@class NodeList; -/** objc won't allow this: #import "NodeList.h"*/ -@class NamedNodeMap; -/** objc won't allow this: #import "NamedNodeMap.h"*/ - -typedef enum DOMNodeType -{ - DOMNodeType_ELEMENT_NODE = 1, - DOMNodeType_ATTRIBUTE_NODE = 2, - DOMNodeType_TEXT_NODE = 3, - DOMNodeType_CDATA_SECTION_NODE = 4, - DOMNodeType_ENTITY_REFERENCE_NODE = 5, - DOMNodeType_ENTITY_NODE = 6, - DOMNodeType_PROCESSING_INSTRUCTION_NODE = 7, - DOMNodeType_COMMENT_NODE = 8, - DOMNodeType_DOCUMENT_NODE = 9, - DOMNodeType_DOCUMENT_TYPE_NODE = 10, - DOMNodeType_DOCUMENT_FRAGMENT_NODE = 11, - DOMNodeType_NOTATION_NODE = 12 -} DOMNodeType; - -@interface Node : NSObject - -@property(nonatomic,strong,readonly) NSString* nodeName; -@property(nonatomic,strong,readonly) NSString* nodeValue; - -@property(nonatomic,readonly) DOMNodeType nodeType; -@property(nonatomic,weak,readonly) Node* parentNode; -@property(nonatomic,strong,readonly) NodeList* childNodes; -@property(nonatomic,weak,readonly) Node* firstChild; -@property(nonatomic,weak,readonly) Node* lastChild; -@property(nonatomic,weak,readonly) Node* previousSibling; -@property(nonatomic,weak,readonly) Node* nextSibling; -@property(nonatomic,strong,readonly) NamedNodeMap* attributes; /**< NB: according to DOM Spec, this is null if the Node is NOT subclassed as an Element */ - -// Modified in DOM Level 2: -@property(nonatomic,weak,readonly) Document* ownerDocument; - --(Node*) insertBefore:(Node*) newChild refChild:(Node*) refChild; - --(Node*) replaceChild:(Node*) newChild oldChild:(Node*) oldChild; --(Node*) removeChild:(Node*) oldChild; --(Node*) appendChild:(Node*) newChild; - -@property(nonatomic) BOOL hasChildNodes; - --(Node*) cloneNode:(BOOL) deep; - -// Modified in DOM Level 2: --(void) normalize; - -// Introduced in DOM Level 2: --(BOOL) isSupportedFeature:(NSString*) feature version:(NSString*) version; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readonly) NSString* namespaceURI; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readonly) NSString* prefix; - -// Introduced in DOM Level 2: -@property(nonatomic,strong,readonly) NSString* localName; - -// Introduced in DOM Level 2: -@property(nonatomic) BOOL hasAttributes; - -// DOM Level 3 that we *need*, partly because SVG Spec makes one brief reference to it: http://www.w3.org/TR/SVG/text.html#InterfaceSVGTextContentElement - -// Introduced in DOM Level 3: http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent -@property(weak, nonatomic,readonly) NSString* textContent; - -#pragma mark - Objective-C init methods (not in SVG Spec - you're supposed to use SVGDocument's createXXX methods instead) -/** Designated initializers - 2 pairs (one for DOM 1, no namespace, the other for DOM 2, with namespace) of 2 methods (one for nodes that REQUIRE a value, the other for nodes that MUST NOT have a value) */ -- (id)initType:(DOMNodeType) nt name:(NSString*) n; -- (id)initType:(DOMNodeType) nt name:(NSString*) n value:(NSString*) v; -- (id)initType:(DOMNodeType) nt name:(NSString*) n inNamespace:(NSString*) nsURI; -- (id)initType:(DOMNodeType) nt name:(NSString*) n value:(NSString*) v inNamespace:(NSString*) nsURI; - -#pragma mark - Objective-C serialization method to serialize a DOM tree back to XML (used heavily in SVGKit's output/conversion features) - -/** EXPERIMENTAL: not fully implemented or tested - this correctly outputs most SVG files, but is missing esoteric - features such as EntityReferences, currently they are simply ignored - - This method should be used hand-in-hand with the proprietary SVGDocument method "allNamespaces" and the SVGSVGElement method " - - @param outputString an empty MUTABLE string we can accumulate with output (NB: this method uses a lot of memory, needs to accumulate data) - - @param prefixesByKNOWNNamespace (required): a dictionary mapping "XML namespace URI" to "prefix to use inside the xml-tags", e.g. "http://w3.org/2000/svg" usually is mapped to "svg" (or to "", signifying it's the default namespace). This MUST include ALL NAMESPACES FOUND IN THE DOCUMENT (it's recommended you use SVGDocument's "allPrefixesByNamespace" method, and some post-processing, to get an accurate input here) - - @param prefixesByACTIVENamespace (required): a mutable dictionary listing which elements of the other dictionary are active in-scope - i.e. which namespaces have been output by this node or a higher node in the tree. You pass-in an empty dictionary to the root SVG node and it fills it in as required. - */ --(void) appendXMLToString:(NSMutableString*) outputString availableNamespaces:(NSDictionary*) prefixesByKNOWNNamespace activeNamespaces:(NSMutableDictionary*) prefixesByACTIVENamespace; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node.m deleted file mode 100644 index af3b6749ec..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Node.m +++ /dev/null @@ -1,642 +0,0 @@ -// -// Node.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "Node.h" -#import "Node+Mutable.h" - -#import "NodeList+Mutable.h" -#import "NamedNodeMap.h" - -#import "NamedNodeMap_Iterable.h" // Needed for the optional (non-SVG spec) "recursive toXML" method - -@implementation Node - -@synthesize nodeName; -@synthesize nodeValue; - -@synthesize nodeType; -@synthesize parentNode; -@synthesize childNodes; -@synthesize attributes; - -// Modified in DOM Level 2: -@synthesize ownerDocument; - -@synthesize hasAttributes, hasChildNodes; - -@synthesize localName; - - -- (id)init -{ - NSAssert( FALSE, @"This class has no init method - it MUST NOT be init'd via init - you MUST use one of the multi-argument constructors instead" ); - - return nil; -} - -- (id)initType:(DOMNodeType) nt name:(NSString*) n value:(NSString*) v -{ - if( [v isKindOfClass:[NSMutableString class]]) - { - /** Apple allows this, but it breaks the whole of Obj-C / cocoa, which is damn stupid - So we have to fix it.*/ - v = [NSString stringWithString:v]; - } - - self = [super init]; - if (self) { - self.nodeType = nt; - switch( nt ) - { - - case DOMNodeType_ATTRIBUTE_NODE: - case DOMNodeType_CDATA_SECTION_NODE: - case DOMNodeType_COMMENT_NODE: - case DOMNodeType_PROCESSING_INSTRUCTION_NODE: - case DOMNodeType_TEXT_NODE: - { - self.nodeName = n; - self.nodeValue = v; - }break; - - - case DOMNodeType_DOCUMENT_NODE: - case DOMNodeType_DOCUMENT_TYPE_NODE: - case DOMNodeType_DOCUMENT_FRAGMENT_NODE: - case DOMNodeType_ENTITY_REFERENCE_NODE: - case DOMNodeType_ENTITY_NODE: - case DOMNodeType_NOTATION_NODE: - case DOMNodeType_ELEMENT_NODE: - { - NSAssert( FALSE, @"NodeType = %i cannot be init'd with a value; nodes of that type have no value in the DOM spec", nt); - - self = nil; - }break; - } - - self.childNodes = [[NodeList alloc] init]; - } - return self; -} - -- (id)initType:(DOMNodeType) nt name:(NSString*) n -{ - self = [super init]; - if (self) { - self.nodeType = nt; - switch( nt ) - { - - case DOMNodeType_ATTRIBUTE_NODE: - case DOMNodeType_CDATA_SECTION_NODE: - case DOMNodeType_COMMENT_NODE: - case DOMNodeType_PROCESSING_INSTRUCTION_NODE: - case DOMNodeType_TEXT_NODE: - { - NSAssert( FALSE, @"NodeType = %i cannot be init'd without a value; nodes of that type MUST have a value in the DOM spec", nt); - - self = nil; - }break; - - - case DOMNodeType_DOCUMENT_NODE: - case DOMNodeType_DOCUMENT_TYPE_NODE: - case DOMNodeType_DOCUMENT_FRAGMENT_NODE: - case DOMNodeType_ENTITY_REFERENCE_NODE: - case DOMNodeType_ENTITY_NODE: - case DOMNodeType_NOTATION_NODE: - { - self.nodeName = n; - }break; - - case DOMNodeType_ELEMENT_NODE: - { - - self.nodeName = n; - - self.attributes = [[NamedNodeMap alloc] init]; - }break; - } - - self.childNodes = [[NodeList alloc] init]; - } - return self; -} - - -#pragma mark - Objective-C init methods DOM LEVEL 2 (preferred init - safer/better!) --(void) postInitNamespaceHandling:(NSString*) nsURI -{ - NSArray* nameSpaceParts = [self.nodeName componentsSeparatedByString:@":"]; - self.localName = [nameSpaceParts lastObject]; - if( [nameSpaceParts count] > 1 ) - self.prefix = [nameSpaceParts objectAtIndex:0]; - - self.namespaceURI = nsURI; -} - -- (id)initType:(DOMNodeType) nt name:(NSString*) n inNamespace:(NSString*) nsURI -{ - self = [self initType:nt name:n]; - - if( self ) - { - [self postInitNamespaceHandling:nsURI]; - } - - return self; -} - -- (id)initType:(DOMNodeType) nt name:(NSString*) n value:(NSString*) v inNamespace:(NSString*) nsURI -{ - if( [v isKindOfClass:[NSMutableString class]]) - { - /** Apple allows this, but it breaks the whole of Obj-C / cocoa, which is damn stupid - So we have to fix it.*/ - v = [NSString stringWithString:v]; - } - - self = [self initType:nt name:n value:v]; - - if( self ) - { - [self postInitNamespaceHandling:nsURI]; - } - - return self; -} - -#pragma mark - Official DOM method implementations - --(Node *)firstChild -{ - if( [self.childNodes length] < 1 ) - return nil; - else - return [self.childNodes item:0]; -} - --(Node *)lastChild -{ - if( [self.childNodes length] < 1 ) - return nil; - else - return [self.childNodes item: [self.childNodes length] - 1]; -} - --(Node *)previousSibling -{ - if( self.parentNode == nil ) - return nil; - else - { - NSUInteger indexInParent = [self.parentNode.childNodes.internalArray indexOfObject:self]; - - if( indexInParent < 1 ) - return nil; - else - return [self.parentNode.childNodes item:indexInParent-1]; - } -} - --(Node *)nextSibling -{ - if( self.parentNode == nil ) - return nil; - else - { - NSUInteger indexInParent = [self.parentNode.childNodes.internalArray indexOfObject:self]; - - if( indexInParent >= [self.parentNode.childNodes length] ) - return nil; - else - return [self.parentNode.childNodes item:indexInParent + 1]; - } -} - --(Node*) insertBefore:(Node*) newChild refChild:(Node*) refChild -{ - if( refChild == nil ) - { - [self.childNodes.internalArray addObject:newChild]; - newChild.parentNode = self; - } - else - { - [self.childNodes.internalArray insertObject:newChild atIndex:[self.childNodes.internalArray indexOfObject:refChild]]; - } - - return newChild; -} - --(Node*) replaceChild:(Node*) newChild oldChild:(Node*) oldChild -{ - if( newChild.nodeType == DOMNodeType_DOCUMENT_FRAGMENT_NODE ) - { - /** Spec: - - "If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed." - */ - - NSUInteger oldIndex = [self.childNodes.internalArray indexOfObject:oldChild]; - - NSAssert( FALSE, @"We should be recursing down the tree to find 'newChild' at any location, and removing it - required by spec - but we have no convenience method for that search, yet" ); - - for( Node* child in newChild.childNodes.internalArray ) - { - [self.childNodes.internalArray insertObject:child atIndex:oldIndex++]; - } - - newChild.parentNode = self; - oldChild.parentNode = nil; - - return oldChild; - } - else - { - [self.childNodes.internalArray replaceObjectAtIndex:[self.childNodes.internalArray indexOfObject:oldChild] withObject:newChild]; - - newChild.parentNode = self; - oldChild.parentNode = nil; - - return oldChild; - } -} --(Node*) removeChild:(Node*) oldChild -{ - [self.childNodes.internalArray removeObject:oldChild]; - - oldChild.parentNode = nil; - - return oldChild; -} - --(Node*) appendChild:(Node*) newChild -{ - [self.childNodes.internalArray removeObject:newChild]; // required by spec - [self.childNodes.internalArray addObject:newChild]; - - newChild.parentNode = self; - - return newChild; -} - --(BOOL)hasChildNodes -{ - return (self.childNodes.length > 0); -} - --(Node*) cloneNode:(BOOL) deep -{ - NSAssert( FALSE, @"Not implemented yet - read the spec. Sounds tricky. I'm too tired, and would probably screw it up right now" ); - return nil; -} - -// Modified in DOM Level 2: --(void) normalize -{ - NSAssert( FALSE, @"Not implemented yet - read the spec. Sounds tricky. I'm too tired, and would probably screw it up right now" ); -} - -// Introduced in DOM Level 2: --(BOOL) isSupportedFeature:(NSString*) feature version:(NSString*) version -{ - NSAssert( FALSE, @"Not implemented yet - read the spec. I have literally no idea what this is supposed to do." ); - return FALSE; -} - -// Introduced in DOM Level 2: -@synthesize namespaceURI; - -// Introduced in DOM Level 2: -@synthesize prefix; - -// Introduced in DOM Level 2: --(BOOL)hasAttributes -{ - if( self.attributes == nil ) - return FALSE; - - return (self.attributes.length > 0 ); -} - -#pragma mark - SPECIAL CASE: DOM level 3 method - -/** - - Note that the DOM 3 spec defines this as RECURSIVE: - - http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent - */ --(NSString *)textContent -{ - switch( self.nodeType ) - { - case DOMNodeType_ELEMENT_NODE: - case DOMNodeType_ATTRIBUTE_NODE: - case DOMNodeType_ENTITY_NODE: - case DOMNodeType_ENTITY_REFERENCE_NODE: - case DOMNodeType_DOCUMENT_FRAGMENT_NODE: - { - /** DOM 3 Spec: - "concatenation of the textContent attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children." - */ - NSMutableString* stringAccumulator = [[NSMutableString alloc] init]; - for( Node* subNode in self.childNodes.internalArray ) - { - NSString* subText = subNode.textContent; // don't call this method twice; it's expensive to calculate! - if( subText != nil ) // Yes, really: Apple docs require that you never append a nil substring. Sigh - [stringAccumulator appendString:subText]; - } - - return [NSString stringWithString:stringAccumulator]; - } - - case DOMNodeType_TEXT_NODE: - case DOMNodeType_CDATA_SECTION_NODE: - case DOMNodeType_COMMENT_NODE: - case DOMNodeType_PROCESSING_INSTRUCTION_NODE: - { - return self.nodeValue; // should never be nil; anything with a valid value will be at least an empty string i.e. "" - } - - case DOMNodeType_DOCUMENT_NODE: - case DOMNodeType_NOTATION_NODE: - case DOMNodeType_DOCUMENT_TYPE_NODE: - { - return nil; - } - } -} - -#pragma mark - ADDITIONAL to SVG Spec: useful debug / output / description methods - --(NSString *)description -{ - NSString* nodeTypeName; - switch( self.nodeType ) - { - case DOMNodeType_ELEMENT_NODE: - nodeTypeName = @"ELEMENT"; - break; - case DOMNodeType_TEXT_NODE: - nodeTypeName = @"TEXT"; - break; - case DOMNodeType_ENTITY_NODE: - nodeTypeName = @"ENTITY"; - break; - case DOMNodeType_COMMENT_NODE: - nodeTypeName = @"COMMENT"; - break; - case DOMNodeType_DOCUMENT_NODE: - nodeTypeName = @"DOCUMENT"; - break; - case DOMNodeType_NOTATION_NODE: - nodeTypeName = @"NOTATION"; - break; - case DOMNodeType_ATTRIBUTE_NODE: - nodeTypeName = @"ATTRIBUTE"; - break; - case DOMNodeType_CDATA_SECTION_NODE: - nodeTypeName = @"CDATA"; - break; - case DOMNodeType_DOCUMENT_TYPE_NODE: - nodeTypeName = @"DOC TYPE"; - break; - case DOMNodeType_ENTITY_REFERENCE_NODE: - nodeTypeName = @"ENTITY REF"; - break; - case DOMNodeType_DOCUMENT_FRAGMENT_NODE: - nodeTypeName = @"DOC FRAGMENT"; - break; - case DOMNodeType_PROCESSING_INSTRUCTION_NODE: - nodeTypeName = @"PROCESSING INSTRUCTION"; - break; - - default: - nodeTypeName = @"N/A (DATA IS MISSING FROM NODE INSTANCE)"; - } - return [NSString stringWithFormat:@"Node: %@ (%@) value:[%@] @@%ld attributes + %ld x children", self.nodeName, nodeTypeName, [self.nodeValue length]<11 ? self.nodeValue : [NSString stringWithFormat:@"%@...",[self.nodeValue substringToIndex:10]], self.attributes.length, (unsigned long)self.childNodes.length]; -} - -#pragma mark - Objective-C serialization method to serialize a DOM tree back to XML (used heavily in SVGKit's output/conversion features) - -/** EXPERIMENTAL: not fully implemented or tested - this correctly outputs most SVG files, but is missing esoteric - features such as EntityReferences, currently they are simply ignored - - This method should be used hand-in-hand with the proprietary SVGDocument method "allNamespaces" and the SVGSVGElement method " - - @param outputString an empty MUTABLE string we can accumulate with output (NB: this method uses a lot of memory, needs to accumulate data) - - @param prefixesByKNOWNNamespace (required): a dictionary mapping "XML namespace URI" to "prefix to use inside the xml-tags", e.g. "http://w3.org/2000/svg" usually is mapped to "svg" (or to "", signifying it's the default namespace). This MUST include ALL NAMESPACES FOUND IN THE DOCUMENT (it's recommended you use SVGDocument's "allPrefixesByNamespace" method, and some post-processing, to get an accurate input here) - - @param prefixesByACTIVENamespace (required): a mutable dictionary listing which elements of the other dictionary are active in-scope - i.e. which namespaces have been output by this node or a higher node in the tree. You pass-in an empty dictionary to the root SVG node and it fills it in as required. - */ --(void) appendXMLToString:(NSMutableString*) outputString availableNamespaces:(NSDictionary*) prefixesByKNOWNNamespace activeNamespaces:(NSMutableDictionary*) prefixesByACTIVENamespace -{ -// NSAssert(namespaceShortnames != nil, @"Must supply an empty dictionary for me to fill with encountered namespaces, and the shortnames I invented for them!"); - - /** Opening */ - switch( self.nodeType ) - { - case DOMNodeType_ATTRIBUTE_NODE: - { - // ? - }break; - - case DOMNodeType_CDATA_SECTION_NODE: - { - [outputString appendFormat:@""]; - }break; - - case DOMNodeType_COMMENT_NODE: - { - [outputString appendFormat:@"]]>"]; - }break; - - case DOMNodeType_DOCUMENT_FRAGMENT_NODE: - case DOMNodeType_DOCUMENT_NODE: - case DOMNodeType_ELEMENT_NODE: - { - [outputString appendFormat:@"", self.nodeName]; - }break; - - case DOMNodeType_DOCUMENT_TYPE_NODE: - case DOMNodeType_ENTITY_NODE: - case DOMNodeType_ENTITY_REFERENCE_NODE: - case DOMNodeType_NOTATION_NODE: - case DOMNodeType_PROCESSING_INSTRUCTION_NODE: - case DOMNodeType_TEXT_NODE: - { - // nothing - }break; - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList+Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList+Mutable.h deleted file mode 100644 index 72fe1d1136..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList+Mutable.h +++ /dev/null @@ -1,11 +0,0 @@ -/** - Makes the writable properties all package-private, effectively - */ - -#import "NodeList.h" - -@interface NodeList() - -@property(nonatomic,strong) NSMutableArray* internalArray; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList.h deleted file mode 100644 index b145fa4da4..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Implemented internally via an NSArray - - NB: contains a slight "upgrade" from the SVG Spec to make it support Objective-C's - Fast Enumeration feature - - From SVG DOM, via CoreDOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-536297177 - - interface NodeList { - Node item(in unsigned long index); - readonly attribute unsigned long length; - }; - - */ -#import - -@class Node; -#import "Node.h" - -@interface NodeList : NSObject - -@property(readonly) NSUInteger length; - --(Node*) item:(NSUInteger) index; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList.m deleted file mode 100644 index 3e715ff579..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/NodeList.m +++ /dev/null @@ -1,42 +0,0 @@ -#import "NodeList.h" -#import "NodeList+Mutable.h" - -@implementation NodeList - -@synthesize internalArray; - -- (id)init { - self = [super init]; - - if (self) { - self.internalArray = [NSMutableArray array]; - } - return self; -} - - --(Node*) item:(NSUInteger) index -{ - return [self.internalArray objectAtIndex:index]; -} - --(NSUInteger)length -{ - return [self.internalArray count]; -} - -#pragma mark - ADDITIONAL to SVG Spec: Objective-C support for fast-iteration ("for * in ..." syntax) - --(NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len -{ - return [self.internalArray countByEnumeratingWithState:state objects:buffer count:len]; -} - -#pragma mark - ADDITIONAL to SVG Spec: useful debug / output / description methods - --(NSString *)description -{ - return [NSString stringWithFormat:@"NodeList: array(%@)", self.internalArray]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/ProcessingInstruction.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/ProcessingInstruction.h deleted file mode 100644 index be98f00da8..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/ProcessingInstruction.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1004215813 - - interface ProcessingInstruction : Node { - readonly attribute DOMString target; - attribute DOMString data; - // raises(DOMException) on setting - - }; -*/ - -#import - -/** objc won't allow this: @class Node;*/ -#import "Node.h" - -@interface ProcessingInstruction : Node -@property(nonatomic,strong,readonly) NSString* target; -@property(nonatomic,strong,readonly) NSString* data; - --(id) initProcessingInstruction:(NSString*) target value:(NSString*) data; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/ProcessingInstruction.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/ProcessingInstruction.m deleted file mode 100644 index 9672dc3e47..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/ProcessingInstruction.m +++ /dev/null @@ -1,31 +0,0 @@ -// -// ProcessingInstruction.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "ProcessingInstruction.h" - -@interface ProcessingInstruction() -@property(nonatomic,strong,readwrite) NSString* target; -@property(nonatomic,strong,readwrite) NSString* data; -@end - -@implementation ProcessingInstruction - -@synthesize target; -@synthesize data; - --(id) initProcessingInstruction:(NSString*) t value:(NSString*) d -{ - self = [super initType:DOMNodeType_PROCESSING_INSTRUCTION_NODE name:t value:d]; - if (self) { - self.target = t; - self.data = d; - } - return self; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheet.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheet.h deleted file mode 100644 index 5c9ee35a31..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheet.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheet - - interface StyleSheet { - readonly attribute DOMString type; - attribute boolean disabled; - readonly attribute Node ownerNode; - readonly attribute StyleSheet parentStyleSheet; - readonly attribute DOMString href; - readonly attribute DOMString title; - readonly attribute MediaList media; - */ - -#import - -@class Node; -@class MediaList; - -@interface StyleSheet : NSObject - -@property(nonatomic,strong) NSString* type; -@property(nonatomic) BOOL disabled; -@property(nonatomic,strong) Node* ownerNode; -@property(nonatomic,strong) StyleSheet* parentStyleSheet; -@property(nonatomic,strong) NSString* href; -@property(nonatomic,strong) NSString* title; -@property(nonatomic,strong) MediaList* media; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheet.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheet.m deleted file mode 100644 index ef8acc2477..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheet.m +++ /dev/null @@ -1,5 +0,0 @@ -#import "StyleSheet.h" - -@implementation StyleSheet - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList+Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList+Mutable.h deleted file mode 100644 index 1597973ea6..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList+Mutable.h +++ /dev/null @@ -1,5 +0,0 @@ -#import "StyleSheetList.h" - -@interface StyleSheetList() -@property(nonatomic,strong) NSMutableArray* internalArray; -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList.h deleted file mode 100644 index c47d72686c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheetList - - interface StyleSheetList { - readonly attribute unsigned long length; - StyleSheet item(in unsigned long index); - */ - -#import - -#import "StyleSheet.h" - -@interface StyleSheetList : NSObject - -@property(nonatomic,readonly) unsigned long length; - --(StyleSheet*) item:(unsigned long) index; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList.m deleted file mode 100644 index 9c95323532..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/StyleSheetList.m +++ /dev/null @@ -1,28 +0,0 @@ -#import "StyleSheetList.h" -#import "StyleSheetList+Mutable.h" - -@implementation StyleSheetList - -@synthesize internalArray; - -- (id)init -{ - self = [super init]; - if (self) { - self.internalArray = [NSMutableArray array]; - } - return self; -} - - --(unsigned long)length -{ - return self.internalArray.count; -} - --(StyleSheet*) item:(unsigned long) index -{ - return [self.internalArray objectAtIndex:index]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Text.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Text.h deleted file mode 100644 index 00e7b00c72..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Text.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - SVG-DOM, via Core DOM: - - http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1312295772 - - interface Text : CharacterData { - Text splitText(in unsigned long offset) - raises(DOMException); - }; -*/ - -#import - -@class CharacterData; -#import "CharacterData.h" - -@interface Text : CharacterData - -- (id)initWithValue:(NSString*) v; - --(Text*) splitText:(unsigned long) offset; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Text.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Text.m deleted file mode 100644 index 91fe282687..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Core DOM/Text.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// Text.m -// SVGKit -// -// Created by adam on 22/05/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "Text.h" - -@implementation Text - -- (id)initWithValue:(NSString*) v -{ - self = [super initType:DOMNodeType_TEXT_NODE name:@"#text" value:v]; - if (self) { - - } - return self; -} --(Text*) splitText:(unsigned long) offset; -{ - NSAssert( FALSE, @"Not implemented yet" ); - return nil; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAngle.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAngle.h deleted file mode 100644 index 5a6dd8ea1b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAngle.h +++ /dev/null @@ -1,42 +0,0 @@ -/*! - SVGAngle - - http://www.w3.org/TR/SVG/types.html#InterfaceSVGAngle - - // Angle Unit Types - const unsigned short SVG_ANGLETYPE_UNKNOWN = 0; - const unsigned short SVG_ANGLETYPE_UNSPECIFIED = 1; - const unsigned short SVG_ANGLETYPE_DEG = 2; - const unsigned short SVG_ANGLETYPE_RAD = 3; - const unsigned short SVG_ANGLETYPE_GRAD = 4; - - readonly attribute unsigned short unitType; - attribute float value setraises(DOMException); - attribute float valueInSpecifiedUnits setraises(DOMException); - attribute DOMString valueAsString setraises(DOMException); - - void newValueSpecifiedUnits(in unsigned short unitType, in float valueInSpecifiedUnits) raises(DOMException); - void convertToSpecifiedUnits(in unsigned short unitType) raises(DOMException); - */ -#import - -@interface SVGAngle : NSObject - -/*! Angle Unit Types */ -typedef enum SVGKAngleType -{ - SVG_ANGLETYPE_UNKNOWN = 0, - SVG_ANGLETYPE_UNSPECIFIED = 1, - SVG_ANGLETYPE_DEG = 2, - SVG_ANGLETYPE_RAD = 3, - SVG_ANGLETYPE_GRAD = 4 -} SVGKAngleType; - -@property(nonatomic, readonly) SVGKAngleType unitType; -@property(nonatomic) float value; -@property(nonatomic) float valueInSpecifiedUnits; -@property(nonatomic,strong) NSString* valueAsString; - --(void) newValueSpecifiedUnits:(SVGKAngleType) unitType valueInSpecifiedUnits:(float) valueInSpecifiedUnits; --(void) convertToSpecifiedUnits:(SVGKAngleType) unitType; -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAngle.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAngle.m deleted file mode 100644 index 56eb2bd69d..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAngle.m +++ /dev/null @@ -1,13 +0,0 @@ -#import "SVGAngle.h" - -@implementation SVGAngle - -@synthesize unitType; -@synthesize value; -@synthesize valueInSpecifiedUnits; -@synthesize valueAsString; - --(void) newValueSpecifiedUnits:(SVGKAngleType) unitType valueInSpecifiedUnits:(float) valueInSpecifiedUnits { NSAssert( FALSE, @"Not implemented yet" ); } --(void) convertToSpecifiedUnits:(SVGKAngleType) unitType { NSAssert( FALSE, @"Not implemented yet" ); } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAnimatedPreserveAspectRatio.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAnimatedPreserveAspectRatio.h deleted file mode 100644 index 9de75f1f0a..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAnimatedPreserveAspectRatio.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - http://www.w3.org/TR/SVG/coords.html#InterfaceSVGAnimatedPreserveAspectRatio - - readonly attribute SVGPreserveAspectRatio baseVal; - readonly attribute SVGPreserveAspectRatio animVal; - */ -#import -#import "SVGPreserveAspectRatio.h" - -@interface SVGAnimatedPreserveAspectRatio : NSObject - -@property(nonatomic,strong) SVGPreserveAspectRatio* baseVal; -@property(nonatomic,strong, readonly) SVGPreserveAspectRatio* animVal; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAnimatedPreserveAspectRatio.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAnimatedPreserveAspectRatio.m deleted file mode 100644 index 11e244fe40..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGAnimatedPreserveAspectRatio.m +++ /dev/null @@ -1,28 +0,0 @@ -#import "SVGAnimatedPreserveAspectRatio.h" - -@implementation SVGAnimatedPreserveAspectRatio - - -- (id)init -{ - self = [super init]; - if (self) { - self.baseVal = [SVGPreserveAspectRatio new]; - } - return self; -} - -/** TODO: Current implementation (animation not supported anywhere in SVGKit yet) simply returns - a copy of self.baseVal --- NOTE: spec REQUIRES you return a copy! It is explicit on this! - */ --(SVGPreserveAspectRatio *)animVal -{ - SVGPreserveAspectRatio* cloneOfBase = [SVGPreserveAspectRatio new]; - - cloneOfBase.align = self.baseVal.align; - cloneOfBase.meetOrSlice = self.baseVal.meetOrSlice; - - return cloneOfBase; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGClipPathElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGClipPathElement.h deleted file mode 100644 index eea2cdb94b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGClipPathElement.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -http://www.w3.org/TR/SVG/masking.html#InterfaceSVGClipPathElement - - interface SVGClipPathElement : SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable, - SVGUnitTypes { - */ - -#import "SVGElement.h" -#import "SVGElement_ForParser.h" - -#import "ConverterSVGToCALayer.h" -#import "SVGTransformable.h" -#import "SVGUnitTypes.h" - - -// Does NOT implement ConverterSVGToCALayer because elements are never rendered directly; they're only referenced via clip-path attributes in other elements -@interface SVGClipPathElement : SVGElement - -@property(nonatomic, readonly) SVG_UNIT_TYPE clipPathUnits; - -- (CALayer *) newLayer; -- (void)layoutLayer:(CALayer *)layer toMaskLayer:(CALayer *)maskThis; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGClipPathElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGClipPathElement.m deleted file mode 100644 index 96b25e5e90..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGClipPathElement.m +++ /dev/null @@ -1,81 +0,0 @@ -#import "SVGClipPathElement.h" - -#import "CALayerWithChildHitTest.h" - -#import "SVGHelperUtilities.h" - -@implementation SVGClipPathElement - -@synthesize clipPathUnits; -@synthesize transform; // each SVGElement subclass that conforms to protocol "SVGTransformable" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - NSError *error = [NSError errorWithDomain:@"SVGKit" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys: - @" found in SVG. May render incorrectly with SVGKFastImageView due to Apple bug in CALayer .mask rendering.", NSLocalizedDescriptionKey, - nil]]; - [parseResult addParseErrorRecoverable:error]; - - clipPathUnits = SVG_UNIT_TYPE_USERSPACEONUSE; - - NSString *units = [self getAttribute:@"clipPathUnits"]; - if( units != nil && units.length > 0 ) { - if( [units isEqualToString:@"userSpaceOnUse"] ) - clipPathUnits = SVG_UNIT_TYPE_USERSPACEONUSE; - else if( [units isEqualToString:@"objectBoundingBox"] ) - clipPathUnits = SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; - else { - SVGKitLogWarn(@"Unknown clipPathUnits value %@", units); - NSError *error = [NSError errorWithDomain:@"SVGKit" code:1 userInfo:[NSDictionary dictionaryWithObjectsAndKeys: - [NSString stringWithFormat:@"Unknown clipPathUnits value %@", units], NSLocalizedDescriptionKey, - nil]]; - [parseResult addParseErrorRecoverable:error]; - } - } -} - -- (CALayer *) newLayer -{ - - CALayer* _layer = [CALayerWithChildHitTest layer]; - - [SVGHelperUtilities configureCALayer:_layer usingElement:self]; - - return _layer; -} - -- (void)layoutLayer:(CALayer *)layer toMaskLayer:(CALayer *)maskThis -{ - // null rect union any other rect will return the other rect - CGRect mainRect = CGRectNull; - - /** make mainrect the UNION of all sublayer's frames (i.e. their individual "bounds" inside THIS layer's space) */ - for ( CALayer *currentLayer in [layer sublayers] ) - { - mainRect = CGRectUnion(mainRect, currentLayer.frame); - } - - /** Changing THIS layer's frame now means all DIRECT sublayers are offset by too much (because when we change the offset - of the parent frame (this.frame), Apple *does not* shift the sublayers around to keep them in same place. - - NB: there are bugs in some Apple code in Interface Builder where it attempts to do exactly that (incorrectly, as the API - is specifically designed NOT to do this), and ... Fails. But in code, thankfully, Apple *almost* never does this (there are a few method - calls where it appears someone at Apple forgot how their API works, and tried to do the offsetting automatically. "Paved - with good intentions...". - */ - if (CGRectIsNull(mainRect)) - { - // TODO what to do when mainRect is null rect? i.e. no sublayer or all sublayers have null rect frame - } else { - for (CALayer *currentLayer in [layer sublayers]) - currentLayer.frame = CGRectOffset(currentLayer.frame, -mainRect.origin.x, -mainRect.origin.y); - } - - // unless we're working in bounding box coords, subtract the owning layer's origin - if( self.clipPathUnits == SVG_UNIT_TYPE_USERSPACEONUSE ) - mainRect = CGRectOffset(mainRect, -maskThis.frame.origin.x, -maskThis.frame.origin.y); - layer.frame = mainRect; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDefsElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDefsElement.h deleted file mode 100644 index c47fca9b59..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDefsElement.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - http://www.w3.org/TR/SVG/struct.html#InterfaceSVGDefsElement - - */ -#import "SVGElement.h" - -@interface SVGDefsElement : SVGElement { } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDefsElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDefsElement.m deleted file mode 100644 index 02ea0542d3..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDefsElement.m +++ /dev/null @@ -1,5 +0,0 @@ -#import "SVGDefsElement.h" - -@implementation SVGDefsElement - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument.h deleted file mode 100644 index 8139a7c310..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - SVG DOM, cf: - - http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGDocument - - interface SVGDocument : Document, - DocumentEvent { - readonly attribute DOMString title; - readonly attribute DOMString referrer; - readonly attribute DOMString domain; - readonly attribute DOMString URL; - readonly attribute SVGSVGElement rootElement; - }; - */ - -#import - -#import "Document.h" -#import "SVGSVGElement.h" - -@interface SVGDocument : Document - -@property (nonatomic, strong, readonly) NSString* title; -@property (nonatomic, strong, readonly) NSString* referrer; -@property (nonatomic, strong, readonly) NSString* domain; -@property (nonatomic, strong, readonly) NSString* URL; -@property (nonatomic, strong, readonly) SVGSVGElement* rootElement; - -#pragma mark - Objective-C init methods (not part of DOM spec, but necessary!) - -- (id)init; - -#pragma mark - Serialization methods that we think ought to be part of the SVG spec, as they are needed for a good implementation, but we can't find in the main Spec - -/** - Recursively goes through the document finding all declared namespaces in-use by any tag or attribute. - - @return a dictionary mapping "namespace" to "ARRAY of prefix-strings" - */ --(NSMutableDictionary*) allPrefixesByNamespace; - -/** - As per allPrefixesByNamespace, but takes the output and guarantees that: - - 1. There is AT MOST ONE namespace with no prefix - 2. The "prefixless" namespace is the SVG namespace (if possible. This should always be possible for an SVG doc!) - 3. All other namespaces have EXACTLY ONE prefix (if there are multiple, it discards excess ones) - 4. All prefixes are UNIQUE (not used by more than one Namespace) - - This is critically important when writing-out an SVG file to disk - As far as I can tell, it's a major ommission from - the XML Spec (which SVG sits on top of). Without this info, you can't construct the appropriate/correct "xmlns" directives - at the start of a file. - - USAGE INSTRUCTIONS: - - 1. Call this method to get the complete list of namespaces, including any prefixes used - 2. Invoke Node's "appendXMLToString:..." method, passing-in this output, so it can correctly output prefixes for all nodes and subnodes - - @return a dictionary mapping "namespace" to "prefix-string or empty-string for the default namespace" - */ --(NSMutableDictionary*) allPrefixesByNamespaceNormalized; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument.m deleted file mode 100644 index 28de3d59c2..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument.m +++ /dev/null @@ -1,177 +0,0 @@ -/** - SVGDocument - - SVG spec defines this as part of the DOM version of SVG: - - http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGDocument - */ - -#import "Document+Mutable.h" - -#import "SVGDocument.h" -#import "SVGDocument_Mutable.h" - -#import "NamedNodeMap_Iterable.h" // needed for the allPrefixesByNamespace implementation - -@implementation SVGDocument - - -@synthesize title; -@synthesize referrer; -@synthesize domain; -@synthesize URL; -@synthesize rootElement=_rootElement; - - - -- (id)init -{ - self = [super initType:DOMNodeType_DOCUMENT_NODE name:@"#document"]; - if (self) { - - } - return self; -} - --(void)setRootElement:(SVGSVGElement *)rootElement -{ - _rootElement = rootElement; - - /*! SVG spec has two variables with same name, because DOM was written to support - weak programming languages that don't provide full OOP polymorphism. - - So, we'd better keep the two variables in sync! - */ - super.documentElement = rootElement; -} - --(void)setDocumentElement:(Element *)newDocumentElement -{ - NSAssert( [newDocumentElement isKindOfClass:[SVGSVGElement class]], @"Cannot set the documentElement property on an SVG doc unless it's of type SVGSVGDocument" ); - - super.documentElement = newDocumentElement; - - /*! SVG spec has two variables with same name, because DOM was written to support - weak programming languages that don't provide full OOP polymorphism. - - So, we'd better keep the two variables in sync! - */ - self.rootElement = (SVGSVGElement*) self.documentElement; -} - -#pragma mark - Serialization methods that we think ought to be part of the SVG spec, as they are needed for a good implementation, but we can't find in the main Spec - -/** - Recursively goes through the document finding all declared namespaces in-use by any tag or attribute. - - @return a dictionary mapping "namespace" to "ARRAY of prefix-strings" - */ --(NSMutableDictionary*) allPrefixesByNamespace -{ - NSMutableDictionary* result = [NSMutableDictionary dictionary]; - - [SVGDocument accumulateNamespacesForNode:self.rootElement intoDictionary:result]; - - return result; -} - -/** implementation of allPrefixesByNamespace - stores "namespace string" : "ARRAY of prefix strings" - */ -+(void) accumulateNamespacesForNode:(Node*) node intoDictionary:(NSMutableDictionary*) output -{ - /** - First, find all the attributes that declare a new Namespace at this point */ - NSDictionary* nodeMapsByNamespace = [node.attributes allNodesUnsortedDOM2]; - - NSString* xmlnsNamespace = @"http://www.w3.org/2000/xmlns/"; - NSDictionary* xmlnsNodemap = [nodeMapsByNamespace objectForKey:xmlnsNamespace]; - - for( NSString* xmlnsNodeName in xmlnsNodemap ) - { - Node* namespaceDeclaration = [xmlnsNodemap objectForKey:xmlnsNodeName]; - - NSMutableArray* prefixesForNamespace = [output objectForKey:namespaceDeclaration.nodeValue]; - if( prefixesForNamespace == nil ) - { - prefixesForNamespace = [NSMutableArray array]; - [output setObject:prefixesForNamespace forKey:namespaceDeclaration.nodeValue]; - } - - if( ! [prefixesForNamespace containsObject:namespaceDeclaration.nodeName]) - [prefixesForNamespace addObject:namespaceDeclaration.localName]; - } - - for( Node* childNode in node.childNodes ) - { - [self accumulateNamespacesForNode:childNode intoDictionary:output]; - } -} - -/** - As per allPrefixesByNamespace, but takes the output and guarantees that: - - 1. There is AT MOST ONE namespace with no prefix - 2. The "prefixless" namespace is the SVG namespace (if possible. This should always be possible for an SVG doc!) - 3. All other namespaces have EXACTLY ONE prefix (if there are multiple, it discards excess ones) - 4. All prefixes are UNIQUE (not used by more than one Namespace) - - This is critically important when writing-out an SVG file to disk - As far as I can tell, it's a major ommission from - the XML Spec (which SVG sits on top of). Without this info, you can't construct the appropriate/correct "xmlns" directives - at the start of a file. - - USAGE INSTRUCTIONS: - - 1. Call this method to get the complete list of namespaces, including any prefixes used - 2. Invoke Node's "appendXMLToString:..." method, passing-in this output, so it can correctly output prefixes for all nodes and subnodes - - @return a dictionary mapping "namespace" to "prefix-string or empty-string for the default namespace" - */ --(NSMutableDictionary*) allPrefixesByNamespaceNormalized -{ - NSMutableDictionary* prefixArraysByNamespace = [self allPrefixesByNamespace]; - NSMutableDictionary* normalizedPrefixesByNamespace = [NSMutableDictionary dictionary]; - - for( NSString* namespace in prefixArraysByNamespace ) - { - NSArray* prefixes = [prefixArraysByNamespace objectForKey:namespace]; - - BOOL exportedAUniquePrefix = FALSE; - for( NSString* nextPrefix in prefixes ) - { - if( ! [normalizedPrefixesByNamespace.allValues containsObject:nextPrefix]) - { - [normalizedPrefixesByNamespace setObject:nextPrefix forKey:namespace]; - exportedAUniquePrefix = TRUE; - break; - } - } - - /** If that failed to find a unique prefix, we need to either generate one, or use the default prefix */ - if( ! exportedAUniquePrefix ) - { - if( [namespace isEqualToString:@"http://w3.org/2000/svg"]) - { - [normalizedPrefixesByNamespace setObject:@"" forKey:namespace]; - } - else - { - /** Generate a new shortname that will OVERRIDE AND REPLACE whatever prefixes this attribute has */ - int suffix = 1; - NSString* newPrefix = [namespace lastPathComponent]; - while( [normalizedPrefixesByNamespace.allValues containsObject:newPrefix]) - { - suffix++; - - newPrefix = [NSString stringWithFormat:@"%@-%i", [namespace lastPathComponent], suffix]; - } - - [normalizedPrefixesByNamespace setObject:newPrefix forKey:namespace]; - } - } - } - - SVGKitLogVerbose(@"Normalized prefixes:\n%@", normalizedPrefixesByNamespace ); - return normalizedPrefixesByNamespace; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument_Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument_Mutable.h deleted file mode 100644 index 55596ab23f..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGDocument_Mutable.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - Makes the writable properties all package-private, effectively - */ - -#import "SVGDocument.h" - -@interface SVGDocument () -@property (nonatomic, strong, readwrite) NSString* title; -@property (nonatomic, strong, readwrite) NSString* referrer; -@property (nonatomic, strong, readwrite) NSString* domain; -@property (nonatomic, strong, readwrite) NSString* URL; -@property (nonatomic, strong, readwrite) SVGSVGElement* rootElement; -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance.h deleted file mode 100644 index 021f29cfc8..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - http://www.w3.org/TR/SVG/struct.html#InterfaceSVGElementInstance - - interface SVGElementInstance : EventTarget { - readonly attribute SVGElement correspondingElement; - readonly attribute SVGUseElement correspondingUseElement; - readonly attribute SVGElementInstance parentNode; - readonly attribute SVGElementInstanceList childNodes; - readonly attribute SVGElementInstance firstChild; - readonly attribute SVGElementInstance lastChild; - readonly attribute SVGElementInstance previousSibling; - readonly attribute SVGElementInstance nextSibling; - */ - -#import "SVGElement.h" -#import "SVGElementInstanceList.h" - -@class SVGUseElement; -#import "SVGUseElement.h" - -/** - ADDITIONAL IMPLEMENTATION NOTES: - - We make the two back-links into the SVG DOM Tree ("correspondingElement" and "correspondingUseElement") weak references to prevent - a retain-cycle. - - If you delete parts of the original tree, but don't do anything to update your USE tags / elements, then ... the back-links will - become nil. This seems the most rational, "what you would expect", behaviour. - */ - -@interface SVGElementInstance : NSObject - - -/*The corresponding element to which this object is an instance. For example, if a ‘use’ element references a ‘rect’ element, then an SVGElementInstance is created, with its correspondingElement being the SVGRectElement object for the ‘rect’ element. */ -@property(nonatomic, weak, readonly) SVGElement* correspondingElement; - - -/* The corresponding ‘use’ element to which this SVGElementInstance object belongs. When ‘use’ elements are nested (e.g., a ‘use’ references another ‘use’ which references a graphics element such as a ‘rect’), then the correspondingUseElement is the outermost ‘use’ (i.e., the one which indirectly references the ‘rect’, not the one with the direct reference). */ -@property(nonatomic, weak, readonly) SVGUseElement* correspondingUseElement; - -/* The parent of this SVGElementInstance within the instance tree. All SVGElementInstance objects have a parent except the SVGElementInstance which corresponds to the element which was directly referenced by the ‘use’ element, in which case parentNode is null. */ -@property(nonatomic,strong, readonly) SVGElementInstance* parentNode; - -/* An SVGElementInstanceList that contains all children of this SVGElementInstance within the instance tree. If there are no children, this is an SVGElementInstanceList containing no entries (i.e., an empty list). -firstChild (readonly SVGElementInstance) */ -@property(nonatomic,strong, readonly) SVGElementInstanceList* childNodes; - - -/* The first child of this SVGElementInstance within the instance tree. If there is no such SVGElementInstance, this returns null. */ -@property(nonatomic,strong, readonly) SVGElementInstance* firstChild; - -/* The last child of this SVGElementInstance within the instance tree. If there is no such SVGElementInstance, this returns null. */ -@property(nonatomic,strong, readonly) SVGElementInstance* lastChild; - -/* The SVGElementInstance immediately preceding this SVGElementInstance. If there is no such SVGElementInstance, this returns null. */ -@property(nonatomic,strong, readonly) SVGElementInstance* previousSibling; - -/* The SVGElementInstance immediately following this SVGElementInstance. If there is no such SVGElementInstance, this returns null. */ -@property(nonatomic,strong, readonly) SVGElementInstance* nextSibling; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance.m deleted file mode 100644 index e6a7645bc9..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance.m +++ /dev/null @@ -1,86 +0,0 @@ -#import "SVGElementInstance.h" -#import "SVGElementInstance_Mutable.h" - -#import "SVGElementInstanceList_Internal.h" - -@implementation SVGElementInstance - -@synthesize parentNode; -@synthesize childNodes; - -- (void)dealloc { - self.parentNode = nil; - self.correspondingElement = nil; - self.correspondingUseElement = nil; -} - --(void)setParentNode:(SVGElementInstance *)newParentNode -{ - if( newParentNode != self.parentNode ) - { - if( newParentNode == nil ) - { - /* additionally remove self from parent's childNodes */ - [self.parentNode.childNodes.internalArray removeObject:self]; - - parentNode = newParentNode; - } - else - { - /* additionally ADD self to parent's childNodes */ - parentNode = newParentNode; - - NSAssert( NSNotFound != [self.parentNode.childNodes.internalArray indexOfObject:self], @"Found that I was already a child of the node that I was being added to - should be impossible!" ); - - [self.parentNode.childNodes.internalArray addObject:self]; - } - } -} - --(SVGElementInstance *)firstChild -{ - if( [self.childNodes length] < 1 ) - return nil; - else - return [self.childNodes item:0]; -} - --(SVGElementInstance *)lastChild -{ - if( [self.childNodes length] < 1 ) - return nil; - else - return [self.childNodes item: [self.childNodes length] - 1]; -} - --(SVGElementInstance *)previousSibling -{ - if( self.parentNode == nil ) - return nil; - else - { - NSUInteger indexInParent = [self.parentNode.childNodes.internalArray indexOfObject:self]; - - if( indexInParent < 1 ) - return nil; - else - return [self.parentNode.childNodes item:indexInParent-1]; - } -} - --(SVGElementInstance *)nextSibling -{ - if( self.parentNode == nil ) - return nil; - else - { - NSUInteger indexInParent = [self.parentNode.childNodes.internalArray indexOfObject:self]; - - if( indexInParent >= [self.parentNode.childNodes length] ) - return nil; - else - return [self.parentNode.childNodes item:indexInParent + 1]; - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList.h deleted file mode 100644 index 9043b5d004..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - http://www.w3.org/TR/SVG/struct.html#InterfaceSVGElementInstanceList - - interface SVGElementInstanceList { - - readonly attribute unsigned long length; - - SVGElementInstance item(in unsigned long index); -*/ - -#import "SVGElement.h" - -@class SVGElementInstance; - -@interface SVGElementInstanceList : SVGElement - -@property(nonatomic, readonly) unsigned long length; - --(SVGElementInstance*) item:(unsigned long) index; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList.m deleted file mode 100644 index c988bd6d3c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList.m +++ /dev/null @@ -1,30 +0,0 @@ -#import "SVGElementInstanceList.h" -#import "SVGElementInstanceList_Internal.h" - -@implementation SVGElementInstanceList -@synthesize internalArray; - - -- (id)init -{ - self = [super init]; - if (self) { - self.internalArray = [NSMutableArray array]; - } - return self; -} - --(unsigned long)length -{ - return [self.internalArray count]; -} - --(SVGElementInstance*) item:(unsigned long) index -{ - if( index >= [self.internalArray count] ) - return nil; - - return [self.internalArray objectAtIndex:index]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList_Internal.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList_Internal.h deleted file mode 100644 index 31a93c9ef2..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstanceList_Internal.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// SVGElementInstanceList_Internal.h -// SVGKit-iOS -// -// Created by adam on 29/09/2012. -// Copyright (c) 2012 na. All rights reserved. -// - -#import "SVGElementInstanceList.h" - -@interface SVGElementInstanceList () - -@property(nonatomic,strong) NSMutableArray* internalArray; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance_Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance_Mutable.h deleted file mode 100644 index 9139416018..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGElementInstance_Mutable.h +++ /dev/null @@ -1,8 +0,0 @@ -#import "SVGElementInstance.h" - -@interface SVGElementInstance () -@property(nonatomic,weak, readwrite) SVGElement* correspondingElement; -@property(nonatomic,weak, readwrite) SVGUseElement* correspondingUseElement; -@property(nonatomic,strong, readwrite) SVGElementInstance* parentNode; -@property(nonatomic,strong, readwrite) SVGElementInstanceList* childNodes; -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGFitToViewBox.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGFitToViewBox.h deleted file mode 100644 index 70e20a3d79..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGFitToViewBox.h +++ /dev/null @@ -1,22 +0,0 @@ -/** - * http://www.w3.org/TR/SVG/types.html#InterfaceSVGFitToViewBox - - interface SVGFitToViewBox { - readonly attribute SVGAnimatedRect viewBox; - readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio; - */ - -#import - -#import - -#import "SVGRect.h" -#import "SVGAnimatedPreserveAspectRatio.h" - -@protocol SVGFitToViewBox - -@property (nonatomic) /* SVGAnimatedRect */ SVGRect viewBox; - -@property(nonatomic,retain) SVGAnimatedPreserveAspectRatio* preserveAspectRatio; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGGElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGGElement.h deleted file mode 100644 index 50b181abed..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGGElement.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - http://www.w3.org/TR/SVG/struct.html#InterfaceSVGGElement - - interface SVGGElement : SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable { - */ - -#import "SVGElement.h" -#import "SVGElement_ForParser.h" - -#import "ConverterSVGToCALayer.h" -#import "SVGTransformable.h" - - -@interface SVGGElement : SVGElement - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGGElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGGElement.m deleted file mode 100644 index a4c2068d9b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGGElement.m +++ /dev/null @@ -1,71 +0,0 @@ -#import "SVGGElement.h" - -#import "CALayerWithChildHitTest.h" - -#import "SVGHelperUtilities.h" - -@implementation SVGGElement - -@synthesize transform; // each SVGElement subclass that conforms to protocol "SVGTransformable" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols - -- (CALayer *) newLayer -{ - - CALayer* _layer = [CALayerWithChildHitTest layer]; - - [SVGHelperUtilities configureCALayer:_layer usingElement:self]; - - return _layer; -} - -- (void)layoutLayer:(CALayer *)layer { - - // null rect union any other rect will return the other rect - CGRect mainRect = CGRectNull; - - /** make mainrect the UNION of all sublayer's frames (i.e. their individual "bounds" inside THIS layer's space) */ - for ( CALayer *currentLayer in [layer sublayers] ) - { - CGRect subLayerFrame = currentLayer.frame; - mainRect = CGRectUnion(mainRect, subLayerFrame); - } - - NSAssert(!CGRectIsNull(mainRect), @"A G element has been generated with non-existent size and no contents. Apple cannot cope with this. As a workaround, we are resetting your layer to empty, but this may have unwanted side-effects (hard to test)" ); - if (CGRectIsNull(mainRect)) - { - return; - } - else - { - /** use mainrect (union of all sub-layer bounds) this layer's FRAME - - i.e. top-left-corner of this layer will be "the top left corner of the convex-hull rect of all sublayers" - AND: bottom-right-corner of this layer will be "the bottom-right corner of the convex-hull rect of all sublayers" - */ - layer.frame = mainRect; - - /** - If this group layer has a mask then since we've adjusted this layer's frame we need to offset the mask's frame by the opposite amount. - */ - if (layer.mask) - layer.mask.frame = CGRectOffset(layer.mask.frame, -mainRect.origin.x, -mainRect.origin.y); - - /** Changing THIS layer's frame now means all DIRECT sublayers are offset by too much (because when we change the offset - of the parent frame (this.frame), Apple *does not* shift the sublayers around to keep them in same place. - - NB: there are bugs in some Apple code in Interface Builder where it attempts to do exactly that (incorrectly, as the API - is specifically designed NOT to do this), and ... Fails. But in code, thankfully, Apple *almost* never does this (there are a few method - calls where it appears someone at Apple forgot how their API works, and tried to do the offsetting automatically. "Paved - with good intentions...". - */ - - for (CALayer *currentLayer in [layer sublayers]) { - CGRect frame = currentLayer.frame; - frame.origin.x -= mainRect.origin.x; - frame.origin.y -= mainRect.origin.y; - currentLayer.frame = frame; - } - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGHelperUtilities.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGHelperUtilities.h deleted file mode 100644 index d06908c3ee..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGHelperUtilities.h +++ /dev/null @@ -1,61 +0,0 @@ -/** - To implement the official SVG Spec, some "extra" methods are needed that are SHARED between classes, but - which in the SVG Spec the classes aren't subclass/superclass of each other - so that there's no way to - implement it without copy/pasting the code. - - To improve maintainability, we put those methods here, and then each place we need them has a 1-line method - that delegates to a method body in this class. - */ -#import - -#import -#import "SVGElement.h" -#import "SVGTransformable.h" -#import "SVGFitToViewBox.h" - -#define FORCE_RASTERIZE_LAYERS 0 // If True, all CALayers will be told to rasterize themselves. This MIGHT increase performance (or might not), but leads to blurriness whenever a layer is scaled / zoomed in -#define IMPROVE_PERFORMANCE_BY_WORKING_AROUND_APPLE_FRAME_ALIGNMENT_BUG 1 // NB: Apple's code for rendering ANY CALayer is extremely slow if the layer has non-integer co-ordinates for its "frame" or "bounds" property. This flag technically makes your SVG's render incorrect at sub-pixel level, but often increases performance of Apple's rendering by a factor of 2 or more! -@class SVGGradientLayer; -@interface SVGHelperUtilities : NSObject - -/** - According to the SVG Spec, there are two types of element that affect the on-screen size/shape/position/rotation/skew of shapes/images: - - 1. Any ancestor that implements SVGTransformable - 2. Any "element that establishes a new viewport" - i.e. the tag and a few others - -This method ONLY looks at current node to establish the above two things, to do a RELATIVE transform (relative to parent node) - */ -+(CGAffineTransform) transformRelativeIncludingViewportForTransformableOrViewportEstablishingElement:(SVGElement*) transformableOrSVGSVGElement; -/** - According to the SVG Spec, there are two types of element that affect the on-screen size/shape/position/rotation/skew of shapes/images: - - 1. Any ancestor that implements SVGTransformable - 2. Any "element that establishes a new viewport" - i.e. the tag and a few others - - This method recurses upwards to combine the above two things for everything in the tree, to establish an ABSOLUTE transform - */ -+(CGAffineTransform) transformAbsoluteIncludingViewportForTransformableOrViewportEstablishingElement:(SVGElement*) transformableOrSVGSVGElement; - - -/** Some things - e.g. setting layer's Opacity - have to be done for pretty much EVERY SVGElement; this method automatically looks - at the incoming element, uses the protocols that element has (e.g. SVGStylable) to automatically adapt the layer. - - This allows each SVGElement subclass to create a custom CALayer as needed (e.g. CATextLayer for text elements), but share the setup - code. - - If compiled with FORCE_RASTERIZE_LAYERS, also tells every layer to rasterize itself - */ -+(void) configureCALayer:(CALayer*) layer usingElement:(SVGElement*) nonStylableElement; - -+(CALayer *) newCALayerForPathBasedSVGElement:(SVGElement*) svgElement withPath:(CGPathRef) path; -+ (SVGGradientLayer*)getGradientLayerWithId:(NSString*)gradId - forElement:(SVGElement*)svgElement - withRect:(CGRect)r - transform:(CGAffineTransform)transform; - -+(CGColorRef) parseFillForElement:(SVGElement *)svgElement; -+(CGColorRef) parseStrokeForElement:(SVGElement *)svgElement; -+(void) parsePreserveAspectRatioFor:(Element*) element; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGHelperUtilities.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGHelperUtilities.m deleted file mode 100644 index 9cdd690fcb..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGHelperUtilities.m +++ /dev/null @@ -1,711 +0,0 @@ -#import "SVGHelperUtilities.h" - -#import -#import - -#import "CAShapeLayerWithHitTest.h" -#import "SVGUtils.h" -#import "SVGGradientElement.h" -#import "CGPathAdditions.h" - -#import "SVGTransformable.h" -#import "SVGSVGElement.h" -#import "SVGGradientLayer.h" - -@implementation SVGHelperUtilities - - -+(CGAffineTransform) transformRelativeIncludingViewportForTransformableOrViewportEstablishingElement:(SVGElement*) transformableOrSVGSVGElement -{ - NSAssert([transformableOrSVGSVGElement conformsToProtocol:@protocol(SVGTransformable)] || [transformableOrSVGSVGElement isKindOfClass:[SVGSVGElement class]], @"Illegal argument, sent a non-SVGTransformable, non-SVGSVGElement object to a method that requires an SVGTransformable (NB: Apple's Xcode is rubbish, it should have thrown a compiler error that you even tried to do this, but it often doesn't bother). Incoming instance = %@", transformableOrSVGSVGElement ); - - /** - Each time you hit a viewPortElement in the DOM Tree, you - have to insert an ADDITIONAL transform into the flow of: - - parent-transform -> child-transform - - has to become: - - parent-transform -> VIEWPORT-TRANSFORM -> child-transform - */ - - CGAffineTransform currentRelativeTransform; - CGAffineTransform optionalViewportTransform; - - /** - Current relative transform: for an incoming "SVGTransformable" it's .transform, for everything else its identity - */ - if( [transformableOrSVGSVGElement conformsToProtocol:@protocol(SVGTransformable)]) - { - currentRelativeTransform = ((SVGElement*)transformableOrSVGSVGElement).transform; - } - else - { - currentRelativeTransform = CGAffineTransformIdentity; - } - - /** - Optional relative transform: if incoming element establishes a viewport, do something clever; for everything else, use identity - */ - if( transformableOrSVGSVGElement.viewportElement == nil // if it's nil, it means THE OPPOSITE of what you'd expect - it means that it IS the viewport element - SVG Spec REQUIRES this - || transformableOrSVGSVGElement.viewportElement == transformableOrSVGSVGElement // ?? I don't understand: ?? if it's something other than itself, then: we simply don't need to worry about it ?? - ) - { - SVGSVGElement* svgSVGElement = (SVGSVGElement*) transformableOrSVGSVGElement; - - /** - Calculate the "implicit" viewport->viewbox transform (caused by the tag's possible "viewBox" attribute) - Also calculate the "implicit" realViewport -> svgDefaultViewport transform (caused by the user changing the external - size of the rendered SVG) - */ - SVGRect frameViewBox = svgSVGElement.viewBox; // the ACTUAL viewbox (may be Uninitalized if none specified in SVG file) - SVGRect frameActualViewport = svgSVGElement.viewport; // the ACTUAL viewport (dictated by the graphics engine; may be Uninitialized if the renderer has too little info to decide on a viewport at all!) - SVGRect frameRequestedViewport = svgSVGElement.requestedViewport; // the default viewport requested in the SVG source file (may be Uninitialized if no svg width or height params in original source file) - - if( ! SVGRectIsInitialized(frameActualViewport)) - { - /** We have NO VIEWPORT (renderer was presented too little info) - - Net effect: we MUST render everything at 1:1, and apply NO FURTHER TRANSFORMS - */ - optionalViewportTransform = CGAffineTransformIdentity; - } - else - { - CGAffineTransform transformRealViewportToSVGViewport; - CGAffineTransform transformSVGViewportToSVGViewBox; - - /** Transform part 1: from REAL viewport to EXPECTED viewport */ - SVGRect viewportForViewBoxToRelateTo; - if( SVGRectIsInitialized( frameRequestedViewport )) - { - viewportForViewBoxToRelateTo = frameRequestedViewport; - transformRealViewportToSVGViewport = CGAffineTransformMakeScale( frameActualViewport.width / frameRequestedViewport.width, frameActualViewport.height / frameRequestedViewport.height); - } - else - { - viewportForViewBoxToRelateTo = frameActualViewport; - transformRealViewportToSVGViewport = CGAffineTransformIdentity; - } - - /** Transform part 2: from EXPECTED viewport to internal viewBox */ - if( SVGRectIsInitialized( frameViewBox ) ) - { - CGAffineTransform translateToViewBox = CGAffineTransformMakeTranslation( -frameViewBox.x, -frameViewBox.y ); - CGAffineTransform scaleToViewBox = CGAffineTransformMakeScale( viewportForViewBoxToRelateTo.width / frameViewBox.width, viewportForViewBoxToRelateTo.height / frameViewBox.height); - - /** This is hard to find in the spec, but: if you have NO implementation of PreserveAspectRatio, you still need to - read the spec on PreserveAspectRatio - because it defines a default behaviour for files that DO NOT specify it, - which is different from the mathemetic default of co-ordinate systems. - - In short, you MUST implement "", even if you're not supporting that attribute. - */ - if( svgSVGElement.preserveAspectRatio.baseVal.meetOrSlice == SVG_MEETORSLICE_MEET ) // ALWAYS TRUE in current implementation - { - if( ABS( svgSVGElement.aspectRatioFromWidthPerHeight - svgSVGElement.aspectRatioFromViewBox) > 0.00001 ) - { - /** The aspect ratios for viewport and viewbox differ; Spec requires us to - insert an extra transform that causes aspect ratio for internal data to be - - ... MEET: == KEPT CONSTANT - - and to "aspect-scale to fit" (i.e. leaving letterboxes at topbottom / leftright as required) - - c.f.: http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute (read carefully) - */ - - double ratioOfRatios = svgSVGElement.aspectRatioFromWidthPerHeight / svgSVGElement.aspectRatioFromViewBox; - - SVGKitLogWarn(@"ratioOfRatios = %.2f", ratioOfRatios ); - SVGKitLogWarn(@"Experimental: auto-scaling viewbox transform to fulfil SVG spec's default MEET settings, because your SVG file has different aspect-ratios for viewBox and for svg.width,svg.height"); - - /** - For MEET, we have to SHRINK the viewbox's contents if they aren't as wide:high as the viewport: - */ - CGAffineTransform catRestoreAspectRatio; - if( ratioOfRatios > 1 ) { - catRestoreAspectRatio = CGAffineTransformMakeScale( 1.0 / ratioOfRatios, 1.0 ); - } else if (ratioOfRatios != 0) { - catRestoreAspectRatio = CGAffineTransformMakeScale( 1.0, 1.0 * ratioOfRatios ); - } else { - catRestoreAspectRatio = CGAffineTransformIdentity; - } - - double xTranslationRequired; - double yTranslationRequired; - if( ratioOfRatios > 1.0 ) // if we're going to have space to either side - { - switch( svgSVGElement.preserveAspectRatio.baseVal.align ) - { - case SVG_PRESERVEASPECTRATIO_XMINYMIN: - case SVG_PRESERVEASPECTRATIO_XMINYMID: - case SVG_PRESERVEASPECTRATIO_XMINYMAX: - { - xTranslationRequired = 0.0; - }break; - - case SVG_PRESERVEASPECTRATIO_XMIDYMIN: - case SVG_PRESERVEASPECTRATIO_XMIDYMID: - case SVG_PRESERVEASPECTRATIO_XMIDYMAX: - { - xTranslationRequired = ((ratioOfRatios-1.0)/2.0) * frameViewBox.width; - }break; - - case SVG_PRESERVEASPECTRATIO_XMAXYMIN: - case SVG_PRESERVEASPECTRATIO_XMAXYMID: - case SVG_PRESERVEASPECTRATIO_XMAXYMAX: - { - xTranslationRequired = ((ratioOfRatios-1.0) * frameViewBox.width); - }break; - - case SVG_PRESERVEASPECTRATIO_NONE: - case SVG_PRESERVEASPECTRATIO_UNKNOWN: - { - xTranslationRequired = 0; - }break; - } - } - else - xTranslationRequired = 0; - - if( ratioOfRatios < 1.0 ) // if we're going to have space above and below - { - switch( svgSVGElement.preserveAspectRatio.baseVal.align ) - { - case SVG_PRESERVEASPECTRATIO_XMINYMIN: - case SVG_PRESERVEASPECTRATIO_XMIDYMIN: - case SVG_PRESERVEASPECTRATIO_XMAXYMIN: - { - yTranslationRequired = 0.0; - }break; - - case SVG_PRESERVEASPECTRATIO_XMINYMID: - case SVG_PRESERVEASPECTRATIO_XMIDYMID: - case SVG_PRESERVEASPECTRATIO_XMAXYMID: - { - yTranslationRequired = ((1.0-ratioOfRatios)/2.0 * [svgSVGElement.height pixelsValue]); - }break; - - case SVG_PRESERVEASPECTRATIO_XMINYMAX: - case SVG_PRESERVEASPECTRATIO_XMIDYMAX: - case SVG_PRESERVEASPECTRATIO_XMAXYMAX: - { - yTranslationRequired = ((1.0-ratioOfRatios) * [svgSVGElement.height pixelsValue]); - }break; - - case SVG_PRESERVEASPECTRATIO_NONE: - case SVG_PRESERVEASPECTRATIO_UNKNOWN: - { - yTranslationRequired = 0.0; - }break; - } - } - else - yTranslationRequired = 0.0; - /** - For xMidYMid, we have to RE-CENTER the viewbox's contents if they aren't as wide:high as the viewport: - */ - CGAffineTransform catRecenterNewAspectRatio = CGAffineTransformMakeTranslation( xTranslationRequired, yTranslationRequired ); - - CGAffineTransform transformsThatHonourAspectRatioRequirements = CGAffineTransformConcat(catRecenterNewAspectRatio, catRestoreAspectRatio); - - scaleToViewBox = CGAffineTransformConcat( transformsThatHonourAspectRatioRequirements, scaleToViewBox ); - } - } - else - SVGKitLogWarn( @"Unsupported: preserveAspectRatio set to SLICE. Code to handle this doesn't exist yet."); - - transformSVGViewportToSVGViewBox = CGAffineTransformConcat( translateToViewBox, scaleToViewBox ); - } - else - transformSVGViewportToSVGViewBox = CGAffineTransformIdentity; - - optionalViewportTransform = CGAffineTransformConcat( transformRealViewportToSVGViewport, transformSVGViewportToSVGViewBox ); - } - } - else - { - optionalViewportTransform = CGAffineTransformIdentity; - } - - /** - TOTAL relative based on the local "transform" property and the viewport (if present) - */ - CGAffineTransform result = CGAffineTransformConcat( currentRelativeTransform, optionalViewportTransform); - - return result; -} - -/*! - Re-calculates the absolute transform on-demand by querying parent's absolute transform and appending self's relative transform. - - Can take ONLY TWO kinds of element: - - something that implements SVGTransformable (non-transformables shouldn't be performing transforms!) - - something that defines a new viewport co-ordinate system (i.e. the SVG tag itself; this is AN IMPLICIT TRANSFORMABLE!) - */ -+(CGAffineTransform) transformAbsoluteIncludingViewportForTransformableOrViewportEstablishingElement:(SVGElement*) transformableOrSVGSVGElement -{ - NSAssert([transformableOrSVGSVGElement conformsToProtocol:@protocol(SVGTransformable)] || [transformableOrSVGSVGElement isKindOfClass:[SVGSVGElement class]], @"Illegal argument, sent a non-SVGTransformable, non-SVGSVGElement object to a method that requires an SVGTransformable (NB: Apple's Xcode is rubbish, it should have thrown a compiler error that you even tried to do this, but it often doesn't bother). Incoming instance = %@", transformableOrSVGSVGElement ); - - CGAffineTransform parentAbsoluteTransform = CGAffineTransformIdentity; - - NSAssert( transformableOrSVGSVGElement.parentNode == nil || [transformableOrSVGSVGElement.parentNode isKindOfClass:[SVGElement class]], @"I don't know what to do when parent node is NOT an SVG element of some kind; presumably, this is when SVG root node gets embedded inside something else? The Spec IS UNCLEAR and doesn't clearly define ANYTHING here, and provides very few examples" ); - - /** - Parent Absolute transform: one of the following - - a. parent is an SVGTransformable (so recurse this method call to find it) - b. parent is a viewport-generating element (so recurse this method call to find it) - c. parent is nil (so treat it as Identity) - d. parent is something else (so do a while loop until we hit an a, b, or c above) - */ - SVGElement* parentSVGElement = transformableOrSVGSVGElement; - while( (parentSVGElement = (SVGElement*) parentSVGElement.parentNode) != nil ) - { - if( [parentSVGElement conformsToProtocol:@protocol(SVGTransformable)] ) - { - parentAbsoluteTransform = [self transformAbsoluteIncludingViewportForTransformableOrViewportEstablishingElement:parentSVGElement]; - break; - } - - if( [parentSVGElement isKindOfClass:[SVGSVGElement class]] ) - { - parentAbsoluteTransform = [self transformAbsoluteIncludingViewportForTransformableOrViewportEstablishingElement:parentSVGElement]; - break; - } - } - - /** - TOTAL absolute based on the parent transform with relative (and possible viewport) transforms - */ - CGAffineTransform result = CGAffineTransformConcat( [self transformRelativeIncludingViewportForTransformableOrViewportEstablishingElement:transformableOrSVGSVGElement], parentAbsoluteTransform ); - - //DEBUG: SVGKitLogWarn( @"[%@] self.transformAbsolute: returning: affine( (%2.2f %2.2f %2.2f %2.2f), (%2.2f %2.2f)", [self class], result.a, result.b, result.c, result.d, result.tx, result.ty); - - return result; -} - -+(void) configureCALayer:(CALayer*) layer usingElement:(SVGElement*) nonStylableElement -{ - layer.name = nonStylableElement.identifier; - [layer setValue:nonStylableElement.identifier forKey:kSVGElementIdentifier]; - -#if FORCE_RASTERIZE_LAYERS - if ([layer respondsToSelector:@selector(setShouldRasterize:)]) { - [layer performSelector:@selector(setShouldRasterize:) - withObject:[NSNumber numberWithBool:YES]]; - } - - /** If you're going to rasterize, Apple's code is dumb, and needs to be "told" if its using a Retina display */ - layer.contentsScale = [[UIScreen mainScreen] scale]; - layer.rasterizationScale = _shapeLayer.contentsScale; -#endif - - if( [nonStylableElement conformsToProtocol:@protocol(SVGStylable)]) - { - SVGElement* stylableElement = (SVGElement*) nonStylableElement; - - NSString* actualOpacity = [stylableElement cascadedValueForStylableProperty:@"opacity" inherit:NO]; - layer.opacity = actualOpacity.length > 0 ? [actualOpacity floatValue] : 1.0f; // svg's "opacity" defaults to 1! - - // Apply fill-rule on layer (only CAShapeLayer) - NSString *fillRule = [stylableElement cascadedValueForStylableProperty:@"fill-rule"]; - if([fillRule isEqualToString:@"evenodd"] && [layer isKindOfClass:[CAShapeLayer class]]){ - CAShapeLayer *shapeLayer = (CAShapeLayer *)layer; - shapeLayer.fillRule = @"even-odd"; - } - } -} - -+(CALayer *) newCALayerForPathBasedSVGElement:(SVGElement*) svgElement withPath:(CGPathRef) pathRelative -{ - CAShapeLayer* _shapeLayer = [CAShapeLayerWithHitTest layer]; - - [self configureCALayer:_shapeLayer usingElement:svgElement]; - - NSString* actualStroke = [svgElement cascadedValueForStylableProperty:@"stroke"]; - if (!actualStroke) - actualStroke = @"none"; - NSString* actualStrokeWidth = [svgElement cascadedValueForStylableProperty:@"stroke-width"]; - - CGFloat strokeWidth = 1.0; - - if (actualStrokeWidth) - { - SVGRect r = ((SVGSVGElement*) svgElement.viewportElement).viewport; - - strokeWidth = [[SVGLength svgLengthFromNSString:actualStrokeWidth] - pixelsValueWithDimension: hypot(r.width, r.height)]; - } - - /** transform our LOCAL path into ABSOLUTE space */ - CGAffineTransform transformAbsolute = [self transformAbsoluteIncludingViewportForTransformableOrViewportEstablishingElement:svgElement]; - - // calculate the rendered dimensions of the path - CGRect r = CGRectInset(CGPathGetBoundingBox(pathRelative), -strokeWidth/2., -strokeWidth/2.); - CGRect transformedPathBB = CGRectApplyAffineTransform(r, transformAbsolute); - - CGPathRef pathToPlaceInLayer = CGPathCreateCopyByTransformingPath(pathRelative, &transformAbsolute); - - /** find out the ABSOLUTE BOUNDING BOX of our transformed path */ - //DEBUG ONLY: CGRect unTransformedPathBB = CGPathGetBoundingBox( _pathRelative ); - -#if IMPROVE_PERFORMANCE_BY_WORKING_AROUND_APPLE_FRAME_ALIGNMENT_BUG - transformedPathBB = CGRectIntegral( transformedPathBB ); // ridiculous but improves performance of apple's code by up to 50% ! -#endif - - /** NB: when we set the _shapeLayer.frame, it has a *side effect* of moving the path itself - so, in order to prevent that, - because Apple didn't provide a BOOL to disable that "feature", we have to pre-shift the path forwards by the amount it - will be shifted backwards */ - CGPathRef finalPath = CGPathCreateByOffsettingPath( pathToPlaceInLayer, transformedPathBB.origin.x, transformedPathBB.origin.y ); - - /** Can't use this - iOS 5 only! path = CGPathCreateCopyByTransformingPath(path, transformFromSVGUnitsToScreenUnits ); */ - - _shapeLayer.path = finalPath; - CGPathRelease(finalPath); - - /** - NB: this line, by changing the FRAME of the layer, has the side effect of also changing the CGPATH's position in absolute - space! This is why we needed the "CGPathRef finalPath =" line a few lines above... - */ - _shapeLayer.frame = transformedPathBB; - - CGRect localRect = CGRectMake(0, 0, CGRectGetWidth(transformedPathBB), CGRectGetHeight(transformedPathBB)); - - //DEBUG ONLY: CGRect shapeLayerFrame = _shapeLayer.frame; - CAShapeLayer* strokeLayer = _shapeLayer; - CAShapeLayer* fillLayer = _shapeLayer; - - if( strokeWidth > 0 - && (! [@"none" isEqualToString:actualStroke]) ) - { - /* - We have to apply any scale-factor part of the affine transform to the stroke itself (this is bizarre and horrible, yes, but that's the spec for you!) - */ - CGSize fakeSize = CGSizeMake( strokeWidth, strokeWidth ); - fakeSize = CGSizeApplyAffineTransform( fakeSize, transformAbsolute ); - strokeLayer.lineWidth = hypot(fakeSize.width, fakeSize.height)/M_SQRT2; - - NSString* actualStrokeOpacity = [svgElement cascadedValueForStylableProperty:@"stroke-opacity"]; - strokeLayer.strokeColor = [self parseStrokeForElement:svgElement fromStroke:actualStroke andOpacity:actualStrokeOpacity]; - - /** - Stroke dash array - */ - NSString *dashArrayString = [svgElement cascadedValueForStylableProperty:@"stroke-dasharray"]; - if(dashArrayString != nil && ![dashArrayString isEqualToString:@""]) { - NSArray *dashArrayStringComponents = [dashArrayString componentsSeparatedByString:@" "]; - if( [dashArrayStringComponents count] < 2 ) - { // min 2 elements required, perhaps it's comma-separated: - dashArrayStringComponents = [dashArrayString componentsSeparatedByString:@","]; - } - if( [dashArrayStringComponents count] > 1 ) - { - BOOL valid = NO; - NSMutableArray *dashArray = [NSMutableArray array]; - for( NSString *n in dashArrayStringComponents ){ - [dashArray addObject:[NSNumber numberWithFloat:[n floatValue]]]; - if( !valid && [n floatValue] != 0 ){ - // avoid 'CGContextSetLineDash: invalid dash array: at least one element must be non-zero.' - valid = YES; - } - } - if( valid ){ - strokeLayer.lineDashPattern = dashArray; - } - } - } - - /** - Line joins + caps: butt / square / miter - */ - NSString* actualLineCap = [svgElement cascadedValueForStylableProperty:@"stroke-linecap"]; - NSString* actualLineJoin = [svgElement cascadedValueForStylableProperty:@"stroke-linejoin"]; - NSString* actualMiterLimit = [svgElement cascadedValueForStylableProperty:@"stroke-miterlimit"]; - if( actualLineCap.length > 0 ) - { - if( [actualLineCap isEqualToString:@"butt"] ) - strokeLayer.lineCap = kCALineCapButt; - else if( [actualLineCap isEqualToString:@"round"] ) - strokeLayer.lineCap = kCALineCapRound; - else if( [actualLineCap isEqualToString:@"square"] ) - strokeLayer.lineCap = kCALineCapSquare; - } - if( actualLineJoin.length > 0 ) - { - if( [actualLineJoin isEqualToString:@"miter"] ) - strokeLayer.lineJoin = kCALineJoinMiter; - else if( [actualLineJoin isEqualToString:@"round"] ) - strokeLayer.lineJoin = kCALineJoinRound; - else if( [actualLineJoin isEqualToString:@"bevel"] ) - strokeLayer.lineJoin = kCALineJoinBevel; - } - if( actualMiterLimit.length > 0 ) - { - strokeLayer.miterLimit = [actualMiterLimit floatValue]; - } - if ( [actualStroke hasPrefix:@"url"] ) - { - // need a new fill layer because the stroke layer is becoming a mask - fillLayer = [CAShapeLayerWithHitTest layer]; - fillLayer.frame = strokeLayer.frame; - fillLayer.opacity = strokeLayer.opacity; - fillLayer.path = strokeLayer.path; - - NSArray *strokeArgs = [actualStroke componentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceCharacterSet]; - NSString *strokeIdArg = strokeArgs.firstObject; - NSRange idKeyRange = NSMakeRange(5, strokeIdArg.length - 6); - NSString* strokeId = [strokeIdArg substringWithRange:idKeyRange]; - - // SVG spec: Vertical and horizontal lines don't have a boundingbox, since they are one-dimensional, even though the stroke-width makes it look like they should have a boundingbox with non-zero width and height. - CGRect boundingBox = strokeLayer.frame; - CGRect pathBoundingBox = CGPathGetPathBoundingBox(pathRelative); - if (!CGRectIsEmpty(pathBoundingBox)) { - // apply gradient - SVGGradientLayer *gradientLayer = [self getGradientLayerWithId:strokeId forElement:svgElement withRect:boundingBox transform:transformAbsolute]; - - if (gradientLayer) { - strokeLayer.frame = localRect; - - strokeLayer.fillColor = nil; - strokeLayer.strokeColor = [UIColor blackColor].CGColor; - - gradientLayer.mask = strokeLayer; - strokeLayer = (CAShapeLayer*) gradientLayer; - } else { - // no gradient, fallback - } - } else { - // no boundingBox, fallback - } - } - - } - else - { - if( [@"none" isEqualToString:actualStroke] ) - { - strokeLayer.strokeColor = nil; // This is how you tell Apple that the stroke is disabled; a strokewidth of 0 will NOT achieve this - strokeLayer.lineWidth = 0.0f; // MUST set this explicitly, or Apple assumes 1.0 - } - else - { - strokeLayer.lineWidth = 1.0f; // default value from SVG spec - } - } - - NSString* actualFill = [svgElement cascadedValueForStylableProperty:@"fill"]; - NSString* actualFillOpacity = [svgElement cascadedValueForStylableProperty:@"fill-opacity"]; - - if ( [actualFill hasPrefix:@"url"] ) - { - NSArray *fillArgs = [actualFill componentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceCharacterSet]; - NSString *fillIdArg = fillArgs.firstObject; - NSRange idKeyRange = NSMakeRange(5, fillIdArg.length - 6); - NSString* fillId = [fillIdArg substringWithRange:idKeyRange]; - - /** Replace the return layer with a special layer using the URL fill */ - /** fetch the fill layer by URL using the DOM */ - SVGGradientLayer *gradientLayer = [self getGradientLayerWithId:fillId forElement:svgElement withRect:fillLayer.frame - transform:transformAbsolute]; - if (gradientLayer) { - CAShapeLayer* maskLayer = [CAShapeLayer layer]; - maskLayer.frame = localRect; - maskLayer.path = fillLayer.path; - maskLayer.fillColor = [UIColor blackColor].CGColor; - maskLayer.strokeColor = nil; - gradientLayer.mask = maskLayer; - gradientLayer.frame = fillLayer.frame; - fillLayer = (CAShapeLayer* )gradientLayer; - } else { - // no gradient, fallback - } - } - else if( actualFill.length > 0 || actualFillOpacity.length > 0 ) - { - fillLayer.fillColor = [self parseFillForElement:svgElement fromFill:actualFill andOpacity:actualFillOpacity]; - } - CGPathRelease(pathToPlaceInLayer); - - NSString* actualOpacity = [svgElement cascadedValueForStylableProperty:@"opacity" inherit:NO]; - fillLayer.opacity = actualOpacity.length > 0 ? [actualOpacity floatValue] : 1; // unusually, the "opacity" attribute defaults to 1, not 0 - - if (strokeLayer == fillLayer) - { - return strokeLayer; - } - CALayer* combined = [CALayer layer]; - - combined.frame = strokeLayer.frame; - strokeLayer.frame = localRect; - if ([strokeLayer isKindOfClass:[CAShapeLayer class]]) - strokeLayer.fillColor = nil; - fillLayer.frame = localRect; - [combined addSublayer:fillLayer]; - [combined addSublayer:strokeLayer]; - return combined; -} - -+ (SVGGradientLayer*)getGradientLayerWithId:(NSString*)gradId - forElement:(SVGElement*)svgElement - withRect:(CGRect)r - transform:(CGAffineTransform)transform -{ - /** Replace the return layer with a special layer using the URL fill */ - /** fetch the fill layer by URL using the DOM */ - NSAssert( svgElement.rootOfCurrentDocumentFragment != nil, @"This SVG shape has a URL fill type; it needs to search for that URL (%@) inside its nearest-ancestor node, but the rootOfCurrentDocumentFragment reference was nil (suggests the parser failed, or the SVG file is corrupt)", gradId ); - - SVGGradientElement* svgGradient = (SVGGradientElement*) [svgElement.rootOfCurrentDocumentFragment getElementById:gradId]; - if (svgGradient == nil) { - // SVG spec allows referenced gradient not exist and will use fallback color - SVGKitLogWarn(@"This SVG shape has a URL fill (%@), but could not find an XML Node with that ID inside the DOM tree (suggests the parser failed, or the SVG file is corrupt)", gradId ); - } - - [svgGradient synthesizeProperties]; - - SVGGradientLayer *gradientLayer = [svgGradient newGradientLayerForObjectRect:r - viewportRect:svgElement.rootOfCurrentDocumentFragment.viewBox - transform:transform]; - - return gradientLayer; -} - -+(CGColorRef) parseFillForElement:(SVGElement *)svgElement -{ - NSString* actualFill = [svgElement cascadedValueForStylableProperty:@"fill"]; - NSString* actualFillOpacity = [svgElement cascadedValueForStylableProperty:@"fill-opacity"]; - return [self parseFillForElement:svgElement fromFill:actualFill andOpacity:actualFillOpacity]; -} - -+(CGColorRef) parseFillForElement:(SVGElement *)svgElement fromFill:(NSString *)actualFill andOpacity:(NSString *)actualFillOpacity -{ - return [self parsePaintColorForElement:svgElement paintColor:actualFill paintOpacity:actualFillOpacity defaultColor:@"white"]; -} - -+(CGColorRef) parseStrokeForElement:(SVGElement *)svgElement -{ - NSString* actualStroke = [svgElement cascadedValueForStylableProperty:@"stroke"]; - NSString* actualStrokeOpacity = [svgElement cascadedValueForStylableProperty:@"stroke-opacity"]; - return [self parseStrokeForElement:svgElement fromStroke:actualStroke andOpacity:actualStrokeOpacity]; -} - -+(CGColorRef) parseStrokeForElement:(SVGElement *)svgElement fromStroke:(NSString *)actualStroke andOpacity:(NSString *)actualStrokeOpacity -{ - return [self parsePaintColorForElement:svgElement paintColor:actualStroke paintOpacity:actualStrokeOpacity defaultColor:@"white"]; -} - -/** - Spec: https://www.w3.org/TR/SVG11/painting.html#SpecifyingPaint - `fill` or `stroke` allows paint color. This should actually be a interface. - `fill` default color is `black`, while `stroke` default color is `none` - */ -+(CGColorRef)parsePaintColorForElement:(SVGElement *)svgElement paintColor:(NSString *)paintColor paintOpacity:(NSString *)paintOpacity defaultColor:(NSString *)defaultColor { - CGColorRef colorRef = NULL; - if (!paintColor) { - paintColor = @"none"; - } - if ([paintColor isEqualToString:@"none"]) - { - return NULL; - } - // there may be a url before the actual color like `url(#grad) #0f0`, parse it - NSString *actualPaintColor; - NSString *actualPaintOpacity = paintOpacity; - NSArray *paintArgs = [paintColor componentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceCharacterSet]; - if ([paintColor hasPrefix:@"url"]) { - if (paintArgs.count > 1) { - actualPaintColor = paintArgs[1]; - } - } else { - actualPaintColor = paintColor; - } - if( actualPaintColor.length > 0 || actualPaintOpacity.length > 0 ) { - SVGColor paintColorSVGColor; - if (actualPaintColor.length > 0) { - if (![actualPaintColor isEqualToString:@"none"]) { - paintColorSVGColor = SVGColorFromString([actualPaintColor UTF8String]); // have to use the intermediate of an SVGColor so that we can over-ride the ALPHA component in next line - } else { - return NULL; - } - } else { - if (![defaultColor isEqualToString:@"none"]) { - paintColorSVGColor = SVGColorFromString([actualPaintColor UTF8String]); - } else { - return NULL; - } - } - - if( actualPaintOpacity.length > 0 ) - paintColorSVGColor.a = (uint8_t) ([actualPaintOpacity floatValue] * 0xFF); - - colorRef = CGColorWithSVGColor(paintColorSVGColor); - } - else - { - if (![defaultColor isEqualToString:@"none"]) { - colorRef = CGColorWithSVGColor(SVGColorFromString([defaultColor UTF8String])); - } else { - return NULL; - } - } - - UIColor *color = [UIColor colorWithCGColor:colorRef]; - if ([color isEqual:[UIColor colorWithRed:0 green:0 blue:0 alpha:1.0]]) { - return [UIColor whiteColor].CGColor; - } else if ([color isEqual:[UIColor colorWithRed:1 green:1 blue:1 alpha:1.0]]) { - return [UIColor blackColor].CGColor; - } else { - return colorRef; - } - - return colorRef; -} - -+(void) parsePreserveAspectRatioFor:(Element*) element -{ - element.preserveAspectRatio = [SVGAnimatedPreserveAspectRatio new]; // automatically sets defaults - - NSString* stringPreserveAspectRatio = [element getAttribute:@"preserveAspectRatio"]; - - if( stringPreserveAspectRatio.length > 0 ) - { - NSArray* aspectRatioCommands = [stringPreserveAspectRatio componentsSeparatedByString:@" "]; - - for( NSString* aspectRatioCommand in aspectRatioCommands ) - { - if( [aspectRatioCommand isEqualToString:@"meet"]) /** NB this is default anyway. Dont technically need to set it */ - element.preserveAspectRatio.baseVal.meetOrSlice = SVG_MEETORSLICE_MEET; - else if( [aspectRatioCommand isEqualToString:@"slice"]) - element.preserveAspectRatio.baseVal.meetOrSlice = SVG_MEETORSLICE_SLICE; - - else if( [aspectRatioCommand isEqualToString:@"xMinYMin"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMINYMIN; - else if( [aspectRatioCommand isEqualToString:@"xMinYMid"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMINYMID; - else if( [aspectRatioCommand isEqualToString:@"xMinYMax"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMINYMAX; - - else if( [aspectRatioCommand isEqualToString:@"xMidYMin"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMIDYMIN; - else if( [aspectRatioCommand isEqualToString:@"xMidYMid"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMIDYMID; - else if( [aspectRatioCommand isEqualToString:@"xMidYMax"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMIDYMAX; - - else if( [aspectRatioCommand isEqualToString:@"xMaxYMin"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMAXYMIN; - else if( [aspectRatioCommand isEqualToString:@"xMaxYMid"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMAXYMID; - else if( [aspectRatioCommand isEqualToString:@"xMaxYMax"]) - element.preserveAspectRatio.baseVal.align = SVG_PRESERVEASPECTRATIO_XMAXYMAX; - - else - { - SVGKitLogWarn(@"Found unexpected preserve-aspect-ratio command inside element's 'preserveAspectRatio' attribute. Command = '%@'", aspectRatioCommand ); - } - } - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGLength.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGLength.h deleted file mode 100644 index d8fab8fa7e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGLength.h +++ /dev/null @@ -1,79 +0,0 @@ -/*! - SVGLength.h - - http://www.w3.org/TR/SVG/types.html#InterfaceSVGLength - - // Length Unit Types - const unsigned short SVG_LENGTHTYPE_UNKNOWN = 0; - const unsigned short SVG_LENGTHTYPE_NUMBER = 1; - const unsigned short SVG_LENGTHTYPE_PERCENTAGE = 2; - const unsigned short SVG_LENGTHTYPE_EMS = 3; - const unsigned short SVG_LENGTHTYPE_EXS = 4; - const unsigned short SVG_LENGTHTYPE_PX = 5; - const unsigned short SVG_LENGTHTYPE_CM = 6; - const unsigned short SVG_LENGTHTYPE_MM = 7; - const unsigned short SVG_LENGTHTYPE_IN = 8; - const unsigned short SVG_LENGTHTYPE_PT = 9; - const unsigned short SVG_LENGTHTYPE_PC = 10; - - readonly attribute unsigned short unitType; - attribute float value setraises(DOMException); - attribute float valueInSpecifiedUnits setraises(DOMException); - attribute DOMString valueAsString setraises(DOMException); - - void newValueSpecifiedUnits(in unsigned short unitType, in float valueInSpecifiedUnits) raises(DOMException); - void convertToSpecifiedUnits(in unsigned short unitType) raises(DOMException); - }; - */ -#import - -typedef enum SVG_LENGTH_TYPE -{ - SVG_LENGTHTYPE_UNKNOWN = 0, - SVG_LENGTHTYPE_NUMBER = 1, - SVG_LENGTHTYPE_PERCENTAGE = 2, - SVG_LENGTHTYPE_EMS = 3, - SVG_LENGTHTYPE_EXS = 4, - SVG_LENGTHTYPE_PX = 5, - SVG_LENGTHTYPE_CM = 6, - SVG_LENGTHTYPE_MM = 7, - SVG_LENGTHTYPE_IN = 8, - SVG_LENGTHTYPE_PT = 9, - SVG_LENGTHTYPE_PC = 10 -} SVG_LENGTH_TYPE; - - -@interface SVGLength : NSObject - -@property(nonatomic,readonly) SVG_LENGTH_TYPE unitType; -@property(nonatomic) float value; -@property(nonatomic) float valueInSpecifiedUnits; -@property(nonatomic,strong) NSString* valueAsString; - --(void) newValueSpecifiedUnits:(SVG_LENGTH_TYPE) unitType valueInSpecifiedUnits:(float) valueInSpecifiedUnits; --(void) convertToSpecifiedUnits:(SVG_LENGTH_TYPE) unitType; - -#pragma mark - things outside the spec but needed to make it usable in Objective C - -+(SVGLength*) svgLengthZero; -+(SVGLength*) svgLengthFromNSString:(NSString*) s; - -/** returns this SVGLength as if it had been converted to pixels, using [self convertToSpecifiedUnits:SVG_LENGTHTYPE_PX] - */ --(float) pixelsValue; - -/** to calculate relative values pass in the appropriate viewport dimension (width, height, or diagonal measure) -*/ --(float) pixelsValueWithDimension:(float)dimension; - -/** to calculate relative gradient values pass in the appropriate viewport dimension (width, height) - * the different between this and `pixelsValueWithDimension` is that this one will treat number value which (0 <= value <= 1.0) as percent value and calculate the result. (used by gradient) - */ --(float) pixelsValueWithGradientDimension:(float)dimension; - -/** returns this SVGLength as if it had been converted to a raw number (USE pixelsValue instead, UNLESS you are dealing with something that you expect to be a percentage or - similar non-pixel value), using [self convertToSpecifiedUnits:SVG_LENGTHTYPE_NUMBER] - */ --(float) numberValue; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGLength.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGLength.m deleted file mode 100644 index cc336995a2..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGLength.m +++ /dev/null @@ -1,241 +0,0 @@ -#import "SVGLength.h" - -#import "CSSPrimitiveValue.h" -#import "CSSPrimitiveValue_ConfigurablePixelsPerInch.h" - -#import "SVGUtils.h" - -#include -#include - -@interface SVGLength() -@property(nonatomic,strong) CSSPrimitiveValue* internalCSSPrimitiveValue; -@end - -@implementation SVGLength - -@synthesize unitType; -@synthesize value; -@synthesize valueInSpecifiedUnits; -@synthesize valueAsString; -@synthesize internalCSSPrimitiveValue; - - -- (id)init -{ - NSAssert(FALSE, @"This class must not be init'd. Use the static hepler methods to instantiate it instead"); - return nil; -} - -- (id)initWithCSSPrimitiveValue:(CSSPrimitiveValue*) pv -{ - self = [super init]; - if (self) { - self.internalCSSPrimitiveValue = pv; - } - return self; -} - --(float)value -{ - return [self.internalCSSPrimitiveValue getFloatValue:self.internalCSSPrimitiveValue.primitiveType]; -} - --(SVG_LENGTH_TYPE)unitType -{ - switch( self.internalCSSPrimitiveValue.primitiveType ) - { - case CSS_CM: - return SVG_LENGTHTYPE_CM; - case CSS_EMS: - return SVG_LENGTHTYPE_EMS; - case CSS_EXS: - return SVG_LENGTHTYPE_EXS; - case CSS_IN: - return SVG_LENGTHTYPE_IN; - case CSS_MM: - return SVG_LENGTHTYPE_MM; - case CSS_PC: - return SVG_LENGTHTYPE_PC; - case CSS_PERCENTAGE: - return SVG_LENGTHTYPE_PERCENTAGE; - case CSS_PT: - return SVG_LENGTHTYPE_PT; - case CSS_PX: - return SVG_LENGTHTYPE_PX; - case CSS_NUMBER: - case CSS_DIMENSION: - return SVG_LENGTHTYPE_NUMBER; - default: - return SVG_LENGTHTYPE_UNKNOWN; - } -} - --(void) newValueSpecifiedUnits:(SVG_LENGTH_TYPE) unitType valueInSpecifiedUnits:(float) valueInSpecifiedUnits -{ - NSAssert(FALSE, @"Not supported yet"); -} - --(void) convertToSpecifiedUnits:(SVG_LENGTH_TYPE) unitType -{ - NSAssert(FALSE, @"Not supported yet"); -} - -/** Apple calls this method when the class is loaded; that's as good a time as any to calculate the device / screen's PPI */ -+(void)initialize -{ - cachedDevicePixelsPerInch = [self pixelsPerInchForCurrentDevice]; -} - -+(SVGLength*) svgLengthZero -{ - SVGLength* result = [[SVGLength alloc] initWithCSSPrimitiveValue:nil]; - - return result; -} - -static float cachedDevicePixelsPerInch; -+(SVGLength*) svgLengthFromNSString:(NSString*) s -{ - CSSPrimitiveValue* pv = [[CSSPrimitiveValue alloc] init]; - - pv.pixelsPerInch = cachedDevicePixelsPerInch; - pv.cssText = s; - - SVGLength* result = [[SVGLength alloc] initWithCSSPrimitiveValue:pv]; - - return result; -} - --(float) pixelsValue -{ - return [self.internalCSSPrimitiveValue getFloatValue:CSS_PX]; -} - --(float) pixelsValueWithDimension:(float)dimension -{ - if (self.internalCSSPrimitiveValue.primitiveType == CSS_PERCENTAGE) - return dimension * self.value / 100.0; - - return [self pixelsValue]; -} - --(float) pixelsValueWithGradientDimension:(float)dimension -{ - if (self.internalCSSPrimitiveValue.primitiveType == CSS_PERCENTAGE) { - return dimension * self.value / 100.0; - } else if (self.internalCSSPrimitiveValue.primitiveType == CSS_NUMBER) { - if (self.value >= 0 && self.value <= 1) { - return dimension * self.value; - } - } - - return [self pixelsValue]; -} - --(float) numberValue -{ - return [self.internalCSSPrimitiveValue getFloatValue:CSS_NUMBER]; -} - -#pragma mark - secret methods needed to provide an implementation on ObjectiveC - -+(float) pixelsPerInchForCurrentDevice -{ - /** Using this as reference: http://en.wikipedia.org/wiki/Retina_Display and https://www.theiphonewiki.com/wiki/Models - */ - - size_t size; - sysctlbyname("hw.machine", NULL, &size, NULL, 0); - char *machine = malloc(size); - sysctlbyname("hw.machine", machine, &size, NULL, 0); - NSString *platform = [NSString stringWithUTF8String:machine]; - free(machine); - - if( [platform hasPrefix:@"iPhone1"] - || [platform hasPrefix:@"iPhone2"] - || [platform hasPrefix:@"iPhone3"]) - return 163.0f; - - if( [platform hasPrefix:@"iPhone4"] - || [platform hasPrefix:@"iPhone5"] - || [platform hasPrefix:@"iPhone6"] - || [platform hasPrefix:@"iPhone7,2"] - || [platform hasPrefix:@"iPhone8,1"] - || [platform hasPrefix:@"iPhone8,4"] - || [platform hasPrefix:@"iPhone9,1"] - || [platform hasPrefix:@"iPhone9,3"]) { - return 326.0f; - } - - if ( [platform hasPrefix:@"iPhone7,1"] - || [platform hasPrefix:@"iPhone8,2"] - || [platform hasPrefix:@"iPhone9,2"] - || [platform hasPrefix:@"iPhone9,4"]) { - return 401.0f; - } - - if( [platform hasPrefix:@"iPhone"]) // catch-all for higher-end devices not yet existing - { - NSAssert(FALSE, @"Update your source code or disable assertions: you are using an iPhone that didn't exist when this code was written, we have no idea what the pixel count per inch is!"); - return 401.0f; - } - - if( [platform hasPrefix:@"iPod1"] - || [platform hasPrefix:@"iPod2"] - || [platform hasPrefix:@"iPod3"]) - return 163.0f; - - if( [platform hasPrefix:@"iPod4"] - || [platform hasPrefix:@"iPod5"] - || [platform hasPrefix:@"iPod7"]) - return 326.0f; - - if( [platform hasPrefix:@"iPod"]) // catch-all for higher-end devices not yet existing - { - NSAssert(FALSE, @"Update your source code or disable assertions: you are using an iPod that didn't exist when this code was written, we have no idea what the pixel count per inch is!"); - return 326.0f; - } - - if( [platform hasPrefix:@"iPad5,1"] - || [platform hasPrefix:@"iPad5,2"]) - return 326.0f; - - if( [platform hasPrefix:@"iPad1"] - || [platform hasPrefix:@"iPad2"]) - return 132.0f; - if( [platform hasPrefix:@"iPad3"] - || [platform hasPrefix:@"iPad4"] - || [platform hasPrefix:@"iPad5,3"] - || [platform hasPrefix:@"iPad5,4"] - || [platform hasPrefix:@"iPad6"] - || [platform hasPrefix:@"iPad7"] - || [platform hasPrefix:@"iPad8"]) - return 264.0f; - - if( [platform hasPrefix:@"iPad"]) // catch-all for higher-end devices not yet existing - { - NSAssert(FALSE, @"Update your source code or disable assertions: you are using an iPad that didn't exist when this code was written, we have no idea what the pixel count per inch is!"); - return 264.0f; - } - - if( [platform hasPrefix:@"iWatch1"]) - return 326.0f; - - if( [platform hasPrefix:@"iWatch"]) // catch-all for higher-end devices not yet existing - { - NSAssert(FALSE, @"Update your source code or disable assertions: you are using an iWatch that didn't exist when this code was written, we have no idea what the pixel count per inch is!"); - return 326.0f; - } - - if( [platform hasPrefix:@"x86_64"]) - { - SVGKitLogWarn(@"[%@] WARNING: you are running on the simulator; it's impossible for us to calculate centimeter/millimeter/inches units correctly", [self class]); - return 132.0f; // Simulator, running on desktop machine - } - - NSAssert(FALSE, @"Cannot determine the PPI values for current device; returning 0.0f - hopefully this will crash your code (you CANNOT run SVG's that use CM/IN/MM etc until you fix this)" ); - return 0.0f; // Bet you'll get a divide by zero here... -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGMatrix.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGMatrix.h deleted file mode 100644 index d53124ca37..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGMatrix.h +++ /dev/null @@ -1,51 +0,0 @@ -/*! - - http://www.w3.org/TR/SVG/coords.html#InterfaceSVGMatrix - - interface SVGMatrix { - - attribute float a setraises(DOMException); - attribute float b setraises(DOMException); - attribute float c setraises(DOMException); - attribute float d setraises(DOMException); - attribute float e setraises(DOMException); - attribute float f setraises(DOMException); - - SVGMatrix multiply(in SVGMatrix secondMatrix); - SVGMatrix inverse() raises(SVGException); - SVGMatrix translate(in float x, in float y); - SVGMatrix scale(in float scaleFactor); - SVGMatrix scaleNonUniform(in float scaleFactorX, in float scaleFactorY); - SVGMatrix rotate(in float angle); - SVGMatrix rotateFromVector(in float x, in float y) raises(SVGException); - SVGMatrix flipX(); - SVGMatrix flipY(); - SVGMatrix skewX(in float angle); - SVGMatrix skewY(in float angle); - }; - */ - -#import - -@interface SVGMatrix : NSObject - -@property(nonatomic) float a; -@property(nonatomic) float b; -@property(nonatomic) float c; -@property(nonatomic) float d; -@property(nonatomic) float e; -@property(nonatomic) float f; - --(SVGMatrix*) multiply:(SVGMatrix*) secondMatrix; --(SVGMatrix*) inverse; --(SVGMatrix*) translate:(float) x y:(float) y; --(SVGMatrix*) scale:(float) scaleFactor; --(SVGMatrix*) scaleNonUniform:(float) scaleFactorX scaleFactorY:(float) scaleFactorY; --(SVGMatrix*) rotate:(float) angle; --(SVGMatrix*) rotateFromVector:(float) x y:(float) y; --(SVGMatrix*) flipX; --(SVGMatrix*) flipY; --(SVGMatrix*) skewX:(float) angle; --(SVGMatrix*) skewY:(float) angle; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGMatrix.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGMatrix.m deleted file mode 100644 index 9b26de9f34..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGMatrix.m +++ /dev/null @@ -1,20 +0,0 @@ - -#import "SVGMatrix.h" - -@implementation SVGMatrix - -@synthesize a,b,c,d,e,f; - --(SVGMatrix*) multiply:(SVGMatrix*) secondMatrix { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) inverse { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) translate:(float) x y:(float) y { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) scale:(float) scaleFactor { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) scaleNonUniform:(float) scaleFactorX scaleFactorY:(float) scaleFactorY { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) rotate:(float) angle { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) rotateFromVector:(float) x y:(float) y { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) flipX { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) flipY { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) skewX:(float) angle { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) skewY:(float) angle { NSAssert( FALSE, @"Not implemented yet" ); return nil; } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGNumber.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGNumber.h deleted file mode 100644 index 6993a08a0e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGNumber.h +++ /dev/null @@ -1,12 +0,0 @@ -/*! - - http://www.w3.org/TR/SVG/types.html#InterfaceSVGNumber - - interface SVGNumber { - attribute float value setraises(DOMException); - }; - */ -typedef struct -{ - float value; -} SVGNumber; diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPoint.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPoint.h deleted file mode 100644 index 04ed0f5923..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPoint.h +++ /dev/null @@ -1,22 +0,0 @@ -/*! - http://www.w3.org/TR/SVG/coords.html#InterfaceSVGPoint - - interface SVGPoint { - - attribute float x setraises(DOMException); - attribute float y setraises(DOMException); - - SVGPoint matrixTransform(in SVGMatrix matrix); - }; - */ -#import - -#import "SVGMatrix.h" - -@interface SVGPoint : NSObject - -@property(nonatomic,readonly) float x, y; - --(SVGPoint*) matrixTransform:(SVGMatrix*) matrix; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPoint.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPoint.m deleted file mode 100644 index 87e1a48373..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPoint.m +++ /dev/null @@ -1,15 +0,0 @@ - -#import "SVGPoint.h" - -@implementation SVGPoint - -@synthesize x, y; - --(SVGPoint*) matrixTransform:(SVGMatrix*) matrix -{ - NSAssert( FALSE, @"Not implemented yet" ); - - return nil; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPreserveAspectRatio.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPreserveAspectRatio.h deleted file mode 100644 index c0331c7f96..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPreserveAspectRatio.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - http://www.w3.org/TR/SVG/coords.html#InterfaceSVGPreserveAspectRatio - - interface SVGPreserveAspectRatio { - - // Alignment Types - 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; - - // Meet-or-slice Types - SVG_MEETORSLICE_UNKNOWN = 0; - SVG_MEETORSLICE_MEET = 1; - SVG_MEETORSLICE_SLICE = 2; - - attribute unsigned short align setraises(DOMException); - attribute unsigned short meetOrSlice setraises(DOMException); - }; - */ -#import - -@interface SVGPreserveAspectRatio : NSObject - -typedef enum SVG_PRESERVEASPECTRATIO -{ - // Alignment Types - 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 -} SVG_PRESERVEASPECTRATIO; - -typedef enum SVG_MEETORSLICE -{ - // Meet-or-slice Types - SVG_MEETORSLICE_UNKNOWN = 0, - SVG_MEETORSLICE_MEET = 1, - SVG_MEETORSLICE_SLICE = 2 -} SVG_MEETORSLICE; - -@property(nonatomic) SVG_PRESERVEASPECTRATIO align; -@property(nonatomic) SVG_MEETORSLICE meetOrSlice; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPreserveAspectRatio.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPreserveAspectRatio.m deleted file mode 100644 index a650463a6d..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGPreserveAspectRatio.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "SVGPreserveAspectRatio.h" - -@implementation SVGPreserveAspectRatio - -/** Sets default values mandated by SVG Spec */ -- (id)init -{ - self = [super init]; - if (self) { - self.align = SVG_PRESERVEASPECTRATIO_XMIDYMID; - self.meetOrSlice = SVG_MEETORSLICE_MEET; - } - return self; -} -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGRect.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGRect.h deleted file mode 100644 index 2936e93dc0..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGRect.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - http://www.w3.org/TR/SVG/types.html#InterfaceSVGRect - - interface SVGRect { - attribute float x setraises(DOMException); - attribute float y setraises(DOMException); - attribute float width setraises(DOMException); - attribute float height setraises(DOMException); - }; - */ -#import - -#import - -typedef struct -{ - float x; - float y; - float width; - float height; -} SVGRect; - -#pragma mark - utility methods that are NOT in the SVG Spec, bu which we need to implement it in ObjectiveC - -/** C has no way of detecting if an SVGRect is deliberately 0 width (has special meaning in SVG), or accidentally (because it was - never initialized). - - Unfortunately, the SVG Spec authors defined "uninitialized" and "values of zero" to mean differnet things, so we MUST preserve - that difference! */ -SVGRect SVGRectUninitialized(void); - -/** c.f. note about SVGRectUninitialized() -- this method checks if a Rect is identical to the output of that method */ -BOOL SVGRectIsInitialized( SVGRect rect ); - -SVGRect SVGRectMake( float x, float y, float width, float height ); - -/** Convenience method to convert to ObjectiveC's kind of rect */ -CGRect CGRectFromSVGRect( SVGRect rect ); - -/** Convenience method to convert to ObjectiveC's kind of size - ONLY the width and height of this rect */ -CGSize CGSizeFromSVGRect( SVGRect rect ); - -NSString * _Nonnull NSStringFromSVGRect( SVGRect rect ); diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGRect.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGRect.m deleted file mode 100644 index 8a5c0b4aaf..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGRect.m +++ /dev/null @@ -1,43 +0,0 @@ -#import "SVGRect.h" - -#import -#import - -BOOL SVGRectIsInitialized( SVGRect rect ) -{ - return rect.x != -1 || rect.y != -1 || rect.width != -1 || rect.height != -1; -} - -SVGRect SVGRectUninitialized( void ) -{ - return SVGRectMake( -1, -1, -1, -1 ); -} - -SVGRect SVGRectMake( float x, float y, float width, float height ) -{ - SVGRect result = { x, y, width, height }; - return result; -} - -CGRect CGRectFromSVGRect( SVGRect rect ) -{ - CGRect result = CGRectMake(rect.x, rect.y, rect.width, rect.height); - - return result; -} - -CGSize CGSizeFromSVGRect( SVGRect rect ) -{ - CGSize result = CGSizeMake( rect.width, rect.height ); - - return result; -} - -NSString * NSStringFromSVGRect( SVGRect rect ) { - CGRect cgRect = CGRectFromSVGRect(rect); -#if SVGKIT_MAC - return NSStringFromRect(cgRect); -#else - return NSStringFromCGRect(cgRect); -#endif -} diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGSVGElement_Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGSVGElement_Mutable.h deleted file mode 100644 index 3587d13103..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGSVGElement_Mutable.h +++ /dev/null @@ -1,21 +0,0 @@ -#import "SVGSVGElement.h" - -@interface SVGSVGElement () - -@property (nonatomic, strong, readwrite) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* x; -@property (nonatomic, strong, readwrite) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* y; -@property (nonatomic, strong, readwrite) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* width; -@property (nonatomic, strong, readwrite) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* height; -@property (nonatomic, strong, readwrite) NSString* contentScriptType; -@property (nonatomic, strong, readwrite) NSString* contentStyleType; -@property (nonatomic, readwrite) SVGRect viewport; -@property (nonatomic, readwrite) float pixelUnitToMillimeterX; -@property (nonatomic, readwrite) float pixelUnitToMillimeterY; -@property (nonatomic, readwrite) float screenPixelToMillimeterX; -@property (nonatomic, readwrite) float screenPixelToMillimeterY; -@property (nonatomic, readwrite) BOOL useCurrentView; -@property (nonatomic, strong, readwrite) SVGViewSpec* currentView; -@property (nonatomic, readwrite) float currentScale; -@property (nonatomic, strong, readwrite) SVGPoint* currentTranslate; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGStylable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGStylable.h deleted file mode 100644 index 57fad595b0..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGStylable.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - http://www.w3.org/TR/SVG/types.html#InterfaceSVGStylable - - interface SVGStylable { - - readonly attribute SVGAnimatedString className; - readonly attribute CSSStyleDeclaration style; - - CSSValue getPresentationAttribute(in DOMString name); - */ -#import - -#import "CSSStyleDeclaration.h" -#import "CSSValue.h" - -@protocol SVGStylable - -@property(nonatomic,retain) /*FIXME: should be of type: SVGAnimatedString */ NSString* className; -@property(nonatomic,retain) CSSStyleDeclaration* style; - --(CSSValue*) getPresentationAttribute:(NSString*) name; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextContentElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextContentElement.h deleted file mode 100644 index 6db41275fb..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextContentElement.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - http://www.w3.org/TR/2011/REC-SVG11-20110816/text.html#InterfaceSVGTextContentElement - - interface SVGTextContentElement : SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable { - - // lengthAdjust Types - const unsigned short LENGTHADJUST_UNKNOWN = 0; - const unsigned short LENGTHADJUST_SPACING = 1; - const unsigned short LENGTHADJUST_SPACINGANDGLYPHS = 2; - - readonly attribute SVGAnimatedLength textLength; - readonly attribute SVGAnimatedEnumeration lengthAdjust; - - long getNumberOfChars(); - float getComputedTextLength(); - float getSubStringLength(in unsigned long charnum, in unsigned long nchars) raises(DOMException); - SVGPoint getStartPositionOfChar(in unsigned long charnum) raises(DOMException); - SVGPoint getEndPositionOfChar(in unsigned long charnum) raises(DOMException); - SVGRect getExtentOfChar(in unsigned long charnum) raises(DOMException); - float getRotationOfChar(in unsigned long charnum) raises(DOMException); - long getCharNumAtPosition(in SVGPoint point); - void selectSubString(in unsigned long charnum, in unsigned long nchars) raises(DOMException); - */ -#import "SVGElement.h" -#import "SVGStylable.h" -#import "SVGLength.h" - -typedef enum SVGLengthAdjust -{ - // lengthAdjust Types - SVGLengthAdjustUnknown = 0, - SVGLengthAdjustSpacing = 1, - SVGLengthAdjustSpacingAndGlyphs = 2 -} SVGLengthAdjust; - -@interface SVGTextContentElement : SVGElement - -@property(weak, nonatomic,readonly) SVGLength* /* FIXMED: should be SVGAnimatedLength*/ textLength; -/**FIXME: missing: readonly attribute SVGAnimatedEnumeration lengthAdjust;*/ - -/**FIXME: missing: - long getNumberOfChars(); - float getComputedTextLength(); - float getSubStringLength(in unsigned long charnum, in unsigned long nchars) raises(DOMException); - SVGPoint getStartPositionOfChar(in unsigned long charnum) raises(DOMException); - SVGPoint getEndPositionOfChar(in unsigned long charnum) raises(DOMException); - SVGRect getExtentOfChar(in unsigned long charnum) raises(DOMException); - float getRotationOfChar(in unsigned long charnum) raises(DOMException); - long getCharNumAtPosition(in SVGPoint point); - void selectSubString(in unsigned long charnum, in unsigned long nchars) raises(DOMException); - */ -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextContentElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextContentElement.m deleted file mode 100644 index 49f97fc921..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextContentElement.m +++ /dev/null @@ -1,7 +0,0 @@ -#import "SVGTextContentElement.h" - -@implementation SVGTextContentElement - -@synthesize textLength; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement.h deleted file mode 100644 index c7bf74c79d..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - http://www.w3.org/TR/2011/REC-SVG11-20110816/text.html#InterfaceSVGTextPositioningElement - - interface SVGTextPositioningElement : SVGTextContentElement { - readonly attribute SVGAnimatedLengthList x; - readonly attribute SVGAnimatedLengthList y; - readonly attribute SVGAnimatedLengthList dx; - readonly attribute SVGAnimatedLengthList dy; - readonly attribute SVGAnimatedNumberList rotate; - */ - -#import "SVGTextContentElement.h" -#import "SVGLength.h" - -@interface SVGTextPositioningElement : SVGTextContentElement - -@property(nonatomic,strong,readonly) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ x; -@property(nonatomic,strong,readonly) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ y; -@property(nonatomic,strong,readonly) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ dx; -@property(nonatomic,strong,readonly) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ dy; -@property(nonatomic,strong,readonly) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ rotate; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement.m deleted file mode 100644 index 92fc32dbbe..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement.m +++ /dev/null @@ -1,22 +0,0 @@ -#import "SVGTextPositioningElement.h" -#import "SVGTextPositioningElement_Mutable.h" - -#import "SVGElement_ForParser.h" // because we do post-processing of the SVG x,y,dx,dy,rotate attributes - -@implementation SVGTextPositioningElement - -@synthesize x,y,dx,dy,rotate; - - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult -{ - [super postProcessAttributesAddingErrorsTo:parseResult]; - - self.x = [self getAttributeAsSVGLength:@"x"]; - self.y = [self getAttributeAsSVGLength:@"y"]; - self.dx = [self getAttributeAsSVGLength:@"dx"]; - self.dy = [self getAttributeAsSVGLength:@"dy"]; - self.rotate = [self getAttributeAsSVGLength:@"rotate"]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement_Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement_Mutable.h deleted file mode 100644 index c50a15e986..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTextPositioningElement_Mutable.h +++ /dev/null @@ -1,9 +0,0 @@ -#import "SVGTextPositioningElement.h" - -@interface SVGTextPositioningElement () -@property(nonatomic,strong,readwrite) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ x; -@property(nonatomic,strong,readwrite) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ y; -@property(nonatomic,strong,readwrite) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ dx; -@property(nonatomic,strong,readwrite) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ dy; -@property(nonatomic,strong,readwrite) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ rotate; -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransform.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransform.h deleted file mode 100644 index d279a7f27f..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransform.h +++ /dev/null @@ -1,54 +0,0 @@ -/*! - http://www.w3.org/TR/SVG/coords.html#InterfaceSVGTransform - - // Transform Types - const unsigned short SVG_TRANSFORM_UNKNOWN = 0; - const unsigned short SVG_TRANSFORM_MATRIX = 1; - const unsigned short SVG_TRANSFORM_TRANSLATE = 2; - const unsigned short SVG_TRANSFORM_SCALE = 3; - const unsigned short SVG_TRANSFORM_ROTATE = 4; - const unsigned short SVG_TRANSFORM_SKEWX = 5; - const unsigned short SVG_TRANSFORM_SKEWY = 6; - - readonly attribute unsigned short type; - readonly attribute SVGMatrix matrix; - readonly attribute float angle; - - void setMatrix(in SVGMatrix matrix) raises(DOMException); - void setTranslate(in float tx, in float ty) raises(DOMException); - void setScale(in float sx, in float sy) raises(DOMException); - void setRotate(in float angle, in float cx, in float cy) raises(DOMException); - void setSkewX(in float angle) raises(DOMException); - void setSkewY(in float angle) raises(DOMException); -*/ - -#import - -#import "SVGMatrix.h" - -@interface SVGTransform : NSObject - -/*! Transform Types */ -typedef enum SVGKTransformType -{ - SVG_TRANSFORM_UNKNOWN = 0, - SVG_TRANSFORM_MATRIX = 1, - SVG_TRANSFORM_TRANSLATE = 2, - SVG_TRANSFORM_SCALE = 3, - SVG_TRANSFORM_ROTATE = 4, - SVG_TRANSFORM_SKEWX = 5, - SVG_TRANSFORM_SKEWY = 6 -} SVGKTransformType; - -@property(nonatomic) SVGKTransformType type; -@property(nonatomic,strong) SVGMatrix* matrix; -@property(nonatomic,readonly) float angle; - --(void) setMatrix:(SVGMatrix*) matrix; --(void) setTranslate:(float) tx ty:(float) ty; --(void) setScale:(float) sx sy:(float) sy; --(void) setRotate:(float) angle cx:(float) cx cy:(float) cy; --(void) setSkewX:(float) angle; --(void) setSkewY:(float) angle; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransform.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransform.m deleted file mode 100644 index fb361aee9b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransform.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "SVGTransform.h" - -@implementation SVGTransform - -@synthesize type; -@synthesize matrix; -@synthesize angle; - - --(void) setMatrix:(SVGMatrix*) matrix { NSAssert( FALSE, @"Not implemented yet" ); } --(void) setTranslate:(float) tx ty:(float) ty { NSAssert( FALSE, @"Not implemented yet" ); } --(void) setScale:(float) sx sy:(float) sy { NSAssert( FALSE, @"Not implemented yet" ); } --(void) setRotate:(float) angle cx:(float) cx cy:(float) cy { NSAssert( FALSE, @"Not implemented yet" ); } --(void) setSkewX:(float) angle { NSAssert( FALSE, @"Not implemented yet" ); } --(void) setSkewY:(float) angle { NSAssert( FALSE, @"Not implemented yet" ); } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransformable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransformable.h deleted file mode 100644 index fe4c09f344..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGTransformable.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * http://www.w3.org/TR/SVG/types.html#InterfaceSVGTransformable - - interface SVGTransformable : SVGLocatable { - readonly attribute SVGAnimatedTransformList transform; - - */ - -#import -#import - -@protocol SVGTransformable - -@property(nonatomic) CGAffineTransform transform; // FIXME: TODO: this should be a different type - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUnitTypes.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUnitTypes.h deleted file mode 100644 index d5bb2d2ca2..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUnitTypes.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// SVGUnitTypes.h -// SVGKit-iOS -// -// Created by David Gileadi on 8/14/14. -// Copyright (c) 2014 na. All rights reserved. -// - -#ifndef SVGKit_iOS_SVGUnitTypes_h -#define SVGKit_iOS_SVGUnitTypes_h - -typedef enum SVG_UNIT_TYPE -{ - // Unit Types - SVG_UNIT_TYPE_UNKNOWN = 0, - SVG_UNIT_TYPE_USERSPACEONUSE = 1, - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2 -} SVG_UNIT_TYPE; - -#endif diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement.h deleted file mode 100644 index fa6f352f9b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - http://www.w3.org/TR/SVG/struct.html#InterfaceSVGUseElement - - interface SVGUseElement : SVGElement, - SVGURIReference, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable { - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - readonly attribute SVGElementInstance instanceRoot; - readonly attribute SVGElementInstance animatedInstanceRoot; - }; - - */ -#import "SVGLength.h" -#import "SVGElement.h" - -@class SVGElementInstance; -#import "SVGElementInstance.h" - -#import "ConverterSVGToCALayer.h" -#import "SVGTransformable.h" - -@interface SVGUseElement : SVGElement < SVGTransformable /*FIXME: delete this rubbish:*/, ConverterSVGToCALayer> - -@property(nonatomic, strong, readonly) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* x; -@property(nonatomic, strong, readonly) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* y; -@property(nonatomic, strong, readonly) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* width; -@property(nonatomic, strong, readonly) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* height; -@property(nonatomic, strong, readonly) SVGElementInstance* instanceRoot; -@property(nonatomic, strong, readonly) SVGElementInstance* animatedInstanceRoot; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement.m deleted file mode 100644 index 3e3fc95376..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement.m +++ /dev/null @@ -1,27 +0,0 @@ -#import "SVGUseElement.h" -#import "SVGUseElement_Mutable.h" - -@implementation SVGUseElement - -@synthesize x; -@synthesize y; -@synthesize width; -@synthesize height; -@synthesize instanceRoot; -@synthesize animatedInstanceRoot; - -@synthesize transform; // each SVGElement subclass that conforms to protocol "SVGTransformable" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols - - --(CALayer *)newLayer -{ - return [CALayer layer]; -} - --(void)layoutLayer:(CALayer *)layer -{ - if( [instanceRoot.correspondingElement respondsToSelector:@selector(layoutLayer:)]) - [((SVGElement*)instanceRoot.correspondingElement) layoutLayer:layer]; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement_Mutable.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement_Mutable.h deleted file mode 100644 index 9b178d7b2b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGUseElement_Mutable.h +++ /dev/null @@ -1,11 +0,0 @@ -#import "SVGUseElement.h" - -@interface SVGUseElement () -@property(nonatomic, strong, readwrite) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* x; -@property(nonatomic, strong, readwrite) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* y; -@property(nonatomic, strong, readwrite) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* width; -@property(nonatomic, strong, readwrite) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* height; -@property(nonatomic, strong, readwrite) SVGElementInstance* instanceRoot; -@property(nonatomic, strong, readwrite) SVGElementInstance* animatedInstanceRoot; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGViewSpec.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGViewSpec.h deleted file mode 100644 index 4e81af3e82..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/SVG-DOM/SVGViewSpec.h +++ /dev/null @@ -1,28 +0,0 @@ -/*! - SVGViewSpec - - interface SVGViewSpec : SVGZoomAndPan, - SVGFitToViewBox { - readonly attribute SVGTransformList transform; - readonly attribute SVGElement viewTarget; - readonly attribute DOMString viewBoxString; - readonly attribute DOMString preserveAspectRatioString; - readonly attribute DOMString transformString; - readonly attribute DOMString viewTargetString; - }; - */ -#import - -@class SVGElement; -#import "SVGElement.h" - -@interface SVGViewSpec : NSObject - -/* FIXME: SVGTransformList not implemented yet: @property(nonatomic,readonly) SVGTransformList transform; */ -@property(nonatomic,readonly) SVGElement* viewTarget; -@property(nonatomic,readonly) NSString* viewBoxString; -@property(nonatomic,readonly) NSString* preserveAspectRatioString; -@property(nonatomic,readonly) NSString* transformString; -@property(nonatomic,readonly) NSString* viewTargetString; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes.h deleted file mode 100644 index 1c94f9a437..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - This class is FOR IMPLEMENTATION ONLY, it is NOT part of the SVG Spec. - - All the SVG Basic Shapes are rendered in ObjectiveC using the same CGPath primitive - so this class provides - a clean, OOP, way of implementing that. - - Sub-classes MUST write to the "pathForShapeInRelativeCoords" property, and this superclass will automatically generate - the required CALayer on the fly, using that CGPath - */ - -#import "SVGElement.h" -#import "ConverterSVGToCALayer.h" -#import "SVGUtils.h" -#import "SVGTransformable.h" - -@class SVGGradientElement; -@class SVGKPattern; - -@interface BaseClassForAllSVGBasicShapes : SVGElement < SVGStylable, SVGTransformable, ConverterSVGToCALayer > -{ - /* FIXME: are any of these private elements in the SVG spec? */ - NSString *_styleClass; - CGRect _layerRect; -} - -/** The actual path as parsed from the original file. THIS MIGHT NOT BE NORMALISED (TODO: perhaps an extra feature?) */ -@property (nonatomic, readonly) CGPathRef pathForShapeInRelativeCoords; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes.m deleted file mode 100644 index 8fb8c3e4fd..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes.m +++ /dev/null @@ -1,53 +0,0 @@ -#import "BaseClassForAllSVGBasicShapes.h" -#import "BaseClassForAllSVGBasicShapes_ForSubclasses.h" - -#import "CGPathAdditions.h" -#import "SVGDefsElement.h" -#import "SVGKPattern.h" -#import "CAShapeLayerWithHitTest.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - -#import "SVGHelperUtilities.h" - -@implementation BaseClassForAllSVGBasicShapes - -@synthesize pathForShapeInRelativeCoords = _pathForShapeInRelativeCoords; - -@synthesize transform; // each SVGElement subclass that conforms to protocol "SVGTransformable" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols - -- (id)init -{ - self = [super init]; - if (self) { - self.pathForShapeInRelativeCoords = NULL; - } - return self; -} - - -- (void)dealloc { - CGPathRelease(_pathForShapeInRelativeCoords); - -} - --(void)setPathForShapeInRelativeCoords:(CGPathRef)pathForShapeInRelativeCoords -{ - if( pathForShapeInRelativeCoords == _pathForShapeInRelativeCoords ) - return; - - CGPathRelease( _pathForShapeInRelativeCoords ); // Apple says NULL is fine as argument - _pathForShapeInRelativeCoords = pathForShapeInRelativeCoords; - CGPathRetain( _pathForShapeInRelativeCoords ); -} - -- (CALayer *) newLayer -{ - NSAssert(self.pathForShapeInRelativeCoords != NULL, @"Requested a CALayer for SVG shape that never initialized its own .pathForShapeInRelativeCoords property. Shape class = %@. Shape instance = %@", [self class], self ); - - return [SVGHelperUtilities newCALayerForPathBasedSVGElement:self withPath:self.pathForShapeInRelativeCoords]; -} - -- (void)layoutLayer:(CALayer *)layer { } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes_ForSubclasses.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes_ForSubclasses.h deleted file mode 100644 index 8576ef7fe6..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/BaseClassForAllSVGBasicShapes_ForSubclasses.h +++ /dev/null @@ -1,7 +0,0 @@ -/** - Class extension that makes the internal properties readWRITE for subclasses to write to - */ - -@interface BaseClassForAllSVGBasicShapes () -@property (nonatomic, readwrite) CGPathRef pathForShapeInRelativeCoords; -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/ConverterSVGToCALayer.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/ConverterSVGToCALayer.h deleted file mode 100644 index 910eb0d3cb..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/ConverterSVGToCALayer.h +++ /dev/null @@ -1,15 +0,0 @@ -#import -#import - -@protocol ConverterSVGToCALayer < NSObject > - -/*! - NB: the returned layer has - as its "name" property - the "identifier" property of the SVGElement that created it; - but that can be overwritten by applications (for valid reasons), so we ADDITIONALLY store the identifier into a - custom key - kSVGElementIdentifier - on the CALayer. Because it's a custom key, it's (almost) guaranteed not to be - overwritten / altered by other application code - */ -- (CALayer *) newLayer; -- (void)layoutLayer:(CALayer *)layer; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGCircleElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGCircleElement.h deleted file mode 100644 index 5f3c72ef18..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGCircleElement.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// SVGCircleElement.h -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGEllipseElement.h" - -@interface SVGCircleElement : SVGEllipseElement { } - -@property (nonatomic, readonly) CGFloat r; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGCircleElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGCircleElement.m deleted file mode 100644 index 855c5613eb..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGCircleElement.m +++ /dev/null @@ -1,23 +0,0 @@ -// -// SVGCircleElement.m -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGCircleElement.h" - -@implementation SVGCircleElement - -@dynamic r; - -- (CGFloat)r { - if (self.rx != self.ry) { - SVGKitLogVerbose(@"Undefined radius of circle"); - return 0.0f; - } - - return self.rx; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGDescriptionElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGDescriptionElement.h deleted file mode 100644 index ef8db80e3f..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGDescriptionElement.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// SVGDescriptionElement.h -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGElement.h" - -@interface SVGDescriptionElement : SVGElement { } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGDescriptionElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGDescriptionElement.m deleted file mode 100644 index ea253272f8..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGDescriptionElement.m +++ /dev/null @@ -1,16 +0,0 @@ -// -// SVGDescriptionElement.m -// SVGKit -// -// Copyright Matt Rajca 2010. All rights reserved. -// - -#import "SVGDescriptionElement.h" - -@implementation SVGDescriptionElement - -+ (BOOL)shouldStoreContent { - return YES; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement.h deleted file mode 100644 index be92fe776c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - SVGElement - - http://www.w3.org/TR/SVG/types.html#InterfaceSVGElement - - NB: "id" is illegal in Objective-C language, so we use "identifier" instead - */ -#import - -#import "Element.h" -#import "Node+Mutable.h" -#import "SVGStylable.h" -#import "SVGLength.h" - -#define DEBUG_SVG_ELEMENT_PARSING 0 - -@class SVGSVGElement; -//obj-c's compiler sucks, and doesn't allow this line: #import "SVGSVGElement.h" - -@interface SVGElement : Element - -@property (nonatomic, readwrite, strong) NSString *identifier; // 'id' is reserved in Obj-C, so we have to break SVG Spec here, slightly -@property (nonatomic, strong) NSString* xmlbase; -/*! - - http://www.w3.org/TR/SVG/intro.html#TermSVGDocumentFragment - - SVG document fragment - The XML document sub-tree which starts with an ‘svg’ element. An SVG document fragment can consist of a stand-alone SVG document, or a fragment of a parent XML document enclosed by an ‘svg’ element. When an ‘svg’ element is a descendant of another ‘svg’ element, there are two SVG document fragments, one for each ‘svg’ element. (One SVG document fragment is contained within another SVG document fragment.) - */ -@property (nonatomic, weak) SVGSVGElement* rootOfCurrentDocumentFragment; - -/*! The viewport is set / re-set whenever an SVG node specifies a "width" (and optionally: a "height") attribute, - assuming that SVG node is one of: svg, symbol, image, foreignobject - - The spec isn't clear what happens if this element redefines the viewport itself, but IMHO it implies that the - viewportElement becomes a reference to "self" */ -@property (nonatomic, weak) SVGElement* viewportElement; - - -#pragma mark - NON-STANDARD features of class (these are things that are NOT in the SVG spec, and should NOT be in SVGKit's implementation - they should be moved to a different class, although WE DO STILL NEED THESE in order to implement the spec, and to provide SVGKit features!) - -/*! This is used when generating CALayer objects, to store the id of the SVGElement that created the CALayer */ -#define kSVGElementIdentifier @"SVGElementIdentifier" - - -#pragma mark - SVG-spec supporting methods that aren't in the Spec itself - -- (id)initWithLocalName:(NSString*) n attributes:(NSMutableDictionary*) attributes; -- (id)initWithQualifiedName:(NSString*) n inNameSpaceURI:(NSString*) nsURI attributes:(NSMutableDictionary*) attributes; - --(void) reCalculateAndSetViewportElementReferenceUsingFirstSVGAncestor:(SVGElement*) firstAncestor; - -/** - Convenience method for reading an attribute (SVG defines all as strings), converting it into an SVGLength object - */ --(SVGLength*) getAttributeAsSVGLength:(NSString*) attributeName; - -#pragma mark - CSS cascading special attributes. c.f. full list here: http://www.w3.org/TR/SVG/propidx.html - --(NSString*) cascadedValueForStylableProperty:(NSString*) stylableProperty; --(NSString*) cascadedValueForStylableProperty:(NSString*) stylableProperty inherit:(BOOL)inherit; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement.m deleted file mode 100644 index 2b22c54cbd..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement.m +++ /dev/null @@ -1,655 +0,0 @@ -// -// SVGElement.m -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGElement.h" - -#import "SVGElement_ForParser.h" //.h" // to solve insane Xcode circular dependencies -#import "StyleSheetList+Mutable.h" - -#import "CSSStyleSheet.h" -#import "CSSStyleRule.h" -#import "CSSRuleList+Mutable.h" - -#import "SVGGElement.h" - -#import "SVGRect.h" - -#import "SVGTransformable.h" - -@interface SVGElement () - -@property (nonatomic, copy) NSString *stringValue; - -@end - -/*! main class implementation for the base SVGElement: NOTE: in practice, most of the interesting - stuff happens in subclasses, e.g.: - - SVGShapeElement - SVGGroupElement - SVGKImageElement - SVGLineElement - SVGPathElement - ...etc - */ -@implementation SVGElement - -@synthesize identifier = _identifier; -@synthesize xmlbase; -@synthesize rootOfCurrentDocumentFragment = _rootOfCurrentDocumentFragment; -@synthesize viewportElement = _viewportElement; -@synthesize stringValue = _stringValue; - -@synthesize className; /**< CSS class, from SVGStylable interface */ -@synthesize style; /**< CSS style, from SVGStylable interface */ - -/** from SVGStylable interface */ --(CSSValue*) getPresentationAttribute:(NSString*) name -{ - NSAssert(FALSE, @"getPresentationAttribute: not implemented yet"); - return nil; -} - - -+ (BOOL)shouldStoreContent { - return NO; -} - -/*! As per the SVG Spec, the local reference to "viewportElement" depends on the values of the - attributes of the node - does it have a "width" attribute? - - NB: by definition, tags MAY NOT have a width, but they are still viewports */ --(void) reCalculateAndSetViewportElementReferenceUsingFirstSVGAncestor:(SVGElement*) firstAncestor -{ - // NB the root svg element IS a viewport, but SVG Spec defines it as NOT a viewport, and so we will overwrite this later - BOOL isTagAllowedToBeAViewport = [self.tagName isEqualToString:@"svg"] || [self.tagName isEqualToString:@"foreignObject"]; // NB: Spec lists "image" tag too but only as an IMPLICIT CREATOR - we don't actually handle it (it creates an tag ... that will be handled later) - - BOOL isTagDefiningAViewport = [self.attributes getNamedItem:@"width"] != nil || [self.attributes getNamedItem:@"height"] != nil; - - if( isTagAllowedToBeAViewport && isTagDefiningAViewport ) - { - SVGKitLogVerbose(@"[%@] WARNING: setting self (tag = %@) to be a viewport", [self class], self.tagName ); - self.viewportElement = self; - } - else - { - SVGElement* ancestorsViewport = firstAncestor.viewportElement; - - if( ancestorsViewport == nil ) - { - /** - Because of the poorly-designed SVG Spec on Viewports, all the children of the root - SVG node will find that their ancestor has a nil viewport! (this is defined in the spec) - - So, in that special case, we INSTEAD guess that the ancestor itself was the viewport... - */ - self.viewportElement = firstAncestor; - } - else - self.viewportElement = ancestorsViewport; - } -} - -/*! Override so that we can automatically set / unset the ownerSVGElement and viewportElement properties, - as required by SVG Spec */ --(void)setParentNode:(Node *)newParent -{ - [super setParentNode:newParent]; - - /** SVG Spec: if "outermost SVG tag" then both element refs should be nil */ - if( [self isKindOfClass:[SVGSVGElement class]] - && (self.parentNode == nil || ! [self.parentNode isKindOfClass:[SVGElement class]]) ) - { - self.rootOfCurrentDocumentFragment = nil; - self.viewportElement = nil; - } - else - { - /** - SVG Spec: we have to set a reference to the "root SVG tag of this part of the tree". - - If the tree is purely SVGElement nodes / subclasses, that's easy. - - But if there are custom nodes in there (any other DOM node, for instance), it gets - more tricky. We have to recurse up the tree until we find an SVGElement we can latch - onto - */ - - if( [self isKindOfClass:[SVGSVGElement class]] ) - { - self.rootOfCurrentDocumentFragment = (SVGSVGElement*) self; - self.viewportElement = self; - } - else - { - Node* currentAncestor = newParent; - SVGElement* firstAncestorThatIsAnyKindOfSVGElement = nil; - while( firstAncestorThatIsAnyKindOfSVGElement == nil - && currentAncestor != nil ) // if we run out of tree! This would be an error (see below) - { - if( [currentAncestor isKindOfClass:[SVGElement class]] ) - firstAncestorThatIsAnyKindOfSVGElement = (SVGElement*) currentAncestor; - else - currentAncestor = currentAncestor.parentNode; - } - - if( newParent == nil ) - { - /** We've set the parent to nil, thereby "orphaning" this Node and the tree underneath it. - - This usually happens when you remove a Node from its parent. - - I'm not sure what the spec expects at that point - you have a valid DOM tree, but *not* a valid SVG fragment; - or maybe it is valid, for some special-case kind of SVG fragment definition? - - TODO: this may also relate to SVG nodes and instancing: if you're fixing that code, check this comment to see if you can improve it. - - For now: we simply "do nothing but set everything to nil" - */ - SVGKitLogWarn( @"SVGElement has had its parent set to nil; this makes the element and tree beneath it no-longer-valid SVG data; this may require fix-up if you try to re-add that SVGElement or any of its children back to an existing/new SVG tree"); - self.rootOfCurrentDocumentFragment = nil; - } - else - { - NSAssert( firstAncestorThatIsAnyKindOfSVGElement != nil, @"This node has no valid SVG tags as ancestor, but it's not an tag, so this is an impossible SVG file" ); - - - if( [firstAncestorThatIsAnyKindOfSVGElement isKindOfClass:[SVGSVGElement class]] ) - self.rootOfCurrentDocumentFragment = (SVGSVGElement*) firstAncestorThatIsAnyKindOfSVGElement; - else - self.rootOfCurrentDocumentFragment = firstAncestorThatIsAnyKindOfSVGElement.rootOfCurrentDocumentFragment; - - [self reCalculateAndSetViewportElementReferenceUsingFirstSVGAncestor:firstAncestorThatIsAnyKindOfSVGElement]; - -#if DEBUG_SVG_ELEMENT_PARSING - SVGKitLogVerbose(@"viewport Element = %@ ... for node/element = %@", self.viewportElement, self.tagName); -#endif - } - } - } -} - -- (void)setRootOfCurrentDocumentFragment:(SVGSVGElement *)root { - _rootOfCurrentDocumentFragment = root; - for (Node *child in self.childNodes) - if ([child isKindOfClass:SVGElement.class]) - ((SVGElement *) child).rootOfCurrentDocumentFragment = root; -} - -- (void)setViewportElement:(SVGElement *)viewport { - _viewportElement = viewport; - for (Node *child in self.childNodes) - if ([child isKindOfClass:SVGElement.class]) - ((SVGElement *) child).viewportElement = viewport; -} - - -- (void)loadDefaults { - // to be overriden by subclasses -} - --(SVGLength*) getAttributeAsSVGLength:(NSString*) attributeName -{ - NSString* attributeAsString = [self getAttribute:attributeName]; - SVGLength* svgLength = [SVGLength svgLengthFromNSString:attributeAsString]; - - return svgLength; -} - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - // to be overriden by subclasses - // make sure super implementation is called - - if( [[self getAttribute:@"id"] length] > 0 ) - self.identifier = [self getAttribute:@"id"]; - - /** CSS styles and classes */ - if ( [self getAttributeNode:@"style"] ) - { - self.style = [[CSSStyleDeclaration alloc] init]; - self.style.cssText = [self getAttribute:@"style"]; // causes all the LOCALLY EMBEDDED style info to be parsed - } - if( [self getAttributeNode:@"class"]) - { - self.className = [self getAttribute:@"class"]; - } - - - /** - http://www.w3.org/TR/SVG/coords.html#TransformAttribute - - The available types of transform definitions include: - - * matrix( ), which specifies a transformation in the form of a transformation matrix of six values. matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix [a b c d e f]. - - * translate( []), which specifies a translation by tx and ty. If is not provided, it is assumed to be zero. - - * scale( []), which specifies a scale operation by sx and sy. If is not provided, it is assumed to be equal to . - - * rotate( [ ]), which specifies a rotation by degrees about a given point. - If optional parameters and are not supplied, the rotate is about the origin of the current user coordinate system. The operation corresponds to the matrix [cos(a) sin(a) -sin(a) cos(a) 0 0]. - If optional parameters and are supplied, the rotate is about the point (cx, cy). The operation represents the equivalent of the following specification: translate(, ) rotate() translate(-, -). - - * skewX(), which specifies a skew transformation along the x-axis. - - * skewY(), which specifies a skew transformation along the y-axis. - */ - if( [[self getAttribute:@"transform"] length] > 0 || [[self getAttribute:@"gradientTransform"] length] > 0) - { - if( [self conformsToProtocol:@protocol(SVGTransformable)] ) - { - SVGElement* selfTransformable = (SVGElement*) self; - - /** - http://www.w3.org/TR/SVG/coords.html#TransformAttribute - - The individual transform definitions are separated by whitespace and/or a comma. - */ - NSString* value = [self getAttribute:@"transform"]; - if (!value.length) { - value = [self getAttribute:@"gradientTransform"]; - } - - NSError* error = nil; - NSRegularExpression* regexpTransformListItem = [NSRegularExpression regularExpressionWithPattern:@"[^\\(\\),]*\\([^\\)]*" options:0 error:&error]; // anything except space and brackets ... followed by anything except open bracket ... plus anything until you hit a close bracket - - [regexpTransformListItem enumerateMatchesInString:value options:0 range:NSMakeRange(0, [value length]) usingBlock: - ^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) - { - NSString* transformString = [value substringWithRange:[result range]]; - - //EXTREME DEBUG: SVGKitLogVerbose(@"[%@] DEBUG: found a transform element (should be command + open bracket + args + close bracket) = %@", [self class], transformString); - - NSRange loc = [transformString rangeOfString:@"("]; - if( loc.length == 0 ) - { - SVGKitLogError(@"[%@] ERROR: input file is illegal, has an item in the SVG transform attribute which has no open-bracket. Item = %@, transform attribute value = %@", [self class], transformString, value ); - return; - } - NSString* command = [transformString substringToIndex:loc.location]; - NSString* rawParametersString = [transformString substringFromIndex:loc.location+1]; - NSArray* parameterStrings = [rawParametersString componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@", "]]; - - /** if you get ", " (comma AND space), Apple sends you an extra 0-length match - "" - between your args. We strip that here */ - parameterStrings = [parameterStrings filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"length > 0"]]; - - //EXTREME DEBUG: SVGKitLogVerbose(@"[%@] DEBUG: found parameters = %@", [self class], parameterStrings); - - command = [command stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" "]]; - - if( [command isEqualToString:@"translate"] ) - { - CGFloat xtrans = [(NSString*)[parameterStrings objectAtIndex:0] floatValue]; - CGFloat ytrans = [parameterStrings count] > 1 ? [(NSString*)[parameterStrings objectAtIndex:1] floatValue] : 0.0; - - CGAffineTransform nt = CGAffineTransformMakeTranslation(xtrans, ytrans); - selfTransformable.transform = CGAffineTransformConcat( nt, selfTransformable.transform ); // Apple's method appears to be backwards, and not doing what Apple's docs state - - } - else if( [command isEqualToString:@"scale"] ) - { - CGFloat xScale = [(NSString*)[parameterStrings objectAtIndex:0] floatValue]; - CGFloat yScale = [parameterStrings count] > 1 ? [(NSString*)[parameterStrings objectAtIndex:1] floatValue] : xScale; - - CGAffineTransform nt = CGAffineTransformMakeScale(xScale, yScale); - selfTransformable.transform = CGAffineTransformConcat( nt, selfTransformable.transform ); // Apple's method appears to be backwards, and not doing what Apple's docs state - } - else if( [command isEqualToString:@"matrix"] ) - { - CGFloat a = [(NSString*)[parameterStrings objectAtIndex:0] floatValue]; - CGFloat b = [(NSString*)[parameterStrings objectAtIndex:1] floatValue]; - CGFloat c = [(NSString*)[parameterStrings objectAtIndex:2] floatValue]; - CGFloat d = [(NSString*)[parameterStrings objectAtIndex:3] floatValue]; - CGFloat tx = [(NSString*)[parameterStrings objectAtIndex:4] floatValue]; - CGFloat ty = [(NSString*)[parameterStrings objectAtIndex:5] floatValue]; - - CGAffineTransform nt = CGAffineTransformMake(a, b, c, d, tx, ty ); - selfTransformable.transform = CGAffineTransformConcat( nt, selfTransformable.transform ); // Apple's method appears to be backwards, and not doing what Apple's docs state - - } - else if( [command isEqualToString:@"rotate"] ) - { - /** - This section merged from warpflyght's commit: - - https://github.com/warpflyght/SVGKit/commit/c1bd9b3d0607635dda14ec03579793fc682763d9 - - */ - if( [parameterStrings count] == 1) - { - CGFloat degrees = [[parameterStrings objectAtIndex:0] floatValue]; - CGFloat radians = degrees * M_PI / 180.0; - - selfTransformable.transform = CGAffineTransformRotate(selfTransformable.transform, radians); -// CGAffineTransform nt = CGAffineTransformMakeRotation(radians); -// selfTransformable.transform = CGAffineTransformConcat( nt, selfTransformable.transform ); // Apple's method appears to be backwards, and not doing what Apple's docs state - } - else if( [parameterStrings count] == 3) - { - CGFloat degrees = [[parameterStrings objectAtIndex:0] floatValue]; - CGFloat radians = degrees * M_PI / 180.0; - CGFloat centerX = [[parameterStrings objectAtIndex:1] floatValue]; - CGFloat centerY = [[parameterStrings objectAtIndex:2] floatValue]; - - selfTransformable.transform = CGAffineTransformTranslate(selfTransformable.transform, centerX, centerY); - selfTransformable.transform = CGAffineTransformRotate(selfTransformable.transform, radians); - selfTransformable.transform = CGAffineTransformTranslate(selfTransformable.transform, -1.0 * centerX, -1.0 * centerY); -// CGAffineTransform nt = CGAffineTransformIdentity; -// nt = CGAffineTransformConcat( nt, CGAffineTransformMakeTranslation(centerX, centerY) ); -// nt = CGAffineTransformConcat( nt, CGAffineTransformMakeRotation(radians) ); -// nt = CGAffineTransformConcat( nt, CGAffineTransformMakeTranslation(-1.0 * centerX, -1.0 * centerY) ); -// selfTransformable.transform = CGAffineTransformConcat( nt, selfTransformable.transform ); // Apple's method appears to be backwards, and not doing what Apple's docs state - } else - { - SVGKitLogError(@"[%@] ERROR: input file is illegal, has an SVG matrix transform attribute without the required 1 or 3 parameters. Item = %@, transform attribute value = %@", [self class], transformString, value ); - return; - } - } - else if( [command isEqualToString:@"skewX"] ) - { - CGFloat degrees = [[parameterStrings objectAtIndex:0] floatValue]; - CGFloat radians = degrees * M_PI / 180.0; - - CGAffineTransform nt = CGAffineTransformMake(1, 0, tan(radians), 1, 0, 0); - selfTransformable.transform = CGAffineTransformConcat( nt, selfTransformable.transform ); - } - else if( [command isEqualToString:@"skewY"] ) - { - CGFloat degrees = [[parameterStrings objectAtIndex:0] floatValue]; - CGFloat radians = degrees * M_PI / 180.0; - - CGAffineTransform nt = CGAffineTransformMake(1, tan(radians), 0, 1, 0, 0); - selfTransformable.transform = CGAffineTransformConcat( nt, selfTransformable.transform ); - } - else - { - NSAssert( FALSE, @"Not implemented yet: transform = %@ %@", command, transformString ); - } - }]; - - //DEBUG: SVGKitLogVerbose(@"[%@] Set local / relative transform = (%2.2f, %2.2f // %2.2f, %2.2f) + (%2.2f, %2.2f translate)", [self class], selfTransformable.transform.a, selfTransformable.transform.b, selfTransformable.transform.c, selfTransformable.transform.d, selfTransformable.transform.tx, selfTransformable.transform.ty ); - } - } - -} - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@ %p | id=%@ | prefix:localName=%@:%@ | tagName=%@ | stringValue=%@ | children=%ld>", - [self class], self, _identifier, self.prefix, self.localName, self.tagName, _stringValue, (unsigned long)self.childNodes.length]; -} - -#pragma mark - Objective-C init methods (not in SVG Spec - the official spec has no explicit way to create nodes, which is clearly a bug in the Spec. Until they fix the spec, we have to do something or else SVG would be unusable) - -- (id)initWithLocalName:(NSString*) n attributes:(NSMutableDictionary*) attributes -{ - self = [super initWithLocalName:n attributes:attributes]; - if( self ) - { - [self loadDefaults]; - - if( [self conformsToProtocol:@protocol(SVGTransformable)] ) - { - SVGElement* selfTransformable = (SVGElement*) self; - selfTransformable.transform = CGAffineTransformIdentity; - } - } - return self; -} -- (id)initWithQualifiedName:(NSString*) n inNameSpaceURI:(NSString*) nsURI attributes:(NSMutableDictionary*) attributes -{ - self = [super initWithQualifiedName:n inNameSpaceURI:nsURI attributes:attributes]; - if( self ) - { - [self loadDefaults]; - - if( [self conformsToProtocol:@protocol(SVGTransformable)] ) - { - SVGElement* selfTransformable = (SVGElement*) self; - selfTransformable.transform = CGAffineTransformIdentity; - } - } - return self; -} - -- (NSRange) nextSelectorGroupFromText:(NSString *) selectorText startFrom:(NSRange) previous -{ - previous.location = previous.location + previous.length; - if( previous.location < selectorText.length ) - { - if( [selectorText characterAtIndex:previous.location] == ',' ) - previous.location = previous.location + 1; - - NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; - while( previous.location < selectorText.length && [whitespace characterIsMember:[selectorText characterAtIndex:previous.location]] ) - previous.location = previous.location + 1; - - if( previous.location < selectorText.length ) { - previous.length = selectorText.length - previous.location; - NSRange nextGroup = [selectorText rangeOfString:@"," options:0 range:previous]; - if( nextGroup.location == NSNotFound ) - return previous; - else - return NSMakeRange(previous.location, nextGroup.location - previous.location); - } - } - return NSMakeRange(NSNotFound, -1); -} - -- (NSRange) nextSelectorRangeFromText:(NSString *) selectorText startFrom:(NSRange) previous -{ - NSMutableCharacterSet *identifier = [NSMutableCharacterSet alphanumericCharacterSet]; - [identifier addCharactersInString:@"-_"]; - NSCharacterSet *selectorStart = [NSCharacterSet characterSetWithCharactersInString:@"#."]; - - NSInteger start = -1; - NSUInteger end = 0; - for( NSUInteger i = previous.location + previous.length; i < selectorText.length; i++ ) - { - unichar c = [selectorText characterAtIndex:i]; - if( [selectorStart characterIsMember:c] ) - { - if( start == -1 ) - start = i; - else - break; - } - else if( [identifier characterIsMember:c] ) - { - if( start == -1 ) - start = i; - end = i; - } - else if( start != -1 ) - { - break; - } - } - - if( start != -1 ) - return NSMakeRange(start, end + 1 - start); - else - return NSMakeRange(NSNotFound, -1); -} - -- (BOOL) selector:(NSString *)selector appliesTo:(SVGElement *) element specificity:(NSInteger*) specificity -{ - if( [selector characterAtIndex:0] == '.' ) - { - if( element.className != nil ) - { - NSScanner *classNameScanner = [NSScanner scannerWithString:element.className]; - NSMutableCharacterSet *whitespaceAndCommaSet = [NSMutableCharacterSet whitespaceCharacterSet]; - NSString *substring; - - [whitespaceAndCommaSet addCharactersInString:@","]; - selector = [selector substringFromIndex:1]; - __block BOOL matched = NO; - - while ([classNameScanner scanUpToCharactersFromSet:whitespaceAndCommaSet intoString:&substring]) - { - if( [substring isEqualToString:selector] ) - { - matched = YES; - break; - } - - if (!classNameScanner.isAtEnd) - classNameScanner.scanLocation = classNameScanner.scanLocation+1L; - } - if( matched ) - { - *specificity += 100; - return YES; - } - } - } - else if( [selector characterAtIndex:0] == '#' ) - { - if( element.identifier != nil && [element.identifier isEqualToString:[selector substringFromIndex:1]] ) - { - *specificity += 10000; - return YES; - } - } - else if( element.nodeName != nil && [element.nodeName isEqualToString:selector] ) - { - *specificity += 1; - return YES; - } - else if( [selector isEqualToString:@"*"] ) - { - return YES; - } - return NO; -} - -- (BOOL) styleRule:(CSSStyleRule *) styleRule appliesTo:(SVGElement *) element specificity:(NSInteger*) specificity -{ - NSRange nextGroup = [self nextSelectorGroupFromText:styleRule.selectorText startFrom:NSMakeRange(0, 0)]; - while( nextGroup.location != NSNotFound ) - { - NSRange nextRule = [self nextSelectorRangeFromText:styleRule.selectorText startFrom:NSMakeRange(nextGroup.location, 0)]; - - BOOL match = nextRule.location != NSNotFound; - while( nextRule.location != NSNotFound ) - { - if( ![self selector:[styleRule.selectorText substringWithRange:nextRule] appliesTo:element specificity:specificity] ) - { - match = NO; - break; - } - nextRule = [self nextSelectorRangeFromText:styleRule.selectorText startFrom:nextRule]; - if( nextRule.location > (nextGroup.location + nextGroup.length) ) - break; - } - - if( match ) - return YES; - - nextGroup = [self nextSelectorGroupFromText:styleRule.selectorText startFrom:nextGroup]; - } - return NO; -} - -#pragma mark - CSS cascading special attributes --(NSString*) cascadedValueForStylableProperty:(NSString*) stylableProperty -{ - return [self cascadedValueForStylableProperty:stylableProperty inherit:YES]; -} - --(NSString*) cascadedValueForStylableProperty:(NSString*) stylableProperty inherit:(BOOL)inherit -{ - /** - This is the core implementation of Cascading Style Sheets, inside SVG. - - c.f.: http://www.w3.org/TR/SVG/styling.html - - In SVG, the set of things that can be cascaded is strictly defined, c.f.: - - http://www.w3.org/TR/SVG/propidx.html - - For each of those, the implementation is the same. - - ********* WAWRNING: THE CURRENT IMPLEMENTATION BELOW IS VERY MUCH INCOMPLETE, BUT IT WORKS FOR VERY SIMPLE SVG'S ************ - */ - NSString* localStyleValue = [self.style getPropertyValue:stylableProperty]; - - if( localStyleValue != nil ) - return localStyleValue; - - /** we have a locally declared CSS class; let's go hunt for it in the document's stylesheets */ - - @autoreleasepool /** DOM / CSS is insanely verbose, so this is likely to generate a lot of crud objects */ - { - CSSStyleRule *mostSpecificRule = nil; - NSInteger mostSpecificity = -1; - - for( StyleSheet* genericSheet in self.rootOfCurrentDocumentFragment.styleSheets.internalArray.reverseObjectEnumerator ) // because it's far too much effort to use CSS's low-quality iteration here... - { - if( [genericSheet isKindOfClass:[CSSStyleSheet class]]) - { - CSSStyleSheet* cssSheet = (CSSStyleSheet*) genericSheet; - - for( CSSRule* genericRule in cssSheet.cssRules.internalArray.reverseObjectEnumerator) - { - if( [genericRule isKindOfClass:[CSSStyleRule class]]) - { - CSSStyleRule* styleRule = (CSSStyleRule*) genericRule; - - if( [styleRule.style getPropertyCSSValue:stylableProperty] != nil ) - { - NSInteger ruleSpecificity = 0; - if( [self styleRule:styleRule appliesTo:self specificity:&ruleSpecificity] ) - { - if( ruleSpecificity > mostSpecificity ) { - mostSpecificity = ruleSpecificity; - mostSpecificRule = styleRule; - } - } - } - } - } - } - } - - if( mostSpecificRule != nil ) - return [mostSpecificRule.style getPropertyValue:stylableProperty]; - } - - /** if there's a local property, use that */ - if( [self hasAttribute:stylableProperty]) - return [self getAttribute:stylableProperty]; - - if( inherit ) - { - /** Finally: move up the tree until you find a or node, and ask it to provide the value - */ - - Node* parentElement = self.parentNode; - while( parentElement != nil - && ! [parentElement isKindOfClass:[SVGGElement class]] - && ! [parentElement isKindOfClass:[SVGSVGElement class]]) - { - parentElement = parentElement.parentNode; - } - - if( parentElement == nil ) - { - return nil; // give up! - } - else - { - return [((SVGElement*)parentElement) cascadedValueForStylableProperty:stylableProperty]; - } - } - else - { - return nil; - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement_ForParser.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement_ForParser.h deleted file mode 100644 index 50dcc872fa..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGElement_ForParser.h +++ /dev/null @@ -1,18 +0,0 @@ -#import "SVGElement.h" - -#import "SVGKParseResult.h" - -@interface SVGElement () - - -+ (BOOL)shouldStoreContent; // to optimize parser, default is NO - -- (void)loadDefaults; // should be overriden to set element defaults - -/*! Overridden by sub-classes. Be sure to call [super postProcessAttributesAddingErrorsTo:attributes]; - Returns nil, or an error if something failed trying to parse attributes (usually: - unsupported SVG feature that's not implemented yet) - */ -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGEllipseElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGEllipseElement.h deleted file mode 100644 index 1e3f33acb4..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGEllipseElement.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// SVGEllipseElement.h -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "BaseClassForAllSVGBasicShapes.h" -#import "BaseClassForAllSVGBasicShapes_ForSubclasses.h" - -@interface SVGEllipseElement : BaseClassForAllSVGBasicShapes { } - -@property (nonatomic, readonly) CGFloat cx; -@property (nonatomic, readonly) CGFloat cy; -@property (nonatomic, readonly) CGFloat rx; -@property (nonatomic, readonly) CGFloat ry; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGEllipseElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGEllipseElement.m deleted file mode 100644 index e326cb94de..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGEllipseElement.m +++ /dev/null @@ -1,65 +0,0 @@ -// -// SVGEllipseElement.m -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGEllipseElement.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - -#import "SVGHelperUtilities.h" - -@interface SVGEllipseElement() -@property (nonatomic, readwrite) CGFloat cx; -@property (nonatomic, readwrite) CGFloat cy; -@property (nonatomic, readwrite) CGFloat rx; -@property (nonatomic, readwrite) CGFloat ry; -@end - -@implementation SVGEllipseElement - -@synthesize cx = _cx; -@synthesize cy = _cy; -@synthesize rx = _rx; -@synthesize ry = _ry; - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - SVGRect r = parseResult.rootOfSVGTree.viewport; - - if( [[self getAttribute:@"cx"] length] > 0 ) - { - self.cx = [[SVGLength svgLengthFromNSString:[self getAttribute:@"cx"] ] - pixelsValueWithDimension:r.width]; - } - if( [[self getAttribute:@"cy"] length] > 0 ) - { - self.cy = [[SVGLength svgLengthFromNSString:[self getAttribute:@"cy"] ] - pixelsValueWithDimension:r.height]; - } - if( [[self getAttribute:@"rx"] length] > 0 ) - { - self.rx = [[SVGLength svgLengthFromNSString:[self getAttribute:@"rx"] ] - pixelsValueWithDimension:r.width]; - } - if( [[self getAttribute:@"ry"] length] > 0 ) - { - self.ry = [[SVGLength svgLengthFromNSString:[self getAttribute:@"ry"] ] - pixelsValueWithDimension:r.height]; - } - if( [[self getAttribute:@"r"] length] > 0 ) { // circle - - self.ry = self.rx = [[SVGLength svgLengthFromNSString:[self getAttribute:@"r"] ] - pixelsValueWithDimension:hypot(r.width, r.height)/M_SQRT2]; - } - - CGMutablePathRef path = CGPathCreateMutable(); - CGPathAddEllipseInRect(path, NULL, CGRectMake(self.cx - self.rx, self.cy - self.ry, self.rx * 2, self.ry * 2)); - self.pathForShapeInRelativeCoords = path; - CGPathRelease(path); -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientElement.h deleted file mode 100644 index 818173565b..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientElement.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -// - http://www.w3.org/TR/SVG/pservers.html#InterfaceSVGGradientElement - - interface SVGGradientElement : SVGElement, - - SVGURIReference, - SVGExternalResourcesRequired, - SVGStylable, - SVGUnitTypes { - - // Spread Method Types - const unsigned short SVG_SPREADMETHOD_UNKNOWN = 0; - const unsigned short SVG_SPREADMETHOD_PAD = 1; - const unsigned short SVG_SPREADMETHOD_REFLECT = 2; - const unsigned short SVG_SPREADMETHOD_REPEAT = 3; - - readonly attribute SVGAnimatedEnumeration gradientUnits; - readonly attribute SVGAnimatedTransformList gradientTransform; - readonly attribute SVGAnimatedEnumeration spreadMethod; - - */ - -#import "SVGElement.h" -#import "SVGRect.h" -#import "SVGGradientStop.h" -#import "SVGTransformable.h" -#import "SVGPreserveAspectRatio.h" -#import "SVGUnitTypes.h" - -typedef NS_ENUM(NSUInteger, SVGSpreadMethod) { - SVGSpreadMethodUnkown = 0, - SVGSpreadMethodPad = 1, - SVGSpreadMethodReflect = 2, - SVGSpreadMethodRepeat = 3 -}; - -@class SVGGradientLayer; -@interface SVGGradientElement : SVGElement /* NB: does NOT implemente "SVGLayeredElement" because spec says that these specifically NEVER appear in the output */ - -@property (readonly, strong) NSArray *stops; /* FIXME: not in SVG Spec */ -@property (readonly, strong) NSArray *locations; /* FIXME: not in SVG Spec */ -@property (readonly, strong) NSArray *colors; /* FIXME: not in SVG Spec */ - -@property (readonly, assign) SVG_UNIT_TYPE gradientUnits; -@property (readonly, assign) SVGSpreadMethod spreadMethod; /* FIXME: currently only support `pad`. other methods are not supported */ - - --(void)addStop:(SVGGradientStop *)gradientStop; /* FIXME: not in SVG Spec */ - --(NSString*) getAttributeInheritedIfNil:(NSString*)attrName; --(SVGGradientLayer *)newGradientLayerForObjectRect:(CGRect)objectRect - viewportRect:(SVGRect)viewportRect - transform:(CGAffineTransform)transform; - -- (void)synthesizeProperties; // resolve any xlink:hrefs to other gradients -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientElement.m deleted file mode 100644 index 481ee4f36d..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientElement.m +++ /dev/null @@ -1,137 +0,0 @@ - /* FIXME: very different from SVG Spec */ - -#import "SVGGradientElement.h" -#import "SVGGradientStop.h" -#import "SVGGElement.h" -#import "SVGLinearGradientElement.h" -#import "SVGRadialGradientElement.h" - -@implementation SVGGradientElement - -@synthesize stops = _stops; -@synthesize transform; -@synthesize locations = _locations; -@synthesize colors = _colors; -@synthesize gradientUnits = _gradientUnits; -@synthesize spreadMethod = _spreadMethod; - --(void)addStop:(SVGGradientStop *)gradientStop -{ - if( _stops == nil ) - { - _stops = [NSArray arrayWithObject:gradientStop]; - } - else - { - _stops = [_stops arrayByAddingObjectsFromArray:[NSArray arrayWithObject:gradientStop]]; - } -} - -- (NSArray *)colors { - if(_colors == nil ) //these can't be determined until parsing is complete, need to update SVGGradientParser and do this on end element - { - NSUInteger numStops = [self.stops count]; - if (numStops == 0) { - return nil; - } - NSMutableArray *colorBuilder = [[NSMutableArray alloc] initWithCapacity:numStops]; - for (SVGGradientStop *theStop in self.stops) - { - [colorBuilder addObject:(__bridge id)CGColorWithSVGColor([theStop stopColor])]; - } - - _colors = [[NSArray alloc] initWithArray:colorBuilder]; - } - return _colors; -} - -- (NSArray *)locations { - if(_locations == nil ) //these can't be determined until parsing is complete, need to update SVGGradientParser and do this on end element - { - NSUInteger numStops = [self.stops count]; - if (numStops == 0) { - return nil; - } - NSMutableArray *locationBuilder = [[NSMutableArray alloc] initWithCapacity:numStops]; - CGFloat previousOffset = 0; - for (int i = 0; i < self.stops.count; i++) { - SVGGradientStop *theStop = self.stops[i]; - // SVG spec: Gradient offset values less than 0 (or less than 0%) are rounded up to 0%. Gradient offset values greater than 1 (or greater than 100%) are rounded down to 100%. - CGFloat offset = MIN(MAX(0.0, theStop.offset), 1.0); - // SVG spec: Each gradient offset value is required to be equal to or greater than the previous gradient stop's offset value. If a given gradient stop's offset value is not equal to or greater than all previous offset values, then the offset value is adjusted to be equal to the largest of all previous offset values. - if (offset < previousOffset) { - offset = previousOffset; - } - // SVG spec: If two gradient stops have the same offset value, then the latter gradient stop controls the color value at the overlap point. - if (offset == previousOffset) { - if (offset != 0) { - CGFloat adjustedOffset = previousOffset - 0.0000000001; - [locationBuilder replaceObjectAtIndex:(i - 1) withObject:@(adjustedOffset)]; - } - } - previousOffset = offset; - [locationBuilder addObject:[NSNumber numberWithFloat:offset]]; - } - - _locations = [[NSArray alloc] initWithArray:locationBuilder]; - } - return _locations; -} - -- (SVG_UNIT_TYPE)gradientUnits { - NSString* gradientUnits = [self getAttributeInheritedIfNil:@"gradientUnits"]; - if( ![gradientUnits length] - || [gradientUnits isEqualToString:@"objectBoundingBox"]) { - return SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; - } else if ([gradientUnits isEqualToString:@"userSpaceOnUse"]) { - return SVG_UNIT_TYPE_USERSPACEONUSE; - } else { - SVGKitLogWarn(@"Unsupported gradientUnits: %@", gradientUnits); - return SVG_UNIT_TYPE_UNKNOWN; - } -} - -- (SVGSpreadMethod)spreadMethod { - NSString* spreadMethod = [self getAttributeInheritedIfNil:@"spreadMethod"]; - if( ![spreadMethod length] - || [spreadMethod isEqualToString:@"pad"]) { - return SVGSpreadMethodPad; - } else if ([spreadMethod isEqualToString:@"reflect"]) { - return SVGSpreadMethodReflect; - } else if ([spreadMethod isEqualToString:@"repeat"]) { - return SVGSpreadMethodRepeat; - } else { - SVGKitLogWarn(@"Unsupported spreadMethod: %@", spreadMethod); - return SVGSpreadMethodUnkown; - } -} - --(void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult -{ - [super postProcessAttributesAddingErrorsTo:parseResult]; -} - --(NSString*) getAttributeInheritedIfNil:(NSString*) attrName -{ - if( [self.parentNode isKindOfClass:[SVGGElement class]] ) - return [self hasAttribute:attrName] ? [self getAttribute:attrName] : [((SVGElement*)self.parentNode) getAttribute:attrName]; - else - return [self getAttribute:attrName]; // will return blank if there was no value AND no parent value -} - -- (SVGGradientLayer *)newGradientLayerForObjectRect:(CGRect)objectRect viewportRect:(SVGRect)viewportRect transform:(CGAffineTransform)transform { - return nil; -} - -- (void)synthesizeProperties -{ - -} - --(void)layoutLayer:(CALayer *)layer -{ - -} - - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientStop.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientStop.h deleted file mode 100644 index d0b6367340..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientStop.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - http://www.w3.org/TR/SVG/pservers.html#InterfaceSVGStopElement - - interface SVGStopElement : SVGElement, - SVGStylable { - readonly attribute SVGAnimatedNumber offset; - */ - -#import "SVGElement.h" -#import "SVGUtils.h" - - -@interface SVGGradientStop : SVGElement - -@property (nonatomic, readonly)CGFloat offset; /** FIXME: wrong units */ -@property (nonatomic, readonly)CGFloat stopOpacity; /** FIXME: not in SVG Spec */ -@property (nonatomic, readonly)SVGColor stopColor; /** FIXME: not in SVG Spec */ - -//@property (nonatomic, readonly)NSDictionary *style; //misc unaccounted for properties - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientStop.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientStop.m deleted file mode 100644 index 4bde7ce688..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGradientStop.m +++ /dev/null @@ -1,58 +0,0 @@ -// -// SVGGradientStop -// SVGPad -// -// Created by Kevin Stich on 2/2/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - - -#import "SVGGradientStop.h" -#import "SVGElement_ForParser.h" - -#import "SVGUtils.h" -#import "SVGKParser.h" - -#import "SVGLength.h" - -@implementation SVGGradientStop - -@synthesize offset = _offset; -@synthesize stopColor = _stopColor; -@synthesize stopOpacity = _stopOpacity; - -//@synthesize style = _style; - --(void)loadDefaults -{ - _stopOpacity = 1.0f; -} - --(void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult -{ - [super postProcessAttributesAddingErrorsTo:parseResult]; - - if( [self getAttribute:@"offset"].length > 0 ) - _offset = [[SVGLength svgLengthFromNSString:[self getAttribute:@"offset"]] numberValue]; - - /** Second, over-ride the style with any locally-specified values */ - NSString *stopColor = [self cascadedValueForStylableProperty:@"stop-color" inherit:NO]; - if( stopColor.length > 0 ) - _stopColor = SVGColorFromString( [stopColor UTF8String] ); - - NSString *stopOpacity = [self cascadedValueForStylableProperty:@"stop-opacity" inherit:NO]; - if( stopOpacity.length > 0 ) - _stopOpacity = [stopOpacity floatValue]; - - _stopColor.a = (_stopOpacity * 255); -} - -//no memory allocated by this subclass -//-(void)dealloc -//{ -// -// -// [super dealloc]; -//} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGroupElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGroupElement.h deleted file mode 100644 index f8062698c2..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGroupElement.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// SVGGroupElement.h -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGElement.h" -#import "ConverterSVGToCALayer.h" - -@interface SVGGroupElement : SVGElement < ConverterSVGToCALayer > { } - -@property (nonatomic, readonly) CGFloat opacity; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGroupElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGroupElement.m deleted file mode 100644 index 739a38a5b6..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGGroupElement.m +++ /dev/null @@ -1,102 +0,0 @@ -/** - SVGGroupElement.m - - In SVG, every single element can contain children. - - However, the SVG spec defines a special (optional) "group" element, that is never rendered, - but allows additional nesting (e.g. for programmatic / organizational purposes). - - This is the "G" tag. - */ -#import "SVGGroupElement.h" - -#import "CALayerWithChildHitTest.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) -#import "Node.h" - -@implementation SVGGroupElement - -@synthesize opacity = _opacity; - - -- (void)loadDefaults { - _opacity = 1.0f; -} - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - if( [[self getAttribute:@"opacity"] length] > 0 ) - _opacity = [[self getAttribute:@"opacity"] floatValue]; -} - -- (CALayer *) newLayer -{ - - CALayer* _layer = [CALayerWithChildHitTest layer]; - - _layer.name = self.identifier; - [_layer setValue:self.identifier forKey:kSVGElementIdentifier]; - _layer.opacity = _opacity; - - - return _layer; -} - -- (void)layoutLayer:(CALayer *)layer { - CGRect mainRect = CGRectZero; - - /** Adam: make a frame thats the UNION of all sublayers frames */ - for ( CALayer *currentLayer in [layer sublayers] ) - { - CGRect subLayerFrame = currentLayer.frame; - mainRect = CGRectUnion(mainRect, subLayerFrame); - } - - layer.frame = mainRect; - - /** Adam:(dont know why this is here): set each sublayer to have a frame the same size as the parent frame, but with 0 offset. - - Adam: if I understand this correctly, the person who wrote it should have just written: - - "currentLayer.bounds = layer.frame" - - i.e. make every layer have the same size as the parent layer. - - But whoever wrote this didn't document their bad code, so I have no idea if thats correct or not - */ - for (CALayer *currentLayer in [layer sublayers]) { - CGRect frame = currentLayer.frame; - frame.origin.x -= mainRect.origin.x; - frame.origin.y -= mainRect.origin.y; - - currentLayer.frame = frame; - } -} - -/* - FIXME: this cannot work; this is incompatible with the way that SVG spec was designed; this code comes from old SVGKit - - //we can't propagate opacity down unfortunately, so we need to build a set of all the properties except a few (opacity is applied differently to groups than simply inheriting it to it's children, - -#import "SVGElement.h" -#import "SVGTransformable.h" -#import "SVGFitToViewBox.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - -@interface SVGImageElement : SVGElement - -@property (nonatomic, readonly) CGFloat x; -@property (nonatomic, readonly) CGFloat y; -@property (nonatomic, readonly) CGFloat width; -@property (nonatomic, readonly) CGFloat height; - -@property (nonatomic, strong, readonly) NSString *href; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGImageElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGImageElement.m deleted file mode 100644 index e929967ab9..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGImageElement.m +++ /dev/null @@ -1,276 +0,0 @@ -#import "SVGImageElement.h" - -#import "CALayerWithClipRender.h" -#import "SVGHelperUtilities.h" -#import "NSData+NSInputStream.h" - -#import "SVGKImage.h" -#import "SVGKSourceURL.h" -#import "SVGKSourceNSData.h" -#import "SVGKInlineResource.h" - -CGImageRef SVGImageCGImage(UIImage *img) -{ -#if SVGKIT_UIKIT - return img.CGImage; -#else - CGImageRef cgImage = [img CGImageForProposedRect:NULL context:nil hints:nil]; - return cgImage; -#endif -} - -@interface SVGImageElement() -@property (nonatomic, strong, readwrite) NSString *href; -@end - -@implementation SVGImageElement - -@synthesize transform; // each SVGElement subclass that conforms to protocol "SVGTransformable" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols -@synthesize viewBox; // each SVGElement subclass that conforms to protocol "SVGFitToViewBox" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols -@synthesize preserveAspectRatio; // each SVGElement subclass that conforms to protocol "SVGFitToViewBox" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols - -@synthesize x = _x; -@synthesize y = _y; -@synthesize width = _width; -@synthesize height = _height; - -@synthesize href = _href; - - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - if( [[self getAttribute:@"x"] length] > 0 ) - _x = [[self getAttribute:@"x"] floatValue]; - - if( [[self getAttribute:@"y"] length] > 0 ) - _y = [[self getAttribute:@"y"] floatValue]; - - if( [[self getAttribute:@"width"] length] > 0 ) - _width = [[self getAttribute:@"width"] floatValue]; - - if( [[self getAttribute:@"height"] length] > 0 ) - _height = [[self getAttribute:@"height"] floatValue]; - - if( [[self getAttribute:@"href"] length] > 0 ) - self.href = [self getAttribute:@"href"]; - - [SVGHelperUtilities parsePreserveAspectRatioFor:self]; -} - - -- (CALayer *) newLayer -{ - CALayer* newLayer = [CALayerWithClipRender layer]; - - [SVGHelperUtilities configureCALayer:newLayer usingElement:self]; - - NSData *imageData; - NSURL* imageURL = [NSURL URLWithString:_href]; - SVGKSource* effectiveSource = nil; - if ([_href hasPrefix:@"http:"] || [_href hasPrefix:@"https:"] ) - imageData = [NSData dataWithContentsOfURL:imageURL]; - else - if( [_href hasPrefix:@"data:"]) - { - self.href = [_href stringByReplacingOccurrencesOfString:@"\\s+" - withString:@"" - options:NSRegularExpressionSearch - range:NSMakeRange(0, [_href length]) ]; - - imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:_href]]; - } - else - { - effectiveSource = [self.rootOfCurrentDocumentFragment.source sourceFromRelativePath:_href]; - NSInputStream *stream = effectiveSource.stream; - if (stream) { - [stream open]; // if we do this, we CANNOT parse from this source again in future - NSError *error = nil; - imageData = [NSData dataWithContentsOfStream:stream initialCapacity:NSUIntegerMax error:&error]; - if( error ) - SVGKitLogError(@"[%@] ERROR: unable to read stream from %@ into NSData: %@", [self class], _href, error); - } else { - SVGKitLogError(@"[%@] ERROR: unable to load the source from URL: %@", [self class], _href); - } - } - - /** Now we have some raw bytes, try to load using Apple's image loaders - (will fail if the image is an SVG file) - */ - UIImage *image = [[UIImage alloc] initWithData:imageData]; - - if( image == nil ) // NSData doesn't contain an imageformat Apple supports; might be an SVG instead - { - SVGKImage *svg = nil; - - if( effectiveSource == nil ) - effectiveSource = [SVGKSourceURL sourceFromURL:imageURL]; - - if( effectiveSource != nil ) - { - SVGKitLogInfo(@"Attempting to interpret the image at URL as an embedded SVG link (Apple failed to parse it): %@", _href ); - if( imageData != nil ) - { - /** NB: sources can only be used once; we've already opened the stream for the source - earlier, so we MUST pass-in the already-downloaded NSData - - (if not, we'd be downloading it twice anyway, which can be lethal with large - SVG files!) - */ - svg = [SVGKImage imageWithSource: [SVGKSourceNSData sourceFromData:imageData URLForRelativeLinks:imageURL]]; - } - else - { - svg = [SVGKImage imageWithSource: effectiveSource]; - } - - if( svg != nil ) - { - image = svg.UIImage; - } - } - - // If still fail, use the broken image placeholder - if (!image) { - image = SVGKGetBrokenImageRepresentation(); - } - } - - if( image != nil ) - { - CGRect frame = CGRectMake(_x, _y, _width, _height); - - if( imageData ) - self.viewBox = SVGRectMake(0, 0, image.size.width, image.size.height); - else - self.viewBox = SVGRectMake(0, 0, _width, _height); - - CGImageRef imageRef = SVGImageCGImage(image); - BOOL imageRefHasBeenRetained = false; // only one codepath CREATES a new image, because of Apple's API; the rest use an existing reference - // apply preserveAspectRatio - if( self.preserveAspectRatio.baseVal.align != SVG_PRESERVEASPECTRATIO_NONE - && ABS( self.aspectRatioFromWidthPerHeight - self.aspectRatioFromViewBox) > 0.00001 ) - { - double ratioOfRatios = self.aspectRatioFromWidthPerHeight / self.aspectRatioFromViewBox; - if( self.preserveAspectRatio.baseVal.meetOrSlice == SVG_MEETORSLICE_MEET ) - { - // shrink the image to fit in the frame, preserving the aspect ratio - frame = [self clipFrame:frame fromRatio:ratioOfRatios]; - } - else if( self.preserveAspectRatio.baseVal.meetOrSlice == SVG_MEETORSLICE_SLICE ) - { - // crop the image - CGRect cropRect = CGRectMake(0, 0, image.size.width, image.size.height); - cropRect = [self clipFrame:cropRect fromRatio:1.0 / ratioOfRatios]; - imageRef = CGImageCreateWithImageInRect(imageRef, cropRect); - imageRefHasBeenRetained = true; - } - } - - /** transform our LOCAL path into ABSOLUTE space */ - frame = CGRectApplyAffineTransform(frame, [SVGHelperUtilities transformAbsoluteIncludingViewportForTransformableOrViewportEstablishingElement:self]); - newLayer.frame = frame; - - newLayer.contents = (__bridge id)imageRef; - if( imageRefHasBeenRetained ) - CGImageRelease( imageRef ); - } - -#if OLD_CODE - __block CALayer *layer = [[CALayer layer] retain]; - - layer.name = self.identifier; - [layer setValue:self.identifier forKey:kSVGElementIdentifier]; - - CGRect frame = CGRectMake(_x, _y, _width, _height); - frame = CGRectApplyAffineTransform(frame, [SVGHelperUtilities transformAbsoluteIncludingViewportForTransformableOrViewportEstablishingElement:self]); - layer.frame = frame; - - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ - NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:_href]]; - SVGImageRef image = [SVGImage imageWithData:imageData]; - - // _href = @"http://b.dryicons.com/images/icon_sets/coquette_part_4_icons_set/png/128x128/png_file.png"; - // NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:_href]]; - // UIImage *image = [UIImage imageWithData:imageData]; - - dispatch_async(dispatch_get_main_queue(), ^{ - layer.contents = (id)SVGImageCGImage(image); - }); - }); - - return layer; -#endif - - return newLayer; -} - -- (CGRect)clipFrame:(CGRect)frame fromRatio:(double)ratioOfRatios -{ - if( ratioOfRatios > 1 ) // if we're going to have space to either side - { - CGFloat width = frame.size.width; - frame.size.width = frame.size.width / ratioOfRatios; - switch( self.preserveAspectRatio.baseVal.align ) - { - case SVG_PRESERVEASPECTRATIO_XMIDYMIN: - case SVG_PRESERVEASPECTRATIO_XMIDYMID: - case SVG_PRESERVEASPECTRATIO_XMIDYMAX: - { - frame.origin.x = frame.origin.x + ((width - frame.size.width) / 2); - }break; - - case SVG_PRESERVEASPECTRATIO_XMAXYMIN: - case SVG_PRESERVEASPECTRATIO_XMAXYMID: - case SVG_PRESERVEASPECTRATIO_XMAXYMAX: - { - frame.origin.x = frame.origin.x + width - frame.size.width; - }break; - - default: - break; - } - } - else // if we're going to have space above and below - { - CGFloat height = frame.size.height; - frame.size.height = frame.size.height * ratioOfRatios; - switch( self.preserveAspectRatio.baseVal.align ) - { - case SVG_PRESERVEASPECTRATIO_XMINYMID: - case SVG_PRESERVEASPECTRATIO_XMIDYMID: - case SVG_PRESERVEASPECTRATIO_XMAXYMID: - { - frame.origin.y = frame.origin.y + ((height - frame.size.height) / 2); - }break; - - case SVG_PRESERVEASPECTRATIO_XMINYMAX: - case SVG_PRESERVEASPECTRATIO_XMIDYMAX: - case SVG_PRESERVEASPECTRATIO_XMAXYMAX: - { - frame.origin.y = frame.origin.y + height - frame.size.height; - }break; - - default: - break; - } - } - return frame; -} - -- (void)layoutLayer:(CALayer *)layer { - -} - --(double)aspectRatioFromWidthPerHeight -{ - return self.height == 0 ? 0 : self.width / self.height; -} - --(double)aspectRatioFromViewBox -{ - return self.viewBox.height == 0 ? 0 : self.viewBox.width / self.viewBox.height; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLineElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLineElement.h deleted file mode 100644 index e8771905b6..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLineElement.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// SVGLineElement.h -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "BaseClassForAllSVGBasicShapes.h" - -@interface SVGLineElement : BaseClassForAllSVGBasicShapes { } - -@property (nonatomic, readonly) CGFloat x1; -@property (nonatomic, readonly) CGFloat y1; -@property (nonatomic, readonly) CGFloat x2; -@property (nonatomic, readonly) CGFloat y2; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLineElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLineElement.m deleted file mode 100644 index c6e72d70a0..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLineElement.m +++ /dev/null @@ -1,60 +0,0 @@ -// -// SVGLineElement.m -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGLineElement.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - -#import "SVGHelperUtilities.h" - -@implementation SVGLineElement - -@synthesize x1 = _x1; -@synthesize y1 = _y1; -@synthesize x2 = _x2; -@synthesize y2 = _y2; - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - SVGRect r = parseResult.rootOfSVGTree.viewport; - - if( [[self getAttribute:@"x1"] length] > 0 ) - { - _x1 = [[SVGLength svgLengthFromNSString:[self getAttribute:@"x1"] ] - pixelsValueWithDimension:r.width]; - } - if( [[self getAttribute:@"y1"] length] > 0 ) - { - _y1 = [[SVGLength svgLengthFromNSString:[self getAttribute:@"y1"] ] - pixelsValueWithDimension:r.height]; - } - if( [[self getAttribute:@"x2"] length] > 0 ) - { - _x2 = [[SVGLength svgLengthFromNSString:[self getAttribute:@"x2"] ] - pixelsValueWithDimension:r.width]; - } - if( [[self getAttribute:@"y2"] length] > 0 ) - { - _y2 = [[SVGLength svgLengthFromNSString:[self getAttribute:@"y2"] ] - pixelsValueWithDimension:r.height]; - } -} - --(CALayer *)newLayer -{ - CGMutablePathRef path = CGPathCreateMutable(); - CGPathMoveToPoint(path, NULL, _x1, _y1); - CGPathAddLineToPoint(path, NULL, _x2, _y2); - - CALayer* result = [SVGHelperUtilities newCALayerForPathBasedSVGElement:self withPath:path]; - - CGPathRelease(path); - return result; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLinearGradientElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLinearGradientElement.h deleted file mode 100644 index 163308cf33..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLinearGradientElement.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -// https://www.w3.org/TR/SVG/pservers.html#InterfaceSVGLinearGradientElement - - interface SVGLinearGradientElement : SVGGradientElement { - [SameObject] readonly attribute SVGAnimatedLength x1; - [SameObject] readonly attribute SVGAnimatedLength y1; - [SameObject] readonly attribute SVGAnimatedLength x2; - [SameObject] readonly attribute SVGAnimatedLength y2; - }; - -*/ - -#import "SVGGradientElement.h" - -@interface SVGLinearGradientElement : SVGGradientElement - -@property (nonatomic, readonly) SVGLength *x1; -@property (nonatomic, readonly) SVGLength *y1; -@property (nonatomic, readonly) SVGLength *x2; -@property (nonatomic, readonly) SVGLength *y2; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLinearGradientElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLinearGradientElement.m deleted file mode 100644 index 8bc83e38e5..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGLinearGradientElement.m +++ /dev/null @@ -1,139 +0,0 @@ -// -// SVGLinearGradientElement.m -// SVGKit-iOS -// -// Created by lizhuoli on 2018/10/15. -// Copyright © 2018年 na. All rights reserved. -// - -#import "SVGLinearGradientElement.h" -#import "SVGElement_ForParser.h" -#import "SVGGradientLayer.h" - -@interface SVGLinearGradientElement () - -@property (nonatomic) BOOL hasSynthesizedProperties; -@property (nonatomic) SVGLength *x1; -@property (nonatomic) SVGLength *y1; -@property (nonatomic) SVGLength *x2; -@property (nonatomic) SVGLength *y2; - -@end - -@implementation SVGLinearGradientElement - -- (SVGGradientLayer *)newGradientLayerForObjectRect:(CGRect)objectRect viewportRect:(SVGRect)viewportRect transform:(CGAffineTransform)absoluteTransform { - SVGGradientLayer *gradientLayer = [[SVGGradientLayer alloc] init]; - BOOL inUserSpace = self.gradientUnits == SVG_UNIT_TYPE_USERSPACEONUSE; - CGRect rectForRelativeUnits = inUserSpace ? CGRectFromSVGRect( viewportRect ) : objectRect; - - gradientLayer.frame = objectRect; - - NSString *attrX1 = [self getAttributeInheritedIfNil:@"x1"]; - NSString *attrY1 = [self getAttributeInheritedIfNil:@"y1"]; - NSString* attrX2 = [self getAttributeInheritedIfNil:@"x2"]; - NSString* attrY2 = [self getAttributeInheritedIfNil:@"y2"]; - SVGLength* svgX1 = [SVGLength svgLengthFromNSString:attrX1.length > 0 ? attrX1 : @"0%"]; - SVGLength* svgY1 = [SVGLength svgLengthFromNSString:attrY1.length > 0 ? attrY1 : @"0%"]; - SVGLength* svgX2 = [SVGLength svgLengthFromNSString:attrX2.length > 0 ? attrX2 : @"100%"]; - SVGLength* svgY2 = [SVGLength svgLengthFromNSString:attrY2.length > 0 ? attrY2 : @"0%"]; - self.x1 = svgX1; - self.y1 = svgY1; - self.x2 = svgX2; - self.y2 = svgY2; - - // these should really be two separate code paths (objectBoundingBox and userSpaceOnUse), but we simplify the logic using `rectForRelativeUnits` - CGFloat x1 = [svgX1 pixelsValueWithGradientDimension:CGRectGetWidth(rectForRelativeUnits)]; - CGFloat y1 = [svgY1 pixelsValueWithGradientDimension:CGRectGetHeight(rectForRelativeUnits)]; - CGFloat x2 = [svgX2 pixelsValueWithGradientDimension:CGRectGetWidth(rectForRelativeUnits)]; - CGFloat y2 = [svgY2 pixelsValueWithGradientDimension:CGRectGetHeight(rectForRelativeUnits)]; - CGPoint startPoint = CGPointMake(x1, y1); - CGPoint endPoint = CGPointMake(x2, y2); - - startPoint = CGPointApplyAffineTransform(startPoint, self.transform); - endPoint = CGPointApplyAffineTransform(endPoint, self.transform); - if (inUserSpace) - { - startPoint = CGPointApplyAffineTransform(startPoint, absoluteTransform); - startPoint.x = startPoint.x - CGRectGetMinX(objectRect); - startPoint.y = startPoint.y - CGRectGetMinY(objectRect); - endPoint = CGPointApplyAffineTransform(endPoint, absoluteTransform); - endPoint.x = endPoint.x - CGRectGetMaxX(objectRect) + CGRectGetWidth(objectRect); - endPoint.y = endPoint.y - CGRectGetMaxY(objectRect) + CGRectGetHeight(objectRect); - } - - CGPoint gradientStartPoint = startPoint; - CGPoint gradientEndPoint = endPoint; - - // convert to percent - gradientStartPoint.x = startPoint.x / CGRectGetWidth(objectRect); - gradientStartPoint.y = startPoint.y / CGRectGetHeight(objectRect); - gradientEndPoint.x = endPoint.x / CGRectGetWidth(objectRect); - gradientEndPoint.y = endPoint.y / CGRectGetHeight(objectRect); - - // Suck on iOS. When using `SVGFastImageView`, the layer software-rendering `drawInContext:` will contains strange boundingRect, while it works fine on macOS. So we need to use custom soft-rendering as well. - gradientLayer.startPoint = gradientStartPoint; - gradientLayer.endPoint = gradientEndPoint; - gradientLayer.type = kCAGradientLayerAxial; - // custom value (match the SVG spec) - gradientLayer.gradientElement = self; - gradientLayer.objectRect = objectRect; - gradientLayer.viewportRect = viewportRect; - gradientLayer.absoluteTransform = absoluteTransform; - - if (self.colors.count == 1) { - // SVG Spec: It is necessary that at least two stops defined to have a gradient effect. If no stops are defined, then painting shall occur as if 'none' were specified as the paint style. If one stop is defined, then paint with the solid color fill using the color defined for that gradient stop. - // However, `CAGradientLayer` will show empty when `colors.count` <= 1 - SVGGradientStop *lastStop = self.stops.lastObject; - gradientLayer.backgroundColor = CGColorWithSVGColor(lastStop.stopColor); - gradientLayer.opacity = lastStop.stopOpacity; - } else { - [gradientLayer setColors:self.colors]; - [gradientLayer setLocations:self.locations]; - } - - SVGKitLogVerbose(@"[%@] set gradient layer start = %@", [self class], NSStringFromCGPoint(gradientLayer.startPoint)); - SVGKitLogVerbose(@"[%@] set gradient layer end = %@", [self class], NSStringFromCGPoint(gradientLayer.endPoint)); - SVGKitLogVerbose(@"[%@] set gradient layer colors = %@", [self class], self.colors); - SVGKitLogVerbose(@"[%@] set gradient layer locations = %@", [self class], self.locations); - - return gradientLayer; -} - -- (void)synthesizeProperties { - if (self.hasSynthesizedProperties) - return; - self.hasSynthesizedProperties = YES; - - NSString* gradientID = [self getAttributeNS:@"http://www.w3.org/1999/xlink" localName:@"href"]; - - if ([gradientID length]) - { - if ([gradientID hasPrefix:@"#"]) - gradientID = [gradientID substringFromIndex:1]; - - SVGLinearGradientElement* baseGradient = (SVGLinearGradientElement*) [self.rootOfCurrentDocumentFragment getElementById:gradientID]; - NSString* svgNamespace = @"http://www.w3.org/2000/svg"; - - if (baseGradient) - { - [baseGradient synthesizeProperties]; - - if (!self.stops && baseGradient.stops) - { - for (SVGGradientStop* stop in baseGradient.stops) - [self addStop:stop]; - } - NSArray *keys = [NSArray arrayWithObjects:@"x1", @"y1", @"x2", @"y2", @"gradientUnits", @"gradientTransform", @"spreadMethod", nil]; - - for (NSString* key in keys) - { - if (![self hasAttribute:key] && [baseGradient hasAttribute:key]) - [self setAttributeNS:svgNamespace qualifiedName:key value:[baseGradient getAttribute:key]]; - } - - } - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPathElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPathElement.h deleted file mode 100644 index 9f934ebbb7..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPathElement.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// SVGPathElement.h -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "BaseClassForAllSVGBasicShapes.h" -#import "BaseClassForAllSVGBasicShapes_ForSubclasses.h" - -@interface SVGPathElement : BaseClassForAllSVGBasicShapes { } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPathElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPathElement.m deleted file mode 100644 index 823d178358..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPathElement.m +++ /dev/null @@ -1,168 +0,0 @@ -// -// SVGPathElement.m -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGPathElement.h" - -#import "SVGUtils.h" -#import "SVGKPointsAndPathsParser.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - -@interface SVGPathElement () - -- (void) parseData:(NSString *)data; - -@end - -@implementation SVGPathElement - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult -{ - [super postProcessAttributesAddingErrorsTo:parseResult]; - - [self parseData:[self getAttribute:@"d"]]; -} - -- (void)parseData:(NSString *)data -{ - CGMutablePathRef path = CGPathCreateMutable(); - NSScanner* dataScanner = [NSScanner scannerWithString:data]; - SVGCurve lastCurve = [SVGKPointsAndPathsParser startingCurve]; - BOOL foundCmd; - - NSCharacterSet *knownCommands = [NSCharacterSet characterSetWithCharactersInString:@"MmLlCcVvHhAaSsQqTtZz"]; - NSString* command; - - do { - - command = nil; - foundCmd = [dataScanner scanCharactersFromSet:knownCommands intoString:&command]; - - if (command.length > 1) { - // Take only one char (it can happen that multiple commands are consecutive, as "ZM" - so we only want to get the "Z") - const NSUInteger tooManyChars = command.length-1; - command = [command substringToIndex:1]; - [dataScanner setScanLocation:([dataScanner scanLocation] - tooManyChars)]; - } - - if (foundCmd) { - if ([@"z" isEqualToString:command] || [@"Z" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readCloseCommand:[NSScanner scannerWithString:command] - path:path - relativeTo:lastCurve.p]; - } else { - NSString* cmdArgs = nil; - BOOL foundParameters = [dataScanner scanUpToCharactersFromSet:knownCommands - intoString:&cmdArgs]; - - if (foundParameters) { - NSString* commandWithParameters = [command stringByAppendingString:cmdArgs]; - NSScanner* commandScanner = [NSScanner scannerWithString:commandWithParameters]; - - if ([@"m" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readMovetoDrawtoCommandGroups:commandScanner - path:path - relativeTo:lastCurve.p - isRelative:TRUE]; - } else if ([@"M" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readMovetoDrawtoCommandGroups:commandScanner - path:path - relativeTo:CGPointZero - isRelative:FALSE]; - } else if ([@"l" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readLinetoCommand:commandScanner - path:path - relativeTo:lastCurve.p - isRelative:TRUE]; - } else if ([@"L" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readLinetoCommand:commandScanner - path:path - relativeTo:CGPointZero - isRelative:FALSE]; - } else if ([@"v" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readVerticalLinetoCommand:commandScanner - path:path - relativeTo:lastCurve.p]; - } else if ([@"V" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readVerticalLinetoCommand:commandScanner - path:path - relativeTo:CGPointZero]; - } else if ([@"h" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readHorizontalLinetoCommand:commandScanner - path:path - relativeTo:lastCurve.p]; - } else if ([@"H" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readHorizontalLinetoCommand:commandScanner - path:path - relativeTo:CGPointZero]; - } else if ([@"c" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readCurvetoCommand:commandScanner - path:path - relativeTo:lastCurve.p - isRelative:TRUE]; - } else if ([@"C" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readCurvetoCommand:commandScanner - path:path - relativeTo:CGPointZero - isRelative:FALSE]; - } else if ([@"s" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readSmoothCurvetoCommand:commandScanner - path:path - relativeTo:lastCurve.p - withPrevCurve:lastCurve - isRelative:TRUE]; - } else if ([@"S" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readSmoothCurvetoCommand:commandScanner - path:path - relativeTo:CGPointZero - withPrevCurve:lastCurve - isRelative:FALSE]; - } else if ([@"q" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readQuadraticCurvetoCommand:commandScanner - path:path - relativeTo:lastCurve.p - isRelative:TRUE]; - } else if ([@"Q" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readQuadraticCurvetoCommand:commandScanner - path:path - relativeTo:CGPointZero - isRelative:FALSE]; - } else if ([@"t" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readSmoothQuadraticCurvetoCommand:commandScanner - path:path - relativeTo:lastCurve.p - withPrevCurve:lastCurve]; - } else if ([@"T" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readSmoothQuadraticCurvetoCommand:commandScanner - path:path - relativeTo:CGPointZero - withPrevCurve:lastCurve]; - } else if ([@"a" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readEllipticalArcArguments:commandScanner - path:path - relativeTo:lastCurve.p - isRelative:TRUE]; - } else if ([@"A" isEqualToString:command]) { - lastCurve = [SVGKPointsAndPathsParser readEllipticalArcArguments:commandScanner - path:path - relativeTo:CGPointZero - isRelative:FALSE]; - } else { - SVGKitLogWarn(@"unsupported command %@", command); - } - } - } - } - - } while (foundCmd); - - - self.pathForShapeInRelativeCoords = path; - CGPathRelease(path); -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolygonElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolygonElement.h deleted file mode 100644 index c6f8ecce75..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolygonElement.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// SVGPolygonElement.h -// SVGKit -// -// Copyright Matt Rajca 2011. All rights reserved. -// - -#import "BaseClassForAllSVGBasicShapes.h" -#import "BaseClassForAllSVGBasicShapes_ForSubclasses.h" - -@interface SVGPolygonElement : BaseClassForAllSVGBasicShapes { } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolygonElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolygonElement.m deleted file mode 100644 index 9483524c9a..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolygonElement.m +++ /dev/null @@ -1,106 +0,0 @@ -// -// SVGPolygonElement.m -// SVGKit -// -// Copyright Matt Rajca 2011. All rights reserved. -// - -#import "SVGPolygonElement.h" - -#import "SVGKPointsAndPathsParser.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - -@interface SVGPolygonElement() - -- (void) parseData:(NSString *)data; - -@end - -@implementation SVGPolygonElement - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - [self parseData:[self getAttribute:@"points"]]; -} - -/*! According to SVG spec, a 'polygon' is EXACTYLY IDENTICAL to a 'path', if you prepend the letter "M", and - postfix the letter 'z'. - - So, we take the complicated parser from SVGPathElement, remove all the multi-command stuff, and just use the - "M" command - */ -- (void)parseData:(NSString *)data -{ - CGMutablePathRef path = CGPathCreateMutable(); - NSScanner* dataScanner = [NSScanner scannerWithString:data]; - - NSCharacterSet* knownCommands = [NSCharacterSet characterSetWithCharactersInString:@""]; - - NSString* cmdArgs = nil; - [dataScanner scanUpToCharactersFromSet:knownCommands - intoString:&cmdArgs]; - - NSString* commandWithParameters = [@"M" stringByAppendingString:cmdArgs]; - NSScanner* commandScanner = [NSScanner scannerWithString:commandWithParameters]; - - - SVGCurve lastCurve = [SVGKPointsAndPathsParser readMovetoDrawtoCommandGroups:commandScanner - path:path - relativeTo:CGPointZero - isRelative:FALSE]; - - [SVGKPointsAndPathsParser readCloseCommand:[NSScanner scannerWithString:@"z"] - path:path - relativeTo:lastCurve.p]; - - self.pathForShapeInRelativeCoords = path; - CGPathRelease(path); -} - -/* reference - http://www.w3.org/TR/2011/REC-SVG11-20110816/shapes.html#PointsBNF - */ - -/* - list-of-points: - wsp* coordinate-pairs? wsp* - coordinate-pairs: - coordinate-pair - | coordinate-pair comma-wsp coordinate-pairs - coordinate-pair: - coordinate comma-wsp coordinate - | coordinate negative-coordinate - coordinate: - number - number: - sign? integer-constant - | sign? floating-point-constant - negative-coordinate: - "-" integer-constant - | "-" floating-point-constant - comma-wsp: - (wsp+ comma? wsp*) | (comma wsp*) - comma: - "," - integer-constant: - digit-sequence - floating-point-constant: - fractional-constant exponent? - | digit-sequence exponent - fractional-constant: - digit-sequence? "." digit-sequence - | digit-sequence "." - exponent: - ( "e" | "E" ) sign? digit-sequence - sign: - "+" | "-" - digit-sequence: - digit - | digit digit-sequence - digit: - "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" - */ - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolylineElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolylineElement.h deleted file mode 100644 index 00b8309d8c..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolylineElement.h +++ /dev/null @@ -1,6 +0,0 @@ -#import "BaseClassForAllSVGBasicShapes.h" -#import "BaseClassForAllSVGBasicShapes_ForSubclasses.h" - -@interface SVGPolylineElement : BaseClassForAllSVGBasicShapes { } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolylineElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolylineElement.m deleted file mode 100644 index 0423b96b03..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGPolylineElement.m +++ /dev/null @@ -1,22 +0,0 @@ -#import "SVGPolylineElement.h" - -#import "SVGUtils.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - - -@implementation SVGPolylineElement - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - if( [[self getAttribute:@"points"] length] > 0 ) - { - CGMutablePathRef path = createPathFromPointsInString([[self getAttribute:@"points"] UTF8String], NO); - - self.pathForShapeInRelativeCoords = path; - CGPathRelease(path); - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRadialGradientElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRadialGradientElement.h deleted file mode 100644 index 7e30302667..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRadialGradientElement.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - https://www.w3.org/TR/SVG/pservers.html#InterfaceSVGRadialGradientElement - - interface SVGRadialGradientElement : SVGGradientElement { - [SameObject] readonly attribute SVGAnimatedLength cx; - [SameObject] readonly attribute SVGAnimatedLength cy; - [SameObject] readonly attribute SVGAnimatedLength r; - [SameObject] readonly attribute SVGAnimatedLength fx; - [SameObject] readonly attribute SVGAnimatedLength fy; - [SameObject] readonly attribute SVGAnimatedLength fr; - }; - */ - -#import "SVGGradientElement.h" - -@interface SVGRadialGradientElement : SVGGradientElement - -@property (nonatomic, readonly) SVGLength *cx; -@property (nonatomic, readonly) SVGLength *cy; -@property (nonatomic, readonly) SVGLength *r; -@property (nonatomic, readonly) SVGLength *fx; -@property (nonatomic, readonly) SVGLength *fy; -@property (nonatomic, readonly) SVGLength *fr; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRadialGradientElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRadialGradientElement.m deleted file mode 100644 index a0867512c8..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRadialGradientElement.m +++ /dev/null @@ -1,192 +0,0 @@ -// -// SVGRadialGradientElement.m -// SVGKit-iOS -// -// Created by lizhuoli on 2018/10/15. -// Copyright © 2018年 na. All rights reserved. -// - -#import "SVGRadialGradientElement.h" -#import "SVGElement_ForParser.h" -#import "SVGUtils.h" -#import "SVGGradientLayer.h" - -// `kCAGradientLayerRadial` this symbol is available since iOS 3.2/tvOS 9.0/macOS 10.6, but it's not externed to public header until Xcode 10 with iOS 12 SDK, so we define it for user who still use old SDK version. -#define kCAGradientLayerRadial @"radial" - -@interface SVGRadialGradientElement () - -@property (nonatomic) BOOL hasSynthesizedProperties; -@property (nonatomic) SVGLength *cx; -@property (nonatomic) SVGLength *cy; -@property (nonatomic) SVGLength *r; -@property (nonatomic) SVGLength *fx; -@property (nonatomic) SVGLength *fy; -@property (nonatomic) SVGLength *fr; - -@end - -@implementation SVGRadialGradientElement - -- (SVGGradientLayer *)newGradientLayerForObjectRect:(CGRect)objectRect viewportRect:(SVGRect)viewportRect transform:(CGAffineTransform)absoluteTransform { - SVGGradientLayer *gradientLayer = [[SVGGradientLayer alloc] init]; - BOOL inUserSpace = self.gradientUnits == SVG_UNIT_TYPE_USERSPACEONUSE; - CGRect rectForRelativeUnits = inUserSpace ? CGRectFromSVGRect( viewportRect ) : objectRect; - - gradientLayer.frame = objectRect; - - NSString *cxAttr = [self getAttributeInheritedIfNil:@"cx"]; - NSString *cyAttr = [self getAttributeInheritedIfNil:@"cy"]; - NSString *rAttr = [self getAttributeInheritedIfNil:@"r"]; - NSString *fxAttr = [self getAttributeInheritedIfNil:@"fx"]; - NSString *fyAttr = [self getAttributeInheritedIfNil:@"fy"]; - NSString *frAttr = [self getAttributeInheritedIfNil:@"fr"]; - SVGLength* svgCX = [SVGLength svgLengthFromNSString:cxAttr.length > 0 ? cxAttr : @"50%"]; - SVGLength* svgCY = [SVGLength svgLengthFromNSString:cyAttr.length > 0 ? cyAttr : @"50%"]; - SVGLength* svgR = [SVGLength svgLengthFromNSString:rAttr.length > 0 ? rAttr : @"50%"]; - // focal value - SVGLength* svgFX = fxAttr.length > 0 ? [SVGLength svgLengthFromNSString:fxAttr] : svgCX; - SVGLength* svgFY = fyAttr.length > 0 ? [SVGLength svgLengthFromNSString:fyAttr] : svgCY; - SVGLength* svgFR = [SVGLength svgLengthFromNSString:frAttr.length > 0 ? frAttr : @"0%"]; - // This is a tempory workaround. Apple's `CAGradientLayer` does not support focal point for radial gradient. We have to use the low-level API `CGContextDrawRadialGradient` and using custom software-render for focal point. So it does not works for `SVGLayredView` which is hardware-render by CA render server. - if (fxAttr.length > 0 || fyAttr.length > 0 || frAttr.length > 0) { - SVGKitLogWarn(@"The radialGradient element #%@ contains focal value: (fx:%@, fy: %@, fr:%@). The focul value is only supported on `SVGFastimageView` and it will be ignored when rendering in SVGLayredView.", [self getAttribute:@"id"], fxAttr, fyAttr, frAttr); - } - self.cx = svgCX; - self.cy = svgCY; - self.r = svgR; - self.fx = svgFX; - self.fy = svgFY; - self.fr = svgFR; - - // these should really be two separate code paths (objectBoundingBox and userSpaceOnUse), but we simplify the logic using `rectForRelativeUnits` - CGFloat width = CGRectGetWidth(rectForRelativeUnits); - CGFloat height = CGRectGetHeight(rectForRelativeUnits); - CGFloat cx = [svgCX pixelsValueWithGradientDimension:width]; - CGFloat cy = [svgCY pixelsValueWithGradientDimension:height]; - CGFloat val = MIN(width, height); - CGFloat radius = [svgR pixelsValueWithGradientDimension:val]; - - CGFloat fx = [svgFX pixelsValueWithGradientDimension:width]; - CGFloat fy = [svgFY pixelsValueWithGradientDimension:height]; - - CGPoint startPoint = CGPointMake(cx, cy); - CGPoint endPoint = CGPointMake(fx, fy); - CGAffineTransform selfTransform = self.transform; - - if (inUserSpace) - { - // work out the new radius - CGFloat rad = radius * 2.f; - CGRect rect = CGRectMake(startPoint.x, startPoint.y, rad, rad); - rect = CGRectApplyAffineTransform(rect, self.transform); - rect = CGRectApplyAffineTransform(rect, absoluteTransform); - radius = CGRectGetHeight(rect) / 2.f; - } - - if (!inUserSpace) - { - // SVG spec: transform if width or height is not equal - if(CGRectGetWidth(objectRect) != CGRectGetHeight(objectRect)) { - CGAffineTransform tr = CGAffineTransformMakeTranslation(startPoint.x, - startPoint.y); - if(CGRectGetWidth(objectRect) > CGRectGetHeight(objectRect)) { - tr = CGAffineTransformScale(tr, CGRectGetWidth(objectRect)/CGRectGetHeight(objectRect), 1); - } else { - tr = CGAffineTransformScale(tr, 1.f, CGRectGetHeight(objectRect)/CGRectGetWidth(objectRect)); - } - tr = CGAffineTransformTranslate(tr, -startPoint.x, -startPoint.y); - selfTransform = CGAffineTransformConcat(tr, selfTransform); - } - } - - CGSize size = CGSizeMake(radius, radius); - startPoint = CGPointApplyAffineTransform(startPoint, selfTransform); - endPoint = CGPointApplyAffineTransform(endPoint, selfTransform); - size = CGSizeApplyAffineTransform(size, selfTransform); - if (inUserSpace) - { - // apply the absolute position - startPoint = CGPointApplyAffineTransform(startPoint, absoluteTransform); - startPoint.x = startPoint.x - CGRectGetMinX(objectRect); - startPoint.y = startPoint.y - CGRectGetMinY(objectRect); - endPoint = CGPointApplyAffineTransform(endPoint, absoluteTransform); - endPoint.x = endPoint.x - CGRectGetMaxX(objectRect) + CGRectGetWidth(objectRect); - endPoint.y = endPoint.y - CGRectGetMaxY(objectRect) + CGRectGetHeight(objectRect); - size = CGSizeApplyAffineTransform(size, selfTransform); - } - - CGPoint gradientStartPoint = startPoint; - CGPoint gradientEndPoint = endPoint; - - // convert to percent - CGPoint centerPoint = gradientStartPoint; - gradientStartPoint = CGPointMake((centerPoint.x) / CGRectGetWidth(objectRect), centerPoint.y / CGRectGetHeight(objectRect)); - gradientEndPoint = CGPointMake((centerPoint.x + size.width) / CGRectGetWidth(objectRect), (centerPoint.y + size.height) / CGRectGetHeight(objectRect)); - - // Suck. When using `SVGLayredImageView`, the layer rendering is submitted to CA render server, and your custom `renderInContex:` code will not work. So we just set both built-in value (CAGradientLayer property) && custom value (SVGGradientLayer property) - // FIX-ME: built-in value (not match the SVG spec, all the focal value will be ignored) - gradientLayer.startPoint = gradientStartPoint; - gradientLayer.endPoint = gradientEndPoint; - gradientLayer.type = kCAGradientLayerRadial; - // custom value (match the SVG spec) - gradientLayer.gradientElement = self; - gradientLayer.objectRect = objectRect; - gradientLayer.viewportRect = viewportRect; - gradientLayer.absoluteTransform = absoluteTransform; - - if (svgR.value <= 0 || self.colors.count == 1) { - // SVG spec: A value of lower or equal to zero will cause the area to be painted as a single color using the color and opacity of the last gradient . - SVGGradientStop *lastStop = self.stops.lastObject; - gradientLayer.backgroundColor = CGColorWithSVGColor(lastStop.stopColor); - gradientLayer.opacity = lastStop.stopOpacity; - } else { - [gradientLayer setColors:self.colors]; - [gradientLayer setLocations:self.locations]; - } - - SVGKitLogVerbose(@"[%@] set gradient layer start = %@", [self class], NSStringFromCGPoint(gradientLayer.startPoint)); - SVGKitLogVerbose(@"[%@] set gradient layer end = %@", [self class], NSStringFromCGPoint(gradientLayer.endPoint)); - SVGKitLogVerbose(@"[%@] set gradient layer colors = %@", [self class], self.colors); - SVGKitLogVerbose(@"[%@] set gradient layer locations = %@", [self class], self.locations); - - return gradientLayer; -} - -- (void)synthesizeProperties { - if (self.hasSynthesizedProperties) - return; - self.hasSynthesizedProperties = YES; - - NSString* gradientID = [self getAttributeNS:@"http://www.w3.org/1999/xlink" localName:@"href"]; - - if ([gradientID length]) - { - if ([gradientID hasPrefix:@"#"]) - gradientID = [gradientID substringFromIndex:1]; - - SVGRadialGradientElement* baseGradient = (SVGRadialGradientElement*) [self.rootOfCurrentDocumentFragment getElementById:gradientID]; - NSString* svgNamespace = @"http://www.w3.org/2000/svg"; - - if (baseGradient) - { - [baseGradient synthesizeProperties]; - - if (!self.stops && baseGradient.stops) - { - for (SVGGradientStop* stop in baseGradient.stops) - [self addStop:stop]; - } - NSArray *keys = [NSArray arrayWithObjects:@"cx", @"cy", @"r", @"fx", @"fy", @"fr", @"gradientUnits", @"gradientTransform", @"spreadMethod", nil]; - - for (NSString* key in keys) - { - if (![self hasAttribute:key] && [baseGradient hasAttribute:key]) - [self setAttributeNS:svgNamespace qualifiedName:key value:[baseGradient getAttribute:key]]; - } - - } - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRectElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRectElement.h deleted file mode 100644 index 7a543d3d74..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRectElement.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - http://www.w3.org/TR/SVG/shapes.html#InterfaceSVGRectElement - - interface SVGRectElement : SVGElement, - SVGTests, - SVGLangSpace, - SVGExternalResourcesRequired, - SVGStylable, - SVGTransformable { - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - readonly attribute SVGAnimatedLength rx; - readonly attribute SVGAnimatedLength ry; - */ -#import "BaseClassForAllSVGBasicShapes.h" -#import "BaseClassForAllSVGBasicShapes_ForSubclasses.h" -#import "SVGLength.h" -#import "SVGTransformable.h" - -@interface SVGRectElement : BaseClassForAllSVGBasicShapes -{ } - -@property (nonatomic, strong, readonly) SVGLength* x; -@property (nonatomic, strong, readonly) SVGLength* y; -@property (nonatomic, strong, readonly) SVGLength* width; -@property (nonatomic, strong, readonly) SVGLength* height; - -@property (nonatomic, strong, readonly) SVGLength* rx; -@property (nonatomic, strong, readonly) SVGLength* ry; - -#pragma mark - Properties not in spec but are needed by ObjectiveC implementation to maintain - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRectElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRectElement.m deleted file mode 100644 index 9b8e27fbc5..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGRectElement.m +++ /dev/null @@ -1,132 +0,0 @@ -#import "SVGRectElement.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - -#import "SVGHelperUtilities.h" - -@interface SVGRectElement () - -#if SVGKIT_UIKIT && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0 -void CGPathAddRoundedRect (CGMutablePathRef path, CGRect rect, CGFloat radiusX, CGFloat radiusY); -#endif - -@end - -@implementation SVGRectElement - -@synthesize transform; // each SVGElement subclass that conforms to protocol "SVGTransformable" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols - -@synthesize x = _x; -@synthesize y = _y; -@synthesize width = _width; -@synthesize height = _height; - -@synthesize rx = _rx; -@synthesize ry = _ry; - -#if SVGKIT_UIKIT && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0 -// adapted from http://www.cocoanetics.com/2010/02/drawing-rounded-rectangles/ - -void CGPathAddRoundedRect (CGMutablePathRef path, CGRect rect, CGFloat radiusX, CGFloat radiusY) { - CGRect innerRect = CGRectInset(rect, radiusX, radiusY); - - CGFloat innerRight = innerRect.origin.x + innerRect.size.width; - CGFloat right = rect.origin.x + rect.size.width; - CGFloat innerBottom = innerRect.origin.y + innerRect.size.height; - CGFloat bottom = rect.origin.y + rect.size.height; - - CGFloat innerTop = innerRect.origin.y; - CGFloat top = rect.origin.y; - CGFloat innerLeft = innerRect.origin.x; - CGFloat left = rect.origin.x; - - CGPathMoveToPoint(path, NULL, innerLeft, top); - - CGPathAddLineToPoint(path, NULL, innerRight, top); - /** c.f http://stackoverflow.com/a/12152442/153422 */ - CGAffineTransform t = CGAffineTransformConcat( CGAffineTransformMakeScale(1.0, radiusY/radiusX), CGAffineTransformMakeTranslation(innerRight, innerTop)); - CGPathAddArc(path, &t, 0, 0, radiusX, -M_PI_2, 0, false); - - CGPathAddLineToPoint(path, NULL, right, innerBottom); - /** c.f http://stackoverflow.com/a/12152442/153422 */ - t = CGAffineTransformConcat( CGAffineTransformMakeScale(1.0, radiusY/radiusX), CGAffineTransformMakeTranslation(innerRight, innerBottom)); - CGPathAddArc(path, &t, 0, 0, radiusX, 0, M_PI_2, false); - - CGPathAddLineToPoint(path, NULL, innerLeft, bottom); - /** c.f http://stackoverflow.com/a/12152442/153422 */ - t = CGAffineTransformConcat( CGAffineTransformMakeScale(1.0, radiusY/radiusX), CGAffineTransformMakeTranslation(innerLeft, innerBottom)); - CGPathAddArc(path, &t, 0, 0, radiusX, M_PI_2, M_PI, false); - - CGPathAddLineToPoint(path, NULL, left, innerTop); - /** c.f http://stackoverflow.com/a/12152442/153422 */ - t = CGAffineTransformConcat( CGAffineTransformMakeScale(1.0, radiusY/radiusX), CGAffineTransformMakeTranslation(innerLeft, innerTop)); - CGPathAddArc(path, &t, 0, 0, radiusX, M_PI, 3*M_PI_2, false); - - CGPathCloseSubpath(path); -} -#endif - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - if( [[self getAttribute:@"x"] length] > 0 ) - _x = [SVGLength svgLengthFromNSString:[self getAttribute:@"x"]]; - - if( [[self getAttribute:@"y"] length] > 0 ) - _y = [SVGLength svgLengthFromNSString:[self getAttribute:@"y"]]; - - if( [[self getAttribute:@"width"] length] > 0 ) - _width = [SVGLength svgLengthFromNSString:[self getAttribute:@"width"]]; - - if( [[self getAttribute:@"height"] length] > 0 ) - _height = [SVGLength svgLengthFromNSString:[self getAttribute:@"height"]]; - - if( [[self getAttribute:@"rx"] length] > 0 ) - _rx = [SVGLength svgLengthFromNSString:[self getAttribute:@"rx"]]; - - if( [[self getAttribute:@"ry"] length] > 0 ) - _ry = [SVGLength svgLengthFromNSString:[self getAttribute:@"ry"]]; - - /** - Create a square OR rounded rectangle as a CGPath - - */ - - SVGRect r = parseResult.rootOfSVGTree.viewport; - - CGMutablePathRef path = CGPathCreateMutable(); - CGRect rect = CGRectMake([_x pixelsValueWithDimension:r.x], [_y pixelsValueWithDimension:r.y], - [_width pixelsValueWithDimension:r.width], [_height pixelsValueWithDimension:r.height]); - - CGFloat radiusXPixels = _rx != nil ? [_rx pixelsValue] : 0; - CGFloat radiusYPixels = _ry != nil ? [_ry pixelsValue] : 0; - - if( radiusXPixels == 0 && radiusYPixels == 0 ) - { - CGPathAddRect(path, NULL, rect); - } - else - { - if( radiusXPixels > 0 && radiusYPixels == 0 ) // if RY unspecified, make it equal to RX - radiusYPixels = radiusXPixels; - else if( radiusXPixels == 0 && radiusYPixels > 0 ) // if RX unspecified, make it equal to RY - radiusXPixels = radiusYPixels; - - if( radiusXPixels > CGRectGetWidth(rect) / 2 ) // give RX max value of half rect width - radiusXPixels = CGRectGetWidth(rect) / 2; - - if( radiusYPixels > CGRectGetHeight(rect) / 2 ) // give RY max value of half rect height - radiusYPixels = CGRectGetHeight(rect) / 2; - - CGPathAddRoundedRect(path, -#if !(SVGKIT_UIKIT && __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0) - nil, -#endif - rect, radiusXPixels, radiusYPixels); - } - self.pathForShapeInRelativeCoords = path; - CGPathRelease(path); -} - - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSVGElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSVGElement.h deleted file mode 100644 index 439ccaac99..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSVGElement.h +++ /dev/null @@ -1,132 +0,0 @@ -/** - SVGSVGElement.m - - Represents the "" tag in an SVG file - - http://www.w3.org/TR/SVG/struct.html#InterfaceSVGSVGElement - - readonly attribute SVGAnimatedLength x; - readonly attribute SVGAnimatedLength y; - readonly attribute SVGAnimatedLength width; - readonly attribute SVGAnimatedLength height; - attribute DOMString contentScriptType setraises(DOMException); - attribute DOMString contentStyleType setraises(DOMException); - readonly attribute SVGRect viewport; - readonly attribute float pixelUnitToMillimeterX; - readonly attribute float pixelUnitToMillimeterY; - readonly attribute float screenPixelToMillimeterX; - readonly attribute float screenPixelToMillimeterY; - readonly attribute boolean useCurrentView; - readonly attribute SVGViewSpec currentView; - attribute float currentScale; - readonly attribute SVGPoint currentTranslate; - - unsigned long suspendRedraw(in unsigned long maxWaitMilliseconds); - void unsuspendRedraw(in unsigned long suspendHandleID); - void unsuspendRedrawAll(); - void forceRedraw(); - void pauseAnimations(); - void unpauseAnimations(); - boolean animationsPaused(); - float getCurrentTime(); - void setCurrentTime(in float seconds); - NodeList getIntersectionList(in SVGRect rect, in SVGElement referenceElement); - NodeList getEnclosureList(in SVGRect rect, in SVGElement referenceElement); - boolean checkIntersection(in SVGElement element, in SVGRect rect); - boolean checkEnclosure(in SVGElement element, in SVGRect rect); - void deselectAll(); - SVGNumber createSVGNumber(); - SVGLength createSVGLength(); - SVGAngle createSVGAngle(); - SVGPoint createSVGPoint(); - SVGMatrix createSVGMatrix(); - SVGRect createSVGRect(); - SVGTransform createSVGTransform(); - SVGTransform createSVGTransformFromMatrix(in SVGMatrix matrix); - Element getElementById(in DOMString elementId); - */ - -#import "DocumentCSS.h" -#import "SVGFitToViewBox.h" - -#import "SVGElement.h" -#import "SVGViewSpec.h" - -#pragma mark - the SVG* types (SVGLength, SVGNumber, etc) -#import "SVGAngle.h" -#import "SVGLength.h" -#import "SVGNumber.h" -#import "SVGPoint.h" -#import "SVGRect.h" -#import "SVGTransform.h" - -#pragma mark - a few raw DOM imports are required for SVG DOM, but not many -#import "Element.h" -#import "NodeList.h" - -#import "ConverterSVGToCALayer.h" -#import "SVGKSource.h" - -@interface SVGSVGElement : SVGElement < DocumentCSS, SVGFitToViewBox, /* FIXME: refactor and delete this, it's in violation of the spec: */ ConverterSVGToCALayer > - - - -@property (nonatomic, strong, readonly) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* x; -@property (nonatomic, strong, readonly) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* y; -@property (nonatomic, strong, readonly) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* width; -@property (nonatomic, strong, readonly) /*FIXME: should be SVGAnimatedLength instead*/ SVGLength* height; -@property (nonatomic, strong, readonly) NSString* contentScriptType; -@property (nonatomic, strong, readonly) NSString* contentStyleType; - -/** - "The position and size of the viewport (implicit or explicit) that corresponds to this ‘svg’ element. When the user agent is actually rendering the content, then the position and size values represent the actual values when rendering. The position and size values are unitless values in the coordinate system of the parent element. If no parent element exists (i.e., ‘svg’ element represents the root of the document tree), if this SVG document is embedded as part of another document (e.g., via the HTML ‘object’ element), then the position and size are unitless values in the coordinate system of the parent document. (If the parent uses CSS or XSL layout, then unitless values represent pixel units for the current CSS or XSL viewport, as described in the CSS2 specification.) If the parent element does not have a coordinate system, then the user agent should provide reasonable default values for this attribute." - */ -@property (nonatomic, readonly) SVGRect viewport; -@property (nonatomic, readonly) float pixelUnitToMillimeterX; -@property (nonatomic, readonly) float pixelUnitToMillimeterY; -@property (nonatomic, readonly) float screenPixelToMillimeterX; -@property (nonatomic, readonly) float screenPixelToMillimeterY; -@property (nonatomic, readonly) BOOL useCurrentView; -@property (nonatomic, strong, readonly) SVGViewSpec* currentView; -@property (nonatomic, readonly) float currentScale; -@property (nonatomic, strong, readonly) SVGPoint* currentTranslate; -@property (nonatomic, strong, readwrite) SVGKSource *source; - --(long) suspendRedraw:(long) maxWaitMilliseconds; --(void) unsuspendRedraw:(long) suspendHandleID; --(void) unsuspendRedrawAll; --(void) forceRedraw; --(void) pauseAnimations; --(void) unpauseAnimations; --(BOOL) animationsPaused; --(float) getCurrentTime; --(void) setCurrentTime:(float) seconds; --(NodeList*) getIntersectionList:(SVGRect) rect referenceElement:(SVGElement*) referenceElement; --(NodeList*) getEnclosureList:(SVGRect) rect referenceElement:(SVGElement*) referenceElement; --(BOOL) checkIntersection:(SVGElement*) element rect:(SVGRect) rect; --(BOOL) checkEnclosure:(SVGElement*) element rect:(SVGRect) rect; --(void) deselectAll; --(SVGNumber) createSVGNumber; --(SVGLength*) createSVGLength __attribute__((ns_returns_retained)); --(SVGAngle*) createSVGAngle; --(SVGPoint*) createSVGPoint; --(SVGMatrix*) createSVGMatrix; --(SVGRect) createSVGRect; --(SVGTransform*) createSVGTransform; --(SVGTransform*) createSVGTransformFromMatrix:(SVGMatrix*) matrix; --(Element*) getElementById:(NSString*) elementId; - -#pragma mark - below here VIOLATES THE STANDARD, but needs to be CAREFULLY merged with spec - -- (SVGElement *)findFirstElementOfClass:(Class)classParameter; /**< temporary convenience method until SVGDocument support is complete */ - -#pragma mark - elements REQUIRED to implement the spec but not included in SVG Spec due to bugs in the spec writing! - -@property(nonatomic,readonly) SVGRect requestedViewport; - -/** Required by the spec whenever someone specifies a width and height that disagree with the viewbox they also specified */ -@property(readonly) double aspectRatioFromWidthPerHeight; -/** Required by the spec whenever someone specifies a width and height that disagree with the viewbox they also specified */ -@property(readonly) double aspectRatioFromViewBox; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSVGElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSVGElement.m deleted file mode 100644 index 00fa693d31..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSVGElement.m +++ /dev/null @@ -1,282 +0,0 @@ -#import "SVGSVGElement.h" - -#import "SVGSVGElement_Mutable.h" -#import "CALayerWithChildHitTest.h" -#import "DOMHelperUtilities.h" -#import "SVGHelperUtilities.h" - -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) - -@interface SVGSVGElement() -#pragma mark - elements REQUIRED to implement the spec but not included in SVG Spec due to bugs in the spec writing! -@property(nonatomic,readwrite) SVGRect requestedViewport; -@end - -@implementation SVGSVGElement - -@synthesize x; -@synthesize y; -@synthesize width; -@synthesize height; -@synthesize contentScriptType; -@synthesize contentStyleType; -@synthesize viewport; -@synthesize pixelUnitToMillimeterX; -@synthesize pixelUnitToMillimeterY; -@synthesize screenPixelToMillimeterX; -@synthesize screenPixelToMillimeterY; -@synthesize useCurrentView; -@synthesize currentView; -@synthesize currentScale; -@synthesize currentTranslate; -@synthesize source; - -@synthesize viewBox = _viewBox; // each SVGElement subclass that conforms to protocol "SVGFitToViewBox" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols -@synthesize preserveAspectRatio; // each SVGElement subclass that conforms to protocol "SVGFitToViewBox" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols - -#pragma mark - NON SPEC, violating, properties - --(void)dealloc -{ - self.viewBox = SVGRectUninitialized(); -} - -#pragma mark - CSS Spec methods (via the DocumentCSS protocol) - --(void)loadDefaults -{ - self.styleSheets = [[StyleSheetList alloc] init]; -} -@synthesize styleSheets; - --(CSSStyleDeclaration *)getOverrideStyle:(Element *)element pseudoElt:(NSString *)pseudoElt -{ - NSAssert(FALSE, @"Not implemented yet"); - - return nil; -} - -#pragma mark - SVG Spec methods - --(long) suspendRedraw:(long) maxWaitMilliseconds { NSAssert( FALSE, @"Not implemented yet" ); return 0; } --(void) unsuspendRedraw:(long) suspendHandleID { NSAssert( FALSE, @"Not implemented yet" ); } --(void) unsuspendRedrawAll { NSAssert( FALSE, @"Not implemented yet" ); } --(void) forceRedraw { NSAssert( FALSE, @"Not implemented yet" ); } --(void) pauseAnimations { NSAssert( FALSE, @"Not implemented yet" ); } --(void) unpauseAnimations { NSAssert( FALSE, @"Not implemented yet" ); } --(BOOL) animationsPaused { NSAssert( FALSE, @"Not implemented yet" ); return TRUE; } --(float) getCurrentTime { NSAssert( FALSE, @"Not implemented yet" ); return 0.0; } --(void) setCurrentTime:(float) seconds { NSAssert( FALSE, @"Not implemented yet" ); } --(NodeList*) getIntersectionList:(SVGRect) rect referenceElement:(SVGElement*) referenceElement { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(NodeList*) getEnclosureList:(SVGRect) rect referenceElement:(SVGElement*) referenceElement { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(BOOL) checkIntersection:(SVGElement*) element rect:(SVGRect) rect { NSAssert( FALSE, @"Not implemented yet" ); return FALSE; } --(BOOL) checkEnclosure:(SVGElement*) element rect:(SVGRect) rect { NSAssert( FALSE, @"Not implemented yet" ); return FALSE; } --(void) deselectAll { NSAssert( FALSE, @"Not implemented yet" );} --(SVGNumber) createSVGNumber -{ - SVGNumber n = { 0 }; - return n; -} --(SVGLength*) createSVGLength -{ - return [SVGLength new]; -} --(SVGAngle*) createSVGAngle { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGPoint*) createSVGPoint { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGMatrix*) createSVGMatrix { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGRect) createSVGRect -{ - SVGRect r = { 0.0, 0.0, 0.0, 0.0 }; - return r; -} --(SVGTransform*) createSVGTransform { NSAssert( FALSE, @"Not implemented yet" ); return nil; } --(SVGTransform*) createSVGTransformFromMatrix:(SVGMatrix*) matrix { NSAssert( FALSE, @"Not implemented yet" ); return nil; } - --(Element*) getElementById:(NSString*) elementId -{ - return [DOMHelperUtilities privateGetElementById:elementId childrenOfElement:self]; -} - - -#pragma mark - Objective C methods needed given our current non-compliant SVG Parser - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult { - [super postProcessAttributesAddingErrorsTo:parseResult]; - - /** - Rather unusually, the official SVG Spec uses an explicit "width=100% height=100%" on every - root SVG tag on every TestSuite file - these ARE NOT PRESENT in any of the Spec examples! - - Only in the TestSuite! - - Net effect: we have a major problem with calculating the initial viewport. What does - "100%" mean when you're parsing? - - Literally, from the spec: NOTHING. It's undefined! It's a hint that requires you to have - a parsed SVG already. c.f. other doc notes below, this is complicated and very badly - documented in the SVG Spec. - - ------------- - - For now, we're going to: - - 1. if width or height are percentages, set the viewport to "uninitialized", since they are indeed. - - --- within the spec, "100%" doesn't mean anything. Other percentages are horribly vague in what - they might (or might not) mean. And different SVG renderers treat them differently. Because the - Spec is so poor, probably. - - 2. Assume that our post-parse renderer code (elsewhere in the library, in SVGKImage I believe) - will correctly modify the viewport afterwards. It will lose the percentage, of course, but frankly - this is enough of a brainfck already that any author who uses percentages in their SVG tag needs - to be coached in better authoring anyway! - - --- i.e. their SVG isn't going to render reliably anyway. Whatever they're trying to do, they - should probably do it a different way. - - --- and: it's so damn hard to get a working, non-crashing implmementation here htat handles all - edge-cases, that ... screw it. Life's too short. - - */ - - - /** - If the width + height are missing, we have to get an image width+height from the USER before we even START parsing. - - There is NO SUPPORT IN THE SVG SPEC TO ALLOW THIS. This is strange, but they specified this part badly, so it's not a surprise. - - We would need to put extra (NON STANDARD) properties on SVGDocument, for the "viewport width and height", - and then in *this* method, if we're missing a width or height, take the values from the SVGDocument's temporary/default width height - - (NB: the input to this method "SVGKParseResult" has a .parsedDocument variable, that's how we'd fetch those values here - */ - - NSString* stringWidth = [self getAttribute:@"width"]; - NSString* stringHeight = [self getAttribute:@"height"]; - - NSString* pos_x = [self getAttribute:@"x"]; - NSString* pos_y = [self getAttribute:@"y"]; - - if (pos_x == nil || pos_x.length < 1) - self.x = 0; // i.e. undefined - else - self.x = [SVGLength svgLengthFromNSString:pos_x]; - - if (pos_y == nil || pos_y.length < 1) - self.y = 0; // i.e. undefined - else - self.y = [SVGLength svgLengthFromNSString:pos_y]; - - if( stringWidth == nil || stringWidth.length < 1 ) - self.width = nil; // i.e. undefined - else - self.width = [SVGLength svgLengthFromNSString:[self getAttribute:@"width"]]; - - if( stringHeight == nil || stringHeight.length < 1 ) - self.height = nil; // i.e. undefined - else - self.height = [SVGLength svgLengthFromNSString:[self getAttribute:@"height"]]; - - /** - WARNING: SVG TestSuite sets SVG element width and height to 100%, which are meaningless - and impossible to calculate at parsetime (they are defined as undefined until you "negotiate" - with the OS / Application / etc -- which won't be possible until you've finished the parse). - - So ... they end up being 0 here. To workaround that, we set them to nil if they are percentages - here. ONLY for the SVG tag though. - */ - if( self.width.unitType == SVG_LENGTHTYPE_PERCENTAGE ) - self.width = nil; - if( self.height.unitType == SVG_LENGTHTYPE_PERCENTAGE ) - self.height = nil; - - /* set the frameRequestedViewport appropriately (NB: spec doesn't allow for this but it REQUIRES it to be done and saved!) */ - if( self.width != nil && self.height != nil ) - self.requestedViewport = SVGRectMake( [self.x pixelsValue], [self.y pixelsValue], [self.width pixelsValue], [self.height pixelsValue] ); - else - self.requestedViewport = SVGRectUninitialized(); - - - /** - NB: this is VERY CONFUSING due to badly written SVG Spec, but: the viewport MUST NOT be set by the parser, - it MUST ONLY be set by the "renderer" -- and the renderer MAY have decided to use a different viewport from - the one that the SVG file *implies* (e.g. if the user scales the SVG, the viewport WILL BE DIFFERENT, - by definition! - - ...However: the renderer will ALWAYS start with the default viewport values (that are calcualted by the parsing process) - and it makes it much cleaner and safer to implement if we have the PARSER set the viewport initially - - (and the renderer will IMMEDIATELY overwrite them once the parsing is finished IFF IT NEEDS TO) - */ - self.viewport = self.requestedViewport; // renderer can/will change the .viewport, but .requestedViewport can only be set by the PARSER - - if( [[self getAttribute:@"viewBox"] length] > 0 ) - { - NSArray* boxElements = [[self getAttribute:@"viewBox"] componentsSeparatedByString:@" "]; - if ([boxElements count] < 2) { - /* count should be 4 -- maybe they're comma separated like (x,y,w,h) */ - boxElements = [[self getAttribute:@"viewBox"] componentsSeparatedByString:@","]; - } - _viewBox = SVGRectMake([[boxElements objectAtIndex:0] floatValue], [[boxElements objectAtIndex:1] floatValue], [[boxElements objectAtIndex:2] floatValue], [[boxElements objectAtIndex:3] floatValue]); - } - else - { - self.viewBox = SVGRectUninitialized(); // VERY IMPORTANT: we MUST make it clear this was never initialized, instead of saying its 0,0,0,0 ! - } - - [SVGHelperUtilities parsePreserveAspectRatioFor:self]; - - if( stringWidth == nil || stringWidth.length < 1 ) - self.width = nil; // i.e. undefined - else - self.width = [SVGLength svgLengthFromNSString:[self getAttribute:@"width"]]; - // logging - SVGKitLogVerbose(@"[%@] DEBUG INFO: set document viewBox = %@", [self class], NSStringFromSVGRect(self.viewBox)); -} - -- (SVGElement *)findFirstElementOfClass:(Class)classParameter { - for (SVGElement *element in self.childNodes) - { - if ([element isKindOfClass:classParameter]) - return element; - } - - return nil; -} - -- (CALayer *) newLayer -{ - - CALayer* _layer = [CALayerWithChildHitTest layer]; - - [SVGHelperUtilities configureCALayer:_layer usingElement:self]; - - /** tags know exactly what size/shape their layer needs to be - it's explicit in their width + height attributes! */ - CGRect newBoundsFromSVGTag = CGRectFromSVGRect( self.viewport ); - _layer.frame = newBoundsFromSVGTag; // assign to FRAME, not to BOUNDS: Apple has some weird bugs where for particular numeric values (!) assignment to bounds will cause the origin to jump away from (0,0)! - - return _layer; -} - -- (void)layoutLayer:(CALayer *)layer { - - /** - According to the SVG spec ... what this method originaly did is illegal. I've deleted all of it, and now a few more SVG's render correctly, that - previously were rendering with strange offsets at the top level - */ -} - -#pragma mark - elements REQUIRED to implement the spec but not included in SVG Spec due to bugs in the spec writing! - --(double)aspectRatioFromWidthPerHeight -{ - return [self.height pixelsValue] == 0 ? 0 : [self.width pixelsValue] / [self.height pixelsValue]; -} - --(double)aspectRatioFromViewBox -{ - return self.viewBox.height == 0 ? 0 : self.viewBox.width / self.viewBox.height; -} - - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleCatcher.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleCatcher.h deleted file mode 100644 index a77a5685f4..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleCatcher.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// SVGStyelCatcher.h -// StyleTouch -// -// Created by Kevin Stich on 3/6/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#ifndef StyleTouch_SVGStyelCatcher_h -#define StyleTouch_SVGStyelCatcher_h - -@class SVGElement; - -@protocol SVGStyleCatcher - -//-(void)styleCatchElement:(SVGElement *)styledLayer forClass:(NSString *)colorIndex; -//-(void)styleCatchNewStyle:(NSString *)className; --(void)styleCatchLayer:(CALayer *)styledLayer forClass:(NSString *)colorIndex; --(UIColor *)styleCatchOverrideFill:(NSString *)fillClassName; -@end - - - -#endif diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleElement.h deleted file mode 100644 index b3a25619a7..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleElement.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// SVGStyleElement.h -// SVGPad -// -// Created by Kevin Stich on 2/21/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "SVGElement.h" - -@interface SVGStyleElement : SVGElement - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleElement.m deleted file mode 100644 index 6f145300f4..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGStyleElement.m +++ /dev/null @@ -1,13 +0,0 @@ -// -// SVGStyleElement.m -// SVGPad -// -// Created by Kevin Stich on 2/21/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "SVGStyleElement.h" - -@implementation SVGStyleElement - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSwitchElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSwitchElement.h deleted file mode 100644 index d501852996..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSwitchElement.h +++ /dev/null @@ -1,11 +0,0 @@ - - -#import "SVGElement.h" - -#import "ConverterSVGToCALayer.h" - -@interface SVGSwitchElement : SVGElement - -@property (nonatomic, readonly, strong) NodeList * visibleChildNodes; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSwitchElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSwitchElement.m deleted file mode 100644 index 47eb5e0a63..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGSwitchElement.m +++ /dev/null @@ -1,61 +0,0 @@ - -#import "SVGSwitchElement.h" -#import "CALayerWithChildHitTest.h" -#import "SVGHelperUtilities.h" -#import "NodeList+Mutable.h" - -@implementation SVGSwitchElement - -@synthesize visibleChildNodes = _visibleChildNodes; - - -- (CALayer *) newLayer -{ - CALayer* _layer = [CALayerWithChildHitTest layer]; - - [SVGHelperUtilities configureCALayer:_layer usingElement:self]; - - return _layer; -} - -- (NodeList *)visibleChildNodes -{ - if (_visibleChildNodes) - return _visibleChildNodes; - - _visibleChildNodes = [[NodeList alloc] init]; - - NSString* localLanguage = [[NSLocale preferredLanguages] firstObject]; - - for ( SVGElement *child in self.childNodes ) - { - if ([child conformsToProtocol:@protocol(ConverterSVGToCALayer)]) - { - // spec says if there is no attribute at all then pick it - if (![child hasAttribute:@"systemLanguage"]) - { - [_visibleChildNodes.internalArray addObject:child]; - break; - } - - NSString* languages = [child getAttribute:@"systemLanguage"]; - - NSArray* languageCodes = [languages componentsSeparatedByCharactersInSet: - [NSCharacterSet characterSetWithCharactersInString:@", \t\n\r"]]; - - if ([languageCodes containsObject:localLanguage]) - { - [_visibleChildNodes.internalArray addObject:child]; - break; - } - - } - } - return _visibleChildNodes; -} - -- (void)layoutLayer:(CALayer *)layer -{ - -} -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTextElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTextElement.h deleted file mode 100644 index a07aa7c6ef..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTextElement.h +++ /dev/null @@ -1,14 +0,0 @@ -#import - -#import "SVGTextPositioningElement.h" -#import "ConverterSVGToCALayer.h" -#import "SVGTransformable.h" - -/** - http://www.w3.org/TR/2011/REC-SVG11-20110816/text.html#TextElement - - interface SVGTextElement : SVGTextPositioningElement, SVGTransformable - */ -@interface SVGTextElement : SVGTextPositioningElement - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTextElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTextElement.m deleted file mode 100644 index 79487d3a33..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTextElement.m +++ /dev/null @@ -1,375 +0,0 @@ -#import "SVGTextElement.h" - -#import -#import -#import -#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec) -#import "SVGGradientLayer.h" -#import "SVGHelperUtilities.h" -#import "SVGUtils.h" -#import "SVGTextLayer.h" - -@implementation SVGTextElement - -@synthesize transform; // each SVGElement subclass that conforms to protocol "SVGTransformable" has to re-synthesize this to work around bugs in Apple's Objective-C 2.0 design that don't allow @properties to be extended by categories / protocols - - -- (CALayer *) newLayer -{ - /** - BY DESIGN: we work out the positions of all text in ABSOLUTE space, and then construct the Apple CALayers and CATextLayers around - them, as required. - - Because: Apple's classes REQUIRE us to provide a lot of this info up-front. Sigh - And: SVGKit works by pre-baking everything into position (its faster, and avoids Apple's broken CALayer.transform property) - */ - CGAffineTransform textTransformAbsolute = [SVGHelperUtilities transformAbsoluteIncludingViewportForTransformableOrViewportEstablishingElement:self]; - /** add on the local x,y that will NOT BE iNCLUDED IN THE TRANSFORM - AUTOMATICALLY BECAUSE THEY ARE NOT TRANSFORM COMMANDS IN SVG SPEC!! - -- but they ARE part of the "implicit transform" of text elements!! (bad SVG Spec design :( ) - - NB: the local bits (x/y offset) have to be pre-transformed by - */ - CGRect viewport = CGRectFromSVGRect(self.rootOfCurrentDocumentFragment.viewBox); - CGAffineTransform textTransformAbsoluteWithLocalPositionOffset = CGAffineTransformConcat( CGAffineTransformMakeTranslation( [self.x pixelsValueWithDimension:viewport.size.width], [self.y pixelsValueWithDimension:viewport.size.height]), textTransformAbsolute); - - /** - Apple's CATextLayer is poor - one of those classes Apple hasn't finished writing? - - It's incompatible with UIFont (Apple states it is so), and it DOES NOT WORK by default: - - If you assign a font, and a font size, and text ... you get a blank empty layer of - size 0,0 - - Because Apple requires you to ALSO do all the work of calculating the font size, shape, - position etc. - - But its the easiest way to get FULL control over size/position/rotation/etc in a CALayer - */ - - /** - Create font based on many information (font-family, font-weight, etc), fallback to system font when there are no available font matching the information. - */ - UIFont *font = [SVGTextElement matchedFontWithElement:self]; - - /** Convert the size down using the SVG transform at this point, before we calc the frame size etc */ -// effectiveFontSize = CGSizeApplyAffineTransform( CGSizeMake(0,effectiveFontSize), textTransformAbsolute ).height; // NB important that we apply a transform to a "CGSize" here, so that Apple's library handles worrying about whether to ignore skew transforms etc - - /** Convert all whitespace to spaces, and trim leading/trailing (SVG doesn't support leading/trailing whitespace, and doesnt support CR LF etc) */ - - NSString* effectiveText = self.textContent; // FIXME: this is a TEMPORARY HACK, UNTIL PROPER PARSING OF ELEMENTS IS ADDED - - effectiveText = [effectiveText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - effectiveText = [effectiveText stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; - - /** - Stroke color && stroke width - Apple's `CATextLayer` can not stroke gradient on the layer (we can only fill the layer) - */ - CGColorRef strokeColor = [SVGHelperUtilities parseStrokeForElement:self]; - CGFloat strokeWidth = 0; - NSString* actualStrokeWidth = [self cascadedValueForStylableProperty:@"stroke-width"]; - if (actualStrokeWidth) - { - SVGRect r = ((SVGSVGElement*)self.viewportElement).viewport; - strokeWidth = [[SVGLength svgLengthFromNSString:actualStrokeWidth] - pixelsValueWithDimension: hypot(r.width, r.height)]; - } - - /** - Fill color - Apple's `CATextLayer` can be filled using mask. - */ - CGColorRef fillColor = [SVGHelperUtilities parseFillForElement:self]; - - /** Calculate - - 1. Create an attributed string (Apple's APIs are hard-coded to require this) - 2. Set the font to be the correct one + correct size for whole string, inside the string - 3. Ask apple how big the final thing should be - 4. Use that to provide a layer.frame - */ - NSMutableAttributedString* attributedString = [[NSMutableAttributedString alloc] initWithString:effectiveText]; - NSRange stringRange = NSMakeRange(0, attributedString.string.length); - [attributedString addAttribute:NSFontAttributeName - value:font - range:stringRange]; - if (fillColor) { - [attributedString addAttribute:NSForegroundColorAttributeName - value:(__bridge id)fillColor - range:stringRange]; - } - if (strokeWidth != 0 && strokeColor) { - [attributedString addAttribute:NSStrokeColorAttributeName - value:(__bridge id)strokeColor - range:stringRange]; - // If both fill && stroke, pass negative value; only fill, pass positive value - // A typical value for outlined text is 3.0. Actually this is not so accurate, but until we directly draw the text glyph using Core Text, we can not control the detailed stroke width follow SVG spec - CGFloat strokeValue = strokeWidth / 3.0; - if (fillColor) { - strokeValue = -strokeValue; - } - [attributedString addAttribute:NSStrokeWidthAttributeName - value:@(strokeValue) - range:stringRange]; - } - CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString( (CFMutableAttributedStringRef) attributedString ); - CGSize suggestedUntransformedSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX), NULL); - CFRelease(framesetter); - - CGRect unTransformedFinalBounds = CGRectMake( 0, - 0, - suggestedUntransformedSize.width, - suggestedUntransformedSize.height); // everything's been pre-scaled by [self transformAbsolute] - - CATextLayer *label = [SVGTextLayer layer]; - [SVGHelperUtilities configureCALayer:label usingElement:self]; - - /** This is complicated for three reasons. - Partly: Apple and SVG use different defitions for the "origin" of a piece of text - Partly: Bugs in Apple's CoreText - Partly: flaws in Apple's CALayer's handling of frame,bounds,position,anchorPoint,affineTransform - - 1. CALayer.frame DOES NOT EXIST AS A REAL PROPERTY - if you read Apple's docs you eventually realise it is fake. Apple explicitly says it is "not defined". They should DELETE IT from their API! - 2. CALayer.bounds and .position ARE NOT AFFECTED BY .affineTransform - only the contents of the layer is affected - 3. SVG defines two SEMI-INCOMPATIBLE ways of positioning TEXT objects, that we have to correctly combine here. - 4. So ... to apply a transform to the layer text: - i. find the TRANSFORM - ii. merge it with the local offset (.x and .y from SVG) - which defaults to (0,0) - iii. apply that to the layer - iv. set the position to 0 - v. BECAUSE SVG AND APPLE DEFINE ORIGIN DIFFERENTLY: subtract the "untransformed" height of the font ... BUT: pre-transformed ONLY BY the 'multiplying (non-translating)' part of the TRANSFORM. - vi. set the bounds to be (whatever Apple's CoreText says is necessary to render TEXT at FONT SIZE, with NO TRANSFORMS) - */ - label.bounds = unTransformedFinalBounds; - - /** NB: specific to Apple: the "origin" is the TOP LEFT corner of first line of text, whereas SVG uses the font's internal origin - (which is BOTTOM LEFT CORNER OF A LETTER SUCH AS 'a' OR 'x' THAT SITS ON THE BASELINE ... so we have to make the FRAME start "font leading" higher up - - WARNING: Apple's font-rendering system has some nasty bugs (c.f. StackOverflow) - - We TRIED to use the font's built-in numbers to correct the position, but Apple's own methods often report incorrect values, - and/or Apple has deprecated REQUIRED methods in their API (with no explanation - e.g. "font leading") - - If/when Apple fixes their bugs - or if you know enough about their API's to workaround the bugs, feel free to fix this code. - */ - CTLineRef line = CTLineCreateWithAttributedString( (CFMutableAttributedStringRef) attributedString ); - CGFloat ascent = 0; - CTLineGetTypographicBounds(line, &ascent, NULL, NULL); - CFRelease(line); - CGFloat offsetToConvertSVGOriginToAppleOrigin = -ascent; - CGSize fakeSizeToApplyNonTranslatingPartsOfTransform = CGSizeMake( 0, offsetToConvertSVGOriginToAppleOrigin); - - label.position = CGPointMake( 0, - 0 + CGSizeApplyAffineTransform( fakeSizeToApplyNonTranslatingPartsOfTransform, textTransformAbsoluteWithLocalPositionOffset).height); - - NSString *textAnchor = [self cascadedValueForStylableProperty:@"text-anchor"]; - if( [@"middle" isEqualToString:textAnchor] ) - label.anchorPoint = CGPointMake(0.5, 0.0); - else if( [@"end" isEqualToString:textAnchor] ) - label.anchorPoint = CGPointMake(1.0, 0.0); - else - label.anchorPoint = CGPointZero; // WARNING: SVG applies transforms around the top-left as origin, whereas Apple defaults to center as origin, so we tell Apple to work "like SVG" here. - - label.affineTransform = textTransformAbsoluteWithLocalPositionOffset; - label.string = [attributedString copy]; - label.alignmentMode = kCAAlignmentLeft; - -#if SVGKIT_MAC - label.contentsScale = [[NSScreen mainScreen] backingScaleFactor]; -#else - label.contentsScale = [[UIScreen mainScreen] scale]; -#endif - - return [self newCALayerForTextLayer:label transformAbsolute:textTransformAbsolute]; - - /** VERY USEFUL when trying to debug text issues: - label.backgroundColor = [UIColor colorWithRed:0.5 green:0 blue:0 alpha:0.5].CGColor; - label.borderColor = [UIColor redColor].CGColor; - //DEBUG: SVGKitLogVerbose(@"font size %2.1f at %@ ... final frame of layer = %@", effectiveFontSize, NSStringFromCGPoint(transformedOrigin), NSStringFromCGRect(label.frame)); - */ -} - --(CALayer *) newCALayerForTextLayer:(CATextLayer *)label transformAbsolute:(CGAffineTransform)transformAbsolute -{ - CALayer *fillLayer = label; - NSString* actualFill = [self cascadedValueForStylableProperty:@"fill"]; - - if ( [actualFill hasPrefix:@"url"] ) - { - NSArray *fillArgs = [actualFill componentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceCharacterSet]; - NSString *fillIdArg = fillArgs.firstObject; - NSRange idKeyRange = NSMakeRange(5, fillIdArg.length - 6); - NSString* fillId = [fillIdArg substringWithRange:idKeyRange]; - - /** Replace the return layer with a special layer using the URL fill */ - /** fetch the fill layer by URL using the DOM */ - SVGGradientLayer *gradientLayer = [SVGHelperUtilities getGradientLayerWithId:fillId forElement:self withRect:label.frame transform:transformAbsolute]; - if (gradientLayer) { - gradientLayer.mask = label; - fillLayer = gradientLayer; - } else { - // no gradient, fallback - } - } - - NSString* actualOpacity = [self cascadedValueForStylableProperty:@"opacity" inherit:NO]; - fillLayer.opacity = actualOpacity.length > 0 ? [actualOpacity floatValue] : 1; // unusually, the "opacity" attribute defaults to 1, not 0 - - return fillLayer; -} - -/** - Return the best matched font with all posible CSS font property (like `font-family`, `font-size`, etc) - - @param svgElement svgElement - @return The matched font, or fallback to system font, non-nil - */ -+ (UIFont *)matchedFontWithElement:(SVGElement *)svgElement { - // Using top-level API to walkthough all availble font-family - NSString *actualSize = [svgElement cascadedValueForStylableProperty:@"font-size"]; - NSString *actualFamily = [svgElement cascadedValueForStylableProperty:@"font-family"]; - // TODO- Using font descriptor to match best font consider `font-style`, `font-weight` - NSString *actualFontStyle = [svgElement cascadedValueForStylableProperty:@"font-style"]; - NSString *actualFontWeight = [svgElement cascadedValueForStylableProperty:@"font-weight"]; - NSString *actualFontStretch = [svgElement cascadedValueForStylableProperty:@"font-stretch"]; - - CGFloat effectiveFontSize = (actualSize.length > 0) ? [actualSize floatValue] : 12; // I chose 12. I couldn't find an official "default" value in the SVG spec. - - NSArray *actualFontFamilies = [SVGTextElement fontFamiliesWithCSSValue:actualFamily]; - NSString *matchedFontFamily; - if (actualFontFamilies) { - // walkthrough all available font-families to find the best matched one - NSSet *availableFontFamilies; -#if SVGKIT_MAC - availableFontFamilies = [NSSet setWithArray:NSFontManager.sharedFontManager.availableFontFamilies]; -#else - availableFontFamilies = [NSSet setWithArray:UIFont.familyNames]; -#endif - for (NSString *fontFamily in actualFontFamilies) { - if ([availableFontFamilies containsObject:fontFamily]) { - matchedFontFamily = fontFamily; - break; - } - } - } - - // we provide enough hint information, let Core Text using their algorithm to detect which fontName should be used - // if `matchedFontFamily` is nil, use the system default font family instead (allows `font-weight` these information works) - NSDictionary *attributes = [self fontAttributesWithFontFamily:matchedFontFamily fontStyle:actualFontStyle fontWeight:actualFontWeight fontStretch:actualFontStretch]; - CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes((__bridge CFDictionaryRef)attributes); - CTFontRef fontRef = CTFontCreateWithFontDescriptor(descriptor, effectiveFontSize, NULL); - UIFont *font = (__bridge_transfer UIFont *)fontRef; - - return font; -} - -/** - Convert CSS font detailed information into Core Text descriptor attributes (determine the best matched font). - - @param fontFamily fontFamily - @param fontStyle fontStyle - @param fontWeight fontWeight - @param fontStretch fontStretch - @return Core Text descriptor attributes - */ -+ (NSDictionary *)fontAttributesWithFontFamily:(NSString *)fontFamily fontStyle:(NSString *)fontStyle fontWeight:(NSString *)fontWeight fontStretch:(NSString *)fontStretch { - // Default value - if (!fontFamily.length) fontFamily = [self systemDefaultFontFamily]; - if (!fontStyle.length) fontStyle = @"normal"; - if (!fontWeight.length) fontWeight = @"normal"; - if (!fontStretch.length) fontStretch = @"normal"; - - NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; - attributes[(__bridge NSString *)kCTFontFamilyNameAttribute] = fontFamily; - // font-weight is in the sub-dictionary - NSMutableDictionary *traits = [NSMutableDictionary dictionary]; - // CSS font weight is from 0-1000 - CGFloat weight; - if ([fontWeight isEqualToString:@"normal"]) { - weight = 400; - } else if ([fontWeight isEqualToString:@"bold"]) { - weight = 700; - } else if ([fontWeight isEqualToString:@"bolder"]) { - weight = 900; - } else if ([fontWeight isEqualToString:@"lighter"]) { - weight = 100; - } else { - CGFloat value = [fontWeight doubleValue]; - weight = MIN(MAX(value, 1), 1000); - } - // map from CSS [1, 1000] to Core Text [-1.0, 1.0], 400 represent 0.0 - CGFloat coreTextFontWeight; - if (weight < 400) { - coreTextFontWeight = (weight - 400) / 1000 * (1 / 0.4); - } else { - coreTextFontWeight = (weight - 400) / 1000 * (1 / 0.6); - } - - // CSS font style - CTFontSymbolicTraits style = 0; - if ([fontStyle isEqualToString:@"normal"]) { - style |= 0; - } else if ([fontStyle isEqualToString:@"italic"] || [fontStyle rangeOfString:@"oblique"].location != NSNotFound) { - // Actually we can control the detailed slant degree via `kCTFontSlantTrait`, but it's rare usage so treat them the same, TODO in the future - style |= kCTFontItalicTrait; - } - - // CSS font stretch - if ([fontStretch rangeOfString:@"condensed"].location != NSNotFound) { - // Actually we can control the detailed percent via `kCTFontWidthTrait`, but it's rare usage so treat them the same, TODO in the future - style |= kCTFontTraitCondensed; - } else if ([fontStretch rangeOfString:@"expanded"].location != NSNotFound) { - style |= kCTFontTraitExpanded; - } - - traits[(__bridge NSString *)kCTFontSymbolicTrait] = @(style); - traits[(__bridge NSString *)kCTFontWeightTrait] = @(coreTextFontWeight); - attributes[(__bridge NSString *)kCTFontTraitsAttribute] = [traits copy]; - - return [attributes copy]; -} - -/** - Parse the `font-family` CSS value into array of font-family name - - @param value value - @return array of font-family name - */ -+ (NSArray *)fontFamiliesWithCSSValue:(NSString *)value { - if (value.length == 0) { - return nil; - } - NSArray *args = [value componentsSeparatedByString:@","]; - if (args.count == 0) { - return nil; - } - NSMutableArray *fontFamilies = [NSMutableArray arrayWithCapacity:args.count]; - for (NSString *arg in args) { - // parse: font-family: "Goudy Bookletter 1911", sans-serif; - // delete "" - NSString *fontFamily = [arg stringByReplacingOccurrencesOfString:@"\"" withString:@""]; - // trim white space - [fontFamily stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet]; - [fontFamilies addObject:fontFamily]; - } - - return [fontFamilies copy]; -} - -+ (NSString *)systemDefaultFontFamily { - static dispatch_once_t onceToken; - static NSString *fontFamily; - dispatch_once(&onceToken, ^{ - UIFont *font = [UIFont systemFontOfSize:12.f]; - fontFamily = font.familyName; - }); - return fontFamily; -} - -- (void)layoutLayer:(CALayer *)layer -{ - -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTitleElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTitleElement.h deleted file mode 100644 index 35c862c3a4..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTitleElement.h +++ /dev/null @@ -1,12 +0,0 @@ -// -// SVGTitleElement.h -// SVGKit -// -// Copyright Matt Rajca 2010-2011. All rights reserved. -// - -#import "SVGElement.h" - -@interface SVGTitleElement : SVGElement { } - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTitleElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTitleElement.m deleted file mode 100644 index 42b6c55b5f..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/SVGTitleElement.m +++ /dev/null @@ -1,16 +0,0 @@ -// -// SVGTitleElement.m -// SVGKit -// -// Copyright Matt Rajca 2010. All rights reserved. -// - -#import "SVGTitleElement.h" - -@implementation SVGTitleElement - -+ (BOOL)shouldStoreContent { - return YES; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/TinySVGTextAreaElement.h b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/TinySVGTextAreaElement.h deleted file mode 100644 index a63ccff0a4..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/TinySVGTextAreaElement.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// TinySVGTextAreaElement.h -// SVGKit-iOS -// -// Created by David Gileadi on 8/26/14. -// Copyright (c) 2014 na. All rights reserved. -// - -#import "SVGTextElement.h" - -@interface TinySVGTextAreaElement : SVGTextElement - -@property(nonatomic,strong,readonly) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ width; -@property(nonatomic,strong,readonly) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ height; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/TinySVGTextAreaElement.m b/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/TinySVGTextAreaElement.m deleted file mode 100644 index 6ff618765e..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/DOM classes/Unported or Partial DOM/TinySVGTextAreaElement.m +++ /dev/null @@ -1,65 +0,0 @@ -// -// TinySVGTextAreaElement.m -// SVGKit-iOS -// -// Created by David Gileadi on 8/26/14. -// Copyright (c) 2014 na. All rights reserved. -// - -#import "TinySVGTextAreaElement.h" -#import "SVGKParseResult.h" -#import "SVGElement_ForParser.h" - - -@interface TinySVGTextAreaElement() -@property(nonatomic,strong,readwrite) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ width; -@property(nonatomic,strong,readwrite) SVGLength* /* FIXME: should be SVGAnimatedLengthList */ height; -@end - - -@implementation TinySVGTextAreaElement - -@synthesize width; -@synthesize height; - - -- (void)postProcessAttributesAddingErrorsTo:(SVGKParseResult *)parseResult -{ - [super postProcessAttributesAddingErrorsTo:parseResult]; - - self.width = [self getAttributeAsSVGLength:@"width"]; - self.height = [self getAttributeAsSVGLength:@"height"]; -} - -- (CALayer *) newLayer -{ - CATextLayer *label = (CATextLayer *) [super newLayer]; - - label.wrapped = YES; - - float w = [self.width pixelsValue]; - float h = [self.height pixelsValue]; - if( w > 0 && h > 0 ) { - if( w == 0.0f ) - w = label.bounds.size.width; - if( h == 0.0f ) - h = label.bounds.size.height; - label.bounds = CGRectMake(0, 0, w, h); - } - - NSString* textAlign = [self cascadedValueForStylableProperty:@"text-align"]; - if( [@"start" isEqualToString:textAlign] ) - label.alignmentMode = kCAAlignmentLeft; - else if( [@"center" isEqualToString:textAlign] ) - label.alignmentMode = kCAAlignmentCenter; - else if( [@"end" isEqualToString:textAlign] ) - label.alignmentMode = kCAAlignmentRight; - else if( [@"justify" isEqualToString:textAlign] ) - label.alignmentMode = kCAAlignmentJustified; - - label.position = CGPointZero; - - return label; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterNSData.h b/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterNSData.h deleted file mode 100644 index 497bd7c00d..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterNSData.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - General-purpose exporter from loaded-SVGKImage object into an NSData byte-array. - - Uses the default color format from [SVGKImage+CGContext newCGContextAutosizedToFit] (currently RGBA / CGColorSpaceCreateDeviceRGB) - */ -#import -#import "SVGKImage.h" - -@interface SVGKExporterNSData : NSObject - -/** - Highest-performance version of .UIImage property (this minimizes memory usage and can lead to large speed-ups e.g. when using SVG images as textures with OpenGLES) - - Delegates to [ exportAsNSData:... flipYaxis:TRUE] - */ -+(NSData*) exportAsNSData:(SVGKImage*) image; - -/** - Highest-performance version of .UIImage property (this minimizes memory usage and can lead to large speed-ups e.g. when using SVG images as textures with OpenGLES) - - Delegates to exportAsNSData:... antiAliased:TRUE curveFlatnessFactor:1.0 interpolationQuality:kCGInterpolationDefault flipYaxis:...] -*/ -+(NSData*) exportAsNSData:(SVGKImage*) image flipYaxis:(BOOL) flipYaxis; - -/** - Highest-performance version of .UIImage property (this minimizes memory usage and can lead to large speed-ups e.g. when using SVG images as textures with OpenGLES) - - NB: we could probably achieve get even higher performance in OpenGL by sidestepping NSData entirely and using raw byte arrays (should result in zero-copy). - - @param shouldAntialias = Apple defaults to TRUE, but turn it off for small speed boost - @param multiplyFlatness = how many pixels a curve can be flattened by (Apple's internal setting) to make it faster to render but less accurate - @param interpolationQuality = Apple internal setting, c.f. Apple docs for CGInterpolationQuality - */ -+(NSData*) exportAsNSData:(SVGKImage*) image antiAliased:(BOOL) shouldAntialias curveFlatnessFactor:(CGFloat) multiplyFlatness interpolationQuality:(CGInterpolationQuality) interpolationQuality flipYaxis:(BOOL) flipYaxis; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterNSData.m b/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterNSData.m deleted file mode 100644 index 2afccbac96..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterNSData.m +++ /dev/null @@ -1,32 +0,0 @@ -#import "SVGKExporterNSData.h" - -#import "SVGKImage+CGContext.h" // needed for Context calls - -@implementation SVGKExporterNSData - -+(NSData*) exportAsNSData:(SVGKImage*) image -{ - return [self exportAsNSData:image flipYaxis:FALSE]; -} - -+(NSData*) exportAsNSData:(SVGKImage*) image flipYaxis:(BOOL) flipYaxis -{ - return [self exportAsNSData:image antiAliased:TRUE curveFlatnessFactor:1.0 interpolationQuality:kCGInterpolationDefault flipYaxis:flipYaxis]; -} - -+(NSData*) exportAsNSData:(SVGKImage*) image antiAliased:(BOOL) shouldAntialias curveFlatnessFactor:(CGFloat) multiplyFlatness interpolationQuality:(CGInterpolationQuality) interpolationQuality flipYaxis:(BOOL) flipYaxis -{ - CGContextRef newContext = [image newCGContextAutosizedToFit]; - - [image renderToContext:newContext antiAliased:shouldAntialias curveFlatnessFactor:multiplyFlatness interpolationQuality:interpolationQuality flipYaxis: flipYaxis]; - - void* resultAsVoidStar = CGBitmapContextGetData(newContext); - - size_t dataSize = 4 * image.size.width * image.size.height; // RGBA = 4 8-bit components - NSData* result = [NSData dataWithBytes:resultAsVoidStar length:dataSize]; - - CGContextRelease(newContext); - - return result; -} -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterUIImage.h b/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterUIImage.h deleted file mode 100644 index ed8d9ca298..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterUIImage.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - General-purpose exporter from loaded-SVGKImage object into a new, rasterised UIImage. - - Uses the default color format from UIGraphicsBeginImageContextWithOptions(...) - */ -#import -#import "SVGKImage.h" - -@interface SVGKExporterUIImage : NSObject - -/** - Higher-performance version of .UIImage property (the property uses this method, but you can tweak the parameters for better performance / worse accuracy) - - NB: you can get BETTER performance using the exportNSDataAntiAliased: version of this method, becuase you bypass Apple's slow code for making UIImage objects - - Delegates to exportAsUIImage:... antiAliased:TRUE curveFlatnessFactor:1.0 interpolationQuality:kCGInterpolationDefault] - */ -+(UIImage*) exportAsUIImage:(SVGKImage*) image; - -/** - Higher-performance version of .UIImage property (the property uses this method, but you can tweak the parameters for better performance / worse accuracy) - - NB: you can get BETTER performance using the exportNSDataAntiAliased: version of this method, becuase you bypass Apple's slow code for making UIImage objects - - @param shouldAntialias = Apple defaults to TRUE, but turn it off for small speed boost - @param multiplyFlatness = how many pixels a curve can be flattened by (Apple's internal setting) to make it faster to render but less accurate - @param interpolationQuality = Apple internal setting, c.f. Apple docs for CGInterpolationQuality - */ -+(UIImage*) exportAsUIImage:(SVGKImage*) image antiAliased:(BOOL) shouldAntialias curveFlatnessFactor:(CGFloat) multiplyFlatness interpolationQuality:(CGInterpolationQuality) interpolationQuality; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterUIImage.m b/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterUIImage.m deleted file mode 100644 index d218e0f0a1..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKExporterUIImage.m +++ /dev/null @@ -1,37 +0,0 @@ -#import "SVGKExporterUIImage.h" - -#import "SVGKImage+CGContext.h" // needed for Context calls - -@implementation SVGKExporterUIImage - -+(UIImage*) exportAsUIImage:(SVGKImage *)image -{ - return [self exportAsUIImage:image antiAliased:TRUE curveFlatnessFactor:1.0 interpolationQuality:kCGInterpolationDefault]; -} - -+(UIImage*) exportAsUIImage:(SVGKImage*) image antiAliased:(BOOL) shouldAntialias curveFlatnessFactor:(CGFloat) multiplyFlatness interpolationQuality:(CGInterpolationQuality) interpolationQuality -{ - if( [image hasSize] ) - { - SVGKitLogVerbose(@"[%@] DEBUG: Generating a UIImage using the current root-object's viewport (may have been overridden by user code): {0,0,%2.3f,%2.3f}", [self class], image.size.width, image.size.height); - - UIGraphicsBeginImageContextWithOptions( image.size, FALSE, [UIScreen mainScreen].scale ); - CGContextRef context = UIGraphicsGetCurrentContext(); - - [image renderToContext:context antiAliased:shouldAntialias curveFlatnessFactor:multiplyFlatness interpolationQuality:interpolationQuality flipYaxis:FALSE]; - - UIImage* result = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - - return result; - } - else - { - NSAssert(FALSE, @"You asked to export an SVG to bitmap, but the SVG file has infinite size. Either fix the SVG file, or set an explicit size you want it to be exported at (by calling .size = something on this SVGKImage instance"); - - return nil; - } -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKImage+CGContext.h b/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKImage+CGContext.h deleted file mode 100644 index 28b2daf3a0..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKImage+CGContext.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - Contains methods for low-level exporting of SVGKImage into CGContext's / OpenGL textures / etc - - Process: - 1. Create a CGContextRef; either use your own code (e.g. with OpenGL, you usually want to do this by hand and check PoT), - or use the [self newCGContextAutosizedToFit] method. - 2. Use the renderToContext:::: method (preferred) or the pure, low-level renderInContext: method (not preferred) to - draw into your context - 3. ...do whatever you want with the results (e.g. use one of the Exporters to export it to raw NSData bytes, or similar) - */ -#import "SVGKImage.h" - -@interface SVGKImage (CGContext) - -/** Creates a CGContext with correct pixel size using sizing info from the source SVG (or returns NULL if that's not possible) - */ --(CGContextRef) newCGContextAutosizedToFit; - -/** - WARNING: due to bugs in Apple's code (c.f. CALayer.h header file for notes from Apple - they say "use caution"), - this method is NOT a perfect render of CA; it uses Apple's own "approximation", as used in [CALayer renderInContext:], - which ignores e.g. masking and some other CA core features - - Generally, for performance and safety, you should use renderToContext:antiAliased:curveFlatnessFactor:interpolationQuality:flipYaxis: - instead of this method (it performs checks and optional performance optimizations) - */ -- (void)renderInContext:(CGContextRef)ctx; - -/** - The standard basic method used by all the different "export..." methods in this class and others - */ --(void) renderToContext:(CGContextRef) context antiAliased:(BOOL) shouldAntialias curveFlatnessFactor:(CGFloat) multiplyFlatness interpolationQuality:(CGInterpolationQuality) interpolationQuality flipYaxis:(BOOL) flipYaxis; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKImage+CGContext.m b/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKImage+CGContext.m deleted file mode 100644 index 7e402f4f07..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Exporters/SVGKImage+CGContext.m +++ /dev/null @@ -1,98 +0,0 @@ -// -// SVGKImage+CGContext.m -// SVGKit-iOS -// -// Created by adam on 22/12/2013. -// Copyright (c) 2013 na. All rights reserved. -// - -#import "SVGKImage+CGContext.h" - -#import "SVGRect.h" -#import "SVGSVGElement.h" - -@implementation SVGKImage (CGContext) - --(CGContextRef) newCGContextAutosizedToFit -{ - NSAssert( [self hasSize], @"Cannot export this image because the SVG file has infinite size. Either fix the SVG file, or set an explicit size you want it to be exported at (by calling .size = something on this SVGKImage instance"); - if( ! [self hasSize] ) - return NULL; - - SVGKitLogVerbose(@"[%@] DEBUG: Generating a CGContextRef using the current root-object's viewport (may have been overridden by user code): {0,0,%2.3f,%2.3f}", [self class], self.size.width, self.size.height); - - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef context = CGBitmapContextCreate( NULL/*malloc( self.size.width * self.size.height * 4 )*/, self.size.width, self.size.height, 8, 4 * self.size.width, colorSpace, (CGBitmapInfo)kCGImageAlphaNoneSkipLast ); - CGColorSpaceRelease( colorSpace ); - - return context; -} - -- (void)renderInContext:(CGContextRef)ctx -{ - [self.CALayerTree renderInContext:ctx]; -} - -/** - Shared between multiple different "export..." methods - */ --(void) renderToContext:(CGContextRef) context antiAliased:(BOOL) shouldAntialias curveFlatnessFactor:(CGFloat) multiplyFlatness interpolationQuality:(CGInterpolationQuality) interpolationQuality flipYaxis:(BOOL) flipYaxis -{ - NSAssert( [self hasSize], @"Cannot scale this image because the SVG file has infinite size. Either fix the SVG file, or set an explicit size you want it to be exported at (by calling .size = something on this SVGKImage instance"); - - NSDate* startTime; - - startTime = [NSDate date]; - - if( SVGRectIsInitialized(self.DOMTree.viewport) ) - SVGKitLogInfo(@"[%@] DEBUG: rendering to CGContext using the current root-object's viewport (may have been overridden by user code): %@", [self class], NSStringFromSVGRect(self.DOMTree.viewport) ); - - /** Typically a 10% performance improvement right here */ - if( !shouldAntialias ) - CGContextSetShouldAntialias( context, FALSE ); - - /** Apple refuses to let you reset this, because they are selfish */ - CGContextSetFlatness( context, multiplyFlatness ); - - /** Apple's own performance hints system */ - CGContextSetInterpolationQuality( context, interpolationQuality ); - - /** Quartz, CoreGraphics, and CoreAnimation all use an "upside-down" co-ordinate system. - This means that images rendered are upside down. - - Apple's UIImage class automatically "un-flips" this - but if you are rendering raw NSData (which is 5x-10x faster than creating UIImages!) then the flipping is "lost" - by Apple's API's. - - The only way to fix it is to pre-transform by y = -y - - This is VERY useful if you want to render SVG's into OpenGL textures! - */ - if( flipYaxis ) - { - NSAssert( [self hasSize], @"Cannot flip this image in Y because the SVG file has infinite size. Either fix the SVG file, or set an explicit size you want it to be treated as (by calling .size = something on this SVGKImage instance"); - - CGContextTranslateCTM(context, 0, self.size.height ); - CGContextScaleCTM(context, 1.0, -1.0); - } - - /** - The method that everyone hates, because Apple refuses to fix / implement it properly: renderInContext: - - It's slow. - - It's broken (according to the official API docs) - - But ... it's all that Apple gives us - */ - [self renderInContext:context]; - - NSMutableString* perfImprovements = [NSMutableString string]; - if( shouldAntialias ) - [perfImprovements appendString:@" NO-ANTI-ALIAS"]; - if( perfImprovements.length < 1 ) - [perfImprovements appendString:@"NONE"]; - - SVGKitLogVerbose(@"[%@] renderToContext: time taken to render CALayers to CGContext (perf improvements:%@): %2.3f seconds)", [self class], perfImprovements, -1.0f * [startTime timeIntervalSinceNow] ); -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSCharacterSet+SVGKExtensions.h b/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSCharacterSet+SVGKExtensions.h deleted file mode 100644 index cf6eae6eeb..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSCharacterSet+SVGKExtensions.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// NSCharacterSet+SVGKExtensions.h -// Avatar -// -// Created by Devin Chalmers on 3/6/13. -// Copyright (c) 2013 DJZ. All rights reserved. -// - -#import - -@interface NSCharacterSet (SVGKExtensions) - -+ (NSCharacterSet *)SVGWhitespaceCharacterSet; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSCharacterSet+SVGKExtensions.m b/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSCharacterSet+SVGKExtensions.m deleted file mode 100644 index 8428809634..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSCharacterSet+SVGKExtensions.m +++ /dev/null @@ -1,30 +0,0 @@ -// -// NSCharacterSet+SVGKExtensions.m -// Avatar -// -// Created by Devin Chalmers on 3/6/13. -// Copyright (c) 2013 DJZ. All rights reserved. -// - -#import "NSCharacterSet+SVGKExtensions.h" - -@implementation NSCharacterSet (SVGKExtensions) - -/** - wsp: - (#x20 | #x9 | #xD | #xA) - */ -+ (NSCharacterSet *)SVGWhitespaceCharacterSet; -{ - static NSCharacterSet *sWhitespaceCharacterSet = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - SVGKitLogVerbose(@"Allocating static NSCharacterSet containing whitespace characters. Should be small, but Apple seems to take up 5+ megabytes each time?"); - sWhitespaceCharacterSet = [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@"%c%c%c%c", 0x20, 0x9, 0xD, 0xA]]; - // required, this is a non-ARC project. - }); - - return sWhitespaceCharacterSet; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSData+NSInputStream.h b/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSData+NSInputStream.h deleted file mode 100644 index 0adffb7702..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSData+NSInputStream.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// NSData+NSInputStream.h -// Tidbits -// -// Created by Ewan Mellor on 6/16/13. -// Copyright (c) 2013 Tipbit, Inc. All rights reserved. -// - -#import - -@interface NSData (NSInputStream) - -/** - * @param capacity May be NSUIntegerMax, in which case just an ordinary [NSMutableData data] is used. Otherwise this is given to NSMutableData dataWithCapacity:]. - * @param error May be nil. - * @return The data or nil on failure in which case *error will be set. - */ -+(NSData*)dataWithContentsOfStream:(NSInputStream*)input initialCapacity:(NSUInteger)capacity error:(NSError **)error; - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSData+NSInputStream.m b/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSData+NSInputStream.m deleted file mode 100644 index 967ec98e77..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Foundation additions/NSData+NSInputStream.m +++ /dev/null @@ -1,66 +0,0 @@ -// -// NSData+NSInputStream.m -// Tidbits -// -// Created by Ewan Mellor on 6/16/13. -// Copyright (c) 2013 Tipbit, Inc. All rights reserved. -// - -#import "NSData+NSInputStream.h" - - -#define BUFSIZE 65536U - - -@implementation NSData (NSInputStream) - - -+(NSData *)dataWithContentsOfStream:(NSInputStream *)input initialCapacity:(NSUInteger)capacity error:(NSError **)error { - if (!input) { - if (error) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:ENOENT userInfo:nil]; - } - return nil; - } - size_t bufsize = MIN(BUFSIZE, capacity); - uint8_t * buf = malloc(bufsize); - if (buf == NULL) { - if (error) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:ENOMEM userInfo:nil]; - } - return nil; - } - - NSMutableData* result = capacity == NSUIntegerMax ? [NSMutableData data] : [NSMutableData dataWithCapacity:capacity]; - @try { - while (true) { - NSInteger n = [input read:buf maxLength:bufsize]; - if (n < 0) { - result = nil; - if (error) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:nil]; - } - break; - } - else if (n == 0) { - break; - } - else { - [result appendBytes:buf length:n]; - } - } - } - @catch (NSException * exn) { - SVGKitLogWarn(@"[%@] WARNING: caught exception writing to file: %@", [self class], exn); - result = nil; - if (error) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:EIO userInfo:nil]; - } - } - - free(buf); - return result; -} - - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDOM.h b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDOM.h deleted file mode 100644 index 9b5cec1818..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDOM.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - According to the DOM spec, all nodes in an XML document must be parsed; if we lack specific information for them, - i.e. if we have no other, more specific, parser - then we must parse them as the most basic objects, i.e. Node, - Element, etc - - This is a special, magical parser that matches "no namespace" - i.e. matches what happens when no namspace was declared\ - */ -#import -#import "SVGKParserExtension.h" - -@interface SVGKParserDOM : NSObject - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDOM.m b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDOM.m deleted file mode 100644 index 19d825f8b7..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDOM.m +++ /dev/null @@ -1,104 +0,0 @@ -#import "SVGKParserDOM.h" - -#import "Node+Mutable.h" - -@implementation SVGKParserDOM - -/** - This is a special, magical parser that matches "no namespace" - i.e. matches what happens when no namespace was declared - */ --(NSArray*) supportedNamespaces -{ - return [NSArray array]; -} - -/** - This is a special, magical parser that matches "all tags" - */ --(NSArray*) supportedTags -{ - return [NSMutableArray array]; -} - -- (Node*) handleStartElement:(NSString *)name document:(SVGKSource*) SVGKSource namePrefix:(NSString*)prefix namespaceURI:(NSString*) XMLNSURI attributes:(NSMutableDictionary *)attributeObjects parseResult:(SVGKParseResult *)parseResult parentNode:(Node*) parentNode -{ - if( [[self supportedNamespaces] count] == 0 - || [[self supportedNamespaces] containsObject:XMLNSURI] ) // unnecesary here, but allows safe updates to this parser's matching later - { - NSString* qualifiedName = (prefix == nil) ? name : [NSString stringWithFormat:@"%@:%@", prefix, name]; - - /** NB: must supply a NON-qualified name if we have no specific prefix here ! */ - // FIXME: we always return an empty Element here; for DOM spec, should we be detecting things like "comment" nodes? I dont know how libxml handles those and sends them to us. I've never seen one in action... - Element *blankElement = [[Element alloc] initWithQualifiedName:qualifiedName inNameSpaceURI:XMLNSURI attributes:attributeObjects]; - - return blankElement; - } - - return nil; -} - --(void)handleEndElement:(Node *)newNode document:(SVGKSource *)document parseResult:(SVGKParseResult *)parseResult -{ - -} - -/*** - - None of this can be used any more; text-processing (the only part that used it) CANNOT be handled - generically, because of the way that the DOM is defined and the libxml XML parser works. - - Instead, text-handling, and creation of text nodes, MUST be hard-coded into the SVGKParser core parser :( - --(BOOL) createdNodeShouldStoreContent:(Node*) item -{ - switch( item.nodeType ) - { - case DOMNodeType_ATTRIBUTE_NODE: - case DOMNodeType_DOCUMENT_FRAGMENT_NODE: - case DOMNodeType_DOCUMENT_NODE: - case DOMNodeType_DOCUMENT_TYPE_NODE: - case DOMNodeType_ELEMENT_NODE: - case DOMNodeType_ENTITY_NODE: - case DOMNodeType_ENTITY_REFERENCE_NODE: - case DOMNodeType_NOTATION_NODE: - { - return FALSE; // do nothing, according to the table in : http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247 - } break; - - case DOMNodeType_CDATA_SECTION_NODE: - case DOMNodeType_COMMENT_NODE: - case DOMNodeType_PROCESSING_INSTRUCTION_NODE: - case DOMNodeType_TEXT_NODE: - { - return TRUE; - } break; - } -} - --(void) handleStringContent:(NSMutableString*) content forNode:(Node*) node parseResult:(SVGKParseResult *)parseResult -{ - switch( node.nodeType ) - { - case DOMNodeType_ATTRIBUTE_NODE: - case DOMNodeType_DOCUMENT_FRAGMENT_NODE: - case DOMNodeType_DOCUMENT_NODE: - case DOMNodeType_DOCUMENT_TYPE_NODE: - case DOMNodeType_ELEMENT_NODE: - case DOMNodeType_ENTITY_NODE: - case DOMNodeType_ENTITY_REFERENCE_NODE: - case DOMNodeType_NOTATION_NODE: - { - // do nothing, according to the table in : http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247 - } break; - - case DOMNodeType_CDATA_SECTION_NODE: - case DOMNodeType_COMMENT_NODE: - case DOMNodeType_PROCESSING_INSTRUCTION_NODE: - case DOMNodeType_TEXT_NODE: - { - node.nodeValue = content; - } break; - } -} -*/ -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDefsAndUse.h b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDefsAndUse.h deleted file mode 100644 index fad28bbe6d..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDefsAndUse.h +++ /dev/null @@ -1,11 +0,0 @@ -/** - Parses the "" and "" tags in SVG files. - - NB: relies upon other parsers to parse the actual CONTENTS of a "defs" or "use" tag - */ -#import -#import "SVGKParserExtension.h" - -@interface SVGKParserDefsAndUse : NSObject - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDefsAndUse.m b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDefsAndUse.m deleted file mode 100644 index 62daa03eb2..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserDefsAndUse.m +++ /dev/null @@ -1,117 +0,0 @@ -#import "SVGKParserDefsAndUse.h" - -#import "Node.h" -#import "SVGKSource.h" -#import "SVGKParseResult.h" - -#import "SVGDefsElement.h" -#import "SVGUseElement.h" -#import "SVGUseElement_Mutable.h" -#import "SVGElementInstance.h" -#import "SVGElementInstance_Mutable.h" -#import "SVGElementInstanceList.h" -#import "SVGElement_ForParser.h" - -@implementation SVGKParserDefsAndUse - --(NSArray*) supportedNamespaces -{ - return [NSArray arrayWithObjects: - @"http://www.w3.org/2000/svg", - nil]; -} - -/** "tags supported" is exactly the set of all SVGElement subclasses that already exist */ --(NSArray*) supportedTags -{ - return [NSMutableArray arrayWithObjects: @"defs", @"use", nil]; -} - --(SVGElementInstance*) convertSVGElementToElementInstanceTree:(SVGElement*) original outermostUseElement:(SVGUseElement*) outermostUseElement -{ - SVGElementInstance* instance = [[SVGElementInstance alloc] init]; - instance.correspondingElement = original; - instance.correspondingUseElement = outermostUseElement; - - for( Node* subNode in original.childNodes ) - { - if( [subNode isKindOfClass:[SVGElement class]]) - { - SVGElement* subElement = (SVGElement*) subNode; - - SVGElementInstance *newSubInstance = [self convertSVGElementToElementInstanceTree:subElement outermostUseElement:outermostUseElement]; - - newSubInstance.parentNode = instance; // side-effect: automatically adds sub as child - } - } - - return instance; -} - -- (Node*) handleStartElement:(NSString *)name document:(SVGKSource*) SVGKSource namePrefix:(NSString*)prefix namespaceURI:(NSString*) XMLNSURI attributes:(NSMutableDictionary *)attributes parseResult:(SVGKParseResult *)parseResult parentNode:(Node*) parentNode -{ - if( [[self supportedNamespaces] containsObject:XMLNSURI] ) - { - NSString* qualifiedName = (prefix == nil) ? name : [NSString stringWithFormat:@"%@:%@", prefix, name]; - - if( [name isEqualToString:@"defs"]) - { - /** NB: must supply a NON-qualified name if we have no specific prefix here ! */ - SVGDefsElement *element = [[SVGDefsElement alloc] initWithQualifiedName:qualifiedName inNameSpaceURI:XMLNSURI attributes:attributes]; - - return element; - } - else if( [name isEqualToString:@"use"]) - { - /** NB: must supply a NON-qualified name if we have no specific prefix here ! */ - SVGUseElement *useElement = [[SVGUseElement alloc] initWithQualifiedName:qualifiedName inNameSpaceURI:XMLNSURI attributes:attributes]; - - [useElement postProcessAttributesAddingErrorsTo:parseResult]; // handles "transform" and "style" - - if( [attributes valueForKey:@"x"] != nil ) - useElement.x = [SVGLength svgLengthFromNSString:[((Attr*)[attributes valueForKey:@"x"]) value]]; - if( [attributes valueForKey:@"y"] != nil ) - useElement.y = [SVGLength svgLengthFromNSString:[((Attr*)[attributes valueForKey:@"y"]) value]]; - if( [attributes valueForKey:@"width"] != nil ) - useElement.width = [SVGLength svgLengthFromNSString:[((Attr*)[attributes valueForKey:@"width"]) value]]; - if( [attributes valueForKey:@"height"] != nil ) - useElement.height = [SVGLength svgLengthFromNSString:[((Attr*)[attributes valueForKey:@"height"]) value]]; - - NSString* hrefAttribute = [useElement getAttributeNS:@"http://www.w3.org/1999/xlink" localName:@"href"]; - - NSAssert( [hrefAttribute length] > 0, @"Found an SVG tag that has no 'xlink:href' attribute. File is invalid / don't know how to parse this" ); - if( [hrefAttribute length] > 0 ) - { - NSString* linkHref = [((Attr*)[attributes valueForKey:@"xlink:href"]) value]; - /** support `url(#id) funcIRI as well to follow SVG spec` */ - if ([linkHref hasPrefix:@"url"]) { - NSRange range = NSMakeRange(4, linkHref.length - 5); - linkHref = [linkHref substringWithRange:range]; - } - - NSAssert( [linkHref hasPrefix:@"#"], @"Not supported: tags that declare an href to something that DOESN'T begin with #. Href supplied = %@", linkHref ); - - linkHref = [linkHref substringFromIndex:1]; - - /** have to find the node in the DOM tree with id = xlink:href's value */ - SVGElement* linkedElement = (SVGElement*) [parseResult.parsedDocument getElementById:linkHref]; - - NSAssert( linkedElement != nil, @"Found an SVG tag that points to a non-existent element. Missing element: id = %@", linkHref ); - - - useElement.instanceRoot = [self convertSVGElementToElementInstanceTree:linkedElement outermostUseElement:useElement]; - } - - return useElement; - } - } - - return nil; -} - --(void)handleEndElement:(Node *)newNode document:(SVGKSource *)document parseResult:(SVGKParseResult *)parseResult -{ - -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserGradient.h b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserGradient.h deleted file mode 100644 index 8e2b48a18f..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserGradient.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// SVGParserLinearGradient.h -// SVGPad -// -// Created by Kevin Stich on 1/31/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import -#import "SVGKParserSVG.h" - - -@class SVGGradientElement; - -@interface SVGKParserGradient : SVGKParserSVG { - SVGGradientElement *currentElement; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserGradient.m b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserGradient.m deleted file mode 100644 index f78ee55449..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserGradient.m +++ /dev/null @@ -1,243 +0,0 @@ -// -// SVGParserLinearGradient.m -// SVGPad -// -// Created by Kevin Stich on 1/31/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "SVGKParserGradient.h" - -#import "SVGElement_ForParser.h" - -#import "SVGGradientStop.h" - -#import "SVGGradientElement.h" -#import "SVGLinearGradientElement.h" -#import "SVGRadialGradientElement.h" - -@interface SVGKParserGradient () -@property (nonatomic) NSArray *supportedNamespaces; -@property (nonatomic) NSArray *supportedTags; -@end - -@implementation SVGKParserGradient - --(NSArray *)supportedNamespaces -{ - if( _supportedNamespaces == nil ) - _supportedNamespaces = @[@"http://www.w3.org/2000/svg"]; - return _supportedNamespaces; -} - --(NSArray *)supportedTags -{ - if( _supportedTags == nil ) - _supportedTags = @[@"linearGradient", @"radialGradient", @"stop"]; - return _supportedTags; -} - --(Node *)handleStartElement:(NSString *)name document:(SVGKSource *)document namePrefix:(NSString *)prefix namespaceURI:(NSString *)XMLNSURI attributes:(NSMutableDictionary *)attributes parseResult:(SVGKParseResult *)parseResult parentNode:(Node *)parentNode -{ - Node *returnObject = nil; - - if( [name isEqualToString:@"linearGradient"] ) - { - returnObject = currentElement = [[SVGLinearGradientElement alloc] initWithQualifiedName:name inNameSpaceURI:XMLNSURI attributes:attributes]; - [currentElement postProcessAttributesAddingErrorsTo:parseResult]; - - /** No need to "store" anything; the node has been parsed, it'll be added to the DOM tree, and accessible later via DOM methods -- which is what the SVG spec expects us to do */ - } - else if( [name isEqualToString:@"radialGradient"] ) { - returnObject = currentElement = [[SVGRadialGradientElement alloc] initWithQualifiedName:name inNameSpaceURI:XMLNSURI attributes:attributes]; - [currentElement postProcessAttributesAddingErrorsTo:parseResult]; - } - else if( [name isEqualToString:@"stop"] ) - { - SVGGradientStop *gradientStop = [[SVGGradientStop alloc] initWithQualifiedName:name inNameSpaceURI:XMLNSURI attributes:attributes]; - - [gradientStop postProcessAttributesAddingErrorsTo:parseResult]; - returnObject = gradientStop; - - [currentElement addStop:gradientStop]; - } - -// var linearGrad:SVGLinearGradient = grad as SVGLinearGradient; -//                                         -//                                         if("@x1" in xml_grad) -//                                                 linearGrad.x1 = xml_grad.@x1; -//                                         else if(linearGrad.x1 == null) -//                                                 linearGrad.x1 = "0%"; -//                                         -//                                         if("@y1" in xml_grad) -//                                                 linearGrad.y1 = xml_grad.@y1; -//                                         else if(linearGrad.y1 == null) -//                                                 linearGrad.y1 = "0%"; -//                                         -//                                         if("@x2" in xml_grad) -//                                                 linearGrad.x2 = xml_grad.@x2; -//                                         else if(linearGrad.x2 == null) -//                                                 linearGrad.x2 = "100%"; -//                                         -//                                         if("@y2" in xml_grad) -//                                                 linearGrad.y2 = xml_grad.@y2; -//                                         else if(linearGrad.y2 == null) -//                                                 linearGrad.y2 = "0%"; - return returnObject; -} - --(void)handleEndElement:(Node *)newNode document:(SVGKSource *)document parseResult:(SVGKParseResult *)parseResult -{ - -} - -//-(void)dealloc -//{ -// currentElement = nil; -// [super dealloc]; -//} - - -@end - - -/*private static function parseGradient(id:String, svg:XML, storeObject:Object):SVGGradient { -                         id = StringUtil.ltrim(id, "#"); -                         -                         if(storeObject[id]!=null) -                                 return storeObject[id]; -                                                 -                         var xml_grad:XML = svg..*.(attribute("id")==id)[0]; -                         -                         if(xml_grad == null) -                                 return null; -                         -                         var grad:SVGGradient; -                         -                         switch(xml_grad.localName().toLowerCase()){ -                                 case "lineargradient": -                                         grad = new SVGLinearGradient(); break; -                                 case "radialgradient" : -                                         grad = new SVGRadialGradient(); break; -                         } -                         -                         //inherits the href reference -                         var xlink:Namespace = new Namespace("http://www.w3.org/1999/xlink"); -                         if(xml_grad.@xlink::href.length()>0){ -                                 var baseGradient:SVGGradient = parseGradient(xml_grad.@xlink::href, svg, storeObject); -                                 if(baseGradient) -                                         baseGradient.copyTo(grad); -                         } -                         // -                         -                         if("@gradientUnits" in xml_grad) -                                 grad.gradientUnits = xml_grad.@gradientUnits; -                         else -                                 grad.gradientUnits = "objectBoundingBox"; -                         -                         if("@gradientTransform" in xml_grad) -                                 grad.transform = parseTransformation(xml_grad.@gradientTransform); -                         -                         switch(grad.type){ -                                 case GradientType.LINEAR : { -                                         var linearGrad:SVGLinearGradient = grad as SVGLinearGradient; -                                         -                                         if("@x1" in xml_grad) -                                                 linearGrad.x1 = xml_grad.@x1; -                                         else if(linearGrad.x1 == null) -                                                 linearGrad.x1 = "0%"; -                                         -                                         if("@y1" in xml_grad) -                                                 linearGrad.y1 = xml_grad.@y1; -                                         else if(linearGrad.y1 == null) -                                                 linearGrad.y1 = "0%"; -                                         -                                         if("@x2" in xml_grad) -                                                 linearGrad.x2 = xml_grad.@x2; -                                         else if(linearGrad.x2 == null) -                                                 linearGrad.x2 = "100%"; -                                         -                                         if("@y2" in xml_grad) -                                                 linearGrad.y2 = xml_grad.@y2; -                                         else if(linearGrad.y2 == null) -                                                 linearGrad.y2 = "0%"; - -                                         break; -                                 } -                                 case GradientType.RADIAL : { -                                         var radialGrad:SVGRadialGradient = grad as SVGRadialGradient; -                                         -                                         if("@cx" in xml_grad) -                                                 radialGrad.cx = xml_grad.@cx; -                                         else if(radialGrad.cx==null) -                                                 radialGrad.cx = "50%"; -                                         -                                         if("@cy" in xml_grad) -                                                 radialGrad.cy = xml_grad.@cy; -                                         else if(radialGrad.cy==null) -                                                 radialGrad.cy = "50%"; -                                         -                                         if("@r" in xml_grad) -                                                 radialGrad.r = xml_grad.@r; -                                         else if(radialGrad.r == null) -                                                 radialGrad.r = "50%"; -                                         -                                         if("@fx" in xml_grad) -                                                 radialGrad.fx = xml_grad.@fx; -                                         else if(radialGrad.fx==null) -                                                 radialGrad.fx = radialGrad.cx; -                                         -                                         if("@fy" in xml_grad) -                                                 radialGrad.fy = xml_grad.@fy; -                                         else if(radialGrad.fy==null) -                                                 radialGrad.fy = radialGrad.cy; -                                         -                                         break; -                                 } -                         } -                         -                         switch(xml_grad.@spreadMethod){ -                                 case "pad" : grad.spreadMethod = SpreadMethod.PAD; break; -                                 case "reflect" : grad.spreadMethod = SpreadMethod.REFLECT; break; -                                 case "repeat" : grad.spreadMethod = SpreadMethod.REPEAT; break; -                                 default: grad.spreadMethod = SpreadMethod.PAD; break -                         } -                         -                         if(grad.colors == null) -                                 grad.colors = new Array(); -                         -                         if(grad.alphas==null) -                                 grad.alphas = new Array(); -                         -                         if(grad.ratios==null) -                                 grad.ratios = new Array(); -                         -                         for each(var stop:XML in xml_grad.*::stop){ -                                 var stopStyle:StyleDeclaration = new StyleDeclaration(); -                                 -                                 if("@stop-opacity" in stop) -                                         stopStyle.setProperty("stop-opacity", stop.@["stop-opacity"]); -                                 -                                 if("@stop-color" in stop) -                                         stopStyle.setProperty("stop-color", stop.@["stop-color"]); -                                 -                                 if("@style" in stop){ -                                         stopStyle.fromString(stop.@style); -                                 } -                                 -                                 grad.colors.push( SVGColorUtils.parseToUint(stopStyle.getPropertyValue("stop-color")) ); -                                 grad.alphas.push( stopStyle.getPropertyValue("stop-opacity" ) != null ? Number(stopStyle.getPropertyValue("stop-opacity")) : 1 ); -                                 -                                 var offset:Number = Number(StringUtil.rtrim(stop.@offset, "%")); -                                 if(String(stop.@offset).indexOf("%") > -1){ -                                         offset/=100; -                                 } -                                 grad.ratios.push( offset*255 ); -                         } -                         -                         //Save the gradient definition -                         storeObject[id] = grad; -                         // -                         -                         return grad; -*/ diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserPatternsAndGradients.h b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserPatternsAndGradients.h deleted file mode 100644 index 2c0a8f649f..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserPatternsAndGradients.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// SVGKParserPatternsAndGradients.h -// SVGKit -// -// Created by adam applecansuckmybigtodger on 28/06/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "SVGKParser.h" - -@interface SVGKParserPatternsAndGradients : NSObject - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserPatternsAndGradients.m b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserPatternsAndGradients.m deleted file mode 100644 index 7170855e59..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserPatternsAndGradients.m +++ /dev/null @@ -1,54 +0,0 @@ -// -// SVGKParserPatternsAndGradients.m -// SVGKit -// -// Created by adam applecansuckmybigtodger on 28/06/2012. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "SVGKParserPatternsAndGradients.h" - -#import "SVGSVGElement.h" -#import "SVGCircleElement.h" -#import "SVGDefsElement.h" -#import "SVGDescriptionElement.h" -//#import "SVGKSource.h" -#import "SVGEllipseElement.h" -#import "SVGImageElement.h" -#import "SVGLineElement.h" -#import "SVGPathElement.h" -#import "SVGPolygonElement.h" -#import "SVGPolylineElement.h" -#import "SVGRectElement.h" -#import "SVGTitleElement.h" - -@implementation SVGKParserPatternsAndGradients - - --(NSArray*) supportedNamespaces -{ - return [NSArray arrayWithObjects: - @"http://www.w3.org/2000/svg", - nil]; -} - -/** "tags supported" is exactly the set of all SVGElement subclasses that already exist */ --(NSArray*) supportedTags -{ - return [NSMutableArray arrayWithObjects:@"pattern", nil]; -} - -- (Node*)handleStartElement:(NSString *)name document:(SVGKSource*) document namePrefix:(NSString*)prefix namespaceURI:(NSString*) XMLNSURI attributes:(NSMutableDictionary *)attributes parseResult:(SVGKParseResult*) parseResult parentNode:(Node*) parentNode -{ - - NSAssert( FALSE, @"Patterns are not supported by SVGKit yet - no-one has implemented them" ); - - return nil; -} - --(void)handleEndElement:(Node *)newNode document:(SVGKSource *)document parseResult:(SVGKParseResult *)parseResult -{ - -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserSVG.h b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserSVG.h deleted file mode 100644 index 8ba7e723ea..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserSVG.h +++ /dev/null @@ -1,8 +0,0 @@ -#import - -#import "SVGKParser.h" - -@interface SVGKParserSVG : NSObject { -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserSVG.m b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserSVG.m deleted file mode 100644 index 172653ffe6..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserSVG.m +++ /dev/null @@ -1,192 +0,0 @@ -#import "SVGKParserSVG.h" - -#import "SVGSVGElement.h" -#import "SVGCircleElement.h" -#import "SVGClipPathElement.h" -#import "SVGDefsElement.h" -#import "SVGDescriptionElement.h" -//#import "SVGKSource.h" -#import "SVGEllipseElement.h" -#import "SVGGElement.h" -#import "SVGImageElement.h" -#import "SVGLineElement.h" -#import "SVGPathElement.h" -#import "SVGPolygonElement.h" -#import "SVGPolylineElement.h" -#import "SVGRectElement.h" -#import "SVGSwitchElement.h" -#import "SVGTitleElement.h" -#import "SVGTextElement.h" -#import "TinySVGTextAreaElement.h" - -#import "SVGDocument_Mutable.h" - -@interface SVGKParserSVG () -@property (nonatomic) NSArray *supportedNamespaces; -@property (nonatomic) NSDictionary *elementMap; -@end - -@implementation SVGKParserSVG - -- (NSDictionary *)elementMap { - if (!_elementMap) { - _elementMap = [NSDictionary dictionaryWithObjectsAndKeys: - [SVGSVGElement class], @"svg", - [SVGCircleElement class], @"circle", - [SVGDescriptionElement class], @"description", - [SVGEllipseElement class], @"ellipse", - [SVGGElement class], @"g", - [SVGClipPathElement class], @"clipPath", - [SVGImageElement class], @"image", - [SVGLineElement class], @"line", - [SVGPathElement class], @"path", - [SVGPolygonElement class], @"polygon", - [SVGPolylineElement class], @"polyline", - [SVGRectElement class], @"rect", - [SVGSwitchElement class], @"switch", - [SVGTitleElement class], @"title", - [SVGTextElement class], @"text", - [TinySVGTextAreaElement class], @"textArea", - nil]; - } - return _elementMap; -} - --(NSArray *)supportedNamespaces -{ - if( _supportedNamespaces == nil ) - _supportedNamespaces = @[@"http://www.w3.org/2000/svg"]; - return _supportedNamespaces; -} - -/** "tags supported" is exactly the set of all SVGElement subclasses that already exist */ --(NSArray*) supportedTags -{ - return [self.elementMap allKeys]; -} - -- (Node*) handleStartElement:(NSString *)name document:(SVGKSource*) SVGKSource namePrefix:(NSString*)prefix namespaceURI:(NSString*) XMLNSURI attributes:(NSMutableDictionary *)attributes parseResult:(SVGKParseResult *)parseResult parentNode:(Node*) parentNode -{ - if( [[self supportedNamespaces] containsObject:XMLNSURI] ) - { - Class elementClass = [self.elementMap objectForKey:name]; - - if (!elementClass) { - elementClass = [SVGElement class]; - SVGKitLogWarn(@"Support for '%@' element has not been implemented", name); - } - - /** - NB: following the SVG Spec, it's critical that we ONLY use the DOM methods for creating - basic 'Element' nodes. - - Our SVGElement root class has an implementation of init that delegates to the same - private methods that the DOM methods use, so it's safe... - - FIXME: ...but in reality we ought to be using the DOMDocument createElement/NS methods, although "good luck" trying to find a DOMDocument if your SVG is embedded inside a larger XML document :( - */ - - - NSString* qualifiedName = (prefix == nil) ? name : [NSString stringWithFormat:@"%@:%@", prefix, name]; - /** NB: must supply a NON-qualified name if we have no specific prefix here ! */ - SVGElement *element = [[elementClass alloc] initWithQualifiedName:qualifiedName inNameSpaceURI:XMLNSURI attributes:attributes]; - - /** NB: all the interesting handling of shared / generic attributes - e.g. the whole of CSS styling etc - takes place in this method: */ - [element postProcessAttributesAddingErrorsTo:parseResult]; - - /** special case: */ - if( [@"svg" isEqualToString:name] ) - { - ((SVGSVGElement *) element).source = SVGKSource; - - NSString* svgVersion = nil; - - /** According to spec, if the first XML node is an SVG node, then it - becomes TWO THINGS: - - - An SVGSVGElement - *and* - - An SVGDocument - - ...and that becomes "the root SVGDocument" - - If it's NOT the first XML node, but it's the first SVG node, then it ONLY becomes: - - - An SVGSVGElement - - If it's NOT the first SVG node, then it becomes: - - - An SVGSVGElement - *and* - - An SVGDocument - - Yes. It's Very confusing! Go read the SVG Spec! - */ - - BOOL generateAnSVGDocument = FALSE; - BOOL overwriteRootSVGDocument = FALSE; - BOOL overwriteRootOfTree = FALSE; - - if( parentNode == nil ) - { - /** This start element is the first item in the document - PS: xcode has a new bug for Lion: it can't format single-line comments with two asterisks. This line added because Xcode sucks. - */ - generateAnSVGDocument = overwriteRootSVGDocument = overwriteRootOfTree = TRUE; - - } - else if( parseResult.rootOfSVGTree == nil ) - { - /** It's not the first XML, but it's the first SVG node */ - overwriteRootOfTree = TRUE; - } - else - { - /** It's not the first SVG node */ - // ... so: do nothing special - } - - /** - Handle the complex stuff above about SVGDocument and SVG node - */ - if( overwriteRootOfTree ) - { - parseResult.rootOfSVGTree = (SVGSVGElement*) element; - - /** Post-processing of the ROOT SVG ONLY (doesn't apply to embedded SVG's ) - */ - if ((svgVersion = [attributes objectForKey:@"version"])) { - SVGKSource.svgLanguageVersion = svgVersion; - } - } - if( generateAnSVGDocument ) - { - NSAssert( [element isKindOfClass:[SVGSVGElement class]], @"Trying to create a new internal SVGDocument from a Node that is NOT of type SVGSVGElement (tag: svg). Node was of type: %@", NSStringFromClass([element class])); - - SVGDocument* newDocument = [[SVGDocument alloc] init]; - newDocument.rootElement = (SVGSVGElement*) element; - - if( overwriteRootSVGDocument ) - { - parseResult.parsedDocument = newDocument; - } - else - { - NSAssert( FALSE, @"Currently not supported: multiple SVG Document nodes in a single SVG file" ); - } - } - - } - - - return element; - } - - return nil; -} - --(void)handleEndElement:(Node *)newNode document:(SVGKSource *)document parseResult:(SVGKParseResult *)parseResult -{ - -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserStyles.h b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserStyles.h deleted file mode 100644 index da7831c5c6..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserStyles.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// SVGStyleParser.h -// SVGPad -// -// Created by Kevin Stich on 2/2/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import -#import "SVGKParser.h" - -@interface SVGKParserStyles : NSObject { - @private -// NSSet *_tags, *_namespaces; -} - -@end diff --git a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserStyles.m b/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserStyles.m deleted file mode 100644 index 72528b9200..0000000000 --- a/submodules/Svg/Sources/SVGKit/Source/Parsers/Parser Extensions/SVGKParserStyles.m +++ /dev/null @@ -1,74 +0,0 @@ -// -// SVGStyleParser.m -// SVGPad -// -// Created by Kevin Stich on 2/2/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "SVGKParserStyles.h" - -#import "CSSStyleSheet.h" -#import "StyleSheetList+Mutable.h" - -@interface SVGKParserStyles () -@property (nonatomic) NSArray *supportedNamespaces; -@property (nonatomic) NSArray *supportedTags; -@end - -@implementation SVGKParserStyles - --(NSArray *)supportedNamespaces -{ - if( _supportedNamespaces == nil ) - _supportedNamespaces = @[@"http://www.w3.org/2000/svg"]; - return _supportedNamespaces; -} - --(NSArray *)supportedTags -{ - if( _supportedTags == nil ) - _supportedTags = @[@"style"]; - return _supportedTags; -} - --(Node *)handleStartElement:(NSString *)name document:(SVGKSource *)document namePrefix:(NSString *)prefix namespaceURI:(NSString *)XMLNSURI attributes:(NSMutableDictionary *)attributes parseResult:(SVGKParseResult *)parseResult parentNode:(Node *)parentNode -{ - if( [[self supportedNamespaces] containsObject:XMLNSURI] ) - { - /** - - NB: this section of code is copy/pasted from SVGKParserDOM -- we don't want anything special, we want an ordinary DOM node, - ...but we need this standalone parser-extension because a