You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/08/28 22:53:49 UTC

[1/4] git commit: [flex-asjs] [refs/heads/develop] - change where we listen for events so we listen to the right place

Repository: flex-asjs
Updated Branches:
  refs/heads/develop 417fc3cff -> a29787a0a


change where we listen for events so we listen to the right place


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

Branch: refs/heads/develop
Commit: 83521ab80e7ad933d2054ed2d670ac39541c35ed
Parents: 417fc3c
Author: Alex Harui <ah...@apache.org>
Authored: Fri Aug 28 13:52:07 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Aug 28 13:52:07 2015 -0700

----------------------------------------------------------------------
 .../src/org/apache/flex/events/ElementEvents.js |  5 ++
 .../org/apache/flex/events/EventDispatcher.js   | 80 ++++++++++----------
 2 files changed, 45 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83521ab8/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js b/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js
index 1f91abe..ce46b37 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/events/ElementEvents.js
@@ -36,6 +36,11 @@ org.apache.flex.events.ElementEvents.prototype.FLEXJS_CLASS_INFO =
  * @type {Object}
  */
 org.apache.flex.events.ElementEvents.elementEvents = {
+  'click': 1,
+  'change': 1,
+  'keyup': 1,
+  'keydown': 1,
+  'load': 1,
   'mouseover': 1,
   'mouseout': 1,
   'mouseup': 1,

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83521ab8/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js b/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
index a26028a..54e48ef 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
@@ -44,29 +44,59 @@ org.apache.flex.events.EventDispatcher.prototype.FLEXJS_CLASS_INFO =
 
 
 /**
- * @override
- * @export
+ * @private
+ * @param {string} type The event name.
+ * @return {goog.events.EventTarget} The target.
  */
-org.apache.flex.events.EventDispatcher.prototype.addEventListener =
-    function(type, handler, opt_capture, opt_handlerScope) {
-  var source;
-
+org.apache.flex.events.EventDispatcher.prototype.getActualDispatcher_ = function(type) {
   /**
    *  A bit of a hack, but for 'native' HTML element based controls, we
    *  want to listen to the 'native' events from the element; for other
    *  types of controls, we listen to 'custom' events.
    */
-  source = this;
+  var source = this;
+  /*
   if (this.element && this.element.nodeName &&
       this.element.nodeName.toLowerCase() !== 'div' &&
       // we don't use any native img events right now, we wrapthem
       this.element.nodeName.toLowerCase() !== 'img' &&
       this.element.nodeName.toLowerCase() !== 'body') {
     source = this.element;
-  } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
+  } else */ if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
     // mouse and keyboard events also dispatch off the element.
     source = this.element;
   }
+  return source;
+};
+
+
+/**
+ * @override
+ * @export
+ */
+org.apache.flex.events.EventDispatcher.prototype.dispatchEvent = function(e) {
+  var t;
+  if (typeof(e) === 'string')
+    t = e;
+  else
+    t = e.type;
+  var source = this.getActualDispatcher_(t);
+  if (source == this)
+    return org.apache.flex.events.EventDispatcher.base(this, 'dispatchEvent', e);
+
+  return source.dispatchEvent(e);
+};
+
+
+/**
+ * @override
+ * @export
+ */
+org.apache.flex.events.EventDispatcher.prototype.addEventListener =
+    function(type, handler, opt_capture, opt_handlerScope) {
+  var source;
+
+  source = this.getActualDispatcher_(type);
 
   goog.events.listen(source, type, handler);
 };
@@ -80,22 +110,7 @@ org.apache.flex.events.EventDispatcher.prototype.removeEventListener =
     function(type, handler, opt_capture, opt_handlerScope) {
   var source;
 
-  /**
-   *  A bit of a hack, but for 'native' HTML element based controls, we
-   *  want to listen to the 'native' events from the element; for other
-   *  types of controls, we listen to 'custom' events.
-   */
-  source = this;
-  if (this.element && this.element.nodeName &&
-      this.element.nodeName.toLowerCase() !== 'div' &&
-      // we don't use any native img events right now, we wrapthem
-      this.element.nodeName.toLowerCase() !== 'img' &&
-      this.element.nodeName.toLowerCase() !== 'body') {
-    source = this.element;
-  } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
-    // mouse and keyboard events also dispatch off the element.
-    source = this.element;
-  }
+  source = this.getActualDispatcher_(type);
 
   goog.events.unlisten(source, type, handler);
 };
@@ -110,22 +125,7 @@ org.apache.flex.events.EventDispatcher.prototype.hasEventListener =
     function(type) {
   var source;
 
-  /**
-   *  A bit of a hack, but for 'native' HTML element based controls, we
-   *  want to listen to the 'native' events from the element; for other
-   *  types of controls, we listen to 'custom' events.
-   */
-  source = this;
-  if (this.element && this.element.nodeName &&
-      this.element.nodeName.toLowerCase() !== 'div' &&
-      // we don't use any native img events right now, we wrapthem
-      this.element.nodeName.toLowerCase() !== 'img' &&
-      this.element.nodeName.toLowerCase() !== 'body') {
-    source = this.element;
-  } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
-    // mouse and keyboard events also dispatch off the element.
-    source = this.element;
-  }
+  source = this.getActualDispatcher_(type);
 
   return goog.events.hasListener(source, type);
 };


