mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1721265 Part 1 - Add method to ServoStyleSet to determine if the default page-size is landscape or portrait. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D124975
This commit is contained in:
parent
2db29ccfa9
commit
4294039c89
@ -631,6 +631,28 @@ StyleSheet* ServoStyleSet::SheetAt(Origin aOrigin, size_t aIndex) const {
|
||||
Servo_StyleSet_GetSheetAt(mRawSet.get(), aOrigin, aIndex));
|
||||
}
|
||||
|
||||
Maybe<StyleOrientation> ServoStyleSet::GetDefaultPageOrientation() {
|
||||
const RefPtr<ComputedStyle> style =
|
||||
ResolveNonInheritingAnonymousBoxStyle(PseudoStyleType::pageContent);
|
||||
const StylePageSize& pageSize = style->StylePage()->mSize;
|
||||
if (pageSize.IsOrientation()) {
|
||||
return Some(pageSize.AsOrientation());
|
||||
}
|
||||
if (pageSize.IsSize()) {
|
||||
const CSSCoord w = pageSize.AsSize().width.ToCSSPixels();
|
||||
const CSSCoord h = pageSize.AsSize().height.ToCSSPixels();
|
||||
if (w > h) {
|
||||
return Some(StyleOrientation::Landscape);
|
||||
}
|
||||
if (w < h) {
|
||||
return Some(StyleOrientation::Portrait);
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(pageSize.IsAuto(), "Impossible page size");
|
||||
}
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
void ServoStyleSet::AppendAllNonDocumentAuthorSheets(
|
||||
nsTArray<StyleSheet*>& aArray) const {
|
||||
EnumerateShadowRoots(*mDocument, [&](ShadowRoot& aShadowRoot) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/AtomArray.h"
|
||||
#include "mozilla/EnumeratedArray.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/PostTraversalTask.h"
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
#include "mozilla/ServoUtils.h"
|
||||
@ -27,6 +28,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
enum class MediaFeatureChangeReason : uint16_t;
|
||||
enum class StyleOrientation : uint8_t;
|
||||
enum class StyleRuleChangeKind : uint32_t;
|
||||
namespace css {
|
||||
class Rule;
|
||||
@ -233,6 +235,13 @@ class ServoStyleSet {
|
||||
size_t SheetCount(Origin) const;
|
||||
StyleSheet* SheetAt(Origin, size_t aIndex) const;
|
||||
|
||||
// Gets the default orientation of unnamed CSS pages.
|
||||
// This will return portrait or landscape both for a landscape/portrait
|
||||
// value to page-size, as well as for an explicit size or paper name which
|
||||
// is not square.
|
||||
// If the value is auto or square, then returns nothing.
|
||||
Maybe<StyleOrientation> GetDefaultPageOrientation();
|
||||
|
||||
void AppendAllNonDocumentAuthorSheets(nsTArray<StyleSheet*>& aArray) const;
|
||||
|
||||
// Manage the set of style sheets in the style set
|
||||
|
Loading…
Reference in New Issue
Block a user