[Bug 24097] New: Bug in the HTML outline algorithm

https://www.w3.org/Bugs/Public/show_bug.cgi?id=24097

            Bug ID: 24097
           Summary: Bug in the HTML outline algorithm
           Product: HTML WG
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HTML5 spec
          Assignee: dave.null@w3.org
          Reporter: marc.hoyois@gmail.com
        QA Contact: public-html-bugzilla@w3.org
                CC: mike@w3.org, public-html-admin@w3.org,
                    public-html-wg-issue-tracking@w3.org

The determination of the *current section* when exiting a sectioning root is
wrong and can lead to several weird behaviors, including an actual error. Here
are a couple of examples.

## Example 1 (error)

<body>
<h1>A</h1>
<section></section>
<figure></figure>
<h2>B</h2>
</body>

After exiting the sectioning root <figure>, the algorithm sets the current
section to be the *deepest section* in the current outline, which is the
section corresponding to the <section> element. Then, when entering <h2>, it
will compare the rank of <h2> with the rank of the implied heading of that
section, which is undefined.

## Example 2 (no error but nonsensical outline)

<body>
<h1>A</h1>
<section><h1>B</h1></section>
<figure></figure>
<h2>C</h2>
</body>

In this case the algorithm produces the outline

1. A
   1.1. B
      1.1.1. C

If we remove the <figure> element, we get the correct outline:

1. A
   1.1. B
   1.2. C

## Solution

The problem is this: when exiting a sectioning root, the current section should
be set to whichever section was current upon entering the root, but this is not
always the deepest section. The algorithm could ask that the correct section be
remembered, or else that section can be determined as follows (when exiting the
sectioning root):

- let *current section* be the last section of the current outline
- if the last child section of *current section* exists and is an *implicit*
section, then go to the step *finding the deepest child*, otherwise do nothing

## Another bug?

There is a related point which I'm not sure is intended. Consider the document:

<body>
<figure></figure>
<h1>Title</h1>
</body>

The algorithm computes the outline:

1. Untitled document
2. Title

If sectioning roots are supposed to be "invisible" in the outline, then the
outline should simply be

1. Title

If the latter is indeed the intended behavior, then the algorithm should not
create an implied heading when entering a sectioning root.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Saturday, 14 December 2013 19:04:43 UTC