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/06/22 09:46:53 UTC
[1/8] incubator-weex git commit: * [ios]cache ctframesetter improve
draw text performance
Repository: incubator-weex
Updated Branches:
refs/heads/0.15-dev 450ba37ef -> 193ecb069
* [ios]cache ctframesetter improve draw text performance
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/7f71c8bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/7f71c8bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/7f71c8bc
Branch: refs/heads/0.15-dev
Commit: 7f71c8bc1307aa3bdeef6d861009843183922b36
Parents: 29fb9a8
Author: acton393 <zh...@gmail.com>
Authored: Mon Jun 19 20:28:58 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Mon Jun 19 20:28:58 2017 +0800
----------------------------------------------------------------------
.../WeexSDK/Sources/Component/WXTextComponent.m | 39 ++++++++++++--------
1 file changed, 24 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7f71c8bc/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 546ca03..72b4052 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -93,7 +93,7 @@ NSString *const WXTextTruncationToken = @"\u2026";
CGFloat WXTextDefaultLineThroughWidth = 1.2;
@interface WXTextComponent()
-@property (nonatomic, assign) NSString *useCoreTextAttr;
+@property (nonatomic, strong) NSString *useCoreTextAttr;
@end
@implementation WXTextComponent
@@ -119,6 +119,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
BOOL _needsRemoveObserver;
NSMutableAttributedString * _ctAttributedString;
+ CTFramesetterRef _ctframeSetter;
}
+ (void)setRenderUsingCoreText:(BOOL)usingCoreText
@@ -176,6 +177,11 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
if (_needsRemoveObserver) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil];
}
+ _ctAttributedString = nil;
+ if(NULL != _ctframeSetter) {
+ CFRelease(_ctframeSetter);
+ _ctframeSetter = NULL;
+ }
}
#define WX_STYLE_FILL_TEXT(key, prop, type, needLayout)\
@@ -243,6 +249,10 @@ do {\
{
_textStorage = nil;
_ctAttributedString = nil;
+ if(NULL != _ctframeSetter) {
+ CFRelease(_ctframeSetter);
+ _ctframeSetter = NULL;
+ }
}
#pragma mark - Subclass
@@ -345,6 +355,14 @@ do {\
return _ctAttributedString;
}
+- (CTFramesetterRef)ctFramesetterRef
+{
+ if (NULL == _ctframeSetter) {
+ _ctframeSetter = CTFramesetterCreateWithAttributedString((CFTypeRef)[self ctAttributedString]);
+ }
+ return _ctframeSetter;
+}
+
- (void)repaintText:(NSNotification *)notification
{
if (![_fontFamily isEqualToString:notification.userInfo[@"fontFamily"]]) {
@@ -619,15 +637,11 @@ do {\
//add path
CGPathRef cgPath = NULL;
cgPath = CGPathCreateWithRect(textFrame, NULL);
- CTFramesetterRef framesetter = NULL;
- framesetter = CTFramesetterCreateWithAttributedString((CFTypeRef)attributedStringCopy);
CTFrameRef _coreTextFrameRef = NULL;
if (_coreTextFrameRef) {
CFRelease(_coreTextFrameRef);
}
- _coreTextFrameRef = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), cgPath, NULL);
- CFRelease(framesetter);
- framesetter = NULL;
+ _coreTextFrameRef = CTFramesetterCreateFrame([self ctFramesetterRef], CFRangeMake(0, 0), cgPath, NULL);
CFArrayRef ctLines = NULL;
ctLines = CTFrameGetLines(_coreTextFrameRef);
CFIndex lineCount = CFArrayGetCount(ctLines);
@@ -828,22 +842,16 @@ do {\
CGFloat totalHeight = 0;
CGSize suggestSize = CGSizeZero;
NSAttributedString * attributedStringCpy = [self ctAttributedString];
- CTFramesetterRef framesetterRef = NULL;
- framesetterRef = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedStringCpy);
-
- suggestSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetterRef, CFRangeMake(0, attributedStringCpy.length), NULL, CGSizeMake(aWidth, MAXFLOAT), NULL);
-
+ suggestSize = CTFramesetterSuggestFrameSizeWithConstraints([self ctFramesetterRef], CFRangeMake(0, attributedStringCpy.length), NULL, CGSizeMake(aWidth, MAXFLOAT), NULL);
+
CGMutablePathRef path = NULL;
path = CGPathCreateMutable();
// sufficient height to draw text
CGPathAddRect(path, NULL, CGRectMake(0, 0, aWidth, suggestSize.height * 10));
CTFrameRef frameRef = NULL;
- frameRef = CTFramesetterCreateFrame(framesetterRef, CFRangeMake(0, attributedStringCpy.length), path, NULL);
-
- CFRelease(framesetterRef);
+ frameRef = CTFramesetterCreateFrame([self ctFramesetterRef], CFRangeMake(0, attributedStringCpy.length), path, NULL);
CGPathRelease(path);
- framesetterRef = NULL;
CFArrayRef lines = NULL;
lines = CTFrameGetLines(frameRef);
@@ -866,6 +874,7 @@ do {\
totalHeight = totalHeight + actualLineCount * leading;
CFRelease(frameRef);
+ frameRef = NULL;
if (WX_SYS_VERSION_LESS_THAN(@"10.0")) {
// there is something wrong with coreText drawing text height, trying to fix this with more efficent way.
[4/8] incubator-weex git commit: * [ios] use get method to access
view property
Posted by ac...@apache.org.
* [ios] use get method to access view property
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/5f6ca9e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/5f6ca9e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/5f6ca9e1
Branch: refs/heads/0.15-dev
Commit: 5f6ca9e11dcc203cb1a02bfa8f7eb0e3d1360b9b
Parents: d884871
Author: acton393 <zh...@gmail.com>
Authored: Wed Jun 21 11:40:58 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Jun 21 11:40:58 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/5f6ca9e1/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
index f1cb034..d3dceb0 100644
--- a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
+++ b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
@@ -272,7 +272,7 @@ if ([removeEventName isEqualToString:@#eventName]) {\
if (_tapGesture) {
_tapGesture.delegate = nil;
if ([self.view.gestureRecognizers containsObject:_tapGesture]) {
- [_view removeGestureRecognizer:_tapGesture];
+ [self.view removeGestureRecognizer:_tapGesture];
}
_tapGesture = nil;
}
[5/8] incubator-weex git commit: * [ios] add mutable copy for text
attributedString
Posted by ac...@apache.org.
* [ios] add mutable copy for text attributedString
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e5e22813
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e5e22813
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e5e22813
Branch: refs/heads/0.15-dev
Commit: e5e228137bc819cd301ae58ecec7ee02308a9079
Parents: 5f6ca9e
Author: acton393 <zh...@gmail.com>
Authored: Thu Jun 22 14:46:26 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jun 22 14:46:26 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/e5e22813/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 72b4052..a67d829 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -352,7 +352,7 @@ do {\
if (!_ctAttributedString) {
_ctAttributedString = [self buildCTAttributeString];
}
- return _ctAttributedString;
+ return [_ctAttributedString mutableCopy];
}
- (CTFramesetterRef)ctFramesetterRef
[8/8] incubator-weex git commit: Merge branch '0.14-dev' of
https://github.com/acton393/incubator-weex into wip-us-0.15-dev
Posted by ac...@apache.org.
Merge branch '0.14-dev' 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/193ecb06
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/193ecb06
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/193ecb06
Branch: refs/heads/0.15-dev
Commit: 193ecb0693caead3aeedc18215c6cb7c479ebe8f
Parents: 450ba37 5649c33
Author: acton393 <zh...@gmail.com>
Authored: Thu Jun 22 17:46:18 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jun 22 17:46:18 2017 +0800
----------------------------------------------------------------------
.../WeexSDK/Sources/Component/WXListComponent.m | 3 ++
.../WeexSDK/Sources/Component/WXTextComponent.m | 42 ++++++++++++--------
.../WeexSDK/Sources/Events/WXComponent+Events.m | 19 ++++++++-
ios/sdk/WeexSDK/Sources/Module/WXDomModule.m | 16 ++++----
4 files changed, 55 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
[6/8] incubator-weex git commit: * [ios] remove unused line @notdanger
Posted by ac...@apache.org.
* [ios] remove unused line @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/d6995bab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/d6995bab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/d6995bab
Branch: refs/heads/0.15-dev
Commit: d6995babc948ed54b5bacc4d727c579392f102ec
Parents: e5e2281
Author: acton393 <zh...@gmail.com>
Authored: Thu Jun 22 14:47:12 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jun 22 14:47:12 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d6995bab/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 a67d829..8d50538 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -158,7 +158,6 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
- (BOOL)useCoreText
{
-
if ([_useCoreTextAttr isEqualToString:@"true"]) {
return YES;
}
[3/8] incubator-weex git commit: * [ios] check remove gesture
Posted by ac...@apache.org.
* [ios] check remove gesture
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/d8848715
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/d8848715
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/d8848715
Branch: refs/heads/0.15-dev
Commit: d88487154dd4849c73560eea888b397c8c84f2ae
Parents: 0c07aba
Author: acton393 <zh...@gmail.com>
Authored: Wed Jun 21 11:37:24 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Jun 21 11:37:24 2017 +0800
----------------------------------------------------------------------
.../WeexSDK/Sources/Events/WXComponent+Events.m | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d8848715/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
index a40144a..f1cb034 100644
--- a/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
+++ b/ios/sdk/WeexSDK/Sources/Events/WXComponent+Events.m
@@ -271,6 +271,9 @@ if ([removeEventName isEqualToString:@#eventName]) {\
{
if (_tapGesture) {
_tapGesture.delegate = nil;
+ if ([self.view.gestureRecognizers containsObject:_tapGesture]) {
+ [_view removeGestureRecognizer:_tapGesture];
+ }
_tapGesture = nil;
}
}
@@ -342,8 +345,10 @@ if ([removeEventName isEqualToString:@#eventName]) {\
for (UISwipeGestureRecognizer *recognizer in _swipeGestures) {
recognizer.delegate = nil;
+ if ([[self.view gestureRecognizers] containsObject:recognizer]) {
+ [self.view removeGestureRecognizer:recognizer];
+ }
}
-
_swipeGestures = nil;
}
@@ -395,6 +400,10 @@ if ([removeEventName isEqualToString:@#eventName]) {\
{
if (_longPressGesture) {
_longPressGesture.delegate = nil;
+
+ if([[self.view gestureRecognizers] containsObject:_longPressGesture]) {
+ [self.view removeGestureRecognizer:_longPressGesture];
+ }
_longPressGesture = nil;
}
}
@@ -540,6 +549,11 @@ if ([removeEventName isEqualToString:@#eventName]) {\
&& !_listenPanStart && !_listenPanMove && !_listenPanEnd
&& !_listenHorizontalPan && !_listenVerticalPan
) {
+
+ if ([[self.view gestureRecognizers] containsObject:_panGesture]) {
+ [self.view removeGestureRecognizer:_panGesture];
+ }
+
_panGesture.delegate = nil;
_panGesture = nil;
}
@@ -606,6 +620,9 @@ if ([removeEventName isEqualToString:@#eventName]) {\
{
if (_touchGesture && !_touchGesture.listenTouchStart && !_touchGesture.listenTouchMove && !_touchGesture.listenTouchEnd && !_touchGesture.listenTouchCancel && !_touchGesture.listenPseudoTouch) {
_touchGesture.delegate = nil;
+ if ([[self.view gestureRecognizers] containsObject:_touchGesture]) {
+ [self.view removeGestureRecognizer:_touchGesture];
+ }
_touchGesture = nil;
}
}
[7/8] incubator-weex git commit: * [ios] fix background thread call
ui method @notdanger
Posted by ac...@apache.org.
* [ios] fix background thread call ui method @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/5649c33f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/5649c33f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/5649c33f
Branch: refs/heads/0.15-dev
Commit: 5649c33fb0941054769cf6c5ee006867396de872
Parents: d6995ba
Author: acton393 <zh...@gmail.com>
Authored: Thu Jun 22 14:54:56 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Jun 22 14:54:56 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Module/WXDomModule.m | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/5649c33f/ios/sdk/WeexSDK/Sources/Module/WXDomModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXDomModule.m b/ios/sdk/WeexSDK/Sources/Module/WXDomModule.m
index 3b97c0b..544bc71 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXDomModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXDomModule.m
@@ -181,14 +181,16 @@ WX_EXPORT_METHOD(@selector(getComponentRect:callback:))
- (void)getComponentRect:(NSString*)ref callback:(WXModuleKeepAliveCallback)callback {
[self performBlockOnComponentManager:^(WXComponentManager * manager) {
UIView *rootView = manager.weexInstance.rootView;
- CGRect rootRect = [rootView.superview convertRect:rootView.frame toView:rootView];
if ([ref isEqualToString:@"viewport"]) {
- NSMutableDictionary * callbackRsp = nil;
- callbackRsp = [self _componentRectInfoWithViewFrame:rootRect];
- [callbackRsp setObject:@(true) forKey:@"result"];
- if (callback) {
- callback(callbackRsp, false);
- }
+ dispatch_async(dispatch_get_main_queue(), ^{
+ NSMutableDictionary * callbackRsp = nil;
+ CGRect rootRect = [rootView.superview convertRect:rootView.frame toView:rootView];
+ callbackRsp = [self _componentRectInfoWithViewFrame:rootRect];
+ [callbackRsp setObject:@(true) forKey:@"result"];
+ if (callback) {
+ callback(callbackRsp, false);
+ }
+ });
} else {
WXComponent *component = [manager componentForRef:ref];
__weak typeof (self) weakSelf = self;
[2/8] incubator-weex git commit: * [ios] in case of remove empty array
Posted by ac...@apache.org.
* [ios] in case of remove empty array
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/0c07abaf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/0c07abaf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/0c07abaf
Branch: refs/heads/0.15-dev
Commit: 0c07abaf9fd0195ce86ab39a41562b8e64e31aea
Parents: 7f71c8b
Author: acton393 <zh...@gmail.com>
Authored: Wed Jun 21 11:27:06 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Jun 21 11:27:06 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Component/WXListComponent.m | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0c07abaf/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
index ddee4b3..c1baa7e 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXListComponent.m
@@ -738,6 +738,9 @@
- (void)removeCellForIndexPath:(NSIndexPath *)indexPath withSections:(NSMutableArray *)sections
{
WXSection *section = [sections wx_safeObjectAtIndex:indexPath.section];
+ if (0 == [section.rows count]) {
+ return;
+ }
WXAssert(section, @"Removing cell at indexPath:%@ has not been inserted to cell list before, sections:%@", indexPath, sections);
WXAssert(indexPath.row < section.rows.count, @"Removing cell at indexPath:%@ outof range, sections:%@", indexPath, sections);
[section.rows removeObjectAtIndex:indexPath.row];