|
Lines 18-52
Link Here
|
| 18 |
|
18 |
|
| 19 |
getElementBounds : function( node ) { |
19 |
getElementBounds : function( node ) { |
| 20 |
var style = node.style; |
20 |
var style = node.style; |
| 21 |
if( style.cssText.indexOf( "%" ) != -1 ) { |
|
|
| 22 |
throw( "getElementBounds does not support '%'!" ); |
| 23 |
} |
| 24 |
var result = { |
21 |
var result = { |
| 25 |
top : parseInt( style.top ), |
22 |
top : this._parseLength( style.top ), |
| 26 |
left : parseInt( style.left ), |
23 |
left : this._parseLength( style.left ), |
| 27 |
width : parseInt( style.width ), |
24 |
width : this._parseLength( style.width ), |
| 28 |
height : parseInt( style.height ) |
25 |
height : this._parseLength( style.height ) |
| 29 |
}; |
26 |
}; |
| 30 |
try { |
27 |
try { |
| 31 |
var ps = node.parentNode.style; |
28 |
var ps = node.parentNode.style; |
| 32 |
if( ps.cssText.indexOf( "%" ) != -1 ) { |
29 |
result.right = this._parseLength( ps.width ) |
| 33 |
throw( "getElementBounds does not support '%'!" ); |
30 |
- this._parseLength( ps.borderLeftWidth || 0 ) |
| 34 |
} |
31 |
- this._parseLength( ps.borderRightWidth || 0 ) |
| 35 |
result.right = parseInt( ps.width ) |
|
|
| 36 |
- parseInt( ps.borderLeftWidth || 0 ) |
| 37 |
- parseInt( ps.borderRightWidth || 0 ) |
| 38 |
- ( result.left + result.width ) |
32 |
- ( result.left + result.width ) |
| 39 |
result.bottom = parseInt( ps.height ) |
33 |
result.bottom = this._parseLength( ps.height ) |
| 40 |
- parseInt( ps.borderTopWidth || 0 ) |
34 |
- this._parseLength( ps.borderTopWidth || 0 ) |
| 41 |
- parseInt( ps.borderBottomWidth || 0 ) |
35 |
- this._parseLength( ps.borderBottomWidth || 0 ) |
| 42 |
- ( result.top + result.height ); |
36 |
- ( result.top + result.height ); |
| 43 |
} catch( e ) { |
37 |
} catch( e ) { |
| 44 |
this.printStackTrace(); |
38 |
throw( "Could not get bounds: no parentNode!" ); |
| 45 |
throw( " could not get bounds: no parentNode!" ); |
39 |
} |
|
|
40 |
return result; |
| 41 |
}, |
| 42 |
|
| 43 |
_parseLength : function( value ) { |
| 44 |
var result = value ? parseInt( value ) : 0; |
| 45 |
if( result != 0 |
| 46 |
&& typeof value == "string" |
| 47 |
&& value.indexOf( "px" ) == -1 ) |
| 48 |
{ |
| 49 |
throw "getElementBounds only supports \"px\" but found " + value; |
| 46 |
} |
50 |
} |
| 47 |
return result; |
51 |
return result; |
| 48 |
}, |
52 |
}, |
| 49 |
|
53 |
|
|
|
54 |
getElementFont : function( element ) { |
| 55 |
var font = element.style.font; |
| 56 |
if( font == "" || typeof font != "string" ) { |
| 57 |
var fontData = [ |
| 58 |
element.style.fontSize, |
| 59 |
element.style.fontStyle, |
| 60 |
element.style.fontWeight, |
| 61 |
element.style.fontFamily |
| 62 |
]; |
| 63 |
font = fontData.join( " " ); |
| 64 |
} |
| 65 |
return font; |
| 66 |
}, |
| 67 |
|
| 50 |
hasElementOpacity : function( node ) { |
68 |
hasElementOpacity : function( node ) { |
| 51 |
return node.style.cssText.search( /opacity/i ) != -1; |
69 |
return node.style.cssText.search( /opacity/i ) != -1; |
| 52 |
}, |
70 |
}, |
|
Lines 61-72
Link Here
|
| 61 |
} else if( node.style.backgroundImage |
79 |
} else if( node.style.backgroundImage |
| 62 |
&& node.style.backgroundImage.indexOf( 'url(' ) != -1 ) |
80 |
&& node.style.backgroundImage.indexOf( 'url(' ) != -1 ) |
| 63 |
{ |
81 |
{ |
| 64 |
result = node.style.backgroundImage.slice( 4, -1 ); |
82 |
result = node.style.backgroundImage.slice( 4, -1 ); |
| 65 |
} |
83 |
} |
| 66 |
// Webkit re-writes the url in certain situations: |
84 |
// Webkit re-writes the url in certain situations: |
| 67 |
if( result.length > 0 && result == document.URL ) { |
85 |
if( result.length > 0 && result == document.URL ) { |
| 68 |
result = ""; |
86 |
result = ""; |
| 69 |
} |
87 |
} |
|
|
88 |
// Firefox writes quotation-marks into the URL |
| 89 |
if( result[ 0 ] == "\"" && result[ result.length -1 ] == "\"" ) { |
| 90 |
result = result.slice( 1, -1 ); |
| 91 |
} |
| 70 |
return result; |
92 |
return result; |
| 71 |
}, |
93 |
}, |
| 72 |
|
94 |
|
|
Lines 100-109
Link Here
|
| 100 |
///////////////////////////// |
122 |
///////////////////////////// |
| 101 |
// Event handling - DOM layer |
123 |
// Event handling - DOM layer |
| 102 |
|
124 |
|
| 103 |
click : function( widget ) { |
|
|
| 104 |
this.clickDOM( widget._getTargetNode() ); |
| 105 |
}, |
| 106 |
|
| 107 |
clickDOM : function( node ) { |
125 |
clickDOM : function( node ) { |
| 108 |
var left = qx.event.type.MouseEvent.buttons.left; |
126 |
var left = qx.event.type.MouseEvent.buttons.left; |
| 109 |
this.fakeMouseEventDOM( node, "mousedown", left ); |
127 |
this.fakeMouseEventDOM( node, "mousedown", left ); |
|
Lines 111-126
Link Here
|
| 111 |
this.fakeMouseEventDOM( node, "click", left ); |
129 |
this.fakeMouseEventDOM( node, "click", left ); |
| 112 |
}, |
130 |
}, |
| 113 |
|
131 |
|
| 114 |
rightClick : function( widget ) { |
132 |
shiftClickDOM : function( node ) { |
| 115 |
var right = qx.event.type.MouseEvent.buttons.right; |
133 |
var left = qx.event.type.MouseEvent.buttons.left; |
| 116 |
var node = widget._getTargetNode(); |
134 |
var mod = qx.event.type.DomEvent.SHIFT_MASK; |
| 117 |
this.fakeMouseEventDOM( node, "mousedown", right ); |
135 |
this.fakeMouseEventDOM( node, "mousedown", left, 0, 0, mod ); |
| 118 |
this.fakeMouseEventDOM( node, "mouseup", right ); |
136 |
this.fakeMouseEventDOM( node, "mouseup", left, 0, 0, mod ); |
| 119 |
this.fakeMouseEventDOM( node, "click", right ); |
137 |
this.fakeMouseEventDOM( node, "click", left, 0, 0, mod ); |
| 120 |
this.fakeMouseEventDOM( node, "contextmenu", right ); |
|
|
| 121 |
}, |
138 |
}, |
| 122 |
|
139 |
|
| 123 |
fakeMouseEventDOM : function( node, type, button, left, top ) { |
140 |
ctrlClickDOM : function( node ) { |
|
|
141 |
var left = qx.event.type.MouseEvent.buttons.left; |
| 142 |
var mod = qx.event.type.DomEvent.CTRL_MASK; |
| 143 |
this.fakeMouseEventDOM( node, "mousedown", left, 0, 0, mod ); |
| 144 |
this.fakeMouseEventDOM( node, "mouseup", left, 0, 0, mod ); |
| 145 |
this.fakeMouseEventDOM( node, "click", left, 0, 0, mod ); |
| 146 |
}, |
| 147 |
|
| 148 |
fakeMouseEventDOM : function( node, type, button, left, top, mod ) { |
| 124 |
if( typeof node == "undefined" ) { |
149 |
if( typeof node == "undefined" ) { |
| 125 |
throw( "Error in fakeMouseEventDOM: node not defined! " ); |
150 |
throw( "Error in fakeMouseEventDOM: node not defined! " ); |
| 126 |
} |
151 |
} |
|
Lines 130-135
Link Here
|
| 130 |
if( typeof top == "undefined" ) { |
155 |
if( typeof top == "undefined" ) { |
| 131 |
top = 0; |
156 |
top = 0; |
| 132 |
} |
157 |
} |
|
|
158 |
if( typeof mod == "undefined" ) { |
| 159 |
mod = 0; |
| 160 |
} |
| 133 |
var clientX = left; |
161 |
var clientX = left; |
| 134 |
var clientY = top; |
162 |
var clientY = top; |
| 135 |
if( qx.core.Client.getEngine() == "mshtml" ) { |
163 |
if( qx.core.Client.getEngine() == "mshtml" ) { |
|
Lines 137-184
Link Here
|
| 137 |
clientY -= qx.bom.Viewport.getScrollTop(window); |
165 |
clientY -= qx.bom.Viewport.getScrollTop(window); |
| 138 |
} |
166 |
} |
| 139 |
var domEvent = { |
167 |
var domEvent = { |
|
|
168 |
"preventDefault" : function(){}, |
| 140 |
"type" : type, |
169 |
"type" : type, |
| 141 |
"target" : node, |
170 |
"target" : node, |
|
|
171 |
"which" : 1, |
| 142 |
"button" : button, |
172 |
"button" : button, |
| 143 |
"pageX" : left, |
173 |
"pageX" : left, |
| 144 |
"pageY" : top, |
174 |
"pageY" : top, |
| 145 |
"clientX" : clientX, |
175 |
"clientX" : clientX, |
| 146 |
"clientY" : clientY, |
176 |
"clientY" : clientY, |
| 147 |
"screenX" : left, |
177 |
"screenX" : left, |
| 148 |
"screenY" : top |
178 |
"screenY" : top, |
|
|
179 |
"ctrlKey" : ( qx.event.type.DomEvent.CTRL_MASK & mod ) != 0, |
| 180 |
"altKey" : ( qx.event.type.DomEvent.ALT_MASK & mod ) != 0, |
| 181 |
"shiftKey" : ( qx.event.type.DomEvent.SHIFT_MASK & mod ) != 0 |
| 149 |
} |
182 |
} |
| 150 |
qx.event.handler.EventHandler.getInstance().__onmouseevent( domEvent ); |
183 |
qx.event.handler.EventHandler.getInstance().__onmouseevent( domEvent ); |
| 151 |
}, |
184 |
}, |
| 152 |
|
185 |
|
|
|
186 |
fakeKeyEventDOM : function( node, eventType, stringOrKeyCode ) { |
| 187 |
var charCode = null; |
| 188 |
var keyCode = null; |
| 189 |
var isChar = typeof stringOrKeyCode == "string"; |
| 190 |
if( isChar ) { |
| 191 |
charCode = stringOrKeyCode.charCodeAt( 0 ); |
| 192 |
} else { |
| 193 |
keyCode = stringOrKeyCode; |
| 194 |
} |
| 195 |
var domEvent = { |
| 196 |
target : node, |
| 197 |
type : eventType, |
| 198 |
ctrlKey : false, |
| 199 |
altKey : false, |
| 200 |
shiftKey : false, |
| 201 |
keyCode : keyCode, |
| 202 |
charCode : charCode, |
| 203 |
isChar: isChar, |
| 204 |
pageX: 0, |
| 205 |
pageY: 0, |
| 206 |
preventDefault : function(){}, |
| 207 |
stopPropagation : function(){} |
| 208 |
}; |
| 209 |
var handler = qx.event.handler.KeyEventHandler.getInstance(); |
| 210 |
handler._idealKeyHandler( keyCode, charCode, eventType, domEvent ); |
| 211 |
}, |
| 212 |
|
| 153 |
///////////////////////////// |
213 |
///////////////////////////// |
| 154 |
// Event handling - Qooxdoo |
214 |
// Event handling - Qooxdoo |
| 155 |
|
215 |
click : function( widget ) { |
|
|
216 |
this.clickDOM( widget._getTargetNode() ); |
| 217 |
}, |
| 218 |
|
| 219 |
doubleClick : function( widget ) { |
| 220 |
var node = widget._getTargetNode(); |
| 221 |
this.clickDOM( node ); |
| 222 |
this.clickDOM( node ); |
| 223 |
var left = qx.event.type.MouseEvent.buttons.left; |
| 224 |
this.fakeMouseEventDOM( node, "dblclick", left ); |
| 225 |
}, |
| 226 |
|
| 227 |
shiftClick : function( widget ) { |
| 228 |
var node = widget._getTargetNode(); |
| 229 |
this.shiftClickDOM( node ); |
| 230 |
}, |
| 231 |
|
| 232 |
ctrlClick : function( widget ) { |
| 233 |
var node = widget._getTargetNode(); |
| 234 |
this.ctrlClickDOM( node ); |
| 235 |
}, |
| 236 |
|
| 237 |
rightClick : function( widget ) { |
| 238 |
var right = qx.event.type.MouseEvent.buttons.right; |
| 239 |
var node = widget._getTargetNode(); |
| 240 |
this.fakeMouseEventDOM( node, "mousedown", right ); |
| 241 |
this.fakeMouseEventDOM( node, "mouseup", right ); |
| 242 |
this.fakeMouseEventDOM( node, "click", right ); |
| 243 |
this.fakeMouseEventDOM( node, "contextmenu", right ); |
| 244 |
}, |
| 245 |
|
| 156 |
mouseOver : function( widget ) { |
246 |
mouseOver : function( widget ) { |
| 157 |
this.fakeMouseEvent( widget, "mouseover" ); |
247 |
this.fakeMouseEvent( widget, "mouseover" ); |
| 158 |
}, |
248 |
}, |
| 159 |
|
249 |
|
| 160 |
mouseMove : function( widget ) { |
250 |
mouseMove : function( widget ) { |
| 161 |
this.fakeMouseEvent( widget, "mousemove" ); |
251 |
this.fakeMouseEvent( widget, "mousemove" ); |
| 162 |
}, |
252 |
}, |
| 163 |
|
253 |
|
| 164 |
mouseOut : function( widget ) { |
254 |
mouseOut : function( widget ) { |
| 165 |
this.fakeMouseEvent( widget, "mouseout" ); |
255 |
this.fakeMouseEvent( widget, "mouseout" ); |
| 166 |
}, |
256 |
}, |
| 167 |
|
257 |
|
| 168 |
mouseFromTo : function( from, to ) { |
258 |
mouseFromTo : function( from, to ) { |
| 169 |
this.mouseMove( from ); |
259 |
this.mouseMove( from ); |
| 170 |
this.mouseOut( from ); |
260 |
this.mouseOut( from ); |
| 171 |
this.mouseOver( to ); |
261 |
this.mouseOver( to ); |
| 172 |
this.mouseMove( to ); |
262 |
this.mouseMove( to ); |
| 173 |
}, |
263 |
}, |
| 174 |
|
264 |
|
| 175 |
fakeMouseClick : function( widget, left, top ) { |
265 |
fakeMouseClick : function( widget, left, top ) { |
| 176 |
this.fakeMouseEvent( widget, "mousedown", left, top ); |
266 |
this.fakeMouseEvent( widget, "mousedown", left, top ); |
| 177 |
this.fakeMouseEvent( widget, "mouseup", left, top ); |
267 |
this.fakeMouseEvent( widget, "mouseup", left, top ); |
| 178 |
this.fakeMouseEvent( widget, "click", left, top ); |
268 |
this.fakeMouseEvent( widget, "click", left, top ); |
| 179 |
}, |
269 |
}, |
| 180 |
|
270 |
|
|
|
271 |
fakeWheel : function( widget, value ) { |
| 272 |
var ev = this._createQxMouseEvent( widget, "mousewheel" ); |
| 273 |
ev.getWheelDelta = function(){ return value; }; |
| 274 |
widget.dispatchEvent( ev ); |
| 275 |
}, |
| 276 |
|
| 181 |
fakeMouseEvent : function( widget, type, left, top ) { |
277 |
fakeMouseEvent : function( widget, type, left, top ) { |
|
|
278 |
var ev = this._createQxMouseEvent( widget, type, left, top ); |
| 279 |
ev.setButton( qx.event.type.MouseEvent.C_BUTTON_LEFT ); |
| 280 |
widget.dispatchEvent( ev ); |
| 281 |
}, |
| 282 |
|
| 283 |
_createQxMouseEvent : function( widget, type, left, top ) { |
| 182 |
if( !widget._isCreated ) { |
284 |
if( !widget._isCreated ) { |
| 183 |
throw( "Error in testUtil.fakeMouseEvent: widget is not created" ); |
285 |
throw( "Error in testUtil.fakeMouseEvent: widget is not created" ); |
| 184 |
} |
286 |
} |
|
Lines 191-197
Link Here
|
| 191 |
clientX : left, |
293 |
clientX : left, |
| 192 |
clientY : top, |
294 |
clientY : top, |
| 193 |
pageX : left, |
295 |
pageX : left, |
| 194 |
pageY : top |
296 |
pageY : top, |
|
|
297 |
preventDefault : function(){}, |
| 298 |
stopPropagation : function(){} |
| 195 |
}; |
299 |
}; |
| 196 |
var ev = new qx.event.type.MouseEvent( |
300 |
var ev = new qx.event.type.MouseEvent( |
| 197 |
type, |
301 |
type, |
|
Lines 202-217
Link Here
|
| 202 |
null |
306 |
null |
| 203 |
); |
307 |
); |
| 204 |
ev.setButton( qx.event.type.MouseEvent.C_BUTTON_LEFT ); |
308 |
ev.setButton( qx.event.type.MouseEvent.C_BUTTON_LEFT ); |
| 205 |
widget.dispatchEvent( ev ); |
309 |
return ev; |
| 206 |
}, |
310 |
}, |
| 207 |
|
311 |
|
| 208 |
press : function( widget, key, checkActive ) { |
312 |
press : function( widget, key, checkActive ) { |
| 209 |
this.fakeKeyEvent( widget, "keydown", key, checkActive ); |
313 |
this.fakeKeyEvent( widget, "keydown", key, checkActive ); |
| 210 |
this.fakeKeyEvent( widget, "keypress", key, checkActive ); |
314 |
this.fakeKeyEvent( widget, "keypress", key, checkActive ); |
| 211 |
this.fakeKeyEvent( widget, "keyinput", key, checkActive ); |
315 |
this.fakeKeyEvent( widget, "keyinput", key, checkActive ); |
| 212 |
this.fakeKeyEvent( widget, "keyup", key, checkActive ); |
316 |
this.fakeKeyEvent( widget, "keyup", key, checkActive ); |
| 213 |
}, |
317 |
}, |
| 214 |
|
318 |
|
| 215 |
fakeKeyEvent : function( widget, type, key, checkActive ) { |
319 |
fakeKeyEvent : function( widget, type, key, checkActive ) { |
| 216 |
if( !widget._isCreated ) { |
320 |
if( !widget._isCreated ) { |
| 217 |
throw( "Error in fakeKeyEvent: " + widget + " is not created" ); |
321 |
throw( "Error in fakeKeyEvent: " + widget + " is not created" ); |
|
Lines 236-269
Link Here
|
| 236 |
widget.warn( type + " not possible: " + widget.__dbKey + " not focused!" ); |
340 |
widget.warn( type + " not possible: " + widget.__dbKey + " not focused!" ); |
| 237 |
} |
341 |
} |
| 238 |
}, |
342 |
}, |
| 239 |
|
343 |
|
| 240 |
fakeKeyEventDOM : function( node, eventType, stringOrKeyCode ) { |
|
|
| 241 |
var charCode = null; |
| 242 |
var keyCode = null; |
| 243 |
var isChar = typeof stringOrKeyCode == "string"; |
| 244 |
if( isChar ) { |
| 245 |
charCode = stringOrKeyCode.charCodeAt( 0 ); |
| 246 |
} else { |
| 247 |
keyCode = stringOrKeyCode; |
| 248 |
} |
| 249 |
var domEvent = { |
| 250 |
target : node, |
| 251 |
type : eventType, |
| 252 |
ctrlKey : false, |
| 253 |
altKey : false, |
| 254 |
shiftKey : false, |
| 255 |
keyCode : keyCode, |
| 256 |
charCode : charCode, |
| 257 |
isChar: isChar, |
| 258 |
pageX: 0, |
| 259 |
pageY: 0, |
| 260 |
preventDefault : function(){}, |
| 261 |
stopPropagation : function(){} |
| 262 |
}; |
| 263 |
var handler = qx.event.handler.KeyEventHandler.getInstance(); |
| 264 |
handler._idealKeyHandler( keyCode, charCode, eventType, domEvent ); |
| 265 |
}, |
| 266 |
|
| 267 |
//////////////// |
344 |
//////////////// |
| 268 |
// client-server |
345 |
// client-server |
| 269 |
|
346 |
|
|
Lines 275-289
Link Here
|
| 275 |
return ""; |
352 |
return ""; |
| 276 |
} ); |
353 |
} ); |
| 277 |
}, |
354 |
}, |
| 278 |
|
355 |
|
| 279 |
getRequestLog : function() { |
356 |
getRequestLog : function() { |
| 280 |
return this._requestLog; |
357 |
return this._requestLog; |
| 281 |
}, |
358 |
}, |
| 282 |
|
359 |
|
| 283 |
getRequestsSend : function() { |
360 |
getRequestsSend : function() { |
| 284 |
return this._requestLog.length; |
361 |
return this._requestLog.length; |
| 285 |
}, |
362 |
}, |
| 286 |
|
363 |
|
| 287 |
clearRequestLog : function() { |
364 |
clearRequestLog : function() { |
| 288 |
org.eclipse.swt.Request.getInstance().send(); |
365 |
org.eclipse.swt.Request.getInstance().send(); |
| 289 |
this._requestLog = []; |
366 |
this._requestLog = []; |
|
Lines 334-339
Link Here
|
| 334 |
timer._oninterval(); |
411 |
timer._oninterval(); |
| 335 |
}, |
412 |
}, |
| 336 |
|
413 |
|
|
|
414 |
////////// |
| 415 |
// Theming |
| 416 |
|
| 417 |
// assumes that the set appearance-theme does never change during tests |
| 418 |
fakeAppearance : function( appearanceId, value ) { |
| 419 |
var manager = qx.theme.manager.Appearance.getInstance(); |
| 420 |
var themeName = manager.getAppearanceTheme().name; |
| 421 |
var base = manager.getAppearanceTheme().appearances; |
| 422 |
if( typeof this._appearanceBackups[ appearanceId ] == "undefined" ) { |
| 423 |
if( base[ appearanceId ] ) { |
| 424 |
this._appearanceBackups[ appearanceId ] = base[ appearanceId ]; |
| 425 |
} else { |
| 426 |
this._appearanceBackups[ appearanceId ] = false; |
| 427 |
} |
| 428 |
} |
| 429 |
base[ appearanceId ] = value; |
| 430 |
this._clearAppearanceCache(); |
| 431 |
}, |
| 432 |
|
| 433 |
restoreAppearance : function() { |
| 434 |
var manager = qx.theme.manager.Appearance.getInstance(); |
| 435 |
var base = manager.getAppearanceTheme().appearances; |
| 436 |
for( var appearanceId in this._appearanceBackups ) { |
| 437 |
var value = this._appearanceBackups[ appearanceId ]; |
| 438 |
if( value === false ) { |
| 439 |
delete base[ appearanceId ]; |
| 440 |
} else { |
| 441 |
base[ appearanceId ] = value; |
| 442 |
} |
| 443 |
} |
| 444 |
this._appearanceBackups = {}; |
| 445 |
this._clearAppearanceCache(); |
| 446 |
}, |
| 447 |
|
| 448 |
_appearanceBackups : {}, |
| 449 |
|
| 450 |
_clearAppearanceCache : function() { |
| 451 |
var manager = qx.theme.manager.Appearance.getInstance() |
| 452 |
manager.__cache[ manager.getAppearanceTheme().name ] = {}; |
| 453 |
}, |
| 454 |
|
| 337 |
//////// |
455 |
//////// |
| 338 |
// Misc |
456 |
// Misc |
| 339 |
|
457 |
|