From 9fb446699fa79791f47aeb6af18217fc1993b127 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Sun, 26 Jun 2016 12:25:11 -0500 Subject: [PATCH] Bug 1278455. If the root element is grid or flex, allow it to be an absolute containing block. r=dholbert If the root element is block or table then the PushAbsoluteContainingBlock call happens in ConstructBlock and ConstructTable respectively. --- layout/base/crashtests/1278455-1.html | 11 +++++++++++ layout/base/crashtests/crashtests.list | 1 + layout/base/nsCSSFrameConstructor.cpp | 20 ++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 layout/base/crashtests/1278455-1.html diff --git a/layout/base/crashtests/1278455-1.html b/layout/base/crashtests/1278455-1.html new file mode 100644 index 000000000000..470fea730dab --- /dev/null +++ b/layout/base/crashtests/1278455-1.html @@ -0,0 +1,11 @@ + + + + + + +
Z
+ + diff --git a/layout/base/crashtests/crashtests.list b/layout/base/crashtests/crashtests.list index 5df4ebe2fc9a..6ceaaa94a03f 100644 --- a/layout/base/crashtests/crashtests.list +++ b/layout/base/crashtests/crashtests.list @@ -473,3 +473,4 @@ load 1234622-1.html load 1235467-1.html pref(dom.webcomponents.enabled,true) load 1261351.html load 1270797-1.html +load 1278455-1.html diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 06de7a5ac5e0..61b53d7b8107 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2496,14 +2496,14 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle // Make sure to start any background image loads for the root element now. styleContext->StartBackgroundImageLoads(); - nsFrameConstructorSaveState absoluteSaveState; + nsFrameConstructorSaveState docElementContainingBlockAbsoluteSaveState; if (mHasRootAbsPosContainingBlock) { // Push the absolute containing block now so we can absolutely position // the root element mDocElementContainingBlock->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN); state.PushAbsoluteContainingBlock(mDocElementContainingBlock, mDocElementContainingBlock, - absoluteSaveState); + docElementContainingBlockAbsoluteSaveState); } // The rules from CSS 2.1, section 9.2.4, have already been applied @@ -2520,6 +2520,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle nsIFrame* newFrame; bool processChildren = false; + nsFrameConstructorSaveState absoluteSaveState; + // Check whether we need to build a XUL box or SVG root frame #ifdef MOZ_XUL if (aDocElement->IsXULElement()) { @@ -2565,12 +2567,26 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle contentFrame); newFrame = contentFrame; processChildren = true; + + newFrame->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN); + if (display->IsAbsPosContainingBlock(newFrame)) { + state.PushAbsoluteContainingBlock(contentFrame, newFrame, + absoluteSaveState); + } + } else if (display->mDisplay == NS_STYLE_DISPLAY_GRID) { contentFrame = NS_NewGridContainerFrame(mPresShell, styleContext); InitAndRestoreFrame(state, aDocElement, mDocElementContainingBlock, contentFrame); newFrame = contentFrame; processChildren = true; + + newFrame->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN); + if (display->IsAbsPosContainingBlock(newFrame)) { + state.PushAbsoluteContainingBlock(contentFrame, newFrame, + absoluteSaveState); + } + } else if (display->mDisplay == NS_STYLE_DISPLAY_TABLE) { // We're going to call the right function ourselves, so no need to give a // function to this FrameConstructionData.