You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CFI returned by getFirstVisibleElementCfi() in cfi_navigation_logic.js is unprecise.
Procedure to reproduce
Open the redium-js-viewer with the embedded book 'accessible epub 3'. Go to chapter 2 and turn a few pages. Launch getFirstVisibleElementCfi()
Actual result
The partial CFI returned is always ""/4/2[building_a_better_epub]/2@0:xx". This targets the first <section> of the chapter, which include the whole text content of the chapter, then add a positionning in % in that chapter.
Expected result
CFI returned should be more precise and return an CFI pointing to an inner <p>inside the <section>, like "/4/2[building_a_better_epub]/10/32/12@0:xx".
Explaination
This is because the first child of the <section> element, which is a blank text node, is reported by both Chrome and Firefox as visible on all columns in a multi-columns layout. When walking the DOM to find the first visible text node, this one is always checked first and always answer "yes".
The code should ignore blank text nodes but this one is not ignored. Probably because it contains tabulations, carriage returns or other characters than space and line feed.
This replace the all code that just strip spaces and line feeds then check that the length is not 0.
Problem
I did not send a PR because when fixing this bug, I trigger a browser bug on Firefox which forbids Firefox from being able to jump to these more precise CFI (the getClientRects() of the targeted element are always totally incoherent).
The text was updated successfully, but these errors were encountered:
edas
changed the title
Unprecise CFI for
Unprecise CFI for getFirstVisibleElementCfi() / cfi_navigation_logic.js
Jul 2, 2014
The CFI returned by getFirstVisibleElementCfi() in cfi_navigation_logic.js is unprecise.
Procedure to reproduce
Open the redium-js-viewer with the embedded book 'accessible epub 3'. Go to chapter 2 and turn a few pages. Launch getFirstVisibleElementCfi()
Actual result
The partial CFI returned is always ""/4/2[building_a_better_epub]/2@0:xx". This targets the first
<section>
of the chapter, which include the whole text content of the chapter, then add a positionning in % in that chapter.Expected result
CFI returned should be more precise and return an CFI pointing to an inner
<p>
inside the<section>
, like "/4/2[building_a_better_epub]/10/32/12@0:xx".Explaination
This is because the first child of the
<section>
element, which is a blank text node, is reported by both Chrome and Firefox as visible on all columns in a multi-columns layout. When walking the DOM to find the first visible text node, this one is always checked first and always answer "yes".The code should ignore blank text nodes but this one is not ignored. Probably because it contains tabulations, carriage returns or other characters than space and line feed.
Fix
In cfi_navigation_logic.js :
This replace the all code that just strip spaces and line feeds then check that the length is not 0.
Problem
I did not send a PR because when fixing this bug, I trigger a browser bug on Firefox which forbids Firefox from being able to jump to these more precise CFI (the getClientRects() of the targeted element are always totally incoherent).
The text was updated successfully, but these errors were encountered: