Commit 30287be5 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Add a bit for ::target-text.

When ::target-text was introduced, we did not add an extra bit in
pseudo_bits. Add static_asserts to make sure we actually test first and
last public pseudo. Had to add another 8 bits to ComputedStyle.

Bug: 1136817
Change-Id: If8593b5a7022b93f18f4ee7b216e6753b6747076
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502629Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821266}
parent ed625050
......@@ -103,7 +103,7 @@ struct SameSizeAsComputedStyleBase {
private:
void* data_refs[8];
unsigned bitfields[5];
unsigned bitfields[6];
};
struct SameSizeAsComputedStyle : public SameSizeAsComputedStyleBase,
......
......@@ -2985,8 +2985,8 @@ inline void ComputedStyle::SetHasPseudoElementStyle(PseudoId pseudo) {
DCHECK(pseudo >= kFirstPublicPseudoId);
DCHECK(pseudo < kFirstInternalPseudoId);
// TODO: Fix up this code. It is hard to understand.
SetPseudoBitsInternal(static_cast<PseudoId>(
PseudoBitsInternal() | 1 << (pseudo - kFirstPublicPseudoId)));
SetPseudoBitsInternal(PseudoBitsInternal() |
1 << (pseudo - kFirstPublicPseudoId));
}
} // namespace blink
......
......@@ -221,7 +221,7 @@
{
name: "PseudoBits",
field_template: "primitive",
field_size: 8,
field_size: 9,
default_value: "kPseudoIdNone",
type_name: "unsigned",
custom_copy: true,
......
......@@ -145,6 +145,9 @@ TEST(ComputedStyleTest, LayoutContainmentStackingContext) {
}
TEST(ComputedStyleTest, FirstPublicPseudoStyle) {
static_assert(kFirstPublicPseudoId == kPseudoIdFirstLine,
"Make sure we are testing the first public pseudo id");
scoped_refptr<ComputedStyle> style = ComputedStyle::Create();
style->SetHasPseudoElementStyle(kPseudoIdFirstLine);
EXPECT_TRUE(style->HasPseudoElementStyle(kPseudoIdFirstLine));
......@@ -152,9 +155,12 @@ TEST(ComputedStyleTest, FirstPublicPseudoStyle) {
}
TEST(ComputedStyleTest, LastPublicPseudoElementStyle) {
static_assert(kFirstInternalPseudoId - 1 == kPseudoIdTargetText,
"Make sure we are testing the last public pseudo id");
scoped_refptr<ComputedStyle> style = ComputedStyle::Create();
style->SetHasPseudoElementStyle(kPseudoIdScrollbar);
EXPECT_TRUE(style->HasPseudoElementStyle(kPseudoIdScrollbar));
style->SetHasPseudoElementStyle(kPseudoIdTargetText);
EXPECT_TRUE(style->HasPseudoElementStyle(kPseudoIdTargetText));
EXPECT_TRUE(style->HasAnyPseudoElementStyles());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment