[webkit-dev] Web Editing and FontManager

Darin Adler darin at apple.com
Tue Sep 5 17:47:17 PDT 2006


On Sep 5, 2006, at 3:06 PM, Rob Burns wrote:

> I'm trying to understand how the FontManager interfaces with  
> WebView. to alter the behavior and replicate in other ways. Does  
> anyone know how FontManager doe s its magic with WebView? What  
> methods are called, etc.? Looking at Blot.app for example, the  
> "Bold" menu item targets FontManager addFontTrait method. After  
> that how does the WebView end up inserting " <SPAN class="Apple- 
> style-span" style="font-weight: bold;"></SPAN>" wrapped around the  
> selectedDOMRange? I imagine much of this happens in the black-box  
> of the FontManager, but what method finally get called in the  
> WebKit APIs?

A great way to figure this out is to set a breakpoint in a low level  
function. In this case, a good example is  
'WebCore::createStyleSpanElement'.

You'll see that's called by these functions (with many less important  
ones in between):

     ApplyStyleCommand::doApply
     Frame::applyStyle
     -[WebCoreFrameBridge applyStyle:withUndoAction:]
     -[WebHTMLView _applyStyleToSelection:withUndoAction:]
     -[WebHTMLView changeFont:]

The tricky bit is inside a method called by changeFont:, called - 
[WebHTMLView _styleFromFontManagerOperation], which has the job of  
figuring out what kind of font manager operation the font panel had  
in mind. The panel doesn't just pass "make this bold", sadly.

     -- Darin




More information about the webkit-dev mailing list