:first-letter text-transformation fix

Leo Savernik l.savernik at aon.at
Wed Sep 3 19:40:20 BST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

:first-letter doesn't play well with text-transformation (see [1]). As it 
breaks caret navigation, I had to fix it, and have come up with the attached 
patch.

It changes RenderText::setStyle to recognize the render object being part of 
:first-letter, and only setting the relevant part for text transformation.

This chang forced some reorganisations in RenderFlow::addChildToFlow. The text 
child must be added *before* the style information is set. As addChild 
somehow accesses style information, I added a helper 
RenderObject::setStyleDirectly, which directly sets m_style. So the new code 
looks like this:

		letter = new (renderArena()) RenderText(newTextChild->element() /* anonymous 
object */, oldText->substring(0,length));
		RenderStyle* newStyle = new RenderStyle();
		newStyle->inheritFrom(pseudoStyle);
		letter->setStyleDirectly(newStyle);
                letter->setIsAnonymousBox(true);
		firstLetter->addChild(letter);
		newTextChild->setForcedMinOffset(length);

The real style cannot be set here because the render tree isn't fully 
constructed at that moment, so I postponed setting to the end of the method. 
Therefore I replaced all returns by gotos (Why does C++ not have 
try/finally?), so that :first-letter construction takes place anyway.

Before I commit I'd like to ask: Is it guaranteed that the RenderText 
containing the real text always is a direct sibling of the anonymous 
:first-letter flow object? I can't deduce it from the code, but assume this 
all over the place.

Btw.: :first-letter has other problems in connection with :before, too. In 
this case, it should apply to the content of :before, not to the content of 
the first DOM text node. This can even go as far as having the :before 
represent some punctuation like ", and the DOM text node the real 
first-letter. In this case we need *two* anonymous RenderTexts. And it's not 
too far-fetched given the fact that <q> uses :before/:after to generate the 
quotation marks.

mfg
	Leo

[1] http://tom.me.uk/bugs/safari/first-letter-transform.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/VjWbj5jssenUYTsRAtuMAJ920EOeShi9b32O5hARvERt6qRM9wCfZ/xs
3q+3xnTn0OlTpYLf2J36g2g=
=Nfui
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: khtml_navigation_19.diff
Type: text/x-diff
Size: 10180 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20030903/8f3eef03/attachment.diff>


More information about the kfm-devel mailing list