You can download the source code for WebCore from Apple's Web site. The code can be found here. In addition to WebCore, JavaScriptCore is also available for download. If you wish to keep both WebCore and JavaScriptCore in sync, it's recommended that you download and build both of them at the same time.
The READMEs contained in the two frameworks have instructions regarding how to build. For convenience, they are included below:
JavaScriptCore README:
In order to use the WebCore and JavaScriptCore projects together you
will need to set both projects to use the same build products directory.
To do this:
1. Click on the JavaScriptCore project item in the Files tab and
"Show Info" (in the Project menu or use cmd-I).
2. Select "Place build products for this project in a separate
location" and type in the shared location (or click the
"Choose..." button to choose a directory).
3. Select "Place intermediate build files for this project in the
same location as the build products".
The repeat these same three steps for WebCore.
Build first JavaScriptCore and then WebCore using either the Project
Builder interface or the "pbxbuild" command from the command line.
WebCore README
WebCore is a framework for Mac OS X that takes the cross-platform
KHTML library (part of the KDE project) and combines it with an
adapter library specific to WebCore called KWQ that makes it work
with Mac OS X technologies. KHTML is written in C++ and KWQ is written
in Objective C++, but WebCore presents an Objective C programming
interface. WebCore requires the JavaScriptCore framework.
This version of WebCore is based on the KHTML library from KDE 3.0.2.
Changes that are specific to WebCore are marked with #if APPLE_CHANGES.
Other changes to improve performance and web page compatibility are
intended for integration into future versions of the KHTML library.
In order to use the WebCore and JavaScriptCore projects together you
will need to set both projects to use the same build products directory.
The JavaScriptCore README has detailed instructions about how to set
this up.
After JavaScriptCore is built, you can build WebCore using the Project
Builder interface or the "pbxbuild" command from the command line.
Once you have a build of the two frameworks, you can drop those frameworks into your Safari.app in order to test your changes. Note that there are a handful of Objective-C++ objects that exist in two worlds and bridge the layer between WebCore and WebKit. Should the APIs for those objects change, then you may run into trouble when you drop the frameworks into Safari and the methods don't match up between the Kit and the Core.
If this does happen to you, the good news is you should see ObjC exceptions about unsupported messages. The trick is to then diff your WebCore with a WebCore that was known to work before. Armed with that diff, you can then revert the methods that fail back to the same signature that the old WebCore had.
You can assume that a version number of Safari (e.g., v60) uses the same version number for WebCore and JavaScriptCore. So for example, if you have just built WebCore v65, and dropped it into Safari v60, and you encounter problems, then you should construct a diff of WebCore from v60 to v65 and then look for the messages that threw exceptions and massage them into a compatible form.