Bug 127662 - All links get underlined while hovering over just one link on http://www.sport1.de
Summary: All links get underlined while hovering over just one link on http://www.spor...
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:
: 137244 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-19 16:11 UTC by Michael Seiwert
Modified: 2006-11-12 17:34 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch (3.42 KB, patch)
2006-10-20 14:16 UTC, Allan Sandfeld
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Seiwert 2006-05-19 16:11:58 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc version 3.3.5 20050117 (prerelease) (SUSE Linux)
 
OS:                Linux

It seems that every link on www.sport1.de gets underlined while hovering over just one link. With Firefox and IE the page is shown correctly. Please fix this site, as it is the most popular sports site in germany. :-)

Very best regards

Michael
Comment 1 Thiago Macieira 2006-05-24 01:41:51 UTC
I can confirm this problem.
Comment 2 Ivor Hewitt 2006-05-25 09:54:54 UTC
The problem is being caused by the floating <a name="oben"/> tag at the start of the body.
This is not getting closed until after the three page layout divs hits the first real <a> tag, making the entire page into one big link.

Simplified test case to follow.

Firefox appears to be inserting a closing </a> automagically after the scripts and before the first <div>. Anyone have any idea why or what their logic is behind that?
Comment 3 Allan Sandfeld 2006-10-20 14:08:25 UTC
Okay. This bug is related to residual styles.

Basically if we have the structure:

<a><div>Text <a>link</a></div>

it gets rewritten to:

<a></a><div><a>Text </a><a>link</a></div>
(That is the unclosed anchor gets closed when it encounters an deeper anchor)

But the residual styles cannot handle multiple levels, so

<a><div><div>Text <a>link</a></div></div>

Results in an open anchor, where it would gets closed in Firefox.
Comment 4 Allan Sandfeld 2006-10-20 14:16:55 UTC
Created attachment 18203 [details]
Patch

Simple patch that tries do deal with multilevel residual element, by at least
making sure we close the residual style.
Comment 5 Michael Seiwert 2006-10-21 10:48:44 UTC
Works like a charm Allan, great work! Will you include it in 3_5_BRANCH?
Comment 6 Allan Sandfeld 2006-10-26 21:16:42 UTC
SVN commit 599348 by carewolf:

Instead of giving up, atleast _close_ the residual style if it gets too
complicated.
Fixes sport1.de ;)
BUG: 127662
CCMAIL:coolo@kde.org


 M  +15 -8     htmlparser.cpp  


--- branches/KDE/3.5/kdelibs/khtml/html/htmlparser.cpp #599347:599348
@@ -1308,18 +1308,21 @@
 
 void KHTMLParser::handleResidualStyleCloseTagAcrossBlocks(HTMLStackElem* elem)
 {
-    // Find the element that crosses over to a higher level.   For now, if there is more than
-    // one, we will just give up and not attempt any sort of correction.  It's highly unlikely that
-    // there will be more than one, since <p> tags aren't allowed to be nested.
+    // Find the element that crosses over to a higher level.
+    // ### For now, if there is more than one, we will only make sure we close the residual style.
     int exceptionCode = 0;
     HTMLStackElem* curr = blockStack;
     HTMLStackElem* maxElem = 0;
+    HTMLStackElem* endElem = 0;
     HTMLStackElem* prev = 0;
     HTMLStackElem* prevMaxElem = 0;
+    bool advancedResidual = false; // ### if set we only close the residual style
     while (curr && curr != elem) {
         if (curr->level > elem->level) {
-            if (maxElem)
-                return;
+            if (!isAffectedByResidualStyle(curr->id)) return;
+            if (maxElem) advancedResidual = true;
+            else
+                endElem = curr;
             maxElem = curr;
             prevMaxElem = prev;
         }
@@ -1328,7 +1331,7 @@
         curr = curr->next;
     }
 
-    if (!curr || !maxElem || !isAffectedByResidualStyle(maxElem->id)) return;
+    if (!curr || !maxElem ) return;
 
     NodeImpl* residualElem = prev->node;
     NodeImpl* blockElem = prevMaxElem ? prevMaxElem->node : current;
@@ -1341,7 +1344,7 @@
     if (!parentElem->childAllowed(blockElem))
         return;
 
-    if (maxElem->node->parentNode() != elem->node) {
+    if (maxElem->node->parentNode() != elem->node && !advancedResidual) {
         // Walk the stack and remove any elements that aren't residual style tags.  These
         // are basically just being closed up.  Example:
         // <font><span>Moo<p>Goo</font></p>.
@@ -1375,6 +1378,8 @@
             if (isResidualStyleTag(currElem->node->id())) {
                 // Create a clone of this element.
                 currNode = currElem->node->cloneNode(false);
+                currElem->node->close();
+                removeForbidden(currElem->id, forbiddenTag);
 
                 // Change the stack element's node to point to the clone.
                 currElem->setNode(currNode);
@@ -1407,6 +1412,7 @@
     SharedPtr<NodeImpl> guard(blockElem);
     blockElem->parentNode()->removeChild(blockElem, exceptionCode);
 
+    if (!advancedResidual) {
     // Step 2: Clone |residualElem|.
     NodeImpl* newNode = residualElem->cloneNode(false); // Shallow clone. We don't pick up the same kids.
 
@@ -1433,6 +1439,7 @@
     // Step 4: Place |newNode| under |blockElem|.  |blockElem| is still out of the document, so no
     // attachment can occur yet.
     blockElem->appendChild(newNode, exceptionCode);
+    }
 
     // Step 5: Reparent |blockElem|.  Now the full attachment of the fixed up tree takes place.
     parentElem->appendChild(blockElem, exceptionCode);
@@ -1454,7 +1461,7 @@
     // In the above example, Goo should stay italic.
     curr = blockStack;
     HTMLStackElem* residualStyleStack = 0;
-    while (curr && curr != maxElem) {
+    while (curr && curr != endElem) {
         // We will actually schedule this tag for reopening
         // after we complete the close of this entire block.
         NodeImpl* currNode = current;
Comment 7 Stephan Kulow 2006-10-27 09:27:01 UTC
thx!
Comment 8 Allan Sandfeld 2006-11-12 17:34:22 UTC
*** Bug 137244 has been marked as a duplicate of this bug. ***