Title: [158361] trunk/Source/WebCore
- Revision
- 158361
- Author
- [email protected]
- Date
- 2013-10-31 09:28:14 -0700 (Thu, 31 Oct 2013)
Log Message
CryptoAlgorithmDescriptionBuilder should support producing nested algorithms
https://bugs.webkit.org/show_bug.cgi?id=123461
Reviewed by Darin Adler.
To add a nested algorithm, clone a builder with createEmptyClone(), fill it,
and add it using add().
* bindings/js/JSCryptoAlgorithmBuilder.h:
* crypto/CryptoAlgorithmDescriptionBuilder.h:
* bindings/js/JSCryptoAlgorithmBuilder.cpp:
(WebCore::JSCryptoAlgorithmBuilder::createEmptyClone):
(WebCore::JSCryptoAlgorithmBuilder::add): Keep VM in a local variable for marginally
better performance.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (158360 => 158361)
--- trunk/Source/WebCore/ChangeLog 2013-10-31 15:35:02 UTC (rev 158360)
+++ trunk/Source/WebCore/ChangeLog 2013-10-31 16:28:14 UTC (rev 158361)
@@ -1,3 +1,20 @@
+2013-10-30 Alexey Proskuryakov <[email protected]>
+
+ CryptoAlgorithmDescriptionBuilder should support producing nested algorithms
+ https://bugs.webkit.org/show_bug.cgi?id=123461
+
+ Reviewed by Darin Adler.
+
+ To add a nested algorithm, clone a builder with createEmptyClone(), fill it,
+ and add it using add().
+
+ * bindings/js/JSCryptoAlgorithmBuilder.h:
+ * crypto/CryptoAlgorithmDescriptionBuilder.h:
+ * bindings/js/JSCryptoAlgorithmBuilder.cpp:
+ (WebCore::JSCryptoAlgorithmBuilder::createEmptyClone):
+ (WebCore::JSCryptoAlgorithmBuilder::add): Keep VM in a local variable for marginally
+ better performance.
+
2013-10-31 Philippe Normand <[email protected]>
[WK2][GTK] enable-media-stream Setting
Modified: trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp (158360 => 158361)
--- trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp 2013-10-31 15:35:02 UTC (rev 158360)
+++ trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.cpp 2013-10-31 16:28:14 UTC (rev 158361)
@@ -44,18 +44,33 @@
{
}
-void JSCryptoAlgorithmBuilder::add(const char* key, unsigned long value)
+std::unique_ptr<CryptoAlgorithmDescriptionBuilder> JSCryptoAlgorithmBuilder::createEmptyClone() const
{
- Identifier identifier(m_exec, key);
- m_dictionary->putDirect(m_exec->vm(), identifier, jsNumber(value));
+ return std::make_unique<JSCryptoAlgorithmBuilder>(m_exec);
}
+void JSCryptoAlgorithmBuilder::add(const char* key, unsigned value)
+{
+ VM& vm = m_exec->vm();
+ Identifier identifier(&vm, key);
+ m_dictionary->putDirect(vm, identifier, jsNumber(value));
+}
+
void JSCryptoAlgorithmBuilder::add(const char* key, const String& value)
{
- Identifier identifier(m_exec, key);
- m_dictionary->putDirect(m_exec->vm(), identifier, jsString(m_exec, value));
+ VM& vm = m_exec->vm();
+ Identifier identifier(&vm, key);
+ m_dictionary->putDirect(vm, identifier, jsString(m_exec, value));
}
+void JSCryptoAlgorithmBuilder::add(const char* key, const CryptoAlgorithmDescriptionBuilder& nestedBuilder)
+{
+ VM& vm = m_exec->vm();
+ Identifier identifier(&vm, key);
+ const JSCryptoAlgorithmBuilder& jsBuilder = static_cast<const JSCryptoAlgorithmBuilder&>(nestedBuilder);
+ m_dictionary->putDirect(vm, identifier, jsBuilder.result());
+}
+
} // namespace WebCore
#endif // ENABLE(SUBTLE_CRYPTO)
Modified: trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h (158360 => 158361)
--- trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h 2013-10-31 15:35:02 UTC (rev 158360)
+++ trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmBuilder.h 2013-10-31 16:28:14 UTC (rev 158361)
@@ -42,10 +42,13 @@
JSCryptoAlgorithmBuilder(JSC::ExecState*);
virtual ~JSCryptoAlgorithmBuilder();
- JSC::JSObject* result() { return m_dictionary; }
+ JSC::JSObject* result() const { return m_dictionary; }
- virtual void add(const char*, unsigned long) OVERRIDE;
+ virtual std::unique_ptr<CryptoAlgorithmDescriptionBuilder> createEmptyClone() const OVERRIDE;
+
+ virtual void add(const char*, unsigned) OVERRIDE;
virtual void add(const char*, const String&) OVERRIDE;
+ virtual void add(const char*, const CryptoAlgorithmDescriptionBuilder&) OVERRIDE;
private:
JSC::ExecState* m_exec;
Modified: trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h (158360 => 158361)
--- trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h 2013-10-31 15:35:02 UTC (rev 158360)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmDescriptionBuilder.h 2013-10-31 16:28:14 UTC (rev 158361)
@@ -39,8 +39,11 @@
CryptoAlgorithmDescriptionBuilder();
virtual ~CryptoAlgorithmDescriptionBuilder();
- virtual void add(const char*, unsigned long) = 0;
+ virtual std::unique_ptr<CryptoAlgorithmDescriptionBuilder> createEmptyClone() const = 0;
+
+ virtual void add(const char*, unsigned) = 0;
virtual void add(const char*, const String&) = 0;
+ virtual void add(const char*, const CryptoAlgorithmDescriptionBuilder&) = 0;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes