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

Unified Diff: third_party/WebKit/Source/platform/fonts/FontVariantNumeric.h

Issue 1955723004: Implement font-variant-numeric (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove whitespace and clarified TODOs Created 4 years, 7 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/platform/fonts/FontVariantNumeric.h
diff --git a/third_party/WebKit/Source/platform/fonts/FontVariantNumeric.h b/third_party/WebKit/Source/platform/fonts/FontVariantNumeric.h
new file mode 100644
index 0000000000000000000000000000000000000000..90d4572285eb136af796028f03ba575a6541a5dc
--- /dev/null
+++ b/third_party/WebKit/Source/platform/fonts/FontVariantNumeric.h
@@ -0,0 +1,95 @@
+// 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 FontVariantNumeric_h
+#define FontVariantNumeric_h
+
+#include "wtf/Allocator.h"
+
+namespace blink {
+
+class FontVariantNumeric {
+ STACK_ALLOCATED();
+
+public:
+
+ enum NumericFigure {
+ NormalFigure = 0,
+ LiningNums = 1,
+ OldstyleNums = 2
+ };
+
+ enum NumericSpacing {
+ NormalSpacing = 0,
+ ProportionalNums = 1,
+ TabularNums = 2
+ };
+
+ enum NumericFraction {
+ NormalFraction = 0,
+ DiagonalFractions = 1,
+ StackedFractions = 2
+ };
+
+ enum Ordinal {
+ OrdinalOff = 0,
+ OrdinalOn = 1
+ };
+
+ enum SlashedZero {
+ SlashedZeroOff = 0,
+ SlashedZeroOn = 1
+ };
+
+ FontVariantNumeric() : m_fieldsAsUnsigned(0) { }
+
+ static FontVariantNumeric initializeFromUnsigned(unsigned initValue)
+ {
+ return FontVariantNumeric(initValue);
+ }
+
+ void setNumericFigure(NumericFigure figure) { m_fields.m_numericFigure = figure; };
+ void setNumericSpacing(NumericSpacing spacing) { m_fields.m_numericSpacing = spacing; };
+ void setNumericFraction(NumericFraction fraction) { m_fields.m_numericFraction = fraction; };
+ void setOrdinal(Ordinal ordinal) { m_fields.m_ordinal = ordinal; };
+ void setSlashedZero(SlashedZero slashedZero) { m_fields.m_slashedZero = slashedZero; };
+
+ NumericFigure numericFigure() const { return static_cast<NumericFigure>(m_fields.m_numericFigure); }
eae 2016/05/09 16:31:58 Methods and enums should use names that differ by
drott 2016/05/10 10:59:06 Suffixed with Value() for all accessors.
+ NumericSpacing numericSpacing() const { return static_cast<NumericSpacing>(m_fields.m_numericSpacing); }
+ NumericFraction numericFraction() const { return static_cast<NumericFraction>(m_fields.m_numericFraction); }
+ Ordinal ordinal() const { return static_cast<Ordinal>(m_fields.m_ordinal); };
+ SlashedZero slashedZero() const { return static_cast<SlashedZero>(m_fields.m_slashedZero); }
+
+ bool isAllNormal() { return !m_fieldsAsUnsigned; }
+
+ bool operator==(const FontVariantNumeric& other) const
+ {
+ return m_fieldsAsUnsigned == other.m_fieldsAsUnsigned;
+ }
+
+private:
+ FontVariantNumeric(unsigned initValue) : m_fieldsAsUnsigned(initValue) { }
+
+ struct BitFields {
+ unsigned m_numericFigure : 2;
+ unsigned m_numericSpacing : 2;
+ unsigned m_numericFraction : 2;
+ unsigned m_ordinal : 1;
+ unsigned m_slashedZero : 1;
+ };
+
+
+ union {
+ BitFields m_fields;
+ unsigned m_fieldsAsUnsigned;
+ };
+ static_assert(sizeof(m_fields) == sizeof(m_fieldsAsUnsigned), "Mapped union types must match in size.");
+
+ // Used in setVariant to store the value in m_fields.m_variantNumeric;
+ friend class FontDescription;
+};
+
+}
+
+#endif // FontVariantNumeric_h

Powered by Google App Engine
This is Rietveld 408576698