Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Revert "Fix rc 0.20"
Browse files Browse the repository at this point in the history
  • Loading branch information
jondong committed Nov 21, 2018
1 parent f060ad8 commit b79bb7c
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 251 deletions.
3 changes: 0 additions & 3 deletions ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ - (id)initWithFrame:(CGRect)frame
_currentIndex = 0;
_itemViews = [[NSMutableArray alloc] init];
_scrollView = [[WXRecycleSliderScrollView alloc] init];
if (@available(iOS 11.0, *)) {
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
_scrollView.backgroundColor = [UIColor clearColor];
_scrollView.delegate = self;
_scrollView.showsHorizontalScrollIndicator = NO;
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
}
if (!decelerate) {
_isScrolling = NO;
[self performSelector:@selector(scrollViewDidEndDecelerating:) withObject:scrollView afterDelay:0.1];
[self performSelector:@selector(scrollViewDidEndDecelerating:) withObject:nil afterDelay:0.1];
}

NSHashTable *delegates = [_delegates copy];
Expand Down
30 changes: 1 addition & 29 deletions ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,6 @@
*/
+ (void)registerService:(NSString *)name withScript:(NSString *)serviceScript withOptions:(NSDictionary *)options;

/**
* @abstract Registers a component for a given name, options and js code
*
* @param name The service name to register
*
* @param options The service options to register
*
* @param serviceScript service js code to invoke
*
* @param completion Completion callback. JS is executed in asynchronously.
*
*/
+ (void)registerService:(NSString *)name withScript:(NSString *)serviceScript withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion;

/**
* @abstract Registers a component for a given name, options and js url
*
Expand All @@ -106,21 +92,7 @@
* @param serviceScriptUrl The service url to register
*
*/
+ (void)registerService:(NSString *)name withScriptUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options;

/**
* @abstract Registers a component for a given name, options and js url
*
* @param name The service name to register
*
* @param options The service options to register
*
* @param serviceScriptUrl The service url to register
*
* @param completion Completion callback. JS is executed in asynchronously.
*
*/
+ (void)registerService:(NSString *)name withScriptUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion;
+ (void)registerService:(NSString *)name withScriptUrl:(NSURL *)serviceScriptUrl WithOptions:(NSDictionary *)options;

/**
* @abstract Registers a component for a given name, options and js code
Expand Down
17 changes: 3 additions & 14 deletions ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,14 @@ + (void)registerComponent:(NSString *)name withClass:(Class)clazz withProperties


# pragma mark Service Register

+ (void)registerService:(NSString *)name withScript:(NSString *)serviceScript withOptions:(NSDictionary *)options
{
[[WXSDKManager bridgeMgr] registerService:name withService:serviceScript withOptions:options completion:nil];
}

+ (void)registerService:(NSString *)name withScript:(NSString *)serviceScript withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion
{
[[WXSDKManager bridgeMgr] registerService:name withService:serviceScript withOptions:options completion:completion];
}

+ (void)registerService:(NSString *)name withScriptUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options
{
[[WXSDKManager bridgeMgr] registerService:name withServiceUrl:serviceScriptUrl withOptions:options completion:nil];
[[WXSDKManager bridgeMgr] registerService:name withService:serviceScript withOptions:options];
}

+ (void)registerService:(NSString *)name withScriptUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion
+ (void)registerService:(NSString *)name withScriptUrl:(NSURL *)serviceScriptUrl WithOptions:(NSDictionary *)options
{
[[WXSDKManager bridgeMgr] registerService:name withServiceUrl:serviceScriptUrl withOptions:options completion:completion];
[[WXSDKManager bridgeMgr] registerService:name withServiceUrl:serviceScriptUrl withOptions:options];
}

+ (void)unregisterService:(NSString *)name
Expand Down
72 changes: 1 addition & 71 deletions ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,13 @@
#ifdef __cplusplus
#include "layout.h"

typedef WeexCore::WXCoreFlexDirection WXCoreFlexDirection;
typedef WeexCore::WXCoreFlexWrap WXCoreFlexWrap;
typedef WeexCore::WXCoreJustifyContent WXCoreJustifyContent;
typedef WeexCore::WXCoreAlignItems WXCoreAlignItems;
typedef WeexCore::WXCoreAlignSelf WXCoreAlignSelf;
typedef WeexCore::WXCorePositionType WXCorePositionType;

extern "C" {
#endif
bool flexIsUndefined(float value);
#ifdef __cplusplus
}
#endif

#ifndef __cplusplus
// Ensure that .m files can use css style enum definitions.
#include "flex_enum.h"

typedef enum WXCoreFlexDirection WXCoreFlexDirection;
typedef enum WXCoreFlexWrap WXCoreFlexWrap;
typedef enum WXCoreJustifyContent WXCoreJustifyContent;
typedef enum WXCoreAlignItems WXCoreAlignItems;
typedef enum WXCoreAlignSelf WXCoreAlignSelf;
typedef enum WXCorePositionType WXCorePositionType;

#endif

@interface WXComponent ()
{
@package
Expand All @@ -71,59 +51,9 @@ typedef enum WXCorePositionType WXCorePositionType;
* @warning Subclasses must not override this.
*/
#ifdef __cplusplus
@property (nonatomic, readonly, assign) WeexCore::WXCoreLayoutNode *flexCssNode;
@property(nonatomic, readonly, assign) WeexCore::WXCoreLayoutNode *flexCssNode;
#endif

