From kfm-devel Thu Jun 17 13:30:13 1999 From: Waldo Bastian Date: Thu, 17 Jun 1999 13:30:13 +0000 To: kfm-devel Subject: Re: khtml/khtmlw and getSelected()/getSelectedText() X-MARC-Message: https://marc.info/?l=kfm-devel&m=92962525022289 Dawit Alemayehu wrote: > > On Wed, 16 Jun 1999, Waldo Bastian wrote: > [snipped] > > I had a look at this the other day. The problem seems to be that select() isn't > > working correctly for HTMLText objects. You might have noted that Ctrl-A > > does select all other objects (e.g. images, links) on a page. > > Correct. This is what I actually meant. It does not select the text objects > at all. But what is wierd is that HTMLLinkText inherts from HTMLText and > does not override the select() method at all. Why would it then work for > hyper-links and not regular text objects. Well... We have several text classes... there is a README about that I guess. Most text is not actually a HTMLText but a HTMLTextMaster. This HTMLTextMaster spawns of HTMLTextSlaves during layout. The HTMLTextMaster contains the actual text as well as selection start and end. The HTMLTextSlave contains a pointer to the Master and info about where which part of the text should be drawn. > > I think that we should add a select(...) method to HTMLText which takes into > > account the selStart and selEnd fields of the HTMLText object. > > >From one of the select() methods in HTMLText : > > void HTMLText::select( KHTMLWidget *_htmlw, HTMLChain *_chain, > bool _select, int _tx, int _ty ) > { > const char *u = getURL(); > if ( (u == 0) || (*u == '\0') || (_select == isSelected()) ) > return; > > setSelected( _select ); > > selStart = 0; > selEnd = strlen( text ); > > _chain->push( this ); > _htmlw->paint(_chain, x + _tx, y - ascent + _ty, width, ascent+descent); > _chain->pop(); > } > > setStart and selEnd values that contain the length of the text within the > HTMLText object are indeed already in both select methods, but they are not used > at all in these methods. Could this be the problem ?? Unlikely. They are used in the paint methods of the object. (htmlw->paint descents the object tree to paint the object) > The reason > I am unsure is because HTMLLinkText inherts from HTMLText and does not override > the select() methods, however the select() function works okay for it. The problem most likely doesn't lie in HTMLText but in HTMLTextMaster/Slave. (Sorry for stating otherwise) Basically there are two clases of HTMLText functions: HTMLText and HTMLTextMaster/HTMLTextSlave. Derived from these is HTMLLinkText and (I guess) HTMLLinkTextMaster (used for links) The difference between HTMLText and HTMLTextMaster/Slave is that HTMLText is used for words without any spaces or with only non-breaking spaces. HTMLTextMaster is a specialized object which can contain a whole paragraph of text and which can fit itself into a flow thereby breaking itself up into HTMLTextSlaves for each line. This is done to reduce the number of objects needed to render text. Having a paragraph consisting of text with 100 words which needs to be spread across 5 lines would take 100 HTMLText objects. Using HTMLTextMaster/ Slave objects, we only need 1 HTMLTextMaster and 5 HTMLTextSlaves. Unfortunately these Master/Slaves objects are slightly more complex than the other objects in KHTML(W). Cheers, Waldo -- KDE, A New Millenium, A New Desktop http://www.kde.org