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

Unified Diff: Source/modules/webdatabase/SQLResultSetRowList.cpp

Issue 972153002: [bindings] Remove custom binding usage in SQLResultSetRowList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@test
Patch Set: Patch for landing Created 5 years, 10 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/modules/webdatabase/SQLResultSetRowList.cpp
diff --git a/Source/modules/webdatabase/SQLResultSetRowList.cpp b/Source/modules/webdatabase/SQLResultSetRowList.cpp
index 1d16c5e4e84cfb40825699f0a7e9d65809161d43..160270f69433a80caf8dd68aa30c9e7bd6ee79d2 100644
--- a/Source/modules/webdatabase/SQLResultSetRowList.cpp
+++ b/Source/modules/webdatabase/SQLResultSetRowList.cpp
@@ -29,6 +29,11 @@
#include "config.h"
#include "modules/webdatabase/SQLResultSetRowList.h"
+#include "bindings/core/v8/ScriptValue.h"
+#include "bindings/core/v8/ToV8.h"
+#include "bindings/modules/v8/ToV8ForModules.h"
+#include "core/dom/ExceptionCode.h"
+
namespace blink {
unsigned SQLResultSetRowList::length() const
@@ -41,4 +46,21 @@ unsigned SQLResultSetRowList::length() const
return m_result.size() / m_columns.size();
}
+ScriptValue SQLResultSetRowList::item(ScriptState* scriptState, unsigned index, ExceptionState& exceptionState)
+{
+ if (index >= length()) {
+ exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::indexExceedsMaximumBound<unsigned>("index", index, length()));
+ return ScriptValue();
+ }
+
+ unsigned numColumns = m_columns.size();
+ unsigned valuesIndex = index * numColumns;
+
+ Vector<std::pair<String, SQLValue>> dataArray;
+ for (unsigned i = 0; i < numColumns; ++i)
+ dataArray.append(std::make_pair(m_columns[i], m_result[valuesIndex + i]));
+
+ return ScriptValue::from(scriptState, dataArray);
}
+
+} // namespace blink
« no previous file with comments | « Source/modules/webdatabase/SQLResultSetRowList.h ('k') | Source/modules/webdatabase/SQLResultSetRowList.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698