Cannot focus on an empty editable span in a non editable div.
https://bugs.webkit.org/show_bug.cgi?id=33411
<rdar://problem/5982901>

Reviewed by Darin Adler.

WebCore: 

We now allow to set the focus inside an empty inline element if it is the only
editable element inside non-editable content.

* dom/Position.cpp:
(WebCore::Position::isCandidate): Extended to allow positions in inline elements when
at the border between editable and non editable content.
(WebCore::Position::getInlineBoxAndOffset): Modified to be able to calculate the caret
position inside an empty inline.
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::mergeParagraphs): When merging, we don't always find a break
element, since now an editable inline is a VisiblePosition if it is at editability boundary.
* editing/VisibleSelection.h: Updated comment on the use of Position member variables
instead of VisiblePosition.
* page/Frame.cpp:
(WebCore::Frame::selectionLayoutChanged): Changed to avoid multiple calls to upstream and
downstream on the same position.

LayoutTests: 

* editing/deleting/6026335-expected.txt: Updated to reflect the lack of extra break element.
* editing/selection/mixed-editability-10-expected.txt: Updated to cover the new case.
* editing/selection/mixed-editability-10.html: Updated to cover the new case.
* platform/mac/editing/deleting/5115601-expected.txt: Updated to reflect the lack of extra break element.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53085 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/editing/selection/mixed-editability-10.html b/LayoutTests/editing/selection/mixed-editability-10.html
index fb7c1e7..9e390d5 100644
--- a/LayoutTests/editing/selection/mixed-editability-10.html
+++ b/LayoutTests/editing/selection/mixed-editability-10.html
@@ -20,6 +20,10 @@
   <p>#5 DIV element empty</p>
   <div style="width:100px;background-color:#cee;text-align: center;" contenteditable="true" id="edit5">
   </div>
+  <p>#6 non editable DIV element with an editable empty span element</p>
+  <div id="nonedit6" style="width:100px;background-color:#cee;">
+    Hello:&nbsp;<span id="edit6" contenteditable="true"> </span>
+  </div>
   <ul id="console"></ul>
 </body>
 <script>
@@ -98,6 +102,12 @@
         x = elem.offsetLeft;
         y = elem.offsetTop + elem.offsetHeight / 2;
         runTest(x, y, elem, 0, (elem.offsetLeft + elem.offsetWidth)/2 + 4);
+
+        // the div is non editable and contains an empty editable span
+        elem = document.getElementById("edit6");
+        x = document.getElementById("nonedit6").offsetLeft + document.getElementById("nonedit6").offsetWidth / 2;
+        y = document.getElementById("nonedit6").offsetTop + document.getElementById("nonedit6").offsetHeight / 2;
+        runTest(x, y, elem, 0, 0);
     }
 }