Sunday, May 6, 2018

internal implementation of DataTransfer.effectAllowed in firefox and chrome browser

Leave a Comment

I'm currently studying the HTML5 drag and drop API on MDN and I'm interested in learning a bit more about how DataTransfer.effectAllowed is implemented in firefox and chrome browser.

Because the source code for both browsers are huge and it is a difficult task for someone unfamiliar with the source code to find exact what they are looking for, so I was just wondering whether anyone can share their experience/strategy in searching through their source code?

1 Answers

Answers 1

I'm not sure about Chrome, but I'll try with Mozilla Firefox. Even though it's huge, the Firefox codebase is searchable using two different engines: Searchfox and DXR. Both are great and have different pros/cons.

Searchfox:

  • it's fast;
  • it's easy to follow the code by looking up symbols/implementations and keep digging through the code from there.

DXR:

  • is much more flexible;
  • doesn't render RST files automatically (that's a pro to me :D).

Now, to your question, let's look up DataTranfer.effectAllowed using searchfox.

  1. In the searchbox on the left, write `effectAllowed".
  2. This gives a bunch of stuff, JS and C++. The second result comes from dom/events/DataTransfer.h, which might be what you're looking for.
  3. Let's restrict the search to .cpp files by writing *.cpp in the box on the top right.
  4. The second result will be from dom/events/DataTransfer.cpp which is exactly where the implementation lives. See here.

From there, depending on what you're looking for, you can keep investigating. I hope this helps :)

Update: steps for searching Chromium's source

Turns out Chromium has a similar service for searching through the code base. The steps are quite similar as well!

  1. Go to https://cs.chromium.org/ .
  2. Write EffectAllowed in the searchbox at the center of the page.
  3. You'll be presented with a drop down with some results. Pick setEffectAllowed (in blink::DataTransfer), the one with the .cc implementation file.
  4. Browse to here and have fun!
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment