Skip to content

Commit

Permalink
Merge branch 't/12503' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Feb 23, 2015
2 parents 681778d + d57ebe4 commit e9db567
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 99 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -32,6 +32,7 @@ Fixed Issues:
* [#12008](http://dev.ckeditor.com/ticket/12008): Fixed various cases of inserting a single non-editable element using the [`editor.insertHtml()`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-insertHtml) method. Fixes pasting a widget with a nested editable inside another widget's nested editable.
* [#12148](http://dev.ckeditor.com/ticket/12148): Fixed: [`dom.element.getChild()`](http://docs.ckeditor.com/#!/api/CKEDITOR.dom.element-method-getChild) should not modify passed array.
* [#12874](http://dev.ckeditor.com/ticket/12874): Fixed: Information about aggregated tasks should be somehow accessible in [aggregated#finished](http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.notificationAggregator-event-finished).
* [#12503](http://dev.ckeditor.com/ticket/12503): [Blink/Webkit] Fixed: Incorrect result of select all, backspace/delete.

Other Changes:

Expand Down
10 changes: 10 additions & 0 deletions core/editable.js
Expand Up @@ -2400,6 +2400,9 @@
if ( ( bogus = startBlock.getBogus() ) )
bogus.remove();

// Changing end container to element from text node (#12503).
range.enlarge( CKEDITOR.ENLARGE_INLINE );

// Delete range contents. Do NOT merge. Merging is weird.
range.deleteContents();

Expand All @@ -2419,6 +2422,13 @@
// Make sure the result selection is collapsed.
range = editor.getSelection().getRanges()[ 0 ];
range.collapse( 1 );

// Optimizing range containers from text nodes to elements (#12503).
range.optimize();
if ( range.startContainer.getHtml() === '' ) {
range.startContainer.appendBogus();
}

range.select();

return true;
Expand Down
Expand Up @@ -11,9 +11,11 @@ var quirksTools = ( function() {
8: 'BACKSPACE'
};

function assertKeystroke( key, keyModifiers, handled, html, expected ) {
function assertKeystroke( key, keyModifiers, handled, html, expected, normalizeSelection ) {
normalizeSelection = ( normalizeSelection === false ) ? false : true;

function decodeBoguses( html ) {
return html.replace( /@/g, '<br />' );
return html.replace( /@/g, CKEDITOR.env.needsBrFiller ? '<br />' : '' );
}

return function() {
Expand All @@ -23,7 +25,7 @@ var quirksTools = ( function() {

html = decodeBoguses( html );

bot.htmlWithSelection( html );
bender.tools.selection.setWithHtml( editor, html );

var listener = editor.on( 'key', function() {
++handledNatively;
Expand All @@ -35,8 +37,16 @@ var quirksTools = ( function() {
shiftKey: keyModifiers & CKEDITOR.SHIFT
} ) );

assert.areSame( decodeBoguses( expected ),
bender.tools.getHtmlWithSelection( editor.editable(), editor.document ).replace( /\u200b/g, '' ), '(' + keyNames[ key ] + ') Correct DOM state after the keystroke' );
var htmlWithSelection = bender.tools.selection.getWithHtml( editor );
var message = '(' + keyNames[ key ] + ') Correct DOM state after the keystroke';

assert.isInnerHtmlMatching(
expected,
htmlWithSelection,
{ compareSelection: true, normalizeSelection: normalizeSelection },
message
);

assert.areSame( handled, handledNatively, '(' + keyNames[ key ] + ') Keystroke handled by the browser' );

listener.removeListener();
Expand All @@ -52,11 +62,11 @@ var quirksTools = ( function() {
}

function bf( html ) {
return assertKeystroke.apply( this, [ BACKSPACE, 0, 1, html, html ] );
return assertKeystroke.apply( this, [ BACKSPACE, 0, 1, html, html, false ] );
}

function df( html ) {
return assertKeystroke.apply( this, [ DEL, 0, 1, html, html ] );
return assertKeystroke.apply( this, [ DEL, 0, 1, html, html, false ] );
}

return {
Expand Down Expand Up @@ -92,4 +102,4 @@ var quirksTools = ( function() {
};
}
};
} )();
} )();

0 comments on commit e9db567

Please sign in to comment.