Remove unused public method

This commit is contained in:
Horcrux
2017-01-16 14:38:43 +08:00
parent a981585b6b
commit 7c9f6b2d3d
11 changed files with 38 additions and 68 deletions

View File

@@ -608,6 +608,7 @@ npm i
4. Mask element. 4. Mask element.
5. Load Image from URL. 5. Load Image from URL.
6. Fix rotate prop on Text 6. Fix rotate prop on Text
7.
### Known issues: ### Known issues:
1. Unable to set alpha channel for Gradient on iOS. 1. Unable to set alpha channel for Gradient on iOS.

View File

@@ -22,7 +22,7 @@ class Use extends Shape {
render() { render() {
let {props} = this; let {props} = this;
// 尝试匹配 "url(#pattern)" // match "url(#pattern)"
let matched = props.href.match(idExpReg); let matched = props.href.match(idExpReg);
let href; let href;

View File

@@ -24,13 +24,14 @@
svg.responsible = YES; svg.responsible = YES;
} }
[node mergeProperties:self mergeList:self.attributeList inherited:YES]; [node mergeProperties:self];
[node renderTo:context]; [node renderTo:context];
if ([node isKindOfClass: [RNSVGRenderable class]]) { if ([node isKindOfClass: [RNSVGRenderable class]]) {
RNSVGRenderable *renderable = node; RNSVGRenderable *renderable = node;
[self concatLayoutBoundingBox:[renderable getLayoutBoundingBox]]; [self concatLayoutBoundingBox:[renderable getLayoutBoundingBox]];
} }
return YES; return YES;
}]; }];
} }
@@ -113,12 +114,4 @@
} }
- (void)resetProperties
{
[self traverseSubviews:^(RNSVGNode *node) {
[node resetProperties];
return YES;
}];
}
@end @end

View File

@@ -27,9 +27,8 @@
if (template) { if (template) {
[self beginTransparencyLayer:context]; [self beginTransparencyLayer:context];
[self clip:context]; [self clip:context];
[template mergeProperties:self mergeList:self.attributeList inherited:YES]; [template mergeProperties:self];
[template renderTo:context]; [template renderTo:context];
[template resetProperties];
[self endTransparencyLayer:context]; [self endTransparencyLayer:context];
} else if (self.href) { } else if (self.href) {
// TODO: calling yellow box here // TODO: calling yellow box here

View File

@@ -68,17 +68,7 @@
*/ */
- (void)saveDefinition; - (void)saveDefinition;
/** - (void)mergeProperties:(__kindof RNSVGNode *)target;
* just for template node to merge target node`s properties into owned properties
*/
- (void)mergeProperties:(__kindof RNSVGNode *)target mergeList:(NSArray<NSString *> *)mergeList;
- (void)mergeProperties:(__kindof RNSVGNode *)target mergeList:(NSArray<NSString *> *)mergeList inherited:(BOOL)inherited;
/**
* just for template node to reset all owned properties once after rendered.
*/
- (void)resetProperties;
- (void)beginTransparencyLayer:(CGContextRef)context; - (void)beginTransparencyLayer:(CGContextRef)context;

View File

@@ -181,12 +181,7 @@
} }
} }
- (void)mergeProperties:(__kindof RNSVGNode *)target mergeList:(NSArray<NSString *> *)mergeList - (void)mergeProperties:(__kindof RNSVGNode *)target
{
// abstract
}
- (void)mergeProperties:(__kindof RNSVGNode *)target mergeList:(NSArray<NSString *> *)mergeList inherited:(BOOL)inherited
{ {
// abstract // abstract
} }
@@ -202,11 +197,6 @@
} }
} }
- (void)resetProperties
{
// abstract
}
- (void)dealloc - (void)dealloc
{ {
CGPathRelease(_cachedClipPath); CGPathRelease(_cachedClipPath);

View File

@@ -28,7 +28,6 @@
@property (nonatomic, assign) RNSVGCGFloatArray strokeDasharray; @property (nonatomic, assign) RNSVGCGFloatArray strokeDasharray;
@property (nonatomic, assign) CGFloat strokeDashoffset; @property (nonatomic, assign) CGFloat strokeDashoffset;
@property (nonatomic, copy) NSArray<NSString *> *propList; @property (nonatomic, copy) NSArray<NSString *> *propList;
@property (nonatomic, strong) NSArray<NSString *> *attributeList;
- (void)setContextBoundingBox:(CGRect)contextBoundingBox; - (void)setContextBoundingBox:(CGRect)contextBoundingBox;
- (CGRect)getContextBoundingBox; - (CGRect)getContextBoundingBox;
@@ -39,5 +38,6 @@
- (RNSVGPercentageConverter *)getWidthConverter; - (RNSVGPercentageConverter *)getWidthConverter;
- (RNSVGPercentageConverter *)getHeightConverter; - (RNSVGPercentageConverter *)getHeightConverter;
- (void)setHitArea:(CGPathRef)path; - (void)setHitArea:(CGPathRef)path;
- (NSArray<NSString *> *)getAttributeList;
@end @end

View File

@@ -11,7 +11,8 @@
@implementation RNSVGRenderable @implementation RNSVGRenderable
{ {
NSMutableDictionary *_originProperties; NSMutableDictionary *_originProperties;
NSArray *_lastMergedList; NSArray<NSString *> *_lastMergedList;
NSArray<NSString *> *_attributeList;
RNSVGPercentageConverter *_widthConverter; RNSVGPercentageConverter *_widthConverter;
RNSVGPercentageConverter *_heightConverter; RNSVGPercentageConverter *_heightConverter;
CGRect _contextBoundingBox; CGRect _contextBoundingBox;
@@ -138,8 +139,8 @@
if (propList == _propList) { if (propList == _propList) {
return; return;
} }
_attributeList = [propList copy];
_propList = propList; _propList = _attributeList = propList;
[self invalidate]; [self invalidate];
} }
@@ -347,37 +348,35 @@
return [_heightConverter stringToFloat:string]; return [_heightConverter stringToFloat:string];
} }
- (void)mergeProperties:(__kindof RNSVGNode *)target mergeList:(NSArray<NSString *> *)mergeList - (NSArray<NSString *> *)getAttributeList
{ {
return _attributeList;
[self mergeProperties:target mergeList:mergeList inherited:NO];
} }
- (void)mergeProperties:(__kindof RNSVGNode *)target mergeList:(NSArray<NSString *> *)mergeList inherited:(BOOL)inherited - (void)mergeProperties:(__kindof RNSVGNode *)target
{ {
_lastMergedList = mergeList; if (_lastMergedList) {
[self resetProperties];
}
if (mergeList.count == 0) { NSArray<NSString *> *targetAttributeList = [target getAttributeList];
if (targetAttributeList.count == 0) {
return; return;
} }
NSMutableArray* attributeList = [self.propList mutableCopy]; NSMutableArray* attributeList = [self.propList mutableCopy];
_originProperties = [[NSMutableDictionary alloc] init]; _originProperties = [[NSMutableDictionary alloc] init];
for (NSString *key in mergeList) { for (NSString *key in targetAttributeList) {
if (inherited) { if (![attributeList containsObject:key]) {
if (![attributeList containsObject:key]) { [attributeList addObject:key];
[attributeList addObject:key];
[_originProperties setValue:[self valueForKey:key] forKey:key];
[self setValue:[target valueForKey:key] forKey:key];
}
} else {
[_originProperties setValue:[self valueForKey:key] forKey:key]; [_originProperties setValue:[self valueForKey:key] forKey:key];
[self setValue:[target valueForKey:key] forKey:key]; [self setValue:[target valueForKey:key] forKey:key];
} }
} }
_lastMergedList = targetAttributeList;
_attributeList = [attributeList copy]; _attributeList = [attributeList copy];
} }
@@ -386,7 +385,9 @@
for (NSString *key in _lastMergedList) { for (NSString *key in _lastMergedList) {
[self setValue:[_originProperties valueForKey:key] forKey:key]; [self setValue:[_originProperties valueForKey:key] forKey:key];
} }
_attributeList = [_propList copy];
_lastMergedList = nil;
_attributeList = _propList;
} }
@end @end

View File

@@ -160,7 +160,7 @@
return CGAffineTransformTranslate(transform, -translateX * (_fromSymbol ? scaleX : 1), -translateY * (_fromSymbol ? scaleY : 1)); return CGAffineTransformTranslate(transform, -translateX * (_fromSymbol ? scaleX : 1), -translateY * (_fromSymbol ? scaleY : 1));
} }
- (void)mergeProperties:(__kindof RNSVGNode *)target mergeList:(NSArray<NSString *> *)mergeList inherited:(BOOL)inherited - (void)mergeProperties:(__kindof RNSVGNode *)target
{ {
if ([target isKindOfClass:[RNSVGUse class]]) { if ([target isKindOfClass:[RNSVGUse class]]) {
RNSVGUse *use = target; RNSVGUse *use = target;

View File

@@ -1,9 +1,8 @@
import _ from 'lodash'; const merge = Object.assign;
const merge = _.assign;
function arrayDiffer(a, b) { function arrayDiffer(a, b) {
if (_.isNil(a) || _.isNil(b) ) { /*eslint eqeqeq:0*/
if (a == null || b == null) {
return true; return true;
} }
if (a.length !== b.length) { if (a.length !== b.length) {
@@ -22,11 +21,10 @@ function fontDiffer(a, b) {
return false; return false;
} }
if (a.fontSize !== b.fontSize || a.fontFamily !== b.fontFamily || a.fontStyle !== b.fontStyle || a.fontWeight !== b.fontWeight) { return a.fontSize !== b.fontSize ||
return true; a.fontFamily !== b.fontFamily ||
} a.fontStyle !== b.fontStyle ||
a.fontWeight !== b.fontWeight;
return false;
} }
const ViewBoxAttributes = { const ViewBoxAttributes = {

View File

@@ -1,6 +1,4 @@
import _ from 'lodash';
export default function (opacity) { export default function (opacity) {
let value = +opacity; const value = +opacity;
return (_.isNil(opacity) || isNaN(value)) ? 1 : value; return (typeof value !== 'number' || isNaN(value)) ? 1 : value;
} }