You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/01/02 08:58:35 UTC

[GitHub] doumafang closed pull request #1986: [iOS] Remove unused options.

doumafang closed pull request #1986: [iOS] Remove unused options.
URL: https://github.com/apache/incubator-weex/pull/1986
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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<WXConfigCenterProtocol> 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 <Foundation/Foundation.h>
 #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];
     }
     


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services