diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m index ab4f63ced3..b8d1c9dce0 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m @@ -113,11 +113,8 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDict if (attributes[@"quality"]) { _imageQuality = [WXConvert WXImageQuality:attributes[@"quality"]]; } - id configCenter = [WXSDKEngine handlerForProtocol:@protocol(WXConfigCenterProtocol)]; + _downloadImageWithURL = YES; - if ([configCenter respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) { - _downloadImageWithURL = [[configCenter configForKey:@"iOS_weex_ext_config.downloadImageWithURL" defaultValue:@(YES) isDefault:NULL] boolValue]; - } if (attributes[@"compositing"]) { _downloadImageWithURL = [WXConvert BOOL:attributes[@"compositing"]]; } diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h index ebd8c7da93..fb20bd0a59 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h +++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h @@ -22,7 +22,6 @@ @interface WXTextComponent : WXComponent @property (atomic, strong) NSString *text; -+ (void)setRenderUsingCoreText:(BOOL)usingCoreText; - (BOOL)useCoreText; @end diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm index 7d779f88cd..97c7d5e046 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm +++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.mm @@ -115,10 +115,8 @@ - (NSString *)accessibilityLabel @end -static BOOL textRenderUsingCoreText = YES; - -NSString *const WXTextTruncationToken = @"\u2026"; -CGFloat WXTextDefaultLineThroughWidth = 1.2; +static NSString *const WXTextTruncationToken = @"\u2026"; +static CGFloat WXTextDefaultLineThroughWidth = 1.2; @interface WXTextComponent() @property (nonatomic, strong) NSString *useCoreTextAttr; @@ -155,16 +153,6 @@ @implementation WXTextComponent BOOL _enableCopy; } -+ (void)setRenderUsingCoreText:(BOOL)usingCoreText -{ - textRenderUsingCoreText = usingCoreText; -} - -+ (BOOL)textRenderUsingCoreText -{ - return textRenderUsingCoreText; -} - - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDictionary *)styles @@ -202,11 +190,7 @@ - (BOOL)useCoreText if ([_useCoreTextAttr isEqualToString:@"false"]) { return NO; } - - if ([WXTextComponent textRenderUsingCoreText]) { - return YES; - } - return NO; + return YES; } - (void)dealloc diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h index 95fe14d30a..f4f5741c25 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h +++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h @@ -17,12 +17,6 @@ * under the License. */ -/** - * def : use weex_flex_engin - * ndef: use yoga - **/ - - #import #import "WXType.h" diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m index 00a53eeccc..a43b554aad 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m +++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m @@ -441,16 +441,7 @@ - (void)_renderWithMainBundleString:(NSString *)mainBundleString - (BOOL)_handleConfigCenter { id configCenter = [WXSDKEngine handlerForProtocol:@protocol(WXConfigCenterProtocol)]; - if ([configCenter respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) { - BOOL useCoreText = [[configCenter configForKey:@"iOS_weex_ext_config.text_render_useCoreText" defaultValue:@YES isDefault:NULL] boolValue]; - [WXTextComponent setRenderUsingCoreText:useCoreText]; - - BOOL unregisterFontWhenCollision = [[configCenter configForKey:@"iOS_weex_ext_config.unregisterFontWhenCollision" defaultValue:@NO isDefault:NULL] boolValue]; - [WXUtility setUnregisterFontWhenCollision:unregisterFontWhenCollision]; - - BOOL useJSCApiForCreateInstance = [[configCenter configForKey:@"iOS_weex_ext_config.useJSCApiForCreateInstance" defaultValue:@(YES) isDefault:NULL] boolValue]; - [WXUtility setUseJSCApiForCreateInstance:useJSCApiForCreateInstance]; - + if ([configCenter respondsToSelector:@selector(configForKey:defaultValue:isDefault:)]) { BOOL enableRTLLayoutDirection = [[configCenter configForKey:@"iOS_weex_ext_config.enableRTLLayoutDirection" defaultValue:@(YES) isDefault:NULL] boolValue]; [WXUtility setEnableRTLLayoutDirection:enableRTLLayoutDirection]; } diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h index f6acabd765..3829c8faf0 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h +++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h @@ -492,12 +492,6 @@ BOOL WXFloatGreaterThanWithPrecision(CGFloat a,CGFloat b,double precision); */ + (NSData *_Nonnull)base64DictToData:(NSDictionary *_Nullable)base64Dict; -+ (void)setUnregisterFontWhenCollision:(BOOL)value; - -+ (void)setUseJSCApiForCreateInstance:(BOOL)value; - -+ (BOOL)useJSCApiForCreateInstance; - + (void)setEnableRTLLayoutDirection:(BOOL)value; + (BOOL)enableRTLLayoutDirection; diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m index 47f0d003e2..740fd4c42c 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m +++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m @@ -42,8 +42,6 @@ #define KEY_PASSWORD @"com.taobao.Weex.123456" #define KEY_USERNAME_PASSWORD @"com.taobao.Weex.weex123456" -static BOOL unregisterFontWhenCollision = NO; -static BOOL useJSCApiForCreateInstance = YES; static BOOL enableRTLLayoutDirection = YES; void WXPerformBlockOnMainThread(void (^ _Nonnull block)(void)) @@ -140,21 +138,6 @@ CGFloat WXFloorPixelValue(CGFloat value) @implementation WXUtility -+ (void)setUnregisterFontWhenCollision:(BOOL)value -{ - unregisterFontWhenCollision = value; -} - -+ (void)setUseJSCApiForCreateInstance:(BOOL)value -{ - useJSCApiForCreateInstance = value; -} - -+ (BOOL)useJSCApiForCreateInstance -{ - return useJSCApiForCreateInstance; -} - + (void)performBlock:(void (^)(void))block onThread:(NSThread *)thread { if (!thread || !block) return; @@ -525,37 +508,14 @@ + (UIFont *)fontWithSize:(CGFloat)size textWeight:(CGFloat)textWeight textStyle: CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL(fontURL); if (fontDataProvider) { CGFontRef newFont = CGFontCreateWithDataProvider(fontDataProvider); - if (unregisterFontWhenCollision) { - CFErrorRef error = nil; - CTFontManagerRegisterGraphicsFont(newFont, &error); - // the same font family, remove it and register new one. - if (error) { - CTFontManagerUnregisterGraphicsFont(newFont, NULL); - CTFontManagerRegisterGraphicsFont(newFont, NULL); - CFRelease(error); - } - } - else { - CTFontManagerRegisterGraphicsFont(newFont, NULL); - } + CTFontManagerRegisterGraphicsFont(newFont, NULL); fontFamily = (__bridge_transfer NSString*)CGFontCopyPostScriptName(newFont); CGFontRelease(newFont); CFRelease(fontURL); CFRelease(fontDataProvider); } } else { - if (unregisterFontWhenCollision) { - CFErrorRef error = nil; - CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error); - if (error) { - CTFontManagerUnregisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL); - CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL); - CFRelease(error); - } - } - else { - CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL); - } + CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, NULL); NSArray *descriptors = (__bridge_transfer NSArray *)CTFontManagerCreateFontDescriptorsFromURL(fontURL); // length of descriptors here will be only one. for (UIFontDescriptor *desc in descriptors) { @@ -1026,63 +986,58 @@ + (long) getUnixFixTimeMillis NSMutableArray* allKeys = nil; - if ([self useJSCApiForCreateInstance]) { - JSContextRef contextRef = jsvalue.context.JSGlobalContextRef; - if (![jsvalue isObject]) { - WXAssert(NO, @"Invalid jsvalue for property enumeration."); - return nil; - } - JSValueRef jsException = NULL; - JSObjectRef instanceContextObjectRef = JSValueToObject(contextRef, jsvalue.JSValueRef, &jsException); - if (jsException != NULL) { - WXLogError(@"JSValueToObject Exception during create instance."); - } - BOOL somethingWrong = NO; - if (instanceContextObjectRef != NULL) { - JSPropertyNameArrayRef allKeyRefs = JSObjectCopyPropertyNames(contextRef, instanceContextObjectRef); - size_t keyCount = JSPropertyNameArrayGetCount(allKeyRefs); - - allKeys = [[NSMutableArray alloc] initWithCapacity:keyCount]; - for (size_t i = 0; i < keyCount; i ++) { - JSStringRef nameRef = JSPropertyNameArrayGetNameAtIndex(allKeyRefs, i); - size_t len = JSStringGetMaximumUTF8CStringSize(nameRef); - if (len > 1024) { - somethingWrong = YES; - break; - } - char* buf = (char*)malloc(len + 5); - if (buf == NULL) { - somethingWrong = YES; - break; - } - bzero(buf, len + 5); - if (JSStringGetUTF8CString(nameRef, buf, len + 5) > 0) { - NSString* keyString = [NSString stringWithUTF8String:buf]; - if ([keyString length] == 0) { - somethingWrong = YES; - free(buf); - break; - } - [allKeys addObject:keyString]; - } - else { + JSContextRef contextRef = jsvalue.context.JSGlobalContextRef; + if (![jsvalue isObject]) { + WXAssert(NO, @"Invalid jsvalue for property enumeration."); + return nil; + } + JSValueRef jsException = NULL; + JSObjectRef instanceContextObjectRef = JSValueToObject(contextRef, jsvalue.JSValueRef, &jsException); + if (jsException != NULL) { + WXLogError(@"JSValueToObject Exception during create instance."); + } + BOOL somethingWrong = NO; + if (instanceContextObjectRef != NULL) { + JSPropertyNameArrayRef allKeyRefs = JSObjectCopyPropertyNames(contextRef, instanceContextObjectRef); + size_t keyCount = JSPropertyNameArrayGetCount(allKeyRefs); + + allKeys = [[NSMutableArray alloc] initWithCapacity:keyCount]; + for (size_t i = 0; i < keyCount; i ++) { + JSStringRef nameRef = JSPropertyNameArrayGetNameAtIndex(allKeyRefs, i); + size_t len = JSStringGetMaximumUTF8CStringSize(nameRef); + if (len > 1024) { + somethingWrong = YES; + break; + } + char* buf = (char*)malloc(len + 5); + if (buf == NULL) { + somethingWrong = YES; + break; + } + bzero(buf, len + 5); + if (JSStringGetUTF8CString(nameRef, buf, len + 5) > 0) { + NSString* keyString = [NSString stringWithUTF8String:buf]; + if ([keyString length] == 0) { somethingWrong = YES; free(buf); break; } + [allKeys addObject:keyString]; + } + else { + somethingWrong = YES; free(buf); + break; } - JSPropertyNameArrayRelease(allKeyRefs); - } else { - somethingWrong = YES; - } - - if (somethingWrong) { - // may contain retain-cycle. - allKeys = (NSMutableArray*)[[jsvalue toDictionary] allKeys]; + free(buf); } + JSPropertyNameArrayRelease(allKeyRefs); + } else { + somethingWrong = YES; } - else { + + if (somethingWrong) { + // may contain retain-cycle. allKeys = (NSMutableArray*)[[jsvalue toDictionary] allKeys]; }