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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 30 matching lines...) Expand all
41 #include "core/css/resolver/StyleResolverStats.h" 41 #include "core/css/resolver/StyleResolverStats.h"
42 #include "core/css/resolver/ViewportStyleResolver.h" 42 #include "core/css/resolver/ViewportStyleResolver.h"
43 #include "core/dom/ClientRect.h" 43 #include "core/dom/ClientRect.h"
44 #include "core/dom/ClientRectList.h" 44 #include "core/dom/ClientRectList.h"
45 #include "core/dom/DOMStringList.h" 45 #include "core/dom/DOMStringList.h"
46 #include "core/dom/Document.h" 46 #include "core/dom/Document.h"
47 #include "core/dom/DocumentMarker.h" 47 #include "core/dom/DocumentMarker.h"
48 #include "core/dom/DocumentMarkerController.h" 48 #include "core/dom/DocumentMarkerController.h"
49 #include "core/dom/Element.h" 49 #include "core/dom/Element.h"
50 #include "core/dom/ExceptionCode.h" 50 #include "core/dom/ExceptionCode.h"
51 #include "core/dom/Iterator.h"
51 #include "core/dom/NodeRenderStyle.h" 52 #include "core/dom/NodeRenderStyle.h"
52 #include "core/dom/PseudoElement.h" 53 #include "core/dom/PseudoElement.h"
53 #include "core/dom/Range.h" 54 #include "core/dom/Range.h"
54 #include "core/dom/StaticNodeList.h" 55 #include "core/dom/StaticNodeList.h"
55 #include "core/dom/StyleEngine.h" 56 #include "core/dom/StyleEngine.h"
56 #include "core/dom/TreeScope.h" 57 #include "core/dom/TreeScope.h"
57 #include "core/dom/ViewportDescription.h" 58 #include "core/dom/ViewportDescription.h"
58 #include "core/dom/shadow/ComposedTreeWalker.h" 59 #include "core/dom/shadow/ComposedTreeWalker.h"
59 #include "core/dom/shadow/ElementShadow.h" 60 #include "core/dom/shadow/ElementShadow.h"
60 #include "core/dom/shadow/SelectRuleFeatureSet.h" 61 #include "core/dom/shadow/SelectRuleFeatureSet.h"
61 #include "core/dom/shadow/ShadowRoot.h" 62 #include "core/dom/shadow/ShadowRoot.h"
62 #include "core/editing/Editor.h" 63 #include "core/editing/Editor.h"
63 #include "core/editing/PlainTextRange.h" 64 #include "core/editing/PlainTextRange.h"
64 #include "core/editing/SpellCheckRequester.h" 65 #include "core/editing/SpellCheckRequester.h"
65 #include "core/editing/SpellChecker.h" 66 #include "core/editing/SpellChecker.h"
66 #include "core/editing/SurroundingText.h" 67 #include "core/editing/SurroundingText.h"
67 #include "core/editing/TextIterator.h" 68 #include "core/editing/TextIterator.h"
68 #include "core/fetch/MemoryCache.h" 69 #include "core/fetch/MemoryCache.h"
69 #include "core/fetch/ResourceFetcher.h" 70 #include "core/fetch/ResourceFetcher.h"
70 #include "core/frame/LocalDOMWindow.h"
71 #include "core/frame/EventHandlerRegistry.h" 71 #include "core/frame/EventHandlerRegistry.h"
72 #include "core/frame/FrameView.h" 72 #include "core/frame/FrameView.h"
73 #include "core/frame/LocalDOMWindow.h"
73 #include "core/frame/LocalFrame.h" 74 #include "core/frame/LocalFrame.h"
74 #include "core/frame/Settings.h" 75 #include "core/frame/Settings.h"
75 #include "core/frame/WebKitPoint.h" 76 #include "core/frame/WebKitPoint.h"
76 #include "core/html/HTMLContentElement.h" 77 #include "core/html/HTMLContentElement.h"
77 #include "core/html/HTMLIFrameElement.h" 78 #include "core/html/HTMLIFrameElement.h"
78 #include "core/html/HTMLInputElement.h" 79 #include "core/html/HTMLInputElement.h"
79 #include "core/html/HTMLMediaElement.h" 80 #include "core/html/HTMLMediaElement.h"
80 #include "core/html/HTMLPlugInElement.h" 81 #include "core/html/HTMLPlugInElement.h"
81 #include "core/html/HTMLSelectElement.h" 82 #include "core/html/HTMLSelectElement.h"
82 #include "core/html/HTMLTextAreaElement.h" 83 #include "core/html/HTMLTextAreaElement.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 #include "public/platform/WebGraphicsContext3DProvider.h" 135 #include "public/platform/WebGraphicsContext3DProvider.h"
135 #include "public/platform/WebLayer.h" 136 #include "public/platform/WebLayer.h"
136 #include "wtf/InstanceCounter.h" 137 #include "wtf/InstanceCounter.h"
137 #include "wtf/PassOwnPtr.h" 138 #include "wtf/PassOwnPtr.h"
138 #include "wtf/dtoa.h" 139 #include "wtf/dtoa.h"
139 #include "wtf/text/StringBuffer.h" 140 #include "wtf/text/StringBuffer.h"
140 #include <v8.h> 141 #include <v8.h>
141 142
142 namespace blink { 143 namespace blink {
143 144
145 namespace {
146
147 class InternalsIterator : public Iterator {
haraken 2014/08/21 16:15:58 Add FINAL.
yhirano 2014/08/25 06:09:26 Done.
148 public:
149 InternalsIterator() : m_current(0) { }
150
151 virtual ScriptValue next(ScriptState* scriptState, ExceptionState& exception State) OVERRIDE
152 {
153 v8::Isolate* isolate = scriptState->isolate();
154 v8::Local<v8::Value> value = v8::Integer::New(isolate, m_current * m_cur rent);
155 bool done = (m_current >= 5);
156 ++m_current;
157
158 v8::Local<v8::Object> result = v8::Object::New(isolate);
159 result->Set(v8String(isolate, "value"), value);
160 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.
161 return ScriptValue(scriptState, result);
162 }
163
164 virtual ScriptValue next(ScriptState* scriptState, ScriptValue value, Except ionState& exceptionState) OVERRIDE
165 {
166 exceptionState.throwTypeError("Not implemented");
167 return ScriptValue();
168 }
169
170 private:
171 int m_current;
172 };
173
174 } // namespace
175
144 // FIXME: oilpan: These will be removed soon. 176 // FIXME: oilpan: These will be removed soon.
145 static MockPagePopupDriver* s_pagePopupDriver = 0; 177 static MockPagePopupDriver* s_pagePopupDriver = 0;
146 178
147 using namespace HTMLNames; 179 using namespace HTMLNames;
148 180
149 static bool markerTypesFrom(const String& markerType, DocumentMarker::MarkerType s& result) 181 static bool markerTypesFrom(const String& markerType, DocumentMarker::MarkerType s& result)
150 { 182 {
151 if (markerType.isEmpty() || equalIgnoringCase(markerType, "all")) 183 if (markerType.isEmpty() || equalIgnoringCase(markerType, "all"))
152 result = DocumentMarker::AllMarkers(); 184 result = DocumentMarker::AllMarkers();
153 else if (equalIgnoringCase(markerType, "Spelling")) 185 else if (equalIgnoringCase(markerType, "Spelling"))
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 return; 2250 return;
2219 } 2251 }
2220 if (!element->isPluginElement()) { 2252 if (!element->isPluginElement()) {
2221 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov ided is not a plugin."); 2253 exceptionState.throwDOMException(InvalidNodeTypeError, "The element prov ided is not a plugin.");
2222 return; 2254 return;
2223 } 2255 }
2224 element->ensureUserAgentShadowRoot().setInnerHTML(htmlSource, exceptionState ); 2256 element->ensureUserAgentShadowRoot().setInnerHTML(htmlSource, exceptionState );
2225 toHTMLPlugInElement(element)->setUsePlaceholderContent(true); 2257 toHTMLPlugInElement(element)->setUsePlaceholderContent(true);
2226 } 2258 }
2227 2259
2260 Iterator* Internals::iterator(ScriptState* scriptState, ExceptionState& exceptio nState)
2261 {
2262 return new InternalsIterator;
2263 }
2264
2228 } // namespace blink 2265 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698