Backed out 5 changesets (bug 1409083) for eslint failures

Backed out changeset 9de539be3665 (bug 1409083)
Backed out changeset 660e79af5c93 (bug 1409083)
Backed out changeset 574cd09aad41 (bug 1409083)
Backed out changeset b21b06a24705 (bug 1409083)
Backed out changeset b21e6a795493 (bug 1409083)
This commit is contained in:
Phil Ringnalda 2017-12-07 19:47:09 -08:00
Родитель 44ded00008
Коммит 9d10710b26
19 изменённых файлов: 24 добавлений и 1368 удалений

Просмотреть файл

@ -16,7 +16,6 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/dom/Animation.h"
#include "mozilla/dom/Attr.h"
#include "mozilla/dom/Flex.h"
#include "mozilla/dom/Grid.h"
#include "mozilla/gfx/Matrix.h"
#include "nsDOMAttributeMap.h"
@ -28,7 +27,6 @@
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIContentIterator.h"
#include "nsFlexContainerFrame.h"
#include "nsFocusManager.h"
#include "nsFrameManager.h"
#include "nsILinkHandler.h"
@ -3709,23 +3707,6 @@ Element::RequestPointerLock(CallerType aCallerType)
OwnerDoc()->RequestPointerLock(this, aCallerType);
}
already_AddRefed<Flex>
Element::GetAsFlexContainer()
{
nsIFrame* frame = GetPrimaryFrame();
// We need the flex frame to compute additional info, and use
// that annotated version of the frame.
nsFlexContainerFrame* flexFrame =
nsFlexContainerFrame::GetFlexFrameWithComputedInfo(frame);
if (flexFrame) {
RefPtr<Flex> flex = new Flex(this, flexFrame);
return flex.forget();
}
return nullptr;
}
void
Element::GetGridFragments(nsTArray<RefPtr<Grid>>& aResult)
{

Просмотреть файл

@ -189,7 +189,6 @@ class Link;
class DOMRect;
class DOMRectList;
class DestinationInsertionPointList;
class Flex;
class Grid;
// IID for the dom::Element interface
@ -1309,7 +1308,6 @@ public:
0;
}
already_AddRefed<Flex> GetAsFlexContainer();
void GetGridFragments(nsTArray<RefPtr<Grid>>& aResult);
already_AddRefed<DOMMatrixReadOnly> GetTransformToAncestor(Element& aAncestor);

Просмотреть файл

