Bug 785324 - Return a FrameTarget with 'empty' flag set true when clicking on an empty block (also in the non-editable case). r=roc
authorMats Palmgren <matspal@gmail.com>
Tue, 28 Aug 2012 03:55:30 +0200
changeset 103632 8bdeda83f7b1be7264ed1d2476c6bf432e20efe2
parent 103631 d65863fbb129f3403d80fba6a508e5558f42509f
child 103633 e3da600d76429306e000d1f1dc4733ea71493ec1
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs785324
milestone18.0a1
Bug 785324 - Return a FrameTarget with 'empty' flag set true when clicking on an empty block (also in the non-editable case). r=roc
layout/generic/nsFrame.cpp
layout/generic/test/Makefile.in
layout/generic/test/test_bug785324.html
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -3348,19 +3348,18 @@ static FrameTarget GetSelectionClosestFr
   if (!bf)
     return FrameTarget::Null();
 
   // This code searches for the correct line
   nsBlockFrame::line_iterator firstLine = bf->begin_lines();
   nsBlockFrame::line_iterator end = bf->end_lines();
   if (firstLine == end) {
     nsIContent *blockContent = aFrame->GetContent();
-    if (blockContent && blockContent->IsEditable()) {
-      // If the frame is ediable empty block, we should return it with empty
-      // flag.
+    if (blockContent) {
+      // Return with empty flag true.
       return FrameTarget(aFrame, false, false, true);
     }
     return FrameTarget::Null();
   }
   nsBlockFrame::line_iterator curLine = firstLine;
   nsBlockFrame::line_iterator closestLine = end;
   while (curLine != end) {
     // Check to see if our point lies with the line's Y bounds
--- a/layout/generic/test/Makefile.in
+++ b/layout/generic/test/Makefile.in
@@ -96,16 +96,17 @@ MOCHITEST_FILES = \
   test_selection_splitText-normalize.html \
   test_bug524925.html \
   test_bug719503.html \
   test_bug719515.html \
   test_bug719518.html \
   test_bug719523.html \
   test_bug735641.html \
   test_bug748961.html \
+  test_bug785324.html \
   $(NULL)
 
 MOCHITEST_CHROME_FILES = \
   frame_selection_underline.xhtml \
   frame_selection_underline-ref.xhtml \
   frame_selection_underline.css \
   test_selection_underline.html \
   test_bug632379.xul \
new file mode 100644
--- /dev/null
+++ b/layout/generic/test/test_bug785324.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=785324
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 785324</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=785324">Mozilla Bug 785324</a>
+<div id="test785324" style="width:100px;height:100px;border:1px solid black;" onclick="this.innerHTML = 'TEST';"></div>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 785324 **/
+
+function test()
+{
+  var div1 = document.getElementById('test785324');
+  synthesizeMouse(div1, 25, 25, {});
+  var sel = window.getSelection();
+  is(sel.rangeCount,1,"have Selection");
+  var r = sel.getRangeAt(0);
+  ok(r.startContainer == div1,"startContainer");
+  ok(r.endContainer == div1,"endContainer");
+  ok(r.startOffset == 0,"startOffset");
+  ok(r.endOffset == 0,"endOffset");
+  SimpleTest.finish();
+}
+
+window.onload = function() { setTimeout(test, 0); };
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>