Merge with inbound
authorAnant Narayanan <anant@kix.in>
Mon, 15 Oct 2012 11:36:15 -0700
changeset 110440 967fa8cc6213ac47ea11826e48be1e9d9d2d1ade
parent 110439 76c3e2baba712fd25b3fabc52c890b6c92364ad2 (current diff)
parent 110438 21cb609fe6690fbad6c6167e10ee2e7f9804a593 (diff)
child 110441 8595e313fc21a8612c18c5c2b03be292dbc2b8f7
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
milestone19.0a1
Merge with inbound
layout/base/nsFrameIterator.cpp
layout/base/nsFrameIterator.h
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -60,16 +60,17 @@
 #include "nsDOMDragEvent.h"
 #include "nsIDOMNSEditableElement.h"
 #include "nsIDOMMozBrowserFrame.h"
 #include "nsIMozBrowserFrame.h"
 
 #include "nsCaret.h"
 
 #include "nsSubDocumentFrame.h"
+#include "nsIFrameTraversal.h"
 #include "nsLayoutCID.h"
 #include "nsLayoutUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsContentUtils.h"
 
 #include "imgIContainer.h"
 #include "nsIProperties.h"
@@ -108,16 +109,18 @@ using namespace mozilla;
 using namespace mozilla::dom;
 
 //#define DEBUG_DOCSHELL_FOCUS
 
 #define NS_USER_INTERACTION_INTERVAL 5000 // ms
 
 static const nsIntPoint kInvalidRefPoint = nsIntPoint(-1,-1);
 
+static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
+
 static bool sLeftClickOnly = true;
 static bool sKeyCausesActivation = true;
 static uint32_t sESMInstanceCount = 0;
 static int32_t sChromeAccessModifier = 0, sContentAccessModifier = 0;
 int32_t nsEventStateManager::sUserInputEventDepth = 0;
 bool nsEventStateManager::sNormalLMouseEventInProcess = false;
 nsEventStateManager* nsEventStateManager::sActiveESM = nullptr;
 nsIDocument* nsEventStateManager::sMouseOverDocument = nullptr;
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -26,17 +26,17 @@
 #include "nsIHTMLDocument.h"
 #include "nsIDocShell.h"
 #include "nsIEditorDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsLayoutUtils.h"
 #include "nsIPresShell.h"
 #include "nsIContentViewer.h"
-#include "nsFrameIterator.h"
+#include "nsFrameTraversal.h"
 #include "nsObjectFrame.h"
 #include "nsEventDispatcher.h"
 #include "nsEventStateManager.h"
 #include "nsIMEStateManager.h"
 #include "nsIWebNavigation.h"
 #include "nsCaret.h"
 #include "nsIBaseWindow.h"
 #include "nsIViewManager.h"
@@ -2265,27 +2265,34 @@ nsFocusManager::GetSelectionLocation(nsI
         startContent->AppendTextTo(nodeValue);
 
         bool isFormControl =
           startContent->IsNodeOfType(nsINode::eHTML_FORM_CONTROL);
 
         if (nodeValue.Length() == (uint32_t)startOffset && !isFormControl &&
             startContent != aDocument->GetRootElement()) {
           // Yes, indeed we were at the end of the last node
-          nsFrameIterator frameTraversal(presContext, startFrame,
-                                         eLeaf, nsFrameIterator::FLAG_FOLLOW_OUT_OF_FLOW);
+          nsCOMPtr<nsIFrameEnumerator> frameTraversal;
+          nsresult rv = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
+                                             presContext, startFrame,
+                                             eLeaf,
+                                             false, // aVisual
+                                             false, // aLockInScrollView
+                                             true      // aFollowOOFs
+                                             );
+          NS_ENSURE_SUCCESS(rv, rv);
 
           nsIFrame *newCaretFrame = nullptr;
           nsCOMPtr<nsIContent> newCaretContent = startContent;
           bool endOfSelectionInStartNode(startContent == endContent);
           do {
             // Continue getting the next frame until the primary content for the frame
             // we are on changes - we don't want to be stuck in the same place
-            frameTraversal.Next();
-            newCaretFrame = static_cast<nsIFrame*>(frameTraversal.CurrentItem());
+            frameTraversal->Next();
+            newCaretFrame = static_cast<nsIFrame*>(frameTraversal->CurrentItem());
             if (nullptr == newCaretFrame)
               break;
             newCaretContent = newCaretFrame->GetContent();
           } while (!newCaretContent || newCaretContent == startContent);
 
           if (newCaretFrame && newCaretContent) {
             // If the caret is exactly at the same position of the new frame,
             // then we can use the newCaretFrame and newCaretContent for our position
@@ -2691,39 +2698,46 @@ nsFocusManager::GetNextTabbableContent(n
       if (iterStartContent)
         continue;
 
       // otherwise, as a last attempt, just look at the root content
       iterStartContent = aRootContent;
       continue;
     }
 
-    nsFrameIterator frameTraversal(presContext, startFrame,
-                                   ePreOrder, nsFrameIterator::FLAG_FOLLOW_OUT_OF_FLOW);
+    nsCOMPtr<nsIFrameEnumerator> frameTraversal;
+    nsresult rv = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
+                                       presContext, startFrame,
+                                       ePreOrder,
+                                       false, // aVisual
+                                       false, // aLockInScrollView
+                                       true      // aFollowOOFs
+                                       );
+    NS_ENSURE_SUCCESS(rv, rv);
 
     if (iterStartContent == aRootContent) {
       if (!aForward) {
-        frameTraversal.Last();
+        frameTraversal->Last();
       } else if (aRootContent->IsFocusable()) {
-        frameTraversal.Next();
+        frameTraversal->Next();
       }
     }
     else if (getNextFrame &&
              (!iterStartContent || iterStartContent->Tag() != nsGkAtoms::area ||
               !iterStartContent->IsHTML())) {
       // Need to do special check in case we're in an imagemap which has multiple
       // content nodes per frame, so don't skip over the starting frame.
       if (aForward)
-        frameTraversal.Next();
+        frameTraversal->Next();
       else
-        frameTraversal.Prev();
+        frameTraversal->Prev();
     }
 
     // Walk frames to find something tabbable matching mCurrentTabIndex
-    nsIFrame* frame = static_cast<nsIFrame*>(frameTraversal.CurrentItem());
+    nsIFrame* frame = static_cast<nsIFrame*>(frameTraversal->CurrentItem());
     while (frame) {
       // TabIndex not set defaults to 0 for form elements, anchors and other
       // elements that are normally focusable. Tabindex defaults to -1
       // for elements that are not normally focusable.
       // The returned computed tabindex from IsFocusable() is as follows:
       //          < 0 not tabbable at all
       //          == 0 in normal tab order (last after positive tabindexed items)
       //          > 0 can be tabbed to in the order specified by this value
@@ -2783,20 +2797,20 @@ nsFocusManager::GetNextTabbableContent(n
                     NS_ADDREF(*aResultContent);
                     return NS_OK;
                   }
                 }
               }
               Element* rootElement = subdoc->GetRootElement();
               nsIPresShell* subShell = subdoc->GetShell();
               if (rootElement && subShell) {
-                nsresult rv = GetNextTabbableContent(subShell, rootElement,
-                                                     aOriginalStartContent, rootElement,
-                                                     aForward, (aForward ? 1 : 0),
-                                                     false, aResultContent);
+                rv = GetNextTabbableContent(subShell, rootElement,
+                                            aOriginalStartContent, rootElement,
+                                            aForward, (aForward ? 1 : 0),
+                                            false, aResultContent);
                 NS_ENSURE_SUCCESS(rv, rv);
                 if (*aResultContent)
                   return NS_OK;
               }
             }
           }
           // otherwise, use this as the next content node to tab to, unless
           // this was the element we started on. This would happen for
