2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-12-27 21:58:37 +04:00
|
|
|
/* 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 WritingModes_h_
|
|
|
|
#define WritingModes_h_
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
|
|
|
#include "mozilla/ComputedStyleInlines.h"
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
#include "nsRect.h"
|
2014-11-20 13:45:22 +03:00
|
|
|
#include "nsBidiUtils.h"
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
// It is the caller's responsibility to operate on logical-coordinate objects
|
|
|
|
// with matched writing modes. Failure to do so will be a runtime bug; the
|
|
|
|
// compiler can't catch it, but in debug mode, we'll throw an assertion.
|
|
|
|
// NOTE that in non-debug builds, a writing mode mismatch error will NOT be
|
|
|
|
// detected, yet the results will be nonsense (and may lead to further layout
|
|
|
|
// failures). Therefore, it is important to test (and fuzz-test) writing-mode
|
|
|
|
// support using debug builds.
|
|
|
|
|
|
|
|
// Methods in logical-coordinate classes that take another logical-coordinate
|
|
|
|
// object as a parameter should call CHECK_WRITING_MODE on it to verify that
|
|
|
|
// the writing modes match.
|
|
|
|
// (In some cases, there are internal (private) methods that don't do this;
|
|
|
|
// such methods should only be used by other methods that have already checked
|
|
|
|
// the writing modes.)
|
2019-09-09 07:49:55 +03:00
|
|
|
// The check ignores the StyleWritingMode_SIDEWAYS bit of writing mode, because
|
|
|
|
// this does not affect the interpretation of logical coordinates.
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
#define CHECK_WRITING_MODE(param) \
|
2015-11-05 18:38:53 +03:00
|
|
|
NS_ASSERTION(param.IgnoreSideways() == GetWritingMode().IgnoreSideways(), \
|
|
|
|
"writing-mode mismatch")
|
2013-12-27 21:58:37 +04:00
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
namespace mozilla {
|
2015-01-17 07:43:20 +03:00
|
|
|
|
2015-05-15 04:18:08 +03:00
|
|
|
namespace widget {
|
|
|
|
struct IMENotification;
|
|
|
|
} // namespace widget
|
|
|
|
|
2015-01-17 07:43:20 +03:00
|
|
|
// Physical axis constants.
|
|
|
|
enum PhysicalAxis { eAxisVertical = 0x0, eAxisHorizontal = 0x1 };
|
|
|
|
|
2016-10-21 03:45:07 +03:00
|
|
|
inline LogicalAxis GetOrthogonalAxis(LogicalAxis aAxis) {
|
|
|
|
return aAxis == eLogicalAxisBlock ? eLogicalAxisInline : eLogicalAxisBlock;
|
|
|
|
}
|
|
|
|
|
2015-01-17 07:22:51 +03:00
|
|
|
inline bool IsInline(LogicalSide aSide) { return aSide & 0x2; }
|
|
|
|
inline bool IsBlock(LogicalSide aSide) { return !IsInline(aSide); }
|
|
|
|
inline bool IsEnd(LogicalSide aSide) { return aSide & 0x1; }
|
|
|
|
inline bool IsStart(LogicalSide aSide) { return !IsEnd(aSide); }
|
|
|
|
|
|
|
|
inline LogicalAxis GetAxis(LogicalSide aSide) {
|
|
|
|
return IsInline(aSide) ? eLogicalAxisInline : eLogicalAxisBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline LogicalEdge GetEdge(LogicalSide aSide) {
|
|
|
|
return IsEnd(aSide) ? eLogicalEdgeEnd : eLogicalEdgeStart;
|
|
|
|
}
|
|
|
|
|
2015-01-22 06:04:55 +03:00
|
|
|
inline LogicalEdge GetOppositeEdge(LogicalEdge aEdge) {
|
|
|
|
// This relies on the only two LogicalEdge enum values being 0 and 1.
|
|
|
|
return LogicalEdge(1 - aEdge);
|
|
|
|
}
|
|
|
|
|
2015-01-17 07:22:51 +03:00
|
|
|
inline LogicalSide MakeLogicalSide(LogicalAxis aAxis, LogicalEdge aEdge) {
|
|
|
|
return LogicalSide((aAxis << 1) | aEdge);
|
|
|
|
}
|
2014-06-28 14:13:13 +04:00
|
|
|
|
2015-01-22 06:04:55 +03:00
|
|
|
inline LogicalSide GetOppositeSide(LogicalSide aSide) {
|
|
|
|
return MakeLogicalSide(GetAxis(aSide), GetOppositeEdge(GetEdge(aSide)));
|
|
|
|
}
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
enum LogicalSideBits {
|
|
|
|
eLogicalSideBitsNone = 0,
|
|
|
|
eLogicalSideBitsBStart = 1 << eLogicalSideBStart,
|
|
|
|
eLogicalSideBitsBEnd = 1 << eLogicalSideBEnd,
|
|
|
|
eLogicalSideBitsIEnd = 1 << eLogicalSideIEnd,
|
|
|
|
eLogicalSideBitsIStart = 1 << eLogicalSideIStart,
|
|
|
|
eLogicalSideBitsBBoth = eLogicalSideBitsBStart | eLogicalSideBitsBEnd,
|
|
|
|
eLogicalSideBitsIBoth = eLogicalSideBitsIStart | eLogicalSideBitsIEnd,
|
|
|
|
eLogicalSideBitsAll = eLogicalSideBitsBBoth | eLogicalSideBitsIBoth
|
|
|
|
};
|
|
|
|
|
2015-01-22 06:04:55 +03:00
|
|
|
enum LineRelativeDir {
|
|
|
|
eLineRelativeDirOver = eLogicalSideBStart,
|
|
|
|
eLineRelativeDirUnder = eLogicalSideBEnd,
|
|
|
|
eLineRelativeDirLeft = eLogicalSideIStart,
|
|
|
|
eLineRelativeDirRight = eLogicalSideIEnd
|
|
|
|
};
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
/**
|
|
|
|
* LogicalSides represents a set of logical sides.
|
|
|
|
*/
|
2015-03-21 19:28:04 +03:00
|
|
|
struct LogicalSides final {
|
2014-06-28 14:13:13 +04:00
|
|
|
LogicalSides() : mBits(0) {}
|
|
|
|
explicit LogicalSides(LogicalSideBits aSideBits) {
|
|
|
|
MOZ_ASSERT((aSideBits & ~eLogicalSideBitsAll) == 0, "illegal side bits");
|
|
|
|
mBits = aSideBits;
|
|
|
|
}
|
|
|
|
bool IsEmpty() const { return mBits == 0; }
|
|
|
|
bool BStart() const { return mBits & eLogicalSideBitsBStart; }
|
|
|
|
bool BEnd() const { return mBits & eLogicalSideBitsBEnd; }
|
|
|
|
bool IStart() const { return mBits & eLogicalSideBitsIStart; }
|
|
|
|
bool IEnd() const { return mBits & eLogicalSideBitsIEnd; }
|
|
|
|
bool Contains(LogicalSideBits aSideBits) const {
|
|
|
|
MOZ_ASSERT((aSideBits & ~eLogicalSideBitsAll) == 0, "illegal side bits");
|
|
|
|
return (mBits & aSideBits) == aSideBits;
|
|
|
|
}
|
|
|
|
LogicalSides operator|(LogicalSides aOther) const {
|
|
|
|
return LogicalSides(LogicalSideBits(mBits | aOther.mBits));
|
|
|
|
}
|
|
|
|
LogicalSides operator|(LogicalSideBits aSideBits) const {
|
|
|
|
return *this | LogicalSides(aSideBits);
|
|
|
|
}
|
|
|
|
LogicalSides& operator|=(LogicalSides aOther) {
|
|
|
|
mBits |= aOther.mBits;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
LogicalSides& operator|=(LogicalSideBits aSideBits) {
|
|
|
|
return *this |= LogicalSides(aSideBits);
|
|
|
|
}
|
|
|
|
bool operator==(LogicalSides aOther) const { return mBits == aOther.mBits; }
|
|
|
|
bool operator!=(LogicalSides aOther) const { return !(*this == aOther); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t mBits;
|
|
|
|
};
|
2014-06-24 21:52:19 +04:00
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
/**
|
|
|
|
* mozilla::WritingMode is an immutable class representing a
|
|
|
|
* writing mode.
|
|
|
|
*
|
|
|
|
* It efficiently stores the writing mode and can rapidly compute
|
|
|
|
* interesting things about it for use in layout.
|
|
|
|
*
|
|
|
|
* Writing modes are computed from the CSS 'direction',
|
|
|
|
* 'writing-mode', and 'text-orientation' properties.
|
|
|
|
* See CSS3 Writing Modes for more information
|
|
|
|
* http://www.w3.org/TR/css3-writing-modes/
|
|
|
|
*/
|
|
|
|
class WritingMode {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Absolute inline flow direction
|
|
|
|
*/
|
|
|
|
enum InlineDir {
|
|
|
|
eInlineLTR = 0x00, // text flows horizontally left to right
|
|
|
|
eInlineRTL = 0x02, // text flows horizontally right to left
|
|
|
|
eInlineTTB = 0x01, // text flows vertically top to bottom
|
|
|
|
eInlineBTT = 0x03, // text flows vertically bottom to top
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Absolute block flow direction
|
|
|
|
*/
|
|
|
|
enum BlockDir {
|
|
|
|
eBlockTB = 0x00, // horizontal lines stack top to bottom
|
|
|
|
eBlockRL = 0x01, // vertical lines stack right to left
|
|
|
|
eBlockLR = 0x05, // vertical lines stack left to right
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Line-relative (bidi-relative) inline flow direction
|
|
|
|
*/
|
|
|
|
enum BidiDir {
|
|
|
|
eBidiLTR = 0x00, // inline flow matches bidi LTR text
|
|
|
|
eBidiRTL = 0x10, // inline flow matches bidi RTL text
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unknown writing mode (should never actually be stored or used anywhere).
|
|
|
|
*/
|
|
|
|
enum { eUnknownWritingMode = 0xff };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the absolute inline flow direction as an InlineDir
|
|
|
|
*/
|
|
|
|
InlineDir GetInlineDir() const {
|
2019-09-09 07:49:55 +03:00
|
|
|
return InlineDir(mWritingMode.bits & eInlineMask);
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the absolute block flow direction as a BlockDir
|
|
|
|
*/
|
2019-09-09 07:49:55 +03:00
|
|
|
BlockDir GetBlockDir() const {
|
|
|
|
return BlockDir(mWritingMode.bits & eBlockMask);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the line-relative inline flow direction as a BidiDir
|
|
|
|
*/
|
2019-09-09 07:49:55 +03:00
|
|
|
BidiDir GetBidiDir() const {
|
|
|
|
return BidiDir((mWritingMode & StyleWritingMode_RTL).bits);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
2015-09-24 12:23:34 +03:00
|
|
|
* Return true if the inline flow direction is against physical direction
|
|
|
|
* (i.e. right-to-left or bottom-to-top).
|
|
|
|
* This occurs when writing-mode is sideways-lr OR direction is rtl (but not
|
|
|
|
* if both of those are true).
|
|
|
|
*/
|
2019-09-09 07:49:55 +03:00
|
|
|
bool IsInlineReversed() const {
|
|
|
|
return !!(mWritingMode & StyleWritingMode_INLINE_REVERSED);
|
|
|
|
}
|
2015-09-24 12:23:34 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if bidi direction is LTR. (Convenience method)
|
2013-12-27 21:58:37 +04:00
|
|
|
*/
|
2014-11-13 11:58:06 +03:00
|
|
|
bool IsBidiLTR() const { return eBidiLTR == GetBidiDir(); }
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if vertical-mode block direction is LR (convenience method).
|
|
|
|
*/
|
2014-11-13 11:58:06 +03:00
|
|
|
bool IsVerticalLR() const { return eBlockLR == GetBlockDir(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if vertical-mode block direction is RL (convenience method).
|
|
|
|
*/
|
|
|
|
bool IsVerticalRL() const { return eBlockRL == GetBlockDir(); }
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if vertical writing mode, i.e. when
|
|
|
|
* writing-mode: vertical-lr | vertical-rl.
|
|
|
|
*/
|
2019-09-09 07:49:55 +03:00
|
|
|
bool IsVertical() const {
|
|
|
|
return !!(mWritingMode & StyleWritingMode_VERTICAL);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* True if line-over/line-under are inverted from block-start/block-end.
|
2015-09-24 12:23:35 +03:00
|
|
|
* This is true only when writing-mode is vertical-lr.
|
2013-12-27 21:58:37 +04:00
|
|
|
*/
|
2019-09-09 07:49:55 +03:00
|
|
|
bool IsLineInverted() const {
|
|
|
|
return !!(mWritingMode & StyleWritingMode_LINE_INVERTED);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Block-axis flow-relative to line-relative factor.
|
|
|
|
* May be used as a multiplication factor for block-axis coordinates
|
|
|
|
* to convert between flow- and line-relative coordinate systems (e.g.
|
|
|
|
* positioning an over- or under-line decoration).
|
|
|
|
*/
|
|
|
|
int FlowRelativeToLineRelativeFactor() const {
|
|
|
|
return IsLineInverted() ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
2014-11-13 11:58:04 +03:00
|
|
|
/**
|
|
|
|
* True if the text-orientation will force all text to be rendered sideways
|
|
|
|
* in vertical lines, in which case we should prefer an alphabetic baseline;
|
|
|
|
* otherwise, the default is centered.
|
|
|
|
* Note that some glyph runs may be rendered sideways even if this is false,
|
|
|
|
* due to text-orientation:mixed resolution, but in that case the dominant
|
|
|
|
* baseline remains centered.
|
|
|
|
*/
|
2019-09-09 07:49:55 +03:00
|
|
|
bool IsSideways() const {
|
|
|
|
return !!(mWritingMode & StyleWritingMode_SIDEWAYS);
|
|
|
|
}
|
2014-11-13 11:58:04 +03:00
|
|
|
|
2015-11-05 18:38:53 +03:00
|
|
|
#ifdef DEBUG // Used by CHECK_WRITING_MODE to compare modes without regard
|
2019-09-09 07:49:55 +03:00
|
|
|
// for the StyleWritingMode_SIDEWAYS flag.
|
2015-11-05 18:38:53 +03:00
|
|
|
WritingMode IgnoreSideways() const {
|
2019-09-09 07:49:55 +03:00
|
|
|
return WritingMode(mWritingMode.bits & ~StyleWritingMode_SIDEWAYS.bits);
|
2015-11-05 18:38:53 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-06-03 18:43:00 +03:00
|
|
|
/**
|
|
|
|
* Return true if boxes with this writing mode should use central baselines.
|
|
|
|
*/
|
|
|
|
bool IsCentralBaseline() const { return IsVertical() && !IsSideways(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if boxes with this writing mode should use alphabetical
|
|
|
|
* baselines.
|
|
|
|
*/
|
|
|
|
bool IsAlphabeticalBaseline() const { return !IsCentralBaseline(); }
|
|
|
|
|
2015-01-17 07:43:20 +03:00
|
|
|
static mozilla::PhysicalAxis PhysicalAxisForLogicalAxis(
|
|
|
|
uint8_t aWritingModeValue, LogicalAxis aAxis) {
|
|
|
|
// This relies on bit 0 of a writing-value mode indicating vertical
|
|
|
|
// orientation and bit 0 of a LogicalAxis value indicating the inline axis,
|
|
|
|
// so that it can correctly form mozilla::PhysicalAxis values using bit
|
|
|
|
// manipulation.
|
|
|
|
static_assert(NS_STYLE_WRITING_MODE_HORIZONTAL_TB == 0 &&
|
|
|
|
NS_STYLE_WRITING_MODE_VERTICAL_RL == 1 &&
|
|
|
|
NS_STYLE_WRITING_MODE_VERTICAL_LR == 3 &&
|
|
|
|
eLogicalAxisBlock == 0 && eLogicalAxisInline == 1 &&
|
|
|
|
eAxisVertical == 0 && eAxisHorizontal == 1,
|
|
|
|
"unexpected writing-mode, logical axis or physical axis "
|
|
|
|
"constant values");
|
|
|
|
return mozilla::PhysicalAxis((aWritingModeValue ^ aAxis) & 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::PhysicalAxis PhysicalAxis(LogicalAxis aAxis) const {
|
|
|
|
// This will set wm to either NS_STYLE_WRITING_MODE_HORIZONTAL_TB or
|
|
|
|
// NS_STYLE_WRITING_MODE_VERTICAL_RL, and not the other two (real
|
|
|
|
// and hypothetical) values. But this is fine; we only need to
|
|
|
|
// distinguish between vertical and horizontal in
|
|
|
|
// PhysicalAxisForLogicalAxis.
|
2019-09-09 07:49:55 +03:00
|
|
|
const auto wm = (mWritingMode & StyleWritingMode_VERTICAL).bits;
|
2015-01-17 07:43:20 +03:00
|
|
|
return PhysicalAxisForLogicalAxis(wm, aAxis);
|
|
|
|
}
|
|
|
|
|
2015-01-17 07:22:51 +03:00
|
|
|
static mozilla::Side PhysicalSideForBlockAxis(uint8_t aWritingModeValue,
|
|
|
|
LogicalEdge aEdge) {
|
|
|
|
// indexes are NS_STYLE_WRITING_MODE_* values, which are the same as these
|
|
|
|
// two-bit values:
|
2019-09-09 07:49:55 +03:00
|
|
|
// bit 0 = the StyleWritingMode_VERTICAL value
|
|
|
|
// bit 1 = the StyleWritingMode_VERTICAL_LR value
|
2016-11-18 11:28:38 +03:00
|
|
|
static const mozilla::Side kLogicalBlockSides[][2] = {
|
2016-11-18 13:12:25 +03:00
|
|
|
{eSideTop, eSideBottom}, // horizontal-tb
|
|
|
|
{eSideRight, eSideLeft}, // vertical-rl
|
|
|
|
{eSideBottom, eSideTop}, // (horizontal-bt)
|
|
|
|
{eSideLeft, eSideRight}, // vertical-lr
|
2015-01-17 07:22:51 +03:00
|
|
|
};
|
|
|
|
|
2015-09-24 00:16:01 +03:00
|
|
|
// Ignore the SIDEWAYS_MASK bit of the writing-mode value, as this has no
|
|
|
|
// effect on the side mappings.
|
|
|
|
aWritingModeValue &= ~NS_STYLE_WRITING_MODE_SIDEWAYS_MASK;
|
|
|
|
|
|
|
|
// What's left of the writing-mode should be in the range 0-3:
|
2015-01-17 07:22:51 +03:00
|
|
|
NS_ASSERTION(aWritingModeValue < 4, "invalid aWritingModeValue value");
|
2015-09-24 00:16:01 +03:00
|
|
|
|
2015-01-17 07:22:51 +03:00
|
|
|
return kLogicalBlockSides[aWritingModeValue][aEdge];
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::Side PhysicalSideForInlineAxis(LogicalEdge aEdge) const {
|
|
|
|
// indexes are four-bit values:
|
2019-09-09 07:49:55 +03:00
|
|
|
// bit 0 = the StyleWritingMode_VERTICAL value
|
|
|
|
// bit 1 = the StyleWritingMode_INLINE_REVERSED value
|
|
|
|
// bit 2 = the StyleWritingMode_VERTICAL_LR value
|
|
|
|
// bit 3 = the StyleWritingMode_LINE_INVERTED value
|
2015-09-24 12:23:35 +03:00
|
|
|
// Not all of these combinations can actually be specified via CSS: there
|
|
|
|
// is no horizontal-bt writing-mode, and no text-orientation value that
|
|
|
|
// produces "inverted" text. (The former 'sideways-left' value, no longer
|
|
|
|
// in the spec, would have produced this in vertical-rl mode.)
|
2016-11-18 11:28:38 +03:00
|
|
|
static const mozilla::Side kLogicalInlineSides[][2] = {
|
2016-11-18 13:12:25 +03:00
|
|
|
{eSideLeft, eSideRight}, // horizontal-tb ltr
|
|
|
|
{eSideTop, eSideBottom}, // vertical-rl ltr
|
|
|
|
{eSideRight, eSideLeft}, // horizontal-tb rtl
|
|
|
|
{eSideBottom, eSideTop}, // vertical-rl rtl
|
|
|
|
{eSideRight, eSideLeft}, // (horizontal-bt) (inverted) ltr
|
|
|
|
{eSideTop, eSideBottom}, // sideways-lr rtl
|
|
|
|
{eSideLeft, eSideRight}, // (horizontal-bt) (inverted) rtl
|
|
|
|
{eSideBottom, eSideTop}, // sideways-lr ltr
|
|
|
|
{eSideLeft, eSideRight}, // horizontal-tb (inverted) rtl
|
|
|
|
{eSideTop, eSideBottom}, // vertical-rl (inverted) rtl
|
|
|
|
{eSideRight, eSideLeft}, // horizontal-tb (inverted) ltr
|
|
|
|
{eSideBottom, eSideTop}, // vertical-rl (inverted) ltr
|
|
|
|
{eSideLeft, eSideRight}, // (horizontal-bt) ltr
|
|
|
|
{eSideTop, eSideBottom}, // vertical-lr ltr
|
|
|
|
{eSideRight, eSideLeft}, // (horizontal-bt) rtl
|
|
|
|
{eSideBottom, eSideTop}, // vertical-lr rtl
|
2015-01-17 07:22:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// Inline axis sides depend on all three of writing-mode, text-orientation
|
2019-09-09 07:49:55 +03:00
|
|
|
// and direction, which are encoded in the StyleWritingMode_VERTICAL,
|
|
|
|
// StyleWritingMode_INLINE_REVERSED, StyleWritingMode_VERTICAL_LR and
|
|
|
|
// StyleWritingMode_LINE_INVERTED bits. Use these four bits to index into
|
|
|
|
// kLogicalInlineSides.
|
|
|
|
MOZ_ASSERT(StyleWritingMode_VERTICAL.bits == 0x01 &&
|
|
|
|
StyleWritingMode_INLINE_REVERSED.bits == 0x02 &&
|
|
|
|
StyleWritingMode_VERTICAL_LR.bits == 0x04 &&
|
|
|
|
StyleWritingMode_LINE_INVERTED.bits == 0x08,
|
|
|
|
"unexpected mask values");
|
|
|
|
int index = mWritingMode.bits & 0x0F;
|
2015-01-17 07:22:51 +03:00
|
|
|
return kLogicalInlineSides[index][aEdge];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the physical side corresponding to the specified logical side,
|
|
|
|
* given the current writing mode.
|
|
|
|
*/
|
|
|
|
mozilla::Side PhysicalSide(LogicalSide aSide) const {
|
|
|
|
if (IsBlock(aSide)) {
|
2019-09-09 07:49:55 +03:00
|
|
|
MOZ_ASSERT(StyleWritingMode_VERTICAL.bits == 0x01 &&
|
|
|
|
StyleWritingMode_VERTICAL_LR.bits == 0x04,
|
|
|
|
"unexpected mask values");
|
|
|
|
const auto wm = static_cast<uint8_t>(
|
|
|
|
((mWritingMode & StyleWritingMode_VERTICAL_LR).bits >> 1) |
|
|
|
|
(mWritingMode & StyleWritingMode_VERTICAL).bits);
|
2015-01-17 07:22:51 +03:00
|
|
|
return PhysicalSideForBlockAxis(wm, GetEdge(aSide));
|
|
|
|
}
|
|
|
|
|
|
|
|
return PhysicalSideForInlineAxis(GetEdge(aSide));
|
|
|
|
}
|
|
|
|
|
2015-07-03 13:37:25 +03:00
|
|
|
/**
|
|
|
|
* Returns the logical side corresponding to the specified physical side,
|
|
|
|
* given the current writing mode.
|
|
|
|
* (This is the inverse of the PhysicalSide() method above.)
|
|
|
|
*/
|
2016-11-18 11:28:38 +03:00
|
|
|
LogicalSide LogicalSideForPhysicalSide(mozilla::Side aSide) const {
|
2018-12-05 21:44:03 +03:00
|
|
|
// clang-format off
|
2015-07-03 13:37:25 +03:00
|
|
|
// indexes are four-bit values:
|
2019-09-09 07:49:55 +03:00
|
|
|
// bit 0 = the StyleWritingMode_VERTICAL value
|
|
|
|
// bit 1 = the StyleWritingMode_INLINE_REVERSED value
|
|
|
|
// bit 2 = the StyleWritingMode_VERTICAL_LR value
|
|
|
|
// bit 3 = the StyleWritingMode_LINE_INVERTED value
|
2015-07-03 13:37:25 +03:00
|
|
|
static const LogicalSide kPhysicalToLogicalSides[][4] = {
|
2018-12-05 21:44:03 +03:00
|
|
|
// top right
|
|
|
|
// bottom left
|
|
|
|
{ eLogicalSideBStart, eLogicalSideIEnd,
|
|
|
|
eLogicalSideBEnd, eLogicalSideIStart }, // horizontal-tb ltr
|
|
|
|
{ eLogicalSideIStart, eLogicalSideBStart,
|
|
|
|
eLogicalSideIEnd, eLogicalSideBEnd }, // vertical-rl ltr
|
|
|
|
{ eLogicalSideBStart, eLogicalSideIStart,
|
|
|
|
eLogicalSideBEnd, eLogicalSideIEnd }, // horizontal-tb rtl
|
|
|
|
{ eLogicalSideIEnd, eLogicalSideBStart,
|
|
|
|
eLogicalSideIStart, eLogicalSideBEnd }, // vertical-rl rtl
|
|
|
|
{ eLogicalSideBEnd, eLogicalSideIStart,
|
|
|
|
eLogicalSideBStart, eLogicalSideIEnd }, // (horizontal-bt) (inv) ltr
|
|
|
|
{ eLogicalSideIStart, eLogicalSideBEnd,
|
|
|
|
eLogicalSideIEnd, eLogicalSideBStart }, // vertical-lr sw-left rtl
|
|
|
|
{ eLogicalSideBEnd, eLogicalSideIEnd,
|
|
|
|
eLogicalSideBStart, eLogicalSideIStart }, // (horizontal-bt) (inv) rtl
|
|
|
|
{ eLogicalSideIEnd, eLogicalSideBEnd,
|
|
|
|
eLogicalSideIStart, eLogicalSideBStart }, // vertical-lr sw-left ltr
|
|
|
|
{ eLogicalSideBStart, eLogicalSideIEnd,
|
|
|
|
eLogicalSideBEnd, eLogicalSideIStart }, // horizontal-tb (inv) rtl
|
|
|
|
{ eLogicalSideIStart, eLogicalSideBStart,
|
|
|
|
eLogicalSideIEnd, eLogicalSideBEnd }, // vertical-rl sw-left rtl
|
|
|
|
{ eLogicalSideBStart, eLogicalSideIStart,
|
|
|
|
eLogicalSideBEnd, eLogicalSideIEnd }, // horizontal-tb (inv) ltr
|
|
|
|
{ eLogicalSideIEnd, eLogicalSideBStart,
|
|
|
|
eLogicalSideIStart, eLogicalSideBEnd }, // vertical-rl sw-left ltr
|
|
|
|
{ eLogicalSideBEnd, eLogicalSideIEnd,
|
|
|
|
eLogicalSideBStart, eLogicalSideIStart }, // (horizontal-bt) ltr
|
|
|
|
{ eLogicalSideIStart, eLogicalSideBEnd,
|
|
|
|
eLogicalSideIEnd, eLogicalSideBStart }, // vertical-lr ltr
|
|
|
|
{ eLogicalSideBEnd, eLogicalSideIStart,
|
|
|
|
eLogicalSideBStart, eLogicalSideIEnd }, // (horizontal-bt) rtl
|
|
|
|
{ eLogicalSideIEnd, eLogicalSideBEnd,
|
|
|
|
eLogicalSideIStart, eLogicalSideBStart }, // vertical-lr rtl
|
2015-07-03 13:37:25 +03:00
|
|
|
};
|
2018-12-05 21:44:03 +03:00
|
|
|
// clang-format on
|
2015-07-03 13:37:25 +03:00
|
|
|
|
2019-09-09 07:49:55 +03:00
|
|
|
MOZ_ASSERT(StyleWritingMode_VERTICAL.bits == 0x01 &&
|
|
|
|
StyleWritingMode_INLINE_REVERSED.bits == 0x02 &&
|
|
|
|
StyleWritingMode_VERTICAL_LR.bits == 0x04 &&
|
|
|
|
StyleWritingMode_LINE_INVERTED.bits == 0x08,
|
|
|
|
"unexpected mask values");
|
|
|
|
int index = mWritingMode.bits & 0x0F;
|
2015-07-03 13:37:25 +03:00
|
|
|
return kPhysicalToLogicalSides[index][aSide];
|
|
|
|
}
|
|
|
|
|
2015-01-22 06:04:55 +03:00
|
|
|
/**
|
2015-03-14 08:46:33 +03:00
|
|
|
* Returns the logical side corresponding to the specified
|
2015-01-22 06:04:55 +03:00
|
|
|
* line-relative direction, given the current writing mode.
|
|
|
|
*/
|
2015-03-14 08:46:33 +03:00
|
|
|
LogicalSide LogicalSideForLineRelativeDir(LineRelativeDir aDir) const {
|
|
|
|
auto side = static_cast<LogicalSide>(aDir);
|
|
|
|
if (IsInline(side)) {
|
2016-11-17 09:10:55 +03:00
|
|
|
return IsBidiLTR() ? side : GetOppositeSide(side);
|
2015-01-22 06:04:55 +03:00
|
|
|
}
|
2015-03-14 08:46:33 +03:00
|
|
|
return !IsLineInverted() ? side : GetOppositeSide(side);
|
2015-01-22 06:04:55 +03:00
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
/**
|
|
|
|
* Default constructor gives us a horizontal, LTR writing mode.
|
|
|
|
* XXX We will probably eliminate this and require explicit initialization
|
|
|
|
* in all cases once transition is complete.
|
|
|
|
*/
|
2019-09-09 07:49:55 +03:00
|
|
|
WritingMode() : mWritingMode{0} {}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
2018-03-23 16:49:21 +03:00
|
|
|
* Construct writing mode based on a ComputedStyle.
|
2013-12-27 21:58:37 +04:00
|
|
|
*/
|
2019-08-16 14:43:36 +03:00
|
|
|
explicit WritingMode(const ComputedStyle* aComputedStyle) {
|
2018-03-22 21:20:41 +03:00
|
|
|
NS_ASSERTION(aComputedStyle, "we need an ComputedStyle here");
|
2019-09-09 07:49:55 +03:00
|
|
|
mWritingMode = aComputedStyle->WritingMode();
|
2015-10-23 02:57:34 +03:00
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
2015-09-17 11:53:49 +03:00
|
|
|
/**
|
|
|
|
* This function performs fixup for elements with 'unicode-bidi: plaintext',
|
|
|
|
* where inline directionality is derived from the Unicode bidi categories
|
|
|
|
* of the element's content, and not the CSS 'direction' property.
|
|
|
|
*
|
|
|
|
* The WritingMode constructor will have already incorporated the 'direction'
|
|
|
|
* property into our flag bits, so such elements need to use this method
|
|
|
|
* (after resolving the bidi level of their content) to update the direction
|
|
|
|
* bits as needed.
|
|
|
|
*
|
|
|
|
* If it turns out that our bidi direction already matches what plaintext
|
|
|
|
* resolution determined, there's nothing to do here. If it didn't (i.e. if
|
|
|
|
* the rtl-ness doesn't match), then we correct the direction by flipping the
|
|
|
|
* same bits that get flipped in the constructor's CSS 'direction'-based
|
|
|
|
* chunk.
|
|
|
|
*
|
|
|
|
* XXX change uint8_t to UBiDiLevel after bug 924851
|
|
|
|
*/
|
2014-02-13 11:55:08 +04:00
|
|
|
void SetDirectionFromBidiLevel(uint8_t level) {
|
2015-09-17 11:53:49 +03:00
|
|
|
if (IS_LEVEL_RTL(level) == IsBidiLTR()) {
|
2019-09-09 07:49:55 +03:00
|
|
|
mWritingMode ^= StyleWritingMode_RTL | StyleWritingMode_INLINE_REVERSED;
|
2014-02-13 11:55:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
/**
|
|
|
|
* Compare two WritingModes for equality.
|
|
|
|
*/
|
|
|
|
bool operator==(const WritingMode& aOther) const {
|
|
|
|
return mWritingMode == aOther.mWritingMode;
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
bool operator!=(const WritingMode& aOther) const {
|
|
|
|
return mWritingMode != aOther.mWritingMode;
|
|
|
|
}
|
|
|
|
|
2014-09-03 19:43:03 +04:00
|
|
|
/**
|
|
|
|
* Check whether two modes are orthogonal to each other.
|
|
|
|
*/
|
|
|
|
bool IsOrthogonalTo(const WritingMode& aOther) const {
|
|
|
|
return IsVertical() != aOther.IsVertical();
|
|
|
|
}
|
|
|
|
|
2016-10-21 03:45:07 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this WritingMode's aLogicalAxis has the same physical
|
|
|
|
* start side as the parallel axis of WritingMode |aOther|.
|
|
|
|
*
|
|
|
|
* @param aLogicalAxis The axis to compare from this WritingMode.
|
|
|
|
* @param aOther The other WritingMode (from which we'll choose the axis
|
|
|
|
* that's parallel to this WritingMode's aLogicalAxis, for
|
|
|
|
* comparison).
|
|
|
|
*/
|
|
|
|
bool ParallelAxisStartsOnSameSide(LogicalAxis aLogicalAxis,
|
|
|
|
const WritingMode& aOther) const {
|
2018-01-31 10:24:30 +03:00
|
|
|
mozilla::Side myStartSide =
|
2016-10-21 03:45:07 +03:00
|
|
|
this->PhysicalSide(MakeLogicalSide(aLogicalAxis, eLogicalEdgeStart));
|
|
|
|
|
|
|
|
// Figure out which of aOther's axes is parallel to |this| WritingMode's
|
|
|
|
// aLogicalAxis, and get its physical start side as well.
|
|
|
|
LogicalAxis otherWMAxis = aOther.IsOrthogonalTo(*this)
|
|
|
|
? GetOrthogonalAxis(aLogicalAxis)
|
|
|
|
: aLogicalAxis;
|
2018-01-31 10:24:30 +03:00
|
|
|
mozilla::Side otherWMStartSide =
|
2016-10-21 03:45:07 +03:00
|
|
|
aOther.PhysicalSide(MakeLogicalSide(otherWMAxis, eLogicalEdgeStart));
|
|
|
|
|
|
|
|
NS_ASSERTION(myStartSide % 2 == otherWMStartSide % 2,
|
|
|
|
"Should end up with sides in the same physical axis");
|
|
|
|
return myStartSide == otherWMStartSide;
|
|
|
|
}
|
|
|
|
|
2019-09-09 07:49:55 +03:00
|
|
|
uint8_t GetBits() const { return mWritingMode.bits; }
|
2015-06-23 04:48:17 +03:00
|
|
|
|
2015-09-24 00:16:11 +03:00
|
|
|
const char* DebugString() const {
|
|
|
|
return IsVertical()
|
|
|
|
? IsVerticalLR()
|
|
|
|
? IsBidiLTR() ? IsSideways() ? "sw-lr-ltr" : "v-lr-ltr"
|
|
|
|
: IsSideways() ? "sw-lr-rtl" : "v-lr-rtl"
|
|
|
|
: IsBidiLTR() ? IsSideways() ? "sw-rl-ltr" : "v-rl-ltr"
|
|
|
|
: IsSideways() ? "sw-rl-rtl" : "v-rl-rtl"
|
|
|
|
: IsBidiLTR() ? "h-ltr" : "h-rtl";
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
private:
|
|
|
|
friend class LogicalPoint;
|
|
|
|
friend class LogicalSize;
|
|
|
|
friend class LogicalMargin;
|
|
|
|
friend class LogicalRect;
|
|
|
|
|
2014-12-05 05:15:43 +03:00
|
|
|
friend struct IPC::ParamTraits<WritingMode>;
|
2015-05-15 04:18:08 +03:00
|
|
|
// IMENotification cannot store this class directly since this has some
|
|
|
|
// constructors. Therefore, it stores mWritingMode and recreate the
|
|
|
|
// instance from it.
|
|
|
|
friend struct widget::IMENotification;
|
2014-12-05 05:15:43 +03:00
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
/**
|
|
|
|
* Return a WritingMode representing an unknown value.
|
|
|
|
*/
|
|
|
|
static inline WritingMode Unknown() {
|
|
|
|
return WritingMode(eUnknownWritingMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructing a WritingMode with an arbitrary value is a private operation
|
2019-09-09 07:49:55 +03:00
|
|
|
* currently only used by the Unknown() and IgnoreSideways() methods.
|
2013-12-27 21:58:37 +04:00
|
|
|
*/
|
2019-09-09 07:49:55 +03:00
|
|
|
explicit WritingMode(uint8_t aValue) : mWritingMode{aValue} {}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
2019-09-09 07:49:55 +03:00
|
|
|
StyleWritingMode mWritingMode;
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
enum Masks {
|
|
|
|
// Masks for output enums
|
2019-09-09 07:49:55 +03:00
|
|
|
eInlineMask = 0x03, // VERTICAL | INLINE_REVERSED
|
|
|
|
eBlockMask = 0x05, // VERTICAL | VERTICAL_LR
|
2013-12-27 21:58:37 +04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logical-coordinate classes:
|
|
|
|
*
|
|
|
|
* There are three sets of coordinate space:
|
|
|
|
* - physical (top, left, bottom, right)
|
|
|
|
* relative to graphics coord system
|
|
|
|
* - flow-relative (block-start, inline-start, block-end, inline-end)
|
|
|
|
* relative to block/inline flow directions
|
|
|
|
* - line-relative (line-over, line-left, line-under, line-right)
|
|
|
|
* relative to glyph orientation / inline bidi directions
|
|
|
|
* See CSS3 Writing Modes for more information
|
|
|
|
* http://www.w3.org/TR/css3-writing-modes/#abstract-box
|
|
|
|
*
|
|
|
|
* For shorthand, B represents the block-axis
|
|
|
|
* I represents the inline-axis
|
|
|
|
*
|
|
|
|
* The flow-relative geometric classes store coords in flow-relative space.
|
|
|
|
* They use a private ns{Point,Size,Rect,Margin} member to store the actual
|
|
|
|
* coordinate values, but reinterpret them as logical instead of physical.
|
|
|
|
* This allows us to easily perform calculations in logical space (provided
|
|
|
|
* writing modes of the operands match), by simply mapping to nsPoint (etc)
|
|
|
|
* methods.
|
|
|
|
*
|
|
|
|
* Physical-coordinate accessors/setters are responsible to translate these
|
|
|
|
* internal logical values as necessary.
|
|
|
|
*
|
|
|
|
* In DEBUG builds, the logical types store their WritingMode and check
|
|
|
|
* that the same WritingMode is passed whenever callers ask them to do a
|
|
|
|
* writing-mode-dependent operation. Non-DEBUG builds do NOT check this,
|
|
|
|
* to avoid the overhead of storing WritingMode fields.
|
|
|
|
*
|
|
|
|
* Open question: do we need a different set optimized for line-relative
|
|
|
|
* math, for use in nsLineLayout and the like? Or is multiplying values
|
|
|
|
* by FlowRelativeToLineRelativeFactor() enough?
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flow-relative point
|
|
|
|
*/
|
|
|
|
class LogicalPoint {
|
|
|
|
public:
|
2014-08-08 03:48:38 +04:00
|
|
|
explicit LogicalPoint(WritingMode aWritingMode)
|
2013-12-27 21:58:37 +04:00
|
|
|
:
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
|
|
|
mPoint(0, 0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct from a writing mode and individual coordinates (which MUST be
|
|
|
|
// values in that writing mode, NOT physical coordinates!)
|
|
|
|
LogicalPoint(WritingMode aWritingMode, nscoord aI, nscoord aB)
|
|
|
|
:
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
|
|
|
mPoint(aI, aB) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct from a writing mode and a physical point, within a given
|
2015-07-16 12:07:57 +03:00
|
|
|
// containing rectangle's size (defining the conversion between LTR
|
2015-07-16 12:08:05 +03:00
|
|
|
// and RTL coordinates, and between TTB and BTT coordinates).
|
2013-12-27 21:58:37 +04:00
|
|
|
LogicalPoint(WritingMode aWritingMode, const nsPoint& aPoint,
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize& aContainerSize)
|
2013-12-27 21:58:37 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
: mWritingMode(aWritingMode)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (aWritingMode.IsVertical()) {
|
2015-09-24 12:23:34 +03:00
|
|
|
I() = aWritingMode.IsInlineReversed() ? aContainerSize.height - aPoint.y
|
|
|
|
: aPoint.y;
|
2015-07-16 12:07:57 +03:00
|
|
|
B() = aWritingMode.IsVerticalLR() ? aPoint.x
|
|
|
|
: aContainerSize.width - aPoint.x;
|
2013-12-27 21:58:37 +04:00
|
|
|
} else {
|
2015-09-24 12:23:34 +03:00
|
|
|
I() = aWritingMode.IsInlineReversed() ? aContainerSize.width - aPoint.x
|
|
|
|
: aPoint.x;
|
2013-12-27 21:58:37 +04:00
|
|
|
B() = aPoint.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-16 12:07:57 +03:00
|
|
|
* Read-only (const) access to the logical coordinates.
|
2013-12-27 21:58:37 +04:00
|
|
|
*/
|
|
|
|
nscoord I(WritingMode aWritingMode) const // inline-axis
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mPoint.x;
|
|
|
|
}
|
|
|
|
nscoord B(WritingMode aWritingMode) const // block-axis
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mPoint.y;
|
|
|
|
}
|
2017-01-06 11:36:43 +03:00
|
|
|
nscoord LineRelative(WritingMode aWritingMode,
|
|
|
|
const nsSize& aContainerSize) const // line-axis
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
if (aWritingMode.IsBidiLTR()) {
|
|
|
|
return I();
|
|
|
|
}
|
|
|
|
return (aWritingMode.IsVertical() ? aContainerSize.height
|
|
|
|
: aContainerSize.width) -
|
|
|
|
I();
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* These non-const accessors return a reference (lvalue) that can be
|
|
|
|
* assigned to by callers.
|
|
|
|
*/
|
|
|
|
nscoord& I(WritingMode aWritingMode) // inline-axis
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mPoint.x;
|
|
|
|
}
|
|
|
|
nscoord& B(WritingMode aWritingMode) // block-axis
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mPoint.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a physical point corresponding to our logical coordinates,
|
|
|
|
* converted according to our writing mode.
|
|
|
|
*/
|
|
|
|
nsPoint GetPhysicalPoint(WritingMode aWritingMode,
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize& aContainerSize) const {
|
2013-12-27 21:58:37 +04:00
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
if (aWritingMode.IsVertical()) {
|
2015-07-16 12:07:57 +03:00
|
|
|
return nsPoint(
|
|
|
|
aWritingMode.IsVerticalLR() ? B() : aContainerSize.width - B(),
|
2015-09-24 12:23:34 +03:00
|
|
|
aWritingMode.IsInlineReversed() ? aContainerSize.height - I() : I());
|
2013-12-27 21:58:37 +04:00
|
|
|
} else {
|
2015-09-24 12:23:34 +03:00
|
|
|
return nsPoint(
|
|
|
|
aWritingMode.IsInlineReversed() ? aContainerSize.width - I() : I(),
|
2013-12-27 21:58:37 +04:00
|
|
|
B());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the equivalent point in a different writing mode.
|
|
|
|
*/
|
|
|
|
LogicalPoint ConvertTo(WritingMode aToMode, WritingMode aFromMode,
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize& aContainerSize) const {
|
2013-12-27 21:58:37 +04:00
|
|
|
CHECK_WRITING_MODE(aFromMode);
|
|
|
|
return aToMode == aFromMode
|
|
|
|
? *this
|
|
|
|
: LogicalPoint(aToMode,
|
2015-07-16 12:07:57 +03:00
|
|
|
GetPhysicalPoint(aFromMode, aContainerSize),
|
|
|
|
aContainerSize);
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2015-01-07 10:10:07 +03:00
|
|
|
bool operator==(const LogicalPoint& aOther) const {
|
2014-10-22 02:16:12 +04:00
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
return mPoint == aOther.mPoint;
|
|
|
|
}
|
|
|
|
|
2015-01-07 10:10:07 +03:00
|
|
|
bool operator!=(const LogicalPoint& aOther) const {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
return mPoint != aOther.mPoint;
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
LogicalPoint operator+(const LogicalPoint& aOther) const {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
// In non-debug builds, LogicalPoint does not store the WritingMode,
|
|
|
|
// so the first parameter here (which will always be eUnknownWritingMode)
|
|
|
|
// is ignored.
|
|
|
|
return LogicalPoint(GetWritingMode(), mPoint.x + aOther.mPoint.x,
|
|
|
|
mPoint.y + aOther.mPoint.y);
|
|
|
|
}
|
|
|
|
|
2014-10-22 02:16:12 +04:00
|
|
|
LogicalPoint& operator+=(const LogicalPoint& aOther) {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
I() += aOther.I();
|
|
|
|
B() += aOther.B();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalPoint operator-(const LogicalPoint& aOther) const {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
// In non-debug builds, LogicalPoint does not store the WritingMode,
|
|
|
|
// so the first parameter here (which will always be eUnknownWritingMode)
|
|
|
|
// is ignored.
|
|
|
|
return LogicalPoint(GetWritingMode(), mPoint.x - aOther.mPoint.x,
|
|
|
|
mPoint.y - aOther.mPoint.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalPoint& operator-=(const LogicalPoint& aOther) {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
I() -= aOther.I();
|
|
|
|
B() -= aOther.B();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
private:
|
|
|
|
friend class LogicalRect;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NOTE that in non-DEBUG builds, GetWritingMode() always returns
|
|
|
|
* eUnknownWritingMode, as the current mode is not stored in the logical-
|
|
|
|
* geometry classes. Therefore, this method is private; it is used ONLY
|
|
|
|
* by the DEBUG-mode checking macros in this class and its friends;
|
|
|
|
* other code is not allowed to ask a logical point for its writing mode,
|
|
|
|
* as this info will simply not be available in non-DEBUG builds.
|
|
|
|
*
|
|
|
|
* Also, in non-DEBUG builds, CHECK_WRITING_MODE does nothing, and the
|
|
|
|
* WritingMode parameter to logical methods will generally be optimized
|
|
|
|
* away altogether.
|
|
|
|
*/
|
|
|
|
#ifdef DEBUG
|
|
|
|
WritingMode GetWritingMode() const { return mWritingMode; }
|
|
|
|
#else
|
|
|
|
WritingMode GetWritingMode() const { return WritingMode::Unknown(); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// We don't allow construction of a LogicalPoint with no writing mode.
|
2015-01-07 02:35:02 +03:00
|
|
|
LogicalPoint() = delete;
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
// Accessors that don't take or check a WritingMode value.
|
|
|
|
// These are for internal use only; they are called by methods that have
|
|
|
|
// themselves already checked the WritingMode passed by the caller.
|
|
|
|
nscoord I() const // inline-axis
|
|
|
|
{
|
|
|
|
return mPoint.x;
|
|
|
|
}
|
|
|
|
nscoord B() const // block-axis
|
|
|
|
{
|
|
|
|
return mPoint.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord& I() // inline-axis
|
|
|
|
{
|
|
|
|
return mPoint.x;
|
|
|
|
}
|
|
|
|
nscoord& B() // block-axis
|
|
|
|
{
|
|
|
|
return mPoint.y;
|
|
|
|
}
|
|
|
|
|
2014-10-08 13:32:50 +04:00
|
|
|
#ifdef DEBUG
|
2013-12-27 21:58:37 +04:00
|
|
|
WritingMode mWritingMode;
|
2014-10-08 13:32:50 +04:00
|
|
|
#endif
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
// We use an nsPoint to hold the coordinates, but reinterpret its .x and .y
|
|
|
|
// fields as the inline and block directions. Hence, this is not exposed
|
|
|
|
// directly, but only through accessors that will map them according to the
|
|
|
|
// writing mode.
|
|
|
|
nsPoint mPoint;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flow-relative size
|
|
|
|
*/
|
|
|
|
class LogicalSize {
|
|
|
|
public:
|
2014-08-08 03:48:38 +04:00
|
|
|
explicit LogicalSize(WritingMode aWritingMode)
|
2013-12-27 21:58:37 +04:00
|
|
|
:
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
|
|
|
mSize(0, 0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalSize(WritingMode aWritingMode, nscoord aISize, nscoord aBSize)
|
|
|
|
:
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
|
|
|
mSize(aISize, aBSize) {
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalSize(WritingMode aWritingMode, const nsSize& aPhysicalSize)
|
|
|
|
#ifdef DEBUG
|
|
|
|
: mWritingMode(aWritingMode)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (aWritingMode.IsVertical()) {
|
|
|
|
ISize() = aPhysicalSize.height;
|
|
|
|
BSize() = aPhysicalSize.width;
|
|
|
|
} else {
|
|
|
|
ISize() = aPhysicalSize.width;
|
|
|
|
BSize() = aPhysicalSize.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
void SizeTo(WritingMode aWritingMode, nscoord aISize, nscoord aBSize) {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
mSize.SizeTo(aISize, aBSize);
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
/**
|
|
|
|
* Dimensions in logical and physical terms
|
|
|
|
*/
|
|
|
|
nscoord ISize(WritingMode aWritingMode) const // inline-size
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mSize.width;
|
|
|
|
}
|
|
|
|
nscoord BSize(WritingMode aWritingMode) const // block-size
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mSize.height;
|
|
|
|
}
|
2018-06-11 16:12:17 +03:00
|
|
|
nscoord Size(LogicalAxis aAxis, WritingMode aWM) const {
|
|
|
|
return aAxis == eLogicalAxisInline ? ISize(aWM) : BSize(aWM);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
nscoord Width(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical() ? BSize() : ISize();
|
|
|
|
}
|
|
|
|
nscoord Height(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical() ? ISize() : BSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-07 16:20:09 +03:00
|
|
|
* Writable references to the logical dimensions
|
2013-12-27 21:58:37 +04:00
|
|
|
*/
|
|
|
|
nscoord& ISize(WritingMode aWritingMode) // inline-size
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mSize.width;
|
|
|
|
}
|
|
|
|
nscoord& BSize(WritingMode aWritingMode) // block-size
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mSize.height;
|
|
|
|
}
|
2018-06-11 16:12:17 +03:00
|
|
|
nscoord& Size(LogicalAxis aAxis, WritingMode aWM) {
|
|
|
|
return aAxis == eLogicalAxisInline ? ISize(aWM) : BSize(aWM);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an nsSize containing our physical dimensions
|
|
|
|
*/
|
|
|
|
nsSize GetPhysicalSize(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical() ? nsSize(BSize(), ISize())
|
|
|
|
: nsSize(ISize(), BSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a LogicalSize representing this size in a different writing mode
|
|
|
|
*/
|
|
|
|
LogicalSize ConvertTo(WritingMode aToMode, WritingMode aFromMode) const {
|
2014-11-30 12:17:56 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// In DEBUG builds make sure to return a LogicalSize with the
|
|
|
|
// expected writing mode
|
2013-12-27 21:58:37 +04:00
|
|
|
CHECK_WRITING_MODE(aFromMode);
|
|
|
|
return aToMode == aFromMode
|
|
|
|
? *this
|
|
|
|
: LogicalSize(aToMode, GetPhysicalSize(aFromMode));
|
2014-11-30 12:17:56 +03:00
|
|
|
#else
|
|
|
|
// optimization for non-DEBUG builds where LogicalSize doesn't store
|
|
|
|
// the writing mode
|
|
|
|
return (aToMode == aFromMode || !aToMode.IsOrthogonalTo(aFromMode))
|
2015-07-16 12:07:57 +03:00
|
|
|
? *this
|
|
|
|
: LogicalSize(aToMode, BSize(), ISize());
|
2014-11-30 12:17:56 +03:00
|
|
|
#endif
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 13:32:50 +04:00
|
|
|
/**
|
|
|
|
* Test if a size is (0, 0).
|
|
|
|
*/
|
|
|
|
bool IsAllZero() const { return ISize() == 0 && BSize() == 0; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Various binary operators on LogicalSize. These are valid ONLY for operands
|
|
|
|
* that share the same writing mode.
|
|
|
|
*/
|
2014-07-24 12:30:07 +04:00
|
|
|
bool operator==(const LogicalSize& aOther) const {
|
2014-10-08 13:32:50 +04:00
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
return mSize == aOther.mSize;
|
2014-07-24 12:30:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const LogicalSize& aOther) const {
|
2014-10-08 13:32:50 +04:00
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
return mSize != aOther.mSize;
|
2014-07-24 12:30:07 +04:00
|
|
|
}
|
|
|
|
|
2014-08-24 18:34:21 +04:00
|
|
|
LogicalSize operator+(const LogicalSize& aOther) const {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
2014-10-08 13:32:50 +04:00
|
|
|
return LogicalSize(GetWritingMode(), ISize() + aOther.ISize(),
|
|
|
|
BSize() + aOther.BSize());
|
2014-08-24 18:34:21 +04:00
|
|
|
}
|
|
|
|
LogicalSize& operator+=(const LogicalSize& aOther) {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
ISize() += aOther.ISize();
|
|
|
|
BSize() += aOther.BSize();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalSize operator-(const LogicalSize& aOther) const {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
2014-10-08 13:32:50 +04:00
|
|
|
return LogicalSize(GetWritingMode(), ISize() - aOther.ISize(),
|
|
|
|
BSize() - aOther.BSize());
|
2014-08-24 18:34:21 +04:00
|
|
|
}
|
|
|
|
LogicalSize& operator-=(const LogicalSize& aOther) {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
|
|
|
ISize() -= aOther.ISize();
|
|
|
|
BSize() -= aOther.BSize();
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
private:
|
|
|
|
friend class LogicalRect;
|
|
|
|
|
2015-01-07 02:35:02 +03:00
|
|
|
LogicalSize() = delete;
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
WritingMode GetWritingMode() const { return mWritingMode; }
|
|
|
|
#else
|
|
|
|
WritingMode GetWritingMode() const { return WritingMode::Unknown(); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nscoord ISize() const // inline-size
|
|
|
|
{
|
|
|
|
return mSize.width;
|
|
|
|
}
|
|
|
|
nscoord BSize() const // block-size
|
|
|
|
{
|
|
|
|
return mSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord& ISize() // inline-size
|
|
|
|
{
|
|
|
|
return mSize.width;
|
|
|
|
}
|
|
|
|
nscoord& BSize() // block-size
|
|
|
|
{
|
|
|
|
return mSize.height;
|
|
|
|
}
|
|
|
|
|
2014-10-08 13:32:50 +04:00
|
|
|
#ifdef DEBUG
|
2013-12-27 21:58:37 +04:00
|
|
|
WritingMode mWritingMode;
|
2014-10-08 13:32:50 +04:00
|
|
|
#endif
|
2013-12-27 21:58:37 +04:00
|
|
|
nsSize mSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flow-relative margin
|
|
|
|
*/
|
|
|
|
class LogicalMargin {
|
|
|
|
public:
|
2014-08-08 03:48:38 +04:00
|
|
|
explicit LogicalMargin(WritingMode aWritingMode)
|
2013-12-27 21:58:37 +04:00
|
|
|
:
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
|
|
|
mMargin(0, 0, 0, 0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalMargin(WritingMode aWritingMode, nscoord aBStart, nscoord aIEnd,
|
|
|
|
nscoord aBEnd, nscoord aIStart)
|
|
|
|
:
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
|
|
|
mMargin(aBStart, aIEnd, aBEnd, aIStart) {
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalMargin(WritingMode aWritingMode, const nsMargin& aPhysicalMargin)
|
|
|
|
#ifdef DEBUG
|
|
|
|
: mWritingMode(aWritingMode)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (aWritingMode.IsVertical()) {
|
|
|
|
if (aWritingMode.IsVerticalLR()) {
|
|
|
|
mMargin.top = aPhysicalMargin.left;
|
|
|
|
mMargin.bottom = aPhysicalMargin.right;
|
|
|
|
} else {
|
|
|
|
mMargin.top = aPhysicalMargin.right;
|
|
|
|
mMargin.bottom = aPhysicalMargin.left;
|
|
|
|
}
|
2015-09-24 12:23:34 +03:00
|
|
|
if (aWritingMode.IsInlineReversed()) {
|
2013-12-27 21:58:37 +04:00
|
|
|
mMargin.left = aPhysicalMargin.bottom;
|
|
|
|
mMargin.right = aPhysicalMargin.top;
|
2015-09-24 12:23:34 +03:00
|
|
|
} else {
|
|
|
|
mMargin.left = aPhysicalMargin.top;
|
|
|
|
mMargin.right = aPhysicalMargin.bottom;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mMargin.top = aPhysicalMargin.top;
|
|
|
|
mMargin.bottom = aPhysicalMargin.bottom;
|
2015-09-24 12:23:34 +03:00
|
|
|
if (aWritingMode.IsInlineReversed()) {
|
2013-12-27 21:58:37 +04:00
|
|
|
mMargin.left = aPhysicalMargin.right;
|
|
|
|
mMargin.right = aPhysicalMargin.left;
|
2015-09-24 12:23:34 +03:00
|
|
|
} else {
|
|
|
|
mMargin.left = aPhysicalMargin.left;
|
|
|
|
mMargin.right = aPhysicalMargin.right;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord IStart(WritingMode aWritingMode) const // inline-start margin
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.left;
|
|
|
|
}
|
|
|
|
nscoord IEnd(WritingMode aWritingMode) const // inline-end margin
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.right;
|
|
|
|
}
|
|
|
|
nscoord BStart(WritingMode aWritingMode) const // block-start margin
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.top;
|
|
|
|
}
|
|
|
|
nscoord BEnd(WritingMode aWritingMode) const // block-end margin
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.bottom;
|
|
|
|
}
|
2018-06-11 16:12:17 +03:00
|
|
|
nscoord Start(LogicalAxis aAxis, WritingMode aWM) const {
|
|
|
|
return aAxis == eLogicalAxisInline ? IStart(aWM) : BStart(aWM);
|
|
|
|
}
|
|
|
|
nscoord End(LogicalAxis aAxis, WritingMode aWM) const {
|
|
|
|
return aAxis == eLogicalAxisInline ? IEnd(aWM) : BEnd(aWM);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
nscoord& IStart(WritingMode aWritingMode) // inline-start margin
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.left;
|
|
|
|
}
|
|
|
|
nscoord& IEnd(WritingMode aWritingMode) // inline-end margin
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.right;
|
|
|
|
}
|
|
|
|
nscoord& BStart(WritingMode aWritingMode) // block-start margin
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.top;
|
|
|
|
}
|
|
|
|
nscoord& BEnd(WritingMode aWritingMode) // block-end margin
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.bottom;
|
|
|
|
}
|
2018-06-11 16:12:17 +03:00
|
|
|
nscoord& Start(LogicalAxis aAxis, WritingMode aWM) {
|
|
|
|
return aAxis == eLogicalAxisInline ? IStart(aWM) : BStart(aWM);
|
|
|
|
}
|
|
|
|
nscoord& End(LogicalAxis aAxis, WritingMode aWM) {
|
|
|
|
return aAxis == eLogicalAxisInline ? IEnd(aWM) : BEnd(aWM);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
nscoord IStartEnd(WritingMode aWritingMode) const // inline margins
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.LeftRight();
|
|
|
|
}
|
|
|
|
nscoord BStartEnd(WritingMode aWritingMode) const // block margins
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return mMargin.TopBottom();
|
|
|
|
}
|
2018-06-11 16:12:17 +03:00
|
|
|
nscoord StartEnd(LogicalAxis aAxis, WritingMode aWM) const {
|
|
|
|
return aAxis == eLogicalAxisInline ? IStartEnd(aWM) : BStartEnd(aWM);
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
|
2015-09-16 00:02:30 +03:00
|
|
|
/*
|
|
|
|
* Return margin values for line-relative sides, as defined in
|
|
|
|
* http://www.w3.org/TR/css-writing-modes-3/#line-directions:
|
|
|
|
*
|
|
|
|
* line-left
|
|
|
|
* Nominally the side from which LTR text would start.
|
|
|
|
* line-right
|
|
|
|
* Nominally the side from which RTL text would start. (Opposite of
|
|
|
|
* line-left.)
|
|
|
|
*/
|
|
|
|
nscoord LineLeft(WritingMode aWritingMode) const {
|
|
|
|
// We don't need to CHECK_WRITING_MODE here because the IStart or IEnd
|
|
|
|
// accessor that we call will do it.
|
|
|
|
return aWritingMode.IsBidiLTR() ? IStart(aWritingMode) : IEnd(aWritingMode);
|
|
|
|
}
|
|
|
|
nscoord LineRight(WritingMode aWritingMode) const {
|
|
|
|
return aWritingMode.IsBidiLTR() ? IEnd(aWritingMode) : IStart(aWritingMode);
|
|
|
|
}
|
|
|
|
|
2014-08-24 18:34:21 +04:00
|
|
|
/**
|
|
|
|
* Return a LogicalSize representing the total size of the inline-
|
|
|
|
* and block-dimension margins.
|
|
|
|
*/
|
|
|
|
LogicalSize Size(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return LogicalSize(aWritingMode, IStartEnd(), BStartEnd());
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
/**
|
|
|
|
* Accessors for physical margins, using our writing mode to convert from
|
|
|
|
* logical values.
|
|
|
|
*/
|
|
|
|
nscoord Top(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical()
|
2015-09-24 12:23:34 +03:00
|
|
|
? (aWritingMode.IsInlineReversed() ? IEnd() : IStart())
|
|
|
|
: BStart();
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord Bottom(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical()
|
2015-09-24 12:23:34 +03:00
|
|
|
? (aWritingMode.IsInlineReversed() ? IStart() : IEnd())
|
|
|
|
: BEnd();
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord Left(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical()
|
|
|
|
? (aWritingMode.IsVerticalLR() ? BStart() : BEnd())
|
2015-09-24 12:23:34 +03:00
|
|
|
: (aWritingMode.IsInlineReversed() ? IEnd() : IStart());
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord Right(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical()
|
|
|
|
? (aWritingMode.IsVerticalLR() ? BEnd() : BStart())
|
2015-09-24 12:23:34 +03:00
|
|
|
: (aWritingMode.IsInlineReversed() ? IStart() : IEnd());
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord LeftRight(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical() ? BStartEnd() : IStartEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord TopBottom(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return aWritingMode.IsVertical() ? IStartEnd() : BStartEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SizeTo(WritingMode aWritingMode, nscoord aBStart, nscoord aIEnd,
|
|
|
|
nscoord aBEnd, nscoord aIStart) {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
mMargin.SizeTo(aBStart, aIEnd, aBEnd, aIStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an nsMargin containing our physical coordinates
|
|
|
|
*/
|
|
|
|
nsMargin GetPhysicalMargin(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2015-05-28 20:29:07 +03:00
|
|
|
return aWritingMode.IsVertical()
|
2015-07-16 12:07:57 +03:00
|
|
|
? (aWritingMode.IsVerticalLR()
|
2015-09-24 12:23:34 +03:00
|
|
|
? (aWritingMode.IsInlineReversed()
|
|
|
|
? nsMargin(IEnd(), BEnd(), IStart(), BStart())
|
|
|
|
: nsMargin(IStart(), BEnd(), IEnd(), BStart()))
|
|
|
|
: (aWritingMode.IsInlineReversed()
|
|
|
|
? nsMargin(IEnd(), BStart(), IStart(), BEnd())
|
|
|
|
: nsMargin(IStart(), BStart(), IEnd(), BEnd())))
|
|
|
|
: (aWritingMode.IsInlineReversed()
|
|
|
|
? nsMargin(BStart(), IStart(), BEnd(), IEnd())
|
|
|
|
: nsMargin(BStart(), IEnd(), BEnd(), IStart()));
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a LogicalMargin representing this margin in a different
|
|
|
|
* writing mode
|
|
|
|
*/
|
|
|
|
LogicalMargin ConvertTo(WritingMode aToMode, WritingMode aFromMode) const {
|
|
|
|
CHECK_WRITING_MODE(aFromMode);
|
|
|
|
return aToMode == aFromMode
|
|
|
|
? *this
|
|
|
|
: LogicalMargin(aToMode, GetPhysicalMargin(aFromMode));
|
|
|
|
}
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
void ApplySkipSides(LogicalSides aSkipSides) {
|
|
|
|
if (aSkipSides.BStart()) {
|
2014-06-24 21:52:19 +04:00
|
|
|
BStart() = 0;
|
|
|
|
}
|
2014-06-28 14:13:13 +04:00
|
|
|
if (aSkipSides.BEnd()) {
|
2014-06-24 21:52:19 +04:00
|
|
|
BEnd() = 0;
|
|
|
|
}
|
2014-06-28 14:13:13 +04:00
|
|
|
if (aSkipSides.IStart()) {
|
2014-06-24 21:52:19 +04:00
|
|
|
IStart() = 0;
|
|
|
|
}
|
2014-06-28 14:13:13 +04:00
|
|
|
if (aSkipSides.IEnd()) {
|
2014-06-24 21:52:19 +04:00
|
|
|
IEnd() = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-05 10:02:36 +04:00
|
|
|
bool IsAllZero() const {
|
2014-03-12 00:23:50 +04:00
|
|
|
return (mMargin.left == 0 && mMargin.top == 0 && mMargin.right == 0 &&
|
|
|
|
mMargin.bottom == 0);
|
|
|
|
}
|
|
|
|
|
2015-01-07 10:10:07 +03:00
|
|
|
LogicalMargin operator+(const LogicalMargin& aMargin) const {
|
2014-04-16 12:03:30 +04:00
|
|
|
CHECK_WRITING_MODE(aMargin.GetWritingMode());
|
|
|
|
return LogicalMargin(GetWritingMode(), BStart() + aMargin.BStart(),
|
|
|
|
IEnd() + aMargin.IEnd(), BEnd() + aMargin.BEnd(),
|
|
|
|
IStart() + aMargin.IStart());
|
|
|
|
}
|
|
|
|
|
2015-05-04 10:09:25 +03:00
|
|
|
LogicalMargin operator+=(const LogicalMargin& aMargin) {
|
|
|
|
CHECK_WRITING_MODE(aMargin.GetWritingMode());
|
|
|
|
mMargin += aMargin.mMargin;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-01-07 10:10:07 +03:00
|
|
|
LogicalMargin operator-(const LogicalMargin& aMargin) const {
|
2014-04-16 12:03:30 +04:00
|
|
|
CHECK_WRITING_MODE(aMargin.GetWritingMode());
|
|
|
|
return LogicalMargin(GetWritingMode(), BStart() - aMargin.BStart(),
|
|
|
|
IEnd() - aMargin.IEnd(), BEnd() - aMargin.BEnd(),
|
|
|
|
IStart() - aMargin.IStart());
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
private:
|
|
|
|
friend class LogicalRect;
|
|
|
|
|
2015-01-07 02:35:02 +03:00
|
|
|
LogicalMargin() = delete;
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
WritingMode GetWritingMode() const { return mWritingMode; }
|
|
|
|
#else
|
|
|
|
WritingMode GetWritingMode() const { return WritingMode::Unknown(); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nscoord IStart() const // inline-start margin
|
|
|
|
{
|
|
|
|
return mMargin.left;
|
|
|
|
}
|
|
|
|
nscoord IEnd() const // inline-end margin
|
|
|
|
{
|
|
|
|
return mMargin.right;
|
|
|
|
}
|
|
|
|
nscoord BStart() const // block-start margin
|
|
|
|
{
|
|
|
|
return mMargin.top;
|
|
|
|
}
|
|
|
|
nscoord BEnd() const // block-end margin
|
|
|
|
{
|
|
|
|
return mMargin.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord& IStart() // inline-start margin
|
|
|
|
{
|
|
|
|
return mMargin.left;
|
|
|
|
}
|
|
|
|
nscoord& IEnd() // inline-end margin
|
|
|
|
{
|
|
|
|
return mMargin.right;
|
|
|
|
}
|
|
|
|
nscoord& BStart() // block-start margin
|
|
|
|
{
|
|
|
|
return mMargin.top;
|
|
|
|
}
|
|
|
|
nscoord& BEnd() // block-end margin
|
|
|
|
{
|
|
|
|
return mMargin.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord IStartEnd() const // inline margins
|
|
|
|
{
|
|
|
|
return mMargin.LeftRight();
|
|
|
|
}
|
|
|
|
nscoord BStartEnd() const // block margins
|
|
|
|
{
|
|
|
|
return mMargin.TopBottom();
|
|
|
|
}
|
|
|
|
|
2014-10-08 13:32:50 +04:00
|
|
|
#ifdef DEBUG
|
2013-12-27 21:58:37 +04:00
|
|
|
WritingMode mWritingMode;
|
2014-10-08 13:32:50 +04:00
|
|
|
#endif
|
2013-12-27 21:58:37 +04:00
|
|
|
nsMargin mMargin;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flow-relative rectangle
|
|
|
|
*/
|
|
|
|
class LogicalRect {
|
|
|
|
public:
|
2014-08-08 03:48:38 +04:00
|
|
|
explicit LogicalRect(WritingMode aWritingMode)
|
2013-12-27 21:58:37 +04:00
|
|
|
:
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
2017-11-07 17:38:31 +03:00
|
|
|
mIStart(0),
|
|
|
|
mBStart(0),
|
|
|
|
mISize(0),
|
|
|
|
mBSize(0) {
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
LogicalRect(WritingMode aWritingMode, nscoord aIStart, nscoord aBStart,
|
|
|
|
nscoord aISize, nscoord aBSize)
|
|
|
|
:
|
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
2017-11-07 17:38:31 +03:00
|
|
|
mIStart(aIStart),
|
|
|
|
mBStart(aBStart),
|
|
|
|
mISize(aISize),
|
|
|
|
mBSize(aBSize) {
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
LogicalRect(WritingMode aWritingMode, const LogicalPoint& aOrigin,
|
|
|
|
const LogicalSize& aSize)
|
2017-07-06 15:00:35 +03:00
|
|
|
:
|
2013-12-27 21:58:37 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
mWritingMode(aWritingMode),
|
|
|
|
#endif
|
2017-11-07 17:38:31 +03:00
|
|
|
mIStart(aOrigin.mPoint.x),
|
|
|
|
mBStart(aOrigin.mPoint.y),
|
|
|
|
mISize(aSize.mSize.width),
|
|
|
|
mBSize(aSize.mSize.height) {
|
2013-12-27 21:58:37 +04:00
|
|
|
CHECK_WRITING_MODE(aOrigin.GetWritingMode());
|
|
|
|
CHECK_WRITING_MODE(aSize.GetWritingMode());
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalRect(WritingMode aWritingMode, const nsRect& aRect,
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize& aContainerSize)
|
2013-12-27 21:58:37 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
: mWritingMode(aWritingMode)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (aWritingMode.IsVertical()) {
|
2017-11-07 17:38:31 +03:00
|
|
|
mBStart = aWritingMode.IsVerticalLR()
|
|
|
|
? aRect.X()
|
|
|
|
: aContainerSize.width - aRect.XMost();
|
|
|
|
mIStart = aWritingMode.IsInlineReversed()
|
|
|
|
? aContainerSize.height - aRect.YMost()
|
|
|
|
: aRect.Y();
|
|
|
|
mBSize = aRect.Width();
|
|
|
|
mISize = aRect.Height();
|
2013-12-27 21:58:37 +04:00
|
|
|
} else {
|
2017-11-07 17:38:31 +03:00
|
|
|
mIStart = aWritingMode.IsInlineReversed()
|
|
|
|
? aContainerSize.width - aRect.XMost()
|
|
|
|
: aRect.X();
|
|
|
|
mBStart = aRect.Y();
|
|
|
|
mISize = aRect.Width();
|
|
|
|
mBSize = aRect.Height();
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inline- and block-dimension geometry.
|
|
|
|
*/
|
|
|
|
nscoord IStart(WritingMode aWritingMode) const // inline-start edge
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mIStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord IEnd(WritingMode aWritingMode) const // inline-end edge
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mIStart + mISize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord ISize(WritingMode aWritingMode) const // inline-size
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mISize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord BStart(WritingMode aWritingMode) const // block-start edge
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord BEnd(WritingMode aWritingMode) const // block-end edge
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBStart + mBSize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord BSize(WritingMode aWritingMode) const // block-size
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBSize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writable (reference) accessors are only available for the basic logical
|
|
|
|
* fields (Start and Size), not derivatives like End.
|
|
|
|
*/
|
|
|
|
nscoord& IStart(WritingMode aWritingMode) // inline-start edge
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mIStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord& ISize(WritingMode aWritingMode) // inline-size
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mISize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord& BStart(WritingMode aWritingMode) // block-start edge
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord& BSize(WritingMode aWritingMode) // block-size
|
|
|
|
{
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBSize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2015-03-22 12:44:48 +03:00
|
|
|
/**
|
|
|
|
* Accessors for line-relative coordinates
|
|
|
|
*/
|
2015-07-16 12:07:57 +03:00
|
|
|
nscoord LineLeft(WritingMode aWritingMode,
|
|
|
|
const nsSize& aContainerSize) const {
|
2015-03-22 12:44:48 +03:00
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2015-07-16 12:08:05 +03:00
|
|
|
if (aWritingMode.IsBidiLTR()) {
|
2015-07-16 12:07:57 +03:00
|
|
|
return IStart();
|
2015-03-22 12:44:48 +03:00
|
|
|
}
|
2015-07-16 12:08:05 +03:00
|
|
|
nscoord containerISize = aWritingMode.IsVertical() ? aContainerSize.height
|
|
|
|
: aContainerSize.width;
|
|
|
|
return containerISize - IEnd();
|
2015-03-22 12:44:48 +03:00
|
|
|
}
|
2015-07-16 12:07:57 +03:00
|
|
|
nscoord LineRight(WritingMode aWritingMode,
|
|
|
|
const nsSize& aContainerSize) const {
|
2015-03-22 12:44:48 +03:00
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2015-07-16 12:08:05 +03:00
|
|
|
if (aWritingMode.IsBidiLTR()) {
|
2015-07-16 12:07:57 +03:00
|
|
|
return IEnd();
|
2015-03-22 12:44:48 +03:00
|
|
|
}
|
2015-07-16 12:08:05 +03:00
|
|
|
nscoord containerISize = aWritingMode.IsVertical() ? aContainerSize.height
|
|
|
|
: aContainerSize.width;
|
|
|
|
return containerISize - IStart();
|
2015-03-22 12:44:48 +03:00
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
/**
|
|
|
|
* Physical coordinates of the rect.
|
|
|
|
*/
|
|
|
|
nscoord X(WritingMode aWritingMode, nscoord aContainerWidth) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
if (aWritingMode.IsVertical()) {
|
|
|
|
return aWritingMode.IsVerticalLR() ? mBStart : aContainerWidth - BEnd();
|
|
|
|
}
|
2019-03-05 04:22:06 +03:00
|
|
|
return aWritingMode.IsInlineReversed() ? aContainerWidth - IEnd() : mIStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
nscoord Y(WritingMode aWritingMode, nscoord aContainerHeight) const {
|
2013-12-27 21:58:37 +04:00
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2015-07-16 12:07:57 +03:00
|
|
|
if (aWritingMode.IsVertical()) {
|
2017-11-07 17:38:31 +03:00
|
|
|
return aWritingMode.IsInlineReversed() ? aContainerHeight - IEnd()
|
|
|
|
: mIStart;
|
2015-07-16 12:07:57 +03:00
|
|
|
}
|
2019-03-05 04:22:06 +03:00
|
|
|
return mBStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord Width(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return aWritingMode.IsVertical() ? mBSize : mISize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord Height(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
return aWritingMode.IsVertical() ? mISize : mBSize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord XMost(WritingMode aWritingMode, nscoord aContainerWidth) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
if (aWritingMode.IsVertical()) {
|
|
|
|
return aWritingMode.IsVerticalLR() ? BEnd() : aContainerWidth - mBStart;
|
|
|
|
}
|
2019-03-05 04:22:06 +03:00
|
|
|
return aWritingMode.IsInlineReversed() ? aContainerWidth - mIStart : IEnd();
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
nscoord YMost(WritingMode aWritingMode, nscoord aContainerHeight) const {
|
2013-12-27 21:58:37 +04:00
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
2015-07-16 12:07:57 +03:00
|
|
|
if (aWritingMode.IsVertical()) {
|
2017-11-07 17:38:31 +03:00
|
|
|
return aWritingMode.IsInlineReversed() ? aContainerHeight - mIStart
|
|
|
|
: IEnd();
|
2015-07-16 12:07:57 +03:00
|
|
|
}
|
2019-03-05 04:22:06 +03:00
|
|
|
return BEnd();
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2017-11-10 15:18:00 +03:00
|
|
|
bool IsEmpty() const { return mISize <= 0 || mBSize <= 0; }
|
2014-10-05 10:02:36 +04:00
|
|
|
|
|
|
|
bool IsAllZero() const {
|
2017-11-07 17:38:31 +03:00
|
|
|
return (mIStart == 0 && mBStart == 0 && mISize == 0 && mBSize == 0);
|
2014-03-12 00:23:50 +04:00
|
|
|
}
|
|
|
|
|
2017-11-07 17:38:31 +03:00
|
|
|
bool IsZeroSize() const { return (mISize == 0 && mBSize == 0); }
|
2014-03-12 00:23:50 +04:00
|
|
|
|
2017-11-07 17:38:31 +03:00
|
|
|
void SetEmpty() { mISize = mBSize = 0; }
|
2014-07-24 12:30:07 +04:00
|
|
|
|
2014-10-22 02:16:12 +04:00
|
|
|
bool IsEqualEdges(const LogicalRect aOther) const {
|
|
|
|
CHECK_WRITING_MODE(aOther.GetWritingMode());
|
2017-11-07 17:38:31 +03:00
|
|
|
bool result = mIStart == aOther.mIStart && mBStart == aOther.mBStart &&
|
|
|
|
mISize == aOther.mISize && mBSize == aOther.mBSize;
|
|
|
|
|
|
|
|
// We want the same result as nsRect, so assert we get it.
|
|
|
|
MOZ_ASSERT(result ==
|
|
|
|
nsRect(mIStart, mBStart, mISize, mBSize)
|
|
|
|
.IsEqualEdges(nsRect(aOther.mIStart, aOther.mBStart,
|
|
|
|
aOther.mISize, aOther.mBSize)));
|
|
|
|
return result;
|
2014-10-22 02:16:12 +04:00
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
LogicalPoint Origin(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return LogicalPoint(aWritingMode, IStart(), BStart());
|
|
|
|
}
|
2015-03-14 08:46:33 +03:00
|
|
|
void SetOrigin(WritingMode aWritingMode, const LogicalPoint& aPoint) {
|
|
|
|
IStart(aWritingMode) = aPoint.I(aWritingMode);
|
|
|
|
BStart(aWritingMode) = aPoint.B(aWritingMode);
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
LogicalSize Size(WritingMode aWritingMode) const {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
return LogicalSize(aWritingMode, ISize(), BSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalRect operator+(const LogicalPoint& aPoint) const {
|
|
|
|
CHECK_WRITING_MODE(aPoint.GetWritingMode());
|
|
|
|
return LogicalRect(GetWritingMode(), IStart() + aPoint.I(),
|
|
|
|
BStart() + aPoint.B(), ISize(), BSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalRect& operator+=(const LogicalPoint& aPoint) {
|
|
|
|
CHECK_WRITING_MODE(aPoint.GetWritingMode());
|
2017-11-07 17:38:31 +03:00
|
|
|
mIStart += aPoint.mPoint.x;
|
|
|
|
mBStart += aPoint.mPoint.y;
|
2013-12-27 21:58:37 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalRect operator-(const LogicalPoint& aPoint) const {
|
|
|
|
CHECK_WRITING_MODE(aPoint.GetWritingMode());
|
|
|
|
return LogicalRect(GetWritingMode(), IStart() - aPoint.I(),
|
|
|
|
BStart() - aPoint.B(), ISize(), BSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalRect& operator-=(const LogicalPoint& aPoint) {
|
|
|
|
CHECK_WRITING_MODE(aPoint.GetWritingMode());
|
2017-11-07 17:38:31 +03:00
|
|
|
mIStart -= aPoint.mPoint.x;
|
|
|
|
mBStart -= aPoint.mPoint.y;
|
2013-12-27 21:58:37 +04:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoveBy(WritingMode aWritingMode, const LogicalPoint& aDelta) {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
CHECK_WRITING_MODE(aDelta.GetWritingMode());
|
|
|
|
IStart() += aDelta.I();
|
|
|
|
BStart() += aDelta.B();
|
|
|
|
}
|
|
|
|
|
2017-11-07 17:38:31 +03:00
|
|
|
void Inflate(nscoord aD) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Compute using nsRect and assert the results match
|
|
|
|
nsRect rectDebug(mIStart, mBStart, mISize, mBSize);
|
|
|
|
rectDebug.Inflate(aD);
|
|
|
|
#endif
|
|
|
|
mIStart -= aD;
|
|
|
|
mBStart -= aD;
|
|
|
|
mISize += 2 * aD;
|
|
|
|
mBSize += 2 * aD;
|
|
|
|
MOZ_ASSERT(
|
|
|
|
rectDebug.IsEqualEdges(nsRect(mIStart, mBStart, mISize, mBSize)));
|
|
|
|
}
|
|
|
|
void Inflate(nscoord aDI, nscoord aDB) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Compute using nsRect and assert the results match
|
|
|
|
nsRect rectDebug(mIStart, mBStart, mISize, mBSize);
|
|
|
|
rectDebug.Inflate(aDI, aDB);
|
|
|
|
#endif
|
|
|
|
mIStart -= aDI;
|
|
|
|
mBStart -= aDB;
|
|
|
|
mISize += 2 * aDI;
|
|
|
|
mBSize += 2 * aDB;
|
|
|
|
MOZ_ASSERT(
|
|
|
|
rectDebug.IsEqualEdges(nsRect(mIStart, mBStart, mISize, mBSize)));
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
void Inflate(WritingMode aWritingMode, const LogicalMargin& aMargin) {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
CHECK_WRITING_MODE(aMargin.GetWritingMode());
|
2017-11-07 17:38:31 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Compute using nsRect and assert the results match
|
|
|
|
nsRect rectDebug(mIStart, mBStart, mISize, mBSize);
|
|
|
|
rectDebug.Inflate(aMargin.mMargin);
|
|
|
|
#endif
|
|
|
|
mIStart -= aMargin.mMargin.left;
|
|
|
|
mBStart -= aMargin.mMargin.top;
|
|
|
|
mISize += aMargin.mMargin.LeftRight();
|
|
|
|
mBSize += aMargin.mMargin.TopBottom();
|
|
|
|
MOZ_ASSERT(
|
|
|
|
rectDebug.IsEqualEdges(nsRect(mIStart, mBStart, mISize, mBSize)));
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2017-11-07 17:38:31 +03:00
|
|
|
void Deflate(nscoord aD) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Compute using nsRect and assert the results match
|
|
|
|
nsRect rectDebug(mIStart, mBStart, mISize, mBSize);
|
|
|
|
rectDebug.Deflate(aD);
|
|
|
|
#endif
|
|
|
|
mIStart += aD;
|
|
|
|
mBStart += aD;
|
|
|
|
mISize = std::max(0, mISize - 2 * aD);
|
|
|
|
mBSize = std::max(0, mBSize - 2 * aD);
|
|
|
|
MOZ_ASSERT(
|
|
|
|
rectDebug.IsEqualEdges(nsRect(mIStart, mBStart, mISize, mBSize)));
|
|
|
|
}
|
|
|
|
void Deflate(nscoord aDI, nscoord aDB) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Compute using nsRect and assert the results match
|
|
|
|
nsRect rectDebug(mIStart, mBStart, mISize, mBSize);
|
|
|
|
rectDebug.Deflate(aDI, aDB);
|
|
|
|
#endif
|
|
|
|
mIStart += aDI;
|
|
|
|
mBStart += aDB;
|
|
|
|
mISize = std::max(0, mISize - 2 * aDI);
|
|
|
|
mBSize = std::max(0, mBSize - 2 * aDB);
|
|
|
|
MOZ_ASSERT(
|
|
|
|
rectDebug.IsEqualEdges(nsRect(mIStart, mBStart, mISize, mBSize)));
|
|
|
|
}
|
2013-12-27 21:58:37 +04:00
|
|
|
void Deflate(WritingMode aWritingMode, const LogicalMargin& aMargin) {
|
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
CHECK_WRITING_MODE(aMargin.GetWritingMode());
|
2017-11-07 17:38:31 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Compute using nsRect and assert the results match
|
|
|
|
nsRect rectDebug(mIStart, mBStart, mISize, mBSize);
|
|
|
|
rectDebug.Deflate(aMargin.mMargin);
|
|
|
|
#endif
|
|
|
|
mIStart += aMargin.mMargin.left;
|
|
|
|
mBStart += aMargin.mMargin.top;
|
|
|
|
mISize = std::max(0, mISize - aMargin.mMargin.LeftRight());
|
|
|
|
mBSize = std::max(0, mBSize - aMargin.mMargin.TopBottom());
|
|
|
|
MOZ_ASSERT(
|
|
|
|
rectDebug.IsEqualEdges(nsRect(mIStart, mBStart, mISize, mBSize)));
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an nsRect containing our physical coordinates within the given
|
2015-07-16 12:07:57 +03:00
|
|
|
* container size.
|
2013-12-27 21:58:37 +04:00
|
|
|
*/
|
|
|
|
nsRect GetPhysicalRect(WritingMode aWritingMode,
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize& aContainerSize) const {
|
2013-12-27 21:58:37 +04:00
|
|
|
CHECK_WRITING_MODE(aWritingMode);
|
|
|
|
if (aWritingMode.IsVertical()) {
|
2015-07-16 12:07:57 +03:00
|
|
|
return nsRect(aWritingMode.IsVerticalLR() ? BStart()
|
|
|
|
: aContainerSize.width - BEnd(),
|
2015-09-24 12:23:34 +03:00
|
|
|
aWritingMode.IsInlineReversed()
|
|
|
|
? aContainerSize.height - IEnd()
|
|
|
|
: IStart(),
|
2015-07-16 12:07:57 +03:00
|
|
|
BSize(), ISize());
|
2013-12-27 21:58:37 +04:00
|
|
|
} else {
|
2015-09-24 12:23:34 +03:00
|
|
|
return nsRect(aWritingMode.IsInlineReversed()
|
|
|
|
? aContainerSize.width - IEnd()
|
|
|
|
: IStart(),
|
2013-12-27 21:58:37 +04:00
|
|
|
BStart(), ISize(), BSize());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a LogicalRect representing this rect in a different writing mode
|
|
|
|
*/
|
2014-10-22 02:16:12 +04:00
|
|
|
LogicalRect ConvertTo(WritingMode aToMode, WritingMode aFromMode,
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize& aContainerSize) const {
|
2013-12-27 21:58:37 +04:00
|
|
|
CHECK_WRITING_MODE(aFromMode);
|
|
|
|
return aToMode == aFromMode
|
2015-07-16 12:07:57 +03:00
|
|
|
? *this
|
|
|
|
: LogicalRect(aToMode,
|
|
|
|
GetPhysicalRect(aFromMode, aContainerSize),
|
|
|
|
aContainerSize);
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2015-04-24 01:15:32 +03:00
|
|
|
/**
|
|
|
|
* Set *this to be the rectangle containing the intersection of aRect1
|
|
|
|
* and aRect2, return whether the intersection is non-empty.
|
|
|
|
*/
|
|
|
|
bool IntersectRect(const LogicalRect& aRect1, const LogicalRect& aRect2) {
|
|
|
|
CHECK_WRITING_MODE(aRect1.mWritingMode);
|
|
|
|
CHECK_WRITING_MODE(aRect2.mWritingMode);
|
2017-11-07 17:38:31 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Compute using nsRect and assert the results match
|
|
|
|
nsRect rectDebug;
|
|
|
|
rectDebug.IntersectRect(
|
|
|
|
nsRect(aRect1.mIStart, aRect1.mBStart, aRect1.mISize, aRect1.mBSize),
|
|
|
|
nsRect(aRect2.mIStart, aRect2.mBStart, aRect2.mISize, aRect2.mBSize));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nscoord iEnd = std::min(aRect1.IEnd(), aRect2.IEnd());
|
|
|
|
mIStart = std::max(aRect1.mIStart, aRect2.mIStart);
|
|
|
|
mISize = iEnd - mIStart;
|
|
|
|
|
|
|
|
nscoord bEnd = std::min(aRect1.BEnd(), aRect2.BEnd());
|
|
|
|
mBStart = std::max(aRect1.mBStart, aRect2.mBStart);
|
|
|
|
mBSize = bEnd - mBStart;
|
|
|
|
|
|
|
|
if (mISize < 0 || mBSize < 0) {
|
|
|
|
mISize = 0;
|
|
|
|
mBSize = 0;
|
|
|
|
}
|
|
|
|
|
2018-04-19 16:56:29 +03:00
|
|
|
MOZ_ASSERT(
|
|
|
|
(rectDebug.IsEmpty() && (mISize == 0 || mBSize == 0)) ||
|
|
|
|
rectDebug.IsEqualEdges(nsRect(mIStart, mBStart, mISize, mBSize)));
|
2017-11-07 17:38:31 +03:00
|
|
|
return mISize > 0 && mBSize > 0;
|
2015-04-24 01:15:32 +03:00
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
private:
|
2015-01-07 02:35:02 +03:00
|
|
|
LogicalRect() = delete;
|
2013-12-27 21:58:37 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
WritingMode GetWritingMode() const { return mWritingMode; }
|
|
|
|
#else
|
|
|
|
WritingMode GetWritingMode() const { return WritingMode::Unknown(); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nscoord IStart() const // inline-start edge
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mIStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord IEnd() const // inline-end edge
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mIStart + mISize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord ISize() const // inline-size
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mISize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord BStart() const // block-start edge
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord BEnd() const // block-end edge
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBStart + mBSize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord BSize() const // block-size
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBSize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord& IStart() // inline-start edge
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mIStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord& ISize() // inline-size
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mISize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord& BStart() // block-start edge
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBStart;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
nscoord& BSize() // block-size
|
|
|
|
{
|
2017-11-07 17:38:31 +03:00
|
|
|
return mBSize;
|
2013-12-27 21:58:37 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 13:32:50 +04:00
|
|
|
#ifdef DEBUG
|
2013-12-27 21:58:37 +04:00
|
|
|
WritingMode mWritingMode;
|
2014-10-08 13:32:50 +04:00
|
|
|
#endif
|
2017-11-07 17:38:31 +03:00
|
|
|
// Inline- and block-geometry dimension
|
|
|
|
nscoord mIStart; // inline-start edge
|
|
|
|
nscoord mBStart; // block-start edge
|
|
|
|
nscoord mISize; // inline-size
|
|
|
|
nscoord mBSize; // block-size
|
2013-12-27 21:58:37 +04:00
|
|
|
};
|
|
|
|
|
2019-01-26 13:00:44 +03:00
|
|
|
template <typename T>
|
|
|
|
const T& StyleRect<T>::Get(mozilla::WritingMode aWM,
|
|
|
|
mozilla::LogicalSide aSide) const {
|
|
|
|
return Get(aWM.PhysicalSide(aSide));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
const T& StyleRect<T>::GetIStart(mozilla::WritingMode aWM) const {
|
|
|
|
return Get(aWM, mozilla::eLogicalSideIStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
const T& StyleRect<T>::GetBStart(mozilla::WritingMode aWM) const {
|
|
|
|
return Get(aWM, mozilla::eLogicalSideBStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
const T& StyleRect<T>::GetIEnd(mozilla::WritingMode aWM) const {
|
|
|
|
return Get(aWM, mozilla::eLogicalSideIEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
const T& StyleRect<T>::GetBEnd(mozilla::WritingMode aWM) const {
|
|
|
|
return Get(aWM, mozilla::eLogicalSideBEnd);
|
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-05-11 13:35:47 +03:00
|
|
|
// Definitions of inline methods for nsStylePosition, declared in
|
|
|
|
// nsStyleStruct.h but not defined there because they need WritingMode.
|
2019-02-10 15:55:16 +03:00
|
|
|
inline const mozilla::StyleSize& nsStylePosition::ISize(WritingMode aWM) const {
|
2015-05-11 13:35:47 +03:00
|
|
|
return aWM.IsVertical() ? mHeight : mWidth;
|
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline const mozilla::StyleSize& nsStylePosition::MinISize(
|
|
|
|
WritingMode aWM) const {
|
2015-05-11 13:35:47 +03:00
|
|
|
return aWM.IsVertical() ? mMinHeight : mMinWidth;
|
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline const mozilla::StyleMaxSize& nsStylePosition::MaxISize(
|
|
|
|
WritingMode aWM) const {
|
2015-05-11 13:35:47 +03:00
|
|
|
return aWM.IsVertical() ? mMaxHeight : mMaxWidth;
|
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline const mozilla::StyleSize& nsStylePosition::BSize(WritingMode aWM) const {
|
2015-05-11 13:35:47 +03:00
|
|
|
return aWM.IsVertical() ? mWidth : mHeight;
|
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline const mozilla::StyleSize& nsStylePosition::MinBSize(
|
|
|
|
WritingMode aWM) const {
|
2015-05-11 13:35:47 +03:00
|
|
|
return aWM.IsVertical() ? mMinWidth : mMinHeight;
|
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline const mozilla::StyleMaxSize& nsStylePosition::MaxBSize(
|
|
|
|
WritingMode aWM) const {
|
2015-05-11 13:35:47 +03:00
|
|
|
return aWM.IsVertical() ? mMaxWidth : mMaxHeight;
|
|
|
|
}
|
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
inline bool nsStylePosition::ISizeDependsOnContainer(WritingMode aWM) const {
|
|
|
|
const auto& iSize = ISize(aWM);
|
|
|
|
return iSize.IsAuto() || ISizeCoordDependsOnContainer(iSize);
|
2015-05-11 13:35:47 +03:00
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline bool nsStylePosition::MinISizeDependsOnContainer(WritingMode aWM) const {
|
2018-10-30 01:56:42 +03:00
|
|
|
// NOTE: For a flex item, "min-inline-size:auto" is supposed to behave like
|
|
|
|
// "min-content", which does depend on the container, so you might think we'd
|
|
|
|
// need a special case for "flex item && min-inline-size:auto" here. However,
|
|
|
|
// we don't actually need that special-case code, because flex items are
|
|
|
|
// explicitly supposed to *ignore* their min-inline-size (i.e. behave like
|
|
|
|
// it's 0) until the flex container explicitly considers it. So -- since the
|
|
|
|
// flex container doesn't rely on this method, we don't need to worry about
|
|
|
|
// special behavior for flex items' "min-inline-size:auto" values here.
|
|
|
|
return ISizeCoordDependsOnContainer(MinISize(aWM));
|
2015-05-11 13:35:47 +03:00
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline bool nsStylePosition::MaxISizeDependsOnContainer(WritingMode aWM) const {
|
2018-10-30 01:56:42 +03:00
|
|
|
// NOTE: The comment above MinISizeDependsOnContainer about flex items
|
|
|
|
// applies here, too.
|
|
|
|
return ISizeCoordDependsOnContainer(MaxISize(aWM));
|
2015-05-11 13:35:47 +03:00
|
|
|
}
|
2018-10-30 01:56:42 +03:00
|
|
|
// Note that these functions count `auto` as depending on the container
|
|
|
|
// since that's the case for absolutely positioned elements.
|
|
|
|
// However, some callers do not care about this case and should check
|
|
|
|
// for it, since it is the most common case.
|
|
|
|
// FIXME: We should probably change the assumption to be the other way
|
|
|
|
// around.
|
2019-02-10 15:55:16 +03:00
|
|
|
inline bool nsStylePosition::BSizeDependsOnContainer(WritingMode aWM) const {
|
|
|
|
const auto& bSize = BSize(aWM);
|
|
|
|
return bSize.BehavesLikeInitialValueOnBlockAxis() ||
|
|
|
|
BSizeCoordDependsOnContainer(bSize);
|
2015-05-11 13:35:47 +03:00
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline bool nsStylePosition::MinBSizeDependsOnContainer(WritingMode aWM) const {
|
2018-10-30 01:56:42 +03:00
|
|
|
return BSizeCoordDependsOnContainer(MinBSize(aWM));
|
2015-05-11 13:35:47 +03:00
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
inline bool nsStylePosition::MaxBSizeDependsOnContainer(WritingMode aWM) const {
|
2018-10-30 01:56:42 +03:00
|
|
|
return BSizeCoordDependsOnContainer(MaxBSize(aWM));
|
2015-05-11 13:35:47 +03:00
|
|
|
}
|
|
|
|
|
2016-05-18 14:49:32 +03:00
|
|
|
inline bool nsStyleMargin::HasBlockAxisAuto(mozilla::WritingMode aWM) const {
|
2019-01-26 13:00:44 +03:00
|
|
|
return mMargin.GetBStart(aWM).IsAuto() || mMargin.GetBEnd(aWM).IsAuto();
|
2016-05-18 14:49:32 +03:00
|
|
|
}
|
2019-01-26 13:00:44 +03:00
|
|
|
|
2016-05-18 14:49:32 +03:00
|
|
|
inline bool nsStyleMargin::HasInlineAxisAuto(mozilla::WritingMode aWM) const {
|
2019-01-26 13:00:44 +03:00
|
|
|
return mMargin.GetIStart(aWM).IsAuto() || mMargin.GetIEnd(aWM).IsAuto();
|
2016-05-18 14:49:32 +03:00
|
|
|
}
|
|
|
|
|
2013-12-27 21:58:37 +04:00
|
|
|
#endif // WritingModes_h_
|