Skip to content

Commit

Permalink
Backed out 3 changesets (bug 1506687) for devtools failures on browse…
Browse files Browse the repository at this point in the history
…r_flexbox_sizing_info_for_text_nodes. CLOSED TREE

Backed out changeset 2788a93e179a (bug 1506687)
Backed out changeset 1c3baa04d4ce (bug 1506687)
Backed out changeset c50af93cfc84 (bug 1506687)
  • Loading branch information
CosminSabou committed Nov 15, 2018
1 parent 6a58ec9 commit 5394c8a
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 137 deletions.
4 changes: 0 additions & 4 deletions dom/chrome-webidl/Flex.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,10 @@ enum FlexItemClampState {
interface FlexItemValues
{
readonly attribute Node? node;
readonly attribute double mainPosition;
readonly attribute double mainSize;
readonly attribute double mainBaseSize;
readonly attribute double mainDeltaSize;
readonly attribute double mainMinSize;
readonly attribute double mainMaxSize;
readonly attribute double crossPosition;
readonly attribute double crossSize;
readonly attribute double crossMinSize;
readonly attribute double crossMaxSize;
readonly attribute FlexItemClampState clampState;
Expand Down
32 changes: 0 additions & 32 deletions dom/flex/FlexItemValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,13 @@ FlexItemValues::FlexItemValues(FlexLineValues* aParent,
mNode = aItem->mNode;

// Convert app unit sizes to css pixel sizes.
mMainPosition = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainPosition);
mMainSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainSize);
mMainBaseSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainBaseSize);
mMainDeltaSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainDeltaSize);
mMainMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainMinSize);
mMainMaxSize = ToPossiblyUnconstrainedPixels(aItem->mMainMaxSize);
mCrossPosition = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mCrossPosition);
mCrossSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mCrossSize);
mCrossMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mCrossMinSize);
mCrossMaxSize = ToPossiblyUnconstrainedPixels(aItem->mCrossMaxSize);
Expand All @@ -84,18 +76,6 @@ FlexItemValues::GetNode() const
return mNode;
}

double
FlexItemValues::MainPosition() const
{
return mMainPosition;
}

double
FlexItemValues::MainSize() const
{
return mMainSize;
}

double
FlexItemValues::MainBaseSize() const
{
Expand All @@ -120,18 +100,6 @@ FlexItemValues::MainMaxSize() const
return mMainMaxSize;
}

double
FlexItemValues::CrossPosition() const
{
return mCrossPosition;
}

double
FlexItemValues::CrossSize() const
{
return mCrossSize;
}

double
FlexItemValues::CrossMinSize() const
{
Expand Down
10 changes: 1 addition & 9 deletions dom/flex/FlexItemValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ class FlexItemValues : public nsISupports
}

nsINode* GetNode() const;
double MainPosition() const;
double MainSize() const;
double MainBaseSize() const;
double MainDeltaSize() const;
double MainMinSize() const;
double MainMaxSize() const;
double CrossPosition() const;
double CrossSize() const;
double CrossMinSize() const;
double CrossMaxSize() const;
FlexItemClampState ClampState() const;
Expand All @@ -55,15 +51,11 @@ class FlexItemValues : public nsISupports
RefPtr<FlexLineValues> mParent;
RefPtr<nsINode> mNode;

// These measurements are all CSS pixel units.
double mMainPosition;
double mMainSize;
// These sizes are all CSS pixel units.
double mMainBaseSize;
double mMainDeltaSize;
double mMainMinSize;
double mMainMaxSize;
double mCrossPosition;
double mCrossSize;
double mCrossMinSize;
double mCrossMaxSize;
FlexItemClampState mClampState;
Expand Down
95 changes: 37 additions & 58 deletions dom/flex/test/chrome/test_flex_items.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
.mainMinMax { min-width: 120px;
max-width: 500px; }

.flexGrow { flex-grow: 1; }
.spacer150 { width: 150px;
box-sizing: border-box;
height: 10px;
Expand All @@ -54,19 +55,13 @@

SimpleTest.waitForExplicitFinish();

const TEXT_NODE = Node.TEXT_NODE;

function testItemMatchesExpectedValues(item, values, index) {
if (typeof(values.node) != "undefined") {
is(item.node, values.node, "Item index " + index + " has expected node.");
}

if (typeof(values.mainPosition) != "undefined") {
is(item.mainPosition, values.mainPosition, "Item index " + index + " has expected mainPosition.");
}

if (typeof(values.mainSize) != "undefined") {
is(item.mainSize, values.mainSize, "Item index " + index + " has expected mainSize.");
}

if (typeof(values.mainBaseSize) != "undefined") {
is(item.mainBaseSize, values.mainBaseSize, "Item index " + index + " has expected mainBaseSize.");
}
Expand All @@ -89,14 +84,6 @@
"Item index " + index + " has expected (default) mainMaxSize.");
}

