empty blocks vs. zero-length runs


Subject: empty blocks vs. zero-length runs
From: Paul Rohr (paul@abisource.com)
Date: Mon Jun 05 2000 - 13:45:18 CDT


Jesper,

Thanks for all the work you've been doing to deal with screw cases in the
hit-testing code. We've been seeing occasional brittleness there forever,
it seems, so it'll be very nice to resolve those problems once and for all.

Since you're currently wading through all that code, I'd like to check on a
suggestion which has been floating around the back of my brain for quite a
while to see what you think. (Ditto for Eric, the original author of much
of this code.)

Could we prevent all this trouble by guaranteeing that *no* level of the
layout hierarchy is ever totally empty?

It seems like the main reason we run into trouble is that various physical
layout units (pages, columns, blocks, lines, runs) can sometimes be totally
empty. Thus, any attempt to hit-test at that level will fail. I forget why
we ever introduced the concept of zero-width runs, but it feels hackish.

A modest proposal
-----------------
I believe that if we guarantee the following invariants:

  A. every paragraph has a single non-zero-length (NZL) run, and
  B. all forced breaks have a corresponding NZL run,

then we can in turn guarantee that all higher-order layout units will be
non-empty. (I haven't attempted to prove this, but I'd be surprised if
anyone could come up with a counter-example.)

Given the work already done for the show paragraphs POW, I'll assert that
invariant B is probably already taken care of, so we just need to focus on
invariant A:

  http://www.abisource.com/mailinglists/abiword-dev/99/December/0315.html

The one hard part of that POW which still hasn't been tackled is the notion
of *always* maintaining a special non-zero-width run at the end of every
paragraph. This run would be the width of that funky P character, which
would only draw when in show paragraphs mode (otherwise, it'd just draw like
a blank character).

Adding support for this special run would have the following three benefits:

1. Even "empty" paragraphs always have one NZL run, satisfying invariant A.

2. This should be the last step required so that the Show Paragraphs
feature Just Works.

3. We can simplify the selection logic around paragraph boundaries so that
it Just Works there as well. (There's currently no good GUI feedback when
you want to just merge two paragraphs without deleting any of the nearby
content.)

bottom line
-----------
Of the three benefits listed above, #2 is the most immediately
user-apparent, but I suspect that benefits #1 and #3 are even more important.

Paul



This archive was generated by hypermail 2b25 : Mon Jun 05 2000 - 13:39:41 CDT