mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-26 10:10:31 +00:00
Bug 1399505 - Expose the API to add sticky frames to the WR display list. r=mstange
MozReview-Commit-ID: 1SEz6bqMoME --HG-- extra : rebase_source : 133853e09f8bc5b1e7d725a53ef3d6a0ab1fdc00
This commit is contained in:
parent
2ccabda678
commit
59ea9aa15f
@ -102,6 +102,16 @@ AppendToString(std::stringstream& aStream, const wr::LayoutSize& s,
|
|||||||
aStream << sfx;
|
aStream << sfx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AppendToString(std::stringstream& aStream, const wr::StickySideConstraint& s,
|
||||||
|
const char* pfx, const char* sfx)
|
||||||
|
{
|
||||||
|
aStream << pfx;
|
||||||
|
aStream << nsPrintfCString("(margin=%f max=%f)",
|
||||||
|
s.margin, s.max_offset).get();
|
||||||
|
aStream << sfx;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AppendToString(std::stringstream& aStream, const nsRegion& r,
|
AppendToString(std::stringstream& aStream, const nsRegion& r,
|
||||||
const char* pfx, const char* sfx)
|
const char* pfx, const char* sfx)
|
||||||
|
@ -121,6 +121,10 @@ void
|
|||||||
AppendToString(std::stringstream& aStream, const wr::LayoutSize& s,
|
AppendToString(std::stringstream& aStream, const wr::LayoutSize& s,
|
||||||
const char* pfx="", const char* sfx="");
|
const char* pfx="", const char* sfx="");
|
||||||
|
|
||||||
|
void
|
||||||
|
AppendToString(std::stringstream& aStream, const wr::StickySideConstraint& s,
|
||||||
|
const char* pfx="", const char* sfx="");
|
||||||
|
|
||||||
void
|
void
|
||||||
AppendToString(std::stringstream& aStream, const nsRegion& r,
|
AppendToString(std::stringstream& aStream, const nsRegion& r,
|
||||||
const char* pfx="", const char* sfx="");
|
const char* pfx="", const char* sfx="");
|
||||||
|
@ -726,6 +726,38 @@ DisplayListBuilder::PopClip(bool aRecordInStack)
|
|||||||
wr_dp_pop_clip(mWrState);
|
wr_dp_pop_clip(mWrState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wr::WrStickyId
|
||||||
|
DisplayListBuilder::DefineStickyFrame(const wr::LayoutRect& aContentRect,
|
||||||
|
const wr::StickySideConstraint* aTop,
|
||||||
|
const wr::StickySideConstraint* aRight,
|
||||||
|
const wr::StickySideConstraint* aBottom,
|
||||||
|
const wr::StickySideConstraint* aLeft)
|
||||||
|
{
|
||||||
|
uint64_t id = wr_dp_define_sticky_frame(mWrState, aContentRect, aTop,
|
||||||
|
aRight, aBottom, aLeft);
|
||||||
|
WRDL_LOG("DefineSticky id=%" PRIu64 " c=%s t=%s r=%s b=%s l=%s\n", mWrState, id,
|
||||||
|
Stringify(aContentRect).c_str(),
|
||||||
|
aTop ? Stringify(*aTop).c_str() : "none",
|
||||||
|
aRight ? Stringify(*aRight).c_str() : "none",
|
||||||
|
aBottom ? Stringify(*aBottom).c_str() : "none",
|
||||||
|
aLeft ? Stringify(*aLeft).c_str() : "none");
|
||||||
|
return wr::WrStickyId { id };
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DisplayListBuilder::PushStickyFrame(const wr::WrStickyId& aStickyId)
|
||||||
|
{
|
||||||
|
wr_dp_push_clip(mWrState, aStickyId.id);
|
||||||
|
WRDL_LOG("PushSticky id=%" PRIu64 "\n", mWrState, aStickyId.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DisplayListBuilder::PopStickyFrame()
|
||||||
|
{
|
||||||
|
WRDL_LOG("PopSticky\n", mWrState);
|
||||||
|
wr_dp_pop_clip(mWrState);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DisplayListBuilder::PushBuiltDisplayList(BuiltDisplayList &dl)
|
DisplayListBuilder::PushBuiltDisplayList(BuiltDisplayList &dl)
|
||||||
{
|
{
|
||||||
|
@ -229,6 +229,14 @@ public:
|
|||||||
void PushClip(const wr::WrClipId& aClipId, bool aRecordInStack = true);
|
void PushClip(const wr::WrClipId& aClipId, bool aRecordInStack = true);
|
||||||
void PopClip(bool aRecordInStack = true);
|
void PopClip(bool aRecordInStack = true);
|
||||||
|
|
||||||
|
wr::WrStickyId DefineStickyFrame(const wr::LayoutRect& aContentRect,
|
||||||
|
const wr::StickySideConstraint* aTop,
|
||||||
|
const wr::StickySideConstraint* aRight,
|
||||||
|
const wr::StickySideConstraint* aBottom,
|
||||||
|
const wr::StickySideConstraint* aLeft);
|
||||||
|
void PushStickyFrame(const wr::WrStickyId& aStickyId);
|
||||||
|
void PopStickyFrame();
|
||||||
|
|
||||||
void PushBuiltDisplayList(wr::BuiltDisplayList &dl);
|
void PushBuiltDisplayList(wr::BuiltDisplayList &dl);
|
||||||
|
|
||||||
bool IsScrollLayerDefined(layers::FrameMetrics::ViewID aScrollId) const;
|
bool IsScrollLayerDefined(layers::FrameMetrics::ViewID aScrollId) const;
|
||||||
|
@ -736,6 +736,16 @@ struct WrClipId {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Corresponds to a clip id for a position:sticky clip in webrender. Similar
|
||||||
|
// to WrClipId but a separate struct so we don't get them mixed up in C++.
|
||||||
|
struct WrStickyId {
|
||||||
|
uint64_t id;
|
||||||
|
|
||||||
|
bool operator==(const WrClipId& other) const {
|
||||||
|
return id == other.id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
typedef Variant<layers::FrameMetrics::ViewID, WrClipId> ScrollOrClipId;
|
typedef Variant<layers::FrameMetrics::ViewID, WrClipId> ScrollOrClipId;
|
||||||
|
|
||||||
enum class WebRenderError : int8_t {
|
enum class WebRenderError : int8_t {
|
||||||
|
@ -1214,6 +1214,31 @@ pub extern "C" fn wr_dp_pop_clip(state: &mut WrState) {
|
|||||||
state.frame_builder.dl_builder.pop_clip_id();
|
state.frame_builder.dl_builder.pop_clip_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn wr_dp_define_sticky_frame(state: &mut WrState,
|
||||||
|
content_rect: LayoutRect,
|
||||||
|
top_range: *const StickySideConstraint,
|
||||||
|
right_range: *const StickySideConstraint,
|
||||||
|
bottom_range: *const StickySideConstraint,
|
||||||
|
left_range: *const StickySideConstraint)
|
||||||
|
-> u64 {
|
||||||
|
assert!(unsafe { is_in_main_thread() });
|
||||||
|
let clip_id = state.frame_builder.dl_builder.define_sticky_frame(
|
||||||
|
None, content_rect, StickyFrameInfo::new(
|
||||||
|
unsafe { top_range.as_ref() }.cloned(),
|
||||||
|
unsafe { right_range.as_ref() }.cloned(),
|
||||||
|
unsafe { bottom_range.as_ref() }.cloned(),
|
||||||
|
unsafe { left_range.as_ref() }.cloned()));
|
||||||
|
match clip_id {
|
||||||
|
ClipId::Clip(id, nesting_index, pipeline_id) => {
|
||||||
|
assert!(pipeline_id == state.pipeline_id);
|
||||||
|
assert!(nesting_index == 0);
|
||||||
|
id
|
||||||
|
},
|
||||||
|
_ => panic!("Got unexpected clip id type"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn wr_dp_define_scroll_layer(state: &mut WrState,
|
pub extern "C" fn wr_dp_define_scroll_layer(state: &mut WrState,
|
||||||
scroll_id: u64,
|
scroll_id: u64,
|
||||||
|
@ -439,6 +439,16 @@ struct WrImageMask {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct StickySideConstraint {
|
||||||
|
float margin;
|
||||||
|
float max_offset;
|
||||||
|
|
||||||
|
bool operator==(const StickySideConstraint& aOther) const {
|
||||||
|
return margin == aOther.margin &&
|
||||||
|
max_offset == aOther.max_offset;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct BorderWidths {
|
struct BorderWidths {
|
||||||
float left;
|
float left;
|
||||||
float top;
|
float top;
|
||||||
@ -858,6 +868,15 @@ void wr_dp_define_scroll_layer(WrState *aState,
|
|||||||
LayoutRect aClipRect)
|
LayoutRect aClipRect)
|
||||||
WR_FUNC;
|
WR_FUNC;
|
||||||
|
|
||||||
|
WR_INLINE
|
||||||
|
uint64_t wr_dp_define_sticky_frame(WrState *aState,
|
||||||
|
LayoutRect aContentRect,
|
||||||
|
const StickySideConstraint *aTopRange,
|
||||||
|
const StickySideConstraint *aRightRange,
|
||||||
|
const StickySideConstraint *aBottomRange,
|
||||||
|
const StickySideConstraint *aLeftRange)
|
||||||
|
WR_FUNC;
|
||||||
|
|
||||||
WR_INLINE
|
WR_INLINE
|
||||||
void wr_dp_end(WrState *aState)
|
void wr_dp_end(WrState *aState)
|
||||||
WR_FUNC;
|
WR_FUNC;
|
||||||
|
Loading…
Reference in New Issue
Block a user