Bug 1140625 - Part 1: Add recursive call in GetFrameForNodeOffset. r=roc
authorJeremy Chen <jeremychen@mozilla.com>
Tue, 24 Mar 2015 01:15:00 -0400
changeset 266156 1b76bac87d825887ca19e7eab0a8455f740486c5
parent 266155 cfdeb23e729642e2345eaefe90361d654915d4c4
child 266157 65d48bfeb65499937cf1679b5d9949f270737c90
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1140625
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1140625 - Part 1: Add recursive call in GetFrameForNodeOffset. r=roc
layout/generic/nsSelection.cpp
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -1850,39 +1850,31 @@ nsFrameSelection::GetFrameForNodeOffset(
       nsCOMPtr<nsIContent> childNode = theNode->GetChildAt(childIndex);
 
       if (!childNode)
         return nullptr;
 
       theNode = childNode;
     }
 
-#ifdef DONT_DO_THIS_YET
-    // XXX: We can't use this code yet because the hinting
-    //      can cause us to attach to the wrong line frame.
-
     // Now that we have the child node, check if it too
     // can contain children. If so, call this method again!
-
-    if (theNode->IsElement())
+    if (theNode->IsElement() &&
+        theNode->GetChildCount() &&
+        !theNode->HasIndependentSelection())
     {
       int32_t newOffset = 0;
 
-      if (aOffset > childIndex)
-      {
+      if (aOffset > childIndex) {
         numChildren = theNode->GetChildCount();
-
         newOffset = numChildren;
       }
 
       return GetFrameForNodeOffset(theNode, newOffset, aHint, aReturnOffset);
-    }
-    else
-#endif // DONT_DO_THIS_YET
-    {
+    } else {
       // Check to see if theNode is a text node. If it is, translate
       // aOffset into an offset into the text node.
 
       nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(theNode);
 
       if (textNode)
       {
         if (theNode->GetPrimaryFrame())