Skip to content

Commit 7f6d782

Browse files
committed
Add document argument to render API
1 parent ae2477d commit 7f6d782

File tree

1 file changed

+20
-33
lines changed

1 file changed

+20
-33
lines changed

webrender/src/renderer/mod.rs

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,47 +1254,34 @@ impl Renderer {
12541254
/// is active, otherwise 0 should be passed here.
12551255
pub fn render(
12561256
&mut self,
1257+
doc_id: DocumentId,
12571258
device_size: DeviceIntSize,
12581259
buffer_age: usize,
12591260
) -> Result<RenderResults, Vec<RendererError>> {
12601261
self.device_size = Some(device_size);
12611262

1262-
// TODO(gw): We want to make the active document that is
1263-
// being rendered configurable via the public
1264-
// API in future. For now, just select the last
1265-
// added document as the active one to render
1266-
// (Gecko only ever creates a single document
1267-
// per renderer right now).
1268-
let doc_id = self.active_documents.keys().last().cloned();
1269-
1270-
let result = match doc_id {
1271-
Some(doc_id) => {
1272-
// Remove the doc from the map to appease the borrow checker
1273-
let mut doc = self.active_documents
1274-
.remove(&doc_id)
1275-
.unwrap();
1276-
1277-
let size = if !device_size.is_empty() {
1278-
Some(device_size)
1279-
} else {
1280-
None
1281-
};
1263+
let result = {
1264+
// Remove the doc from the map to appease the borrow checker
1265+
let mut doc = self.active_documents
1266+
.remove(&doc_id)
1267+
.unwrap();
12821268

1283-
let result = self.render_impl(
1284-
doc_id,
1285-
&mut doc,
1286-
size,
1287-
buffer_age,
1288-
);
1269+
let size = if !device_size.is_empty() {
1270+
Some(device_size)
1271+
} else {
1272+
None
1273+
};
12891274

1290-
self.active_documents.insert(doc_id, doc);
1275+
let result = self.render_impl(
1276+
doc_id,
1277+
&mut doc,
1278+
size,
1279+
buffer_age,
1280+
);
12911281

1292-
result
1293-
}
1294-
None => {
1295-
self.last_time = precise_time_ns();
1296-
Ok(RenderResults::default())
1297-
}
1282+
self.active_documents.insert(doc_id, doc);
1283+
1284+
result
12981285
};
12991286

13001287
drain_filter(

0 commit comments

Comments
 (0)