@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Flex.h"
#include "FlexLine.h"
#include "mozilla/dom/FlexBinding.h"
#include "nsFlexContainerFrame.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Flex, mParent, mLines)
NS_IMPL_CYCLE_COLLECTING_ADDREF(Flex)
NS_IMPL_CYCLE_COLLECTING_RELEASE(Flex)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Flex)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
Flex::Flex(Element* aParent,
nsFlexContainerFrame* aFrame)
: mParent(aParent)
{
MOZ_ASSERT(aFrame,
"Should never be instantiated with a null nsFlexContainerFrame");
// Eagerly create property values from aFrame, because we're not
// going to keep it around.
const ComputedFlexContainerInfo* containerInfo =
aFrame->GetFlexContainerInfo();
MOZ_ASSERT(containerInfo, "Should only be passed a frame with info.");
mLines.SetLength(containerInfo->mLines.Length());
uint32_t index = 0;
for (auto&& l : containerInfo->mLines) {
FlexLine* line = new FlexLine(this, &l);
mLines.ElementAt(index) = line;
index++;
}
}
JSObject*
Flex::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return FlexBinding::Wrap(aCx, this, aGivenProto);
}
void
Flex::GetLines(nsTArray<RefPtr<FlexLine>>& aResult)
{
aResult.AppendElements(mLines);
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_Flex_h
#define mozilla_dom_Flex_h
#include "mozilla/dom/Element.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
class nsFlexContainerFrame;
namespace mozilla {
namespace dom {
class FlexLine;
class Flex : public nsISupports
, public nsWrapperCache
{
public:
explicit Flex(Element* aParent, nsFlexContainerFrame* aFrame);
protected:
virtual ~Flex() = default;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Flex)
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
Element* GetParentObject()
{
return mParent;
}
void GetLines(nsTArray<RefPtr<FlexLine>>& aResult);
protected:
nsCOMPtr<Element> mParent;
nsTArray<RefPtr<FlexLine>> mLines;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_Flex_h */

Просмотреть файл

@ -1,98 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FlexItem.h"
#include "mozilla/dom/FlexBinding.h"
#include "nsFlexContainerFrame.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FlexItem, mParent)
NS_IMPL_CYCLE_COLLECTING_ADDREF(FlexItem)
NS_IMPL_CYCLE_COLLECTING_RELEASE(FlexItem)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FlexItem)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
FlexItem::FlexItem(FlexLine* aParent,
const ComputedFlexItemInfo* aItem)
: mParent(aParent)
{
MOZ_ASSERT(aItem,
"Should never be instantiated with a null ComputedFlexLineInfo.");
// Eagerly copy values from aItem, because we're not
// going to keep it around.
mNode = aItem->mNode;
// Convert app unit sizes to css pixel sizes.
mMainBaseSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainBaseSize);
mMainDeltaSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainDeltaSize);
mMainMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainMinSize);
mMainMaxSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mMainMaxSize);
mCrossMinSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mCrossMinSize);
mCrossMaxSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aItem->mCrossMaxSize);
}
JSObject*
FlexItem::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return FlexItemBinding::Wrap(aCx, this, aGivenProto);
}
nsINode*
FlexItem::GetNode() const
{
return mNode;
}
double
FlexItem::MainBaseSize() const
{
return mMainBaseSize;
}
double
FlexItem::MainDeltaSize() const
{
return mMainDeltaSize;
}
double
FlexItem::MainMinSize() const
{
return mMainMinSize;
}
double
FlexItem::MainMaxSize() const
{
return mMainMaxSize;
}
double
FlexItem::CrossMinSize() const
{
return mCrossMinSize;
}
double
FlexItem::CrossMaxSize() const
{
return mCrossMaxSize;
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_FlexItem_h
#define mozilla_dom_FlexItem_h
#include "mozilla/dom/FlexBinding.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
struct ComputedFlexItemInfo;
namespace mozilla {
namespace dom {
class FlexLine;
class FlexItem : public nsISupports
, public nsWrapperCache
{
public:
explicit FlexItem(FlexLine* aParent,
const ComputedFlexItemInfo* aItem);
protected:
virtual ~FlexItem() = default;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FlexItem)
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
FlexLine* GetParentObject()
{
return mParent;
}
nsINode* GetNode() const;
double MainBaseSize() const;
double MainDeltaSize() const;
double MainMinSize() const;
double MainMaxSize() const;
double CrossMinSize() const;
double CrossMaxSize() const;
protected:
RefPtr<FlexLine> mParent;
RefPtr<nsINode> mNode;
// These sizes are all CSS pixel units.
double mMainBaseSize;
double mMainDeltaSize;
double mMainMinSize;
double mMainMaxSize;
double mCrossMinSize;
double mCrossMaxSize;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_FlexItem_h */

Просмотреть файл

@ -1,100 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FlexLine.h"
#include "FlexItem.h"
#include "mozilla/dom/FlexBinding.h"
#include "nsFlexContainerFrame.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(FlexLine, mParent, mItems)
NS_IMPL_CYCLE_COLLECTING_ADDREF(FlexLine)
NS_IMPL_CYCLE_COLLECTING_RELEASE(FlexLine)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FlexLine)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
FlexLine::FlexLine(Flex* aParent,
const ComputedFlexLineInfo* aLine)
: mParent(aParent)
{
MOZ_ASSERT(aLine,
"Should never be instantiated with a null ComputedFlexLineInfo.");
// Eagerly copy values from aLine, because we're not
// going to keep it around.
switch (aLine->mGrowthState) {
case ComputedFlexLineInfo::GrowthState::SHRINKING:
mGrowthState = FlexLineGrowthState::Shrinking;
break;
case ComputedFlexLineInfo::GrowthState::GROWING:
mGrowthState = FlexLineGrowthState::Growing;
break;
default:
mGrowthState = FlexLineGrowthState::Unchanged;
};
// Convert all the app unit values into css pixels.
mCrossSize = nsPresContext::AppUnitsToDoubleCSSPixels(
aLine->mCrossSize);
mFirstBaselineOffset = nsPresContext::AppUnitsToDoubleCSSPixels(
aLine->mFirstBaselineOffset);
mLastBaselineOffset = nsPresContext::AppUnitsToDoubleCSSPixels(
aLine->mLastBaselineOffset);
mItems.SetLength(aLine->mItems.Length());
uint32_t index = 0;
for (auto&& i : aLine->mItems) {
FlexItem* item = new FlexItem(this, &i);
mItems.ElementAt(index) = item;
index++;
}
}
JSObject*
FlexLine::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return FlexLineBinding::Wrap(aCx, this, aGivenProto);
}
FlexLineGrowthState
FlexLine::GrowthState() const
{
return mGrowthState;
}
double
FlexLine::CrossSize() const
{
return mCrossSize;
}
double
FlexLine::FirstBaselineOffset() const
{
return mFirstBaselineOffset;
}
double
FlexLine::LastBaselineOffset() const
{
return mLastBaselineOffset;
}
void
FlexLine::GetItems(nsTArray<RefPtr<FlexItem>>& aResult)
{
aResult.AppendElements(mItems);
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -1,63 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_FlexLine_h
#define mozilla_dom_FlexLine_h
#include "mozilla/dom/FlexBinding.h"
#include "nsISupports.h"
#include "nsWrapperCache.h"
struct ComputedFlexLineInfo;
namespace mozilla {
namespace dom {
class Flex;
class FlexItem;
class FlexLine : public nsISupports
, public nsWrapperCache
{
public:
explicit FlexLine(Flex* aParent,
const ComputedFlexLineInfo* aLine);
protected:
virtual ~FlexLine() = default;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FlexLine)
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
Flex* GetParentObject()
{
return mParent;
}
FlexLineGrowthState GrowthState() const;
double CrossSize() const;
double FirstBaselineOffset() const;
double LastBaselineOffset() const;
void GetItems(nsTArray<RefPtr<FlexItem>>& aResult);
protected:
RefPtr<Flex> mParent;
FlexLineGrowthState mGrowthState;
double mCrossSize;
double mFirstBaselineOffset;
double mLastBaselineOffset;
nsTArray<RefPtr<FlexItem>> mItems;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_FlexLine_h */

Просмотреть файл

@ -1,28 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files("**"):
BUG_COMPONENT = ("Core", "CSS Parsing and Computation")
MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
EXPORTS.mozilla.dom += [
'Flex.h',
'FlexItem.h',
'FlexLine.h',
]
UNIFIED_SOURCES += [
'Flex.cpp',
'FlexItem.cpp',
'FlexLine.cpp',
]
LOCAL_INCLUDES += [
'/layout/generic',
]
FINAL_LIBRARY = 'xul'

Просмотреть файл

@ -1,2 +0,0 @@
[chrome/test_flex_items.html]
[chrome/test_flex_lines.html]

Просмотреть файл

@ -1,170 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style>
.container {
display: flex;
background-color: grey;
font: 14px sans-serif;
width: 800px;
height: 50px;
}
.base { align-self: baseline; }
.lastbase { align-self: last baseline; }
.offset { margin-top: 10px;
margin-bottom: 3px; }
.lime { background: lime; }
.yellow { background: yellow; }
.orange { background: orange; }
.pink { background: pink; }
.white { background: white; }
.crossMinMax { min-height: 40px;
max-height: 120px; }
.mainMinMax { min-width: 120px;
max-width: 500px; }
.flexGrow { flex-grow: 1; }
#second { width: 100px; }
</style>
<script>
'use strict';
SimpleTest.waitForExplicitFinish();
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const TEXT_NODE = Ci.nsIDOMNode.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.node_todo) != "undefined") {
todo_is(item.node, values.node_todo, "Item index " + index + " has expected node.");
}
if (typeof(values.mainBaseSize) != "undefined") {
is(item.mainBaseSize, values.mainBaseSize, "Item index " + index + " has expected mainBaseSize.");
}
if (typeof(values.mainDeltaSize) != "undefined") {
is(item.mainDeltaSize, values.mainDeltaSize, "Item index " + index + " has expected mainDeltaSize.");
}
if (typeof(values.mainMinSize) != "undefined") {
is(item.mainMinSize, values.mainMinSize, "Item index " + index + " has expected mainMinSize.");
}
if (typeof(values.mainMaxSize) != "undefined") {
is(item.mainMaxSize, values.mainMaxSize, "Item index " + index + " has expected mainMaxSize.");
}
if (typeof(values.crossMinSize) != "undefined") {
is(item.crossMinSize, values.crossMinSize, "Item index " + index + " has expected crossMinSize.");
}
if (typeof(values.crossMaxSize) != "undefined") {
is(item.crossMaxSize, values.crossMaxSize, "Item index " + index + " has expected crossMaxSize.");
}
}
function nearlyEqual(a, b) {
const ep = 1e-4;
let diff = a - b;
return (diff < ep && diff > -ep);
}
function runTests() {
let container = document.getElementById("wrapper");
let flex = container.getAsFlexContainer();
let lines = flex.getLines();
is(lines.length, 1, "Container has expected number of lines.");
let line = lines[0];
let containerHeight = container.getBoundingClientRect().height;
is(line.crossSize, containerHeight, "Line crossSize equals the height of the container.");
let first = document.getElementById("first");
let second = document.getElementById("second");
let third = document.getElementById("third");
let fourth = document.getElementById("fourth");
let fifth = document.getElementById("fifth");
let sixth = container.lastChild;
is(sixth.nodeType, TEXT_NODE, "Sixth child should be an anonymous text node.");
// We can't compare baselines precisely, so we'll just confirm that they appear
// somewhere within the elements that determine them.
let firstRect = first.getBoundingClientRect();
ok(line.firstBaselineOffset > firstRect.top &&
line.firstBaselineOffset < firstRect.bottom,
"Line firstBaselineOffset lands somewhere within the element that determines it.");
// For last baseline, it's measured from the bottom, so we have to compare against
// the element bounds subtracted from the container height.
let secondRect = second.getBoundingClientRect();
ok(line.lastBaselineOffset > containerHeight - secondRect.bottom &&
line.lastBaselineOffset < containerHeight - secondRect.top,
"Line lastBaselineOffset lands somewhere within the element that determines it.");
let items = line.getItems();
is(items.length, 6, "Line has expected number of items.");
let expectedValues = [
{ node: first,
crossMinSize: 0 },
{ node: second,
mainBaseSize: secondRect.width,
mainDeltaSize: 0 },
{ node: third,
crossMinSize: 40,
crossMaxSize: 120,
mainDeltaSize: 0 },
{ node: fourth,
mainMinSize: 120,
mainMaxSize: 500,
mainDeltaSize: 0 },
{ node: fifth,
mainDeltaSize: 0 },
{ node: sixth },
];
for (let i = 0; i < items.length; ++i) {
let item = items[i];
let values = expectedValues[i];
testItemMatchesExpectedValues(item, values, i);
}
// Check that the delta size of the first item is nearly equal to the actual size minus the base size.
ok(nearlyEqual(items[0].mainDeltaSize, firstRect.width - items[0].mainBaseSize),
"flex-grow item has expected mainDeltaSize.");
SimpleTest.finish();
}
</script>
</head>
</head>
<body onLoad="runTests();">
<div id="wrapper" class="container">
<div id="first" class="lime base flexGrow">one line (first)</div>
<div id="second" class="yellow lastbase">one line (last)</div>
<div id="third" class="orange offset lastbase crossMinMax">two<br/>lines and offset (last)</div>
<div id="fourth" class="pink offset base mainMinMax">offset (first)</div>
<div style="display:contents">
<div id="fifth" class="white">replaced</div>
</div>
anonymous text node
</div>
</body>
</html>

Просмотреть файл

@ -1,282 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style>
f {
display: flex;
background-color: grey;
font: 12px sans-serif;
width: 800px;
height: 42px;
margin-bottom: 5px;
}
.withZ::after {
background-color: pink;
content: "Z";
width: 100px;
height: 10px;
}
.wrap {
flex-wrap: wrap;
}
.wrapReverse {
flex-wrap: wrap-reverse;
}
b {
background-color: gold;
min-width: 100px;
height: 20px;
flex-grow: 1;
}
b::after {
content: "B";
}
c {
background-color: yellow;
width: 200px;
height: 15px;
}
c::after {
content: "C";
}
d {
background-color: orange;
width: 300px;
height: 10px;
}
d::after {
content: "D";
}
e {
background-color: silver;
width: 300px;
height: 10px;
flex-shrink: 2;
}
e::after {
content: "E";
}
</style>
<script>
'use strict';
SimpleTest.waitForExplicitFinish();
function testLineMatchesExpectedValues(line, values, lineIndex, flexIndex) {
if (typeof(values.growthState) != "undefined") {
is(line.growthState, values.growthState, "Flex index " + flexIndex + " line index " + lineIndex + " has expected growthState.");
}
if (typeof(values.crossSize) != "undefined") {
is(line.crossSize, values.crossSize, "Flex index " + flexIndex + " line index " + lineIndex + " has expected crossSize.");
}
if (typeof(values.itemCount) != "undefined") {
is(line.getItems().length, values.itemCount, "Flex index " + flexIndex + " line index " + lineIndex + " has expected number of items.");
}
}
function runTests() {
let expectedValues = [
// items don't fill container, no grow, shrink, or min-width
[{ crossSize: 42,
itemCount: 2,
growthState: "unchanged" }],
[{ crossSize: 42,
itemCount: 3,
growthState: "unchanged" }],
// items don't fill container, no grow, shrink, or min-width, with wrap and align-content:center -->
[{ crossSize: 15,
itemCount: 2,
growthState: "unchanged" }],
[{ crossSize: 15,
itemCount: 3,
growthState: "unchanged" }],
// items don't fill container, with grow
[{ crossSize: 42,
itemCount: 3,
growthState: "growing" }],
[{ crossSize: 42,
itemCount: 4,
growthState: "growing" }],
// items overfill container, with min-width, and sometimes with wrap
[{ crossSize: 42,
itemCount: 5,
growthState: "shrinking" }],
[{ crossSize: 21,
itemCount: 3,
growthState: "growing" },
{ crossSize: 21,
itemCount: 2,
growthState: "growing" }],
[{ crossSize: 42,
itemCount: 6,
growthState: "shrinking" }],
[{ crossSize: 21,
itemCount: 3,
growthState: "growing" },
{ crossSize: 21,
itemCount: 3,
growthState: "growing" }],
// items overfill container, with shrink and sometimes with wrap
[{ crossSize: 42,
itemCount: 3,
growthState: "shrinking" }],
[{ crossSize: 21,
itemCount: 2,
growthState: "unchanged" },
{ crossSize: 21,
itemCount: 1,
growthState: "unchanged" }],
[{ crossSize: 42,
itemCount: 4,
growthState: "shrinking" }],
[{ crossSize: 21,
itemCount: 2,
growthState: "unchanged" },
{ crossSize: 21,
itemCount: 2,
growthState: "unchanged" }],
// items overfill container, with wrap and different types of align-content
[{ crossSize: 26,
itemCount: 3 },
{ crossSize: 16,
itemCount: 1 }],
[{ crossSize: 20,
itemCount: 3 },
{ crossSize: 10,
itemCount: 1 }],
[{ crossSize: 20,
itemCount: 3 },
{ crossSize: 10,
itemCount: 1 }],
[{ crossSize: 20,
itemCount: 3 },
{ crossSize: 10,
itemCount: 1 }],
[{ crossSize: 20,
itemCount: 3 },
{ crossSize: 10,
itemCount: 1 }],
[{ crossSize: 20,
itemCount: 3 },
{ crossSize: 10,
itemCount: 1 }],
// items overfill container, with wrap-reverse and different types of align-content
[{ crossSize: 16,
itemCount: 2 },
{ crossSize: 26,
itemCount: 3 }],
[{ crossSize: 10,
itemCount: 2 },
{ crossSize: 20,
itemCount: 3 }],
[{ crossSize: 10,
itemCount: 2 },
{ crossSize: 20,
itemCount: 3 }],
[{ crossSize: 10,
itemCount: 2 },
{ crossSize: 20,
itemCount: 3 }],
[{ crossSize: 10,
itemCount: 2 },
{ crossSize: 20,
itemCount: 3 }],
[{ crossSize: 10,
itemCount: 2 },
{ crossSize: 20,
itemCount: 3 }],
// other strange types of flex containers
[{ itemCount: 3 }],
];
let children = document.body.children;
is(children.length, expectedValues.length, "Document has expected number of flex containers.");
for (let i = 0; i < children.length; ++i) {
let flex = children.item(i).getAsFlexContainer();
ok(flex, "Document child index " + i + " is a flex container.");
if (flex) {
let values = expectedValues[i];
let lines = flex.getLines();
is(lines.length, values.length, "Flex index " + i + " has expected number of lines.");
for (let j = 0; j < lines.length; ++j) {
testLineMatchesExpectedValues(lines[j], values[j], j, i);
}
}
}
SimpleTest.finish();
}
</script>
</head>
</head>
<body onLoad="runTests();">
<!-- items don't fill container, no grow, shrink, or min-width -->
<f><c></c><d></d></f>
<f class="withZ"><c></c><d></d></f>
<!-- items don't fill container, no grow, shrink, or min-width, with wrap and align-content:center -->
<f class="wrap" style="align-content:center"><c></c><d></d></f>
<f class="withZ wrap" style="align-content:center"><c></c><d></d></f>
<!-- items don't fill container, with grow -->
<f><b></b><c></c><d></d></f>
<f class="withZ"><b></b><c></c><d></d></f>
<!-- items overfill container, with min-width, and sometimes with wrap -->
<f><b></b><d></d><d></d><d></d><b></b></f>
<f class="wrap"><b></b><d></d><d></d><d></d><b></b></f>
<f class="withZ"><b></b><d></d><d></d><d></d><b></b></f>
<f class="wrap withZ"><b></b><d></d><d></d><d></d><b></b></f>
<!-- items overfill container, with shrink and sometimes with wrap -->
<f><d></d><d></d><e></e></f>
<f class="wrap"><d></d><d></d><e></e></f>
<f class="withZ"><d></d><d></d><e></e></f>
<f class="wrap withZ"><d></d><d></d><e></e></f>
<!-- items overfill container, with wrap and different types of align-content -->
<f class="wrap"><b></b><c></c><d></d><e></e></f>
<f class="wrap" style="align-content:flex-start"><b></b><c></c><d></d><e></e></f>
<f class="wrap" style="align-content:flex-end"><b></b><c></c><d></d><e></e></f>
<f class="wrap" style="align-content:center"><b></b><c></c><d></d><e></e></f>
<f class="wrap" style="align-content:space-between"><b></b><c></c><d></d><e></e></f>
<f class="wrap" style="align-content:space-around"><b></b><c></c><d></d><e></e></f>
<!-- items overfill container, with wrap-reverse and different types of align-content -->
<f class="wrapReverse withZ"><b></b><c></c><d></d><e></e></f>
<f class="wrapReverse withZ" style="align-content:flex-start"><b></b><c></c><d></d><e></e></f>
<f class="wrapReverse withZ" style="align-content:flex-end"><b></b><c></c><d></d><e></e></f>
<f class="wrapReverse withZ" style="align-content:center"><b></b><c></c><d></d><e></e></f>
<f class="wrapReverse withZ" style="align-content:space-between"><b></b><c></c><d></d><e></e></f>
<f class="wrapReverse withZ" style="align-content:space-around"><b></b><c></c><d></d><e></e></f>
<!-- other strange types of flex containers -->
<f style="overflow:scroll"><d></d><d></d><e></e></f>
</body>
</html>

Просмотреть файл

@ -59,7 +59,6 @@ DIRS += [
'file',
'filehandle',
'filesystem',
'flex',
'gamepad',
'geolocation',
'grid',

Просмотреть файл

@ -119,7 +119,7 @@ interface Element : Node {
* called. If retargetToElement is true, then all events are targetted at
* this element. If false, events can also fire at descendants of this
* element.
*
*
*/
void setCapture(optional boolean retargetToElement = false);
@ -154,17 +154,8 @@ interface Element : Node {
*/
boolean scrollByNoFlush(long dx, long dy);
// Support reporting of Flexbox properties
/**
* If this element has a display:flex or display:inline-flex style,
* this property returns an object with computed values for flex
* properties, as well as a property that exposes the flex lines
* in this container.
*/
[ChromeOnly, Pure]
Flex? getAsFlexContainer();
// Support reporting of Grid properties
/**
* If this element has a display:grid or display:inline-grid style,
* this property returns an object with computed values for grid
@ -200,7 +191,7 @@ partial interface Element {
attribute long scrollLeft; // scroll on setting
readonly attribute long scrollWidth;
readonly attribute long scrollHeight;
void scroll(unrestricted double x, unrestricted double y);
void scroll(optional ScrollToOptions options);
void scrollTo(unrestricted double x, unrestricted double y);

Просмотреть файл

@ -1,53 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* These objects support visualization of flex containers by the
* dev tools.
*/
[ChromeOnly]
interface Flex
{
sequence<FlexLine> getLines();
};
/**
* Lines with items that have been shrunk are shrinking; with items
* that have grown are growing, and all others are unchanged.
*/
enum FlexLineGrowthState { "unchanged", "shrinking", "growing" };
[ChromeOnly]
interface FlexLine
{
readonly attribute FlexLineGrowthState growthState;
readonly attribute double crossSize;
// firstBaselineOffset measures from flex-start edge.
readonly attribute double firstBaselineOffset;
// lastBaselineOffset measures from flex-end edge.
readonly attribute double lastBaselineOffset;
/**
* getItems() returns FlexItems only for the Elements in this Flex
* container -- ignoring struts and abs-pos Elements.
*/
sequence<FlexItem> getItems();
};
[ChromeOnly]
interface FlexItem
{
readonly attribute Node? node;
readonly attribute double mainBaseSize;
readonly attribute double mainDeltaSize;
readonly attribute double mainMinSize;
readonly attribute double mainMaxSize;
readonly attribute double crossMinSize;
readonly attribute double crossMaxSize;
};

Просмотреть файл

@ -103,9 +103,6 @@ with Files("DesktopNotification.webidl"):
with Files("FakePluginTagInit.webidl"):
BUG_COMPONENT = ("Core", "Plug-ins")
with Files("Flex.webidl"):
BUG_COMPONENT = ("Core", "CSS Parsing and Computation")
with Files("FocusEvent.webidl"):
BUG_COMPONENT = ("Core", "DOM: Events")
@ -527,7 +524,6 @@ WEBIDL_FILES = [
'FileSystemDirectoryReader.webidl',
'FileSystemEntry.webidl',
'FileSystemFileEntry.webidl',
'Flex.webidl',
'FocusEvent.webidl',
'FontFace.webidl',
'FontFaceSet.webidl',

Просмотреть файл

@ -157,49 +157,6 @@ 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->StyleContext()->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
@ -991,8 +948,7 @@ public:
// Runs the "Resolving Flexible Lengths" algorithm from section 9.7 of the
// CSS flexbox spec to distribute aFlexContainerMainSize among our flex items.
void ResolveFlexibleLengths(nscoord aFlexContainerMainSize,
ComputedFlexLineInfo* aLineInfo);
void ResolveFlexibleLengths(nscoord aFlexContainerMainSize);
void PositionItemsInMainAxis(uint8_t aJustifyContent,
nscoord aContentBoxMainSize,
@ -2424,8 +2380,7 @@ FlexLine::FreezeOrRestoreEachFlexibleSize(const nscoord aTotalViolation,
}
void
FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize,
ComputedFlexLineInfo* aLineInfo)
FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize)
{
MOZ_LOG(gFlexContainerLog, LogLevel::Debug, ("ResolveFlexibleLengths\n"));
@ -2437,13 +2392,11 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize,
// direction we've chosen:
FreezeItemsEarly(isUsingFlexGrow);
if ((mNumFrozenItems == mNumItems) && !aLineInfo) {
// All our items are frozen, so we have no flexible lengths to resolve,
// and we aren't being asked to generate computed line info.
if (mNumFrozenItems == mNumItems) {
// All our items are frozen, so we have no flexible lengths to resolve.
return;
}
MOZ_ASSERT(!IsEmpty() || aLineInfo,
"empty lines should take the early-return above");
MOZ_ASSERT(!IsEmpty(), "empty lines should take the early-return above");
// Subtract space occupied by our items' margins/borders/padding, so we can
// just be dealing with the space available for our flex items' content
@ -2477,21 +2430,6 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize,
availableFreeSpace -= item->GetMainSize();
}
// If we have an aLineInfo structure to fill out, and this is the
// first time through the loop, capture these sizes as mainBaseSizes.
// We only care about the first iteration, because additional
// iterations will only reset item base sizes to these values.
// We also set a 0 mainDeltaSize. This will be modified later if
// the item is stretched or shrunk.
if (aLineInfo && (iterationCounter == 0)) {
uint32_t itemIndex = 0;
for (FlexItem* item = mItems.getFirst(); item; item = item->getNext(),
++itemIndex) {
aLineInfo->mItems[itemIndex].mMainBaseSize = item->GetMainSize();
aLineInfo->mItems[itemIndex].mMainDeltaSize = 0;
}
}
MOZ_LOG(gFlexContainerLog, LogLevel::Debug,
(" available free space = %d\n", availableFreeSpace));
@ -2657,45 +2595,6 @@ FlexLine::ResolveFlexibleLengths(nscoord aFlexContainerMainSize,
item, sizeDelta, item->GetMainSize()));
}
}
// If we have an aLineInfo structure to fill out, capture any
// size changes that may have occurred in the previous loop.
// We don't do this inside the previous loop, because we don't
// want to burden layout when aLineInfo is null.
if (aLineInfo) {
uint32_t itemIndex = 0;
for (FlexItem* item = mItems.getFirst(); item; item = item->getNext(),
++itemIndex) {
// Calculate a deltaSize that represents how much the
// flex sizing algorithm "wants" to stretch or shrink this
// item during this pass through the algorithm. Later
// passes through the algorithm may overwrite this value.
// Also, this value may not reflect how much the size of
// the item is actually changed, since the size of the
// item will be clamped to min and max values later in
// this pass. That's intentional, since we want to report
// the value that the sizing algorithm tried to stretch
// or shrink the item.
nscoord deltaSize = item->GetMainSize() -
aLineInfo->mItems[itemIndex].mMainBaseSize;
aLineInfo->mItems[itemIndex].mMainDeltaSize = deltaSize;
// If any item on the line is growing, mark the aLineInfo
// structure; likewise if any item is shrinking. Items in
// a line can't be both growing and shrinking.
if (deltaSize > 0) {
MOZ_ASSERT(aLineInfo->mGrowthState !=
ComputedFlexLineInfo::GrowthState::SHRINKING);
aLineInfo->mGrowthState =
ComputedFlexLineInfo::GrowthState::GROWING;
} else if (deltaSize < 0) {
MOZ_ASSERT(aLineInfo->mGrowthState !=
ComputedFlexLineInfo::GrowthState::GROWING);
aLineInfo->mGrowthState =
ComputedFlexLineInfo::GrowthState::SHRINKING;
}
}
}
}
}
@ -4075,24 +3974,6 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
const FlexboxAxisTracker axisTracker(this, aReflowInput.GetWritingMode());
// Check to see if we need to create a computed info structure, to
// be filled out for use by devtools.
if (HasAnyStateBits(NS_STATE_FLEX_GENERATE_COMPUTED_VALUES)) {
// This state bit will never be cleared. That's acceptable because
// it's only set in a Chrome API invoked by devtools, and won't
// impact normal browsing.
// Re-use the ComputedFlexContainerInfo, if it exists.
ComputedFlexContainerInfo* info = GetProperty(FlexContainerInfo());
if (info) {
// We can reuse, as long as we clear out old data.
info->mLines.Clear();
} else {
info = new ComputedFlexContainerInfo();
SetProperty(FlexContainerInfo(), info);
}
}
// If we're being fragmented into a constrained BSize, then subtract off
// borderpadding BStart from that constrained BSize, to get the available
// BSize for our content box. (No need to subtract the borderpadding BStart
@ -4236,59 +4117,6 @@ nsFlexContainerFrame::CalculatePackingSpace(uint32_t aNumThingsToPack,
*aPackingSpaceRemaining -= totalEdgePackingSpace;
}
nsFlexContainerFrame*
nsFlexContainerFrame::GetFlexFrameWithComputedInfo(nsIFrame* aFrame)
{
// Prepare a lambda function that we may need to call multiple times.
auto GetFlexContainerFrame = [](nsIFrame *aFrame) {
// Return the aFrame's content insertion frame, iff it is
// a flex container frame.
nsFlexContainerFrame* flexFrame = nullptr;
if (aFrame) {
nsIFrame* contentFrame = aFrame->GetContentInsertionFrame();
if (contentFrame && (contentFrame->IsFlexContainerFrame())) {
flexFrame = static_cast<nsFlexContainerFrame*>(contentFrame);
}
}
return flexFrame;
};
nsFlexContainerFrame* flexFrame = GetFlexContainerFrame(aFrame);
if (flexFrame) {
// Generate the FlexContainerInfo data, if it's not already there.
bool reflowNeeded = !flexFrame->HasProperty(FlexContainerInfo());
if (reflowNeeded) {
// Trigger a reflow that generates additional flex property data.
// Hold onto aFrame while we do this, in case reflow destroys it.
AutoWeakFrame weakFrameRef(aFrame);
nsIPresShell* shell = flexFrame->PresContext()->PresShell();
flexFrame->AddStateBits(NS_STATE_FLEX_GENERATE_COMPUTED_VALUES);
shell->FrameNeedsReflow(flexFrame,
nsIPresShell::eResize,
NS_FRAME_IS_DIRTY);
shell->FlushPendingNotifications(FlushType::Layout);
// Since the reflow may have side effects, get the flex frame
// again. But if the weakFrameRef is no longer valid, then we
// must bail out.
if (!weakFrameRef.IsAlive()) {
return nullptr;
}
flexFrame = GetFlexContainerFrame(weakFrameRef.GetFrame());
MOZ_ASSERT(!flexFrame ||
flexFrame->HasProperty(FlexContainerInfo()),
"The state bit should've made our forced-reflow "
"generate a FlexContainerInfo object");
}
}
return flexFrame;
}
void
nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
@ -4319,92 +4147,13 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
RemoveStateBits(NS_STATE_FLEX_SYNTHESIZE_BASELINE);
}
// Construct our computed info if we've been asked to do so. This is
// necessary to do now so we can capture some computed values for
// FlexItems during layout that would not otherwise be saved (like
// size adjustments). We'll later fix up the line properties,
// because the correct values aren't available yet.
ComputedFlexContainerInfo* containerInfo = nullptr;
if (HasAnyStateBits(NS_STATE_FLEX_GENERATE_COMPUTED_VALUES)) {
containerInfo = GetProperty(FlexContainerInfo());
MOZ_ASSERT(containerInfo,
"::Reflow() should have created container info.");
if (!aStruts.IsEmpty()) {
// We restarted DoFlexLayout, and may have stale mLines to clear:
containerInfo->mLines.Clear();
} else {
MOZ_ASSERT(containerInfo->mLines.IsEmpty(),
"Shouldn't have lines yet.");
}
for (const FlexLine* line = lines.getFirst(); line;
line = line->getNext()) {
ComputedFlexLineInfo* lineInfo =
containerInfo->mLines.AppendElement();
// Most lineInfo properties will be set later, but we set
// mGrowthState to UNCHANGED here because it may be later
// modified by ResolveFlexibleLengths().
lineInfo->mGrowthState =
ComputedFlexLineInfo::GrowthState::UNCHANGED;
// The remaining lineInfo properties will be filled out at the
// end of this function, when we have real values. But we still
// add all the items here, so we can capture computed data for
// each item.
for (const FlexItem* item = line->GetFirstItem(); item;
item = item->getNext()) {
nsIFrame* frame = item->Frame();
// The frame may be for an element, or it may be for an
// anonymous flex item, e.g. wrapping one or more text nodes.
// 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 = content;
// mMainBaseSize and itemInfo->mMainDeltaSize will
// be filled out in ResolveFlexibleLengths().
// Other FlexItem properties can be captured now.
itemInfo->mMainMinSize = item->GetMainMinSize();
itemInfo->mMainMaxSize = item->GetMainMaxSize();
itemInfo->mCrossMinSize = item->GetCrossMinSize();
itemInfo->mCrossMaxSize = item->GetCrossMaxSize();
}
}
}
aContentBoxMainSize =
ResolveFlexContainerMainSize(aReflowInput, aAxisTracker,
aContentBoxMainSize, aAvailableBSizeForContent,
lines.getFirst(), aStatus);
uint32_t lineIndex = 0;
for (FlexLine* line = lines.getFirst(); line; line = line->getNext(),
++lineIndex) {
ComputedFlexLineInfo* lineInfo = containerInfo ?
&containerInfo->mLines[lineIndex] :
nullptr;
line->ResolveFlexibleLengths(aContentBoxMainSize, lineInfo);
for (FlexLine* line = lines.getFirst(); line; line = line->getNext()) {
line->ResolveFlexibleLengths(aContentBoxMainSize);
}
// Cross Size Determination - Flexbox spec section 9.4
@ -4714,19 +4463,6 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
aReflowInput, aStatus);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize)
// Finally update our line sizing values in our containerInfo.
if (containerInfo) {
uint32_t lineIndex = 0;
for (const FlexLine* line = lines.getFirst(); line;
line = line->getNext(), ++lineIndex) {
ComputedFlexLineInfo* lineInfo = &containerInfo->mLines[lineIndex];
lineInfo->mCrossSize = line->GetLineCrossSize();
lineInfo->mFirstBaselineOffset = line->GetFirstBaselineOffset();
lineInfo->mLastBaselineOffset = line->GetLastBaselineOffset();
}
}
}
void