@@ -2830,20 +2844,20 @@ nsFocusManager::GetNextTabbableContent(n
       // Otherwise, a loop will occur in the following example:
       //   <span tabindex="1">...<a/><a/>...</span>
       // where the text wraps onto multiple lines. Tabbing from the second
       // link can find one of the span's continuation frames between the link
       // and the end of the span, and the span would end up getting focused
       // again.
       do {
         if (aForward)
-          frameTraversal.Next();
+          frameTraversal->Next();
         else
-          frameTraversal.Prev();
-        frame = static_cast<nsIFrame*>(frameTraversal.CurrentItem());
+          frameTraversal->Prev();
+        frame = static_cast<nsIFrame*>(frameTraversal->CurrentItem());
       } while (frame && frame->GetPrevContinuation());
     }
 
     // If already at lowest priority tab (0), end search completely.
     // A bit counterintuitive but true, tabindex order goes 1, 2, ... 32767, 0
     if (aCurrentTabIndex == (aForward ? 0 : 1)) {
       // if going backwards, the canvas should be focused once the beginning
       // has been reached.
--- a/layout/base/Makefile.in
+++ b/layout/base/Makefile.in
@@ -12,16 +12,17 @@ include $(DEPTH)/config/autoconf.mk
 
 TEST_DIRS += tests
 
 MODULE		= layout
 XPIDL_MODULE	= layout_base
 GRE_MODULE	= 1
 LIBRARY_NAME	= gkbase_s
 LIBXUL_LIBRARY	= 1
+FAIL_ON_WARNINGS = 1
 
 
 
 XPIDLSRCS	= \
 		nsIStyleSheetService.idl	\
 		$(NULL)
 
 EXPORTS_NAMESPACES = mozilla
@@ -37,17 +38,18 @@ EXPORTS		= \
 		nsChangeHint.h \
 		nsCompatibility.h \
 		nsDisplayItemTypes.h \
 		nsDisplayItemTypesList.h \
 		nsDisplayList.h \
 		nsDisplayListInvalidation.h \
 		nsFrameManager.h \
 		nsFrameManagerBase.h \
-		nsFrameIterator.h \
+		nsFrameTraversal.h \
+		nsIFrameTraversal.h \
 		nsILayoutDebugger.h \
 		nsILayoutHistoryState.h \
 		nsIPercentHeightObserver.h  \
 		nsIPresShell.h \
 		nsIReflowCallback.h \
 		nsLayoutUtils.h \
 		nsPresArena.h \
 		nsPresContext.h \
@@ -73,17 +75,17 @@ CPPSRCS		= \
 		nsCSSRenderingBorders.cpp \
 		nsCaret.cpp \
 		nsChildIterator.cpp \
 		nsCounterManager.cpp \
 		nsDisplayList.cpp \
 		nsDisplayListInvalidation.cpp \
 		nsDocumentViewer.cpp \
 		nsFrameManager.cpp \
-		nsFrameIterator.cpp \
+		nsFrameTraversal.cpp \
 		nsGenConList.cpp \
 		nsLayoutDebugger.cpp \
 		nsLayoutHistoryState.cpp \
 		nsLayoutUtils.cpp \
 		nsPresArena.cpp \
 		nsPresContext.cpp \
 		nsPresShell.cpp \
 		nsQuoteList.cpp \
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -2097,17 +2097,18 @@ bool nsBidiPresUtils::WriteLogicalToVisu
         NS_ASSERTION(src >= aSrc && src < aSrc + aSrcLength,
                      "logical index out of range");
         NS_ASSERTION(dest < aDest + aSrcLength, "visual index out of range");
         *(dest++) = *(src++);
       } while (--length);
     }
   }
 
