Adding DOM classes to CEF

Think CEF could benefit from a new feature or capability? Discuss CEF feature requests here.

Re: Adding DOM classes to CEF

Postby emerick » Tue Apr 20, 2010 10:51 am

Marshall,

I've done some work on this and I can provide my diffs if it would be helpful. I followed your proposed API, although I renamed CefDOMElement to CefDOMNode and didn't include the strictly element-related methods (e.g., HasAttributes). I think it's best to follow Chromium's lead here and have two separate classes: CefDOMNode and CefDOMElement.

Emerick
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Adding DOM classes to CEF

Postby magreenblatt » Tue Apr 20, 2010 10:58 am

Hi Emerick,

Great to hear! Please attach your patch to the associated issue ( http://code.google.com/p/chromiumembedd ... tail?id=60 ) and we'll move forward from there.

Regards,
Marshall
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Adding DOM classes to CEF

Postby emerick » Tue Apr 20, 2010 3:02 pm

OK, I updated that item with my diffs (CefDOMNode and CefDOMRange). This is diffed against r72 of the CEF. The changes I made are bracketed with #ifdef EN_CEF_MODS/#endif, since I've also made some minor non-DOM modifications to the CEF. Hopefully, this doesn't render the patch useless to you, but it will require some very minor fixups on your side (just a couple of deletions).
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Adding DOM classes to CEF

Postby emerick » Tue May 18, 2010 9:26 pm

Has anyone (Marshall?) put any thought into how "Phase 2" of this work should be implemented (i.e. the DOM listeners)? I'm looking at potentially implementing this now and could use some guidance on the design front. WebKit::WebEventListener has a pure virtual function named handleEvent() that's called when an event is received. I presume that CEF would need to subclass WebEventListener and provide its own implementation of handleEvent. What's the best approach to then route that event to the client?
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Adding DOM classes to CEF

Postby magreenblatt » Thu May 20, 2010 8:59 am

Something like the following would probably be good.

1. Create a CEF class in cef.h that provides access to WebEvent information (CefWebEvent?).
2. Create a CEF class in cef.h that handles web events (CefWebEventHandler?) and exposes a single virtual method that accepts a CefWebEvent argument.
3. Create a class in libcef that implements WebEventListener and forwards handleEvent() calls to the associated CefWebEventHandler.
4. Add methods to the CEF document class that allow for registration/unregistration of handlers with arguments similar to WebNode::addEventListener() and WebNode::removeEventListener().

Also, are you planning to upload a new patch for issue 60 covering the bug fixes that you mention there?

Regards,
Marshall
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Adding DOM classes to CEF

Postby emerick » Thu May 20, 2010 9:06 am

Marshall,

Thanks for the input, that sounds like a good approach. I'll investigate implementing that.

Thank you for pinging me about my patch for Issue 60. My day job is keeping me pretty busy right now (the kids too ;-), but I hope to have the patch sorted out soon. It's definitely on my radar and I haven't forgotten about it at all. I'll try to carve out some time this weekend, if possible! I'm sure a lot of people would find this useful.

Thanks,

Emerick
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Adding DOM classes to CEF

Postby emerick » Thu May 20, 2010 3:44 pm

Hi Marshall,

The one thing I'm having trouble following here is how a client of CEF provides its own handler implementation. For example, let's suppose that I want to provide my own specific "click" handler for a DOM node. Following the design you provided, am I (as a client of CEF) expected to subclass CefWebEventHandler? I guess I'm not understanding how one constructs a CefWebEventHandler and what the implementation of CefWebEventHandler::HandleEvent actually does.

Sorry if this is a dumb question. I've been stuck in C for the past few years, so my object-oriented design skills are still a little rusty at the moment! In C, I'd implement some type of callback function; I'm not sure what the correct paradigm is in C++, however.

Thanks,

Emerick
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Adding DOM classes to CEF

Postby magreenblatt » Thu May 20, 2010 3:54 pm

Following the design you provided, am I (as a client of CEF) expected to subclass CefWebEventHandler?


Yes, the client would implement CefWebEventHandler. This is identical in concept to how CefV8Handler works.

Sorry if this is a dumb question


No such thing :-).
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Adding DOM classes to CEF

Postby emerick » Thu May 20, 2010 6:38 pm

Yes, the client would implement CefWebEventHandler. This is identical in concept to how CefV8Handler works.


Ah, perfect. It turns out that I was on the right track then, but I was trying to subclass CefWebEventHandler instead of the correct CefThreadSafeBase<CefWebEventHandler>. Thanks for the pointer to CefV8Handler, that was very useful!

Now to see if it all works...

Emerick
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: Adding DOM classes to CEF

Postby emerick » Fri May 21, 2010 2:30 pm

Implemented as described and everything seems to work properly so far. I'll clean the code up this weekend and provide a patch for your review that includes this change and my other DOM changes.

Thanks for all of the help with this!

Emerick
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

PreviousNext

Return to Feature Request Forum

Who is online

Users browsing this forum: No registered users and 20 guests