mirror of
https://github.com/servo/servo.git
synced 2025-08-30 17:48:20 +01:00
stylo: Add uses of fallible Vec, SmallVec and HashMap facilities.
Bug: 1395064 Reviewed-by: emilio
This commit is contained in:
parent
815fb6b058
commit
c85633f48e
10 changed files with 125 additions and 57 deletions
|
@ -6,6 +6,7 @@ use {Prefix, Namespace};
|
|||
use context::QuirksMode;
|
||||
use cssparser::{Parser, RuleListParser, ParserInput};
|
||||
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use fallible::FallibleVec;
|
||||
use fnv::FnvHashMap;
|
||||
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||
use media_queries::{MediaList, Device};
|
||||
|
@ -382,7 +383,14 @@ impl Stylesheet {
|
|||
|
||||
while let Some(result) = iter.next() {
|
||||
match result {
|
||||
Ok(rule) => rules.push(rule),
|
||||
Ok(rule) => {
|
||||
// Use a fallible push here, and if it fails, just
|
||||
// fall out of the loop. This will cause the page to
|
||||
// be shown incorrectly, but it's better than OOMing.
|
||||
if rules.try_push(rule).is_err() {
|
||||
break;
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
let error = ContextualParseError::InvalidRule(err.slice, err.error);
|
||||
iter.parser.context.log_css_error(&iter.parser.error_context,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue