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

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

            Bug ID: 24107
           Summary: Bug in the HTML outline algorithm
           Product: WHATWG
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HTML
          Assignee: ian@hixie.ch
          Reporter: faulkner.steve@gmail.com
        QA Contact: contributor@whatwg.org
                CC: marc.hoyois@gmail.com, mike@w3.org,
                    public-html-admin@w3.org,
                    public-html-wg-issue-tracking@w3.org
        Depends on: 24097

+++ This bug was initially created as a clone of Bug #24097 +++

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 Monday, 16 December 2013 07:54:27 UTC