mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Auto merge of #7203 - jdm:style, r=Ms2ger
Add automated style nit checks to test-tidy Expands on the work by @wilmoz and cleans up the existing errors. Closes #7180. Closes #7111. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7203) <!-- Reviewable:end -->
This commit is contained in:
commit
e74825f9fd
94 changed files with 489 additions and 405 deletions
|
@ -8,17 +8,11 @@ extern crate freetype;
|
|||
extern crate fontconfig;
|
||||
|
||||
use fontconfig::fontconfig::{FcChar8, FcResultMatch, FcSetSystem};
|
||||
use fontconfig::fontconfig::{
|
||||
FcConfigGetCurrent, FcConfigGetFonts,
|
||||
FcConfigSubstitute, FcDefaultSubstitute,
|
||||
FcFontMatch,
|
||||
FcNameParse, FcPatternGetString,
|
||||
FcPatternDestroy, FcFontSetDestroy,
|
||||
FcMatchPattern,
|
||||
FcPatternCreate, FcPatternAddString,
|
||||
FcFontSetList, FcObjectSetCreate, FcObjectSetDestroy,
|
||||
FcObjectSetAdd, FcPatternGetInteger
|
||||
};
|
||||
use fontconfig::fontconfig::{FcConfigGetCurrent, FcConfigGetFonts, FcConfigSubstitute};
|
||||
use fontconfig::fontconfig::{FcDefaultSubstitute, FcFontMatch, FcNameParse, FcPatternGetString};
|
||||
use fontconfig::fontconfig::{FcPatternDestroy, FcFontSetDestroy, FcMatchPattern, FcPatternCreate};
|
||||
use fontconfig::fontconfig::{FcPatternAddString, FcFontSetList, FcObjectSetCreate, FcObjectSetDestroy};
|
||||
use fontconfig::fontconfig::{FcObjectSetAdd, FcPatternGetInteger};
|
||||
|
||||
use util::str::c_str_to_string;
|
||||
|
||||
|
|
|
@ -45,10 +45,10 @@ use std::sync::Arc;
|
|||
use std::sync::mpsc::channel;
|
||||
use std::f32;
|
||||
use style::computed_values::filter::Filter;
|
||||
use style::computed_values::{background_attachment, background_clip, background_origin,
|
||||
background_repeat, background_size};
|
||||
use style::computed_values::{border_style, image_rendering, overflow_x, position,
|
||||
visibility, transform, transform_style};
|
||||
use style::computed_values::{background_attachment, background_clip, background_origin};
|
||||
use style::computed_values::{background_repeat, background_size};
|
||||
use style::computed_values::{border_style, image_rendering, overflow_x, position};
|
||||
use style::computed_values::{visibility, transform, transform_style};
|
||||
use style::properties::ComputedValues;
|
||||
use style::properties::style_structs::Border;
|
||||
use style::values::RGBA;
|
||||
|
|
|
@ -8,8 +8,8 @@ use syntax::ptr::P;
|
|||
use syntax::ast::{MetaItem, Expr};
|
||||
use syntax::ast;
|
||||
use syntax::ext::build::AstBuilder;
|
||||
use syntax::ext::deriving::generic::{combine_substructure, EnumMatching, FieldInfo, MethodDef, Struct,
|
||||
Substructure, TraitDef, ty};
|
||||
use syntax::ext::deriving::generic::{combine_substructure, EnumMatching, FieldInfo, MethodDef};
|
||||
use syntax::ext::deriving::generic::{Struct, Substructure, TraitDef, ty};
|
||||
|
||||
pub fn expand_dom_struct(cx: &mut ExtCtxt, sp: Span, _: &MetaItem, anno: Annotatable) -> Annotatable {
|
||||
if let Annotatable::Item(item) = anno {
|
||||
|
|
|
@ -191,8 +191,10 @@ impl CanvasRenderingContext2D {
|
|||
|
||||
// The destination rectangle is the rectangle whose corners are the four points (dx, dy),
|
||||
// (dx+dw, dy), (dx+dw, dy+dh), (dx, dy+dh).
|
||||
let dest_rect = Rect::new(Point2D::new(dx.min(dx+dest_rect_width_scaled), dy.min(dy+dest_rect_height_scaled)),
|
||||
Size2D::new(dest_rect_width_scaled.abs(), dest_rect_height_scaled.abs()));
|
||||
let dest_rect = Rect::new(Point2D::new(dx.min(dx + dest_rect_width_scaled),
|
||||
dy.min(dy + dest_rect_height_scaled)),
|
||||
Size2D::new(dest_rect_width_scaled.abs(),
|
||||
dest_rect_height_scaled.abs()));
|
||||
|
||||
let source_rect = Rect::new(Point2D::new(source_rect_clipped.origin.x,
|
||||
source_rect_clipped.origin.y),
|
||||
|
|
|
@ -7,8 +7,8 @@ use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
|
|||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, EventCast};
|
||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLElementCast,
|
||||
HTMLIFrameElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLElementCast};
|
||||
use dom::bindings::codegen::InheritTypes::HTMLIFrameElementDerived;
|
||||
use dom::bindings::conversions::ToJSValConvertible;
|
||||
use dom::bindings::error::{ErrorResult, Fallible};
|
||||
use dom::bindings::error::Error::NotSupported;
|
||||
|
|
|
@ -8,8 +8,8 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, EventTargetCast, HTMLElementCast,
|
||||
HTMLImageElementDerived};
|
||||
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, EventTargetCast};
|
||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLImageElementDerived};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{LayoutJS, Root};
|
||||
|
|
|
@ -32,8 +32,8 @@ use dom::bindings::js::{RootCollectionPtr, Root, RootedReference};
|
|||
use dom::bindings::refcounted::{LiveDOMReferences, Trusted, TrustedReference, trace_refcounted_objects};
|
||||
use dom::bindings::trace::{JSTraceable, trace_traceables, RootedVec};
|
||||
use dom::bindings::utils::{WRAP_CALLBACKS, DOM_CALLBACKS};
|
||||
use dom::document::{Document, IsHTMLDocument, DocumentHelpers, DocumentProgressHandler,
|
||||
DocumentProgressTask, DocumentSource, MouseEventType};
|
||||
use dom::document::{Document, IsHTMLDocument, DocumentHelpers, DocumentProgressHandler};
|
||||
use dom::document::{DocumentProgressTask, DocumentSource, MouseEventType};
|
||||
use dom::element::{Element, AttributeHandlers};
|
||||
use dom::event::{EventHelpers, EventBubbles, EventCancelable};
|
||||
use dom::htmliframeelement::HTMLIFrameElementHelpers;
|
||||
|
|
|
@ -10,8 +10,8 @@ use url::Url;
|
|||
|
||||
use encoding::EncodingRef;
|
||||
|
||||
use cssparser::{Parser, decode_stylesheet_bytes,
|
||||
QualifiedRuleParser, AtRuleParser, RuleListParser, AtRuleType};
|
||||
use cssparser::{Parser, decode_stylesheet_bytes, QualifiedRuleParser, AtRuleParser};
|
||||
use cssparser::{RuleListParser, AtRuleType};
|
||||
use string_cache::{Atom, Namespace};
|
||||
use selectors::parser::{Selector, parse_selector_list};
|
||||
use parser::{ParserContext, log_css_error};
|
||||
|
|
|
@ -19,18 +19,17 @@ extern crate rustc_serialize;
|
|||
extern crate uuid;
|
||||
extern crate ipc_channel;
|
||||
|
||||
use msg::constellation_msg::{ConstellationChan, LoadData, FrameId, PipelineId, NavigationDirection,
|
||||
WebDriverCommandMsg};
|
||||
use msg::constellation_msg::{ConstellationChan, LoadData, FrameId, PipelineId};
|
||||
use msg::constellation_msg::{NavigationDirection, WebDriverCommandMsg};
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
use msg::webdriver_msg::{WebDriverFrameId, WebDriverScriptCommand, WebDriverJSError, WebDriverJSResult, LoadStatus};
|
||||
|
||||
use url::Url;
|
||||
use webdriver::command::{WebDriverMessage, WebDriverCommand};
|
||||
use webdriver::command::{GetParameters, JavascriptCommandParameters, LocatorParameters,
|
||||
SwitchToFrameParameters, TimeoutsParameters};
|
||||
use webdriver::command::{GetParameters, JavascriptCommandParameters, LocatorParameters};
|
||||
use webdriver::command::{SwitchToFrameParameters, TimeoutsParameters};
|
||||
use webdriver::common::{LocatorStrategy, WebElement};
|
||||
use webdriver::response::{
|
||||
WebDriverResponse, NewSessionResponse, ValueResponse};
|
||||
use webdriver::response::{WebDriverResponse, NewSessionResponse, ValueResponse};
|
||||
use webdriver::server::{self, WebDriverHandler, Session};
|
||||
use webdriver::error::{WebDriverResult, WebDriverError, ErrorStatus};
|
||||
use util::task::spawn_named;
|
||||
|
|
|
@ -204,7 +204,8 @@ fn read_input_device(device_path: &Path,
|
|||
cur_dist, last_dist, screen_dist,
|
||||
((screen_dist + (cur_dist - last_dist)) / screen_dist));
|
||||
sender.send(
|
||||
WindowEvent::Zoom((screen_dist + (cur_dist - last_dist))/screen_dist)).ok().unwrap();
|
||||
WindowEvent::Zoom((screen_dist + (cur_dist - last_dist)) /
|
||||
screen_dist)).ok().unwrap();
|
||||
last_dist = cur_dist;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,6 +165,93 @@ def check_toml(file_name, contents):
|
|||
yield (idx + 1, "found asterisk instead of minimum version number")
|
||||
|
||||
|
||||
def check_rust(file_name, contents):
|
||||
if not file_name.endswith(".rs") or \
|
||||
file_name.endswith("properties.mako.rs") or \
|
||||
file_name.endswith("style/build.rs") or \
|
||||
file_name.endswith("unit/style/stylesheets.rs"):
|
||||
raise StopIteration
|
||||
contents = contents.splitlines(True)
|
||||
comment_depth = 0
|
||||
merged_lines = ''
|
||||
for idx, line in enumerate(contents):
|
||||
# simplify the analysis
|
||||
line = line.strip()
|
||||
|
||||
# Simple heuristic to avoid common case of no comments.
|
||||
if '/' in line:
|
||||
comment_depth += line.count('/*')
|
||||
comment_depth -= line.count('*/')
|
||||
|
||||
if line.endswith('\\'):
|
||||
merged_lines += line[:-1]
|
||||
continue
|
||||
if comment_depth:
|
||||
merged_lines += line
|
||||
continue
|
||||
if merged_lines:
|
||||
line = merged_lines + line
|
||||
merged_lines = ''
|
||||
|
||||
# get rid of strings and chars because cases like regex expression
|
||||
line = re.sub('".*?"|\'.*?\'', '', line)
|
||||
|
||||
# get rid of comments and attributes
|
||||
line = re.sub('//.*?$|/\*.*?$|^\*.*?$|^#.*?$', '', line)
|
||||
|
||||
match = re.search(r",[A-Za-z0-9]", line)
|
||||
if match:
|
||||
yield (idx + 1, "missing space after ,")
|
||||
|
||||
# Avoid flagging <Item=Foo> constructs
|
||||
def is_associated_type(match, line, index):
|
||||
open_angle = line[0:match.end()].rfind('<')
|
||||
close_angle = line[open_angle:].find('>') if open_angle != -1 else -1
|
||||
is_equals = match.group(0)[index] == '='
|
||||
generic_open = open_angle != -1 and open_angle < match.start()
|
||||
generic_close = close_angle != -1 and close_angle + open_angle >= match.end()
|
||||
return is_equals and generic_open and generic_close
|
||||
|
||||
# - not included because of scientific notation (1e-6)
|
||||
match = re.search(r"[A-Za-z0-9][\+/\*%=]", line)
|
||||
if match and not is_associated_type(match, line, 1):
|
||||
yield (idx + 1, "missing space before %s" % match.group(0)[1])
|
||||
|
||||
# * not included because of dereferencing and casting
|
||||
# - not included because of unary negation
|
||||
match = re.search(r"[\+/\%=][A-Za-z0-9]", line)
|
||||
if match and not is_associated_type(match, line, 0):
|
||||
yield (idx + 1, "missing space after %s" % match.group(0)[0])
|
||||
|
||||
match = re.search(r"\)->", line)
|
||||
if match:
|
||||
yield (idx + 1, "missing space before ->")
|
||||
|
||||
match = re.search(r"->[A-Za-z]", line)
|
||||
if match:
|
||||
yield (idx + 1, "missing space after ->")
|
||||
|
||||
# Avoid flagging ::crate::mod and `trait Foo : Bar`
|
||||
match = line.find(" :")
|
||||
if match != -1:
|
||||
if line[0:match].find('trait ') == -1 and line[match + 2] != ':':
|
||||
yield (idx + 1, "extra space before :")
|
||||
|
||||
# Avoid flagging crate::mod
|
||||
match = re.search(r"[^:]:[A-Za-z]", line)
|
||||
if match:
|
||||
# Avoid flagging macros like $t1:expr
|
||||
if line[0:match.end()].rfind('$') == -1:
|
||||
yield (idx + 1, "missing space after :")
|
||||
|
||||
match = re.search(r"[A-Za-z0-9\)]{", line)
|
||||
if match:
|
||||
yield (idx + 1, "missing space before {")
|
||||
|
||||
if line.startswith("use ") and "{" in line and "}" not in line:
|
||||
yield (idx + 1, "use statement spans multiple lines")
|
||||
|
||||
|
||||
def check_webidl_spec(file_name, contents):
|
||||
# Sorted by this function (in pseudo-Rust). The idea is to group the same
|
||||
# organization together.
|
||||
|
@ -278,7 +365,8 @@ def scan():
|
|||
all_files = collect_file_names()
|
||||
files_to_check = filter(should_check, all_files)
|
||||
|
||||
checking_functions = [check_license, check_by_line, check_flake8, check_toml, check_webidl_spec, check_spec]
|
||||
checking_functions = [check_license, check_by_line, check_flake8, check_toml,
|
||||
check_rust, check_webidl_spec, check_spec]
|
||||
errors = collect_errors_for_files(files_to_check, checking_functions)
|
||||
|
||||
reftest_files = collect_file_names(reftest_directories)
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use euclid::{Size2D, Point2D, SideOffsets2D, Rect};
|
||||
use util::logical_geometry::{WritingMode, LogicalSize, LogicalPoint, LogicalMargin, LogicalRect,
|
||||
FLAG_RTL, FLAG_VERTICAL, FLAG_VERTICAL_LR, FLAG_SIDEWAYS_LEFT};
|
||||
use util::logical_geometry::{WritingMode, LogicalSize, LogicalPoint, LogicalMargin, LogicalRect};
|
||||
use util::logical_geometry::{FLAG_RTL, FLAG_VERTICAL, FLAG_VERTICAL_LR, FLAG_SIDEWAYS_LEFT};
|
||||
|
||||
#[cfg(test)]
|
||||
fn modes() -> [WritingMode; 10] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue