Skip to content

Commit 50980e5

Browse files
authored
cre.cpp: tweak getLinkFromPosition() (koreader#2502)
Make the behaviour hardcoded in c0ae49f toggable: Frontend unit tests failed after this change, and it may actually be only helpful for the calls in the coherency check.
1 parent 8e2e48d commit 50980e5

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

cre.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,12 +1951,16 @@ static int getLinkFromPosition(lua_State *L) {
19511951
CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument");
19521952
int x = luaL_checkint(L, 2);
19531953
int y = luaL_checkint(L, 3);
1954+
// Providing forTextSelection=true may give more chances of success to
1955+
// the link coherency checks done by frontend (eg. with negative text
1956+
// indent and the link rect being outside of its paragraph rect).
1957+
bool forTextSelection = false;
1958+
if (lua_isboolean(L, 4)) {
1959+
forTextSelection = lua_toboolean(L, 4);
1960+
}
19541961

19551962
lvPoint pt(x, y);
1956-
// Providing forTextSelection=true gives more chances of success to
1957-
// the link coherenrency checks done by frontend (eg. with negative
1958-
// text indent and the link rect being outside of its paragraph rect).
1959-
ldomXPointer p = doc->text_view->getNodeByPoint(pt, true, true);
1963+
ldomXPointer p = doc->text_view->getNodeByPoint(pt, true, forTextSelection);
19601964
ldomXPointer a_p;
19611965
lString32 href = p.getHRef(a_p);
19621966
lua_pushstring(L, UnicodeToLocal(href).c_str());

0 commit comments

Comments
 (0)