-  NS_ASSERTION(dest - aDest == aSrcLength, "whole string not copied");
+  NS_ASSERTION(static_cast<uint32_t>(dest - aDest) == aSrcLength,
+               "whole string not copied");
   return true;
 }
 
 void nsBidiPresUtils::CopyLogicalToVisual(const nsAString& aSource,
                                           nsAString& aDest,
                                           nsBidiLevel aBaseDirection,
                                           bool aOverride)
 {
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -8030,17 +8030,16 @@ FrameHasPositionedPlaceholderDescendants
 static bool
 NeedToReframeForAddingOrRemovingTransform(nsIFrame* aFrame)
 {
   MOZ_STATIC_ASSERT(0 <= NS_STYLE_POSITION_ABSOLUTE &&
                     NS_STYLE_POSITION_ABSOLUTE < 32, "Style constant out of range");
   MOZ_STATIC_ASSERT(0 <= NS_STYLE_POSITION_FIXED &&
                     NS_STYLE_POSITION_FIXED < 32, "Style constant out of range");
 
-  const nsStyleDisplay* style = aFrame->GetStyleDisplay();
   uint32_t positionMask;
   // Don't call aFrame->IsPositioned here, since that returns true if
   // the frame already has a transform, and we want to ignore that here
   if (aFrame->IsAbsolutelyPositioned() ||
       aFrame->IsRelativelyPositioned()) {
     // This frame is a container for abs-pos descendants whether or not it
     // has a transform.
     // So abs-pos descendants are no problem; we only need to reframe if
deleted file mode 100644
--- a/layout/base/nsFrameIterator.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsFrameIterator.h"
-#include "nsIFrame.h"
-#include "nsGkAtoms.h"
-#include "nsPlaceholderFrame.h"
-
-nsFrameIterator::nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
-                                 nsIteratorType aType, uint32_t aFlags)
-  : mPresContext(aPresContext)
-  , mOffEdge(0)
-  , mType(aType)
-{
-  mFollowOOFs = (aFlags & FLAG_FOLLOW_OUT_OF_FLOW) != 0;
-  mLockScroll = (aFlags & FLAG_LOCK_SCROLL) != 0;
-  mVisual = (aFlags & FLAG_VISUAL) != 0;
-  if (mFollowOOFs && aStart)
-    aStart = nsPlaceholderFrame::GetRealFrameFor(aStart);
-  setStart(aStart);
-  setCurrent(aStart);
-  setLast(aStart);
-}
-
-nsIFrame*
-nsFrameIterator::CurrentItem()
-{
-  return mOffEdge ? nullptr : mCurrent;
-}
-
-bool
-nsFrameIterator::IsDone()
-{
-  return mOffEdge != 0;
-}
-
-void
-nsFrameIterator::First()
-{
-  mCurrent = mStart;
-}
-
-static bool
-IsRootFrame(nsIFrame* aFrame)
-{
-  nsIAtom* atom = aFrame->GetType();
-  return (atom == nsGkAtoms::canvasFrame) ||
-         (atom == nsGkAtoms::rootFrame);
-}
-
-void
-nsFrameIterator::Last()
-{
-  nsIFrame* result;
-  nsIFrame* parent = getCurrent();
-  // If the current frame is a popup, don't move farther up the tree.
-  // Otherwise, get the nearest root frame or popup.
-  if (parent->GetType() != nsGkAtoms::menuPopupFrame) {
-    while (!IsRootFrame(parent) && (result = GetParentFrameNotPopup(parent)))
-      parent = result;
-  }
-
-  while ((result = GetLastChild(parent))) {
-    parent = result;
-  }
-
-  setCurrent(parent);
-  if (!parent)
-    setOffEdge(1);
-}
-
-void
-nsFrameIterator::Next()
-{
-  // recursive-oid method to get next frame
-  nsIFrame *result = nullptr;
-  nsIFrame *parent = getCurrent();
-  if (!parent)
-    parent = getLast();
-
-  if (mType == eLeaf) {
-    // Drill down to first leaf
-    while ((result = GetFirstChild(parent))) {
-      parent = result;
-    }
-  } else if (mType == ePreOrder) {
-    result = GetFirstChild(parent);
-    if (result)
-      parent = result;
-  }
-
-  if (parent != getCurrent()) {
-    result = parent;
-  } else {
-    while (parent) {
-      result = GetNextSibling(parent);
-      if (result) {
-        if (mType != ePreOrder) {
-          parent = result;
-          while ((result = GetFirstChild(parent))) {
-            parent = result;
-          }
-          result = parent;
-        }
-        break;
-      }
-      else {
-        result = GetParentFrameNotPopup(parent);
-        if (!result || IsRootFrame(result) ||
-            (mLockScroll && result->GetType() == nsGkAtoms::scrollFrame)) {
-          result = nullptr;
-          break;
-        }
-        if (mType == ePostOrder)
-          break;
-        parent = result;
-      }
-    }
-  }
-
-  setCurrent(result);
-  if (!result) {
-    setOffEdge(1);
-    setLast(parent);
-  }
-}
-
-void
-nsFrameIterator::Prev()
-{
-  // recursive-oid method to get prev frame
-  nsIFrame *result = nullptr;
-  nsIFrame *parent = getCurrent();
-  if (!parent)
-    parent = getLast();
-
-  if (mType == eLeaf) {
-    // Drill down to last leaf
-    while ((result = GetLastChild(parent))) {
-      parent = result;
-    }
-  } else if (mType == ePostOrder) {
-    result = GetLastChild(parent);
-    if (result)
-      parent = result;
-  }
-
-  if (parent != getCurrent()) {
-    result = parent;
-  } else {
-    while (parent) {
-      result = GetPrevSibling(parent);
-      if (result) {
-        if (mType != ePostOrder) {
-          parent = result;
-          while ((result = GetLastChild(parent))) {
-            parent = result;
-          }
-          result = parent;
-        }
-        break;
-      } else {
-        result = GetParentFrameNotPopup(parent);
-        if (!result || IsRootFrame(result) ||
-            (mLockScroll && result->GetType() == nsGkAtoms::scrollFrame)) {
-          result = nullptr;
-          break;
-        }
-        if (mType == ePreOrder)
-          break;
-        parent = result;
-      }
-    }
-  }
-
-  setCurrent(result);
-  if (!result) {
-    setOffEdge(-1);
-    setLast(parent);
-  }
-}
-
-nsIFrame*
-nsFrameIterator::GetParentFrame(nsIFrame* aFrame)
-{
-  if (mFollowOOFs)
-    aFrame = GetPlaceholderFrame(aFrame);
-  if (aFrame)
-    return aFrame->GetParent();
-
-  return nullptr;
-}
-
-nsIFrame*
-nsFrameIterator::GetParentFrameNotPopup(nsIFrame* aFrame)
-{
-  if (mFollowOOFs)
-    aFrame = GetPlaceholderFrame(aFrame);
-  if (aFrame) {
-    nsIFrame* parent = aFrame->GetParent();
-    if (!IsPopupFrame(parent))
-      return parent;
-  }
-
-  return nullptr;
-}
-
-nsIFrame*
-nsFrameIterator::GetFirstChild(nsIFrame* aFrame)
-{
-  nsIFrame* result = GetFirstChildInner(aFrame);
-  if (mLockScroll && result && result->GetType() == nsGkAtoms::scrollFrame)
-    return nullptr;
-  if (result && mFollowOOFs) {
-    result = nsPlaceholderFrame::GetRealFrameFor(result);
-
-    if (IsPopupFrame(result))
-      result = GetNextSibling(result);
-  }
-  return result;
-}
-
-nsIFrame*
-nsFrameIterator::GetLastChild(nsIFrame* aFrame)
-{
-  nsIFrame* result = GetLastChildInner(aFrame);
-  if (mLockScroll && result && result->GetType() == nsGkAtoms::scrollFrame)
-    return nullptr;
-  if (result && mFollowOOFs) {
-    result = nsPlaceholderFrame::GetRealFrameFor(result);
-
-    if (IsPopupFrame(result))
-      result = GetPrevSibling(result);
-  }
-  return result;
-}
-
-nsIFrame*
-nsFrameIterator::GetNextSibling(nsIFrame* aFrame)
-{
-  nsIFrame* result = nullptr;
-  if (mFollowOOFs)
-    aFrame = GetPlaceholderFrame(aFrame);
-  if (aFrame) {
-    result = GetNextSiblingInner(aFrame);
-    if (result && mFollowOOFs)
-      result = nsPlaceholderFrame::GetRealFrameFor(result);
-  }
-
-  if (mFollowOOFs && IsPopupFrame(result))
-    result = GetNextSibling(result);
-
-  return result;
-}
-
-nsIFrame*
-nsFrameIterator::GetPrevSibling(nsIFrame* aFrame)
-{
-  nsIFrame* result = nullptr;
-  if (mFollowOOFs)
-    aFrame = GetPlaceholderFrame(aFrame);
-  if (aFrame) {
-    result = GetPrevSiblingInner(aFrame);
-    if (result && mFollowOOFs)
-      result = nsPlaceholderFrame::GetRealFrameFor(result);
-  }
-
-  if (mFollowOOFs && IsPopupFrame(result))
-    result = GetPrevSibling(result);
-
-  return result;
-}
-
-nsIFrame*
-nsFrameIterator::GetFirstChildInner(nsIFrame* aFrame) {
-  if (mVisual) {
-    return aFrame->PrincipalChildList().GetNextVisualFor(nullptr);
-  }
-  return aFrame->GetFirstPrincipalChild();
-}
-
-nsIFrame*
-nsFrameIterator::GetLastChildInner(nsIFrame* aFrame) {
-  if (mVisual) {
-    return aFrame->PrincipalChildList().GetPrevVisualFor(nullptr);
-  }
-  return aFrame->PrincipalChildList().LastChild();
-}
-
-nsIFrame*
-nsFrameIterator::GetNextSiblingInner(nsIFrame* aFrame) {
-  if (mVisual) {
-    nsIFrame* parent = GetParentFrame(aFrame);
-    if (!parent)
-      return nullptr;
-    return parent->PrincipalChildList().GetNextVisualFor(aFrame);
-  }
-  return aFrame->GetNextSibling();
-}
-
-nsIFrame*
-nsFrameIterator::GetPrevSiblingInner(nsIFrame* aFrame) {
-  if (mVisual) {
-    nsIFrame* parent = GetParentFrame(aFrame);
-    if (!parent)
-      return nullptr;
-    return parent->PrincipalChildList().GetPrevVisualFor(aFrame);
-  }
-  return aFrame->GetPrevSibling();
-}
-
-nsIFrame*
-nsFrameIterator::GetPlaceholderFrame(nsIFrame* aFrame)
-{
-  nsIFrame* result = aFrame;
-  nsIPresShell *presShell = mPresContext->GetPresShell();
-  if (presShell) {
-    nsIFrame* placeholder = presShell->GetPlaceholderFrameFor(aFrame);
-    if (placeholder)
-      result = placeholder;
-  }
-
-  if (result != aFrame)
-    result = GetPlaceholderFrame(result);
-
-  return result;
-}
-
-bool
-nsFrameIterator::IsPopupFrame(nsIFrame* aFrame)
-{
-  return (aFrame &&
-          aFrame->GetStyleDisplay()->mDisplay == NS_STYLE_DISPLAY_POPUP);
-}
-
deleted file mode 100644
--- a/layout/base/nsFrameIterator.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef NSFRAMEITERATOR_H
-#define NSFRAMEITERATOR_H
-
-#include "mozilla/StandardInteger.h"
-
-class nsPresContext;
-class nsIFrame;
-
-enum nsIteratorType {
-  eLeaf,
-  ePreOrder,
-  ePostOrder
-};
-
-class nsFrameIterator
-{
-public:
-  nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
-                  nsIteratorType aType, uint32_t aFlags);
-
-  ~nsFrameIterator() {}
-
-  void First();
-  void Next();
-  nsIFrame* CurrentItem();
-  bool IsDone();
-
-  void Last();
-  void Prev();
-
-  enum FrameIteratorFlags {
-    FLAG_NONE = 0,
-    FLAG_LOCK_SCROLL = 1 << 1,
-    FLAG_FOLLOW_OUT_OF_FLOW = 1 << 2,
-    FLAG_VISUAL = 1 << 3
-  };
-protected:
-  void      setCurrent(nsIFrame *aFrame){mCurrent = aFrame;}
-  nsIFrame *getCurrent(){return mCurrent;}
-  void      setStart(nsIFrame *aFrame){mStart = aFrame;}
-  nsIFrame *getStart(){return mStart;}
-  nsIFrame *getLast(){return mLast;}
-  void      setLast(nsIFrame *aFrame){mLast = aFrame;}
-  int8_t    getOffEdge(){return mOffEdge;}
-  void      setOffEdge(int8_t aOffEdge){mOffEdge = aOffEdge;}
-  void      SetLockInScrollView(bool aLockScroll){mLockScroll = aLockScroll;}
-
-  /*
-   Our own versions of the standard frame tree navigation
-   methods, which, if the iterator is following out-of-flows,
-   apply the following rules for placeholder frames:
-
-   - If a frame HAS a placeholder frame, getting its parent
-   gets the placeholder's parent.
-
-   - If a frame's first child or next/prev sibling IS a
-   placeholder frame, then we instead return the real frame.
-
-   - If a frame HAS a placeholder frame, getting its next/prev
-   sibling gets the placeholder frame's next/prev sibling.
-
-   These are all applied recursively to support multiple levels of
-   placeholders.
-   */
-
-  nsIFrame* GetParentFrame(nsIFrame* aFrame);
-  // like GetParentFrame but returns null once a popup frame is reached
-  nsIFrame* GetParentFrameNotPopup(nsIFrame* aFrame);
-
-  nsIFrame* GetFirstChild(nsIFrame* aFrame);
-  nsIFrame* GetLastChild(nsIFrame* aFrame);
-
-  nsIFrame* GetNextSibling(nsIFrame* aFrame);
-  nsIFrame* GetPrevSibling(nsIFrame* aFrame);
-
-  /*
-   These methods are different in visual mode to have the
-   semantics of "get first child in visual order", "get last child in visual
-   order", "get next sibling in visual order" and "get previous sibling in visual
-   order".
-  */
-
-  nsIFrame* GetFirstChildInner(nsIFrame* aFrame);
-  nsIFrame* GetLastChildInner(nsIFrame* aFrame);
-
-  nsIFrame* GetNextSiblingInner(nsIFrame* aFrame);
-  nsIFrame* GetPrevSiblingInner(nsIFrame* aFrame);
-
-  nsIFrame* GetPlaceholderFrame(nsIFrame* aFrame);
-  bool      IsPopupFrame(nsIFrame* aFrame);
-
-  nsPresContext* mPresContext;
-  nsIFrame *mStart;
-  nsIFrame *mCurrent;
-  nsIFrame *mLast; //the last one that was in current;
-  int8_t    mOffEdge; //0= no -1 to far prev, 1 to far next;
-  nsIteratorType mType;
-  bool mLockScroll;
-  bool mFollowOOFs;
-  bool mVisual;
-};
-
-#endif //NSFRAMEITERATOR_H
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -447,18 +447,18 @@ nsFrameManager::AppendFrames(nsIFrame*  
 
 nsresult
 nsFrameManager::InsertFrames(nsIFrame*       aParentFrame,
                              ChildListID     aListID,
                              nsIFrame*       aPrevFrame,
                              nsFrameList&    aFrameList)
 {
   NS_PRECONDITION(!aPrevFrame || (!aPrevFrame->GetNextContinuation()
-                  || ((aPrevFrame->GetNextContinuation()->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))
-                  && !(aPrevFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)),
+                  || (((aPrevFrame->GetNextContinuation()->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))
+                  && !(aPrevFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))),
                   "aPrevFrame must be the last continuation in its chain!");
 
   if (aParentFrame->IsAbsoluteContainer() &&
       aListID == aParentFrame->GetAbsoluteListID()) {
     return aParentFrame->GetAbsoluteContainingBlock()->
            InsertFrames(aParentFrame, aListID, aPrevFrame, aFrameList);
   } else {
     return aParentFrame->InsertFrames(aListID, aPrevFrame, aFrameList);
new file mode 100644
--- /dev/null
+++ b/layout/base/nsFrameTraversal.cpp
@@ -0,0 +1,528 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include "nsCOMPtr.h"
+#include "nsGkAtoms.h"
+
+#include "nsFrameTraversal.h"
+#include "nsFrameList.h"
+#include "nsPlaceholderFrame.h"
+
+
+class nsFrameIterator : public nsIFrameEnumerator
+{
+public:
+  typedef nsIFrame::ChildListID ChildListID;
+
+  NS_DECL_ISUPPORTS
+
+  virtual ~nsFrameIterator() {}
+
+  virtual void First();
+  virtual void Next();
+  virtual nsIFrame* CurrentItem();
+  virtual bool IsDone();
+
+  virtual void Last();
+  virtual void Prev();
+
+  nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
+                  nsIteratorType aType, bool aLockScroll, bool aFollowOOFs);
+
+protected:
+  void      setCurrent(nsIFrame *aFrame){mCurrent = aFrame;}
+  nsIFrame *getCurrent(){return mCurrent;}
+  void      setStart(nsIFrame *aFrame){mStart = aFrame;}
+  nsIFrame *getStart(){return mStart;}
+  nsIFrame *getLast(){return mLast;}
+  void      setLast(nsIFrame *aFrame){mLast = aFrame;}
+  PRInt8    getOffEdge(){return mOffEdge;}
+  void      setOffEdge(PRInt8 aOffEdge){mOffEdge = aOffEdge;}
+  void      SetLockInScrollView(bool aLockScroll){mLockScroll = aLockScroll;}
+
+  /*
+   Our own versions of the standard frame tree navigation
+   methods, which, if the iterator is following out-of-flows,
+   apply the following rules for placeholder frames:
+   
+   - If a frame HAS a placeholder frame, getting its parent
+   gets the placeholder's parent.
+   
+   - If a frame's first child or next/prev sibling IS a
+   placeholder frame, then we instead return the real frame.
+   
+   - If a frame HAS a placeholder frame, getting its next/prev
+   sibling gets the placeholder frame's next/prev sibling.
+   
+   These are all applied recursively to support multiple levels of
+   placeholders.
+   */  
+  
+  nsIFrame* GetParentFrame(nsIFrame* aFrame);
+  // like GetParentFrame but returns null once a popup frame is reached
+  nsIFrame* GetParentFrameNotPopup(nsIFrame* aFrame);
+
+  nsIFrame* GetFirstChild(nsIFrame* aFrame);
+  nsIFrame* GetLastChild(nsIFrame* aFrame);
+
+  nsIFrame* GetNextSibling(nsIFrame* aFrame);
+  nsIFrame* GetPrevSibling(nsIFrame* aFrame);
+
+  /*
+   These methods are overridden by the bidi visual iterator to have the
+   semantics of "get first child in visual order", "get last child in visual
+   order", "get next sibling in visual order" and "get previous sibling in visual
+   order".
+  */
+  
+  virtual nsIFrame* GetFirstChildInner(nsIFrame* aFrame);
+  virtual nsIFrame* GetLastChildInner(nsIFrame* aFrame);  
+
+  virtual nsIFrame* GetNextSiblingInner(nsIFrame* aFrame);
+  virtual nsIFrame* GetPrevSiblingInner(nsIFrame* aFrame);
+
+  nsIFrame* GetPlaceholderFrame(nsIFrame* aFrame);
+  bool      IsPopupFrame(nsIFrame* aFrame);
+
+  nsPresContext* mPresContext;
+  bool mLockScroll;
+  bool mFollowOOFs;
+  nsIteratorType mType;
+
+private:
+  nsIFrame *mStart;
+  nsIFrame *mCurrent;
+  nsIFrame *mLast; //the last one that was in current;
+  PRInt8    mOffEdge; //0= no -1 to far prev, 1 to far next;
+};
+
+
+
+// Bidi visual iterator
+class nsVisualIterator: public nsFrameIterator
+{
+public:
+  nsVisualIterator(nsPresContext* aPresContext, nsIFrame *aStart,
+                   nsIteratorType aType, bool aLockScroll, bool aFollowOOFs) :
+  nsFrameIterator(aPresContext, aStart, aType, aLockScroll, aFollowOOFs) {}
+
+protected:
+  nsIFrame* GetFirstChildInner(nsIFrame* aFrame);
+  nsIFrame* GetLastChildInner(nsIFrame* aFrame);  
+  
+  nsIFrame* GetNextSiblingInner(nsIFrame* aFrame);
+  nsIFrame* GetPrevSiblingInner(nsIFrame* aFrame);  
+};
+
+/************IMPLEMENTATIONS**************/
+
+nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult)
+{
+  NS_ENSURE_ARG_POINTER(aResult);
+  *aResult = nullptr;
+
+  nsCOMPtr<nsIFrameTraversal> t(new nsFrameTraversal());
+
+  *aResult = t;
+  NS_ADDREF(*aResult);
+
+  return NS_OK;
+}
+
+nsresult
+NS_NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
+                     nsPresContext* aPresContext,
+                     nsIFrame *aStart,
+                     nsIteratorType aType,
+                     bool aVisual,
+                     bool aLockInScrollView,
+                     bool aFollowOOFs)
+{
+  if (!aEnumerator || !aStart)
+    return NS_ERROR_NULL_POINTER;
+  nsCOMPtr<nsIFrameEnumerator> trav;
+  if (aVisual) {
+    trav = new nsVisualIterator(aPresContext, aStart, aType,
+                                aLockInScrollView, aFollowOOFs);
+  } else {
+    trav = new nsFrameIterator(aPresContext, aStart, aType,
+                               aLockInScrollView, aFollowOOFs);
+  }
+  trav.forget(aEnumerator);
+  return NS_OK;
+}
+
+
+nsFrameTraversal::nsFrameTraversal()
+{
+}
+
+nsFrameTraversal::~nsFrameTraversal()
+{
+}
+
+NS_IMPL_ISUPPORTS1(nsFrameTraversal,nsIFrameTraversal)
+
+NS_IMETHODIMP 
+ nsFrameTraversal::NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
+                                     nsPresContext* aPresContext,
+                                     nsIFrame *aStart,
+                                     PRInt32 aType,
+                                     bool aVisual,
+                                     bool aLockInScrollView,
+                                     bool aFollowOOFs)
+{
+  return NS_NewFrameTraversal(aEnumerator, aPresContext, aStart,
+                              static_cast<nsIteratorType>(aType),
+                              aVisual, aLockInScrollView, aFollowOOFs);  
+}
+
+// nsFrameIterator implementation
+
+NS_IMPL_ISUPPORTS1(nsFrameIterator, nsIFrameEnumerator)
+
+nsFrameIterator::nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
+                                 nsIteratorType aType, bool aLockInScrollView,
+                                 bool aFollowOOFs)
+{
+  mOffEdge = 0;
+  mPresContext = aPresContext;
+  if (aFollowOOFs && aStart)
+    aStart = nsPlaceholderFrame::GetRealFrameFor(aStart);
+  setStart(aStart);
+  setCurrent(aStart);
+  setLast(aStart);
+  mType = aType;
+  SetLockInScrollView(aLockInScrollView);
+  mFollowOOFs = aFollowOOFs;
+}
+
+
+
+nsIFrame*
+nsFrameIterator::CurrentItem()
+{
+  if (mOffEdge)
+    return nullptr;
+
+  return mCurrent;
+}
+
+
+
+bool
+nsFrameIterator::IsDone()
+{
+  return mOffEdge != 0;
+}
+
+void
+nsFrameIterator::First()
+{
+  mCurrent = mStart;
+}
+
+static bool
+IsRootFrame(nsIFrame* aFrame)
+{
+  nsIAtom* atom = aFrame->GetType();
+  return (atom == nsGkAtoms::canvasFrame) ||
+         (atom == nsGkAtoms::rootFrame);
+}
+
+void
+nsFrameIterator::Last()
+{
+  nsIFrame* result;
+  nsIFrame* parent = getCurrent();
+  // If the current frame is a popup, don't move farther up the tree.
+  // Otherwise, get the nearest root frame or popup.
+  if (parent->GetType() != nsGkAtoms::menuPopupFrame) {
+    while (!IsRootFrame(parent) && (result = GetParentFrameNotPopup(parent)))
+      parent = result;
+  }
+
+  while ((result = GetLastChild(parent))) {
+    parent = result;
+  }
+  
+  setCurrent(parent);
+  if (!parent)
+    setOffEdge(1);
+}
+
+void
+nsFrameIterator::Next()
+{
+  // recursive-oid method to get next frame
+  nsIFrame *result = nullptr;
+  nsIFrame *parent = getCurrent();
+  if (!parent)
+    parent = getLast();
+
+  if (mType == eLeaf) {
+    // Drill down to first leaf
+    while ((result = GetFirstChild(parent))) {
+      parent = result;
+    }
+  } else if (mType == ePreOrder) {
+    result = GetFirstChild(parent);
+    if (result)
+      parent = result;
+  }
+
+  if (parent != getCurrent()) {
+    result = parent;
+  } else {
+    while (parent) {
+      result = GetNextSibling(parent);
+      if (result) {
+        if (mType != ePreOrder) {
+          parent = result;
+          while ((result = GetFirstChild(parent))) {
+            parent = result;
+          }
+          result = parent;
+        }
+        break;
+      }
+      else {
+        result = GetParentFrameNotPopup(parent);
+        if (!result || IsRootFrame(result) ||
+            (mLockScroll && result->GetType() == nsGkAtoms::scrollFrame)) {
+          result = nullptr;
+          break;
+        }
+        if (mType == ePostOrder)
+          break;
+        parent = result;
+      }
+    }
+  }
+
+  setCurrent(result);
+  if (!result) {
+    setOffEdge(1);
+    setLast(parent);
+  }
+}
+
+void
+nsFrameIterator::Prev()
+{
+  // recursive-oid method to get prev frame
+  nsIFrame *result = nullptr;
+  nsIFrame *parent = getCurrent();
+  if (!parent)
+    parent = getLast();
+
+  if (mType == eLeaf) {
+    // Drill down to last leaf
+    while ((result = GetLastChild(parent))) {
+      parent = result;
+    }
+  } else if (mType == ePostOrder) {
+    result = GetLastChild(parent);
+    if (result)
+      parent = result;
+  }
+  
+  if (parent != getCurrent()) {
+    result = parent;
+  } else {
+    while (parent) {
+      result = GetPrevSibling(parent);
+      if (result) {
+        if (mType != ePostOrder) {
+          parent = result;
+          while ((result = GetLastChild(parent))) {
+            parent = result;
+          }
+          result = parent;
+        }
+        break;
+      } else {
+        result = GetParentFrameNotPopup(parent);
+        if (!result || IsRootFrame(result) ||
+            (mLockScroll && result->GetType() == nsGkAtoms::scrollFrame)) {
+          result = nullptr;
+          break;
+        }
+        if (mType == ePreOrder)
+          break;
+        parent = result;
+      }
+    }
+  }
+
+  setCurrent(result);
+  if (!result) {
+    setOffEdge(-1);
+    setLast(parent);
+  }
+}
+
+nsIFrame*
+nsFrameIterator::GetParentFrame(nsIFrame* aFrame)
+{
+  if (mFollowOOFs)
+    aFrame = GetPlaceholderFrame(aFrame);
+  if (aFrame)
+    return aFrame->GetParent();
+  
+  return nullptr;
+}
+
+nsIFrame*
+nsFrameIterator::GetParentFrameNotPopup(nsIFrame* aFrame)
+{
+  if (mFollowOOFs)
+    aFrame = GetPlaceholderFrame(aFrame);
+  if (aFrame) {
+    nsIFrame* parent = aFrame->GetParent();
+    if (!IsPopupFrame(parent))
+      return parent;
+  }
+    
+  return nullptr;
+}
+
+nsIFrame*
+nsFrameIterator::GetFirstChild(nsIFrame* aFrame)
+{
+  nsIFrame* result = GetFirstChildInner(aFrame);
+  if (mLockScroll && result && result->GetType() == nsGkAtoms::scrollFrame)
+    return nullptr;
+  if (result && mFollowOOFs) {
+    result = nsPlaceholderFrame::GetRealFrameFor(result);
+    
+    if (IsPopupFrame(result))
+      result = GetNextSibling(result);
+  }
+  return result;
+}
+
+nsIFrame*
+nsFrameIterator::GetLastChild(nsIFrame* aFrame)
+{
+  nsIFrame* result = GetLastChildInner(aFrame);
+  if (mLockScroll && result && result->GetType() == nsGkAtoms::scrollFrame)
+    return nullptr;
+  if (result && mFollowOOFs) {
+    result = nsPlaceholderFrame::GetRealFrameFor(result);
+    
+    if (IsPopupFrame(result))
+      result = GetPrevSibling(result);
+  }
+  return result;
+}
+
+nsIFrame*
+nsFrameIterator::GetNextSibling(nsIFrame* aFrame)
+{
+  nsIFrame* result = nullptr;
+  if (mFollowOOFs)
+    aFrame = GetPlaceholderFrame(aFrame);
+  if (aFrame) {
+    result = GetNextSiblingInner(aFrame);
+    if (result && mFollowOOFs)
+      result = nsPlaceholderFrame::GetRealFrameFor(result);
+  }
+
+  if (mFollowOOFs && IsPopupFrame(result))
+    result = GetNextSibling(result);
+
+  return result;
+}
+
+nsIFrame*
+nsFrameIterator::GetPrevSibling(nsIFrame* aFrame)
+{
+  nsIFrame* result = nullptr;
+  if (mFollowOOFs)
+    aFrame = GetPlaceholderFrame(aFrame);
+  if (aFrame) {
+    result = GetPrevSiblingInner(aFrame);
+    if (result && mFollowOOFs)
+      result = nsPlaceholderFrame::GetRealFrameFor(result);
+  }
+
+  if (mFollowOOFs && IsPopupFrame(result))
+    result = GetPrevSibling(result);
+
+  return result;
+}
+
+nsIFrame*
+nsFrameIterator::GetFirstChildInner(nsIFrame* aFrame) {
+  return aFrame->GetFirstPrincipalChild();
+}
+
+nsIFrame*
+nsFrameIterator::GetLastChildInner(nsIFrame* aFrame) {
+  return aFrame->PrincipalChildList().LastChild();
+}
+
+nsIFrame*
+nsFrameIterator::GetNextSiblingInner(nsIFrame* aFrame) {
+  return aFrame->GetNextSibling();
+}
+
+nsIFrame*
+nsFrameIterator::GetPrevSiblingInner(nsIFrame* aFrame) {
+  return aFrame->GetPrevSibling();
+}
+
+
+nsIFrame*
+nsFrameIterator::GetPlaceholderFrame(nsIFrame* aFrame)
+{
+  nsIFrame* result = aFrame;
+  nsIPresShell *presShell = mPresContext->GetPresShell();
+  if (presShell) {
+    nsIFrame* placeholder = presShell->GetPlaceholderFrameFor(aFrame);
+    if (placeholder)
+      result = placeholder;
+  }
+
+  if (result != aFrame)
+    result = GetPlaceholderFrame(result);
+
+  return result;
+}
+
+bool
+nsFrameIterator::IsPopupFrame(nsIFrame* aFrame)
+{
+  return (aFrame &&
+          aFrame->GetStyleDisplay()->mDisplay == NS_STYLE_DISPLAY_POPUP);
+}
+
+// nsVisualIterator implementation
+
+nsIFrame*
+nsVisualIterator::GetFirstChildInner(nsIFrame* aFrame) {
+  return aFrame->PrincipalChildList().GetNextVisualFor(nullptr);
+}
+
+nsIFrame*
+nsVisualIterator::GetLastChildInner(nsIFrame* aFrame) {
+  return aFrame->PrincipalChildList().GetPrevVisualFor(nullptr);
+}
+
+nsIFrame*
+nsVisualIterator::GetNextSiblingInner(nsIFrame* aFrame) {
+  nsIFrame* parent = GetParentFrame(aFrame);
+  if (!parent)
+    return nullptr;
+  return parent->PrincipalChildList().GetNextVisualFor(aFrame);
+}
+
+nsIFrame*
+nsVisualIterator::GetPrevSiblingInner(nsIFrame* aFrame) {
+  nsIFrame* parent = GetParentFrame(aFrame);
+  if (!parent)
+    return nullptr;
+  return parent->PrincipalChildList().GetPrevVisualFor(aFrame);
+}
new file mode 100644
--- /dev/null
+++ b/layout/base/nsFrameTraversal.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#ifndef NSFRAMETRAVERSAL_H
+#define NSFRAMETRAVERSAL_H
+
+#include "nsIFrame.h"
+#include "nsIFrameTraversal.h"
+
+nsresult NS_NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
+                              nsPresContext* aPresContext,
+                              nsIFrame *aStart,
+                              nsIteratorType aType,
+                              bool aVisual,
+                              bool aLockInScrollView,
+                              bool aFollowOOFs);
+
+nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
+
+class nsFrameTraversal : public nsIFrameTraversal
+{
+public:
+  nsFrameTraversal();
+  virtual ~nsFrameTraversal();
+
+  NS_DECL_ISUPPORTS
+
+  NS_IMETHOD NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
+                               nsPresContext* aPresContext,
+                               nsIFrame *aStart,
+                               PRInt32 aType,
+                               bool aVisual,
+                               bool aLockInScrollView,
+                               bool aFollowOOFs);
+};
+
+#endif //NSFRAMETRAVERSAL_H
new file mode 100644
--- /dev/null
+++ b/layout/base/nsIFrameTraversal.h
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#ifndef NSIFRAMETRAVERSAL_H
+#define NSIFRAMETRAVERSAL_H
+
+#include "nsISupports.h"
+#include "nsIFrame.h"
+
+#define NS_IFRAMEENUMERATOR_IID \
+{ 0x7c633f5d, 0x91eb, 0x494e, \
+  { 0xa1, 0x40, 0x17, 0x46, 0x17, 0x4c, 0x23, 0xd3 } }
+
+class nsIFrameEnumerator : public nsISupports
+{
+public:
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMEENUMERATOR_IID)
+
+  virtual void First() = 0;
+  virtual void Next() = 0;
+  virtual nsIFrame* CurrentItem() = 0;
+  virtual bool IsDone() = 0;
+
+  virtual void Last() = 0;
+  virtual void Prev() = 0;
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(nsIFrameEnumerator, NS_IFRAMEENUMERATOR_IID)
+
+enum nsIteratorType {
+  eLeaf,
+  ePreOrder,
+  ePostOrder
+};
+
+// {9d469828-9bf2-4151-a385-05f30219221b}
+#define NS_IFRAMETRAVERSAL_IID \
+{ 0x9d469828, 0x9bf2, 0x4151, { 0xa3, 0x85, 0x05, 0xf3, 0x02, 0x19, 0x22, 0x1b } }
+
+class nsIFrameTraversal : public nsISupports
+{
+public:
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMETRAVERSAL_IID)
+
+  /**
+   * Create a frame iterator with the specified properties.
+   * @param aEnumerator [out] the created iterator
+   * @param aPresContext [in]
+   * @param aStart [in] the frame to start iterating from
+   * @param aType [in] the type of the iterator: leaf, pre-order, or post-order
+   * @param aVisual [in] whether the iterator should traverse frames in visual
+   *        bidi order
+   * @param aLockInScrollView [in] whether to stop iterating when exiting a
+   *        scroll view
+   * @param aFollowOOFs [in] whether the iterator should follow out-of-flows.
+   *        If true, when reaching a placeholder frame while going down will get
+   *        the real frame. Going back up will go on past the placeholder,
+   *        so the placeholders are logically part of the frame tree.
+   */
+  NS_IMETHOD NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
+                               nsPresContext* aPresContext,
+                               nsIFrame *aStart,
+                               PRInt32 aType,
+                               bool aVisual,
+                               bool aLockInScrollView,
+                               bool aFollowOOFs) = 0;
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(nsIFrameTraversal, NS_IFRAMETRAVERSAL_IID)
+
+#endif //NSIFRAMETRAVERSAL_H
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -3743,17 +3743,17 @@ PresShell::FlushPendingNotifications(moz
     "Content",
     "ContentAndNotify",
     "Style",
     "InterruptibleLayout",
     "Layout",
     "Display"
   };
   // Make sure that we don't miss things added to mozFlushType!
-  MOZ_ASSERT(aType <= ArrayLength(flushTypeNames));
+  MOZ_ASSERT(static_cast<uint32_t>(aType) <= ArrayLength(flushTypeNames));
 
   SAMPLE_LABEL_PRINTF("layout", "Flush", "(Flush_%s)",
                       flushTypeNames[aType - 1]);
 #endif
 
 #ifdef ACCESSIBILITY
 #ifdef DEBUG
   nsAccessibilityService* accService = GetAccService();
--- a/layout/build/nsLayoutCID.h
+++ b/layout/build/nsLayoutCID.h
@@ -1,16 +1,20 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsLayoutCID_h__
 #define nsLayoutCID_h__
 
+// {1691E1F4-EE41-11d4-9885-00C04FA0CF4B}
+#define NS_FRAMETRAVERSAL_CID \
+{ 0x1691e1f4, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
+
 /* a6cf90f9-15b3-11d2-932e-00805f8add32 */
 #define NS_LAYOUT_DEBUGGER_CID \
  { 0xa6cf90f9, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
 
 /* a6cf90d7-15b3-11d2-932e-00805f8add32 */
 #define NS_FRAME_UTIL_CID \
  { 0xa6cf90d5, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
 
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -40,16 +40,17 @@
 #include "nsCaret.h"
 #include "nsPlainTextSerializer.h"
 #include "nsXMLContentSerializer.h"
 #include "nsXHTMLContentSerializer.h"
 #include "nsRuleNode.h"
 #include "nsContentAreaDragDrop.h"
 #include "nsContentList.h"
 #include "nsBox.h"
+#include "nsIFrameTraversal.h"
 #include "nsLayoutCID.h"
 #include "nsStyleSheetService.h"
 #include "nsFocusManager.h"
 #include "ThirdPartyUtil.h"
 #include "mozilla/Services.h"
 #include "nsStructuredCloneContainer.h"
 #include "mozilla/Attributes.h"
 
@@ -439,16 +440,18 @@ nsresult NS_NewMenuBoxObject(nsIBoxObjec
 nsresult NS_NewPopupBoxObject(nsIBoxObject** aResult);
 nsresult NS_NewContainerBoxObject(nsIBoxObject** aResult);
 nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult);
 #endif
 
 nsresult NS_NewCanvasRenderingContext2D(nsIDOMCanvasRenderingContext2D** aResult);
 nsresult NS_NewCanvasRenderingContextWebGL(nsIDOMWebGLRenderingContext** aResult);
 
+nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
+
 nsresult NS_NewDomSelection(nsISelection** aResult);
 nsresult NS_NewContentViewer(nsIContentViewer** aResult);
 nsresult NS_NewGenRegularIterator(nsIContentIterator** aResult);
 nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult);
 nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
 nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult);
 nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult);
 nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
