You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/07/13 07:28:53 UTC

[1/6] incubator-weex git commit: * [ios] fix local scheme url rewrite

Repository: incubator-weex
Updated Branches:
  refs/heads/0.15-dev ed6504196 -> a609a7f84


* [ios] fix local scheme url rewrite


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/6408366e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/6408366e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/6408366e

Branch: refs/heads/0.15-dev
Commit: 6408366e6e1553c462e74db2108ad12059d24a23
Parents: 3d97c00
Author: acton393 <zh...@gmail.com>
Authored: Thu Jul 13 11:47:25 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jul 13 11:47:25 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Handler/WXURLRewriteDefaultImpl.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/6408366e/ios/sdk/WeexSDK/Sources/Handler/WXURLRewriteDefaultImpl.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Handler/WXURLRewriteDefaultImpl.m b/ios/sdk/WeexSDK/Sources/Handler/WXURLRewriteDefaultImpl.m
index 3e8950a..bcd7215 100644
--- a/ios/sdk/WeexSDK/Sources/Handler/WXURLRewriteDefaultImpl.m
+++ b/ios/sdk/WeexSDK/Sources/Handler/WXURLRewriteDefaultImpl.m
@@ -34,7 +34,7 @@ NSString *const WXURLLocalScheme = @"local";
     if ([completeURL isFileURL]) {
         return completeURL;
     } else if ([self isLocalURL:completeURL]) {
-        NSString *resourceName = [[completeURL host] stringByAppendingString:[completeURL path]];
+        NSString *resourceName = [[completeURL host]?:@"" stringByAppendingString:[completeURL path]];
         NSURL *resourceURL = [[NSBundle mainBundle] URLForResource:resourceName withExtension:@""];
         if (!resourceURL) {
             WXLogError(@"Invalid local resource URL:%@, no resouce found.", url);


[6/6] incubator-weex git commit: Merge branch '0.15-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex into wip-us-0.15-dev

Posted by ac...@apache.org.
Merge branch '0.15-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex into wip-us-0.15-dev


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/a609a7f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/a609a7f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/a609a7f8

Branch: refs/heads/0.15-dev
Commit: a609a7f84d94b141d581e677f4758534735804f0
Parents: ebb23bb ed65041
Author: acton393 <zh...@gmail.com>
Authored: Thu Jul 13 15:25:57 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jul 13 15:25:57 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Bridge/WXBridgeContext.m    | 33 ++++++++++----------
 1 file changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------



[5/6] incubator-weex git commit: Merge branch 'ios-feature-0.15-text-lock' of https://github.com/acton393/incubator-weex into wip-us-0.15-dev

Posted by ac...@apache.org.
Merge branch 'ios-feature-0.15-text-lock' of https://github.com/acton393/incubator-weex into wip-us-0.15-dev


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ebb23bb1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ebb23bb1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ebb23bb1

Branch: refs/heads/0.15-dev
Commit: ebb23bb190e236839fed74272c846bfcb3414fed
Parents: e0ed204 eb69d00
Author: acton393 <zh...@gmail.com>
Authored: Thu Jul 13 15:23:29 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jul 13 15:23:29 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXTextComponent.m | 51 ++++++++------------
 1 file changed, 20 insertions(+), 31 deletions(-)
----------------------------------------------------------------------



[4/6] incubator-weex git commit: * [ios] fix text height @nodanger

Posted by ac...@apache.org.
* [ios] fix text height @nodanger


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/eb69d00c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/eb69d00c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/eb69d00c

Branch: refs/heads/0.15-dev
Commit: eb69d00cef4561e06946f6c24b9ced095ca8217e
Parents: 8381657
Author: acton393 <zh...@gmail.com>
Authored: Thu Jul 13 14:46:37 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jul 13 14:46:37 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/eb69d00c/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index 680be09..7d873a1 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -896,7 +896,7 @@ do {\
         }
         return suggestSize;
     }
-    return CGSizeMake(!isnan(aWidth)? aWidth :suggestSize.width, totalHeight >suggestSize.height? totalHeight:suggestSize.height);
+    return CGSizeMake(!isnan(aWidth)? aWidth :suggestSize.width, totalHeight);
 }
 
 static void WXTextGetRunsMaxMetric(CFArrayRef runs, CGFloat *xHeight, CGFloat *underlinePosition, CGFloat *lineThickness)


