Bug 20976 - [WebCore] [test case] Residual styles
Summary: [WebCore] [test case] Residual styles
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml parsing (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 31535 32852 59454 59749 75481 86414 97713 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-02-27 13:48 UTC by Kalle Kivimaa
Modified: 2005-10-09 20:55 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
test case (51 bytes, text/html)
2004-01-22 23:23 UTC, Dominic Chambers
Details
Quick patch (14.96 KB, patch)
2005-03-21 17:45 UTC, Allan Sandfeld
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kalle Kivimaa 2001-02-27 12:58:16 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           khtml
Version:           KDE 2.1.0 CVS/CVSup/Snapshot
Severity:          wishlist
Installed from:    Compiled sources
Compiler:          gcc version 2.95.2 19991024 (release)
OS:                Linux
OS/Compiler notes: Not Specified

Various tags do not close if the order of opening and closing differs (eg. <b><u><font>something</b></u></font> does not close any of the three tags).

As an example see http://www.cs.hut.fi/Opinnot/Tik-76.011/op01KT3.htm with both Konqueror and Netscape.  I know this is not valid HTML but it would be nice to have it renered right.



(Submitted via bugs.kde.org)
(Called from KBugReport dialog. Fields Application KDE Version OS Compiler E-Mail manually changed)
Comment 1 Kai Lahmann 2003-06-22 02:10:33 UTC
*** Bug 31535 has been marked as a duplicate of this bug. ***
Comment 2 Kai Lahmann 2003-06-22 02:14:39 UTC
*** Bug 32852 has been marked as a duplicate of this bug. ***
Comment 3 Alain Knaff 2004-01-21 23:50:54 UTC
In KDE 3.1.95, we get the opposite behavior of bug 31535 (marked as duplicate of this one). Rather than implicitly closing the bold tag at <p>, now the text stays bold until the end, despite the presence of a </b> tag.

In the following example, the whole text shows up as bold, even the 222 after the closing tag. It's as if after a paragraph, all closing tags corresponding to tags opened before get ignored.

<b>test<p>
ing</b> 222

...

Tests with <p> </p> pairs show that it does work if paragraph is closed. However, even nowadays, many pages still use <p> as a single tag (not closing),
and it might be useful to make khtml take such usage into account, rather than rejecting the </b> because of the "unbalanced" <p> tag. With <br>, for instance, it works as expected.
Comment 4 Stephan Kulow 2004-01-22 13:21:01 UTC
because <br> is no block element
Comment 5 Dominic Chambers 2004-01-22 23:23:35 UTC
Created attachment 4304 [details]
test case

Here is a test case for this problem, which I can confirm is still ocurring as
of KDE 3.1.4:

  my <b><u><font color="red">foo</b></u></font> bar 

The problem is that the </b> and </u> are ignored because <font> is the last
opened tag; only </font> is honoured.

Instead, </b> should only be ignored if there is no <b> currently open, but
should be closed, and should cause automatic closure of <u> and <font> since
<b> *is* open, and since these tags appear after it. Later, </u> and </font>
would then be ignored since there would be no such tags open, due to the
automatic closure that occured previously.
Comment 6 Alain Knaff 2004-01-23 07:50:53 UTC
>because <br> is no block element

Would it be possible to have <p> treated as a "non-block" element too for the purpose of tag closing? Or as an optional block element (which may have, or may not have a closing </p>). Indeed unfortunately that is the way how many Web authors (unfortunately) use it for... (seen especially often in slashdot or similar discussion board comments: guy quotes a multiparagraph text, and puts a single <em> </em> pair around his group of unproperly closed paragraphs ===> the whole thing comment now shows up in italics, rather than only the quoted part!)

Comment 7 Leo Savernik 2004-05-09 23:51:57 UTC
To handle improper nesting of tags "properly" (i. e. the way mozilla or opera do it), we'd have to add support for residual styles. This is *not* trivial. Therefore, don't expect this bug to be solved soon.
Comment 8 Leo Savernik 2004-08-22 20:45:47 UTC
Support for residual styles has already be implemented by Apple. I attempted to merge back the changes, but hit troubles with some combinations of elements. I haven't been able to solve those yet.
Comment 9 Allan Sandfeld 2005-03-09 11:53:02 UTC
*** Bug 97713 has been marked as a duplicate of this bug. ***
Comment 10 Christopher B. Wright 2005-03-14 17:21:28 UTC
This bug is not restricted to situations where tags are placed out of order.

The following web page:

http://ubersoft.net/template.html

Uses cascading stylesheets for all of its formatting, and all text on that page is displayed in bold text in Konqueror... except for italicized text, which is displayed normally.

Comment 11 Allan Sandfeld 2005-03-21 17:45:07 UTC
Created attachment 10239 [details]
Quick patch

Here is a quick port of the WebCore code. It seems to work just fine. 

Leo, what problems did you encounter?
Comment 12 Allan Sandfeld 2005-03-22 12:18:08 UTC
*** Bug 59454 has been marked as a duplicate of this bug. ***
Comment 13 Allan Sandfeld 2005-03-22 12:20:14 UTC
*** Bug 86414 has been marked as a duplicate of this bug. ***
Comment 14 Allan Sandfeld 2005-03-22 12:21:27 UTC
*** Bug 75481 has been marked as a duplicate of this bug. ***
Comment 15 Allan Sandfeld 2005-03-22 12:22:53 UTC
*** Bug 59749 has been marked as a duplicate of this bug. ***
Comment 16 Germain Garand 2005-03-22 14:39:49 UTC
the regression ouput looks all fine indeed...
I was concerned that the DOM manipulation could lead to crashes in the like of #99480, but so far it resisted all my worst attempts.

Go ahead?
Comment 17 Allan Sandfeld 2005-03-30 13:53:57 UTC
CVS commit by carewolf: 

Merge WebCore handling of residual styles, which improves our handling of 
various broken HTML.
BUG: 20976


  M +4 -0      ChangeLog   1.414
  M +303 -7    html/htmlparser.cpp   1.357
  M +7 -1      html/htmlparser.h   1.67
Comment 18 Alain Knaff 2005-10-09 20:55:25 UTC
Works fine in 3.4.91 beta1