@@ -493,16 +496,17 @@ ctor_(nsISupports* aOuter, REFNSIID aIID
   return NS_OK;                                           \
 }
 
 #ifdef DEBUG
 MAKE_CTOR(CreateNewFrameUtil,             nsIFrameUtil,                NS_NewFrameUtil)
 MAKE_CTOR(CreateNewLayoutDebugger,        nsILayoutDebugger,           NS_NewLayoutDebugger)
 #endif
 
+MAKE_CTOR(CreateNewFrameTraversal,      nsIFrameTraversal,      NS_CreateFrameTraversal)
 MAKE_CTOR(CreateNewPresShell,           nsIPresShell,           NS_NewPresShell)
 MAKE_CTOR(CreateNewBoxObject,           nsIBoxObject,           NS_NewBoxObject)
 
 #ifdef MOZ_XUL
 MAKE_CTOR(CreateNewListBoxObject,       nsIBoxObject,           NS_NewListBoxObject)
 MAKE_CTOR(CreateNewMenuBoxObject,       nsIBoxObject,           NS_NewMenuBoxObject)
 MAKE_CTOR(CreateNewPopupBoxObject,      nsIBoxObject,           NS_NewPopupBoxObject)
 MAKE_CTOR(CreateNewScrollBoxObject,     nsIBoxObject,           NS_NewScrollBoxObject)
