mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Test for tabs in tidy.py.
This commit is contained in:
parent
4ff4b5833d
commit
a283f7801b
4 changed files with 84 additions and 81 deletions
|
@ -47,7 +47,7 @@ impl ScriptListener for CompositorChan {
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
layer_id: LayerId,
|
layer_id: LayerId,
|
||||||
point: Point2D<f32>) {
|
point: Point2D<f32>) {
|
||||||
self.chan.send(ScrollFragmentPoint(pipeline_id, layer_id, point));
|
self.chan.send(ScrollFragmentPoint(pipeline_id, layer_id, point));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&self) {
|
fn close(&self) {
|
||||||
|
|
|
@ -234,10 +234,10 @@ impl ResourceManager {
|
||||||
for scheme_loader in self.loaders.iter() {
|
for scheme_loader in self.loaders.iter() {
|
||||||
match *scheme_loader {
|
match *scheme_loader {
|
||||||
(ref scheme, ref loader_factory) => {
|
(ref scheme, ref loader_factory) => {
|
||||||
if (*scheme) == load_data.url.scheme {
|
if (*scheme) == load_data.url.scheme {
|
||||||
return Some((*loader_factory)());
|
return Some((*loader_factory)());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -22,120 +22,120 @@ import gdb
|
||||||
|
|
||||||
# Print Au in both raw value and CSS pixels
|
# Print Au in both raw value and CSS pixels
|
||||||
class AuPrinter:
|
class AuPrinter:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
i32_type = gdb.lookup_type("i32")
|
i32_type = gdb.lookup_type("i32")
|
||||||
au = self.val.cast(i32_type);
|
au = self.val.cast(i32_type);
|
||||||
return "{0}px ({1} au)".format(au / 60.0, au)
|
return "{0}px ({1} au)".format(au / 60.0, au)
|
||||||
|
|
||||||
# Print a U8 bitfield as binary
|
# Print a U8 bitfield as binary
|
||||||
class BitFieldU8Printer:
|
class BitFieldU8Printer:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
u8_type = gdb.lookup_type("u8")
|
u8_type = gdb.lookup_type("u8")
|
||||||
value = self.val.cast(u8_type);
|
value = self.val.cast(u8_type);
|
||||||
return "[{0:#010b}]".format(int(value))
|
return "[{0:#010b}]".format(int(value))
|
||||||
|
|
||||||
# Print a struct with fields as children
|
# Print a struct with fields as children
|
||||||
class ChildPrinter:
|
class ChildPrinter:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
children = []
|
children = []
|
||||||
for f in self.val.type.fields():
|
for f in self.val.type.fields():
|
||||||
children.append( (f.name, self.val[f.name]) )
|
children.append( (f.name, self.val[f.name]) )
|
||||||
return children
|
return children
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Allow a trusted node to be dereferenced in the debugger
|
# Allow a trusted node to be dereferenced in the debugger
|
||||||
class TrustedNodeAddressPrinter:
|
class TrustedNodeAddressPrinter:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
node_type = gdb.lookup_type("struct script::dom::node::Node").pointer()
|
node_type = gdb.lookup_type("struct script::dom::node::Node").pointer()
|
||||||
value = self.val.cast(node_type)
|
value = self.val.cast(node_type)
|
||||||
return [('Node', value)]
|
return [('Node', value)]
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
return self.val.address
|
return self.val.address
|
||||||
|
|
||||||
# Extract a node type ID from enum
|
# Extract a node type ID from enum
|
||||||
class NodeTypeIdPrinter:
|
class NodeTypeIdPrinter:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
u8_ptr_type = gdb.lookup_type("u8").pointer()
|
u8_ptr_type = gdb.lookup_type("u8").pointer()
|
||||||
enum_0 = self.val.address.cast(u8_ptr_type).dereference()
|
enum_0 = self.val.address.cast(u8_ptr_type).dereference()
|
||||||
enum_type = self.val.type.fields()[int(enum_0)].type;
|
enum_type = self.val.type.fields()[int(enum_0)].type;
|
||||||
return str(enum_type).lstrip('struct ')
|
return str(enum_type).lstrip('struct ')
|
||||||
|
|
||||||
# Printer for std::Option<>
|
# Printer for std::Option<>
|
||||||
class OptionPrinter:
|
class OptionPrinter:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
||||||
def is_some(self):
|
def is_some(self):
|
||||||
# Get size of discriminator
|
# Get size of discriminator
|
||||||
d_size = self.val.type.fields()[0].type.sizeof
|
d_size = self.val.type.fields()[0].type.sizeof
|
||||||
|
|
||||||
if d_size > 0 and d_size <= 8:
|
if d_size > 0 and d_size <= 8:
|
||||||
# Read first byte to check if None or Some
|
# Read first byte to check if None or Some
|
||||||
ptr = self.val.address.cast(gdb.lookup_type("unsigned char").pointer())
|
ptr = self.val.address.cast(gdb.lookup_type("unsigned char").pointer())
|
||||||
discriminator = int(ptr.dereference())
|
discriminator = int(ptr.dereference())
|
||||||
return discriminator != 0
|
return discriminator != 0
|
||||||
|
|
||||||
raise "unhandled discriminator size"
|
raise "unhandled discriminator size"
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
if self.is_some():
|
if self.is_some():
|
||||||
option_type = self.val.type
|
option_type = self.val.type
|
||||||
|
|
||||||
# Get total size and size of value
|
# Get total size and size of value
|
||||||
ptr = self.val.address.cast(gdb.lookup_type("unsigned char").pointer())
|
ptr = self.val.address.cast(gdb.lookup_type("unsigned char").pointer())
|
||||||
t_size = option_type.sizeof
|
t_size = option_type.sizeof
|
||||||
value_type = option_type.fields()[1].type.fields()[1].type
|
value_type = option_type.fields()[1].type.fields()[1].type
|
||||||
v_size = value_type.sizeof
|
v_size = value_type.sizeof
|
||||||
data_ptr = (ptr + t_size - v_size).cast(value_type.pointer()).dereference()
|
data_ptr = (ptr + t_size - v_size).cast(value_type.pointer()).dereference()
|
||||||
return [('Some', data_ptr)]
|
return [('Some', data_ptr)]
|
||||||
return [('None', None)]
|
return [('None', None)]
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Useful for debugging when type is unknown
|
# Useful for debugging when type is unknown
|
||||||
class TestPrinter:
|
class TestPrinter:
|
||||||
def __init__(self, val):
|
def __init__(self, val):
|
||||||
self.val = val
|
self.val = val
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
return "[UNKNOWN - type = {0}]".format(str(self.val.type))
|
return "[UNKNOWN - type = {0}]".format(str(self.val.type))
|
||||||
|
|
||||||
type_map = [
|
type_map = [
|
||||||
('Au', AuPrinter),
|
('Au', AuPrinter),
|
||||||
('FlowFlags', BitFieldU8Printer),
|
('FlowFlags', BitFieldU8Printer),
|
||||||
('IntrinsicWidths', ChildPrinter),
|
('IntrinsicWidths', ChildPrinter),
|
||||||
('PlacementInfo', ChildPrinter),
|
('PlacementInfo', ChildPrinter),
|
||||||
('TrustedNodeAddress', TrustedNodeAddressPrinter),
|
('TrustedNodeAddress', TrustedNodeAddressPrinter),
|
||||||
('NodeTypeId', NodeTypeIdPrinter),
|
('NodeTypeId', NodeTypeIdPrinter),
|
||||||
('Option', OptionPrinter),
|
('Option', OptionPrinter),
|
||||||
]
|
]
|
||||||
|
|
||||||
def lookup_servo_type (val):
|
def lookup_servo_type (val):
|
||||||
val_type = str(val.type)
|
val_type = str(val.type)
|
||||||
for (type_name, printer) in type_map:
|
for (type_name, printer) in type_map:
|
||||||
if val_type == type_name or val_type.endswith("::"+type_name):
|
if val_type == type_name or val_type.endswith("::"+type_name):
|
||||||
return printer(val)
|
return printer(val)
|
||||||
return None
|
return None
|
||||||
#return TestPrinter(val)
|
#return TestPrinter(val)
|
||||||
|
|
||||||
def register_printers(obj):
|
def register_printers(obj):
|
||||||
gdb.pretty_printers.append(lookup_servo_type)
|
gdb.pretty_printers.append(lookup_servo_type)
|
||||||
|
|
|
@ -37,6 +37,9 @@ def do_whitespace_check(name, contents):
|
||||||
if line.endswith(' '):
|
if line.endswith(' '):
|
||||||
report_error_name_no(name, idx + 1, "trailing whitespace")
|
report_error_name_no(name, idx + 1, "trailing whitespace")
|
||||||
|
|
||||||
|
if '\t' in line:
|
||||||
|
report_error_name_no(name, idx + 1, "tab on line")
|
||||||
|
|
||||||
|
|
||||||
exceptions = [
|
exceptions = [
|
||||||
# Upstream
|
# Upstream
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue