зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1676791 - Part 1: Add ScrollTimeline class. r=hiro
Define a simple version of ScrollTimeline. Differential Revision: https://phabricator.services.mozilla.com/D129099
This commit is contained in:
Родитель
e0197fccf4
Коммит
470f574f58
|
@ -0,0 +1,41 @@
|
|||
/* -*- 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 "ScrollTimeline.h"
|
||||
|
||||
#include "mozilla/dom/Animation.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(ScrollTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ScrollTimeline,
|
||||
AnimationTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSource)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ScrollTimeline,
|
||||
AnimationTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSource)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(ScrollTimeline,
|
||||
AnimationTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(ScrollTimeline,
|
||||
AnimationTimeline)
|
||||
|
||||
ScrollTimeline::ScrollTimeline(Document* aDocument, Element* aScroller)
|
||||
: AnimationTimeline(aDocument->GetParentObject()),
|
||||
mDocument(aDocument),
|
||||
mSource(aScroller),
|
||||
mDirection(StyleScrollDirection::Auto) {
|
||||
// TODO: Register the timeline to the soruce element in the next patch.
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
|
@ -0,0 +1,64 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ScrollTimeline_h
|
||||
#define mozilla_dom_ScrollTimeline_h
|
||||
|
||||
#include "mozilla/dom/AnimationTimeline.h"
|
||||
#include "mozilla/ServoStyleConsts.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ScrollTimeline final : public AnimationTimeline {
|
||||
public:
|
||||
ScrollTimeline() = delete;
|
||||
ScrollTimeline(Document* aDocument, Element* aScroller);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(ScrollTimeline,
|
||||
AnimationTimeline)
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override {
|
||||
// FIXME: Bug 1676794: Implement ScrollTimeline interface.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// AnimationTimeline methods.
|
||||
Nullable<TimeDuration> GetCurrentTimeAsDuration() const override {
|
||||
// FIXME: We will update this function in the patch series.
|
||||
return nullptr;
|
||||
}
|
||||
bool TracksWallclockTime() const override { return false; }
|
||||
Nullable<TimeDuration> ToTimelineTime(
|
||||
const TimeStamp& aTimeStamp) const override {
|
||||
// It's unclear to us what should we do for this function now, so return
|
||||
// nullptr.
|
||||
return nullptr;
|
||||
}
|
||||
TimeStamp ToTimeStamp(const TimeDuration& aTimelineTime) const override {
|
||||
// It's unclear to us what should we do for this function now, so return
|
||||
// zero time.
|
||||
return {};
|
||||
}
|
||||
Document* GetDocument() const override { return mDocument; }
|
||||
|
||||
protected:
|
||||
virtual ~ScrollTimeline() = default;
|
||||
|
||||
private:
|
||||
RefPtr<Document> mDocument;
|
||||
|
||||
// FIXME: We will use these data members in the following patches.
|
||||
RefPtr<Element> mSource;
|
||||
StyleScrollDirection mDirection;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ScrollTimeline_h
|
|
@ -19,6 +19,7 @@ EXPORTS.mozilla.dom += [
|
|||
"CSSTransition.h",
|
||||
"DocumentTimeline.h",
|
||||
"KeyframeEffect.h",
|
||||
"ScrollTimeline.h",
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
|
@ -58,6 +59,7 @@ UNIFIED_SOURCES += [
|
|||
"KeyframeEffect.cpp",
|
||||
"KeyframeUtils.cpp",
|
||||
"PendingAnimationTracker.cpp",
|
||||
"ScrollTimeline.cpp",
|
||||
"TimingParams.cpp",
|
||||
]
|
||||
|
||||
|
|
|
@ -438,6 +438,7 @@ cbindgen-types = [
|
|||
{ gecko = "StyleBreakWithin", servo = "crate::values::computed::BreakWithin" },
|
||||
{ gecko = "StyleBorderStyle", servo = "crate::values::computed::BorderStyle" },
|
||||
{ gecko = "StyleOutlineStyle", servo = "crate::values::computed::OutlineStyle" },
|
||||
{ gecko = "StyleScrollDirection", servo = "crate::stylesheets::scroll_timeline_rule::ScrollDirection" },
|
||||
{ gecko = "StyleScrollSnapAlign", servo = "crate::values::computed::ScrollSnapAlign" },
|
||||
{ gecko = "StyleScrollSnapStrictness", servo = "crate::values::computed::ScrollSnapStrictness" },
|
||||
{ gecko = "StyleScrollSnapType", servo = "crate::values::computed::ScrollSnapType" },
|
||||
|
|
|
@ -182,7 +182,8 @@ impl Default for Source {
|
|||
/// definition of ScrollTimelineOptions (WebIDL API).
|
||||
/// https://drafts.csswg.org/scroll-animations/#dom-scrolltimelineoptions-orientation
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, Eq, Parse, PartialEq, PartialOrd, ToCss, ToShmem)]
|
||||
pub enum Orientation {
|
||||
#[repr(u8)]
|
||||
pub enum ScrollDirection {
|
||||
/// The initial value.
|
||||
Auto,
|
||||
/// The direction along the block axis. This is the default value.
|
||||
|
@ -195,12 +196,15 @@ pub enum Orientation {
|
|||
Vertical,
|
||||
}
|
||||
|
||||
impl Default for Orientation {
|
||||
impl Default for ScrollDirection {
|
||||
fn default() -> Self {
|
||||
Orientation::Auto
|
||||
ScrollDirection::Auto
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid name collision in cbindgen with StyleOrientation.
|
||||
pub use self::ScrollDirection as Orientation;
|
||||
|
||||
/// Scroll-timeline offsets. We treat None as an empty vector.
|
||||
/// value: none | <scroll-timeline-offset>#
|
||||
///
|
||||
|
|
|
@ -236,6 +236,7 @@ include = [
|
|||
"DProperty",
|
||||
"ImageRendering",
|
||||
"ScrollbarGutter",
|
||||
"ScrollDirection",
|
||||
]
|
||||
item_types = ["enums", "structs", "unions", "typedefs", "functions", "constants"]
|
||||
renaming_overrides_prefixing = true
|
||||
|
|
Загрузка…
Ссылка в новой задаче