Backed out changeset 811c1368e51b (bug 1302470)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 17 Nov 2016 17:49:37 +0100
changeset 440804 c010db9d4302df3bb5002b9da43aeaea30e907ad
parent 440803 ce21333d6f8f9f681c9fa36845424b8b841eff32
child 440805 cb78abd0c2a7e65034ae32418f9922e7fc036fa2
push id36319
push userwcosta@mozilla.com
push dateFri, 18 Nov 2016 03:26:11 +0000
bugs1302470
milestone53.0a1
backs out811c1368e51ba421f27ec765c58b4e2151d26f30
Backed out changeset 811c1368e51b (bug 1302470)
toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
@@ -1177,105 +1177,63 @@ nsTypeAheadFind::IsRangeVisible(nsIDOMRa
   nsCOMPtr<nsIDOMRange> startPointRange = new nsRange(presShell->GetDocument());
   *aResult = IsRangeVisible(presShell, presContext, aRange, aFlushLayout,
                             getter_AddRefs(startPointRange),
                             nullptr);
   return NS_OK;
 }
 
 bool
-IsFrameVisibleInFrameStack(nsIFrame *aFrame,
-                           const nsTArray<nsIFrame*>& aOrderedFramesFrontToBack)
-{
-  // Visibility requires that aFrame appears in aOrderedFramesFrontToBack,
-  // and that overlaying frames are not entirely opaque. We stop evaluating
-  // once we reach aFrame, because we don't want frames underneath aFrame to
-  // affect the test.
-
-  // This definition is conservative; this function will return false in some
-  // cases where aFrame may actually be visible, including:
-  // a) aFrame is only partially covered by another frame.
-  // b) A frame covering aFrame is opaque but empty.
-
-  for (nsIFrame* f : aOrderedFramesFrontToBack) {
-    if (!f) {
-      continue;
-    }
-
-    if (f == aFrame) {
-      return true;
-    }
-
-    if (f->StyleEffects()->mOpacity < 1.0f) {
-      continue;
-    }
-
-    // Something fully opaque is at least partially obscuring aFrame, so
-    // aFrame is considered not visible.
-    return false;
-  }
-
-  // We didn't find aFrame, which means it wasn't visible.
-  return false;
-}
-
-bool
 nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
                                 nsPresContext *aPresContext,
                                 nsIDOMRange *aRange,
                                 bool aFlushLayout,
                                 nsIDOMRange **aFirstVisibleRange,
                                 bool *aUsesIndependentSelection)
 {
   NS_ASSERTION(aPresShell && aPresContext && aRange && aFirstVisibleRange, 
                "params are invalid");
 
-  // We need to know if the range start and end are both visible.
-  // In all cases, return the first visible range in aFirstVisibleRange.
+  // We need to know if the range start is visible.
+  // Otherwise, return the first visible range start 
+  // in aFirstVisibleRange
   aRange->CloneRange(aFirstVisibleRange);
 
   if (aFlushLayout) {
     aPresShell->FlushPendingNotifications(Flush_Layout);
   }
 
   nsCOMPtr<nsIDOMNode> node;
-  aRange->GetCommonAncestorContainer(getter_AddRefs(node));
+  aRange->GetStartContainer(getter_AddRefs(node));
 
   nsCOMPtr<nsIContent> content(do_QueryInterface(node));
-  if (!content) {
+  if (!content)
     return false;
-  }
 
   nsIFrame *frame = content->GetPrimaryFrame();
-  if (!frame) {
+  if (!frame)
     return false;  // No frame! Not visible then.
-  }
 
   // Having a primary frame doesn't mean that the range is visible inside the
   // viewport. Do a hit-test to determine that quickly and properly.
   AutoTArray<nsIFrame*,8> frames;
   nsIFrame *rootFrame = aPresShell->GetRootFrame();
   RefPtr<nsRange> range = static_cast<nsRange*>(aRange);
   RefPtr<mozilla::dom::DOMRectList> rects = range->GetClientRects(true, false);
   for (uint32_t i = 0; i < rects->Length(); ++i) {
     RefPtr<mozilla::dom::DOMRect> rect = rects->Item(i);
     nsRect r(nsPresContext::CSSPixelsToAppUnits((float)rect->X()),
              nsPresContext::CSSPixelsToAppUnits((float)rect->Y()),
              nsPresContext::CSSPixelsToAppUnits((float)rect->Width()),
              nsPresContext::CSSPixelsToAppUnits((float)rect->Height()));
     nsLayoutUtils::GetFramesForArea(rootFrame, r, frames,
       nsLayoutUtils::IGNORE_PAINT_SUPPRESSION | nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME);
   }
-  if (!frames.Length()) {
+  if (!frames.Length())
     return false;
-  }
-
-  if (!IsFrameVisibleInFrameStack(frame, frames)) {
-    return false;
-  }
 
   // Detect if we are _inside_ a text control, or something else with its own
   // selection controller.
   if (aUsesIndependentSelection) {
     *aUsesIndependentSelection = 
       (frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION);
   }