if (typeof(values.crossPosition) != "undefined") {
is(item.crossPosition, values.crossPosition, "Item index " + index + " has expected crossPosition.");
}

if (typeof(values.crossSize) != "undefined") {
is(item.crossSize, values.crossSize, "Item index " + index + " has expected crossSize.");
}

if (typeof(values.crossMinSize) != "undefined") {
is(item.crossMinSize, values.crossMinSize, "Item index " + index + " has expected crossMinSize.");
}
Expand Down Expand Up @@ -143,41 +130,31 @@
"that determines it.");

let expectedValues = [
{ mainPosition: 0,
crossMinSize: 0 },
{ mainPosition: 300,
mainBaseSize: 100,
mainDeltaSize: 0 },
{ crossMinSize: 40,
crossMaxSize: 120,
mainDeltaSize: 0 },
{ mainMinSize: 120,
mainMaxSize: 500,
mainDeltaSize: 0 },
{ mainMinSize: 120,
mainMaxSize: 500,
mainBaseSize: 150,
mainDeltaSize: 0 },
{ mainSize: 5,
mainBaseSize: 10,
mainMaxSize: 5,
mainDeltaSize: 0 },
{ mainSize: 15,
mainBaseSize: 10,
mainMinSize: 15,
mainDeltaSize: 0 },
{ mainSize: 10,
mainBaseSize: 50,
mainMaxSize: 10 },
{ crossSize: 20 },
{ mainSize: 10,
mainBaseSize: 1650,
mainMaxSize: 10,
mainDeltaSize: 0 },
{ mainDeltaSize: 0 },
{ crossPosition: 10,
crossSize: 40 },
{ mainSize: 20 },
{ crossMinSize: 0 },
{ mainBaseSize: 100,
mainDeltaSize: 0 },
{ crossMinSize: 40,
crossMaxSize: 120,
mainDeltaSize: 0 },
{ mainMinSize: 120,
mainMaxSize: 500,
mainDeltaSize: 0 },
{ mainMinSize: 120,
mainMaxSize: 500,
mainBaseSize: 150,
mainDeltaSize: 0 },
{ mainBaseSize: 10,
mainMaxSize: 5,
mainDeltaSize: 0 },
{ mainBaseSize: 10,
mainMinSize: 15,
mainDeltaSize: 0 },
{ mainBaseSize: 50,
mainMaxSize: 10 },
{ mainBaseSize: 1650,
mainMaxSize: 10,
mainDeltaSize: 0 },
{ mainDeltaSize: 0 },
{ /* final item is anonymous flex item */ },
];

Expand All @@ -201,11 +178,17 @@
? curElem.firstElementChild
: curElem);
} else {
// The final item should be an anonymous flex item with no node reported.
values.node = null;
is(container.lastChild.nodeType, TEXT_NODE,
"container's last child should be a text node");
values.node = container.lastChild;
}
testItemMatchesExpectedValues(item, values, i);
}

// Check that the delta size of the first item is (roughly) equal to the
// actual size minus the base size.
isfuzzy(items[0].mainDeltaSize, firstRect.width - items[0].mainBaseSize, 1e-4,
"flex-grow item should have expected mainDeltaSize.");
}

// Test for items in "flex-growing" flex container:
Expand Down Expand Up @@ -252,7 +235,7 @@
- flex items formation for display:contents subtrees & text nodes.
-->
<div id="flex-sanity" class="container">
<div class="lime base" style="min-width: 300px">one line (first)</div>
<div class="lime base flexGrow">one line (first)</div>
<div class="yellow lastbase" style="width: 100px">one line (last)</div>
<div class="orange offset lastbase crossMinMax">two<br/>lines and offset (last)</div>
<div class="pink offset base mainMinMax">offset (first)</div>
Expand All @@ -268,14 +251,10 @@
<!-- Item that wants to grow but is trivially clamped to max-width
below base size: -->
<div style="flex: 1 1 50px; max-width: 10px"></div>
<!-- Item with a fixed cross size: -->
<div style="height:20px"></div>
<div class="clamped-huge-item"></div>
<div style="display:contents">
<div class="white">replaced</div>
</div>
<table style="margin-top: 10px"></table>
<div style="display:table-cell; width: 20px"></div>
anon item for text
</div>

Expand Down
102 changes: 72 additions & 30 deletions layout/generic/nsFlexContainerFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,49 @@ ConvertLegacyStyleToJustifyContent(const nsStyleXUL* aStyleXUL)
return NS_STYLE_ALIGN_FLEX_START;
}

// Helper-function to find the first non-anonymous-box descendent of aFrame.
static nsIFrame*
GetFirstNonAnonBoxDescendant(nsIFrame* aFrame)
{
while (aFrame) {
nsAtom* pseudoTag = aFrame->Style()->GetPseudo();

// If aFrame isn't an anonymous container, then it'll do.
if (!pseudoTag || // No pseudotag.
!nsCSSAnonBoxes::IsAnonBox(pseudoTag) || // Pseudotag isn't anon.
nsCSSAnonBoxes::IsNonElement(pseudoTag)) { // Text, not a container.
break;
}

// Otherwise, descend to its first child and repeat.

// SPECIAL CASE: if we're dealing with an anonymous table, then it might
// be wrapping something non-anonymous in its caption or col-group lists
// (instead of its principal child list), so we have to look there.
// (Note: For anonymous tables that have a non-anon cell *and* a non-anon
// column, we'll always return the column. This is fine; we're really just
// looking for a handle to *anything* with a meaningful content node inside
// the table, for use in DOM comparisons to things outside of the table.)
if (MOZ_UNLIKELY(aFrame->IsTableWrapperFrame())) {
nsIFrame* captionDescendant =
GetFirstNonAnonBoxDescendant(aFrame->GetChildList(kCaptionList).FirstChild());
if (captionDescendant) {
return captionDescendant;
}
} else if (MOZ_UNLIKELY(aFrame->IsTableFrame())) {
nsIFrame* colgroupDescendant =
GetFirstNonAnonBoxDescendant(aFrame->GetChildList(kColGroupList).FirstChild());
if (colgroupDescendant) {
return colgroupDescendant;
}
}

// USUAL CASE: Descend to the first child in principal list.
aFrame = aFrame->PrincipalChildList().FirstChild();
}
return aFrame;
}

// Indicates whether advancing along the given axis is equivalent to
// increasing our X or Y position (as opposed to decreasing it).
static inline bool
Expand Down Expand Up @@ -4783,24 +4826,37 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,

// The frame may be for an element, or it may be for an
// anonymous flex item, e.g. wrapping one or more text nodes.
// If it's for an element, we want to return the DOM node that
// corresponds to it. If it's an anonymous flex item, we want
// to return a null DOM node.
nsINode* node = nullptr;

// If this frame is not an anonymous flex item, we will return its
// content as the DOM node for this flex item.
nsAtom* pseudoTag = frame->Style()->GetPseudo();
if (pseudoTag != nsCSSAnonBoxes::anonymousFlexItem()) {
node = frame->GetContent();
// DevTools wants the content node for the actual child in
// the DOM tree, so we descend through anonymous boxes.
nsIFrame* targetFrame = GetFirstNonAnonBoxDescendant(frame);
nsIContent* content = targetFrame->GetContent();

// Skip over content that is only whitespace, which might
// have been broken off from a text node which is our real
// target.
while (content && content->TextIsOnlyWhitespace()) {
// If content is only whitespace, try the frame sibling.
targetFrame = targetFrame->GetNextSibling();
if (targetFrame) {
content = targetFrame->GetContent();
} else {
content = nullptr;
}
}

ComputedFlexItemInfo* itemInfo = lineInfo->mItems.AppendElement();
itemInfo->mNode = node;
ComputedFlexItemInfo* itemInfo =
lineInfo->mItems.AppendElement();

itemInfo->mNode = content;

// mMainBaseSize and itemInfo->mMainDeltaSize will
// be filled out in ResolveFlexibleLengths().

// itemInfo->mMainBaseSize and mMainDeltaSize will be filled out
// in ResolveFlexibleLengths(). Other measurements will be captured
// at the end of this function.
// Other FlexItem properties can be captured now.
itemInfo->mMainMinSize = item->GetMainMinSize();
itemInfo->mMainMaxSize = item->GetMainMaxSize();
itemInfo->mCrossMinSize = item->GetCrossMinSize();
itemInfo->mCrossMaxSize = item->GetCrossMaxSize();
}
}
}
Expand Down Expand Up @@ -5205,7 +5261,7 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,

NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize)

// Finally update our line and item measurements in our containerInfo.
// Finally update our line sizing values in our containerInfo.
if (MOZ_UNLIKELY(containerInfo)) {
lineIndex = 0;
for (const FlexLine* line = lines.getFirst(); line;
Expand All @@ -5215,20 +5271,6 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
lineInfo.mCrossSize = line->GetLineCrossSize();
lineInfo.mFirstBaselineOffset = line->GetFirstBaselineOffset();
lineInfo.mLastBaselineOffset = line->GetLastBaselineOffset();

uint32_t itemIndex = 0;
for (const FlexItem* item = line->GetFirstItem(); item;
item = item->getNext(), ++itemIndex) {
ComputedFlexItemInfo& itemInfo = lineInfo.mItems[itemIndex];
itemInfo.mMainPosition = item->GetMainPosition();
itemInfo.mMainSize = item->GetMainSize();
itemInfo.mMainMinSize = item->GetMainMinSize();
itemInfo.mMainMaxSize = item->GetMainMaxSize();
itemInfo.mCrossPosition = item->GetCrossPosition();
itemInfo.mCrossSize = item->GetCrossSize();
itemInfo.mCrossMinSize = item->GetCrossMinSize();
itemInfo.mCrossMaxSize = item->GetCrossMaxSize();
}
}
}
}
Expand Down
Loading

0 comments on commit 5394c8a

Please sign in to comment.