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

Issue 38943008: Explore the possibility of implementing the CSS Region interface.

Created:
7 years, 1 month ago by abucur
Modified:
7 years, 1 month ago
CC:
blink-reviews, eae+blinkwatch, apavlov+blink_chromium.org, adamk+blink_chromium.org, aandrey+blink_chromium.org, Nils Barth (inactive), caseq+blink_chromium.org, Nate Chapin, chromiumbugtracker_adobe.com, yurys+blink_chromium.org, abarth-chromium, marja+watch_chromium.org, dglazkov+blink, devtools-reviews_chromium.org, loislo+blink_chromium.org, lushnikov+blink_chromium.org, eustas+blink_chromium.org, paulirish+reviews_chromium.org, darktears, haraken, kojih, jsbell+bindings_chromium.org, alph+blink_chromium.org, vsevik+blink_chromium.org, pfeldman+blink_chromium.org, Inactive
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

NOT FOR LANDING! Explore the possibility of implementing the CSS Region interface. ====== New prototype below ====== The new prototype takes a different approach. The getRegions() and getRegionsForContent() APIs are now custom implemented. They get a Vector of RenderRegion* objects and introspect the type of the regions similarly with CanvasRenderingContext2D strokeStyle or fillStyle. A V8 Array is created and filled with the wrappers for the objects representing the regions. The array is set as the return value for the functions. Another thing present in the prototype is a new dummy PseudoElement interface that implements the Region interface. It was created as a proof-of-concept for the moment when PseudoElements will be exposed through the CSS OM. The PseudoElement objects are not destroyed when they are discarded through CSS. They live until there's no other reference from V8 to the objects. On a dead pseudo-element the Region API will return null values. The prototype solves: - the ugly hack in the bindings generator from the previous prototype - the life cycle issue with storing a RenderRegion pointer inside a CSSRegion object ====== Old Prototype below ====== This is a proof-of-concept for a possible approach of implementing the Region interface. The idea is to make the Region interface a NoInterfaceObject interface and mark Element as implementing Region. This allows us to implement the Region interface functions without affecting the inheritance tree for Element. When we are asked to return an array of such objects: - we instantiate a Region interface object in C++, wrapping the RenderRegion object - when we generate the V8 wrapper, we verify what kind of object that region actually is. For now, only Elements are allowed. - we return in V8 a wrap of the native object that region actually represents This way, we can mix all kind of V8 objects inside the array returned by getRegions. BUG=

Patch Set 1 #

Total comments: 14

Patch Set 2 : Prototype v2 #

