Skip to content

Commit

Permalink
Merge branch 't/12858' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Apr 6, 2015
2 parents 8354774 + 4cc3716 commit 3263734
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 91 deletions.
62 changes: 21 additions & 41 deletions core/dom/element.js
Expand Up @@ -344,7 +344,7 @@ CKEDITOR.dom.element.clearMarkers = function( database, element, removeFromDatab
* @param {CKEDITOR.dom.node} node
* @returns {Boolean}
*/
contains: CKEDITOR.env.ie || CKEDITOR.env.webkit ?
contains: !document.compareDocumentPosition ?
function( node ) {
var $ = this.$;

Expand Down Expand Up @@ -590,14 +590,15 @@ CKEDITOR.dom.element.clearMarkers = function( database, element, removeFromDatab
* @param {String} propertyName The style property name.
* @returns {String} The property value.
*/
getComputedStyle: CKEDITOR.env.ie ?
function( propertyName ) {
return this.$.currentStyle[ CKEDITOR.tools.cssStyleToDomStyle( propertyName ) ];
} : function( propertyName ) {
var style = this.getWindow().$.getComputedStyle( this.$, null );
// Firefox may return null if we call the above on a hidden iframe. (#9117)
return style ? style.getPropertyValue( propertyName ) : '';
},
getComputedStyle: ( document.defaultView && document.defaultView.getComputedStyle ) ?
function( propertyName ) {
var style = this.getWindow().$.getComputedStyle( this.$, null );

// Firefox may return null if we call the above on a hidden iframe. (#9117)
return style ? style.getPropertyValue( propertyName ) : '';
} : function( propertyName ) {
return this.$.currentStyle[ CKEDITOR.tools.cssStyleToDomStyle( propertyName ) ];
},

/**
* Gets the DTD entries for this element.
Expand Down Expand Up @@ -632,39 +633,18 @@ CKEDITOR.dom.element.clearMarkers = function( database, element, removeFromDatab
* @method
* @returns {Number} The tabindex value.
*/
getTabIndex: CKEDITOR.env.ie ?
function() {
var tabIndex = this.$.tabIndex;
getTabIndex: function() {
var tabIndex = this.$.tabIndex;

// IE returns tabIndex=0 by default for all elements. In
// those cases we must check that the element really has
// the tabindex attribute set to zero, or it is one of
// those element that should have zero by default.
if ( tabIndex === 0 && !CKEDITOR.dtd.$tabIndex[ this.getName() ] && parseInt( this.getAttribute( 'tabindex' ), 10 ) !== 0 )
tabIndex = -1;
// IE returns tabIndex=0 by default for all elements. In
// those cases we must check that the element really has
// the tabindex attribute set to zero, or it is one of
// those element that should have zero by default.
if ( tabIndex === 0 && !CKEDITOR.dtd.$tabIndex[ this.getName() ] && parseInt( this.getAttribute( 'tabindex' ), 10 ) !== 0 )
return -1;

return tabIndex;
} : CKEDITOR.env.webkit ?
function() {
var tabIndex = this.$.tabIndex;

// Safari returns "undefined" for elements that should not
// have tabindex (like a div). So, we must try to get it
// from the attribute.
// https://bugs.webkit.org/show_bug.cgi?id=20596
if ( tabIndex === undefined ) {
tabIndex = parseInt( this.getAttribute( 'tabindex' ), 10 );

// If the element don't have the tabindex attribute,
// then we should return -1.
if ( isNaN( tabIndex ) )
tabIndex = -1;
}

return tabIndex;
} : function() {
return this.$.tabIndex;
},
return tabIndex;
},

/**
* Gets the text value of this element.
Expand Down Expand Up @@ -1452,7 +1432,7 @@ CKEDITOR.dom.element.clearMarkers = function( database, element, removeFromDatab
scrollRelativeTop;

// See #12758 to know more about document.(documentElement|body).scroll(Left|Top) in Webkit.
if ( CKEDITOR.env.webkit ) {
if ( CKEDITOR.env.webkit || ( CKEDITOR.env.ie && CKEDITOR.env.version >= 12 ) ) {
scrollRelativeLeft = body.$.scrollLeft || $docElem.scrollLeft;
scrollRelativeTop = body.$.scrollTop || $docElem.scrollTop;
} else {
Expand Down
8 changes: 7 additions & 1 deletion core/editable.js
Expand Up @@ -1378,7 +1378,13 @@

function isNotBubbling( fn, src ) {
return function( evt ) {
var other = CKEDITOR.dom.element.get( evt.data.$.toElement || evt.data.$.fromElement || evt.data.$.relatedTarget );
var other = evt.data.$.toElement || evt.data.$.fromElement || evt.data.$.relatedTarget;

// First of all, other may simply be null/undefined.
// Second of all, at least early versions of Spartan returned empty objects from evt.relatedTarget,
// so let's also check the node type.
other = ( other && other.nodeType == CKEDITOR.NODE_ELEMENT ) ? new CKEDITOR.dom.element( other ) : null;

if ( !( other && ( src.equals( other ) || src.contains( other ) ) ) )
fn.call( this, evt );
};
Expand Down
16 changes: 11 additions & 5 deletions core/env.js
Expand Up @@ -16,7 +16,10 @@ if ( !CKEDITOR.env ) {
* @singleton
*/
CKEDITOR.env = ( function() {
var agent = navigator.userAgent.toLowerCase();
var agent = navigator.userAgent.toLowerCase(),
spartan = agent.match( /edge[ \/](\d+.?\d*)/ ),
trident = agent.indexOf( 'trident/' ) > -1,
ie = !!( spartan || trident );

var env = {
/**
Expand All @@ -27,7 +30,7 @@ if ( !CKEDITOR.env ) {
*
* @property {Boolean}
*/
ie: ( agent.indexOf( 'trident/' ) > -1 ),
ie: ie,

/**
* Indicates that CKEditor is running in a WebKit-based browser, like Safari.
Expand All @@ -37,7 +40,7 @@ if ( !CKEDITOR.env ) {
*
* @property {Boolean}
*/
webkit: ( agent.indexOf( ' applewebkit/' ) > -1 ),
webkit: !ie && ( agent.indexOf( ' applewebkit/' ) > -1 ),

/**
* Indicates that CKEditor is running in Adobe AIR.
Expand Down Expand Up @@ -169,10 +172,13 @@ if ( !CKEDITOR.env ) {
// Internet Explorer 6.0+
if ( env.ie ) {
// We use env.version for feature detection, so set it properly.
if ( env.quirks || !document.documentMode )
if ( spartan ) {
version = parseFloat( spartan[ 1 ] );
} else if ( env.quirks || !document.documentMode ) {
version = parseFloat( agent.match( /msie (\d+)/ )[ 1 ] );
else
} else {
version = document.documentMode;
}

// Deprecated features available just for backwards compatibility.
env.ie9Compat = version == 9;
Expand Down
17 changes: 5 additions & 12 deletions plugins/magicline/plugin.js
Expand Up @@ -1627,18 +1627,7 @@
var sizePrefixes = [ 'top', 'left', 'right', 'bottom' ];

function getSize( that, element, ignoreScroll, force ) {
var getStyle = ( function() {
// Better "cache and reuse" than "call again and again".
var computed = env.ie ? element.$.currentStyle : that.win.$.getComputedStyle( element.$, '' );

return env.ie ?
function( propertyName ) {
return computed[ CKEDITOR.tools.cssStyleToDomStyle( propertyName ) ];
} : function( propertyName ) {
return computed.getPropertyValue( propertyName );
};
} )(),
docPosition = element.getDocumentPosition(),
var docPosition = element.getDocumentPosition(),
border = {},
margin = {},
padding = {},
Expand Down Expand Up @@ -1677,6 +1666,10 @@
margin: margin,
ignoreScroll: ignoreScroll
}, box, true );

function getStyle( propertyName ) {
return element.getComputedStyle.call( element, propertyName );
}
}

function updateSize( that, element, ignoreScroll ) {
Expand Down
16 changes: 0 additions & 16 deletions plugins/wysiwygarea/plugin.js
Expand Up @@ -287,22 +287,6 @@
setTimeout( function() {
editor.fire( 'dataReady' );
}, 0 );

// IE BUG: IE might have rendered the iframe with invisible contents.
// (#3623). Push some inconsequential CSS style changes to force IE to
// refresh it.
//
// Also, for some unknown reasons, short timeouts (e.g. 100ms) do not
// fix the problem. :(
if ( CKEDITOR.env.ie ) {
setTimeout( function() {
if ( editor.document ) {
var $body = editor.document.$.body;
$body.runtimeStyle.marginBottom = '0px';
$body.runtimeStyle.marginBottom = '';
}
}, 1000 );
}
}, 0, this );
}

Expand Down
26 changes: 10 additions & 16 deletions tests/plugins/image/image.js
Expand Up @@ -217,20 +217,7 @@
},

'test update image (attributes)': function() {
var bot = this.editorBot,
// jscs:disable maximumLineLength
standard = '<img src="' + SRC + '" style="border-style:solid;border-width:2px;float:right;height:86px;margin:10px 5px;width:414px;" />',
outputIE = '<img src="' + SRC + '" style="border-bottom:2px solid;border-left:2px solid;border-right:2px solid;border-top:2px solid;float:right;height:86px;margin:10px 5px;width:414px;" />',
outputOpera = '<img src="' + SRC + '" style="border-bottom-style:solid;border-bottom-width:2px;border-left-style:solid;border-left-width:2px;border-right-style:solid;border-right-width:2px;border-top-style:solid;border-top-width:2px;float:right;height:86px;margin-bottom:10px;margin-left:5px;margin-right:5px;margin-top:10px;width:414px;" />',
outputSafari5 = '<img src="' + SRC + '" style="border-bottom-style:solid;border-bottom-width:2px;border-left-style:solid;border-left-width:2px;border-right-style:solid;border-right-width:2px;border-top-style:solid;border-top-width:2px;float:right;height:86px;margin-bottom:10px;margin-left:5px;margin-right:5px;margin-top:10px;width:414px;" />',
// jscs:enable maximumLineLength
output =
( CKEDITOR.env.ie && document.documentMode > 8 ) ? standard
: CKEDITOR.env.ie ? outputIE
: CKEDITOR.env.gecko ? standard
: CKEDITOR.env.safari && CKEDITOR.env.version < 536 ? outputSafari5
: CKEDITOR.env.webkit ? standard
: outputOpera;
var bot = this.editorBot;

bot.setHtmlWithSelection( '[<img src="' + SRC + '" height="300" width="200" border="1" align="right" vspace="10" hspace="5"/>]' );
bot.dialog( 'image', function( dialog ) {
Expand All @@ -250,7 +237,14 @@

dialog.getButton( 'ok' ).click();

assert.areEqual( output.toLowerCase(), bot.getData( true ) );
var img = bot.editor.editable().findOne( 'img' );
assert.areEqual( img.getStyle( 'border-width' ), '2px' );
assert.areEqual( img.getStyle( 'border-style' ), 'solid' );
assert.areEqual( img.getStyle( 'margin' ), '10px 5px' );
assert.areEqual( img.getStyle( 'float' ), 'right' );
assert.areEqual( img.getStyle( 'height' ), '86px' );
assert.areEqual( img.getStyle( 'width' ), '414px' );
assert.areEqual( img.getAttribute( 'src' ), SRC );
} );
},

Expand Down Expand Up @@ -477,4 +471,4 @@
}
} );
} )();
//]]>
//]]>

0 comments on commit 3263734

Please sign in to comment.