+ function onSelectEnd()\r
+ {\r
+\r
+ html.removeListener( 'mousemove', onHover );\r
+ removeListeners();\r
+\r
+ // Make it in effect on mouse up. (#9022)\r
+ textRng.select();\r
+ }\r
+\r
+ evt = evt.data;\r
+\r
+ // We're sure that the click happens at the region\r
+ // outside body, but not on scrollbar.\r
+ if ( evt.getTarget().is( 'html' ) &&\r
+ evt.$.x < html.$.clientWidth &&\r
+ evt.$.y < html.$.clientHeight )\r
+ {\r
+ // Start to build the text range.\r
+ var textRng = body.$.createTextRange();\r
+ moveRangeToPoint( textRng, evt.$.x, evt.$.y );\r
+ // Records the dragging start of the above text range.\r
+ var startRng = textRng.duplicate();\r
+\r
+ html.on( 'mousemove', onHover );\r
+ outerDoc.on( 'mouseup', onSelectEnd );\r
+ html.on( 'mouseup', onSelectEnd );\r
+ }\r
+ });\r
+ }\r
+\r
+ // It's much simpler for IE > 8, we just need to reselect the reported range.\r
+ if ( CKEDITOR.env.ie8 )\r
+ {\r
+ html.on( 'mousedown', function( evt )\r
+ {\r
+ if ( evt.data.getTarget().is( 'html' ) )\r
+ {\r
+ // Limit the text selection mouse move inside of editable. (#9715)\r
+ outerDoc.on( 'mouseup', onSelectEnd );\r
+ html.on( 'mouseup', onSelectEnd );\r
+ }\r
+\r
+ });\r
+\r
+ function removeListeners()\r
+ {\r
+ outerDoc.removeListener( 'mouseup', onSelectEnd );\r
+ html.removeListener( 'mouseup', onSelectEnd );\r
+ }\r
+\r
+ function onSelectEnd()\r
+ {\r
+ removeListeners();\r
+\r
+ // The event is not fired when clicking on the scrollbars,\r
+ // so we can safely check the following to understand\r
+ // whether the empty space following <body> has been clicked.\r
+ var sel = CKEDITOR.document.$.selection,\r
+ range = sel.createRange();\r
+ // The selection range is reported on host, but actually it should applies to the content doc.\r
+ if ( sel.type != 'None' && range.parentElement().ownerDocument == doc.$ )\r
+ range.select();\r
+ }\r
+ }\r
+\r
+ }\r