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

Unified Diff: Source/core/testing/Internals.cpp

Issue 483163003: Introduce ES6 iterator for DOM objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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/core/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index e2179351d80974b8f6042360a135805693161fe0..5b4a92af667077592b73584565323053b0965d9e 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -48,6 +48,7 @@
#include "core/dom/DocumentMarkerController.h"
#include "core/dom/Element.h"
#include "core/dom/ExceptionCode.h"
+#include "core/dom/Iterator.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/dom/PseudoElement.h"
#include "core/dom/Range.h"
@@ -67,9 +68,9 @@
#include "core/editing/TextIterator.h"
#include "core/fetch/MemoryCache.h"
#include "core/fetch/ResourceFetcher.h"
-#include "core/frame/LocalDOMWindow.h"
#include "core/frame/EventHandlerRegistry.h"
#include "core/frame/FrameView.h"
+#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/frame/WebKitPoint.h"
@@ -141,6 +142,37 @@
namespace blink {
+namespace {
+
+class InternalsIterator : public Iterator {
haraken 2014/08/21 16:15:58 Add FINAL.
yhirano 2014/08/25 06:09:26 Done.
+public:
+ InternalsIterator() : m_current(0) { }
+
+ virtual ScriptValue next(ScriptState* scriptState, ExceptionState& exceptionState) OVERRIDE
+ {
+ v8::Isolate* isolate = scriptState->isolate();
+ v8::Local<v8::Value> value = v8::Integer::New(isolate, m_current * m_current);
+ bool done = (m_current >= 5);
+ ++m_current;
+
+ v8::Local<v8::Object> result = v8::Object::New(isolate);
+ result->Set(v8String(isolate, "value"), value);
+ result->Set(v8String(isolate, "done"), v8::Boolean::New(isolate, done));
haraken 2014/08/21 16:15:58 v8::Boolean::New() => v8Boolean()
yhirano 2014/08/25 06:09:26 Done.
+ return ScriptValue(scriptState, result);
+ }
+
+ virtual ScriptValue next(ScriptState* scriptState, ScriptValue value, ExceptionState& exceptionState) OVERRIDE
+ {
+ exceptionState.throwTypeError("Not implemented");
+ return ScriptValue();
+ }
+
+private:
+ int m_current;
+};
+
+} // namespace
+
// FIXME: oilpan: These will be removed soon.
static MockPagePopupDriver* s_pagePopupDriver = 0;
@@ -2225,4 +2257,9 @@ void Internals::forcePluginPlaceholder(HTMLElement* element, const String& htmlS
toHTMLPlugInElement(element)->setUsePlaceholderContent(true);
}
+Iterator* Internals::iterator(ScriptState* scriptState, ExceptionState& exceptionState)
+{
+ return new InternalsIterator;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698