Diff
Modified: trunk/Source/WebCore/ChangeLog (224886 => 224887)
--- trunk/Source/WebCore/ChangeLog 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/ChangeLog 2017-11-15 19:06:53 UTC (rev 224887)
@@ -1,3 +1,31 @@
+2017-11-15 Jer Noble <jer.no...@apple.com>
+
+ Add a compile-time-checked string literal initializer for FourCC.
+ https://bugs.webkit.org/show_bug.cgi?id=179706
+
+ Reviewed by Alex Christensen.
+
+ Add a contexpr constructor for FourCC that takes a string literal and static_asserts that it
+ is exactly 4 chars long. Use this string literal constructor everywhere instead of multi-
+ character literals.
+
+ * platform/graphics/FourCC.h:
+ (WebCore::FourCC::FourCC):
+ * platform/graphics/iso/ISOBox.cpp:
+ (WebCore::ISOBox::parse):
+ * platform/graphics/iso/ISOOriginalFormatBox.h:
+ (WebCore::ISOOriginalFormatBox::boxTypeName):
+ * platform/graphics/iso/ISOProtectionSchemeInfoBox.h:
+ (WebCore::ISOProtectionSchemeInfoBox::boxTypeName):
+ * platform/graphics/iso/ISOSchemeInformationBox.h:
+ (WebCore::ISOSchemeInformationBox::boxTypeName):
+ * platform/graphics/iso/ISOSchemeTypeBox.h:
+ (WebCore::ISOSchemeTypeBox::boxTypeName):
+ * platform/graphics/iso/ISOTrackEncryptionBox.h:
+ (WebCore::ISOTrackEncryptionBox::boxTypeName):
+ * platform/graphics/iso/ISOVTTCue.h:
+ (WebCore::ISOWebVTTCue::boxTypeName):
+
2017-11-15 Adrian Perez de Castro <ape...@igalia.com>
[Cairo] Clang warns about mismatched declaration type tag for GraphicsContextState
Modified: trunk/Source/WebCore/platform/graphics/FourCC.h (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/FourCC.h 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/FourCC.h 2017-11-15 19:06:53 UTC (rev 224887)
@@ -32,6 +32,13 @@
struct FourCC {
WEBCORE_EXPORT FourCC(uint32_t value) : value(value) { }
+ template<std::size_t N>
+ constexpr FourCC(const char (&data)[N])
+ {
+ static_assert((N - 1) == 4, "FourCC literals must be exactly 4 characters long");
+ value = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
+ }
+
String toString() const;
WEBCORE_EXPORT static std::optional<FourCC> fromString(const String&);
Modified: trunk/Source/WebCore/platform/graphics/iso/ISOBox.cpp (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/iso/ISOBox.cpp 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/iso/ISOBox.cpp 2017-11-15 19:06:53 UTC (rev 224887)
@@ -75,7 +75,7 @@
if (m_size == 1 && !checkedRead<uint64_t>(m_size, view, offset, BigEndian))
return false;
- if (m_boxType.value == 'uuid') {
+ if (m_boxType == "uuid") {
struct ExtendedType {
uint8_t value[16];
} extendedTypeStruct;
Modified: trunk/Source/WebCore/platform/graphics/iso/ISOOriginalFormatBox.h (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/iso/ISOOriginalFormatBox.h 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/iso/ISOOriginalFormatBox.h 2017-11-15 19:06:53 UTC (rev 224887)
@@ -31,7 +31,7 @@
class ISOOriginalFormatBox : public ISOBox {
public:
- static FourCC boxTypeName() { return 'frma'; }
+ static FourCC boxTypeName() { return "frma"; }
FourCC dataFormat() const { return m_dataFormat; }
Modified: trunk/Source/WebCore/platform/graphics/iso/ISOProtectionSchemeInfoBox.h (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/iso/ISOProtectionSchemeInfoBox.h 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/iso/ISOProtectionSchemeInfoBox.h 2017-11-15 19:06:53 UTC (rev 224887)
@@ -34,7 +34,7 @@
class ISOProtectionSchemeInfoBox : public ISOFullBox {
public:
- static FourCC boxTypeName() { return 'sinf'; }
+ static FourCC boxTypeName() { return "sinf"; }
const ISOSchemeTypeBox* schemeTypeBox() const { return m_schemeTypeBox.get(); }
const ISOSchemeInformationBox* schemeInformationBox() const { return m_schemeInformationBox.get(); }
Modified: trunk/Source/WebCore/platform/graphics/iso/ISOSchemeInformationBox.h (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/iso/ISOSchemeInformationBox.h 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/iso/ISOSchemeInformationBox.h 2017-11-15 19:06:53 UTC (rev 224887)
@@ -31,7 +31,7 @@
class ISOSchemeInformationBox : public ISOBox {
public:
- static FourCC boxTypeName() { return 'schi'; }
+ static FourCC boxTypeName() { return "schi"; }
const ISOBox* schemeSpecificData() const { return m_schemeSpecificData.get(); }
Modified: trunk/Source/WebCore/platform/graphics/iso/ISOSchemeTypeBox.h (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/iso/ISOSchemeTypeBox.h 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/iso/ISOSchemeTypeBox.h 2017-11-15 19:06:53 UTC (rev 224887)
@@ -31,7 +31,7 @@
class ISOSchemeTypeBox : public ISOFullBox {
public:
- static FourCC boxTypeName() { return 'schm'; }
+ static FourCC boxTypeName() { return "schm"; }
FourCC schemeType() const { return m_schemeType; }
uint32_t schemeVersion() const { return m_schemeVersion; }
Modified: trunk/Source/WebCore/platform/graphics/iso/ISOTrackEncryptionBox.h (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/iso/ISOTrackEncryptionBox.h 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/iso/ISOTrackEncryptionBox.h 2017-11-15 19:06:53 UTC (rev 224887)
@@ -31,7 +31,7 @@
class ISOTrackEncryptionBox : public ISOFullBox {
public:
- static FourCC boxTypeName() { return 'tenc'; }
+ static FourCC boxTypeName() { return "tenc"; }
std::optional<int8_t> defaultCryptByteBlock() const { return m_defaultCryptByteBlock; }
std::optional<int8_t> defaultSkipByteBlock() const { return m_defaultSkipByteBlock; }
Modified: trunk/Source/WebCore/platform/graphics/iso/ISOVTTCue.cpp (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/iso/ISOVTTCue.cpp 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/iso/ISOVTTCue.cpp 2017-11-15 19:06:53 UTC (rev 224887)
@@ -73,11 +73,11 @@
String m_contents;
};
-static FourCC vttIdBoxType() { return 'iden'; }
-static FourCC vttSettingsBoxType() { return 'sttg'; }
-static FourCC vttPayloadBoxType() { return 'payl'; }
-static FourCC vttCurrentTimeBoxType() { return 'ctim'; }
-static FourCC vttCueSourceIDBoxType() { return 'vsid'; }
+static FourCC vttIdBoxType() { return "iden"; }
+static FourCC vttSettingsBoxType() { return "sttg"; }
+static FourCC vttPayloadBoxType() { return "payl"; }
+static FourCC vttCurrentTimeBoxType() { return "ctim"; }
+static FourCC vttCueSourceIDBoxType() { return "vsid"; }
ISOWebVTTCue::ISOWebVTTCue(const MediaTime& presentationTime, const MediaTime& duration)
: m_presentationTime(presentationTime)
Modified: trunk/Source/WebCore/platform/graphics/iso/ISOVTTCue.h (224886 => 224887)
--- trunk/Source/WebCore/platform/graphics/iso/ISOVTTCue.h 2017-11-15 18:48:01 UTC (rev 224886)
+++ trunk/Source/WebCore/platform/graphics/iso/ISOVTTCue.h 2017-11-15 19:06:53 UTC (rev 224887)
@@ -42,7 +42,7 @@
public:
ISOWebVTTCue(const MediaTime& presentationTime, const MediaTime& duration);
- static FourCC boxTypeName() { return 'vtcc'; }
+ static FourCC boxTypeName() { return "vtcc"; }
const MediaTime& presentationTime() const { return m_presentationTime; }
const MediaTime& duration() const { return m_duration; }