Bug 914891 - Bail gracefully on sticky positioning with no scroll container. r=dholbert

This commit is contained in:
Corey Ford
2013-09-11 16:30:56 -07:00
parent 23cc8866f7
commit 1bceaf53a9
6 changed files with 35 additions and 12 deletions

View File

@@ -41,13 +41,17 @@ StickyScrollContainer::~StickyScrollContainer()
// static
StickyScrollContainer*
StickyScrollContainer::StickyScrollContainerForFrame(nsIFrame* aFrame)
StickyScrollContainer::GetStickyScrollContainerForFrame(nsIFrame* aFrame)
{
nsIScrollableFrame* scrollFrame =
nsLayoutUtils::GetNearestScrollableFrame(aFrame->GetParent(),
nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
NS_ASSERTION(scrollFrame, "Need a scrolling container");
if (!scrollFrame) {
// We might not find any, for instance in the case of
// <html style="position: fixed">
return nullptr;
}
FrameProperties props = static_cast<nsIFrame*>(do_QueryFrame(scrollFrame))->
Properties();
StickyScrollContainer* s = static_cast<StickyScrollContainer*>
@@ -90,8 +94,7 @@ StickyScrollContainer::ComputeStickyOffsets(nsIFrame* aFrame)
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
if (!scrollableFrame) {
// Not sure how this would happen, but bail if it does.
NS_ERROR("Couldn't find a scrollable frame");
// Bail.
return;
}