Skip to content

Commit eafeeab

Browse files
author
Sam
committed
Add types ScrollLocation documentation. Insert continue in layers loop instead of early return.
1 parent 29837e9 commit eafeeab

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

webrender/src/frame.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,28 +328,30 @@ impl Frame {
328328
continue;
329329
}
330330

331-
let mut delta:Point2D<f32> = match scroll_location {
331+
let mut delta = match scroll_location {
332332
ScrollLocation::Delta(delta) => delta,
333333
ScrollLocation::Start => {
334-
if layer.scrolling.offset.y.round() == 0.0 {
335-
// Nothing to do.
336-
return false;
334+
if layer.scrolling.offset.y.round() <= 0.0 {
335+
// Nothing to do on this layer.
336+
continue;
337337
}
338338

339339
layer.scrolling.offset.y = 0.0;
340-
return true;
340+
scrolled_a_layer = true;
341+
continue;
341342
},
342343
ScrollLocation::End => {
343344
let end_pos = -layer.content_size.height +
344-
(layer.local_viewport_rect.size.height);
345+
layer.local_viewport_rect.size.height;
345346

346-
if layer.scrolling.offset.y.round() == end_pos {
347-
// Nothing to do.
348-
return false;
347+
if layer.scrolling.offset.y.round() >= end_pos {
348+
// Nothing to do on this layer.
349+
continue;
349350
}
350351

351352
layer.scrolling.offset.y = end_pos;
352-
return true;
353+
scrolled_a_layer = true;
354+
continue;
353355
},
354356
};
355357

webrender_traits/src/types.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,12 @@ pub enum ScrollPolicy {
445445

446446
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
447447
pub enum ScrollLocation {
448-
Delta(Point2D<f32>), // Scroll by a certain amount.
449-
Start, // Scroll to very top of element.
450-
End // Scroll to very bottom of element.
448+
/// Scroll by a certain amount.
449+
Delta(Point2D<f32>),
450+
/// Scroll to very top of element.
451+
Start,
452+
/// Scroll to very bottom of element.
453+
End
451454
}
452455

453456
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]

0 commit comments

Comments
 (0)