Просмотреть файл

@ -20,54 +20,6 @@ class LogicalPoint;
nsContainerFrame* NS_NewFlexContainerFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
/**
* These structures are used to capture data during reflow to be
* extracted by devtools via Chrome APIs. The structures are only
* created when requested in GetFlexFrameWithComputedInfo(), and
* the structures are attached to the nsFlexContainerFrame via the
* FlexContainerInfo property.
*/
struct ComputedFlexItemInfo
{
nsCOMPtr<nsINode> mNode;
/**
* mMainBaseSize is a measure of the size of the item in the main
* axis before the flex sizing algorithm is applied. In the spec,
* this is called "flex base size", but we use this name to connect
* the value to the other main axis sizes.
*/
nscoord mMainBaseSize;
/**
* mMainDeltaSize is the value that the flex sizing algorithm
* "wants" to use to stretch or shrink the item, before clamping to
* the item's main min and max sizes. Since the flex sizing
* algorithm proceeds linearly, the mMainDeltaSize for an item only
* respects the resolved size of items already frozen.
*/
nscoord mMainDeltaSize;
nscoord mMainMinSize;
nscoord mMainMaxSize;
nscoord mCrossMinSize;
nscoord mCrossMaxSize;
};
struct ComputedFlexLineInfo
{
nsTArray<ComputedFlexItemInfo> mItems;
nscoord mCrossSize;
nscoord mFirstBaselineOffset;
nscoord mLastBaselineOffset;
enum GrowthState {
UNCHANGED,
SHRINKING,
GROWING,
} mGrowthState;
};
struct ComputedFlexContainerInfo
{
nsTArray<ComputedFlexLineInfo> mLines;
};
/**
* This is the rendering object used for laying out elements with
@ -156,49 +108,25 @@ public:
bool IsHorizontal();
/**
* Helper function to calculate packing space and initial offset of alignment
* subjects in MainAxisPositionTracker() and CrossAxisPositionTracker() for
* space-between, space-around, and space-evenly.
* * @param aNumThingsToPack Number of alignment subjects.
* @param aAlignVal Value for align-self or justify-self.
* @param aFirstSubjectOffset Outparam for first subject offset.
* @param aNumPackingSpacesRemaining Outparam for number of equal-sized
* packing spaces to apply between each
* alignment subject.
* @param aPackingSpaceRemaining Outparam for total amount of packing
* space to be divided up.
*/
* Helper function to calculate packing space and initial offset of alignment
* subjects in MainAxisPositionTracker() and CrossAxisPositionTracker() for
* space-between, space-around, and space-evenly.
*
* @param aNumThingsToPack Number of alignment subjects.
* @param aAlignVal Value for align-self or justify-self.
* @param aFirstSubjectOffset Outparam for first subject offset.
* @param aNumPackingSpacesRemaining Outparam for number of equal-sized
* packing spaces to apply between each
* alignment subject.
* @param aPackingSpaceRemaining Outparam for total amount of packing
* space to be divided up.
*/
static void CalculatePackingSpace(uint32_t aNumThingsToPack,
uint8_t aAlignVal,
nscoord* aFirstSubjectOffset,
uint32_t* aNumPackingSpacesRemaining,
nscoord* aPackingSpaceRemaining);
/**
* This property is created by a call to
* nsFlexContainerFrame::GetFlexFrameWithComputedInfo.
*/
NS_DECLARE_FRAME_PROPERTY_DELETABLE(FlexContainerInfo, ComputedFlexContainerInfo)
/**
* This function should only be called on a nsFlexContainerFrame
* that has just been returned by a call to
* GetFlexFrameWithComputedInfo.
*/
const ComputedFlexContainerInfo* GetFlexContainerInfo()
{
const ComputedFlexContainerInfo* info = GetProperty(FlexContainerInfo());
MOZ_ASSERT(info, "Property generation wasn't requested.");
return info;
}
/**
* Return aFrame as a flex frame after ensuring it has computed flex info.
* @return nullptr if aFrame is null or doesn't have a flex frame
* as its content insertion frame.
* @note this might destroy layout/style data since it may flush layout.
*/
static nsFlexContainerFrame* GetFlexFrameWithComputedInfo(nsIFrame* aFrame);
protected:
// Protected constructor & destructor
explicit nsFlexContainerFrame(nsStyleContext* aContext)

Просмотреть файл

@ -323,11 +323,8 @@ FRAME_STATE_BIT(FlexContainer, 20, NS_STATE_FLEX_NORMAL_FLOW_CHILDREN_IN_CSS_ORD
// 'display:-webkit-{inline-}box' container.
FRAME_STATE_BIT(FlexContainer, 21, NS_STATE_FLEX_IS_LEGACY_WEBKIT_BOX)
// True iff computed flex values should be generated on the next reflow
FRAME_STATE_BIT(FlexContainer, 22, NS_STATE_FLEX_GENERATE_COMPUTED_VALUES)
// True if the container has no flex items; may lie if there is a pending reflow
FRAME_STATE_BIT(FlexContainer, 23, NS_STATE_FLEX_SYNTHESIZE_BASELINE)
FRAME_STATE_BIT(FlexContainer, 22, NS_STATE_FLEX_SYNTHESIZE_BASELINE)
// == Frame state bits that apply to grid container frames ====================