@@ -687,16 +691,17 @@ Construct_nsIScriptSecurityManager(nsISu
         return NS_ERROR_FAILURE;
     return NS_OK;
 }
 
 #ifdef DEBUG
 NS_DEFINE_NAMED_CID(NS_FRAME_UTIL_CID);
 NS_DEFINE_NAMED_CID(NS_LAYOUT_DEBUGGER_CID);
 #endif
+NS_DEFINE_NAMED_CID(NS_FRAMETRAVERSAL_CID);
 NS_DEFINE_NAMED_CID(NS_PRESSHELL_CID);
 NS_DEFINE_NAMED_CID(NS_BOXOBJECT_CID);
 #ifdef MOZ_XUL
 NS_DEFINE_NAMED_CID(NS_LISTBOXOBJECT_CID);
 NS_DEFINE_NAMED_CID(NS_MENUBOXOBJECT_CID);
 NS_DEFINE_NAMED_CID(NS_POPUPBOXOBJECT_CID);
 NS_DEFINE_NAMED_CID(NS_CONTAINERBOXOBJECT_CID);
 NS_DEFINE_NAMED_CID(NS_SCROLLBOXOBJECT_CID);
@@ -972,16 +977,17 @@ nsEditingCommandTableConstructor(nsISupp
 
 
 static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
   XPCONNECT_CIDENTRIES
 #ifdef DEBUG
   { &kNS_FRAME_UTIL_CID, false, NULL, CreateNewFrameUtil },
   { &kNS_LAYOUT_DEBUGGER_CID, false, NULL, CreateNewLayoutDebugger },
 #endif
+  { &kNS_FRAMETRAVERSAL_CID, false, NULL, CreateNewFrameTraversal },
   { &kNS_PRESSHELL_CID, false, NULL, CreateNewPresShell },
   { &kNS_BOXOBJECT_CID, false, NULL, CreateNewBoxObject },
 #ifdef MOZ_XUL
   { &kNS_LISTBOXOBJECT_CID, false, NULL, CreateNewListBoxObject },
   { &kNS_MENUBOXOBJECT_CID, false, NULL, CreateNewMenuBoxObject },
   { &kNS_POPUPBOXOBJECT_CID, false, NULL, CreateNewPopupBoxObject },
   { &kNS_CONTAINERBOXOBJECT_CID, false, NULL, CreateNewContainerBoxObject },
   { &kNS_SCROLLBOXOBJECT_CID, false, NULL, CreateNewScrollBoxObject },
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -44,17 +44,17 @@
 #include "nsISelectionPrivate.h"
 #include "nsFrameSelection.h"
 #include "nsHTMLParts.h"
 #include "nsGkAtoms.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCSSFrameConstructor.h"
 
-#include "nsFrameIterator.h"
+#include "nsFrameTraversal.h"
 #include "nsStyleChangeList.h"
 #include "nsIDOMRange.h"
 #include "nsRange.h"
 #include "nsITableLayout.h"    //selection necessity
 #include "nsITableCellLayout.h"//  "
 #include "nsITextControlFrame.h"
 #include "nsINameSpaceManager.h"
 #include "nsIPercentHeightObserver.h"
@@ -5806,36 +5806,41 @@ nsFrame::GetNextPrevLineFromeBlockFrame(
       if (newIt)
       {
         aPos->mResultFrame = resultFrame;
         return NS_OK;
       }
       //resultFrame is not a block frame
       result = NS_ERROR_FAILURE;
 
-      uint32_t flags = nsFrameIterator::FLAG_NONE;
-      if (aPos->mScrollViewStop) {
-        flags |= nsFrameIterator::FLAG_LOCK_SCROLL;
-      }
-      nsFrameIterator frameTraversal(aPresContext, resultFrame,
-                                     ePostOrder, flags);
+      nsCOMPtr<nsIFrameEnumerator> frameTraversal;
+      result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
+                                    aPresContext, resultFrame,
+                                    ePostOrder,
+                                    false, // aVisual
+                                    aPos->mScrollViewStop,
+                                    false     // aFollowOOFs
+                                    );
+      if (NS_FAILED(result))
+        return result;
+
       nsIFrame *storeOldResultFrame = resultFrame;
       while ( !found ){
         nsPoint point;
         point.x = aPos->mDesiredX;
 
         nsRect tempRect = resultFrame->GetRect();
         nsPoint offset;
         nsIView * view; //used for call of get offset from view
         result = resultFrame->GetOffsetFromView(offset, &view);
         if (NS_FAILED(result))
           return result;
         point.y = tempRect.height + offset.y;
 
-        //special check. if we allow non-text selection then we can allow a hit location to fall before a table. 
+        //special check. if we allow non-text selection then we can allow a hit location to fall before a table.
         //otherwise there is no way to get and click signal to fall before a table (it being a line iterator itself)
         nsIPresShell *shell = aPresContext->GetPresShell();
         if (!shell)
           return NS_ERROR_FAILURE;
         int16_t isEditor = shell->GetSelectionFlags();
         isEditor = isEditor == nsISelectionDisplay::DISPLAY_ALL;
         if ( isEditor )
         {
@@ -5888,31 +5893,32 @@ nsFrame::GetNextPrevLineFromeBlockFrame(
           }
         }
 
         if (aPos->mDirection == eDirPrevious && (resultFrame == farStoppingFrame))
           break;
         if (aPos->mDirection == eDirNext && (resultFrame == nearStoppingFrame))
           break;
         //always try previous on THAT line if that fails go the other way
-        frameTraversal.Prev();
-        resultFrame = frameTraversal.CurrentItem();
+        frameTraversal->Prev();
+        resultFrame = frameTraversal->CurrentItem();
         if (!resultFrame)
           return NS_ERROR_FAILURE;
       }
 
       if (!found){
         resultFrame = storeOldResultFrame;
 
-        uint32_t flags = nsFrameIterator::FLAG_NONE;
-        if (aPos->mScrollViewStop) {
-          flags |= nsFrameIterator::FLAG_LOCK_SCROLL;
-        }
-        frameTraversal = nsFrameIterator(aPresContext, resultFrame,
-                                         eLeaf, flags);
+        result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
+                                      aPresContext, resultFrame,
+                                      eLeaf,
+                                      false, // aVisual
+                                      aPos->mScrollViewStop,
+                                      false     // aFollowOOFs
+                                      );
       }
       while ( !found ){
         nsPoint point(aPos->mDesiredX, 0);
         nsIView* view;
         nsPoint offset;
         resultFrame->GetOffsetFromView(offset, &view);
         ContentOffsets offsets =
             resultFrame->GetContentOffsetsFromPoint(point - offset);
@@ -5933,18 +5939,18 @@ nsFrame::GetNextPrevLineFromeBlockFrame(
             break;
           }
         }
         if (aPos->mDirection == eDirPrevious && (resultFrame == nearStoppingFrame))
           break;
         if (aPos->mDirection == eDirNext && (resultFrame == farStoppingFrame))
           break;
         //previous didnt work now we try "next"
