Opened 9 years ago

Last modified 2 years ago

#10724 assigned defect

dojo.position return different values on WebKit based platforms

Reported by: steveshaw@… Owned by:
Priority: high Milestone: 1.15
Component: HTML Version: 1.4.0
Keywords: Cc:
Blocked By: Blocking:

Description

Steps:

  • Create a group shape -> shape = owner.createGroup();
  • transform the shape (x, y) ->

shape.setTransform(null); var matrix = { xx: 1.0, yy: 1.0, dx: 100, dy: 100 }; shape.setTransform(matrix);

  • Query for it's position -> dojo.position(shape.rawNode, true);

In FireFox? it returns the translated value relative to it's parent. In WebKit? browsers (Safari / Chrome) it is unchanged.

Change History (9)

comment:1 Changed 9 years ago by davidmark

Owner: changed from anonymous to davidmark
Status: newassigned

What version(s) of Safari and FF? Makes a huge difference for dojo.position (e.g. may or may not be using getBoundingClientRect).

Browser sniffing may be the culprit as well.

comment:2 in reply to:  1 Changed 9 years ago by davidmark

Replying to davidmark:

What version(s) of Safari and FF? Makes a huge difference for dojo.position (e.g. may or may not be using getBoundingClientRect).

Browser sniffing may be the culprit as well.

Of course, the function is all tangled up with browser sniffing. Each sniff is a placeholder for a problem that was never properly investigated, diagnosed or solved.

		if(node["getBoundingClientRect"]){
			// IE6+, FF3+, super-modern WebKit, and Opera 9.6+ all take this branch
			ret = node.getBoundingClientRect();
			ret = { x: ret.left, y: ret.top, w: ret.right - ret.left, h: ret.bottom - ret.top };
		//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
			if(d.isIE){
				// On IE there's a 2px offset that we need to adjust for, see _getIeDocumentElementOffset()
				var offset = d._getIeDocumentElementOffset();

				// fixes the position in IE, quirks mode
				ret.x -= offset.x + (d.isQuirks ? db.clientLeft+db.offsetLeft : 0);
				ret.y -= offset.y + (d.isQuirks ? db.clientTop+db.offsetTop : 0);
			}else if(d.isFF == 3){
				// In FF3 you have to subtract the document element margins.
				// Fixed in FF3.5 though.
				var cs = gcs(dh);
				ret.x -= px(dh, cs.marginLeft) + px(dh, cs.borderLeftWidth);
				ret.y -= px(dh, cs.marginTop) + px(dh, cs.borderTopWidth);
			}
		//>>excludeEnd("webkitMobile");
		}else{
			// FF2 and older WebKit

Of course, the documentElement should _never_ have margins (think about what that would look like.)

The IE quirks mode stuff is wrong too, but that is irrelevant here.

So, is it a "super modern" WebKit? that is giving you problems?

comment:3 Changed 9 years ago by dante

Owner: changed from davidmark to anonymous
Status: assignednew

comment:4 Changed 8 years ago by Eugene Lazutkin

Owner: changed from anonymous to Eugene Lazutkin
Status: newassigned

comment:5 Changed 8 years ago by Eugene Lazutkin

Component: GeneralCore

comment:6 Changed 8 years ago by Eugene Lazutkin

Hmm, it is more core than GFX.

comment:7 Changed 7 years ago by bill

Component: CoreHTML

comment:8 Changed 3 years ago by dylan

Milestone: tbd1.12
Owner: Eugene Lazutkin deleted

Consider cleaning this code up for 1.12.

comment:9 Changed 2 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.