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

Side by Side Diff: Source/bindings/v8/custom/V8WebKitNamedFlowCustom.cpp

Issue 38943008: Explore the possibility of implementing the CSS Region interface. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Prototype v2 Created 7 years, 1 month 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
(Empty)
1 /*
2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 #include "config.h"
31 #include "V8WebKitNamedFlow.h"
32
33 #include "V8HTMLElement.h"
34 #include "V8PseudoElement.h"
35
abarth-chromium 2013/11/14 07:55:15 no need for this blank line
36 #include "bindings/v8/V8Binding.h"
37 #include "core/dom/NamedFlow.h"
38 #include "core/rendering/RenderRegion.h"
39
abarth-chromium 2013/11/14 07:55:15 ditto
40 #include "wtf/RefPtr.h"
41 #include "wtf/Vector.h"
42
43 namespace WebCore {
44
45 static v8::Handle<v8::Value> toV8Array(Vector<const RenderRegion*>& regionsList, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
abarth-chromium 2013/11/14 07:55:15 regionsList -> regions
46 {
47 v8::Local<v8::Array> result = v8::Array::New(regionsList.size());
abarth-chromium 2013/11/14 07:55:15 If script has replaced the global Array constructo
abucur 2013/11/15 07:15:14 Good point, I agree it's a problem if this code ex
48
49 int index = 0;
50 Vector<const RenderRegion*>::const_iterator end = regionsList.end();
51 for (Vector<const RenderRegion*>::const_iterator iter = regionsList.begin(); iter != end; ++iter) {
52 const RenderRegion* region = *iter;
53 Element* generator = region->element();
54 if (!generator)
55 continue;
abarth-chromium 2013/11/14 07:55:15 When can this happen?
abucur 2013/11/15 07:15:14 At this moment, never. It's better to make it an A
56 if (generator->isHTMLElement())
57 result->Set(v8::Integer::New(index++, isolate), toV8(toHTMLElement(g enerator), creationContext, isolate));
58 else if (generator->isPseudoElement())
59 result->Set(v8::Integer::New(index++, isolate), toV8(toPseudoElement (generator), creationContext, isolate));
60 else
61 ASSERT_NOT_REACHED();
abarth-chromium 2013/11/14 07:55:15 Why can't it be a non-HTML element?
abucur 2013/11/15 07:15:14 At this moment only blocks can become regions (I s
62 }
63
64 return result;
65 }
66
67 void V8WebKitNamedFlow::getRegionsMethodCustom(const v8::FunctionCallbackInfo<v8 ::Value>& args)
68 {
69 NamedFlow* imp = V8WebKitNamedFlow::toNative(args.Holder());
70 Vector<const RenderRegion*> regionsList = imp->getRegions();
71
72 v8SetReturnValue(args, toV8Array(regionsList, args.Holder(), args.GetIsolate ()));
73 }
74
75 void V8WebKitNamedFlow::getRegionsByContentMethodCustom(const v8::FunctionCallba ckInfo<v8::Value>& args)
76 {
77 NamedFlow* imp = V8WebKitNamedFlow::toNative(args.Holder());
78
79 V8TRYCATCH_VOID(Node*, node, V8Node::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(a rgs[1])) : 0);
abarth-chromium 2013/11/14 07:55:15 What about args[0]? What if there are zero or one
abucur 2013/11/15 07:15:14 Oh, I don't know why I had the feeling args[0] was
80 Vector<const RenderRegion*> regionsList = imp->getRegionsByContent(node);
81
82 v8SetReturnValue(args, toV8Array(regionsList, args.Holder(), args.GetIsolate ()));
83 }
84
85 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698