Repository: incubator-weex Updated Branches: refs/heads/master ae45df45e -> bf14bcdb5
[WEEX-313][iOS]fix RTL issue Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/bf14bcdb Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/bf14bcdb Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/bf14bcdb Branch: refs/heads/master Commit: bf14bcdb56c0d850d2f19b8d3bf994b839d75158 Parents: ae45df4 Author: Klueze <tiankai...@alibaba-inc.com> Authored: Thu Apr 26 17:58:45 2018 +0800 Committer: Klueze <tiankai...@alibaba-inc.com> Committed: Thu Apr 26 17:59:31 2018 +0800 ---------------------------------------------------------------------- .../WeexSDK/Sources/Component/WXTextComponent.h | 1 + .../WeexSDK/Sources/Component/WXTextComponent.m | 4 +-- ios/sdk/WeexSDK/Sources/Layout/Layout.c | 2 ++ .../WeexSDK/Sources/Layout/WXComponent+Layout.m | 38 ++------------------ 4 files changed, 7 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bf14bcdb/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h index 1d98066..ebd8c7d 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h +++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h @@ -24,4 +24,5 @@ + (void)setRenderUsingCoreText:(BOOL)usingCoreText; - (BOOL)useCoreText; + @end http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bf14bcdb/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 042f0a6..2a948e2 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m @@ -481,7 +481,7 @@ do {\ NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; // handle text direction style, default ltr - if ([_direction isEqualToString:@"rtl"]) { + if (_cssNode->layout.direction == CSS_DIRECTION_RTL) { if (0 == _textAlign) { //force text right-align if don't specified any align. _textAlign = NSTextAlignmentRight; @@ -563,7 +563,7 @@ do {\ NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; // handle text direction style, default ltr - if ([_direction isEqualToString:@"rtl"]) { + if (_cssNode->layout.direction == CSS_DIRECTION_RTL) { if (0 == _textAlign) { //force text right-align if don't specified any align. _textAlign = NSTextAlignmentRight; http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bf14bcdb/ios/sdk/WeexSDK/Sources/Layout/Layout.c ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Layout/Layout.c b/ios/sdk/WeexSDK/Sources/Layout/Layout.c index 07b25cc..6e3214f 100644 --- a/ios/sdk/WeexSDK/Sources/Layout/Layout.c +++ b/ios/sdk/WeexSDK/Sources/Layout/Layout.c @@ -1324,4 +1324,6 @@ void resetNodeLayout(css_node_t *node) { node->layout.dimensions[CSS_HEIGHT] = CSS_UNDEFINED; node->layout.position[CSS_LEFT] = 0; node->layout.position[CSS_TOP] = 0; + node->layout.position[CSS_RIGHT] = 0; + node->layout.position[CSS_BOTTOM] = 0; } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bf14bcdb/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m b/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m index b3907af..dcb2d80 100644 --- a/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m +++ b/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m @@ -37,30 +37,13 @@ - (void)setNeedsLayout { + _isLayoutDirty = YES; WXComponent *supercomponent = [self supercomponent]; - if (self->_virtualComponentId || self->_templateComponent) { - // we will generate a virtualComponentId for recycleList virtual component or templateComponent for recycleList component template. - // as for recyclelist component, it depends on the input data, not the new layout, here will not try to clear slibling child layout. - _isLayoutDirty = YES; + if(supercomponent){ [supercomponent setNeedsLayout]; - } else { - if(supercomponent){ - for (WXComponent *siblingComponent in [supercomponent subcomponents]) { - [siblingComponent _needRecalculateLayout]; - } - [supercomponent setNeedsLayout]; - } else { - [self _needRecalculateLayout]; - } } } -- (void)_needRecalculateLayout -{ - _isLayoutDirty = YES; - [self _clearLayoutCSS]; -} - - (BOOL)needsLayout { return _isLayoutDirty; @@ -234,23 +217,6 @@ [self layoutDidFinish]; } -/** - * clear the layout variables on css node - **/ -- (void)_clearLayoutCSS { - memset(&(_cssNode->layout), 0, sizeof(_cssNode->layout)); - _cssNode->layout.dimensions[CSS_WIDTH] = CSS_UNDEFINED; - _cssNode->layout.dimensions[CSS_HEIGHT] = CSS_UNDEFINED; - - // Such that the comparison is always going to be false - _cssNode->layout.last_requested_dimensions[CSS_WIDTH] = -1; - _cssNode->layout.last_requested_dimensions[CSS_HEIGHT] = -1; - _cssNode->layout.last_parent_max_width = -1; - _cssNode->layout.last_parent_max_height = -1; - _cssNode->layout.last_direction = (css_direction_t)-1; - _cssNode->layout.should_update = true; -} - #define WX_STYLE_FILL_CSS_NODE(key, cssProp, type)\ do {\ id value = styles[@#key];\