flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [11/15] git commit: [flex-asjs] [refs/heads/develop] - fix beadmetrics
Date Wed, 12 Aug 2015 18:47:17 GMT
fix beadmetrics


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/9b192ed2
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/9b192ed2
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/9b192ed2

Branch: refs/heads/develop
Commit: 9b192ed214bcec86240d814ac97ef9490774e2b0
Parents: 40232b4
Author: Alex Harui <aharui@apache.org>
Authored: Wed Aug 12 09:54:05 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Aug 12 09:54:05 2015 -0700

----------------------------------------------------------------------
 .../as/src/org/apache/flex/utils/BeadMetrics.as |  5 +-
 .../js/src/org/apache/flex/utils/BeadMetrics.js | 71 +++++++++++++-------
 2 files changed, 52 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9b192ed2/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as b/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as
index 93a7d59..9abe499 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/utils/BeadMetrics.as
@@ -55,7 +55,10 @@ public class BeadMetrics
             borderOffset = 0;
         else if (borderThickness != null)
         {
-            borderOffset = Number(borderThickness);
+            if (borderThickness is String)
+                borderOffset = CSSUtils.toNumber(borderThickness as String, object.width);
+            else
+                borderOffset = Number(borderThickness);
             if( isNaN(borderOffset) ) borderOffset = 0;            
         }
         else // no style and/or no width

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9b192ed2/frameworks/projects/Core/js/src/org/apache/flex/utils/BeadMetrics.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/utils/BeadMetrics.js b/frameworks/projects/Core/js/src/org/apache/flex/utils/BeadMetrics.js
index 7716f57..2ac73d7 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/utils/BeadMetrics.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/utils/BeadMetrics.js
@@ -15,6 +15,7 @@
 goog.provide('org.apache.flex.utils.BeadMetrics');
 
 goog.require('org.apache.flex.core.UIMetrics');
+goog.require('org.apache.flex.utils.CSSUtils');
 
 
 
@@ -27,33 +28,57 @@ org.apache.flex.utils.BeadMetrics = function() {
 
 /**
  * @export
- * @param {org.apache.flex.core.IStrand} strand The strand whose bounds are required.
+ * @param {Object} object The strand whose bounds are required.
  * @return {org.apache.flex.core.UIMetrics} The bounding box.
  */
-org.apache.flex.utils.BeadMetrics.getMetrics = function(strand) {
+org.apache.flex.utils.BeadMetrics.getMetrics = function(object) {
   var box = new org.apache.flex.core.UIMetrics();
-  var style = strand.element.style;
-  if (style['padding']) {
-    box.top = Number(style.padding);
-    box.left = Number(style.padding);
-    box.right = Number(style.padding);
-    box.bottom = Number(style.padding);
-  } else {
-    if (style['padding_top']) box.top = Number(style.padding_top);
-    if (style['padding_left']) box.left = Number(style.padding_left);
-    if (style['padding_right']) box.right = Number(style.padding_right);
-    if (style['padding_bottom']) box.bottom = Number(style.padding_bottom);
+  var style = getComputedStyle(object.element);
+  var borderThickness = style['border-width'];
+  var borderStyle = style['border-style'];
+  var border = style['border'];
+  var borderOffset;
+  if (borderStyle == 'none')
+    borderOffset = 0;
+  else if (borderThickness != null) {
+    if (typeof(borderThickness) === 'string')
+      borderOffset = org.apache.flex.utils.CSSUtils.toNumber(borderThickness, object.width);
+    else
+      borderOffset = borderThickness;
+    if (isNaN(borderOffset)) borderOffset = 0;
   }
-  if (style['margin']) {
-    box.marginLeft = Number(style.margin);
-    box.marginTop = Number(style.margin);
-    box.marginRight = Number(style.margin);
-    box.marginBottom = Number(style.margin);
-  } else {
-    if (style['margin_top']) box.marginTop = Number(style.margin_top);
-    if (style['margin_left']) box.marginLeft = Number(style.margin_left);
-    if (style['margin_bottom']) box.marginBottom = Number(style.margin_bottom);
-    if (style['margin_right']) box.marginRight = Number(style.margin_right);
+  else {// no style and/or no width
+    border = style['border'];
+    if (border != null) {
+      if (typeof(border) !== 'string') {
+         borderOffset = org.apache.flex.utils.CSSUtils.toNumber(border[0], object.width);
+         borderStyle = border[1];
+       }
+       else if (border == 'none')
+         borderOffset = 0;
+       else if (typeof(border) === 'string')
+         borderOffset = org.apache.flex.utils.CSSUtils.toNumber(border, object.width);
+       else
+         borderOffset = Number(border);
+     }
+     else // no border style set at all so default to none
+       borderOffset = 0;
+   }
+
+  if (style['padding'] != null) {
+    var p = style['padding'];
+    box.top = org.apache.flex.utils.CSSUtils.getTopValue(style['padding_top'], p, object.height)
+ borderOffset;
+    box.left = org.apache.flex.utils.CSSUtils.getLeftValue(style['padding_left'], p, object.width)
+ borderOffset;
+    box.right = org.apache.flex.utils.CSSUtils.getRightValue(style['padding_right'], p, object.width)
+ borderOffset;
+    box.bottom = org.apache.flex.utils.CSSUtils.getBottomValue(style['padding_bottom'], p,
object.height) +
+        borderOffset;
+  }
+  if (style['margin'] != null) {
+    var m = style['margin'];
+    box.marginTop = org.apache.flex.utils.CSSUtils.getTopValue(style['margin_top'], m, object.height);
+    box.marginLeft = org.apache.flex.utils.CSSUtils.getLeftValue(style['margin_left'], m,
object.width);
+    box.marginBottom = org.apache.flex.utils.CSSUtils.getBottomValue(style['margin_bottom'],
m, object.height);
+    box.marginRight = org.apache.flex.utils.CSSUtils.getRightValue(style['margin_right'],
m, object.width);
   }
   return box;
 };


Mime
View raw message