-        frameTraversal.Next();
-        nsIFrame *tempFrame = frameTraversal.CurrentItem();
+        frameTraversal->Next();
+        nsIFrame *tempFrame = frameTraversal->CurrentItem();
         if (!tempFrame)
           break;
         resultFrame = tempFrame;
       }
       aPos->mResultFrame = resultFrame;
     }
     else {
         //we need to jump to new block frame.
@@ -6658,32 +6664,33 @@ nsIFrame::GetFrameFromDirection(nsDirect
     }
 
     if (atLineEdge) {
       *aOutJumpedLine = true;
       if (!aJumpLines)
         return NS_ERROR_FAILURE; //we are done. cannot jump lines
     }
 
-    uint32_t flags = nsFrameIterator::FLAG_FOLLOW_OUT_OF_FLOW;
-    if (aScrollViewStop) {
-      flags |= nsFrameIterator::FLAG_LOCK_SCROLL;
-    }
-    if (aVisual && presContext->BidiEnabled()) {
-      flags |= nsFrameIterator::FLAG_VISUAL;
-    }
-    nsFrameIterator frameTraversal(presContext, traversedFrame,
-                                   eLeaf, flags);
+    nsCOMPtr<nsIFrameEnumerator> frameTraversal;
+    result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
+                                  presContext, traversedFrame,
+                                  eLeaf,
+                                  aVisual && presContext->BidiEnabled(),
+                                  aScrollViewStop,
+                                  true     // aFollowOOFs
+                                  );
+    if (NS_FAILED(result))
+      return result;
 
     if (aDirection == eDirNext)
