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

Unified Diff: third_party/WebKit/Source/core/style/TextSizeAdjust.h

Issue 2100013002: Implement the new text-size-adjust CSS property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update virtual expectation, minor cleanup. Created 4 years, 6 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
Index: third_party/WebKit/Source/core/style/TextSizeAdjust.h
diff --git a/third_party/WebKit/Source/core/style/TextSizeAdjust.h b/third_party/WebKit/Source/core/style/TextSizeAdjust.h
new file mode 100644
index 0000000000000000000000000000000000000000..3f1fe03fea45042fc1994ea326cbb6625c5b8db5
--- /dev/null
+++ b/third_party/WebKit/Source/core/style/TextSizeAdjust.h
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TextSizeAdjust_h
+#define TextSizeAdjust_h
+
+#include "wtf/Allocator.h"
+
+namespace blink {
+
+// Value for text-size-adjust, see: https://drafts.csswg.org/css-size-adjust
+class TextSizeAdjust {
+ DISALLOW_NEW();
+public:
+ TextSizeAdjust(float adjustment) : m_adjustment(adjustment) {}
+
+ // Negative values are invalid so we use them internally to signify 'auto'.
+ static TextSizeAdjust adjustAuto() { return TextSizeAdjust(-1); }
+ // An adjustment of 'none' is equivalent to 100%.
+ static TextSizeAdjust adjustNone() { return TextSizeAdjust(1); }
+
+ bool isAuto() const { return m_adjustment < 0.f; }
+
+ float multiplier() const
+ {
+ // If the adjustment is 'auto', no multiplier is available.
+ DCHECK(!isAuto());
+ return m_adjustment;
+ }
+
+ bool operator==(const TextSizeAdjust& o) const
+ {
+ return m_adjustment == o.m_adjustment;
+ }
+
+ bool operator!=(const TextSizeAdjust& o) const
+ {
+ return !(*this == o);
+ }
+
+private:
+ // Percent adjustment, without units (i.e., 10% is .1 and not 10). Negative
+ // values indicate 'auto' adjustment.
+ float m_adjustment;
+};
+
+} // namespace blink
+
+#endif // TextSizeAdjust_h

Powered by Google App Engine
This is Rietveld 408576698