Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CF360200C0D for ; Mon, 26 Dec 2016 19:40:54 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id CE2AA160B40; Mon, 26 Dec 2016 18:40:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3730D160B41 for ; Mon, 26 Dec 2016 19:40:54 +0100 (CET) Received: (qmail 34593 invoked by uid 500); 26 Dec 2016 18:40:53 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 34434 invoked by uid 99); 26 Dec 2016 18:40:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Dec 2016 18:40:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D29B4F2DE9; Mon, 26 Dec 2016 18:40:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: carlosrovira@apache.org To: commits@flex.apache.org Date: Mon, 26 Dec 2016 18:41:04 -0000 Message-Id: <8993459fd5664b9c81121b4a4c23a5af@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [13/17] git commit: [flex-asjs] [refs/heads/feature/mdl] - Fix getScreenBoundingRect() for svg elements. archived-at: Mon, 26 Dec 2016 18:40:55 -0000 Fix getScreenBoundingRect() for svg elements. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/85c08046 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/85c08046 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/85c08046 Branch: refs/heads/feature/mdl Commit: 85c080468af4d1b1bd8602b9e284f5b6c211a845 Parents: d277641 Author: yishayw Authored: Mon Dec 26 11:18:03 2016 +0200 Committer: yishayw Committed: Mon Dec 26 11:18:03 2016 +0200 ---------------------------------------------------------------------- .../flex/org/apache/flex/utils/DisplayUtils.as | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/85c08046/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as index 483ab41..ac66a19 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as @@ -19,7 +19,14 @@ package org.apache.flex.utils { import org.apache.flex.core.IUIBase; - import org.apache.flex.geom.Rectangle + import org.apache.flex.geom.Rectangle; + + COMPILE::JS + { + import org.apache.flex.geom.Matrix; + import org.apache.flex.geom.Point; + import org.apache.flex.core.ITransformHost; + } /** * The SpriteUtils class is a collection of static functions that are useful * for geometric operations on visible objects. @@ -42,6 +49,7 @@ package org.apache.flex.utils * @playerversion AIR 2.6 * @productversion FlexJS 0.0 * @flexjsignorecoercion HTMLElement + * @flexjsignorecoercion ITransformHost */ public static function getScreenBoundingRect(obj:IUIBase):Rectangle { @@ -53,9 +61,21 @@ package org.apache.flex.utils COMPILE::JS { var r:Object = (obj.element as HTMLElement).getBoundingClientRect(); - var bounds:Rectangle = new Rectangle(r.x, r.y, r.width, r.height); + var bounds:Rectangle = new Rectangle(r.left, r.top, r.right - r.left, r.bottom - r.top); bounds.x -= window.pageXOffset; bounds.y -= window.pageYOffset; + if (obj.element instanceof SVGElement) + { + var svgElement:Object = (obj as ITransformHost).transformElement as Object; + var sm:SVGMatrix = svgElement.getScreenCTM(); + var m:Matrix = new Matrix(sm.a,sm.b,sm.c,sm.d,sm.e,sm.f); + var tl:Point = m.transformPoint(bounds.topLeft); + var br:Point = m.transformPoint(bounds.bottomRight); + bounds.top = tl.y; + bounds.left = tl.x; + bounds.bottom = br.y; + bounds.right = br.x; + } return bounds; } }