Diff
Modified: trunk/Source/WebCore/ChangeLog (200286 => 200287)
--- trunk/Source/WebCore/ChangeLog 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/ChangeLog 2016-04-30 04:51:31 UTC (rev 200287)
@@ -1,5 +1,50 @@
2016-04-29 Chris Dumez <[email protected]>
+ Get rid of unnecessary null check in wrap(JSDOMGlobalObject*, DOMClass*)
+ https://bugs.webkit.org/show_bug.cgi?id=157224
+
+ Reviewed by Ryosuke Niwa.
+
+ Get rid of unnecessary null check in wrap(JSDOMGlobalObject*, DOMClass*)
+ since all the call sites already do a null check. Also update the function
+ to take the implementation object by reference instead of pointer. Finally,
+ use is<>() / downcast<>() more at the call sites.
+
+ * Modules/indexeddb/IDBCursor.cpp:
+ (WebCore::IDBCursor::update):
+ (WebCore::IDBCursor::deleteFunction):
+ (WebCore::IDBCursor::setGetResult):
+ * Modules/indexeddb/IDBCursor.h:
+ (WebCore::IDBCursor::isKeyCursorWithValue):
+ (WebCore::IDBCursor::isKeyCursor): Deleted.
+ * Modules/indexeddb/IDBCursorWithValue.h:
+ (isType):
+ * bindings/js/JSBlobCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSCanvasRenderingContextCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::wrap):
+ * bindings/js/JSIDBCursorCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSMediaStreamCapabilitiesCustom.cpp:
+ (WebCore::toJS):
+ * bindings/js/JSPerformanceEntryCustom.cpp:
+ (WebCore::toJS):
+ * html/canvas/WebGL2RenderingContext.h:
+ * html/canvas/WebGLRenderingContext.h:
+ * page/PerformanceMark.h:
+ (isType):
+ (WebCore::PerformanceMark::isMark): Deleted.
+ * page/PerformanceMeasure.h:
+ (isType):
+ (WebCore::PerformanceMeasure::isMeasure): Deleted.
+ * page/PerformanceResourceTiming.h:
+ (isType):
+ (WebCore::PerformanceResourceTiming::isResource): Deleted.
+
+2016-04-29 Chris Dumez <[email protected]>
+
Use LIKELY() / UNLIKELY() hints when suitable in the _javascript_ bindings
https://bugs.webkit.org/show_bug.cgi?id=157210
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp (200286 => 200287)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.cpp 2016-04-30 04:51:31 UTC (rev 200287)
@@ -187,7 +187,7 @@
return nullptr;
}
- if (isKeyCursor()) {
+ if (!isKeyCursorWithValue()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor.");
return nullptr;
@@ -350,7 +350,7 @@
return nullptr;
}
- if (isKeyCursor()) {
+ if (!isKeyCursorWithValue()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor is a key cursor.");
return nullptr;
@@ -393,10 +393,10 @@
m_currentPrimaryKey = { vm, idbKeyDataToScriptValue(*context, getResult.primaryKeyData()) };
m_currentPrimaryKeyData = getResult.primaryKeyData();
- if (isKeyCursor())
+ if (isKeyCursorWithValue())
+ m_currentValue = { vm, deserializeIDBValueToJSValue(*context, getResult.value()) };
+ else
m_currentValue = { };
- else
- m_currentValue = { vm, deserializeIDBValueToJSValue(*context, getResult.value()) };
m_gotValue = true;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h (200286 => 200287)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursor.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -77,7 +77,7 @@
void setGetResult(IDBRequest&, const IDBGetResult&);
- virtual bool isKeyCursor() const { return true; }
+ virtual bool isKeyCursorWithValue() const { return false; }
void decrementOutstandingRequestCount();
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h (200286 => 200287)
--- trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBCursorWithValue.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -28,6 +28,7 @@
#if ENABLE(INDEXED_DATABASE)
#include "IDBCursor.h"
+#include <wtf/TypeCasts.h>
namespace WebCore {
@@ -38,7 +39,7 @@
virtual ~IDBCursorWithValue();
- bool isKeyCursor() const final { return false; }
+ bool isKeyCursorWithValue() const override { return true; }
private:
IDBCursorWithValue(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
@@ -47,4 +48,8 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::IDBCursorWithValue)
+ static bool isType(const WebCore::IDBCursor& cursor) { return cursor.isKeyCursorWithValue(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp (200286 => 200287)
--- trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp 2016-04-30 04:51:31 UTC (rev 200287)
@@ -53,10 +53,10 @@
if (!blob)
return jsNull();
- if (blob->isFile())
- return wrap<JSFile>(globalObject, static_cast<File*>(blob));
+ if (is<File>(*blob))
+ return wrap<JSFile>(globalObject, downcast<File>(*blob));
- return wrap<JSBlob>(globalObject, blob);
+ return wrap<JSBlob>(globalObject, *blob);
}
EncodedJSValue JSC_HOST_CALL constructJSBlob(ExecState* exec)
Modified: trunk/Source/WebCore/bindings/js/JSCanvasRenderingContextCustom.cpp (200286 => 200287)
--- trunk/Source/WebCore/bindings/js/JSCanvasRenderingContextCustom.cpp 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/bindings/js/JSCanvasRenderingContextCustom.cpp 2016-04-30 04:51:31 UTC (rev 200287)
@@ -53,15 +53,14 @@
return jsNull();
#if ENABLE(WEBGL)
- if (object->isWebGL1())
- return wrap<JSWebGLRenderingContext>(globalObject, static_cast<WebGLRenderingContext*>(object));
+ if (is<WebGLRenderingContext>(*object))
+ return wrap<JSWebGLRenderingContext>(globalObject, downcast<WebGLRenderingContext>(*object));
#if ENABLE(WEBGL2)
- if (object->isWebGL2())
- return wrap<JSWebGL2RenderingContext>(globalObject, static_cast<WebGL2RenderingContext*>(object));
+ if (is<WebGL2RenderingContext>(*object))
+ return wrap<JSWebGL2RenderingContext>(globalObject, downcast<WebGL2RenderingContext>(*object));
#endif
#endif
- ASSERT_WITH_SECURITY_IMPLICATION(object->is2d());
- return wrap<JSCanvasRenderingContext2D>(globalObject, static_cast<CanvasRenderingContext2D*>(object));
+ return wrap<JSCanvasRenderingContext2D>(globalObject, downcast<CanvasRenderingContext2D>(*object));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (200286 => 200287)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -267,13 +267,11 @@
return wrapper;
}
-template<typename WrapperClass, typename DOMClass> inline JSC::JSValue wrap(JSDOMGlobalObject* globalObject, DOMClass* domObject)
+template<typename WrapperClass, typename DOMClass> inline JSC::JSValue wrap(JSDOMGlobalObject* globalObject, DOMClass& domObject)
{
- if (!domObject)
- return JSC::jsNull();
- if (JSC::JSObject* wrapper = getCachedWrapper(globalObject->world(), domObject))
+ if (JSC::JSObject* wrapper = getCachedWrapper(globalObject->world(), &domObject))
return wrapper;
- return createWrapper<WrapperClass>(globalObject, domObject);
+ return createWrapper<WrapperClass>(globalObject, &domObject);
}
template<typename WrapperClass, typename DOMClass> inline JSC::JSValue getExistingWrapper(JSDOMGlobalObject* globalObject, DOMClass* domObject)
Modified: trunk/Source/WebCore/bindings/js/JSIDBCursorCustom.cpp (200286 => 200287)
--- trunk/Source/WebCore/bindings/js/JSIDBCursorCustom.cpp 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/bindings/js/JSIDBCursorCustom.cpp 2016-04-30 04:51:31 UTC (rev 200287)
@@ -54,9 +54,13 @@
JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, IDBCursor* cursor)
{
- if (cursor->isKeyCursor())
- return wrap<JSIDBCursor>(globalObject, cursor);
- return wrap<JSIDBCursorWithValue>(globalObject, static_cast<IDBCursorWithValue*>(cursor));
+ if (!cursor)
+ return JSC::jsNull();
+
+ if (is<IDBCursorWithValue>(*cursor))
+ return wrap<JSIDBCursorWithValue>(globalObject, downcast<IDBCursorWithValue>(*cursor));
+
+ return wrap<JSIDBCursor>(globalObject, *cursor);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSMediaStreamCapabilitiesCustom.cpp (200286 => 200287)
--- trunk/Source/WebCore/bindings/js/JSMediaStreamCapabilitiesCustom.cpp 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/bindings/js/JSMediaStreamCapabilitiesCustom.cpp 2016-04-30 04:51:31 UTC (rev 200287)
@@ -43,9 +43,9 @@
return jsNull();
if (object->hasVideoSource())
- return wrap<JSAllVideoCapabilities>(globalObject, static_cast<AllVideoCapabilities*>(object));
+ return wrap<JSAllVideoCapabilities>(globalObject, static_cast<AllVideoCapabilities>(*object));
- return wrap<JSAllAudioCapabilities>(globalObject, static_cast<AllAudioCapabilities*>(object));
+ return wrap<JSAllAudioCapabilities>(globalObject, static_cast<AllAudioCapabilities>(*object));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/js/JSPerformanceEntryCustom.cpp (200286 => 200287)
--- trunk/Source/WebCore/bindings/js/JSPerformanceEntryCustom.cpp 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/bindings/js/JSPerformanceEntryCustom.cpp 2016-04-30 04:51:31 UTC (rev 200287)
@@ -52,19 +52,19 @@
return jsNull();
#if ENABLE(RESOURCE_TIMING)
- if (entry->isResource())
- return wrap<JSPerformanceResourceTiming>(globalObject, static_cast<PerformanceResourceTiming*>(entry));
+ if (is<PerformanceResourceTiming>(*entry))
+ return wrap<JSPerformanceResourceTiming>(globalObject, downcast<PerformanceResourceTiming>(*entry));
#endif
#if ENABLE(USER_TIMING)
- if (entry->isMark())
- return wrap<JSPerformanceMark>(globalObject, static_cast<PerformanceMark*>(entry));
+ if (is<PerformanceMark>(*entry))
+ return wrap<JSPerformanceMark>(globalObject, downcast<PerformanceMark>(*entry));
- if (entry->isMeasure())
- return wrap<JSPerformanceMeasure>(globalObject, static_cast<PerformanceMeasure*>(entry));
+ if (is<PerformanceMeasure>(*entry))
+ return wrap<JSPerformanceMeasure>(globalObject, downcast<PerformanceMeasure>(*entry));
#endif
- return wrap<JSPerformanceEntry>(globalObject, entry);
+ return wrap<JSPerformanceEntry>(globalObject, *entry);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h (200286 => 200287)
--- trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -220,6 +220,8 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGL2RenderingContext, isWebGL2())
+
#endif // WEBGL2
#endif
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h (200286 => 200287)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -85,4 +85,6 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGLRenderingContext, isWebGL1())
+
#endif
Modified: trunk/Source/WebCore/page/PerformanceEntry.h (200286 => 200287)
--- trunk/Source/WebCore/page/PerformanceEntry.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/page/PerformanceEntry.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -37,6 +37,7 @@
#include "Performance.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
+#include <wtf/TypeCasts.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -50,9 +51,9 @@
double startTime() const;
double duration() const;
- virtual bool isResource() { return false; }
- virtual bool isMark() { return false; }
- virtual bool isMeasure() { return false; }
+ virtual bool isResource() const { return false; }
+ virtual bool isMark() const { return false; }
+ virtual bool isMeasure() const { return false; }
static bool startTimeCompareLessThan(PassRefPtr<PerformanceEntry> a, PassRefPtr<PerformanceEntry> b)
{
Modified: trunk/Source/WebCore/page/PerformanceMark.h (200286 => 200287)
--- trunk/Source/WebCore/page/PerformanceMark.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/page/PerformanceMark.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -34,11 +34,11 @@
namespace WebCore {
-class PerformanceMark : public PerformanceEntry {
+class PerformanceMark final : public PerformanceEntry {
public:
static Ref<PerformanceMark> create(const String& name, double startTime) { return adoptRef(*new PerformanceMark(name, startTime)); }
- virtual bool isMark() { return true; }
+ bool isMark() const override { return true; }
private:
PerformanceMark(const String& name, double startTime) : PerformanceEntry(name, "mark", startTime, startTime) { }
@@ -47,6 +47,10 @@
}
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::PerformanceMark)
+ static bool isType(const WebCore::PerformanceEntry& entry) { return entry.isMark(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // ENABLE(USER_TIMING)
#endif // !defined(PerformanceMark_h)
Modified: trunk/Source/WebCore/page/PerformanceMeasure.h (200286 => 200287)
--- trunk/Source/WebCore/page/PerformanceMeasure.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/page/PerformanceMeasure.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -34,11 +34,11 @@
namespace WebCore {
-class PerformanceMeasure : public PerformanceEntry {
+class PerformanceMeasure final : public PerformanceEntry {
public:
static Ref<PerformanceMeasure> create(const String& name, double startTime, double duration) { return adoptRef(*new PerformanceMeasure(name, startTime, duration)); }
- virtual bool isMeasure() { return true; }
+ bool isMeasure() const override { return true; }
private:
PerformanceMeasure(const String& name, double startTime, double duration) : PerformanceEntry(name, "measure", startTime, duration) { }
@@ -47,6 +47,10 @@
}
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::PerformanceMeasure)
+ static bool isType(const WebCore::PerformanceEntry& entry) { return entry.isMeasure(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // ENABLE(USER_TIMING)
#endif // !defined(PerformanceMeasure_h)
Modified: trunk/Source/WebCore/page/PerformanceResourceTiming.h (200286 => 200287)
--- trunk/Source/WebCore/page/PerformanceResourceTiming.h 2016-04-30 04:48:34 UTC (rev 200286)
+++ trunk/Source/WebCore/page/PerformanceResourceTiming.h 2016-04-30 04:51:31 UTC (rev 200287)
@@ -48,7 +48,7 @@
class ResourceRequest;
class ResourceResponse;
-class PerformanceResourceTiming : public PerformanceEntry {
+class PerformanceResourceTiming final : public PerformanceEntry {
public:
static Ref<PerformanceResourceTiming> create(const AtomicString& initiatorType, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime, Document* requestingDocument)
{
@@ -68,7 +68,7 @@
double requestStart() const;
double responseEnd() const;
- virtual bool isResource() { return true; }
+ bool isResource() const override { return true; }
private:
PerformanceResourceTiming(const AtomicString& initatorType, const ResourceRequest&, const ResourceResponse&, double initiationTime, double finishTime, Document*);
@@ -85,6 +85,11 @@
}
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::PerformanceResourceTiming)
+ static bool isType(const WebCore::PerformanceEntry& entry) { return entry.isResource(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // ENABLE(RESOURCE_TIMING)
#endif // !defined(PerformanceResourceTiming_h)