mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 04:05:32 +00:00
ca59532ce8
This will save us some time from figuring out what's the best thing to do in bug 1552587, so that other patches I have in flight (mainly bug 1552708) can land, since we cannot add a single byte to nsStyleDisplay right now otherwise. The code removed here is well isolated and not that complicated, so it seems to me that should be easy to bring back should we have an emergency (and I commit to doing that while preserving the nsStyleDisplay size limit if we need to :)). Differential Revision: https://phabricator.services.mozilla.com/D32026 --HG-- extra : moz-landing-system : lando
71 lines
2.6 KiB
C++
71 lines
2.6 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/ScrollStyles.h"
|
|
#include "mozilla/WritingModes.h"
|
|
#include "nsStyleStruct.h" // for nsStyleDisplay & nsStyleBackground::Position
|
|
|
|
namespace mozilla {
|
|
|
|
void ScrollStyles::InitializeScrollSnapType(WritingMode aWritingMode,
|
|
const nsStyleDisplay* aDisplay) {
|
|
mScrollSnapTypeX = StyleScrollSnapStrictness::None;
|
|
mScrollSnapTypeY = StyleScrollSnapStrictness::None;
|
|
|
|
if (aDisplay->mScrollSnapType.strictness == StyleScrollSnapStrictness::None) {
|
|
return;
|
|
}
|
|
|
|
switch (aDisplay->mScrollSnapType.axis) {
|
|
case StyleScrollSnapAxis::X:
|
|
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
|
|
break;
|
|
case StyleScrollSnapAxis::Y:
|
|
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
|
|
break;
|
|
case StyleScrollSnapAxis::Block:
|
|
if (aWritingMode.IsVertical()) {
|
|
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
|
|
} else {
|
|
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
|
|
}
|
|
break;
|
|
case StyleScrollSnapAxis::Inline:
|
|
if (aWritingMode.IsVertical()) {
|
|
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
|
|
} else {
|
|
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
|
|
}
|
|
break;
|
|
case StyleScrollSnapAxis::Both:
|
|
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
|
|
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
|
|
break;
|
|
}
|
|
}
|
|
|
|
ScrollStyles::ScrollStyles(WritingMode aWritingMode, StyleOverflow aH,
|
|
StyleOverflow aV, const nsStyleDisplay* aDisplay)
|
|
: mHorizontal(aH),
|
|
mVertical(aV),
|
|
mScrollBehavior(aDisplay->mScrollBehavior),
|
|
mOverscrollBehaviorX(aDisplay->mOverscrollBehaviorX),
|
|
mOverscrollBehaviorY(aDisplay->mOverscrollBehaviorY) {
|
|
InitializeScrollSnapType(aWritingMode, aDisplay);
|
|
}
|
|
|
|
ScrollStyles::ScrollStyles(WritingMode aWritingMode,
|
|
const nsStyleDisplay* aDisplay)
|
|
: mHorizontal(aDisplay->mOverflowX),
|
|
mVertical(aDisplay->mOverflowY),
|
|
mScrollBehavior(aDisplay->mScrollBehavior),
|
|
mOverscrollBehaviorX(aDisplay->mOverscrollBehaviorX),
|
|
mOverscrollBehaviorY(aDisplay->mOverscrollBehaviorY) {
|
|
InitializeScrollSnapType(aWritingMode, aDisplay);
|
|
}
|
|
|
|
} // namespace mozilla
|