Bug 894716 - Parameterize nsLayoutUtils::GetNearestScrollableFrame. r=dbaron

This commit is contained in:
Corey Ford 2013-07-30 21:01:06 -07:00
parent 3d591629ad
commit df05870c1e
3 changed files with 26 additions and 23 deletions

View File

@ -1165,14 +1165,16 @@ nsLayoutUtils::GetNearestScrollableFrameForDirection(nsIFrame* aFrame,
// static
nsIScrollableFrame*
nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame)
nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame, uint32_t aFlags)
{
NS_ASSERTION(aFrame, "GetNearestScrollableFrame expects a non-null frame");
for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
for (nsIFrame* f = aFrame; f; f = (aFlags & SCROLLABLE_SAME_DOC) ?
f->GetParent() : nsLayoutUtils::GetCrossDocParentFrame(f)) {
nsIScrollableFrame* scrollableFrame = do_QueryFrame(f);
if (scrollableFrame) {
nsPresContext::ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
if (ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN ||
if ((aFlags & SCROLLABLE_INCLUDE_HIDDEN) ||
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN ||
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN)
return scrollableFrame;
}

View File

@ -378,16 +378,23 @@ public:
static nsIScrollableFrame* GetNearestScrollableFrameForDirection(nsIFrame* aFrame,
Direction aDirection);
enum {
SCROLLABLE_SAME_DOC = 0x01,
SCROLLABLE_INCLUDE_HIDDEN = 0x02
};
/**
* GetNearestScrollableFrame locates the first ancestor of aFrame
* (or aFrame itself) that is scrollable with overflow:scroll or
* overflow:auto in some direction.
* The search extends across document boundaries.
*
* @param aFrame the frame to start with
* @param aFlags if SCROLLABLE_SAME_DOC is set, do not search across
* document boundaries. If SCROLLABLE_INCLUDE_HIDDEN is set, include
* frames scrollable with overflow:hidden.
* @return the nearest scrollable frame or nullptr if not found
*/
static nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame);
static nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame,
uint32_t aFlags = 0);
/**
* GetScrolledRect returns the range of allowable scroll offsets

View File

@ -2554,15 +2554,14 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
// frame, or something else is already capturing the mouse, there's no
// reason to capture.
if (!nsIPresShell::GetCapturingContent()) {
nsIFrame* checkFrame = this;
nsIScrollableFrame *scrollFrame = nullptr;
while (checkFrame) {
scrollFrame = do_QueryFrame(checkFrame);
if (scrollFrame) {
nsIPresShell::SetCapturingContent(checkFrame->GetContent(), CAPTURE_IGNOREALLOWED);
break;
}
checkFrame = checkFrame->GetParent();
nsIScrollableFrame* scrollFrame =
nsLayoutUtils::GetNearestScrollableFrame(this,
nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
if (scrollFrame) {
nsIFrame* capturingFrame = do_QueryFrame(scrollFrame);
nsIPresShell::SetCapturingContent(capturingFrame->GetContent(),
CAPTURE_IGNOREALLOWED);
}
}
@ -2925,15 +2924,10 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext,
}
// get the nearest scrollframe
nsIFrame* checkFrame = this;
nsIScrollableFrame *scrollFrame = nullptr;
while (checkFrame) {
scrollFrame = do_QueryFrame(checkFrame);
if (scrollFrame) {
break;
}
checkFrame = checkFrame->GetParent();
}
nsIScrollableFrame* scrollFrame =
nsLayoutUtils::GetNearestScrollableFrame(this,
nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
if (scrollFrame) {
nsIFrame* capturingFrame = scrollFrame->GetScrolledFrame();