Skip to content

Commit

Permalink
lvtext: rename LTEXT_WORD_IS_OBJECT to LTEXT_WORD_IS_IMAGE
Browse files Browse the repository at this point in the history
Also rename OBJECT_CHAR_INDEX to IMAGE_CHAR_INDEX.
Also remove LTEXT_WORD_ unused flags.
  • Loading branch information
poire-z committed Apr 23, 2022
1 parent d6564c3 commit 6fe1411
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
8 changes: 4 additions & 4 deletions crengine/include/lvtextfm.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ typedef struct

// formatted_word_t flags
#define LTEXT_WORD_CAN_ADD_SPACE_AFTER 0x0001 /// can add space after this word
#define LTEXT_WORD_CAN_BREAK_LINE_AFTER 0x0002 /// can break line after this word (not used anywhere)
#define LTEXT_WORD_CAN_HYPH_BREAK_LINE_AFTER 0x0004 /// can break with hyphenation after this word
#define LTEXT_WORD_MUST_BREAK_LINE_AFTER 0x0008 /// must break line after this word (not used anywhere)
#define LTEXT_WORD_CAN_HYPH_BREAK_LINE_AFTER 0x0002 /// can break with hyphenation after this word
#define LTEXT_WORD__AVAILABLE_BIT_03__ 0x0004
#define LTEXT_WORD__AVAILABLE_BIT_04__ 0x0008

#define LTEXT_WORD_IS_LINK_START 0x0010 /// first word of link flag
#define LTEXT_WORD_IS_OBJECT 0x0020 /// word is an image
#define LTEXT_WORD_IS_IMAGE 0x0020 /// word is an image
#define LTEXT_WORD_IS_INLINE_BOX 0x0040 /// word is a inline-block or inline-table wrapping box
#define LTEXT_WORD__AVAILABLE_BIT_08__ 0x0080

