Generate StyleVisualData in ComputedStyleBase.
This patch generates the following fields as part of a group:
- clip ('storage_only' of type LengthBox)
- HasAutoClip ('storage_only' of type bool)
- text-decoration ('storage_only' of enum type TextDecoration)
- zoom ('storage_only' of type float)
Since HasAutoClip doesn't correspond to a CSS property, we specify
it in ComputedStyleExtraFields.json5.
Furthermore, text-decoration is a keyword CSS property, but it
can take on any subset of values from a set of keywords. We can't
generate this kind of fields yet. Instead of complicating this
patch with the generation of text-decoration, we will specify it as
a storage_only field in ComputedStyleExtraFields.json5 with a
field size of 4 bits (we can't specify it in CSSProperties.json5
since that file doesn't support field sizes).
A future patch will generate text-decoration properly.
Diff of generated files:
https://gist.github.com/b3420eb4c3d0514cd4f1f936181fedb6/revisions
BUG=628043
Review-Url: https://codereview.chromium.org/2841453002
Cr-Commit-Position: refs/heads/master@{#469939}
diff --git a/third_party/WebKit/Source/core/css/CSSProperties.json5 b/third_party/WebKit/Source/core/css/CSSProperties.json5
index 6d3486c..e16dbde3 100644
--- a/third_party/WebKit/Source/core/css/CSSProperties.json5
+++ b/third_party/WebKit/Source/core/css/CSSProperties.json5
@@ -545,6 +545,10 @@
custom_all: true,
is_descriptor: true,
priority: "High",
+ field_template: "storage_only",
+ type_name: "float",
+ default_value: "1.0",
+ field_group: "visual",
},
{
@@ -892,6 +896,10 @@
converter: "ConvertClip",
custom_all: true,
interpolable: true,
+ field_template: "storage_only",
+ field_type_path: "platform/LengthBox",
+ default_value: "LengthBox()",
+ field_group: "visual",
},
{
name: "clip-path",
diff --git a/third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5 b/third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5
index 68e408a..5e7fae3 100644
--- a/third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5
+++ b/third_party/WebKit/Source/core/css/ComputedStyleExtraFields.json5
@@ -183,5 +183,21 @@
default_value: "Color::kTransparent",
field_group: "background",
},
+ {
+ name: "TextDecoration",
+ field_template: "storage_only",
+ type_name: "TextDecoration",
+ field_size: 4,
+ default_value: "kTextDecorationNone",
+ field_group: "visual",
+ },
+ {
+ name: "HasAutoClip",
+ field_template: "storage_only",
+ type_name: "bool",
+ field_size: 1,
+ default_value: "true",
+ field_group: "visual",
+ },
],
}
diff --git a/third_party/WebKit/Source/core/style/BUILD.gn b/third_party/WebKit/Source/core/style/BUILD.gn
index 2c449ce..1458f9a 100644
--- a/third_party/WebKit/Source/core/style/BUILD.gn
+++ b/third_party/WebKit/Source/core/style/BUILD.gn
@@ -103,8 +103,6 @@
"StyleSelfAlignmentData.h",
"StyleTransformData.cpp",
"StyleTransformData.h",
- "StyleVisualData.cpp",
- "StyleVisualData.h",
"StyleWillChangeData.cpp",
"StyleWillChangeData.h",
"TextSizeAdjust.h",
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.cpp b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
index f4ddbc2..522a8a5 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -115,7 +115,6 @@
ALWAYS_INLINE ComputedStyle::ComputedStyle()
: ComputedStyleBase(), RefCounted<ComputedStyle>() {
box_data_.Init();
- visual_data_.Init();
rare_non_inherited_data_.Init();
rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init();
rare_non_inherited_data_.Access()->flexible_box_.Init();
@@ -136,7 +135,6 @@
: ComputedStyleBase(o),
RefCounted<ComputedStyle>(),
box_data_(o.box_data_),
- visual_data_(o.visual_data_),
rare_non_inherited_data_(o.rare_non_inherited_data_),
rare_inherited_data_(o.rare_inherited_data_),
inherited_data_(o.inherited_data_),
@@ -330,7 +328,6 @@
void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) {
ComputedStyleBase::CopyNonInheritedFromCached(other);
box_data_ = other.box_data_;
- visual_data_ = other.visual_data_;
rare_non_inherited_data_ = other.rare_non_inherited_data_;
// The flags are copied one-by-one because they contain
@@ -471,7 +468,6 @@
// compare everything except the pseudoStyle pointer
return ComputedStyleBase::NonInheritedEqual(other) &&
box_data_ == other.box_data_ &&
- visual_data_ == other.visual_data_ &&
rare_non_inherited_data_ == other.rare_non_inherited_data_ &&
svg_style_->NonInheritedEqual(*other.svg_style_);
}
@@ -1057,7 +1053,8 @@
inherited_data_->visited_link_color_ !=
other.inherited_data_->visited_link_color_ ||
HasSimpleUnderlineInternal() != other.HasSimpleUnderlineInternal() ||
- visual_data_->text_decoration != other.visual_data_->text_decoration) {
+ visual_data_->text_decoration_ !=
+ other.visual_data_->text_decoration_) {
diff.SetTextDecorationOrColorChanged();
} else {
if (rare_non_inherited_data_.Get() !=
@@ -1102,11 +1099,11 @@
}
}
- bool has_clip = HasOutOfFlowPosition() && !visual_data_->has_auto_clip;
+ bool has_clip = HasOutOfFlowPosition() && !visual_data_->has_auto_clip_;
bool other_has_clip =
- other.HasOutOfFlowPosition() && !other.visual_data_->has_auto_clip;
+ other.HasOutOfFlowPosition() && !other.visual_data_->has_auto_clip_;
if (has_clip != other_has_clip ||
- (has_clip && visual_data_->clip != other.visual_data_->clip))
+ (has_clip && visual_data_->clip_ != other.visual_data_->clip_))
diff.SetCSSClipChanged();
}
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.h b/third_party/WebKit/Source/core/style/ComputedStyle.h
index 9034275..d0b5313f 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.h
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.h
@@ -53,7 +53,6 @@
#include "core/style/StyleReflection.h"
#include "core/style/StyleSelfAlignmentData.h"
#include "core/style/StyleTransformData.h"
-#include "core/style/StyleVisualData.h"
#include "core/style/StyleWillChangeData.h"
#include "core/style/TransformOrigin.h"
#include "platform/Length.h"
@@ -184,7 +183,6 @@
protected:
// non-inherited attributes
DataRef<StyleBoxData> box_data_;
- DataRef<StyleVisualData> visual_data_;
DataRef<StyleRareNonInheritedData> rare_non_inherited_data_;
// inherited attributes
@@ -576,15 +574,15 @@
// clip
static LengthBox InitialClip() { return LengthBox(); }
- const LengthBox& Clip() const { return visual_data_->clip; }
+ const LengthBox& Clip() const { return visual_data_->clip_; }
void SetClip(const LengthBox& box) {
- SET_VAR(visual_data_, has_auto_clip, false);
- SET_VAR(visual_data_, clip, box);
+ SET_VAR(visual_data_, has_auto_clip_, false);
+ SET_VAR(visual_data_, clip_, box);
}
- bool HasAutoClip() const { return visual_data_->has_auto_clip; }
+ bool HasAutoClip() const { return visual_data_->has_auto_clip_; }
void SetHasAutoClip() {
- SET_VAR(visual_data_, has_auto_clip, true);
- SET_VAR(visual_data_, clip, ComputedStyle::InitialClip());
+ SET_VAR(visual_data_, has_auto_clip_, true);
+ SET_VAR(visual_data_, clip_, ComputedStyle::InitialClip());
}
// Column properties.
@@ -1454,10 +1452,10 @@
// text-decoration-line
static TextDecoration InitialTextDecoration() { return kTextDecorationNone; }
TextDecoration GetTextDecoration() const {
- return static_cast<TextDecoration>(visual_data_->text_decoration);
+ return static_cast<TextDecoration>(visual_data_->text_decoration_);
}
void SetTextDecoration(TextDecoration v) {
- SET_VAR(visual_data_, text_decoration, v);
+ SET_VAR(visual_data_, text_decoration_, v);
}
// text-decoration-color
@@ -2971,10 +2969,10 @@
}
// Clip utility functions.
- const Length& ClipLeft() const { return visual_data_->clip.Left(); }
- const Length& ClipRight() const { return visual_data_->clip.Right(); }
- const Length& ClipTop() const { return visual_data_->clip.Top(); }
- const Length& ClipBottom() const { return visual_data_->clip.Bottom(); }
+ const Length& ClipLeft() const { return visual_data_->clip_.Left(); }
+ const Length& ClipRight() const { return visual_data_->clip_.Right(); }
+ const Length& ClipTop() const { return visual_data_->clip_.Top(); }
+ const Length& ClipBottom() const { return visual_data_->clip_.Bottom(); }
// Offset utility functions.
// Accessors for positioned object edges that take into account writing mode.
diff --git a/third_party/WebKit/Source/core/style/StyleVisualData.cpp b/third_party/WebKit/Source/core/style/StyleVisualData.cpp
deleted file mode 100644
index 89541881..0000000
--- a/third_party/WebKit/Source/core/style/StyleVisualData.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "core/style/StyleVisualData.h"
-
-#include "core/style/ComputedStyle.h"
-
-namespace blink {
-
-StyleVisualData::StyleVisualData()
- : has_auto_clip(true),
- text_decoration(ComputedStyle::InitialTextDecoration()),
- zoom_(ComputedStyle::InitialZoom()) {}
-
-StyleVisualData::~StyleVisualData() {}
-
-StyleVisualData::StyleVisualData(const StyleVisualData& o)
- : RefCounted<StyleVisualData>(),
- clip(o.clip),
- has_auto_clip(o.has_auto_clip),
- text_decoration(o.text_decoration),
- zoom_(o.zoom_) {}
-
-} // namespace blink
diff --git a/third_party/WebKit/Source/core/style/StyleVisualData.h b/third_party/WebKit/Source/core/style/StyleVisualData.h
deleted file mode 100644
index 39b6ea6..0000000
--- a/third_party/WebKit/Source/core/style/StyleVisualData.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
- * (C) 2000 Antti Koivisto (koivisto@kde.org)
- * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef StyleVisualData_h
-#define StyleVisualData_h
-
-#include "core/CoreExport.h"
-#include "core/style/ComputedStyleConstants.h"
-#include "platform/LengthBox.h"
-#include "platform/wtf/PassRefPtr.h"
-#include "platform/wtf/RefCounted.h"
-
-namespace blink {
-
-// TODO(sashab): Move this into a private class on ComputedStyle, and remove
-// all methods on it, merging them into copy/creation methods on ComputedStyle
-// instead. Keep the allocation logic, only allocating a new object if needed.
-class CORE_EXPORT StyleVisualData : public RefCounted<StyleVisualData> {
- public:
- static PassRefPtr<StyleVisualData> Create() {
- return AdoptRef(new StyleVisualData);
- }
- PassRefPtr<StyleVisualData> Copy() const {
- return AdoptRef(new StyleVisualData(*this));
- }
- ~StyleVisualData();
-
- bool operator==(const StyleVisualData& o) const {
- return clip == o.clip && has_auto_clip == o.has_auto_clip &&
- text_decoration == o.text_decoration && zoom_ == o.zoom_;
- }
- bool operator!=(const StyleVisualData& o) const { return !(*this == o); }
-
- LengthBox clip;
- bool has_auto_clip : 1;
- unsigned text_decoration : kTextDecorationBits; // Text decorations defined
- // *only* by this element.
-
- float zoom_;
-
- private:
- StyleVisualData();
- StyleVisualData(const StyleVisualData&);
-};
-
-} // namespace blink
-
-#endif // StyleVisualData_h