Convert flex item margin/border/padding computations to use logical axes
Categories
(Core :: Layout: Flexbox, defect)
Tracking
()
People
(Reporter: dholbert, Assigned: TYLin)
References
(Blocks 1 open bug)
Details
Attachments
(16 files)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
Bug 1155772 Part 5 - Cache flex container's logical axis and writing-mode in PositionTracker. r=mats
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
Assignee | ||
Comment 1•5 years ago
•
|
||
I look at this a bit, I think we'll need to
- Change
FlexItem::{mBorderPadding,mMargin}
to store inLogicalMargin
. I'm not sure which writing-mode we should use to store theLogicalMargin
. It's straitforward to use flex item's writing-mode because it is fromReflowInput
, but flex algorithm seems need to use flex container's writing-mode most of the cases. - Eliminate
AxisOrientationType
andFlexboxAxisTracker::{GetMainAxis(),GetCrossAxis()}
, and useFlexboxAxisTracker::{IsRowOriented(),IsColumnOriented}
instead. - Search for
XXXdholbert [BEGIN DEPRECATED]
, and delete those code.
Did I miss anything?
Reporter | ||
Comment 2•5 years ago
|
||
(In reply to Ting-Yu Lin [:TYLin] (UTC-8) (Traveling Nov 23 - Dec 15) from comment #1)
I look at this a bit, I think we'll need to
- Change
FlexItem::{mBorderPadding,mMargin}
to store inLogicalMargin
. I'm not sure which writing-mode we should use to store theLogicalMargin
. It's straitforward to use flex item's writing-mode because it is fromReflowInput
, but flex algorithm seems need to use flex container's writing-mode most of the cases.
Yeah, we should pick whichever is more convenient in terms of usage. I suspect the flex container's WM is the more commonly-needed one. This will involve minor tweaks/rewriting of a bunch of small APIs, I think, but hopefully they're all pretty straightforward.
- Eliminate
AxisOrientationType
andFlexboxAxisTracker::{GetMainAxis(),GetCrossAxis()}
, and use `FlexboxAxisTracker::{IsRowOriented(),IsColumnOriented} instead.
(Also the kAxisOrientationToSidesMap
struct, which is indexed in part by AxisOrientationType
and is currently only used for physical-margin/border-side related stuff, I believe. Probably all/most of its usages will be removed in (1).)
- Search for
XXXdholbert [BEGIN DEPRECATED]
, and delete those code.
Yeah -- I think that should cover it for this bug! Thanks for taking a look.
Assignee | ||
Comment 3•5 years ago
|
||
Fix "warning: deleted member function should be public", which can be
reproduced by
./mach static-analysis check layout/generic/nsFlexContainerFrame.cpp
If a private delete method is called, the compiler shows two error
messages: the method is deleted, and a private methods is called. By
declaring the method as public, only the former message is shown, which
should be more readable.
Updated•5 years ago
|
Assignee | ||
Comment 4•5 years ago
|
||
I'm going to add logical accessors and variables in the next patch, so
it's better the rename the old ones first.
Depends on D59043
Assignee | ||
Comment 5•5 years ago
|
||
Depends on D59044
Assignee | ||
Comment 6•5 years ago
|
||
This includes renaming aAxis to aPhysicalAxis in PositionTracker's
constructor.
Depends on D59045
Assignee | ||
Comment 7•5 years ago
|
||
They are going to be used in the later parts.
Depends on D59046
Assignee | ||
Comment 8•5 years ago
|
||
These new added member variables are going to be used in the following
parts that convert border/padding/margin to use logical layout, so they
are added to the place prior to mBorderPadding and mMargin.
Also, move flex item's own writing-mode mWM
for readability.
For "strut" constructor, we can use the default values for mMainAxis,
mCrossAxis, and mIsInlineAxisMainAxis initialized in the class
declaration.
Depends on D59047
Assignee | ||
Comment 9•5 years ago
|
||
Also delete unused GetBorderPadding().
Depends on D59048
Assignee | ||
Comment 10•5 years ago
|
||
Also, use GetPhysicalMargin() instead of mMargin in
FlexItem::GetBaselineOffsetFromOuterCrossEdge() to ease the transition
when converting FlexItem::mMargin to LogicalMargin in the later parts.
Depends on D59049
Assignee | ||
Comment 11•5 years ago
|
||
Note that I return LogicalMargin by value for GetMargin(). It is
considered a suboptimal practice to return a constant reference to a
member variable. We won't gain performance by returning a reference
because the compiler can optimize the return value. If it were assigned
to a new variable, the copy/move constructor is called anyway.
It can also break encapsulation if the caller removes the const
deliberately by something like
const_cast<LogicalMargin&>(item->GetMargin()) = LogicalMargin(...);
As noted in FIXME(TYLin), the AxisOrientationType argument in
GetMarginBorderPaddingSizeInMainAxis() and many other methods can be
removed. However, to make the patch size manageable, I'll remove them in
a later part.
Depends on D59050
Assignee | ||
Comment 12•5 years ago
|
||
Depends on D59051
Assignee | ||
Comment 13•5 years ago
|
||
Also, remove unused FlexboxAxisTracker argument from
ResolveStretchedCrossSize().
Depends on D59052
Assignee | ||
Comment 14•5 years ago
|
||
Depends on D59053
Assignee | ||
Comment 15•5 years ago
|
||
The original physical axis AxisOrientationType contains direction
information, which can be replaced by physical start side
straightforwardly.
Depends on D59054
Assignee | ||
Comment 16•5 years ago
|
||
Depends on D59055
Assignee | ||
Comment 17•5 years ago
|
||
Depends on D59056
Assignee | ||
Comment 18•5 years ago
|
||
Depends on D59057
Updated•5 years ago
|
Comment 19•5 years ago
|
||
Comment 20•5 years ago
|
||
Backed out for bustages on WritingModes.h
backout: https://hg.mozilla.org/integration/autoland/rev/5914beb11d5c24fc83bc1e2bfb28281b42facf9f
failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=285822980&repo=autoland&lineNumber=43427
[task 2020-01-21T20:15:07.759Z] 20:15:07 INFO - In file included from /builds/worker/workspace/build/src/layout/generic/nsIFrame.h:59:0,
[task 2020-01-21T20:15:07.759Z] 20:15:07 INFO - from /builds/worker/workspace/build/src/layout/generic/ScrollbarActivity.cpp:11,
[task 2020-01-21T20:15:07.759Z] 20:15:07 INFO - from Unified_cpp_layout_generic1.cpp:11:
[task 2020-01-21T20:15:07.759Z] 20:15:07 INFO - /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/WritingModes.h: In member function 'nscoord& mozilla::LogicalMargin::Side(mozilla::LogicalSide, mozilla::WritingMode)':
[task 2020-01-21T20:15:07.759Z] 20:15:07 ERROR - /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/WritingModes.h:1253:3: error: control reaches end of non-void function [-Werror=return-type]
[task 2020-01-21T20:15:07.759Z] 20:15:07 INFO - }
[task 2020-01-21T20:15:07.759Z] 20:15:07 INFO - ^
[task 2020-01-21T20:15:07.759Z] 20:15:07 INFO - /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/WritingModes.h: In member function 'nscoord mozilla::LogicalMargin::Side(mozilla::LogicalSide, mozilla::WritingMode) const':
[task 2020-01-21T20:15:07.759Z] 20:15:07 ERROR - /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/WritingModes.h:1241:3: error: control reaches end of non-void function [-Werror=return-type]
Assignee | ||
Comment 21•5 years ago
|
||
OK. This is a build failure for warnings on only g++. For a code snippet like the following, clang is smart enough to know that we have handled all the cases in LogicalSide
enum in the switch-statement, so the code flow never reaches after the switch, but g++ does not aware of this.
nscoord Side(LogicalSide aSide, WritingMode aWM) const {
switch (aSide) {
case eLogicalSideBStart:
return BStart(aWM);
case eLogicalSideBEnd:
return BEnd(aWM);
case eLogicalSideIStart:
return IStart(aWM);
case eLogicalSideIEnd:
return IEnd(aWM);
}
Both Part 9 & Part 13 contain such switch statements that can trigger this kind of warnings.
I'll add an assertion and dumb return value at the end of the function.
MOZ_ASSERT_UNREACHABLE("We should handle all sides!");
return BStart(aWM);
Comment 22•5 years ago
|
||
Comment 23•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8503dcdda2c4
https://hg.mozilla.org/mozilla-central/rev/c887483fa25b
https://hg.mozilla.org/mozilla-central/rev/075afaa25ee6
https://hg.mozilla.org/mozilla-central/rev/e42d916c6011
https://hg.mozilla.org/mozilla-central/rev/fd73bbfddf8c
https://hg.mozilla.org/mozilla-central/rev/2babcfb213c5
https://hg.mozilla.org/mozilla-central/rev/bfd7c1c2accc
https://hg.mozilla.org/mozilla-central/rev/ea81b8962a19
https://hg.mozilla.org/mozilla-central/rev/d03d935a66df
https://hg.mozilla.org/mozilla-central/rev/d4e98d652bc3
https://hg.mozilla.org/mozilla-central/rev/54e1f82768fd
https://hg.mozilla.org/mozilla-central/rev/ba772f194d56
https://hg.mozilla.org/mozilla-central/rev/0e8361f9069e
https://hg.mozilla.org/mozilla-central/rev/615c3a987954
https://hg.mozilla.org/mozilla-central/rev/38150b46f038
https://hg.mozilla.org/mozilla-central/rev/d3fd7085836b
Updated•5 years ago
|
Assignee | ||
Updated•4 years ago
|
Description
•