Skip to content

Commit

Permalink
CSS Motion Path: Use counter for offset-rotate
Browse files Browse the repository at this point in the history
offset-rotate now has a distinct use counter from offset-rotation.

update_use_counter_css.py has been updated to take into account the
effects of git cl format on UseCounter.cpp, where the case
and return statements are now on separate lines.

BUG=672264

Review-Url: https://codereview.chromium.org/2554263002
Cr-Commit-Position: refs/heads/master@{#437228}
  • Loading branch information
ericwilligers authored and Commit bot committed Dec 8, 2016
1 parent 110efb2 commit 0e27a99
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<head>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>

<div id="target" class="p"></div>
<script>
test(function() {
assert_false(internals.isCSSPropertyUseCounted(document, "motion-rotation"));

var styleElement = document.createElement('style');
styleElement.textContent = ".p { motion-rotation: 0deg; }";
document.head.appendChild(styleElement);
getComputedStyle(target);

assert_true(internals.isCSSPropertyUseCounted(document, "motion-rotation"));
assert_false(internals.isCSSPropertyUseCounted(document, "offset-rotation"));
assert_false(internals.isCSSPropertyUseCounted(document, "offset-rotate"));
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<head>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>

<div id="target" class="p"></div>
<script>
test(function() {
assert_false(internals.isCSSPropertyUseCounted(document, "offset-rotate"));

var styleElement = document.createElement('style');
styleElement.textContent = ".p { offset-rotate: 0deg; }";
document.head.appendChild(styleElement);
getComputedStyle(target);

assert_true(internals.isCSSPropertyUseCounted(document, "offset-rotate"));
assert_false(internals.isCSSPropertyUseCounted(document, "motion-rotation"));
assert_false(internals.isCSSPropertyUseCounted(document, "offset-rotation"));
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<head>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>

<div id="target" class="p"></div>
<script>
test(function() {
assert_false(internals.isCSSPropertyUseCounted(document, "offset-rotation"));

var styleElement = document.createElement('style');
styleElement.textContent = ".p { offset-rotation: 0deg; }";
document.head.appendChild(styleElement);
getComputedStyle(target);

assert_true(internals.isCSSPropertyUseCounted(document, "offset-rotation"));
assert_false(internals.isCSSPropertyUseCounted(document, "motion-rotation"));
assert_false(internals.isCSSPropertyUseCounted(document, "offset-rotate"));
});
</script>
6 changes: 3 additions & 3 deletions third_party/WebKit/Source/core/frame/UseCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int totalPagesMeasuredCSSSampleId() {
}

// Make sure update_use_counter_css.py was run which updates histograms.xml.
constexpr int kMaximumCSSSampleId = 547;
constexpr int kMaximumCSSSampleId = 548;

} // namespace

Expand Down Expand Up @@ -1050,9 +1050,7 @@ int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(
return 540;
case CSSPropertyOffsetPath:
return 541;
case CSSPropertyOffsetRotate:
case CSSPropertyOffsetRotation:
// TODO(ericwilligers): Distinct use counter for CSSPropertyOffsetRotate.
return 542;
case CSSPropertyOffset:
return 543;
Expand All @@ -1064,6 +1062,8 @@ int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(
return 546;
case CSSPropertyCaretColor:
return 547;
case CSSPropertyOffsetRotate:
return 548;
// 1. Add new features above this line (don't change the assigned numbers of
// the existing items).
// 2. Update kMaximumCSSSampleId with the new maximum value.
Expand Down
2 changes: 2 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94133,6 +94133,8 @@ value.
<int value="544" label="offset-anchor"/>
<int value="545" label="offset-position"/>
<int value="546" label="text-decoration-skip"/>
<int value="547" label="caret-color"/>
<int value="548" label="offset-rotate"/>
</enum>

<enum name="MappedEditingCommands" type="int">
Expand Down
8 changes: 6 additions & 2 deletions tools/metrics/histograms/update_use_counter_css.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,23 @@ def ReadCssProperties(filename):
with open(path_util.GetInputFile(filename)) as f:
content = f.readlines()

# Looking for a line like "case CSSPropertyGrid: return 453;".
# Looking for a pair of lines like "case CSSPropertyGrid:\n return 453;".
ENUM_REGEX = re.compile(r"""CSSProperty(.*): # capture the enum name
\s*return\s*
([0-9]+) # capture the id
""", re.VERBOSE)

properties = {}
previous_line = ''
for line in content:
enum_match = ENUM_REGEX.search(line)
enum_match = ENUM_REGEX.search(previous_line + '\n' + line)
if enum_match:
enum_name = enum_match.group(1)
property_id = int(enum_match.group(2))
properties[property_id] = EnumToCssProperty(enum_name)
previous_line = ''
else:
previous_line = line

return properties

Expand Down

0 comments on commit 0e27a99

Please sign in to comment.