From 7b9ea72f65dda28822c5a9054dff850f8ced6944 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Fri, 21 Apr 2017 17:10:46 +0200 Subject: [PATCH] Backed out changeset 87ae43ab52ed (bug 1302470) --HG-- extra : rebase_source : 65f6245418155127ecc6ffc9c8347086db78cd4c --- .../typeaheadfind/nsITypeAheadFind.idl | 5 +- .../typeaheadfind/nsTypeAheadFind.cpp | 80 ------------------- .../typeaheadfind/nsTypeAheadFind.h | 6 +- 3 files changed, 3 insertions(+), 88 deletions(-) diff --git a/toolkit/components/typeaheadfind/nsITypeAheadFind.idl b/toolkit/components/typeaheadfind/nsITypeAheadFind.idl index 0d4c7f93e294..379d2c2a261e 100644 --- a/toolkit/components/typeaheadfind/nsITypeAheadFind.idl +++ b/toolkit/components/typeaheadfind/nsITypeAheadFind.idl @@ -57,12 +57,9 @@ interface nsITypeAheadFind : nsISupports * necessarily happen automatically. */ void collapseSelection(); - /* Check if a range is visible using heuristics */ + /* Check if a range is visible */ boolean isRangeVisible(in nsIDOMRange aRange, in boolean aMustBeInViewPort); - /* Check if a range is actually rendered (out of viewport always false) */ - boolean isRangeRendered(in nsIDOMRange aRange); - /******************************* Attributes ******************************/ readonly attribute AString searchString; diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp index 883d7628d42c..083feffc2ff0 100644 --- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp +++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp @@ -1308,86 +1308,6 @@ nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell, return false; } -NS_IMETHODIMP -nsTypeAheadFind::IsRangeRendered(nsIDOMRange *aRange, - bool *aResult) -{ - // Jump through hoops to extract the docShell from the range. - nsCOMPtr node; - aRange->GetStartContainer(getter_AddRefs(node)); - nsCOMPtr document; - node->GetOwnerDocument(getter_AddRefs(document)); - nsCOMPtr window; - document->GetDefaultView(getter_AddRefs(window)); - nsCOMPtr navNav (do_GetInterface(window)); - nsCOMPtr docShell (do_GetInterface(navNav)); - - // Set up the arguments needed to check if a range is visible. - nsCOMPtr presShell (docShell->GetPresShell()); - RefPtr presContext = presShell->GetPresContext(); - *aResult = IsRangeRendered(presShell, presContext, aRange); - return NS_OK; -} - -bool -nsTypeAheadFind::IsRangeRendered(nsIPresShell *aPresShell, - nsPresContext *aPresContext, - nsIDOMRange *aRange) -{ - NS_ASSERTION(aPresShell && aPresContext && aRange, - "params are invalid"); - - nsCOMPtr node; - aRange->GetCommonAncestorContainer(getter_AddRefs(node)); - - nsCOMPtr content(do_QueryInterface(node)); - if (!content) { - return false; - } - - nsIFrame *frame = content->GetPrimaryFrame(); - if (!frame) { - return false; // No frame! Not visible then. - } - - if (!frame->StyleVisibility()->IsVisible()) { - return false; - } - - // 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 frames; - nsIFrame *rootFrame = aPresShell->GetRootFrame(); - RefPtr range = static_cast(aRange); - RefPtr rects = range->GetClientRects(true, false); - for (uint32_t i = 0; i < rects->Length(); ++i) { - RefPtr 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())); - // Append visible frames to frames array. - nsLayoutUtils::GetFramesForArea(rootFrame, r, frames, - nsLayoutUtils::IGNORE_PAINT_SUPPRESSION | - nsLayoutUtils::IGNORE_ROOT_SCROLL_FRAME | - nsLayoutUtils::ONLY_VISIBLE); - - // See if any of the frames contain the content. If they do, then the range - // is visible. We search for the content rather than the original frame, - // because nsTextContinuation frames might be returned instead of the - // original frame. - for (const auto &f: frames) { - if (f->GetContent() == content) { - return true; - } - } - - frames.ClearAndRetainStorage(); - } - - return false; -} - already_AddRefed nsTypeAheadFind::GetPresShell() { diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.h b/toolkit/components/typeaheadfind/nsTypeAheadFind.h index d12fc3e38bd7..2caf0b69cc72 100644 --- a/toolkit/components/typeaheadfind/nsTypeAheadFind.h +++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.h @@ -48,10 +48,10 @@ protected: nsresult GetWebBrowserFind(nsIDocShell *aDocShell, nsIWebBrowserFind **aWebBrowserFind); - void RangeStartsInsideLink(nsIDOMRange *aRange, nsIPresShell *aPresShell, + void RangeStartsInsideLink(nsIDOMRange *aRange, nsIPresShell *aPresShell, bool *aIsInsideLink, bool *aIsStartingLink); - void GetSelection(nsIPresShell *aPresShell, nsISelectionController **aSelCon, + void GetSelection(nsIPresShell *aPresShell, nsISelectionController **aSelCon, nsISelection **aDomSel); // *aNewRange may not be collapsed. If you want to collapse it in a // particular way, you need to do it yourself. @@ -59,8 +59,6 @@ protected: nsIDOMRange *aRange, bool aMustBeVisible, bool aGetTopVisibleLeaf, nsIDOMRange **aNewRange, bool *aUsesIndependentSelection); - bool IsRangeRendered(nsIPresShell *aPresShell, nsPresContext *aPresContext, - nsIDOMRange *aRange); nsresult FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly, bool aIsFirstVisiblePreferred, bool aFindPrev, uint16_t* aResult);