Index: Source/modules/webdatabase/SQLResultSetRowList.cpp |
diff --git a/Source/modules/webdatabase/SQLResultSetRowList.cpp b/Source/modules/webdatabase/SQLResultSetRowList.cpp |
index 1d16c5e4e84cfb40825699f0a7e9d65809161d43..b1b88d652fcec0b78d7bc0cbd712902f8adc0671 100644 |
--- a/Source/modules/webdatabase/SQLResultSetRowList.cpp |
+++ b/Source/modules/webdatabase/SQLResultSetRowList.cpp |
@@ -29,6 +29,9 @@ |
#include "config.h" |
#include "modules/webdatabase/SQLResultSetRowList.h" |
+#include "bindings/modules/v8/ScriptValueUtilities.h" |
+#include "core/dom/ExceptionCode.h" |
+ |
namespace blink { |
unsigned SQLResultSetRowList::length() const |
@@ -41,4 +44,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 toScriptValue(scriptState, dataArray); |
} |
+ |
+} // namespace blink |