Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (209938 => 209939)
--- trunk/Source/WebCore/CMakeLists.txt 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-12-16 22:29:19 UTC (rev 209939)
@@ -1071,7 +1071,6 @@
bindings/generic/ActiveDOMCallback.cpp
bindings/generic/RuntimeEnabledFeatures.cpp
- bindings/js/ArrayValue.cpp
bindings/js/CachedModuleScript.cpp
bindings/js/CachedModuleScriptLoader.cpp
bindings/js/CallbackFunction.cpp
Modified: trunk/Source/WebCore/ChangeLog (209938 => 209939)
--- trunk/Source/WebCore/ChangeLog 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/ChangeLog 2016-12-16 22:29:19 UTC (rev 209939)
@@ -1,3 +1,28 @@
+2016-12-16 Sam Weinig <s...@webkit.org>
+
+ [Bindings] Remove use of Dictionary/ArrayValue in CDMSessionClearKey
+ https://bugs.webkit.org/show_bug.cgi?id=165961
+
+ Reviewed by Darin Adler.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSBindingsAllInOne.cpp:
+ Remove ArrayValue.h/cpp
+
+ * bindings/js/ArrayValue.cpp: Removed.
+ * bindings/js/ArrayValue.h: Removed.
+
+ * bindings/js/Dictionary.cpp:
+ * bindings/js/Dictionary.h:
+ Remove support for ArrayValue.
+
+ * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
+ (WebCore::CDMSessionClearKey::update):
+ Replace use of Dictionary/ArrayValue with direct JSObject functions. This
+ should really be replaced with a JSON parser that does not require round
+ tripping through _javascript_ objects.
+
2016-12-13 Jer Noble <jer.no...@apple.com>
Move existing CDM* implementations into modules/encryptedmedia/legacy
Modified: trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp (209938 => 209939)
--- trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp 2016-12-16 22:29:19 UTC (rev 209939)
@@ -26,8 +26,6 @@
#include "config.h"
#include "LegacyCDMSessionClearKey.h"
-#include "ArrayValue.h"
-#include "Dictionary.h"
#include "JSMainThreadExecState.h"
#include "Logging.h"
#include "TextEncoding.h"
@@ -99,66 +97,86 @@
ASSERT(rawKeysData);
do {
- String rawKeysString = String::fromUTF8(rawKeysData->data(), rawKeysData->length());
+ auto rawKeysString = String::fromUTF8(rawKeysData->data(), rawKeysData->length());
if (rawKeysString.isEmpty()) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: empty message", this);
continue;
}
- VM& vm = clearKeyVM();
+ auto& vm = clearKeyVM();
JSLockHolder lock(vm);
auto scope = DECLARE_THROW_SCOPE(vm);
- JSGlobalObject* globalObject = JSGlobalObject::create(vm, JSGlobalObject::createStructure(vm, jsNull()));
- ExecState* exec = globalObject->globalExec();
+ auto* globalObject = JSGlobalObject::create(vm, JSGlobalObject::createStructure(vm, jsNull()));
+ auto& state = *globalObject->globalExec();
- JSLockHolder locker(clearKeyVM());
- JSValue keysDataObject = JSONParse(exec, rawKeysString);
- if (scope.exception() || !keysDataObject) {
+ auto keysDataValue = JSONParse(&state, rawKeysString);
+ if (scope.exception() || !keysDataValue.isObject()) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: invalid JSON", this);
break;
}
- Dictionary keysDataDictionary(exec, keysDataObject);
- ArrayValue keysArray;
- size_t length;
- if (!keysDataDictionary.get("keys", keysArray) || keysArray.isUndefinedOrNull() || !keysArray.length(length) || !length) {
+
+ auto keysArrayValue = asObject(keysDataValue)->get(&state, Identifier::fromString(&state, "keys"));
+ if (scope.exception() || !isJSArray(keysArrayValue)) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: keys array missing or empty", this);
break;
}
+ auto keysArray = asArray(keysArrayValue);
+ auto length = keysArray->length();
+ if (!length) {
+ LOG(Media, "CDMSessionClearKey::update(%p) - failed: keys array missing or empty", this);
+ break;
+ }
+
bool foundValidKey = false;
- for (size_t i = 0; i < length; ++i) {
- Dictionary keyDictionary;
- if (!keysArray.get(i, keyDictionary) || keyDictionary.isUndefinedOrNull()) {
+ for (unsigned i = 0; i < length; ++i) {
+ auto keyValue = keysArray->getIndex(&state, i);
+
+ if (scope.exception() || !keyValue.isObject()) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: null keyDictionary", this);
continue;
}
- String algorithm;
- if (!keyDictionary.get("alg", algorithm) || !equalLettersIgnoringASCIICase(algorithm, "a128kw")) {
+ auto keyObject = asObject(keyValue);
+
+ auto getStringProperty = [&scope, &state, &keyObject](const char* name) -> String {
+ auto value = keyObject->get(&state, Identifier::fromString(&state, name));
+ if (scope.exception() || !value.isString())
+ return { };
+
+ auto string = asString(value)->value(&state);
+ if (scope.exception())
+ return { };
+
+ return string;
+ };
+
+ auto algorithm = getStringProperty("alg");
+ if (!equalLettersIgnoringASCIICase(algorithm, "a128kw")) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: algorithm unsupported", this);
continue;
}
- String keyType;
- if (!keyDictionary.get("kty", keyType) || !equalLettersIgnoringASCIICase(keyType, "oct")) {
+ auto keyType = getStringProperty("kty");
+ if (!equalLettersIgnoringASCIICase(keyType, "oct")) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: keyType unsupported", this);
continue;
}
- String keyId;
- if (!keyDictionary.get("kid", keyId) || keyId.isEmpty()) {
+ auto keyId = getStringProperty("kid");
+ if (keyId.isEmpty()) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: keyId missing or empty", this);
continue;
}
- String rawKeyData;
- if (!keyDictionary.get("k", rawKeyData) || rawKeyData.isEmpty()) {
+ auto rawKeyData = getStringProperty("k");
+ if (rawKeyData.isEmpty()) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: key missing or empty", this);
continue;
}
Vector<uint8_t> keyData;
- if (!base64Decode(rawKeyData, keyData) || keyData.isEmpty()) {
+ if (!base64Decode(rawKeyData, keyData) || keyData.isEmpty()) {
LOG(Media, "CDMSessionClearKey::update(%p) - failed: unable to base64 decode key", this);
continue;
}
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (209938 => 209939)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-12-16 22:29:19 UTC (rev 209939)
@@ -1817,8 +1817,6 @@
49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AE2D95134EE5F90072920A /* CalculationValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
49AF2D6914435D050016A784 /* DisplayRefreshMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AF2D6814435D050016A784 /* DisplayRefreshMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */; };
- 49B3760C15C6C6840059131D /* ArrayValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49B3760A15C6C6840059131D /* ArrayValue.cpp */; };
- 49B3760D15C6C6840059131D /* ArrayValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49B3760B15C6C6840059131D /* ArrayValue.h */; };
49C7B9931042D2D30009D447 /* JSWebGLBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C7B9801042D2D30009D447 /* JSWebGLBuffer.cpp */; };
49C7B9941042D2D30009D447 /* JSWebGLBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C7B9811042D2D30009D447 /* JSWebGLBuffer.h */; };
49C7B9971042D2D30009D447 /* JSWebGLFramebuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C7B9841042D2D30009D447 /* JSWebGLFramebuffer.cpp */; };
@@ -9015,8 +9013,6 @@
49AE2D95134EE5F90072920A /* CalculationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CalculationValue.h; sourceTree = "<group>"; };
49AF2D6814435D050016A784 /* DisplayRefreshMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayRefreshMonitor.h; sourceTree = "<group>"; };
49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayRefreshMonitorMac.cpp; sourceTree = "<group>"; };
- 49B3760A15C6C6840059131D /* ArrayValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayValue.cpp; sourceTree = "<group>"; };
- 49B3760B15C6C6840059131D /* ArrayValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayValue.h; sourceTree = "<group>"; };
49C7B9801042D2D30009D447 /* JSWebGLBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLBuffer.cpp; sourceTree = "<group>"; };
49C7B9811042D2D30009D447 /* JSWebGLBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLBuffer.h; sourceTree = "<group>"; };
49C7B9841042D2D30009D447 /* JSWebGLFramebuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLFramebuffer.cpp; sourceTree = "<group>"; };
@@ -21930,8 +21926,6 @@
BCCE58B41061E925008FB35A /* Constructors */,
BC4EDEF70C08F414007EDD49 /* Custom */,
14DFB33F0A7DF7630018F769 /* Derived Sources */,
- 49B3760A15C6C6840059131D /* ArrayValue.cpp */,
- 49B3760B15C6C6840059131D /* ArrayValue.h */,
2DFA488E1DB541C200362B99 /* BufferSource.h */,
E307DEC91D81E46E00141CAF /* CachedModuleScript.cpp */,
E307DECA1D81E46E00141CAF /* CachedModuleScript.h */,
@@ -24864,7 +24858,6 @@
512DD8FD0D91E6AF000F89EE /* ArchiveFactory.h in Headers */,
512DD8FC0D91E6AF000F89EE /* ArchiveResource.h in Headers */,
512DD8F80D91E6AF000F89EE /* ArchiveResourceCollection.h in Headers */,
- 49B3760D15C6C6840059131D /* ArrayValue.h in Headers */,
FD5686CA13AC180200B69C68 /* AsyncAudioDecoder.h in Headers */,
E1CDE9221501916900862CC5 /* AsyncFileStream.h in Headers */,
0FFD4D6118651FA300512F6E /* AsyncScrollingCoordinator.h in Headers */,
@@ -28752,7 +28745,6 @@
512DD8FA0D91E6AF000F89EE /* ArchiveFactory.cpp in Sources */,
512DD8FB0D91E6AF000F89EE /* ArchiveResource.cpp in Sources */,
512DD8F70D91E6AF000F89EE /* ArchiveResourceCollection.cpp in Sources */,
- 49B3760C15C6C6840059131D /* ArrayValue.cpp in Sources */,
FD5686C913AC180200B69C68 /* AsyncAudioDecoder.cpp in Sources */,
E1CDE92015018ED000862CC5 /* AsyncFileStream.cpp in Sources */,
0FFD4D6018651FA300512F6E /* AsyncScrollingCoordinator.cpp in Sources */,
Deleted: trunk/Source/WebCore/bindings/js/ArrayValue.cpp (209938 => 209939)
--- trunk/Source/WebCore/bindings/js/ArrayValue.cpp 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/bindings/js/ArrayValue.cpp 2016-12-16 22:29:19 UTC (rev 209939)
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- * Copyright (C) 2016 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ArrayValue.h"
-
-#include "Dictionary.h"
-#include <runtime/JSArray.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-ArrayValue::ArrayValue()
- : m_exec(0)
-{
-}
-
-ArrayValue::ArrayValue(JSC::ExecState* exec, JSC::JSValue value)
- : m_exec(exec)
-{
- if (!value.isUndefinedOrNull() && isJSArray(value))
- m_value = value;
-}
-
-ArrayValue& ArrayValue::operator=(const ArrayValue& other)
-{
- m_exec = other.m_exec;
- m_value = other.m_value;
- return *this;
-}
-
-bool ArrayValue::isUndefinedOrNull() const
-{
- return m_value.isEmpty() || m_value.isUndefinedOrNull();
-}
-
-bool ArrayValue::length(size_t& length) const
-{
- if (isUndefinedOrNull())
- return false;
-
- JSArray* array = asArray(m_value);
- length = array->length();
- return true;
-}
-
-bool ArrayValue::get(size_t index, Dictionary& value) const
-{
- if (isUndefinedOrNull())
- return false;
-
- JSValue indexedValue = asArray(m_value)->getIndex(m_exec, index);
- if (indexedValue.isUndefinedOrNull() || !indexedValue.isObject())
- return false;
-
- value = Dictionary(m_exec, indexedValue);
- return true;
-}
-
-bool ArrayValue::get(size_t index, String& value) const
-{
- VM& vm = m_exec->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- if (isUndefinedOrNull())
- return false;
-
- JSValue indexedValue = asArray(m_value)->getIndex(m_exec, index);
- if (indexedValue.isUndefinedOrNull() || !indexedValue.isString())
- return false;
-
- value = asString(indexedValue)->value(m_exec);
- RETURN_IF_EXCEPTION(scope, false);
-
- return true;
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/bindings/js/ArrayValue.h (209938 => 209939)
--- trunk/Source/WebCore/bindings/js/ArrayValue.h 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/bindings/js/ArrayValue.h 2016-12-16 22:29:19 UTC (rev 209939)
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <interpreter/CallFrame.h>
-
-namespace WebCore {
-
-class Dictionary;
-
-class ArrayValue {
-public:
- ArrayValue();
- ArrayValue(JSC::ExecState*, JSC::JSValue);
-
- ArrayValue& operator=(const ArrayValue&);
-
- bool isUndefinedOrNull() const;
-
- bool length(size_t&) const;
- bool get(size_t index, Dictionary&) const;
- bool get(size_t index, String&) const;
-
-private:
- JSC::ExecState* m_exec;
- JSC::JSValue m_value;
-};
-
-} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/Dictionary.cpp (209938 => 209939)
--- trunk/Source/WebCore/bindings/js/Dictionary.cpp 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/bindings/js/Dictionary.cpp 2016-12-16 22:29:19 UTC (rev 209939)
@@ -26,7 +26,6 @@
#include "config.h"
#include "Dictionary.h"
-#include "ArrayValue.h"
#include "JSDOMConvert.h"
using namespace JSC;
@@ -125,11 +124,4 @@
result = Dictionary(&state, value);
}
-void Dictionary::convertValue(ExecState& state, JSValue value, ArrayValue& result)
-{
- if (value.isUndefinedOrNull())
- return;
- result = ArrayValue(&state, value);
}
-
-}
Modified: trunk/Source/WebCore/bindings/js/Dictionary.h (209938 => 209939)
--- trunk/Source/WebCore/bindings/js/Dictionary.h 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/bindings/js/Dictionary.h 2016-12-16 22:29:19 UTC (rev 209939)
@@ -42,8 +42,6 @@
namespace WebCore {
-class ArrayValue;
-
class Dictionary {
public:
Dictionary();
@@ -85,7 +83,6 @@
static void convertValue(JSC::ExecState&, JSC::JSValue, String& result);
static void convertValue(JSC::ExecState&, JSC::JSValue, Vector<String>& result);
static void convertValue(JSC::ExecState&, JSC::JSValue, Dictionary& result);
- static void convertValue(JSC::ExecState&, JSC::JSValue, ArrayValue& result);
JSC::ExecState* m_state { nullptr };
JSC::Strong<JSC::JSObject> m_initializerObject;
Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (209938 => 209939)
--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2016-12-16 22:26:09 UTC (rev 209938)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2016-12-16 22:29:19 UTC (rev 209939)
@@ -25,7 +25,6 @@
// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
-#include "ArrayValue.cpp"
#include "CachedModuleScript.cpp"
#include "CachedModuleScriptLoader.cpp"
#include "CallbackFunction.cpp"