Total comments: 19
Unified diffs Side-by-side diffs Delta from patch set Stats (+164 lines, -61 lines) Patch
M Source/bindings/bindings.gypi View 1 1 chunk +1 line, -0 lines 0 comments Download
A Source/bindings/v8/custom/V8WebKitNamedFlowCustom.cpp View 1 1 chunk +85 lines, -0 lines 11 comments Download
M Source/core/core.gypi View 1 3 chunks +3 lines, -0 lines 0 comments Download
A + Source/core/css/CSSRegion.h View 1 1 chunk +39 lines, -19 lines 2 comments Download
A + Source/core/css/CSSRegion.idl View 1 1 chunk +5 lines, -6 lines 2 comments Download
M Source/core/dom/Element.idl View 2 chunks +1 line, -4 lines 0 comments Download
M Source/core/dom/NamedFlow.h View 1 2 chunks +3 lines, -2 lines 2 comments Download
M Source/core/dom/NamedFlow.cpp View 1 4 chunks +13 lines, -19 lines 0 comments Download
M Source/core/dom/PseudoElement.cpp View 1 1 chunk +2 lines, -0 lines 0 comments Download
A + Source/core/dom/PseudoElement.idl View 1 2 chunks +3 lines, -4 lines 2 comments Download
M Source/core/dom/WebKitNamedFlow.idl View 1 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/inspector/InspectorCSSAgent.h View 1 2 chunks +2 lines, -1 line 0 comments Download
M Source/core/inspector/InspectorCSSAgent.cpp View 1 3 chunks +5 lines, -4 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
abucur
Adding a comment about the bindings script hack. https://codereview.chromium.org/38943008/diff/1/Source/bindings/scripts/generate_bindings.pl File Source/bindings/scripts/generate_bindings.pl (right): https://codereview.chromium.org/38943008/diff/1/Source/bindings/scripts/generate_bindings.pl#newcode99 Source/bindings/scripts/generate_bindings.pl:99: if ...
7 years, 1 month ago (2013-10-25 16:54:56 UTC) #1
abarth-chromium
https://codereview.chromium.org/38943008/diff/1/Source/core/css/CSSRegion.h File Source/core/css/CSSRegion.h (right): https://codereview.chromium.org/38943008/diff/1/Source/core/css/CSSRegion.h#newcode73 Source/core/css/CSSRegion.h:73: const RenderRegion* m_region; How are the lifetimes of CSSRegion ...
7 years, 1 month ago (2013-10-25 16:56:20 UTC) #2
abarth-chromium
https://codereview.chromium.org/38943008/diff/1/Source/bindings/scripts/generate_bindings.pl File Source/bindings/scripts/generate_bindings.pl (right): https://codereview.chromium.org/38943008/diff/1/Source/bindings/scripts/generate_bindings.pl#newcode99 Source/bindings/scripts/generate_bindings.pl:99: if (!$idlFound and !($targetInterfaceName eq "CSSRegion")) { On 2013/10/25 ...
7 years, 1 month ago (2013-10-25 16:57:23 UTC) #3
Inactive
https://codereview.chromium.org/38943008/diff/1/Source/bindings/scripts/generate_bindings.pl File Source/bindings/scripts/generate_bindings.pl (right): https://codereview.chromium.org/38943008/diff/1/Source/bindings/scripts/generate_bindings.pl#newcode99 Source/bindings/scripts/generate_bindings.pl:99: if (!$idlFound and !($targetInterfaceName eq "CSSRegion")) { On 2013/10/25 ...
7 years, 1 month ago (2013-10-25 17:48:50 UTC) #4
Inactive
https://codereview.chromium.org/38943008/diff/1/Source/core/dom/NamedFlow.cpp File Source/core/dom/NamedFlow.cpp (right): https://codereview.chromium.org/38943008/diff/1/Source/core/dom/NamedFlow.cpp#newcode124 Source/core/dom/NamedFlow.cpp:124: Vector<RefPtr<CSSRegion>> regionObjects; C++11? https://codereview.chromium.org/38943008/diff/1/Source/core/inspector/InspectorCSSAgent.cpp File Source/core/inspector/InspectorCSSAgent.cpp (right): https://codereview.chromium.org/38943008/diff/1/Source/core/inspector/InspectorCSSAgent.cpp#newcode1778 Source/core/inspector/InspectorCSSAgent.cpp:1778: ...
7 years, 1 month ago (2013-10-25 17:51:47 UTC) #5
abucur
Another prototype for the Region interface solving the design issues raised for the first version.
7 years, 1 month ago (2013-10-29 16:28:46 UTC) #6
abarth-chromium
https://codereview.chromium.org/38943008/diff/130001/Source/core/css/CSSRegion.idl File Source/core/css/CSSRegion.idl (right): https://codereview.chromium.org/38943008/diff/130001/Source/core/css/CSSRegion.idl#newcode33 Source/core/css/CSSRegion.idl:33: [PerWorldBindings] readonly attribute DOMString webkitRegionOverset; There's no need for ...
7 years, 1 month ago (2013-10-30 16:38:20 UTC) #7
abarth-chromium
Ok, you've convinced me that this problem is solvable without requiring a massive refactoring of ...
7 years, 1 month ago (2013-11-14 07:55:14 UTC) #8
abucur
7 years, 1 month ago (2013-11-15 07:15:14 UTC) #9
Awesome news! Thanks for taking the time to look into this.

https://codereview.chromium.org/38943008/diff/130001/Source/bindings/v8/custo...
File Source/bindings/v8/custom/V8WebKitNamedFlowCustom.cpp (right):

https://codereview.chromium.org/38943008/diff/130001/Source/bindings/v8/custo...
Source/bindings/v8/custom/V8WebKitNamedFlowCustom.cpp:47: v8::Local<v8::Array>
result = v8::Array::New(regionsList.size());
On 2013/11/14 07:55:15, abarth wrote:
> If script has replaced the global Array constructor, will this line of code
> cause JavaScript to execute?
> 
> If it's possible to enter the site's script at any time during this function,
> we're in deep trouble because nothing is keeping the RenderRegion* in the
Vector
> alive.  Other than this line, I don't see anything else that triggers JS
> execution, but this approach is very fragile.  Instead, you probably want the
> C++ DOM API to return a DOM concept (not a RenderTree concept) because DOM
> concepts can be usually be retained by RefPtrs whereas RenderTree concepts
> cannot.  In your earlier iteration, you wrapped the RenderRegion* in a
> RefCounted container, but that's just window dressing around the same problem.

> You can solve this problem, it's just some ugly code.

Good point, I agree it's a problem if this code execute scripts, though I
suspect it should be possible for the engine to build a "default" type of array.
It doesn't sound very safe (and neither spec compliant) for the engine to return
user defined data structures when a Web API is called. It somehow exposes the
browser internals.

I'll break this dependency and write a test for it in the final patch.

https://codereview.chromium.org/38943008/diff/130001/Source/bindings/v8/custo...
Source/bindings/v8/custom/V8WebKitNamedFlowCustom.cpp:55: continue;
On 2013/11/14 07:55:15, abarth wrote:
> When can this happen?

At this moment, never. It's better to make it an ASSERT.

https://codereview.chromium.org/38943008/diff/130001/Source/bindings/v8/custo...
Source/bindings/v8/custom/V8WebKitNamedFlowCustom.cpp:61: ASSERT_NOT_REACHED();
On 2013/11/14 07:55:15, abarth wrote:
> Why can't it be a non-HTML element?

At this moment only blocks can become regions (I suspected this implies
HTMLElement, please correct me if I'm wrong). The ASSERT_NOT_REACHED is there to
help implementors add a new toV8 case for future region types that may appear.
If they forgot to edit this file, running the OM tests will cause this to
trigger.

https://codereview.chromium.org/38943008/diff/130001/Source/bindings/v8/custo...
Source/bindings/v8/custom/V8WebKitNamedFlowCustom.cpp:79: V8TRYCATCH_VOID(Node*,
node, V8Node::HasInstance(args[1], args.GetIsolate(),
worldType(args.GetIsolate())) ?
V8Node::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
On 2013/11/14 07:55:15, abarth wrote:
> What about args[0]?  What if there are zero or one argument?

Oh, I don't know why I had the feeling args[0] was the Function object. I'll
change it in the real implementation.

https://codereview.chromium.org/38943008/diff/130001/Source/core/css/CSSRegion.h
File Source/core/css/CSSRegion.h (right):

https://codereview.chromium.org/38943008/diff/130001/Source/core/css/CSSRegio...
Source/core/css/CSSRegion.h:49: }
On 2013/11/14 07:55:15, abarth wrote:
> We shouldn't use the "webkit" prefix in C++.  You can use the ImplementedAs
IDL
> attribute to map a prefixed names in the IDL to an unprefixed C++ name.

Ok, I'll create a code review that will remove the prefixes from C++.

https://codereview.chromium.org/38943008/diff/130001/Source/core/css/CSSRegio...
File Source/core/css/CSSRegion.idl (right):

https://codereview.chromium.org/38943008/diff/130001/Source/core/css/CSSRegio...
Source/core/css/CSSRegion.idl:33: [PerWorldBindings] readonly attribute
DOMString webkitRegionOverset;
On 2013/10/30 16:38:20, abarth wrote:
> There's no need for per-world bindings here.

I think it was in the Element definition and I didn't change it when I took the
attribute out of there. I'll remove it in the implementation.

https://codereview.chromium.org/38943008/diff/130001/Source/core/dom/NamedFlow.h
File Source/core/dom/NamedFlow.h (right):

https://codereview.chromium.org/38943008/diff/130001/Source/core/dom/NamedFlo...
Source/core/dom/NamedFlow.h:46: class RenderRegion;
On 2013/11/14 07:55:15, abarth wrote:
> These seem like bad dependencies.  The DOM shouldn't really have any direct
> dependencies on the render tree, but that's a topic for another day.

I had in mind creating a DOM equivalent for region a while back but I didn't get
the chance. Maybe it's something we should do before exposing the Region
interface.

https://codereview.chromium.org/38943008/diff/130001/Source/core/dom/PseudoEl...
File Source/core/dom/PseudoElement.idl (right):

https://codereview.chromium.org/38943008/diff/130001/Source/core/dom/PseudoEl...
Source/core/dom/PseudoElement.idl:30: interface PseudoElement {
On 2013/11/14 07:55:15, abarth wrote:
> This probably needs NoInterfaceObject, right?

Yes. I forgot to add it.

Powered by Google App Engine
This is Rietveld 408576698