Skip to content

Commit

Permalink
bump crengine: normalized xpointers, complete incomplete tables (#1054)
Browse files Browse the repository at this point in the history
Includes:
- Fix shifted native selection/internal bookmarks in legacy mode
- Fix drawing of inline-block taller than page height
- (Upstream) createXPointer/toString: normalized xpointers
- toStringUsingNames(): rename to toStringV2()
- DOM_VERSION_WITH_NORMALIZED_XPOINTERS 20200223
- CSS/List items: skip boxing elements when walking
- CSS: parse pseudoclass nth_child(3n+2)
- toStringV2(): output [1] when first but not single
- Tables: complete incomplete tables
- Store gDOMVersionRequested in cache file header
- Cache: increase Rects cache size

cre.cpp: adds getDomVersionWithNormalizedXPointers()
and getNormalizedXPointer(xpv1)
  • Loading branch information
poire-z committed Feb 24, 2020
1 parent 8758b21 commit 4913a46
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions cre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ static int getLatestDomVersion(lua_State *L) {
return 1;
}

static int getDomVersionWithNormalizedXPointers(lua_State *L) {
lua_pushnumber(L, DOM_VERSION_WITH_NORMALIZED_XPOINTERS); // defined in lvtinydom.h
return 1;
}

static int requestDomVersion(lua_State *L) {
int version = luaL_checkint(L, 1);
gDOMVersionRequested = version;
Expand Down Expand Up @@ -2643,6 +2648,24 @@ static int highlightXPointer(lua_State *L) {
return 1;
}

static int getNormalizedXPointer(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
const char* xp = luaL_checkstring(L, 2);
ldomXPointer nodep = doc->dom_doc->createXPointer(lString16(xp));
// When gDOMVersionRequested >= DOM_VERSION_WITH_NORMALIZED_XPOINTERS,
// it will use internally createXPointerV2(), otherwise createXPointerV1().

if ( nodep.isNull() ) {
// XPointer not found in document
lua_pushboolean(L, false);
}
else {
// Force the use of toStrinV2() to get a normalized xpointer
lua_pushstring(L, UnicodeToLocal(nodep.toStringV2()).c_str());
}
return 1;
}

static int gotoLink(lua_State *L) {
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
const char *pos = luaL_checkstring(L, 2);
Expand Down Expand Up @@ -2975,6 +2998,7 @@ static const struct luaL_Reg cre_func[] = {
{"getSelectedHyphDict", getSelectedHyphDict},
{"setHyphDictionary", setHyphDictionary},
{"getLatestDomVersion", getLatestDomVersion},
{"getDomVersionWithNormalizedXPointers", getDomVersionWithNormalizedXPointers},
{"requestDomVersion", requestDomVersion},
{NULL, NULL}
};
Expand Down Expand Up @@ -3064,6 +3088,7 @@ static const struct luaL_Reg credocument_meth[] = {
{"getPageLinks", getPageLinks},
{"isLinkToFootnote", isLinkToFootnote},
{"highlightXPointer", highlightXPointer},
{"getNormalizedXPointer", getNormalizedXPointer},
{"getCoverPageImageData", getCoverPageImageData},
{"gotoLink", gotoLink},
{"goBack", goBack},
Expand Down

0 comments on commit 4913a46

Please sign in to comment.