Skip to content
Permalink
Browse files

Merge branch 't/12858' into major

  • Loading branch information...
Reinmar committed Apr 6, 2015
2 parents 8354774 + 4cc3716 commit 3263734b2bd9215f1626aee29f9466e17504e736
Showing with 54 additions and 91 deletions.
  1. +21 −41 core/dom/element.js
  2. +7 −1 core/editable.js
  3. +11 −5 core/env.js
  4. +5 −12 plugins/magicline/plugin.js
  5. +0 −16 plugins/wysiwygarea/plugin.js
  6. +10 −16 tests/plugins/image/image.js
@@ -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.$;

@@ -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.
@@ -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.
@@ -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 {
@@ -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 );
};
@@ -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 = {
/**
@@ -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.
@@ -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.
@@ -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;
@@ -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 = {},
@@ -1677,6 +1666,10 @@
margin: margin,
ignoreScroll: ignoreScroll
}, box, true );

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

function updateSize( that, element, ignoreScroll ) {
@@ -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 );
}

@@ -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 ) {
@@ -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 );
} );
},

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

0 comments on commit 3263734

Please sign in to comment.
You can’t perform that action at this time.