Expand Down
20 changes: 11 additions & 9 deletions crengine/src/lvtextfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void lvtextAddSourceLine( formatted_text_fragment_t * pbuffer,
// CRLog::trace("c font = %08x txt = %08x", (lUInt32)font, (lUInt32)text);
// ((LVFont*)font)->getVisualAligmentWidth();
// }
// if (font == NULL && ((flags & LTEXT_WORD_IS_OBJECT) == 0)) {
// if (font == NULL && ((flags & LTEXT_WORD_IS_IMAGE) == 0)) {
// CRLog::fatal("No font specified for text");
// }
if ( !lang_cfg )
Expand Down Expand Up @@ -429,7 +429,7 @@ class LVFormatter {
// So, when checking for these, also checks for m_flags[i] & LCHAR_IS_OBJECT.
// Note that m_charindex, being lUInt16, assume text nodes are not longer
// than 65535 chars. Things will get messy with longer text nodes...
#define OBJECT_CHAR_INDEX ((lUInt16)0xFFFF)
#define IMAGE_CHAR_INDEX ((lUInt16)0xFFFF)
#define FLOAT_CHAR_INDEX ((lUInt16)0xFFFE)
#define INLINEBOX_CHAR_INDEX ((lUInt16)0xFFFD)

Expand Down Expand Up @@ -1181,7 +1181,7 @@ class LVFormatter {
else if ( src->o.objflags & LTEXT_OBJECT_IS_IMAGE ) {
m_text[pos] = 0;
m_srcs[pos] = src;
m_charindex[pos] = OBJECT_CHAR_INDEX; //0xFFFF;
m_charindex[pos] = IMAGE_CHAR_INDEX; //0xFFFF;
m_flags[pos] = LCHAR_IS_OBJECT;
#if (USE_LIBUNIBREAK==1)
// Let libunibreak know there was an object
Expand Down Expand Up @@ -2073,7 +2073,7 @@ class LVFormatter {
lastWidth += width;
m_widths[start] = lastWidth;
}
else {
else if ( m_charindex[start] == IMAGE_CHAR_INDEX ) {
// measure image
// assume i==start+1
src_text_fragment_t * src = m_srcs[start];
Expand Down Expand Up @@ -2109,6 +2109,10 @@ class LVFormatter {
UnicodeToLocal(ldomXPointer((ldomNode*)m_srcs[start]->object, 0).toString()).c_str());
*/
}
else {
// Should not happen
crFatalError(129, "Attempting to measure unexpected object type");
}
}
else {
// Should not happen
Expand Down Expand Up @@ -3187,7 +3191,7 @@ class LVFormatter {
}
}
else if ( srcline->o.objflags & LTEXT_OBJECT_IS_IMAGE ) {
word->flags = LTEXT_WORD_IS_OBJECT;
word->flags = LTEXT_WORD_IS_IMAGE;
// The image dimensions have already been resized to fit
// into m_pbuffer->width (and strut confining if requested.
// Note: it can happen when there is some text-indent than
Expand Down Expand Up @@ -3592,8 +3596,6 @@ class LVFormatter {
// between previous word and this one if needed
frmline->words[frmline->word_count-2].flags |= LTEXT_WORD_CAN_ADD_SPACE_AFTER;
}
// if ( m_flags[i-1] & LCHAR_ALLOW_WRAP_AFTER )
// word->flags |= LTEXT_WORD_CAN_BREAK_LINE_AFTER; // not used anywhere

if ( lastWord && (align == LTEXT_ALIGN_RIGHT || align == LTEXT_ALIGN_WIDTH) ) {
// Adjust line end if needed.
Expand Down Expand Up @@ -5057,7 +5059,7 @@ void LFormattedText::Draw( LVDrawBuf * buf, int x, int y, ldomMarkedRangeList *
srcline = &m_pbuffer->srctext[word->src_text_index];
if ( (srcline->flags & LTEXT_HAS_EXTRA) && getLTextExtraProperty(srcline, LTEXT_EXTRA_CSS_HIDDEN) && !buf->WantsHiddenContent() )
continue;
if (word->flags & LTEXT_WORD_IS_OBJECT)
if (word->flags & LTEXT_WORD_IS_IMAGE)
{
// no background, TODO
}
Expand Down Expand Up @@ -5134,7 +5136,7 @@ void LFormattedText::Draw( LVDrawBuf * buf, int x, int y, ldomMarkedRangeList *
srcline = &m_pbuffer->srctext[word->src_text_index];
if ( (srcline->flags & LTEXT_HAS_EXTRA) && getLTextExtraProperty(srcline, LTEXT_EXTRA_CSS_HIDDEN) && !buf->WantsHiddenContent() )
continue;
if (word->flags & LTEXT_WORD_IS_OBJECT)
if (word->flags & LTEXT_WORD_IS_IMAGE)
{
ldomNode * node = (ldomNode *) srcline->object;
if (node) {
Expand Down
14 changes: 7 additions & 7 deletions crengine/src/lvtinydom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9016,7 +9016,7 @@ ldomXPointer ldomDocument::createXPointer( lvPoint pt, int direction, bool stric
// Otherwise, return xpointer to the inlineBox itself
return ldomXPointer(node, 0);
}
if ( word->flags & LTEXT_WORD_IS_OBJECT ) {
if ( word->flags & LTEXT_WORD_IS_IMAGE ) {
return ldomXPointer(node, 0);
}
// It is a word
Expand Down Expand Up @@ -9058,7 +9058,7 @@ ldomXPointer ldomDocument::createXPointer( lvPoint pt, int direction, bool stric
// Otherwise, return xpointer to the inlineBox itself
return ldomXPointer(node, 0);
}
if ( word->flags & LTEXT_WORD_IS_OBJECT ) {
if ( word->flags & LTEXT_WORD_IS_IMAGE ) {
// Object (image)
#if 1
// return image object itself
Expand Down Expand Up @@ -9345,22 +9345,22 @@ bool ldomXPointer::getRect(lvRect & rect, bool extended, bool adjusted) const
else {
bestBidiRect.left = word->x + rc.left + frmline->x;
if (extended) {
if (word->flags & (LTEXT_WORD_IS_OBJECT|LTEXT_WORD_IS_INLINE_BOX) && word->width > 0)
if (word->flags & (LTEXT_WORD_IS_IMAGE|LTEXT_WORD_IS_INLINE_BOX) && word->width > 0)
bestBidiRect.right = bestBidiRect.left + word->width; // width of image
else
bestBidiRect.right = bestBidiRect.left + 1;
}
}
hasBestBidiRect = true;
nearestForwardSrcIndex = word->src_text_index;
if (word->flags & (LTEXT_WORD_IS_OBJECT|LTEXT_WORD_IS_INLINE_BOX))
if (word->flags & (LTEXT_WORD_IS_IMAGE|LTEXT_WORD_IS_INLINE_BOX))
nearestForwardSrcOffset = 0;
else
nearestForwardSrcOffset = word->t.start;
}
else if (word->src_text_index == srcIndex) {
// Found word in that exact source text node
if ( word->flags & (LTEXT_WORD_IS_OBJECT|LTEXT_WORD_IS_INLINE_BOX) ) {
if ( word->flags & (LTEXT_WORD_IS_IMAGE|LTEXT_WORD_IS_INLINE_BOX) ) {
// An image is the single thing in its srcIndex
rect.top = rc.top + frmline->y;
rect.bottom = rect.top + frmline->height;
Expand Down Expand Up @@ -9557,7 +9557,7 @@ bool ldomXPointer::getRect(lvRect & rect, bool extended, bool adjusted) const
// Generic code when visual order = logical order
if ( word->src_text_index>=srcIndex || lastWord ) {
// found word from same src line
if ( word->flags & (LTEXT_WORD_IS_OBJECT|LTEXT_WORD_IS_INLINE_BOX)
if ( word->flags & (LTEXT_WORD_IS_IMAGE|LTEXT_WORD_IS_INLINE_BOX)
|| word->src_text_index > srcIndex
|| (!extended && offset <= word->t.start)
|| (extended && offset < word->t.start)
Expand All @@ -9569,7 +9569,7 @@ bool ldomXPointer::getRect(lvRect & rect, bool extended, bool adjusted) const
//rect.top = word->y + rc.top + frmline->y + frmline->baseline;
rect.top = rc.top + frmline->y;
if (extended) {
if (word->flags & (LTEXT_WORD_IS_OBJECT|LTEXT_WORD_IS_INLINE_BOX) && word->width > 0)
if (word->flags & (LTEXT_WORD_IS_IMAGE|LTEXT_WORD_IS_INLINE_BOX) && word->width > 0)
rect.right = rect.left + word->width; // width of image
else
rect.right = rect.left + 1; // not the right word: no char width
Expand Down

0 comments on commit 6fe1411

Please sign in to comment.