* [android] clean up csslayout code
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/d44f9618 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/d44f9618 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/d44f9618 Branch: refs/heads/android-feature-yoga Commit: d44f9618473ec50c201f0ecaa7063546a59c6fc4 Parents: 851248c Author: sospartan <[email protected]> Authored: Mon Jun 26 17:43:49 2017 +0800 Committer: sospartan <[email protected]> Committed: Wed Jun 28 11:17:25 2017 +0800 ---------------------------------------------------------------------- .../taobao/weex/dom/BasicEditTextDomObject.java | 3 - .../com/taobao/weex/dom/CSSAlignConvert.java | 61 -- .../weex/dom/CSSFlexDirectionConvert.java | 43 - .../com/taobao/weex/dom/CSSJustifyConvert.java | 43 - .../taobao/weex/dom/CSSPositionTypeConvert.java | 36 - .../com/taobao/weex/dom/CSSWrapConvert.java | 37 - .../taobao/weex/dom/DOMActionContextImpl.java | 1 - .../com/taobao/weex/dom/ImmutableDomObject.java | 4 - .../java/com/taobao/weex/dom/LayoutUtility.java | 147 +++ .../com/taobao/weex/dom/ResultDomObject.java | 2 - .../main/java/com/taobao/weex/dom/Spacing.java | 245 +++++ .../com/taobao/weex/dom/WXCellDomObject.java | 5 - .../java/com/taobao/weex/dom/WXDomObject.java | 5 +- .../taobao/weex/dom/WXRecyclerDomObject.java | 1 - .../main/java/com/taobao/weex/dom/WXStyle.java | 14 +- .../com/taobao/weex/dom/WXSwitchDomObject.java | 4 +- .../com/taobao/weex/dom/WXTextDomObject.java | 10 +- .../java/com/taobao/weex/dom/YogaUtility.java | 136 --- .../weex/dom/action/UpdateStyleAction.java | 2 +- .../java/com/taobao/weex/dom/flex/CSSAlign.java | 15 - .../com/taobao/weex/dom/flex/CSSConstants.java | 16 - .../com/taobao/weex/dom/flex/CSSDirection.java | 13 - .../taobao/weex/dom/flex/CSSFlexDirection.java | 14 - .../com/taobao/weex/dom/flex/CSSJustify.java | 15 - .../com/taobao/weex/dom/flex/CSSLayout.java | 77 -- .../taobao/weex/dom/flex/CSSLayoutContext.java | 19 - .../java/com/taobao/weex/dom/flex/CSSNode.java | 605 ------------ .../taobao/weex/dom/flex/CSSPositionType.java | 12 - .../java/com/taobao/weex/dom/flex/CSSStyle.java | 124 --- .../java/com/taobao/weex/dom/flex/CSSWrap.java | 12 - .../taobao/weex/dom/flex/CachedCSSLayout.java | 19 - .../com/taobao/weex/dom/flex/FloatUtil.java | 19 - .../com/taobao/weex/dom/flex/LayoutEngine.java | 935 ------------------- .../com/taobao/weex/dom/flex/MeasureOutput.java | 16 - .../java/com/taobao/weex/dom/flex/Spacing.java | 238 ----- .../taobao/weex/ui/RenderActionContextImpl.java | 15 - .../taobao/weex/ui/component/WXComponent.java | 2 +- .../taobao/weex/ui/component/list/WXCell.java | 1 - .../weex/ui/component/list/WXListComponent.java | 2 +- .../weex/ui/view/border/BorderCorner.java | 4 +- .../weex/ui/view/border/BorderDrawable.java | 20 +- .../taobao/weex/ui/view/border/BorderEdge.java | 2 +- .../taobao/weex/ui/view/border/BorderStyle.java | 2 +- .../taobao/weex/ui/view/border/BorderUtil.java | 2 +- .../view/border/BorderWidthStyleColorType.java | 2 +- .../java/com/taobao/weex/utils/WXDomUtils.java | 21 +- .../java/com/taobao/weex/dom/TestDomObject.java | 1 - .../taobao/weex/dom/WXTextDomObjectTest.java | 10 +- .../com/taobao/weex/ui/component/WXDivTest.java | 6 +- .../taobao/weex/ui/component/WXTextTest.java | 2 +- .../weex/ui/view/border/BorderDrawableTest.java | 2 +- 51 files changed, 439 insertions(+), 2603 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java index 73103c3..95ea40a 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java @@ -25,9 +25,6 @@ import com.facebook.yoga.YogaMeasureMode; import com.facebook.yoga.YogaMeasureOutput; import com.facebook.yoga.YogaNode; import com.taobao.weex.common.Constants; -import com.taobao.weex.dom.flex.CSSConstants; -import com.taobao.weex.dom.flex.CSSNode; -import com.taobao.weex.dom.flex.MeasureOutput; import com.taobao.weex.ui.component.WXText; import com.taobao.weex.utils.TypefaceUtil; import com.taobao.weex.utils.WXViewUtils; http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java deleted file mode 100644 index eb6a575..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import android.text.TextUtils; - -import com.taobao.weex.dom.flex.CSSAlign; - -@Deprecated -final class CSSAlignConvert { - - public static CSSAlign convert2AlignItems(String s) { - CSSAlign align = CSSAlign.STRETCH; - if (TextUtils.isEmpty(s)) { - align = CSSAlign.STRETCH; - } else if (s.equals("stretch")) { - align = CSSAlign.STRETCH; - } else if (s.equals("flex-end")) { - align = CSSAlign.FLEX_END; - } else if (s.equals("auto")) { - align = CSSAlign.AUTO; - } else if (s.equals("center")) { - align = CSSAlign.CENTER; - } - - return align; - } - - public static CSSAlign convert2AlignSelf(String s) { - CSSAlign align = CSSAlign.AUTO; - if (TextUtils.isEmpty(s)) { - align = CSSAlign.AUTO; - } else if (s.equals("flex-start")) { - align = CSSAlign.FLEX_START; - } else if (s.equals("flex-end")) { - align = CSSAlign.FLEX_END; - } else if (s.equals("stretch")) { - align = CSSAlign.STRETCH; - } else if (s.equals("center")) { - align = CSSAlign.CENTER; - } - - return align; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java deleted file mode 100644 index bf37547..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import android.text.TextUtils; - -import com.taobao.weex.dom.flex.CSSFlexDirection; - -@Deprecated -class CSSFlexDirectionConvert { - - public static CSSFlexDirection convert(String s) { - CSSFlexDirection cssFlexDirection = CSSFlexDirection.ROW; - if (TextUtils.isEmpty(s)) { - cssFlexDirection = CSSFlexDirection.ROW; - } else if (s.equals("column")) { - cssFlexDirection = CSSFlexDirection.COLUMN; - } else if (s.equals("column-reverse")) { - cssFlexDirection = CSSFlexDirection.COLUMN_REVERSE; - } else if (s.equals("row")) { - cssFlexDirection = CSSFlexDirection.ROW; - } else if (s.equals("row-reverse")) { - cssFlexDirection = CSSFlexDirection.ROW_REVERSE; - } - return cssFlexDirection; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java deleted file mode 100644 index bfdb98e..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import android.text.TextUtils; - -import com.taobao.weex.dom.flex.CSSJustify; - -@Deprecated -class CSSJustifyConvert { - - public static CSSJustify convert(String s) { - CSSJustify cssJustify = CSSJustify.FLEX_START; - if (TextUtils.isEmpty(s) || s.equals("flex-start")) { - cssJustify = CSSJustify.FLEX_START; - } else if (s.equals("flex-end")) { - cssJustify = CSSJustify.FLEX_END; - } else if (s.equals("center")) { - cssJustify = CSSJustify.CENTER; - } else if (s.equals("space-between")) { - cssJustify = CSSJustify.SPACE_BETWEEN; - } else if (s.equals("space-around")) { - cssJustify = CSSJustify.SPACE_AROUND; - } - return cssJustify; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java deleted file mode 100644 index 673b8be..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import android.text.TextUtils; - -import com.taobao.weex.dom.flex.CSSPositionType; - -class CSSPositionTypeConvert { - - public static CSSPositionType convert(String s) { - CSSPositionType position = CSSPositionType.RELATIVE; - if (TextUtils.isEmpty(s) || s.equals("relative") || s.equals("sticky")) { - position = CSSPositionType.RELATIVE; - } else if (s.equals("absolute") || s.equals("fixed")) { - position = CSSPositionType.ABSOLUTE; - } - return position; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java deleted file mode 100644 index 34a21f4..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import android.text.TextUtils; - -import com.taobao.weex.dom.flex.CSSWrap; - -@Deprecated -class CSSWrapConvert { - - public static CSSWrap convert(String s) { - CSSWrap cssWrap = CSSWrap.NOWRAP; - if (TextUtils.isEmpty(s)) { - return cssWrap; - } else if (s.equals("wrap")) { - return CSSWrap.WRAP; - } - return cssWrap; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java index d565eff..cf9647b 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java @@ -26,7 +26,6 @@ import com.taobao.weex.WXEnvironment; import com.taobao.weex.WXSDKInstance; import com.taobao.weex.WXSDKManager; import com.taobao.weex.dom.action.Actions; -import com.taobao.weex.dom.flex.CSSLayoutContext; import com.taobao.weex.ui.IWXRenderTask; import com.taobao.weex.ui.WXRenderManager; import com.taobao.weex.ui.animation.WXAnimationBean; http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java index 55439c3..339bcd1 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java @@ -20,10 +20,6 @@ package com.taobao.weex.dom; import android.support.annotation.NonNull; -import com.taobao.weex.dom.flex.Spacing; - -import static com.taobao.weex.dom.WXDomObject.DESTROYED; - /** * Created by sospartan on 25/10/2016. */ http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/LayoutUtility.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/LayoutUtility.java b/android/sdk/src/main/java/com/taobao/weex/dom/LayoutUtility.java new file mode 100644 index 0000000..0172e33 --- /dev/null +++ b/android/sdk/src/main/java/com/taobao/weex/dom/LayoutUtility.java @@ -0,0 +1,147 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.taobao.weex.dom; + +import android.text.TextUtils; +import android.view.View; + +import com.facebook.yoga.YogaAlign; +import com.facebook.yoga.YogaFlexDirection; +import com.facebook.yoga.YogaJustify; +import com.facebook.yoga.YogaMeasureMode; +import com.facebook.yoga.YogaPositionType; +import com.facebook.yoga.YogaWrap; + + +/** + * Created by sospartan on 21/06/2017. + */ + +public class LayoutUtility { + public static final float UNDEFINED = Float.NaN; + private static final float EPSILON = .00001f; + + public static boolean isUndefined(float value) { + return Float.compare(value, UNDEFINED) == 0; + } + + public static YogaAlign alignItems(String s) { + YogaAlign align = YogaAlign.STRETCH; + if (TextUtils.isEmpty(s)) { + align = YogaAlign.STRETCH; + } else if (s.equals("stretch")) { + align = YogaAlign.STRETCH; + } else if (s.equals("flex-end")) { + align = YogaAlign.FLEX_END; + } else if (s.equals("auto")) { + align = YogaAlign.AUTO; + } else if (s.equals("center")) { + align = YogaAlign.CENTER; + } + + return align; + } + + public static YogaAlign alignSelf(String s) { + YogaAlign align = YogaAlign.AUTO; + if (TextUtils.isEmpty(s)) { + align = YogaAlign.AUTO; + } else if (s.equals("flex-start")) { + align = YogaAlign.FLEX_START; + } else if (s.equals("flex-end")) { + align = YogaAlign.FLEX_END; + } else if (s.equals("stretch")) { + align = YogaAlign.STRETCH; + } else if (s.equals("center")) { + align = YogaAlign.CENTER; + } + + return align; + } + + public static YogaFlexDirection flexDirection(String s) { + YogaFlexDirection cssFlexDirection = YogaFlexDirection.ROW; + if (TextUtils.isEmpty(s)) { + cssFlexDirection = YogaFlexDirection.ROW; + } else if (s.equals("column")) { + cssFlexDirection = YogaFlexDirection.COLUMN; + } else if (s.equals("column-reverse")) { + cssFlexDirection = YogaFlexDirection.COLUMN_REVERSE; + } else if (s.equals("row")) { + cssFlexDirection = YogaFlexDirection.ROW; + } else if (s.equals("row-reverse")) { + cssFlexDirection = YogaFlexDirection.ROW_REVERSE; + } + return cssFlexDirection; + } + + public static YogaJustify justify(String s) { + YogaJustify cssJustify = YogaJustify.FLEX_START; + if (TextUtils.isEmpty(s) || s.equals("flex-start")) { + cssJustify = YogaJustify.FLEX_START; + } else if (s.equals("flex-end")) { + cssJustify = YogaJustify.FLEX_END; + } else if (s.equals("center")) { + cssJustify = YogaJustify.CENTER; + } else if (s.equals("space-between")) { + cssJustify = YogaJustify.SPACE_BETWEEN; + } else if (s.equals("space-around")) { + cssJustify = YogaJustify.SPACE_AROUND; + } + return cssJustify; + } + + public static YogaWrap wrap(String s) { + YogaWrap cssWrap = YogaWrap.NO_WRAP; + if (TextUtils.isEmpty(s)) { + return cssWrap; + } else if (s.equals("wrap")) { + return YogaWrap.WRAP; + } + return cssWrap; + } + + public static YogaPositionType positionType(String s) { + YogaPositionType position = YogaPositionType.RELATIVE; + if (TextUtils.isEmpty(s) || s.equals("relative") || s.equals("sticky")) { + position = YogaPositionType.RELATIVE; + } else if (s.equals("absolute") || s.equals("fixed")) { + position = YogaPositionType.ABSOLUTE; + } + return position; + } + + + public static int viewMeasureSpec(YogaMeasureMode mode) { + if (mode == YogaMeasureMode.AT_MOST) { + return View.MeasureSpec.AT_MOST; + } else if (mode == YogaMeasureMode.EXACTLY) { + return View.MeasureSpec.EXACTLY; + } else { + return View.MeasureSpec.UNSPECIFIED; + } + } + + public static boolean floatsEqual(float f1, float f2) { + if (Float.isNaN(f1) || Float.isNaN(f2)) { + return Float.isNaN(f1) && Float.isNaN(f2); + } + return Math.abs(f2 - f1) < EPSILON; + } +} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/ResultDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/ResultDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/ResultDomObject.java index f6e25a1..5b868fb 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/ResultDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/ResultDomObject.java @@ -20,8 +20,6 @@ package com.taobao.weex.dom; import android.support.annotation.NonNull; -import com.taobao.weex.dom.flex.Spacing; - /** * Created by sospartan on 22/06/2017. */ http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/Spacing.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/Spacing.java b/android/sdk/src/main/java/com/taobao/weex/dom/Spacing.java new file mode 100755 index 0000000..70761a6 --- /dev/null +++ b/android/sdk/src/main/java/com/taobao/weex/dom/Spacing.java @@ -0,0 +1,245 @@ +/** + * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under + * the BSD-style license found in the LICENSE file in the root directory of this source tree. An + * additional grant of patent rights can be found in the PATENTS file in the same directory. + */ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.taobao.weex.dom; + +//import javax.annotation.Nullable; + +import java.util.Arrays; + +/** + * Class representing CSS spacing (padding, margin, and borders). This is mostly necessary to + * properly implement interactions and updates for properties like margin, marginLeft, and + * marginHorizontal. + */ +@Deprecated +public class Spacing /**implements Cloneable**/ +{ + + /** + * Spacing type that represents the left direction. E.g. {@code marginLeft}. + */ + public static final int LEFT = 0; + /** + * Spacing type that represents the top direction. E.g. {@code marginTop}. + */ + public static final int TOP = 1; + /** + * Spacing type that represents the right direction. E.g. {@code marginRight}. + */ + public static final int RIGHT = 2; + /** + * Spacing type that represents the bottom direction. E.g. {@code marginBottom}. + */ + public static final int BOTTOM = 3; + /** + * Spacing type that represents vertical direction (top and bottom). E.g. {@code marginVertical}. + */ + public static final int VERTICAL = 4; + /** + * Spacing type that represents horizontal direction (left and right). E.g. + * {@code marginHorizontal}. + */ + public static final int HORIZONTAL = 5; + /** + * Spacing type that represents start direction e.g. left in left-to-right, right in right-to-left. + */ + public static final int START = 6; + /** + * Spacing type that represents end direction e.g. right in left-to-right, left in right-to-left. + */ + public static final int END = 7; + /** + * Spacing type that represents all directions (left, top, right, bottom). E.g. {@code margin}. + */ + public static final int ALL = 8; + + private static final int[] sFlagsMap = { + 1, /*LEFT*/ + 2, /*TOP*/ + 4, /*RIGHT*/ + 8, /*BOTTOM*/ + 16, /*VERTICAL*/ + 32, /*HORIZONTAL*/ + 64, /*START*/ + 128, /*END*/ + 256, /*ALL*/ + }; + + private final float[] mSpacing = newFullSpacingArray(); + private float[] mDefaultSpacing = null; + private int mValueFlags = 0; + private boolean mHasAliasesSet; + + private static float[] newFullSpacingArray() { + return new float[]{ + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + }; + } + + /** + * Set a spacing value. + * + * @param spacingType one of {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, {@link #BOTTOM}, + * {@link #VERTICAL}, {@link #HORIZONTAL}, {@link #ALL} + * @param value the value for this direction + * @return {@code true} if the spacing has changed, or {@code false} if the same value was already + * set + */ + public boolean set(int spacingType, float value) { + if (!LayoutUtility.floatsEqual(mSpacing[spacingType], value)) { + mSpacing[spacingType] = value; + + if (LayoutUtility.isUndefined(value)) { + mValueFlags &= ~sFlagsMap[spacingType]; + } else { + mValueFlags |= sFlagsMap[spacingType]; + } + + mHasAliasesSet = + (mValueFlags & sFlagsMap[ALL]) != 0 || + (mValueFlags & sFlagsMap[VERTICAL]) != 0 || + (mValueFlags & sFlagsMap[HORIZONTAL]) != 0; + + return true; + } + return false; + } + + /** + * Set a default spacing value. This is used as a fallback when no spacing has been set for a + * particular direction. + * + * @param spacingType one of {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, {@link #BOTTOM} + * @param value the default value for this direction + * @return + */ + public boolean setDefault(int spacingType, float value) { + if (mDefaultSpacing == null) { + mDefaultSpacing = newSpacingResultArray(); + } + if (!LayoutUtility.floatsEqual(mDefaultSpacing[spacingType], value)) { + mDefaultSpacing[spacingType] = value; + return true; + } + return false; + } + + private static float[] newSpacingResultArray() { + return newSpacingResultArray(0); + } + + private static float[] newSpacingResultArray(float defaultValue) { + return new float[]{ + defaultValue, + defaultValue, + defaultValue, + defaultValue, + defaultValue, + defaultValue, + LayoutUtility.UNDEFINED, + LayoutUtility.UNDEFINED, + defaultValue, + }; + } + + /** + * Get the raw value (that was set using {@link #set(int, float)}), without taking into account + * any default values. + * + * @param spacingType one of {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, {@link #BOTTOM}, + * {@link #VERTICAL}, {@link #HORIZONTAL}, {@link #ALL} + */ + public float getRaw(int spacingType) { + return mSpacing[spacingType]; + } + + /** + * Resets the spacing instance to its default state. This method is meant to be used when + * recycling {@link Spacing} instances. + */ + void reset() { + Arrays.fill(mSpacing, LayoutUtility.UNDEFINED); + mDefaultSpacing = null; + mHasAliasesSet = false; + mValueFlags = 0; + } + + /** + * Try to get start value and fallback to given type if not defined. This is used privately + * by the layout engine as a more efficient way to fetch direction-aware values by + * avoid extra method invocations. + */ + float getWithFallback(int spacingType, int fallbackType) { + return + (mValueFlags & sFlagsMap[spacingType]) != 0 + ? mSpacing[spacingType] + : get(fallbackType); + } + + /** + * Get the spacing for a direction. This takes into account any default values that have been set. + * + * @param spacingType one of {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, {@link #BOTTOM} + */ + public float get(int spacingType) { + float defaultValue = (mDefaultSpacing != null) + ? mDefaultSpacing[spacingType] + : (spacingType == START || spacingType == END ? LayoutUtility.UNDEFINED : 0); + + if (mValueFlags == 0) { + return defaultValue; + } + + if ((mValueFlags & sFlagsMap[spacingType]) != 0) { + return mSpacing[spacingType]; + } + + if (mHasAliasesSet) { + int secondType = spacingType == TOP || spacingType == BOTTOM ? VERTICAL : HORIZONTAL; + if ((mValueFlags & sFlagsMap[secondType]) != 0) { + return mSpacing[secondType]; + } else if ((mValueFlags & sFlagsMap[ALL]) != 0) { + return mSpacing[ALL]; + } + } + + return defaultValue; + } + + public boolean equal(Spacing spacing) { + return LayoutUtility.floatsEqual(get(LEFT), spacing.get(LEFT)) + && LayoutUtility.floatsEqual(get(TOP), spacing.get(TOP)) + && LayoutUtility.floatsEqual(get(RIGHT), spacing.get(RIGHT)) + && LayoutUtility.floatsEqual(get(BOTTOM), spacing.get(BOTTOM)); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java index 11cde51..930e3b7 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXCellDomObject.java @@ -18,12 +18,7 @@ */ package com.taobao.weex.dom; -import com.facebook.yoga.YogaMeasureFunction; -import com.facebook.yoga.YogaMeasureMode; -import com.facebook.yoga.YogaMeasureOutput; import com.facebook.yoga.YogaNode; -import com.taobao.weex.dom.flex.CSSNode; -import com.taobao.weex.dom.flex.MeasureOutput; import com.taobao.weex.ui.component.WXBasicComponentType; import com.taobao.weex.utils.WXLogUtils; http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java index 0007522..0b889ba 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java @@ -32,9 +32,6 @@ import com.taobao.weex.WXSDKInstance; import com.taobao.weex.WXSDKManager; import com.taobao.weex.bridge.WXValidateProcessor; import com.taobao.weex.common.Constants; -import com.taobao.weex.dom.flex.CSSLayoutContext; -import com.taobao.weex.dom.flex.CSSNode; -import com.taobao.weex.dom.flex.Spacing; import com.taobao.weex.ui.component.WXBasicComponentType; import com.taobao.weex.utils.WXLogUtils; import com.taobao.weex.utils.WXViewUtils; @@ -266,7 +263,7 @@ public class WXDomObject extends YogaNode implements Cloneable,ImmutableDomObjec /** * Tell whether this object need to be updated. This is usually called when - * {@link CSSNode#calculateLayout(CSSLayoutContext)} finishes and new layout has been + * {@link WXDomObject} finishes and new layout has been * calculated. This method is a simple wrapper method for {@link #hasNewLayout()} and * {@link #isDirty()}. * @return true for need update since last update. http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java index 8bd1e2c..e081977 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXRecyclerDomObject.java @@ -20,7 +20,6 @@ package com.taobao.weex.dom; import com.taobao.weex.WXEnvironment; import com.taobao.weex.common.Constants; -import com.taobao.weex.dom.flex.Spacing; import com.taobao.weex.ui.component.WXBasicComponentType; import com.taobao.weex.utils.WXLogUtils; import com.taobao.weex.utils.WXViewUtils; http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/WXStyle.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXStyle.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXStyle.java index 2fff536..beb727d 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXStyle.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXStyle.java @@ -31,8 +31,6 @@ import com.facebook.yoga.YogaJustify; import com.facebook.yoga.YogaPositionType; import com.facebook.yoga.YogaWrap; import com.taobao.weex.common.Constants; -import com.taobao.weex.dom.flex.CSSPositionType; -import com.taobao.weex.dom.flex.CSSWrap; import com.taobao.weex.ui.component.WXText; import com.taobao.weex.ui.component.WXTextDecoration; import com.taobao.weex.utils.WXUtils; @@ -211,7 +209,7 @@ public class WXStyle implements Map<String, Object>,Cloneable { if (alignItems == null) { return YogaAlign.STRETCH; } - return YogaUtility.alignItems(alignItems.toString().trim()); + return LayoutUtility.alignItems(alignItems.toString().trim()); } public YogaAlign getAlignSelf() { @@ -219,7 +217,7 @@ public class WXStyle implements Map<String, Object>,Cloneable { if (alignSelf == null) { return YogaAlign.AUTO; } - return YogaUtility.alignSelf(alignSelf.toString().trim()); + return LayoutUtility.alignSelf(alignSelf.toString().trim()); } public float getFlex() { @@ -231,7 +229,7 @@ public class WXStyle implements Map<String, Object>,Cloneable { if (flexDirection == null) { return YogaFlexDirection.COLUMN; } - return YogaUtility.flexDirection(flexDirection.toString().trim()); + return LayoutUtility.flexDirection(flexDirection.toString().trim()); } public YogaJustify getJustifyContent() { @@ -239,7 +237,7 @@ public class WXStyle implements Map<String, Object>,Cloneable { if (justifyContent == null) { return YogaJustify.FLEX_START; } - return YogaUtility.justify(justifyContent.toString().trim()); + return LayoutUtility.justify(justifyContent.toString().trim()); } public YogaWrap getCSSWrap() { @@ -247,7 +245,7 @@ public class WXStyle implements Map<String, Object>,Cloneable { if (cssWrap == null) { return YogaWrap.NO_WRAP; } - return YogaUtility.wrap(cssWrap.toString().trim()); + return LayoutUtility.wrap(cssWrap.toString().trim()); } /* @@ -558,7 +556,7 @@ public class WXStyle implements Map<String, Object>,Cloneable { if (position == null) { return YogaPositionType.RELATIVE; } - return YogaUtility.positionType(position.toString().trim()); + return LayoutUtility.positionType(position.toString().trim()); } public boolean isSticky() { http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/WXSwitchDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXSwitchDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXSwitchDomObject.java index 2b6dfec..d96ea41 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXSwitchDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXSwitchDomObject.java @@ -25,8 +25,6 @@ import com.facebook.yoga.YogaMeasureFunction; import com.facebook.yoga.YogaMeasureMode; import com.facebook.yoga.YogaMeasureOutput; import com.facebook.yoga.YogaNode; -import com.taobao.weex.dom.flex.CSSNode; -import com.taobao.weex.dom.flex.MeasureOutput; import com.taobao.weex.ui.view.WXSwitchView; import com.taobao.weex.utils.WXLogUtils; @@ -39,7 +37,7 @@ public class WXSwitchDomObject extends WXDomObject { Context context=((WXDomObject) yogaNode).getDomContext().getUIContext(); WXSwitchView wxSwitchView = new WXSwitchView(context); int widthSpec, heightSpec; - heightSpec = MeasureSpec.makeMeasureSpec((int)height, YogaUtility.viewMeasureSpec(widthMeasureMode)); + heightSpec = MeasureSpec.makeMeasureSpec((int)height, LayoutUtility.viewMeasureSpec(widthMeasureMode)); if (Float.isNaN(width)) { widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); } else { http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/WXTextDomObject.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXTextDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXTextDomObject.java index a76da0b..302d07c 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXTextDomObject.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXTextDomObject.java @@ -40,10 +40,6 @@ import com.facebook.yoga.YogaMeasureOutput; import com.facebook.yoga.YogaNode; import com.taobao.weex.WXEnvironment; import com.taobao.weex.common.Constants; -import com.taobao.weex.dom.flex.CSSConstants; -import com.taobao.weex.dom.flex.CSSNode; -import com.taobao.weex.dom.flex.FloatUtil; -import com.taobao.weex.dom.flex.MeasureOutput; import com.taobao.weex.ui.component.WXText; import com.taobao.weex.ui.component.WXTextDecoration; import com.taobao.weex.utils.WXDomUtils; @@ -174,7 +170,7 @@ public class WXTextDomObject extends WXDomObject { public void layoutAfter() { if (hasBeenMeasured) { if (layout != null && - !FloatUtil.floatsEqual(WXDomUtils.getContentWidth(this), previousWidth)) { + !LayoutUtility.floatsEqual(WXDomUtils.getContentWidth(this), previousWidth)) { recalculateLayout(); } } else { @@ -304,7 +300,7 @@ public class WXTextDomObject extends WXDomObject { float textWidth; textWidth = getTextWidth(mTextPaint, width, forceWidth); Layout layout; - if (!FloatUtil.floatsEqual(previousWidth, textWidth) || previousLayout == null) { + if (!LayoutUtility.floatsEqual(previousWidth, textWidth) || previousLayout == null) { layout = new StaticLayout(spanned, mTextPaint, (int) Math.ceil(textWidth), Layout.Alignment.ALIGN_NORMAL, 1, 0, false); } else { @@ -363,7 +359,7 @@ public class WXTextDomObject extends WXDomObject { textWidth = outerWidth; } else { float desiredWidth = Layout.getDesiredWidth(spanned, textPaint); - if (CSSConstants.isUndefined(outerWidth) || desiredWidth < outerWidth) { + if (LayoutUtility.isUndefined(outerWidth) || desiredWidth < outerWidth) { textWidth = desiredWidth; } else { textWidth = outerWidth; http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/YogaUtility.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/YogaUtility.java b/android/sdk/src/main/java/com/taobao/weex/dom/YogaUtility.java deleted file mode 100644 index b7d1167..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/YogaUtility.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import android.text.TextUtils; -import android.view.View; - -import com.facebook.yoga.YogaAlign; -import com.facebook.yoga.YogaFlexDirection; -import com.facebook.yoga.YogaJustify; -import com.facebook.yoga.YogaMeasureMode; -import com.facebook.yoga.YogaPositionType; -import com.facebook.yoga.YogaWrap; -import com.taobao.weex.dom.flex.CSSFlexDirection; -import com.taobao.weex.dom.flex.CSSJustify; -import com.taobao.weex.dom.flex.CSSPositionType; -import com.taobao.weex.dom.flex.CSSWrap; - -/** - * Created by sospartan on 21/06/2017. - */ - -class YogaUtility { - public static YogaAlign alignItems(String s) { - YogaAlign align = YogaAlign.STRETCH; - if (TextUtils.isEmpty(s)) { - align = YogaAlign.STRETCH; - } else if (s.equals("stretch")) { - align = YogaAlign.STRETCH; - } else if (s.equals("flex-end")) { - align = YogaAlign.FLEX_END; - } else if (s.equals("auto")) { - align = YogaAlign.AUTO; - } else if (s.equals("center")) { - align = YogaAlign.CENTER; - } - - return align; - } - - public static YogaAlign alignSelf(String s) { - YogaAlign align = YogaAlign.AUTO; - if (TextUtils.isEmpty(s)) { - align = YogaAlign.AUTO; - } else if (s.equals("flex-start")) { - align = YogaAlign.FLEX_START; - } else if (s.equals("flex-end")) { - align = YogaAlign.FLEX_END; - } else if (s.equals("stretch")) { - align = YogaAlign.STRETCH; - } else if (s.equals("center")) { - align = YogaAlign.CENTER; - } - - return align; - } - - public static YogaFlexDirection flexDirection(String s) { - YogaFlexDirection cssFlexDirection = YogaFlexDirection.ROW; - if (TextUtils.isEmpty(s)) { - cssFlexDirection = YogaFlexDirection.ROW; - } else if (s.equals("column")) { - cssFlexDirection = YogaFlexDirection.COLUMN; - } else if (s.equals("column-reverse")) { - cssFlexDirection = YogaFlexDirection.COLUMN_REVERSE; - } else if (s.equals("row")) { - cssFlexDirection = YogaFlexDirection.ROW; - } else if (s.equals("row-reverse")) { - cssFlexDirection = YogaFlexDirection.ROW_REVERSE; - } - return cssFlexDirection; - } - - public static YogaJustify justify(String s) { - YogaJustify cssJustify = YogaJustify.FLEX_START; - if (TextUtils.isEmpty(s) || s.equals("flex-start")) { - cssJustify = YogaJustify.FLEX_START; - } else if (s.equals("flex-end")) { - cssJustify = YogaJustify.FLEX_END; - } else if (s.equals("center")) { - cssJustify = YogaJustify.CENTER; - } else if (s.equals("space-between")) { - cssJustify = YogaJustify.SPACE_BETWEEN; - } else if (s.equals("space-around")) { - cssJustify = YogaJustify.SPACE_AROUND; - } - return cssJustify; - } - - public static YogaWrap wrap(String s) { - YogaWrap cssWrap = YogaWrap.NO_WRAP; - if (TextUtils.isEmpty(s)) { - return cssWrap; - } else if (s.equals("wrap")) { - return YogaWrap.WRAP; - } - return cssWrap; - } - - public static YogaPositionType positionType(String s) { - YogaPositionType position = YogaPositionType.RELATIVE; - if (TextUtils.isEmpty(s) || s.equals("relative") || s.equals("sticky")) { - position = YogaPositionType.RELATIVE; - } else if (s.equals("absolute") || s.equals("fixed")) { - position = YogaPositionType.ABSOLUTE; - } - return position; - } - - - public static int viewMeasureSpec(YogaMeasureMode mode) { - if (mode == YogaMeasureMode.AT_MOST) { - return View.MeasureSpec.AT_MOST; - } else if (mode == YogaMeasureMode.EXACTLY) { - return View.MeasureSpec.EXACTLY; - } else { - return View.MeasureSpec.UNSPECIFIED; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java index aa56e70..6dcadbe 100644 --- a/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java @@ -30,7 +30,7 @@ import com.taobao.weex.dom.DOMActionContext; import com.taobao.weex.dom.RenderAction; import com.taobao.weex.dom.RenderActionContext; import com.taobao.weex.dom.WXDomObject; -import com.taobao.weex.dom.flex.Spacing; +import com.taobao.weex.dom.Spacing; import com.taobao.weex.ui.component.WXComponent; import java.util.Map; http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSAlign.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSAlign.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSAlign.java deleted file mode 100755 index 04148fe..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSAlign.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -@Deprecated -public enum CSSAlign { - AUTO, - FLEX_START, - CENTER, - FLEX_END, - STRETCH, -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSConstants.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSConstants.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSConstants.java deleted file mode 100755 index ceb5f38..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSConstants.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -@Deprecated -public class CSSConstants { - - public static final float UNDEFINED = Float.NaN; - - public static boolean isUndefined(float value) { - return Float.compare(value, UNDEFINED) == 0; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSDirection.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSDirection.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSDirection.java deleted file mode 100755 index f6f4a48..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSDirection.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -@Deprecated -public enum CSSDirection { - INHERIT, - LTR, - RTL, -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSFlexDirection.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSFlexDirection.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSFlexDirection.java deleted file mode 100755 index b474b71..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSFlexDirection.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -@Deprecated -public enum CSSFlexDirection { - COLUMN, - COLUMN_REVERSE, - ROW, - ROW_REVERSE -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSJustify.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSJustify.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSJustify.java deleted file mode 100755 index 4bba4fb..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSJustify.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -@Deprecated -public enum CSSJustify { - FLEX_START, - CENTER, - FLEX_END, - SPACE_BETWEEN, - SPACE_AROUND, -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSLayout.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSLayout.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSLayout.java deleted file mode 100755 index 920e819..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSLayout.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -import java.util.Arrays; - -/** - * Where the output of {@link LayoutEngine#layoutNode(CSSLayoutContext, CSSNode, float, - * CSSDirection)} will go in the CSSNode. - */ -@Deprecated -public class CSSLayout { - - public static final int POSITION_LEFT = 0; - public static final int POSITION_TOP = 1; - public static final int POSITION_RIGHT = 2; - public static final int POSITION_BOTTOM = 3; - - public static final int DIMENSION_WIDTH = 0; - public static final int DIMENSION_HEIGHT = 1; - - public float[] position = new float[4]; - public float[] dimensions = new float[2]; - public CSSDirection direction = CSSDirection.LTR; - - /** - * This should always get called before calling {@link LayoutEngine#layoutNode(CSSLayoutContext, - * CSSNode, float, CSSDirection)} - */ - public void resetResult() { - Arrays.fill(position, 0); - Arrays.fill(dimensions, CSSConstants.UNDEFINED); - direction = CSSDirection.LTR; - } - - public void copy(CSSLayout layout) { - position[POSITION_LEFT] = layout.position[POSITION_LEFT]; - position[POSITION_TOP] = layout.position[POSITION_TOP]; - position[POSITION_RIGHT] = layout.position[POSITION_RIGHT]; - position[POSITION_BOTTOM] = layout.position[POSITION_BOTTOM]; - dimensions[DIMENSION_WIDTH] = layout.dimensions[DIMENSION_WIDTH]; - dimensions[DIMENSION_HEIGHT] = layout.dimensions[DIMENSION_HEIGHT]; - direction = layout.direction; - } - - @Override - public String toString() { - return "layout: {" + - "left: " + position[POSITION_LEFT] + ", " + - "top: " + position[POSITION_TOP] + ", " + - "width: " + dimensions[DIMENSION_WIDTH] + ", " + - "height: " + dimensions[DIMENSION_HEIGHT] + ", " + - "direction: " + direction + - "}"; - } - - @Override - public boolean equals(Object o) { - if(this == o){ - return true; - } - if(o instanceof CSSLayout){ - CSSLayout cl = (CSSLayout)o; - return FloatUtil.floatsEqual(cl.position[POSITION_LEFT],this.position[POSITION_LEFT]) && - FloatUtil.floatsEqual(cl.position[POSITION_TOP],this.position[POSITION_TOP]) && - FloatUtil.floatsEqual(cl.position[POSITION_RIGHT],this.position[POSITION_RIGHT]) && - FloatUtil.floatsEqual(cl.position[POSITION_BOTTOM],this.position[POSITION_BOTTOM]) && - FloatUtil.floatsEqual(cl.dimensions[DIMENSION_HEIGHT],this.dimensions[DIMENSION_HEIGHT]) && - FloatUtil.floatsEqual(cl.dimensions[DIMENSION_WIDTH],this.dimensions[DIMENSION_WIDTH]); - - } - return false; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSLayoutContext.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSLayoutContext.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSLayoutContext.java deleted file mode 100755 index 38a6680..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSLayoutContext.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -/** - * A context for holding values local to a given instance of layout computation. - * - * This is necessary for making layout thread-safe. A separate instance should - * be used when {@link CSSNode#calculateLayout} is called concurrently on - * different node hierarchies. - */ -@Deprecated -public class CSSLayoutContext { - - /*package*/ final MeasureOutput measureOutput = new MeasureOutput(); -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSNode.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSNode.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSNode.java deleted file mode 100755 index 5957798..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSNode.java +++ /dev/null @@ -1,605 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-cssstyle license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -//import javax.annotation.Nullable; - -import android.support.annotation.NonNull; - -import java.util.ArrayList; - -import static com.taobao.weex.dom.flex.CSSLayout.DIMENSION_HEIGHT; -import static com.taobao.weex.dom.flex.CSSLayout.DIMENSION_WIDTH; -import static com.taobao.weex.dom.flex.CSSLayout.POSITION_BOTTOM; -import static com.taobao.weex.dom.flex.CSSLayout.POSITION_LEFT; -import static com.taobao.weex.dom.flex.CSSLayout.POSITION_RIGHT; -import static com.taobao.weex.dom.flex.CSSLayout.POSITION_TOP; - -//import com.facebook.infer.annotation.Assertions; - -/** - * A CSS Node. It has a cssstyle object you can manipulate at {@link #cssstyle}. After calling - * {@link #calculateLayout(CSSLayoutContext)}, {@link #csslayout} will be filled with the results of - * the csslayout. - */ -@Deprecated -public class CSSNode { - - // VisibleForTesting - /*package*/public final CSSStyle cssstyle = new CSSStyle(); - /*package*/ public final CSSLayout csslayout = new CSSLayout(); - /*package*/ final CachedCSSLayout lastLayout = new CachedCSSLayout(); - public int lineIndex = 0; - /*package*/ CSSNode nextAbsoluteChild; - /*package*/ CSSNode nextFlexChild; - private ArrayList<CSSNode> mChildren; - private CSSNode mParent; - private MeasureFunction mMeasureFunction = null; - private LayoutState mLayoutState = LayoutState.DIRTY; - private boolean mShow = true; - - private boolean mIsLayoutChanged = true; - - public boolean isShow() { - return mShow; - } - - public void setVisible(boolean isShow) { - if (!mShow && isShow) { - mLayoutState = LayoutState.UP_TO_DATE; - } - mShow = isShow; - dirty(); - } - - /** - * whether layout changed when {@link #updateLastLayout(CSSLayout)} invoked last time. - * @return - */ - public boolean isLayoutChanged(){ - return mIsLayoutChanged; - } - - /** - * must invoke after every layout finished,even nothing changed. - * @param newLayout - * @return - */ - public boolean updateLastLayout(CSSLayout newLayout){ - mIsLayoutChanged = !lastLayout.equals(newLayout); - if(mIsLayoutChanged) { - lastLayout.copy(newLayout); - } - return mIsLayoutChanged; - } - - public int getChildCount() { - return mChildren == null ? 0 : mChildren.size(); - } - - public CSSNode getChildAt(int i) { - // Assertions.assertNotNull(mChildren); - return mChildren.get(i); - } - - public void addChildAt(CSSNode child, int i) { - if (child.mParent != null) { - throw new IllegalStateException("Child already has a parent, it must be removed first."); - } - if (mChildren == null) { - // 4 is kinda arbitrary, but the default of 10 seems really high for an average View. - mChildren = new ArrayList<CSSNode>(4); - } - - mChildren.add(i, child); - child.mParent = this; - dirty(); - } - - public CSSNode removeChildAt(int i) { - // Assertions.assertNotNull(mChildren); - CSSNode removed = mChildren.remove(i); - removed.mParent = null; - dirty(); - return removed; - } - - public void setParentNull() { - mParent = null; - } - - public CSSNode getParent() { - return mParent; - } - - /** - * @return the index of the given child, or -1 if the child doesn't exist in this node. - */ - public int indexOf(CSSNode child) { - // Assertions.assertNotNull(mChildren); - return mChildren.indexOf(child); - } - - public void setMeasureFunction(MeasureFunction measureFunction) { - if (mMeasureFunction != measureFunction) { - mMeasureFunction = measureFunction; - dirty(); - } - } - - /*package*/ MeasureOutput measure(MeasureOutput measureOutput, float width) { - if (!isMeasureDefined()) { - throw new RuntimeException("Measure function isn't defined!"); - } - measureOutput.height = CSSConstants.UNDEFINED; - measureOutput.width = CSSConstants.UNDEFINED; - if (mMeasureFunction != null) { - mMeasureFunction.measure(this, width, measureOutput); - } - // Assertions.assertNotNull(mMeasureFunction).measure(this, width, measureOutput); - return measureOutput; - } - - public boolean isMeasureDefined() { - return mMeasureFunction != null; - } - - /** - * Performs the actual csslayout and saves the results in {@link #csslayout} - */ - public void calculateLayout(CSSLayoutContext layoutContext) { - csslayout.resetResult(); - LayoutEngine.layoutNode(layoutContext, this, CSSConstants.UNDEFINED, null); - } - - /** - * See {@link LayoutState#DIRTY}. - */ - protected boolean isDirty() { - return mLayoutState == LayoutState.DIRTY; - } - - protected void dirty() { - if (mLayoutState == LayoutState.DIRTY) { - return; - } else if (mLayoutState == LayoutState.HAS_NEW_LAYOUT) { - throw new IllegalStateException("Previous csslayout was ignored! markLayoutSeen() never called"); - } - - mLayoutState = LayoutState.DIRTY; - - if (mParent != null) { - mParent.dirty(); - } - } - - /*package*/ void markHasNewLayout() { - mLayoutState = LayoutState.HAS_NEW_LAYOUT; - } - - /** - * Tells the node that the current values in {@link #csslayout} have been seen. Subsequent calls - * to {@link #hasNewLayout()} will return false until this node is laid out with new parameters. - * You must call this each time the csslayout is generated if the node has a new csslayout. - */ - public void markLayoutSeen() { - if (!hasNewLayout()) { - throw new IllegalStateException("Expected node to have a new csslayout to be seen!"); - } - - mLayoutState = LayoutState.UP_TO_DATE; - } - - /** - * See {@link LayoutState#HAS_NEW_LAYOUT}. - */ - public boolean hasNewLayout() { - return mLayoutState == LayoutState.HAS_NEW_LAYOUT; - } - - private void toStringWithIndentation(StringBuilder result, int level) { - // Spaces and tabs are dropped by IntelliJ logcat integration, so rely on __ instead. - StringBuilder indentation = new StringBuilder(); - for (int i = 0; i < level; ++i) { - indentation.append("__"); - } - - result.append(indentation.toString()); - result.append(csslayout.toString()); - result.append(cssstyle.toString()); - - if (getChildCount() == 0) { - return; - } - - result.append(", children: [\n"); - for (int i = 0; i < getChildCount(); i++) { - getChildAt(i).toStringWithIndentation(result, level + 1); - result.append("\n"); - } - result.append(indentation + "]"); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - this.toStringWithIndentation(sb, 0); - return sb.toString(); - } - - protected boolean valuesEqual(float f1, float f2) { - return FloatUtil.floatsEqual(f1, f2); - } - - /** - * Get this node's direction, as defined in the cssstyle. - */ - public CSSDirection getStyleDirection() { - return cssstyle.direction; - } - - public void setDirection(CSSDirection direction) { - if (cssstyle.direction != direction) { - cssstyle.direction = direction; - dirty(); - } - } - - /** - * Get this node's flex direction, as defined by cssstyle. - */ - public CSSFlexDirection getFlexDirection() { - return cssstyle.flexDirection; - } - - public void setFlexDirection(CSSFlexDirection flexDirection) { - if (cssstyle.flexDirection != flexDirection) { - cssstyle.flexDirection = flexDirection; - dirty(); - } - } - - /** - * Get this node's justify content, as defined by cssstyle. - */ - public CSSJustify getJustifyContent() { - return cssstyle.justifyContent; - } - - public void setJustifyContent(CSSJustify justifyContent) { - if (cssstyle.justifyContent != justifyContent) { - cssstyle.justifyContent = justifyContent; - dirty(); - } - } - - /** - * Get this node's align items, as defined by cssstyle. - */ - public CSSAlign getAlignItems() { - return cssstyle.alignItems; - } - - public void setAlignItems(CSSAlign alignItems) { - if (cssstyle.alignItems != alignItems) { - cssstyle.alignItems = alignItems; - dirty(); - } - } - - /** - * Get this node's align items, as defined by cssstyle. - */ - public CSSAlign getAlignSelf() { - return cssstyle.alignSelf; - } - - public void setAlignSelf(CSSAlign alignSelf) { - if (cssstyle.alignSelf != alignSelf) { - cssstyle.alignSelf = alignSelf; - dirty(); - } - } - - /** - * Get this node's position type, as defined by cssstyle. - */ - public CSSPositionType getPositionType() { - return cssstyle.positionType; - } - - public void setPositionType(CSSPositionType positionType) { - if (cssstyle.positionType != positionType) { - cssstyle.positionType = positionType; - dirty(); - } - } - - public void setWrap(CSSWrap flexWrap) { - if (cssstyle.flexWrap != flexWrap) { - cssstyle.flexWrap = flexWrap; - dirty(); - } - } - - /** - * Get this node's flex, as defined by cssstyle. - */ - public float getFlex() { - return cssstyle.flex; - } - - public void setFlex(float flex) { - if (!valuesEqual(cssstyle.flex, flex)) { - cssstyle.flex = flex; - dirty(); - } - } - - /** - * Get this node's margin, as defined by cssstyle + default margin. - */ - public @NonNull Spacing getMargin() { - return cssstyle.margin; - } - - public void setMargin(int spacingType, float margin) { - if (cssstyle.margin.set(spacingType, margin)) { - dirty(); - } - } - - public void setMinWidth(float minWidth) { - if (!valuesEqual(cssstyle.minWidth, minWidth)) { - cssstyle.minWidth = minWidth; - dirty(); - } - } - - public void setMaxWidth(float maxWidth) { - if (!valuesEqual(cssstyle.maxWidth, maxWidth)) { - cssstyle.maxWidth = maxWidth; - dirty(); - } - } - - public void setMinHeight(float minHeight) { - if (!valuesEqual(cssstyle.minHeight, minHeight)) { - cssstyle.minHeight = minHeight; - dirty(); - } - } - - public void setMaxHeight(float maxHeight) { - if (!valuesEqual(cssstyle.maxHeight, maxHeight)) { - cssstyle.maxHeight = maxHeight; - dirty(); - } - } - - /** - * Get this node's padding, as defined by cssstyle + default padding. - */ - public @NonNull Spacing getPadding() { - return cssstyle.padding; - } - - public void setPadding(int spacingType, float padding) { - if (cssstyle.padding.set(spacingType, padding)) { - dirty(); - } - } - - /** - * Get this node's border, as defined by cssstyle. - */ - public @NonNull Spacing getBorder() { - return cssstyle.border; - } - - public void setBorder(int spacingType, float border) { - if (cssstyle.border.set(spacingType, border)) { - dirty(); - } - } - - /** - * Get this node's position top, as defined by cssstyle. - */ - public float getPositionTop() { - return cssstyle.position[POSITION_TOP]; - } - - public void setPositionTop(float positionTop) { - if (!valuesEqual(cssstyle.position[POSITION_TOP], positionTop)) { - cssstyle.position[POSITION_TOP] = positionTop; - dirty(); - } - } - - /** - * Get this node's position bottom, as defined by cssstyle. - */ - public float getPositionBottom() { - return cssstyle.position[POSITION_BOTTOM]; - } - - public void setPositionBottom(float positionBottom) { - if (!valuesEqual(cssstyle.position[POSITION_BOTTOM], positionBottom)) { - cssstyle.position[POSITION_BOTTOM] = positionBottom; - dirty(); - } - } - - /** - * Get this node's position left, as defined by cssstyle. - */ - public float getPositionLeft() { - return cssstyle.position[POSITION_LEFT]; - } - - public void setPositionLeft(float positionLeft) { - if (!valuesEqual(cssstyle.position[POSITION_LEFT], positionLeft)) { - cssstyle.position[POSITION_LEFT] = positionLeft; - dirty(); - } - } - - /** - * Get this node's position right, as defined by cssstyle. - */ - public float getPositionRight() { - return cssstyle.position[POSITION_RIGHT]; - } - - public void setPositionRight(float positionRight) { - if (!valuesEqual(cssstyle.position[POSITION_RIGHT], positionRight)) { - cssstyle.position[POSITION_RIGHT] = positionRight; - dirty(); - } - } - - /** - * Get this node's width, as defined in the cssstyle. - */ - public float getStyleWidth() { - return cssstyle.dimensions[DIMENSION_WIDTH]; - } - - public void setStyleWidth(float width) { - if (!valuesEqual(cssstyle.dimensions[DIMENSION_WIDTH], width)) { - cssstyle.dimensions[DIMENSION_WIDTH] = width; - dirty(); - } - } - - /** - * Get this node's height, as defined in the cssstyle. - */ - public float getStyleHeight() { - return cssstyle.dimensions[DIMENSION_HEIGHT]; - } - - public void setStyleHeight(float height) { - if (!valuesEqual(cssstyle.dimensions[DIMENSION_HEIGHT], height)) { - cssstyle.dimensions[DIMENSION_HEIGHT] = height; - dirty(); - } - } - - public float getLayoutX() { - return csslayout.position[POSITION_LEFT]; - } - - public void setLayoutX(float x) { - csslayout.position[POSITION_LEFT] = x; - } - - public float getLayoutY() { - return csslayout.position[POSITION_TOP]; - } - - public void setLayoutY(float y) { - csslayout.position[POSITION_TOP] = y; - } - - public float getLayoutWidth() { - return csslayout.dimensions[DIMENSION_WIDTH]; - } - - public void setLayoutWidth(float width) { - csslayout.dimensions[DIMENSION_WIDTH] = width; - } - - public float getLayoutHeight() { - return csslayout.dimensions[DIMENSION_HEIGHT]; - } - - public void setLayoutHeight(float height) { - csslayout.dimensions[DIMENSION_HEIGHT] = height; - } - - public CSSDirection getLayoutDirection() { - return csslayout.direction; - } - - /** - * Set a default padding (left/top/right/bottom) for this node. - */ - public void setDefaultPadding(int spacingType, float padding) { - if (cssstyle.padding.setDefault(spacingType, padding)) { - dirty(); - } - } - - /** - * Resets this instance to its default state. This method is meant to be used when recycling - * {@link CSSNode} instances. - */ - public void reset() { - if (mParent != null || (mChildren != null && mChildren.size() > 0)) { - throw new IllegalStateException("You should not reset an attached CSSNode"); - } - - cssstyle.reset(); - csslayout.resetResult(); - lineIndex = 0; - mLayoutState = LayoutState.DIRTY; - } - - private static enum LayoutState { - /** - * Some property of this node or its children has changes and the current values in {@link - * #csslayout} are not valid. - */ - DIRTY, - - /** - * This node has a new csslayout relative to the last time {@link #markLayoutSeen()} was - * called. - */ - HAS_NEW_LAYOUT, - - /** - * {@link #csslayout} is valid for the node's properties and this csslayout has been marked as - * having been seen. - */ - UP_TO_DATE, - } - - public static interface MeasureFunction { - - /** - * Should measure the given node and put the result in the given MeasureOutput. - * NB: measure is NOT guaranteed to be threadsafe/re-entrant safe! - */ - public void measure(CSSNode node, float width, MeasureOutput measureOutput); - } - - public float getCSSLayoutHeight() { - return csslayout.dimensions[CSSLayout.DIMENSION_HEIGHT]; - } - - public float getCSSLayoutWidth() { - return csslayout.dimensions[CSSLayout.DIMENSION_WIDTH]; - } - - public float getCSSLayoutTop() { - return csslayout.position[CSSLayout.POSITION_TOP]; - } - - public float getCSSLayoutBottom() { - return csslayout.position[CSSLayout.POSITION_BOTTOM]; - } - - public float getCSSLayoutLeft() { - return csslayout.position[CSSLayout.POSITION_LEFT]; - } - - public float getCSSLayoutRight() { - return csslayout.position[CSSLayout.POSITION_RIGHT]; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSPositionType.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSPositionType.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSPositionType.java deleted file mode 100755 index 4d396f6..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSPositionType.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -@Deprecated -public enum CSSPositionType { - RELATIVE, - ABSOLUTE, -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSStyle.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSStyle.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSStyle.java deleted file mode 100755 index f3087c4..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSStyle.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -import java.util.Arrays; - -import static com.taobao.weex.dom.flex.CSSLayout.DIMENSION_HEIGHT; -import static com.taobao.weex.dom.flex.CSSLayout.DIMENSION_WIDTH; -import static com.taobao.weex.dom.flex.CSSLayout.POSITION_BOTTOM; -import static com.taobao.weex.dom.flex.CSSLayout.POSITION_LEFT; -import static com.taobao.weex.dom.flex.CSSLayout.POSITION_RIGHT; -import static com.taobao.weex.dom.flex.CSSLayout.POSITION_TOP; - -/** - * The CSS style definition for a {@link CSSNode}. - */ -@Deprecated -public class CSSStyle { - - public CSSDirection direction; - public CSSFlexDirection flexDirection; - public CSSJustify justifyContent; - public CSSAlign alignContent; - public CSSAlign alignItems; - public CSSAlign alignSelf; - public CSSPositionType positionType; - public CSSWrap flexWrap; - public float flex; - - public Spacing margin = new Spacing(); - public Spacing padding = new Spacing(); - public Spacing border = new Spacing(); - - public float[] position = new float[4]; - public float[] dimensions = new float[2]; - - public float minWidth = CSSConstants.UNDEFINED; - public float minHeight = CSSConstants.UNDEFINED; - - public float maxWidth = CSSConstants.UNDEFINED; - public float maxHeight = CSSConstants.UNDEFINED; - - CSSStyle() { - reset(); - } - - void reset() { - direction = CSSDirection.INHERIT; - flexDirection = CSSFlexDirection.COLUMN; - justifyContent = CSSJustify.FLEX_START; - alignContent = CSSAlign.FLEX_START; - alignItems = CSSAlign.STRETCH; - alignSelf = CSSAlign.AUTO; - positionType = CSSPositionType.RELATIVE; - flexWrap = CSSWrap.NOWRAP; - flex = 0f; - - margin.reset(); - padding.reset(); - border.reset(); - - Arrays.fill(position, CSSConstants.UNDEFINED); - Arrays.fill(dimensions, CSSConstants.UNDEFINED); - - minWidth = CSSConstants.UNDEFINED; - minHeight = CSSConstants.UNDEFINED; - - maxWidth = CSSConstants.UNDEFINED; - maxHeight = CSSConstants.UNDEFINED; - } - - public void copy(CSSStyle cssStyle) { - direction = cssStyle.direction; - flexDirection = cssStyle.flexDirection; - justifyContent = cssStyle.justifyContent; - alignContent = cssStyle.alignContent; - alignItems = cssStyle.alignItems; - alignSelf = cssStyle.alignSelf; - positionType = cssStyle.positionType; - flexWrap = cssStyle.flexWrap; - flex = cssStyle.flex; - margin = cssStyle.margin; - padding = cssStyle.padding; - border = cssStyle.border; - position[POSITION_TOP] = cssStyle.position[POSITION_TOP]; - position[POSITION_BOTTOM] = cssStyle.position[POSITION_BOTTOM]; - position[POSITION_LEFT] = cssStyle.position[POSITION_LEFT]; - position[POSITION_RIGHT] = cssStyle.position[POSITION_RIGHT]; - dimensions[DIMENSION_WIDTH] = cssStyle.dimensions[DIMENSION_WIDTH]; - dimensions[DIMENSION_HEIGHT] = cssStyle.dimensions[DIMENSION_HEIGHT]; - minWidth = cssStyle.minWidth; - minHeight = cssStyle.minHeight; - maxWidth = cssStyle.maxWidth; - maxHeight = cssStyle.maxHeight; - } - - public String toString() { - return "direction =" + direction + "\n" - + "flexDirection =" + flexDirection + "\n" - + "justifyContent=" + justifyContent + "\n" - + "alignContent =" + alignContent + "\n" - + "alignItems =" + alignItems + "\n" - + "alignSelf =" + alignSelf + "\n" - + "positionType =" + positionType + "\n" - + "flexWrap =" + flexWrap + "\n" - + "flex =" + flex + "\n" - + "margin =" + margin + "\n" - + "padding =" + padding + "\n" - + "border =" + border + "\n" - + "position[POSITION_TOP] =" + position[POSITION_TOP] + "\n" - + "position[POSITION_BOTTOM] =" + position[POSITION_BOTTOM] + "\n" - + "position[POSITION_LEFT] =" + position[POSITION_LEFT] + "\n" - + "position[POSITION_RIGHT] =" + position[POSITION_RIGHT] + "\n" - + "position[DIMENSION_WIDTH] =" + position[DIMENSION_WIDTH] + "\n" - + "position[DIMENSION_HEIGHT] =" + position[DIMENSION_HEIGHT] + "\n" - + "minWidth =" + minWidth + "\n" - + "minHeight =" + minHeight + "\n" - + "maxWidth =" + maxWidth + "\n" - + "maxHeight =" + maxHeight + "\n"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSWrap.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSWrap.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSWrap.java deleted file mode 100755 index 68c8ca4..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CSSWrap.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -@Deprecated -public enum CSSWrap { - NOWRAP, - WRAP, -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/CachedCSSLayout.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CachedCSSLayout.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/CachedCSSLayout.java deleted file mode 100755 index 99aaa0c..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/CachedCSSLayout.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -/** - * CSSLayout with additional information about the conditions under which it was generated. - * {@link #requestedWidth} and {@link #requestedHeight} are the width and height the parent set on - * this node before calling layout visited us. - */ -@Deprecated -public class CachedCSSLayout extends CSSLayout { - - public float requestedWidth = CSSConstants.UNDEFINED; - public float requestedHeight = CSSConstants.UNDEFINED; - public float parentMaxWidth = CSSConstants.UNDEFINED; -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d44f9618/android/sdk/src/main/java/com/taobao/weex/dom/flex/FloatUtil.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/flex/FloatUtil.java b/android/sdk/src/main/java/com/taobao/weex/dom/flex/FloatUtil.java deleted file mode 100755 index 4dbfeba..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/dom/flex/FloatUtil.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2014, Facebook, Inc. All rights reserved. <p/> This source code is licensed under - * the BSD-style license found in the LICENSE file in the root directory of this source tree. An - * additional grant of patent rights can be found in the PATENTS file in the same directory. - */ -package com.taobao.weex.dom.flex; - -@Deprecated -public class FloatUtil { - - private static final float EPSILON = .00001f; - - public static boolean floatsEqual(float f1, float f2) { - if (Float.isNaN(f1) || Float.isNaN(f2)) { - return Float.isNaN(f1) && Float.isNaN(f2); - } - return Math.abs(f2 - f1) < EPSILON; - } -}