[3/4] git commit: [flex-asjs] [refs/heads/develop] - skip layout if not in the DOM because your measurements are invalid

Posted by ah...@apache.org.
skip layout if not in the DOM because your measurements are invalid


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

Branch: refs/heads/develop
Commit: 00f2d2c8e3dfacc03ebc7930188aab213e6cca9b
Parents: 8ad4565
Author: Alex Harui <ah...@apache.org>
Authored: Fri Aug 28 13:53:14 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Aug 28 13:53:14 2015 -0700

----------------------------------------------------------------------
 .../HTML/js/src/org/apache/flex/html/beads/ContainerView.js      | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/00f2d2c8/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
index 6e60e27..26bae27 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
@@ -92,7 +92,9 @@ org.apache.flex.html.beads.ContainerView.
          this.completeSetup();
 
          var num = this.contentView.numElements;
-         if (num > 0) {
+         // make sure there are children AND you are in the DOM before laying out.
+         // If not in the DOM, you'll get funky numbers
+         if (num > 0 && document.contains(this.host.element)) {
            this.performLayout(event);
          }
    }


[2/4] git commit: [flex-asjs] [refs/heads/develop] - dispatch change events

Posted by ah...@apache.org.
dispatch change events


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

Branch: refs/heads/develop
Commit: 8ad4565eebecf8a131aca02f5d348c0a7d2da31e
Parents: 83521ab
Author: Alex Harui <ah...@apache.org>
Authored: Fri Aug 28 13:52:35 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Aug 28 13:52:35 2015 -0700

----------------------------------------------------------------------
 frameworks/projects/HTML/js/src/org/apache/flex/html/Label.js | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8ad4565e/frameworks/projects/HTML/js/src/org/apache/flex/html/Label.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/Label.js b/frameworks/projects/HTML/js/src/org/apache/flex/html/Label.js
index 795b843..82a35c5 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/Label.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/Label.js
@@ -53,6 +53,7 @@ Object.defineProperties(org.apache.flex.html.Label.prototype, {
         /** @this {org.apache.flex.html.Label} */
         set: function(value) {
             this.element.innerHTML = value;
+            this.dispatchEvent('textChange');
         }
     },
     /** @export */
@@ -64,6 +65,7 @@ Object.defineProperties(org.apache.flex.html.Label.prototype, {
         /** @this {org.apache.flex.html.Label} */
         set: function(value) {
             this.element.innerHTML = value;
+            this.dispatchEvent('htmlChange');
         }
     }
 });


[4/4] git commit: [flex-asjs] [refs/heads/develop] - compute width is sized to content. The prior width might get used and cause linebreaks which we don't want

Posted by ah...@apache.org.
compute width is sized to content.  The prior width might get used and cause linebreaks which we don't want


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

Branch: refs/heads/develop
Commit: a29787a0aedb1b1e582ca6557af11cb6c5dc02c4
Parents: 00f2d2c
Author: Alex Harui <ah...@apache.org>
Authored: Fri Aug 28 13:53:52 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Aug 28 13:53:52 2015 -0700

----------------------------------------------------------------------
 .../flex/html/beads/layouts/HorizontalLayout.js      | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a29787a0/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
index 8db30eb..efc75d0 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
@@ -65,7 +65,9 @@ org.apache.flex.html.beads.layouts.HorizontalLayout.
   var contentView = viewBead.contentView;
   children = contentView.internalChildren();
   var hasHeight = !this.strand_.isHeightSizedToContent();
+  var hasWidth = !this.strand_.isWidthSizedToContent();
   var maxHeight = 0;
+  var computedWidth = 0;
   n = children.length;
   for (i = 0; i < n; i++)
   {
@@ -75,7 +77,15 @@ org.apache.flex.html.beads.layouts.HorizontalLayout.
       child.lastDisplay_ = 'inline-block';
     else
       child.style.display = 'inline-block';
-    maxHeight = Math.max(maxHeight, child.offsetTop + child.offsetHeight);
+    maxHeight = Math.max(maxHeight, child.offsetHeight);
+    if (!hasWidth) {
+      var cv = window.getComputedStyle(child);
+      var mls = cv['margin-left'];
+      var ml = Number(mls.substring(0, mls.length - 2));
+      var mrs = cv['margin-right'];
+      var mr = Number(mrs.substring(0, mrs.length - 2));
+      computedWidth += ml + child.offsetWidth + mr;
+    }
     child.flexjs_wrapper.dispatchEvent('sizeChanged');
   }
   // if there are children and maxHeight is ok, use it.
@@ -83,4 +93,7 @@ org.apache.flex.html.beads.layouts.HorizontalLayout.
   if (!hasHeight && n > 0 && !isNaN(maxHeight)) {
     contentView.height = maxHeight;
   }
+  if (!hasWidth && n > 0 && !isNaN(computedWidth)) {
+    contentView.width = computedWidth + 1; // some browser need one more pixel
+  }
 };