-      frameTraversal.Next();
+      frameTraversal->Next();
     else
-      frameTraversal.Prev();
-
-    traversedFrame = frameTraversal.CurrentItem();
+      frameTraversal->Prev();
+
+    traversedFrame = frameTraversal->CurrentItem();
     if (!traversedFrame)
       return NS_ERROR_FAILURE;
     traversedFrame->IsSelectable(&selectable, nullptr);
   } // while (!selectable)
 
   *aOutOffset = (aDirection == eDirNext) ? 0 : -1;
 
 #ifdef IBMBIDI
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -35,22 +35,24 @@
 #include "nsTArray.h"
 #include "nsIScrollableFrame.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsIContentIterator.h"
 #include "nsIDocumentEncoder.h"
 #include "nsTextFragment.h"
 
 // for IBMBIDI
-#include "nsFrameIterator.h"
+#include "nsFrameTraversal.h"
 #include "nsILineIterator.h"
 #include "nsGkAtoms.h"
+#include "nsIFrameTraversal.h"
 #include "nsLayoutUtils.h"
 #include "nsLayoutCID.h"
 #include "nsBidiPresUtils.h"
+static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
 #include "nsTextFrame.h"
 
 #include "nsIDOMText.h"
 
 #include "nsContentUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsDOMClassInfoID.h"
@@ -1240,27 +1242,40 @@ nsFrameSelection::GetFrameFromLevel(nsIF
                                     nsDirection  aDirection,
                                     uint8_t      aBidiLevel,
                                     nsIFrame   **aFrameOut) const
 {
   NS_ENSURE_STATE(mShell);
   uint8_t foundLevel = 0;
   nsIFrame *foundFrame = aFrameIn;
 
-  nsFrameIterator frameTraversal(mShell->GetPresContext(), aFrameIn,
-                                 eLeaf, nsFrameIterator::FLAG_NONE);
+  nsCOMPtr<nsIFrameEnumerator> frameTraversal;
+  nsresult result;
+  nsCOMPtr<nsIFrameTraversal> trav(do_CreateInstance(kFrameTraversalCID,&result));
+  if (NS_FAILED(result))
+      return result;
+
+  result = trav->NewFrameTraversal(getter_AddRefs(frameTraversal),
+                                   mShell->GetPresContext(), aFrameIn,
+                                   eLeaf,
+                                   false, // aVisual
+                                   false, // aLockInScrollView
+                                   false     // aFollowOOFs
+                                   );
+  if (NS_FAILED(result))
+    return result;
 
   do {
     *aFrameOut = foundFrame;
     if (aDirection == eDirNext)
-      frameTraversal.Next();
+      frameTraversal->Next();
     else
-      frameTraversal.Prev();
-
-    foundFrame = frameTraversal.CurrentItem();
+      frameTraversal->Prev();
+
+    foundFrame = frameTraversal->CurrentItem();
     if (!foundFrame)
       return NS_ERROR_FAILURE;
     foundLevel = NS_GET_EMBEDDING_LEVEL(foundFrame);
 
   } while (foundLevel > aBidiLevel);
 
   return NS_OK;
 }
--- a/layout/ipc/Makefile.in
+++ b/layout/ipc/Makefile.in
@@ -9,16 +9,17 @@ VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = layout
 LIBRARY_NAME = gkipc_s
 LIBXUL_LIBRARY = 1
 FORCE_STATIC_LIB = 1
 EXPORT_LIBRARY = 1
+FAIL_ON_WARNINGS = 1
 
 EXPORTS_NAMESPACES = mozilla/layout
 
 EXPORTS_mozilla/layout = \
   RenderFrameChild.h \
   RenderFrameParent.h \
   RenderFrameUtils.h \
   $(NULL)
--- a/layout/tools/layout-debug/src/Makefile.in
+++ b/layout/tools/layout-debug/src/Makefile.in
@@ -12,16 +12,17 @@ include $(DEPTH)/config/autoconf.mk
 
 MODULE		= layout_debug
 LIBRARY_NAME	= gkdebug
 EXPORT_LIBRARY	= 1
 IS_COMPONENT	= 1
 MODULE_NAME	= nsLayoutDebugModule
 LIBXUL_LIBRARY	= 1
 GRE_MODULE	= 1
+FAIL_ON_WARNINGS = 1
 
 
 XPIDLSRCS	= \
 		nsILayoutRegressionTester.idl \
 		nsILayoutDebuggingTools.idl \
 		$(NULL)
 
 EXPORTS		= \
--- a/layout/xul/base/src/grid/Makefile.in
+++ b/layout/xul/base/src/grid/Makefile.in
@@ -8,16 +8,17 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= layout
 LIBRARY_NAME	= gkxulgrid_s
 LIBXUL_LIBRARY  = 1
+FAIL_ON_WARNINGS = 1
 
 CPPSRCS	= \
         nsGridLayout2.cpp \
         nsGridRowLayout.cpp \
         nsGridRowLeafLayout.cpp \
         nsGridRowLeafFrame.cpp \
         nsGridRowGroupLayout.cpp \
         nsGridRowGroupFrame.cpp \
--- a/layout/xul/base/src/tree/src/Makefile.in
+++ b/layout/xul/base/src/tree/src/Makefile.in
@@ -8,16 +8,17 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= layout
 LIBRARY_NAME	= gkxultree_s
 LIBXUL_LIBRARY  = 1
+FAIL_ON_WARNINGS = 1
 
 CPPSRCS		= \
 		nsTreeBodyFrame.cpp \
 		nsTreeBoxObject.cpp \
 		nsTreeColFrame.cpp \
 		nsTreeColumns.cpp \
 		nsTreeContentView.cpp \
 		nsTreeImageListener.cpp \
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
@@ -20,17 +20,17 @@
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsString.h"
 #include "nsCRT.h"
 
 #include "nsIDOMNode.h"
 #include "mozilla/dom/Element.h"
 #include "nsIFrame.h"
-#include "nsFrameIterator.h"
+#include "nsFrameTraversal.h"
 #include "nsIImageDocument.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDocument.h"
 #include "nsISelection.h"
 #include "nsILink.h"
 #include "nsTextFragment.h"
 #include "nsIDOMNSEditableElement.h"
@@ -58,16 +58,18 @@ NS_INTERFACE_MAP_BEGIN(nsTypeAheadFind)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITypeAheadFind)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(nsTypeAheadFind)
 NS_IMPL_RELEASE(nsTypeAheadFind)
 
+static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
+
 #define NS_FIND_CONTRACTID "@mozilla.org/embedcomp/rangefind;1"
 
 nsTypeAheadFind::nsTypeAheadFind():
   mStartLinksOnlyPref(false),
   mCaretBrowsingOn(false),
   mLastFindLength(0),
   mIsSoundInitialized(false),
   mCaseSensitive(false)
@@ -1107,22 +1109,33 @@ nsTypeAheadFind::IsRangeVisible(nsIPresS
     if (rectVisibility != nsRectVisibility_kAboveViewport) {
       return true;
     }
   }
 
   // We know that the target range isn't usable because it's not in the
   // view port. Move range forward to first visible point,
   // this speeds us up a lot in long documents
-  nsFrameIterator frameTraversal(aPresContext, frame,
-                                 eLeaf, nsFrameIterator::FLAG_NONE);
+  nsCOMPtr<nsIFrameEnumerator> frameTraversal;
+  nsCOMPtr<nsIFrameTraversal> trav(do_CreateInstance(kFrameTraversalCID));
+  if (trav)
+    trav->NewFrameTraversal(getter_AddRefs(frameTraversal),
+                            aPresContext, frame,
+                            eLeaf,
+                            false, // aVisual
+                            false, // aLockInScrollView
+                            false     // aFollowOOFs
+                            );
+
+  if (!frameTraversal)
+    return false;
 
   while (rectVisibility == nsRectVisibility_kAboveViewport) {
-    frameTraversal.Next();
-    frame = frameTraversal.CurrentItem();
+    frameTraversal->Next();
+    frame = frameTraversal->CurrentItem();
     if (!frame)
       return false;
 
     if (!frame->GetRect().IsEmpty()) {
       rectVisibility =
         aPresShell->GetRectVisibility(frame,
                                       nsRect(nsPoint(0,0), frame->GetSize()),
                                       minDistance);