mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-20 08:51:04 +00:00
Backed out changeset bf86de479585 (bug 1790299) for causing failures in test_splitter.xhtml CLOSED TREE
This commit is contained in:
parent
8855a8d3ac
commit
d74b5dc67c
@ -31,7 +31,6 @@
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsFlexContainerFrame.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/MouseEvent.h"
|
||||
@ -228,6 +227,19 @@ void nsSplitterFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
||||
MOZ_ASSERT(!mInner);
|
||||
mInner = new nsSplitterFrameInner(this);
|
||||
|
||||
// determine orientation of parent, and if vertical, set orient to vertical
|
||||
// on splitter content, then re-resolve style
|
||||
// XXXbz this is pretty messed up, since this can change whether we should
|
||||
// have a frame at all. This really needs a better solution.
|
||||
if (aParent && aParent->IsXULBoxFrame()) {
|
||||
if (!aParent->IsXULHorizontal()) {
|
||||
if (!nsContentUtils::HasNonEmptyAttr(aContent, kNameSpaceID_None,
|
||||
nsGkAtoms::orient)) {
|
||||
aContent->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::orient,
|
||||
u"vertical"_ns, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
|
||||
|
||||
@ -236,20 +248,10 @@ void nsSplitterFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
||||
mInner->mParentBox = nullptr;
|
||||
}
|
||||
|
||||
static bool IsValidParentBox(nsIFrame* aFrame) {
|
||||
return aFrame->IsXULBoxFrame() || aFrame->IsFlexContainerFrame();
|
||||
}
|
||||
|
||||
static nsIFrame* GetValidParentBox(nsIFrame* aChild) {
|
||||
return aChild->GetParent() && IsValidParentBox(aChild->GetParent())
|
||||
? aChild->GetParent()
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSplitterFrame::DoXULLayout(nsBoxLayoutState& aState) {
|
||||
if (HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) {
|
||||
mInner->mParentBox = GetValidParentBox(this);
|
||||
mInner->mParentBox = nsIFrame::GetParentXULBox(this);
|
||||
mInner->UpdateState();
|
||||
}
|
||||
|
||||
@ -260,9 +262,8 @@ void nsSplitterFrame::GetInitialOrientation(bool& aIsHorizontal) {
|
||||
nsIFrame* box = nsIFrame::GetParentXULBox(this);
|
||||
if (box) {
|
||||
aIsHorizontal = !box->IsXULHorizontal();
|
||||
} else {
|
||||
} else
|
||||
nsBoxFrame::GetInitialOrientation(aIsHorizontal);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -508,7 +509,7 @@ nsresult nsSplitterFrameInner::MouseDown(Event* aMouseEvent) {
|
||||
nsGkAtoms::_true, eCaseMatters))
|
||||
return NS_OK;
|
||||
|
||||
mParentBox = GetValidParentBox(mOuter);
|
||||
mParentBox = nsIFrame::GetParentXULBox(mOuter);
|
||||
if (!mParentBox) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -559,6 +560,7 @@ nsresult nsSplitterFrameInner::MouseDown(Event* aMouseEvent) {
|
||||
count++;
|
||||
|
||||
nsIContent* content = childBox->GetContent();
|
||||
|
||||
if (auto* element = nsXULElement::FromNode(content)) {
|
||||
if (element->NodeInfo()->NameAtom() == nsGkAtoms::splitter) {
|
||||
// skip over any splitters
|
||||
@ -573,22 +575,17 @@ nsresult nsSplitterFrameInner::MouseDown(Event* aMouseEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
nsSize prefSize;
|
||||
nsSize minSize;
|
||||
nsSize maxSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
const nscoord flex = childBox->GetXULFlex();
|
||||
// TODO(emilio): Figure out if we need this for regular flexbox.
|
||||
if (childBox->IsXULBoxFrame()) {
|
||||
prefSize = childBox->GetXULPrefSize(state);
|
||||
minSize = childBox->GetXULMinSize(state);
|
||||
maxSize = nsIFrame::XULBoundsCheckMinMax(minSize,
|
||||
childBox->GetXULMaxSize(state));
|
||||
prefSize = nsIFrame::XULBoundsCheck(minSize, prefSize, maxSize);
|
||||
nsSize prefSize = childBox->GetXULPrefSize(state);
|
||||
nsSize minSize = childBox->GetXULMinSize(state);
|
||||
nsSize maxSize =
|
||||
nsIFrame::XULBoundsCheckMinMax(minSize, childBox->GetXULMaxSize(state));
|
||||
prefSize = nsIFrame::XULBoundsCheck(minSize, prefSize, maxSize);
|
||||
|
||||
nsSplitterFrame::AddXULMargin(childBox, minSize);
|
||||
nsSplitterFrame::AddXULMargin(childBox, prefSize);
|
||||
nsSplitterFrame::AddXULMargin(childBox, maxSize);
|
||||
}
|
||||
nsSplitterFrame::AddXULMargin(childBox, minSize);
|
||||
nsSplitterFrame::AddXULMargin(childBox, prefSize);
|
||||
nsSplitterFrame::AddXULMargin(childBox, maxSize);
|
||||
|
||||
nscoord flex = childBox->GetXULFlex();
|
||||
|
||||
nsMargin margin;
|
||||
childBox->GetXULMargin(margin);
|
||||
@ -627,21 +624,7 @@ nsresult nsSplitterFrameInner::MouseDown(Event* aMouseEvent) {
|
||||
|
||||
mPressed = true;
|
||||
|
||||
const bool reverseDirection = [&] {
|
||||
if (mParentBox->IsXULBoxFrame()) {
|
||||
return !mParentBox->IsXULNormalDirection();
|
||||
}
|
||||
MOZ_ASSERT(mParentBox->IsFlexContainerFrame());
|
||||
const FlexboxAxisInfo info(mParentBox);
|
||||
if (!info.mIsRowOriented) {
|
||||
return info.mIsMainAxisReversed;
|
||||
}
|
||||
const bool rtl =
|
||||
mParentBox->StyleVisibility()->mDirection == StyleDirection::Rtl;
|
||||
return info.mIsMainAxisReversed != rtl;
|
||||
}();
|
||||
|
||||
if (reverseDirection) {
|
||||
if (!mParentBox->IsXULNormalDirection()) {
|
||||
// The before array is really the after array, and the order needs to be
|
||||
// reversed. First reverse both arrays.
|
||||
Reverse(mChildInfosBefore, mChildInfosBeforeCount);
|
||||
@ -756,7 +739,7 @@ void nsSplitterFrameInner::UpdateState() {
|
||||
}
|
||||
|
||||
if ((SupportsCollapseDirection(Before) || SupportsCollapseDirection(After)) &&
|
||||
IsValidParentBox(mOuter->GetParent())) {
|
||||
mOuter->GetParent()->IsXULBoxFrame()) {
|
||||
// Find the splitter's immediate sibling.
|
||||
const bool prev = newState == CollapsedBefore || mState == CollapsedBefore;
|
||||
nsIFrame* splitterSibling =
|
||||
@ -786,16 +769,7 @@ void nsSplitterFrameInner::UpdateState() {
|
||||
}
|
||||
|
||||
void nsSplitterFrameInner::EnsureOrient() {
|
||||
// If our parent is horizontal, the splitter is vertical and vice-versa.
|
||||
const bool isHorizontal = [&] {
|
||||
if (mParentBox->IsXULBoxFrame()) {
|
||||
return !mParentBox->HasAnyStateBits(NS_STATE_IS_HORIZONTAL);
|
||||
}
|
||||
MOZ_ASSERT(mParentBox->IsFlexContainerFrame());
|
||||
const FlexboxAxisInfo info(mParentBox);
|
||||
return !info.mIsRowOriented;
|
||||
}();
|
||||
|
||||
bool isHorizontal = !mParentBox->HasAnyStateBits(NS_STATE_IS_HORIZONTAL);
|
||||
if (isHorizontal)
|
||||
mOuter->AddStateBits(NS_STATE_IS_HORIZONTAL);
|
||||
else
|
||||
@ -804,7 +778,7 @@ void nsSplitterFrameInner::EnsureOrient() {
|
||||
|
||||
void nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext) {
|
||||
EnsureOrient();
|
||||
const bool isHorizontal = !mOuter->IsXULHorizontal();
|
||||
bool isHorizontal = !mOuter->IsXULHorizontal();
|
||||
|
||||
AdjustChildren(aPresContext, mChildInfosBefore.get(), mChildInfosBeforeCount,
|
||||
isHorizontal);
|
||||
@ -814,11 +788,13 @@ void nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext) {
|
||||
|
||||
static nsIFrame* GetChildBoxForContent(nsIFrame* aParentBox,
|
||||
nsIContent* aContent) {
|
||||
// XXX Can this use GetPrimaryFrame?
|
||||
for (nsIFrame* f : aParentBox->PrincipalChildList()) {
|
||||
if (f->GetContent() == aContent) {
|
||||
return f;
|
||||
nsIFrame* childBox = nsIFrame::GetChildXULBox(aParentBox);
|
||||
|
||||
while (childBox) {
|
||||
if (childBox->GetContent() == aContent) {
|
||||
return childBox;
|
||||
}
|
||||
childBox = nsIFrame::GetNextXULBox(childBox);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -830,10 +806,19 @@ void nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext,
|
||||
|
||||
nsBoxLayoutState state(aPresContext);
|
||||
|
||||
// first set all the widths.
|
||||
nsIFrame* child = nsIFrame::GetChildXULBox(mOuter);
|
||||
while (child) {
|
||||
SetPreferredSize(state, child, aIsHorizontal, nullptr);
|
||||
child = nsIFrame::GetNextXULBox(child);
|
||||
}
|
||||
|
||||
// now set our changed widths.
|
||||
for (int i = 0; i < aCount; i++) {
|
||||
nscoord pref = aChildInfos[i].changed;
|
||||
nsIFrame* childBox =
|
||||
GetChildBoxForContent(mParentBox, aChildInfos[i].childElem);
|
||||
|
||||
if (childBox) {
|
||||
SetPreferredSize(state, childBox, aIsHorizontal, &pref);
|
||||
}
|
||||
|
@ -66,22 +66,8 @@ XUL <splitter> collapsing tests
|
||||
}
|
||||
|
||||
var splitter;
|
||||
var activeBox = null;
|
||||
function setActiveBox(element) {
|
||||
if (activeBox) {
|
||||
activeBox.style.display = "none";
|
||||
}
|
||||
if (element) {
|
||||
element.style.display = "";
|
||||
element.getBoundingClientRect();
|
||||
}
|
||||
activeBox = element;
|
||||
}
|
||||
|
||||
async function runTests(rtl, splitterId) {
|
||||
info(`Running tests for ${splitterId}`);
|
||||
splitter = document.getElementById(splitterId);
|
||||
setActiveBox(splitter.parentNode);
|
||||
await runPass(rtl, false, false);
|
||||
splitter.setAttribute("collapse", "before");
|
||||
await runPass(rtl, rtl, !rtl);
|
||||
@ -94,36 +80,22 @@ XUL <splitter> collapsing tests
|
||||
async function runAllTests() {
|
||||
await runTests(false, "ltr-splitter");
|
||||
await runTests(true, "rtl-splitter");
|
||||
await runTests(false, "ltr-flex-splitter");
|
||||
await runTests(true, "rtl-flex-splitter");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
addLoadEvent(function() {SimpleTest.executeSoon(runAllTests);});
|
||||
]]></script>
|
||||
|
||||
<hbox style="display: none; max-width: 200px; height: 300px; direction: ltr;">
|
||||
<hbox style="max-width: 200px; height: 300px; direction: ltr;">
|
||||
<vbox style="width: 100px; height: 300px;" flex="1"/>
|
||||
<splitter id="ltr-splitter" width="5"/>
|
||||
<vbox style="width: 100px; height: 300px;" flex="1"/>
|
||||
</hbox>
|
||||
|
||||
<hbox style="display: none; max-width: 200px; height: 300px; direction: rtl;">
|
||||
<hbox style="max-width: 200px; height: 300px; direction: rtl;">
|
||||
<vbox style="width: 100px; height: 300px;" flex="1"/>
|
||||
<splitter id="rtl-splitter" width="5"/>
|
||||
<vbox style="width: 100px; height: 300px;" flex="1"/>
|
||||
</hbox>
|
||||
|
||||
<hbox style="display: none; max-width: 200px; height: 300px; direction: ltr; -moz-box-layout: flex">
|
||||
<vbox style="width: 100px; height: 300px;" flex="1"/>
|
||||
<splitter id="ltr-flex-splitter" width="5"/>
|
||||
<vbox style="width: 100px; height: 300px;" flex="1"/>
|
||||
</hbox>
|
||||
|
||||
<hbox style="display: none; max-width: 200px; height: 300px; direction: rtl; -moz-box-layout: flex">
|
||||
<vbox style="width: 100px; height: 300px;" flex="1"/>
|
||||
<splitter id="rtl-flex-splitter" width="5"/>
|
||||
<vbox style="width: 100px; height: 300px;" flex="1"/>
|
||||
</hbox>
|
||||
|
||||
</window>
|
||||
|
Loading…
x
Reference in New Issue
Block a user