stylo: Add uses of fallible Vec, SmallVec and HashMap facilities.

Bug: 1395064
Reviewed-by: emilio
This commit is contained in:
Julian Seward 2017-09-10 12:25:01 +02:00 committed by Emilio Cobos Álvarez
parent 815fb6b058
commit c85633f48e
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
10 changed files with 125 additions and 57 deletions

View file

@ -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,