Re: text selection and images
"corvid" <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <20111016203129.GB14482@local> |
I wrote: > > I think this may be a different problem, but I discovered that moving the > mouse about a lot while selecting text (I think it helps if the page is > shorter than the viewport) can get: > [...] The valgrind complaints go away if we check the case where we're in the space following the word specially. I'm guessing that the nextGlyph() loop happens to 'work' but shouldn't. _______________________________________________ Dillo-dev mailing list [email protected] http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
valgrind_text_selection.diff
(text/plain, 2.9 KB)
diff -r 43854b926388 dw/textblock.cc
--- a/dw/textblock.cc Fri Oct 14 21:56:13 2011 +0000
+++ b/dw/textblock.cc Sun Oct 16 20:26:49 2011 +0000
@@ -656,23 +656,30 @@
if (word->content.type == core::Content::TEXT) {
// Search the character the mouse pointer is in.
// nextWordX is the right side of this character.
- charPos = 0;
- while ((nextWordX = wordStartX +
- layout->textWidth (word->style->font,
- word->content.text, charPos))
- <= event->xWidget)
- charPos = layout->nextGlyph (word->content.text,
+ if (event->xWidget >= nextWordStartX - word->effSpace) {
+ charPos = core::SelectionState::END_OF_WORD;
+ } else {
+ charPos = 0;
+ while ((nextWordX = wordStartX +
+ layout->textWidth (word->style->font,
+ word->content.text,
+ charPos))
+ <= event->xWidget)
+ charPos = layout->nextGlyph (word->content.text,
+ charPos);
+ // The left side of this character.
+ prevPos = layout->prevGlyph (word->content.text,
charPos);
- // The left side of this character.
- prevPos = layout->prevGlyph (word->content.text, charPos);
- wordX = wordStartX + layout->textWidth (word->style->font,
- word->content.text,
- prevPos);
+ wordX = wordStartX +
+ layout->textWidth (word->style->font,
+ word->content.text,
+ prevPos);
- // If the mouse pointer is left from the middle, use the
- // left position, otherwise, use the right one.
- if (event->xWidget <= (wordX + nextWordX) / 2)
- charPos = prevPos;
+ // If the mouse pointer is left from the middle, use
+ // left left position, otherwise, use the right one.
+ if (event->xWidget <= (wordX + nextWordX) / 2)
+ charPos = prevPos;
+ }
} else {
// Depends on whether the pointer is within the left or
// right half of the (non-text) word.