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

Unified Diff: Source/bindings/core/v8/V8StringResource.h

Issue 368313005: IDL: Add support for [TreatNullAs=EmptyString] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix debug compilation Created 6 years, 5 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: Source/bindings/core/v8/V8StringResource.h
diff --git a/Source/bindings/core/v8/V8StringResource.h b/Source/bindings/core/v8/V8StringResource.h
index 92dd0b80d065033b60cf2d2f64459f8072f836ea..3ecfb964131e9bb5c838efb8c7d8ab4ba5bc7d8b 100644
--- a/Source/bindings/core/v8/V8StringResource.h
+++ b/Source/bindings/core/v8/V8StringResource.h
@@ -162,8 +162,9 @@ String int32ToWebCoreString(int value);
// or AtomicStrings as appropriate, using multiple typecast operators.
enum V8StringResourceMode {
DefaultMode,
- WithNullCheck,
- WithUndefinedOrNullCheck
+ TreatNullAsEmptyString,
+ TreatNullAsNullString,
+ TreatNullAndUndefinedAsNullString
};
template <V8StringResourceMode Mode = DefaultMode>
@@ -201,7 +202,7 @@ public:
return true;
if (!isValid()) {
- setString(String());
+ setString(fallbackString());
return true;
}
@@ -228,6 +229,7 @@ public:
private:
bool isValid() const;
+ String fallbackString() const;
void setString(const String& string)
{
@@ -254,16 +256,42 @@ template<> inline bool V8StringResource<DefaultMode>::isValid() const
return true;
}
-template<> inline bool V8StringResource<WithNullCheck>::isValid() const
+template<> inline String V8StringResource<DefaultMode>::fallbackString() const
+{
+ ASSERT_NOT_REACHED();
+ return String();
+}
+
+template<> inline bool V8StringResource<TreatNullAsEmptyString>::isValid() const
+{
+ return !m_v8Object->IsNull();
+}
+
+template<> inline String V8StringResource<TreatNullAsEmptyString>::fallbackString() const
+{
+ return emptyString();
+}
+
+template<> inline bool V8StringResource<TreatNullAsNullString>::isValid() const
{
return !m_v8Object->IsNull();
}
-template<> inline bool V8StringResource<WithUndefinedOrNullCheck>::isValid() const
+template<> inline String V8StringResource<TreatNullAsNullString>::fallbackString() const
+{
+ return String();
+}
+
+template<> inline bool V8StringResource<TreatNullAndUndefinedAsNullString>::isValid() const
{
return !m_v8Object->IsNull() && !m_v8Object->IsUndefined();
}
+template<> inline String V8StringResource<TreatNullAndUndefinedAsNullString>::fallbackString() const
+{
+ return String();
+}
+
} // namespace WebCore
#endif // V8StringResource_h
« no previous file with comments | « Source/bindings/core/v8/V8Binding.cpp ('k') | Source/bindings/core/v8/custom/V8CSSStyleDeclarationCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698