[2/6] incubator-weex git commit: * [ios] use copy instead of mutable copy @notdanger

Posted by ac...@apache.org.
* [ios] use copy instead of mutable copy @notdanger


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e0ed204a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e0ed204a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e0ed204a

Branch: refs/heads/0.15-dev
Commit: e0ed204af4ca75e7cfd3ddcefc8b67e12175a662
Parents: 6408366
Author: acton393 <zh...@gmail.com>
Authored: Thu Jul 13 11:49:21 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jul 13 11:49:21 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXAComponent.m        | 2 +-
 ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m    | 4 ++--
 ios/sdk/WeexSDK/Sources/Component/WXVideoComponent.m    | 2 +-
 ios/sdk/WeexSDK/Sources/Component/WXWebComponent.m      | 2 +-
 ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m         | 2 +-
 ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m         | 2 +-
 ios/sdk/WeexSDK/Sources/Protocol/WXURLRewriteProtocol.h | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e0ed204a/ios/sdk/WeexSDK/Sources/Component/WXAComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXAComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXAComponent.m
index bd39f36..c777440 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXAComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXAComponent.m
@@ -66,7 +66,7 @@
     }
     
     if (_href && [_href length] > 0) {
-        NSMutableString *newURL = [_href mutableCopy];
+        NSString *newURL = [_href copy];
         WX_REWRITE_URL(_href, WXResourceTypeLink, self.weexInstance)
         if (!newURL) {
             return;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e0ed204a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index 5c6cd05..86af74d 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -269,7 +269,7 @@ static dispatch_queue_t WXImageUpdateQueue;
     
     if (placeholderSrc) {
         WXLogDebug(@"Updating image, component:%@, placeholder:%@ ", self.ref, placeholderSrc);
-        NSMutableString *newURL = [_placeholdSrc mutableCopy];
+        NSString *newURL = [_placeholdSrc copy];
         WX_REWRITE_URL(_placeholdSrc, WXResourceTypeImage, self.weexInstance)
         
         __weak typeof(self) weakSelf = self;
@@ -308,7 +308,7 @@ static dispatch_queue_t WXImageUpdateQueue;
     if (imageSrc) {
         WXLogDebug(@"Updating image:%@, component:%@", self.imageSrc, self.ref);
         NSDictionary *userInfo = @{@"imageQuality":@(self.imageQuality), @"imageSharp":@(self.imageSharp), @"blurRadius":@(self.blurRadius)};
-        NSMutableString * newURL = [imageSrc mutableCopy];
+        NSString * newURL = [imageSrc copy];
         WX_REWRITE_URL(imageSrc, WXResourceTypeImage, self.weexInstance)
         __weak typeof(self) weakSelf = self;
         dispatch_async(dispatch_get_main_queue(), ^{

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e0ed204a/ios/sdk/WeexSDK/Sources/Component/WXVideoComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXVideoComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXVideoComponent.m
index b1b22bd..15c674b 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXVideoComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXVideoComponent.m
@@ -150,7 +150,7 @@
 
 - (void)setURL:(NSURL *)URL
 {
-    NSMutableString *newURL = nil;
+    NSString *newURL = [URL.absoluteString copy];
     WX_REWRITE_URL(URL.absoluteString, WXResourceTypeVideo, self.weexSDKInstance)
     
     if (!newURL) {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e0ed204a/ios/sdk/WeexSDK/Sources/Component/WXWebComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXWebComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXWebComponent.m
index ab8b63d..0ae4974 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXWebComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXWebComponent.m
@@ -117,7 +117,7 @@ WX_EXPORT_METHOD(@selector(goForward))
 
 - (void)setUrl:(NSString *)url
 {
-    NSMutableString* newURL = [url mutableCopy];
+    NSString* newURL = [url copy];
     WX_REWRITE_URL(url, WXResourceTypeLink, self.weexInstance)
     if (!newURL) {
         return;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e0ed204a/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m b/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m
index a348b21..00a2772 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXRuleManager.m
@@ -74,7 +74,7 @@ static WXRuleManager *_sharedInstance = nil;
             }
             
             NSString *fontSrc = [rule[@"src"] substringWithRange:NSMakeRange(start, end-start)];
-            NSMutableString *newURL = [fontSrc mutableCopy];
+            NSString *newURL = [fontSrc copy];
             WX_REWRITE_URL(fontSrc, WXResourceTypeFont, self.instance)
             
             if (!newURL) {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e0ed204a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m b/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
index d7c5a8b..cb591bd 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXStreamModule.m
@@ -107,7 +107,7 @@ WX_EXPORT_METHOD(@selector(fetch:callback:progressCallback:))
 {
     // parse request url
     NSString *urlStr = [options objectForKey:@"url"];
-    NSMutableString *newURL = [urlStr mutableCopy];
+    NSString *newURL = [urlStr copy];
     WX_REWRITE_URL(urlStr, WXResourceTypeLink, self.weexInstance)
     urlStr = newURL;
     

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e0ed204a/ios/sdk/WeexSDK/Sources/Protocol/WXURLRewriteProtocol.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Protocol/WXURLRewriteProtocol.h b/ios/sdk/WeexSDK/Sources/Protocol/WXURLRewriteProtocol.h
index 38a12d3..2ed72e4 100644
--- a/ios/sdk/WeexSDK/Sources/Protocol/WXURLRewriteProtocol.h
+++ b/ios/sdk/WeexSDK/Sources/Protocol/WXURLRewriteProtocol.h
@@ -26,7 +26,7 @@
 do {\
     id<WXURLRewriteProtocol> rewriteHandler = [WXHandlerFactory handlerForProtocol:@protocol(WXURLRewriteProtocol)];\
     if ([rewriteHandler respondsToSelector:@selector(rewriteURL:withResourceType:withInstance:)]) {\
-        newURL = [[rewriteHandler rewriteURL:url withResourceType:resourceType withInstance:instance].absoluteString mutableCopy];\
+        newURL = [[rewriteHandler rewriteURL:url withResourceType:resourceType withInstance:instance].absoluteString copy];\
     }\
 } while(0);
 


[3/6] incubator-weex git commit: * [ios] fix text trim tail white space and fix thread safe

Posted by ac...@apache.org.
* [ios] fix text trim tail white space and fix thread safe


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/83816574
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/83816574
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/83816574

Branch: refs/heads/0.15-dev
Commit: 83816574ae83a7ac1fb65c3fb96807c79ee3310a
Parents: 3d97c00
Author: acton393 <zh...@gmail.com>
Authored: Thu Jul 13 14:34:29 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jul 13 14:34:29 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Component/WXTextComponent.m | 51 ++++++++------------
 1 file changed, 20 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/83816574/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index a092019..680be09 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -119,9 +119,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
     
     BOOL _needsRemoveObserver;
     NSAttributedString * _ctAttributedString;
-    CTFramesetterRef _ctframeSetter;
     
-    pthread_mutex_t _ctFrameSetterMutex;
     pthread_mutex_t _ctAttributedStringMutex;
     pthread_mutexattr_t _propertMutexAttr;
 }
@@ -149,7 +147,6 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
         _needsRemoveObserver = NO;
         pthread_mutexattr_init(&(_propertMutexAttr));
         pthread_mutexattr_settype(&(_propertMutexAttr), PTHREAD_MUTEX_RECURSIVE);
-        pthread_mutex_init(&(_ctFrameSetterMutex), &(_propertMutexAttr));
         pthread_mutex_init(&(_ctAttributedStringMutex), &(_propertMutexAttr));
         
         if ([attributes objectForKey:@"coretext"]) {
@@ -186,12 +183,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
         [[NSNotificationCenter defaultCenter] removeObserver:self name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil];
     }
     _ctAttributedString = nil;
-    if(NULL != _ctframeSetter) {
-        CFRelease(_ctframeSetter);
-        _ctframeSetter = NULL;
-    }
     pthread_mutex_destroy(&_ctAttributedStringMutex);
-    pthread_mutex_destroy(&_ctFrameSetterMutex);
     pthread_mutexattr_destroy(&_propertMutexAttr);
 }
 
@@ -260,10 +252,6 @@ do {\
 {
     _textStorage = nil;
     _ctAttributedString = nil;
-    if(NULL != _ctframeSetter) {
-        CFRelease(_ctframeSetter);
-        _ctframeSetter = NULL;
-    }
 }
 
 #pragma mark - Subclass
@@ -368,16 +356,6 @@ do {\
     return [_ctAttributedString copy];
 }
 
-- (CTFramesetterRef)ctFramesetterRef
-{
-    pthread_mutex_lock(&(_ctFrameSetterMutex));
-    if (NULL == _ctframeSetter) {
-        _ctframeSetter = CTFramesetterCreateWithAttributedString((CFTypeRef)[self ctAttributedString]);
-    }
-    pthread_mutex_unlock(&(_ctFrameSetterMutex));
-    return _ctframeSetter;
-}
-
 - (void)repaintText:(NSNotification *)notification
 {
     if (![_fontFamily isEqualToString:notification.userInfo[@"fontFamily"]]) {
@@ -655,13 +633,20 @@ do {\
         CTFrameRef _coreTextFrameRef = NULL;
         if (_coreTextFrameRef) {
             CFRelease(_coreTextFrameRef);
+            _coreTextFrameRef = NULL;
+        }
+        if(!attributedStringCopy) {
+            return;
         }
-        _coreTextFrameRef = CTFramesetterCreateFrame([self ctFramesetterRef], CFRangeMake(0, attributedStringCopy.length), cgPath, NULL);
+        CTFramesetterRef ctframesetterRef = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)(attributedStringCopy));
+        _coreTextFrameRef = CTFramesetterCreateFrame(ctframesetterRef, CFRangeMake(0, attributedStringCopy.length), cgPath, NULL);
         CFArrayRef ctLines = NULL;
         if (NULL == _coreTextFrameRef) {
             // try to protect crash from frame is NULL
             return;
         }
+        CFRelease(ctframesetterRef);
+        ctframesetterRef = NULL;
         ctLines = CTFrameGetLines(_coreTextFrameRef);
         CFIndex lineCount = CFArrayGetCount(ctLines);
         NSMutableArray * mutableLines = [NSMutableArray new];
@@ -854,14 +839,17 @@ do {\
 
 - (CGSize)calculateTextHeightWithWidth:(CGFloat)aWidth
 {
-    if (isnan(aWidth)) {
-        aWidth = CGFLOAT_MAX;
-    }
-    
     CGFloat totalHeight = 0;
     CGSize suggestSize = CGSizeZero;
     NSAttributedString * attributedStringCpy = [self ctAttributedString];
-    suggestSize = CTFramesetterSuggestFrameSizeWithConstraints([self ctFramesetterRef], CFRangeMake(0, attributedStringCpy.length), NULL, CGSizeMake(aWidth, MAXFLOAT), NULL);
+    if (!attributedStringCpy) {
+        return CGSizeZero;
+    }
+    if (isnan(aWidth)) {
+        aWidth = [attributedStringCpy boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading context:nil].size.width;
+    }
+    CTFramesetterRef ctframesetterRef = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)(attributedStringCpy));
+    suggestSize = CTFramesetterSuggestFrameSizeWithConstraints(ctframesetterRef, CFRangeMake(0, 0), NULL, CGSizeMake(aWidth, MAXFLOAT), NULL);
     
     CGMutablePathRef path = NULL;
     path = CGPathCreateMutable();
@@ -869,7 +857,7 @@ do {\
     CGPathAddRect(path, NULL, CGRectMake(0, 0, aWidth, suggestSize.height * 10));
         
     CTFrameRef frameRef = NULL;
-    frameRef = CTFramesetterCreateFrame([self ctFramesetterRef], CFRangeMake(0, attributedStringCpy.length), path, NULL);
+    frameRef = CTFramesetterCreateFrame(ctframesetterRef, CFRangeMake(0, attributedStringCpy.length), path, NULL);
     CGPathRelease(path);
     
     CFArrayRef lines = NULL;
@@ -877,6 +865,8 @@ do {\
         //try to protect unexpected crash.
         return suggestSize;
     }
+    CFRelease(ctframesetterRef);
+    ctframesetterRef = NULL;
     lines = CTFrameGetLines(frameRef);
     CFIndex lineCount = CFArrayGetCount(lines);
     CGFloat ascent = 0;
@@ -906,8 +896,7 @@ do {\
         }
         return suggestSize;
     }
-    
-    return CGSizeMake(suggestSize.width, totalHeight);
+    return CGSizeMake(!isnan(aWidth)? aWidth :suggestSize.width, totalHeight >suggestSize.height? totalHeight:suggestSize.height);
 }
 
 static void WXTextGetRunsMaxMetric(CFArrayRef runs, CGFloat *xHeight, CGFloat *underlinePosition, CGFloat *lineThickness)