Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background images enhancements, fix FB2 footnotes alignment #353

Merged
merged 8 commits into from
Jul 5, 2020
Merged
16 changes: 5 additions & 11 deletions crengine/include/cssdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,6 @@ enum css_background_repeat_value_t {
css_background_r_inherit,
css_background_r_none
};
enum css_background_attachment_value_t {
css_background_scroll,
css_background_fixed,
css_background_local,
css_background_a_initial,
css_background_a_inherit,
css_background_a_none
};
enum css_background_position_value_t {
css_background_left_top,
css_background_left_center,
Expand Down Expand Up @@ -330,9 +322,11 @@ enum css_direction_t {
};

enum css_generic_value_t {
css_generic_auto = -1, // (css_val_unspecified, css_generic_auto), for "margin: auto"
css_generic_normal = -2, // (css_val_unspecified, css_generic_normal), for "line-height: normal"
css_generic_transparent = -3 // (css_val_unspecified, css_generic_transparent), for "color: transparent"
css_generic_auto = -1, // (css_val_unspecified, css_generic_auto), for "margin: auto"
css_generic_normal = -2, // (css_val_unspecified, css_generic_normal), for "line-height: normal"
css_generic_transparent = -3, // (css_val_unspecified, css_generic_transparent), for "color: transparent"
css_generic_contain = -4, // (css_val_unspecified, css_generic_contain), for "background-size: contain"
css_generic_cover = -5 // (css_val_unspecified, css_generic_cover), for "background-size: cover"
};

// Non standard property for providing hints to crengine via style tweaks
Expand Down
16 changes: 8 additions & 8 deletions crengine/include/dtddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,25 @@ struct ns_def_t {
#define XS_BEGIN_TAGS \
static elem_def_t fb2_elem_table [] = {
#define XS_TAG1(itm) \
{ el_ ## itm, #itm, {false, false, css_d_block, css_ws_normal} },
{ el_ ## itm, #itm, {false, false, css_d_block, css_ws_inherit} },
#define XS_TAG2(itm, name) \
{ el_ ## itm, name, {false, false, css_d_block, css_ws_normal} },
{ el_ ## itm, name, {false, false, css_d_block, css_ws_inherit} },
#define XS_TAG1T(itm) \
{ el_ ## itm, #itm, {true, false, css_d_block, css_ws_normal} },
{ el_ ## itm, #itm, {true, false, css_d_block, css_ws_inherit} },
#define XS_TAG1OBJ(itm) \
{ el_ ## itm, #itm, {false, true, css_d_inline, css_ws_normal} },
{ el_ ## itm, #itm, {false, true, css_d_inline, css_ws_inherit} },
#define XS_TAG2T(itm, name) \
{ el_ ## itm, name, {true, false, css_d_block, css_ws_normal} },
{ el_ ## itm, name, {true, false, css_d_block, css_ws_inherit} },
#define XS_TAG1I(itm) \
{ el_ ## itm, #itm, {true, false, css_d_inline, css_ws_normal} },
{ el_ ## itm, #itm, {true, false, css_d_inline, css_ws_inherit} },
#define XS_TAG2I(itm, name) \
{ el_ ## itm, name, {true, false, css_d_inline, css_ws_normal} },
{ el_ ## itm, name, {true, false, css_d_inline, css_ws_inherit} },
#define XS_TAG1D(itm, txt, disp, ws) \
{ el_ ## itm, #itm, {txt, false, disp, ws} },
#define XS_TAG2D(itm, name, txt, false, disp, ws) \
{ el_ ## itm, name, {txt, false, disp, ws} },
#define XS_END_TAGS \
{ 0, NULL, {false, false, css_d_block, css_ws_normal} } \
{ 0, NULL, {false, false, css_d_block, css_ws_inherit} } \
};

#undef XS_BEGIN_ATTRS
Expand Down
40 changes: 20 additions & 20 deletions crengine/include/fb2def.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ XS_TAG1I( inlineBox )
// - it doesn't have a text node child, the content will be fetched from
// its style->content when rendering and drawing text.
// It does not box anything and has no child, so it's not considered a boxing node.
XS_TAG1D( pseudoElem, false, css_d_none, css_ws_normal )
XS_TAG1D( pseudoElem, false, css_d_none, css_ws_inherit )

// Internal element for EPUB, containing each individual HTML file
XS_TAG1( DocFragment )
Expand All @@ -59,10 +59,10 @@ XS_TAG2( xml_stylesheet, "?xml-stylesheet" )
// Classic HTML / EPUB elements
XS_TAG1( html )
XS_TAG1( head )
XS_TAG1D( title, true, css_d_block, css_ws_normal )
XS_TAG1D( style, true, css_d_none, css_ws_normal )
XS_TAG1D( script, true, css_d_none, css_ws_normal )
XS_TAG1D( base, false, css_d_none, css_ws_normal ) // among crengine autoclose elements
XS_TAG1D( title, true, css_d_block, css_ws_inherit )
XS_TAG1D( style, true, css_d_none, css_ws_inherit )
XS_TAG1D( script, true, css_d_none, css_ws_inherit )
XS_TAG1D( base, false, css_d_none, css_ws_inherit ) // among crengine autoclose elements
XS_TAG1T( body )
XS_TAG1( param ) /* quite obsolete, child of <object>... was there, let's keep it */

Expand Down Expand Up @@ -123,16 +123,16 @@ XS_TAG1T( dt )
XS_TAG1T( dd )

// Tables
XS_TAG1D( table, false, css_d_table, css_ws_normal )
XS_TAG1D( caption, true, css_d_table_caption, css_ws_normal )
XS_TAG1D( col, false, css_d_table_column, css_ws_normal )
XS_TAG1D( colgroup, false, css_d_table_column_group, css_ws_normal )
XS_TAG1D( tr, false, css_d_table_row, css_ws_normal )
XS_TAG1D( tbody, false, css_d_table_row_group, css_ws_normal )
XS_TAG1D( thead, false, css_d_table_header_group, css_ws_normal )
XS_TAG1D( tfoot, false, css_d_table_footer_group, css_ws_normal )
XS_TAG1D( th, true, css_d_table_cell, css_ws_normal )
XS_TAG1D( td, true, css_d_table_cell, css_ws_normal )
XS_TAG1D( table, false, css_d_table, css_ws_inherit )
XS_TAG1D( caption, true, css_d_table_caption, css_ws_inherit )
XS_TAG1D( col, false, css_d_table_column, css_ws_inherit )
XS_TAG1D( colgroup, false, css_d_table_column_group, css_ws_inherit )
XS_TAG1D( tr, false, css_d_table_row, css_ws_inherit )
XS_TAG1D( tbody, false, css_d_table_row_group, css_ws_inherit )
XS_TAG1D( thead, false, css_d_table_header_group, css_ws_inherit )
XS_TAG1D( tfoot, false, css_d_table_footer_group, css_ws_inherit )
XS_TAG1D( th, true, css_d_table_cell, css_ws_inherit )
XS_TAG1D( td, true, css_d_table_cell, css_ws_inherit )

// Inline elements
XS_TAG1OBJ( img ) /* inline and specific handling as 'object' */
Expand Down Expand Up @@ -168,7 +168,7 @@ XS_TAG1I( u )
XS_TAG1I( var )

// Ruby elements (defaults to inline)
XS_TAG1D( ruby, true, css_d_ruby, css_ws_normal )
XS_TAG1D( ruby, true, css_d_ruby, css_ws_inherit )
XS_TAG1I( rbc ) // no more in HTML5, but in 2001's https://www.w3.org/TR/ruby/
XS_TAG1I( rtc )
XS_TAG1I( rb )
Expand All @@ -189,10 +189,10 @@ XS_TAG1( epigraph )
XS_TAG1( part )
XS_TAG1( poem )
XS_TAG1( stanza )
XS_TAG1D( binary, true, css_d_none, css_ws_normal )
XS_TAG1D( description, false, css_d_none, css_ws_normal )
XS_TAG1D( genre, true, css_d_none, css_ws_normal )
XS_TAG1D( stylesheet, true, css_d_none, css_ws_normal )
XS_TAG1D( binary, true, css_d_none, css_ws_inherit )
XS_TAG1D( description, false, css_d_none, css_ws_inherit )
XS_TAG1D( genre, true, css_d_none, css_ws_inherit )
XS_TAG1D( stylesheet, true, css_d_none, css_ws_inherit )
XS_TAG1I( spacing )
XS_TAG1I( strikethrough )
XS_TAG1I( underline )
Expand Down
26 changes: 17 additions & 9 deletions crengine/include/hyphman.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ class HyphDictionary
public:
HyphDictionary( HyphDictType type, lString16 title, lString16 id, lString16 filename )
: _type(type), _title(title), _id( id ), _filename( filename ) { }
HyphDictType getType() { return _type; }
lString16 getTitle() { return _title; }
lString16 getId() { return _id; }
lString16 getFilename() { return _filename; }
HyphDictType getType() const { return _type; }
lString16 getTitle() const { return _title; }
lString16 getId() const { return _id; }
lString16 getFilename() const { return _filename; }
bool activate();
virtual lUInt32 getHash() { return getTitle().getHash(); }
virtual lUInt32 getHash() const { return getTitle().getHash(); }
virtual ~HyphDictionary() { }
};

Expand All @@ -98,7 +98,7 @@ class HyphDictionaryList
HyphDictionary * get( int index ) { return (index>=0 && index<+_list.length()) ? _list[index] : NULL; }
HyphDictionaryList() { addDefault(); }
bool open(lString16 hyphDirectory, bool clear = true);
HyphDictionary * find( lString16 id );
HyphDictionary * find( const lString16& id );
bool activate( lString16 id );
};

Expand All @@ -109,12 +109,18 @@ class HyphDictionaryList
// the document if the book does not contain any language tag, and
// we end up going with it anyway.

class HyphDictionary;
class HyphDictionaryList;
class TexHyph;
class AlgoHyph;
class SoftHyphensHyph;

class HyphDataLoader
{
public:
HyphDataLoader() {}
virtual ~HyphDataLoader() {}
virtual LVStreamRef loadData(lString16 id) = 0;
};

/// hyphenation manager
class HyphMan
{
Expand All @@ -127,15 +133,17 @@ class HyphMan
// static HyphDictionary * _selectedDictionary;
static HyphDictionaryList * _dictList; // available hyph dict files (+ none/algo/softhyphens)
static LVHashTable<lString16, HyphMethod*> _loaded_hyph_methods; // methods with loaded dictionaries
static HyphDataLoader* _dataLoader;
static int _LeftHyphenMin;
static int _RightHyphenMin;
static int _TrustSoftHyphens;
public:
static void uninit();
static bool initDictionaries(lString16 dir, bool clear = true);
static HyphDictionaryList * getDictList() { return _dictList; }
static bool addDictionaryItem(HyphDictionary* dict);
static void setDataLoader(HyphDataLoader* loader);
static bool activateDictionary( lString16 id ) { return _dictList->activate(id); }
static bool activateDictionaryFromStream( LVStreamRef stream ); // used by CoolReader on Android
static HyphDictionary * getSelectedDictionary(); // was: { return _selectedDictionary; }
static int getLeftHyphenMin() { return _LeftHyphenMin; }
static int getRightHyphenMin() { return _RightHyphenMin; }
Expand Down
35 changes: 18 additions & 17 deletions crengine/include/lvstyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,19 @@ enum css_style_rec_important_bit {
imp_bit_border_color_left = 1ULL << 45,
imp_bit_background_image = 1ULL << 46,
imp_bit_background_repeat = 1ULL << 47,
imp_bit_background_attachment = 1ULL << 48,
imp_bit_background_position = 1ULL << 49,
imp_bit_border_collapse = 1ULL << 50,
imp_bit_border_spacing_h = 1ULL << 51,
imp_bit_border_spacing_v = 1ULL << 52,
imp_bit_orphans = 1ULL << 53,
imp_bit_widows = 1ULL << 54,
imp_bit_float = 1ULL << 55,
imp_bit_clear = 1ULL << 56,
imp_bit_direction = 1ULL << 57,
imp_bit_content = 1ULL << 58,
imp_bit_cr_hint = 1ULL << 59
imp_bit_background_position = 1ULL << 48,
imp_bit_background_size_h = 1ULL << 49,
imp_bit_background_size_v = 1ULL << 50,
imp_bit_border_collapse = 1ULL << 51,
imp_bit_border_spacing_h = 1ULL << 52,
imp_bit_border_spacing_v = 1ULL << 53,
imp_bit_orphans = 1ULL << 54,
imp_bit_widows = 1ULL << 55,
imp_bit_float = 1ULL << 56,
imp_bit_clear = 1ULL << 57,
imp_bit_direction = 1ULL << 58,
imp_bit_content = 1ULL << 59,
imp_bit_cr_hint = 1ULL << 60
};

// Style handling flags
Expand All @@ -101,8 +102,8 @@ struct css_style_rec_tag {
int refCount; // for reference counting
lUInt32 hash; // cache calculated hash value here
lUInt64 important; // bitmap for !important (used only by LVCssDeclaration)
// we have currently below 60 css properties
// lvstsheet knows about 82, which are mapped to these 60
// we have currently below 61 css properties
// lvstsheet knows about 83, which are mapped to these 61
// update bits above if you add new properties below
lUInt64 importance; // bitmap for important bit's importance/origin
// (allows for 2 level of !important importance)
Expand Down Expand Up @@ -142,8 +143,8 @@ struct css_style_rec_tag {
css_length_t border_color[4]; ///< border-top-color, -right-, -bottom-, -left-
lString8 background_image;
css_background_repeat_value_t background_repeat;
css_background_attachment_value_t background_attachment;
css_background_position_value_t background_position;
css_length_t background_size[2];//first width and second height
css_border_collapse_value_t border_collapse;
css_length_t border_spacing[2];//first horizontal and the second vertical spacing
css_orphans_widows_value_t orphans;
Expand Down Expand Up @@ -194,7 +195,6 @@ struct css_style_rec_tag {
, border_style_right(css_border_none)
, border_style_left(css_border_none)
, background_repeat(css_background_r_none)
, background_attachment(css_background_a_none)
, background_position(css_background_p_none)
, border_collapse(css_border_seperate)
, orphans(css_orphans_widows_inherit)
Expand All @@ -215,6 +215,8 @@ struct css_style_rec_tag {
border_width[1] = css_length_t(css_val_unspecified, 0);
border_width[2] = css_length_t(css_val_unspecified, 0);
border_width[3] = css_length_t(css_val_unspecified, 0);
background_size[0] = css_length_t(css_val_unspecified, 0);
background_size[1] = css_length_t(css_val_unspecified, 0);
}
void AddRef() { refCount++; }
int Release() { return --refCount; }
Expand Down Expand Up @@ -278,7 +280,6 @@ enum lvdom_element_render_method
erm_block, ///< render as block element (render as containing other elements)
erm_final, ///< final element: render the whole it's content as single render block
erm_inline, ///< inline element
erm_runin, ///< run-in (used as a solution to inline FB2 footnotes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a Norse mythological bird named something like Runin — I can't quite think of the name right now. I didn't immediately realize it said run-in. :-)

Copy link
Member

@NiLuJe NiLuJe Jul 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muninn, (one of) Odin's raven (Memory, IIRC).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erm_table, ///< table element: render as table
erm_table_row_group, ///< table row group
erm_table_header_group, ///< table header group
Expand Down
2 changes: 1 addition & 1 deletion crengine/include/lvtextfm.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern "C" {
// (Don't waste the 4th bit not used in the 4-bits sets above)
#define LTEXT_FLAG_OWNTEXT 0x0008 // store local copy of text instead of pointer
#define LTEXT_IS_LINK 0x0080 // source text is a link (to gather in-page footnotes)
#define LTEXT_RUNIN_FLAG 0x8000 // element display mode is runin (used with FB2 footnotes)
#define LTEXT__AVAILABLE_BIT_16__ 0x8000

// Text white-space and hyphenation handling
#define LTEXT_FLAG_PREFORMATTED 0x00010000 // text is preformatted (white-space: pre, pre-wrap, break-spaces)
Expand Down
Loading