Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: third_party/WebKit/Source/build/scripts/make_computed_style_base.py

Issue 2686473004: Make ComputedStyle generation deterministic. (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/build/scripts/make_computed_style_base.py
diff --git a/third_party/WebKit/Source/build/scripts/make_computed_style_base.py b/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
index 174941950ab6248421308683cec646ce9470580b..82d8df12fa2a464aab1e6622b2ccf988efe95f5f 100755
--- a/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
+++ b/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
@@ -13,6 +13,7 @@ import make_style_builder
from name_utilities import (
enum_for_css_keyword, enum_type_name, enum_value_name, class_member_name, method_name
)
+from collections import OrderedDict
# Temporary hard-coded list of fields that are not CSS properties.
@@ -138,7 +139,7 @@ def _get_include_paths(properties):
def _create_enums(properties):
"""
- Returns a dictionary of enums to be generated, enum name -> [list of enum values]
+ Returns an OrderedDict of enums to be generated, enum name -> [list of enum values]
"""
enums = {}
for property_ in properties:
@@ -156,7 +157,8 @@ def _create_enums(properties):
enums[enum_name] = enum_values
- return enums
+ # Return the enums sorted by key (enum name)
+ return OrderedDict(sorted(enums.items(), key=lambda t: t[0]))
def _create_field(field_role, property_):
@@ -248,8 +250,8 @@ def _pack_fields(fields):
# http://www.catb.org/esr/structure-packing/#_bitfields
field_buckets = []
# Consider fields in descending order of size to reduce fragmentation
- # when they are selected.
- for field in sorted(fields, key=lambda f: f.size, reverse=True):
+ # when they are selected. Ties broken in alphabetical order by name.
+ for field in sorted(fields, key=lambda f: (-f.size, f.name)):
added_to_bucket = False
# Go through each bucket and add this field if it will not increase
# the bucket's size to larger than 32 bits. Otherwise, make a new
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698