/**
* @abstract Get css style value for key. The key should be of CSS standard form.
* This method is for convenience use in C/ObjC environment. And if you want to
* retrieve all style values or in C++, you could use flexCssNode directly.
*
* Thread usage:
* This method should be invoked in component thread by WXPerformBlockOnComponentThread.
* Note that all initWithRef methods of WXComponent and its subclasses are performed in
* component thread by default. Therefore you can call this method directly in initWithRef.
*
* Supported keys:
* width, height, min-width, min-height, max-width, max-height,
* margin-(left/right/top/bottom)
* padding-(left/right/top/bottom)
* border-(left/right/top/bottom)-width
* left, right, top, bottom
* flex-grow
*/
- (float)getCssStyleValueForKey:(NSString *)key;

/**
* @abstract Get css style flex-direction. Thread usage the same as getCssStyleValueForKey.
*/
- (WXCoreFlexDirection)getCssStyleFlexDirection;

/**
* @abstract Get css style flex-wrap. Thread usage the same as getCssStyleValueForKey.
*/
- (WXCoreFlexWrap)getCssStyleFlexWrap;

/**
* @abstract Get css style justify-content. Thread usage the same as getCssStyleValueForKey.
*/
- (WXCoreJustifyContent)getCssStyleJustifyContent;

/**
* @abstract Get css style align-items. Thread usage the same as getCssStyleValueForKey.
*/
- (WXCoreAlignItems)getCssStyleAlignItems;

/**
* @abstract Get css style align-self. Thread usage the same as getCssStyleValueForKey.
*/
- (WXCoreAlignSelf)getCssStyleAlignSelf;

/**
* @abstract Get css style position. Thread usage the same as getCssStyleValueForKey.
*/
- (WXCorePositionType)getCssStylePositionType;

/**
* @abstract Convert layout dimension value like 'left', 'width' to style value in js considering viewport and scale.
*/
Expand Down
80 changes: 0 additions & 80 deletions ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -366,86 +366,6 @@ - (CGFloat)judgePropValuePropValue:(id)propValue defaultValue:(CGFloat)defaultVa
return defaultValue;
}

