attached patch fixes bug 2998294 and maybe other scroll related bugs.
The patch encapsulates the Anchor class and reworks the event code of "preContentRemoved" and "contentInserted". Also it adds some more comments of the usage of the fields "scrollLine" and "physicalLine" in the Anchor class as FirstLine and ScrollLineCount have very different semantics on these fields.
As a side effect the update of the screen line count per physical line is now done directly instead of the doDelayedUpdate() method.
Please review and test.