- (float)getCssStyleValueForKey:(NSString *)key
{
/*
* width, height, min-width, min-height, max-width, max-height,
* margin-(left/right/top/bottom)
* padding-(left/right/top/bottom)
* border-(left/right/top/bottom)-width
* left, right, top, bottom
* flex-grow
*/
WXAssert(_flexCssNode != nullptr, @"Css node is null.");
if (_flexCssNode == nullptr) {
return NAN;
}

std::string ckey = [key UTF8String];
if (ckey == "width") return _flexCssNode->getStyleWidth();
if (ckey == "height") return _flexCssNode->getStyleHeight();
if (ckey == "min-width") return _flexCssNode->getMinWidth();
if (ckey == "min-height") return _flexCssNode->getMinHeight();
if (ckey == "max-width") return _flexCssNode->getMaxWidth();
if (ckey == "max-height") return _flexCssNode->getMaxHeight();
if (ckey == "margin-left") return _flexCssNode->getMarginLeft();
if (ckey == "margin-right") return _flexCssNode->getMarginRight();
if (ckey == "margin-top") return _flexCssNode->getMarginTop();
if (ckey == "margin-bottom") return _flexCssNode->getMarginBottom();
if (ckey == "padding-left") return _flexCssNode->getPaddingLeft();
if (ckey == "padding-right") return _flexCssNode->getPaddingRight();
if (ckey == "padding-top") return _flexCssNode->getPaddingTop();
if (ckey == "padding-bottom") return _flexCssNode->getPaddingBottom();
if (ckey == "border-left-width") return _flexCssNode->getBorderWidthLeft();
if (ckey == "border-right-width") return _flexCssNode->getBorderWidthRight();
if (ckey == "border-top-width") return _flexCssNode->getBorderWidthTop();
if (ckey == "border-bottom-width") return _flexCssNode->getBorderWidthBottom();
if (ckey == "left") return _flexCssNode->getStylePositionLeft();
if (ckey == "right") return _flexCssNode->getStylePositionRight();
if (ckey == "top") return _flexCssNode->getStylePositionTop();
if (ckey == "bottom") return _flexCssNode->getStylePositionBottom();
if (ckey == "flex-grow") return _flexCssNode->getFlex();

WXAssert(NO, @"Invalid css style key %@", key);
return NAN;
}

- (WXCoreFlexDirection)getCssStyleFlexDirection
{
WXAssert(_flexCssNode != nullptr, @"Css node is null.");
return _flexCssNode ? _flexCssNode->getFlexDirection() : kFlexDirectionColumn;
}

- (WXCoreFlexWrap)getCssStyleFlexWrap
{
WXAssert(_flexCssNode != nullptr, @"Css node is null.");
return _flexCssNode ? _flexCssNode->getFlexWrap() : kNoWrap;
}

- (WXCoreJustifyContent)getCssStyleJustifyContent
{
WXAssert(_flexCssNode != nullptr, @"Css node is null.");
return _flexCssNode ? _flexCssNode->getJustifyContent() : kJustifyFlexStart;
}

- (WXCoreAlignItems)getCssStyleAlignItems
{
WXAssert(_flexCssNode != nullptr, @"Css node is null.");
return _flexCssNode ? _flexCssNode->getAlignItems() : kAlignItemsStretch;
}

- (WXCoreAlignSelf)getCssStyleAlignSelf
{
WXAssert(_flexCssNode != nullptr, @"Css node is null.");
return _flexCssNode ? _flexCssNode->getAlignSelf() : kAlignSelfAuto;
}

- (WXCorePositionType)getCssStylePositionType
{
WXAssert(_flexCssNode != nullptr, @"Css node is null.");
return _flexCssNode ? _flexCssNode->getStylePositionType() : kRelative;
}

- (NSString*)convertLayoutValueToStyleValue:(NSString*)valueName
{
if (_flexCssNode == nullptr) {
Expand Down
7 changes: 3 additions & 4 deletions ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,18 @@ extern void WXPerformBlockOnBridgeThread(void (^block)(void));
* @param name : service name
* @param serviceScript : script code
* @param options : service options
* @param completion : completion callback
**/
- (void)registerService:(NSString *)name withService:(NSString *)serviceScript withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion;
- (void)registerService:(NSString *)name withService:(NSString *)serviceScript withOptions:(NSDictionary *)options;


/**
* Register JS service Script
* @param name : service name
* @param serviceScriptUrl : script url
* @param options : service options
* @param completion : completion callback
**/
-(void)registerService:(NSString *)name withServiceUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion;

-(void)registerService:(NSString *)name withServiceUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options;

/**
* Unregister JS service Script
Expand Down
26 changes: 5 additions & 21 deletions ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -288,41 +288,28 @@ - (JSValue *)callJSMethodWithResult:(WXCallJSMethod *)method
return value;
}

- (void)registerService:(NSString *)name withServiceUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion
-(void)registerService:(NSString *)name withServiceUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options
{
if (!name || !serviceScriptUrl || !options) {
if (completion) {
completion(NO);
}
return;
}
if (!name || !serviceScriptUrl || !options) return;
__weak typeof(self) weakSelf = self;
WXResourceRequest *request = [WXResourceRequest requestWithURL:serviceScriptUrl resourceType:WXResourceTypeServiceBundle referrer:@"" cachePolicy:NSURLRequestUseProtocolCachePolicy];
WXResourceLoader *serviceBundleLoader = [[WXResourceLoader alloc] initWithRequest:request];;
serviceBundleLoader.onFinished = ^(WXResourceResponse *response, NSData *data) {
__strong typeof(weakSelf) strongSelf = weakSelf;
NSString *jsServiceString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[strongSelf registerService:name withService:jsServiceString withOptions:options completion:completion];
[strongSelf registerService:name withService:jsServiceString withOptions:options];
};

serviceBundleLoader.onFailed = ^(NSError *loadError) {
WXLogError(@"No script URL found");
if (completion) {
completion(NO);
}
};

[serviceBundleLoader start];
}

- (void)registerService:(NSString *)name withService:(NSString *)serviceScript withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion
- (void)registerService:(NSString *)name withService:(NSString *)serviceScript withOptions:(NSDictionary *)options
{
if (!name || !serviceScript || !options) {
if (completion) {
completion(NO);
}
return;
}
if (!name || !serviceScript || !options) return;

NSString *script = [WXServiceFactory registerServiceScript:name withRawScript:serviceScript withOptions:options];

Expand All @@ -331,9 +318,6 @@ - (void)registerService:(NSString *)name withService:(NSString *)serviceScript w
// save it when execute
[WXDebugTool cacheJsService:name withScript:serviceScript withOptions:options];
[weakSelf.bridgeCtx executeJsService:script withName:name];
if (completion) {
completion(YES);
}
});
}

Expand Down
13 changes: 11 additions & 2 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ @implementation WXSDKInstance
BOOL _debugJS;
id<WXBridgeProtocol> _instanceJavaScriptContext; // sandbox javaScript context
CGFloat _defaultPixelScaleFactor;
BOOL _bReleaseInstanceInMainThread;
BOOL _defaultDataRender;
}

Expand Down Expand Up @@ -117,6 +118,7 @@ - (instancetype)init
_apmInstance = [[WXApmForInstance alloc] init];

_defaultPixelScaleFactor = CGFLOAT_MIN;
_bReleaseInstanceInMainThread = YES;
_defaultDataRender = NO;

[self addObservers];
Expand Down Expand Up @@ -441,6 +443,9 @@ - (BOOL)_handleConfigCenter

BOOL useJSCApiForCreateInstance = [[configCenter configForKey:@"iOS_weex_ext_config.useJSCApiForCreateInstance" defaultValue:@(YES) isDefault:NULL] boolValue];
[WXUtility setUseJSCApiForCreateInstance:useJSCApiForCreateInstance];

//Reading config from orange for Release instance in Main Thread or not
_bReleaseInstanceInMainThread = [[configCenter configForKey:@"iOS_weex_ext_config.releaseInstanceInMainThread" defaultValue:@(YES) isDefault:nil] boolValue];

BOOL shoudMultiContext = NO;
shoudMultiContext = [[configCenter configForKey:@"iOS_weex_ext_config.createInstanceUsingMutliContext" defaultValue:@(YES) isDefault:NULL] boolValue];
Expand Down Expand Up @@ -654,9 +659,13 @@ - (void)destroyInstance
[WXCoreBridge closePage:instanceId];

// Reading config from orange for Release instance in Main Thread or not, for Bug #15172691 +{
dispatch_async(dispatch_get_main_queue(), ^{
if (!_bReleaseInstanceInMainThread) {
[WXSDKManager removeInstanceforID:instanceId];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[WXSDKManager removeInstanceforID:instanceId];
});
}
//+}
});

Expand Down
Loading

0 comments on commit b79bb7c

Please sign in to comment.