Title: [119065] trunk
Revision
119065
Author
[email protected]
Date
2012-05-31 00:12:48 -0700 (Thu, 31 May 2012)

Log Message

text-decoration should not be propagated through absolutely positioned elements to <a> tags
https://bugs.webkit.org/show_bug.cgi?id=86517

Source/WebCore:

Patch by Shane Stephens <[email protected]> on 2012-05-31
Reviewed by Darin Adler.

Test: fast/css/text-decoration-in-second-order-descendants.html

* rendering/RenderObject.cpp:
(WebCore::RenderObject::getTextDecorationColors):
Remove fix from 18611 as it doesn't work on second order descendants.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustRenderStyle):
Add floating and positioned checks when deciding whether to avoid propagating text decoration. Move all checks into new method to improve readability.
(WebCore::doesNotInheritTextDecoration): Added

LayoutTests:

Added layout test to check no propagation of text-decoration to second-order descendants
(i.e. descendants of descendants), where the first-order descendant is positioned.

Tightened up existing descendants test to fail when text-decoration is incorrectly propagated
to first-order descendant.

Patch by Shane Stephens <[email protected]> on 2012-05-31
Reviewed by Darin Adler.

* fast/css/text-decoration-in-descendants-expected.html:
* fast/css/text-decoration-in-second-order-descendants-expected.html: Added.
* fast/css/text-decoration-in-second-order-descendants.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119064 => 119065)


--- trunk/LayoutTests/ChangeLog	2012-05-31 06:58:10 UTC (rev 119064)
+++ trunk/LayoutTests/ChangeLog	2012-05-31 07:12:48 UTC (rev 119065)
@@ -1,3 +1,20 @@
+2012-05-31  Shane Stephens  <[email protected]>
+
+        text-decoration should not be propagated through absolutely positioned elements to <a> tags
+        https://bugs.webkit.org/show_bug.cgi?id=86517
+
+        Added layout test to check no propagation of text-decoration to second-order descendants 
+        (i.e. descendants of descendants), where the first-order descendant is positioned.
+
+        Tightened up existing descendants test to fail when text-decoration is incorrectly propagated
+        to first-order descendant.
+
+        Reviewed by Darin Adler. 
+
+        * fast/css/text-decoration-in-descendants-expected.html:
+        * fast/css/text-decoration-in-second-order-descendants-expected.html: Added.
+        * fast/css/text-decoration-in-second-order-descendants.html: Added.
+
 2012-05-30  Abhishek Arya  <[email protected]>
 
         Crash in ContainerNode::parserAddChild.

Modified: trunk/LayoutTests/fast/css/text-decoration-in-descendants-expected.html (119064 => 119065)


--- trunk/LayoutTests/fast/css/text-decoration-in-descendants-expected.html	2012-05-31 06:58:10 UTC (rev 119064)
+++ trunk/LayoutTests/fast/css/text-decoration-in-descendants-expected.html	2012-05-31 07:12:48 UTC (rev 119065)
@@ -1,7 +1,7 @@
 <html>
 <head>
 <style>
-.parent { text-decoration: underline; position: relative; }
+.parent { position: relative; }
 .static { position: static; }
 .relative { position: relative; }
 .float { float: right; }

Added: trunk/LayoutTests/fast/css/text-decoration-in-second-order-descendants-expected.html (0 => 119065)


--- trunk/LayoutTests/fast/css/text-decoration-in-second-order-descendants-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/text-decoration-in-second-order-descendants-expected.html	2012-05-31 07:12:48 UTC (rev 119065)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<div style="position: absolute; top: 50px;">
+  This text should not inherit text-decoration from its parent, and should therefore not be underlined. 
+  <p>
+  <a href="" style="text-decoration: none;">As the child of an absolutely positioned block, this link should not be underlined</a>
+</div>
+<a href="" the child of a statically positioned block, this link should be underlined</a>

Added: trunk/LayoutTests/fast/css/text-decoration-in-second-order-descendants.html (0 => 119065)


--- trunk/LayoutTests/fast/css/text-decoration-in-second-order-descendants.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/text-decoration-in-second-order-descendants.html	2012-05-31 07:12:48 UTC (rev 119065)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<style>
+.outer {
+    text-decoration: underline;
+}
+.middle {
+    position: absolute;
+    top: 50px;
+}
+.inner {
+    text-decoration: none;
+}
+
+.override {
+    position: static;
+}
+</style>
+<div class="outer">
+  <div class="middle">
+    This text should not inherit text-decoration from its parent, and should therefore not be underlined. 
+    <p>
+    <a href="" class="inner">As the child of an absolutely positioned block, this link should not be underlined</a>
+  </div>
+</div>
+<div class="outer">
+  <div class="middle override">
+    <a href="" class="inner">As the child of a statically positioned block, this link should be underlined</a>
+  </div>
+</div>

Modified: trunk/Source/WebCore/ChangeLog (119064 => 119065)


--- trunk/Source/WebCore/ChangeLog	2012-05-31 06:58:10 UTC (rev 119064)
+++ trunk/Source/WebCore/ChangeLog	2012-05-31 07:12:48 UTC (rev 119065)
@@ -1,3 +1,21 @@
+2012-05-31  Shane Stephens  <[email protected]>
+
+        text-decoration should not be propagated through absolutely positioned elements to <a> tags
+        https://bugs.webkit.org/show_bug.cgi?id=86517
+
+        Reviewed by Darin Adler.
+
+        Test: fast/css/text-decoration-in-second-order-descendants.html
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::getTextDecorationColors):
+        Remove fix from 18611 as it doesn't work on second order descendants.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::adjustRenderStyle):
+        Add floating and positioned checks when deciding whether to avoid propagating text decoration. Move all checks into new method to improve readability.
+        (WebCore::doesNotInheritTextDecoration): Added
+
 2012-05-30  Yoshifumi Inoue  <[email protected]>
 
         Build fix for Linon/SnowLeopard after r119062

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (119064 => 119065)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-05-31 06:58:10 UTC (rev 119064)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-05-31 07:12:48 UTC (rev 119065)
@@ -1960,6 +1960,16 @@
     return BLOCK;
 }
 
+// CSS requires text-decoration to be reset at each DOM element for tables, 
+// inline blocks, inline tables, run-ins, shadow DOM crossings, floating elements,
+// and absolute or relatively positioned elements.
+static bool doesNotInheritTextDecoration(RenderStyle* style, Element* e)
+{
+    return style->display() == TABLE || style->display() == INLINE_TABLE || style->display() == RUN_IN
+        || style->display() == INLINE_BLOCK || style->display() == INLINE_BOX || isAtShadowBoundary(e)
+        || style->isFloating() || style->isPositioned();
+}
+
 void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e)
 {
     // Cache our original display.
@@ -2072,10 +2082,7 @@
         style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->overflowY());
     }
 
-    // Finally update our text decorations in effect, but don't allow text-decoration to percolate through
-    // tables, inline blocks, inline tables, run-ins, or shadow DOM.
-    if (style->display() == TABLE || style->display() == INLINE_TABLE || style->display() == RUN_IN
-        || style->display() == INLINE_BLOCK || style->display() == INLINE_BOX || isAtShadowBoundary(e))
+    if (doesNotInheritTextDecoration(style, e))
         style->setTextDecorationsInEffect(style->textDecoration());
     else
         style->addToTextDecorationsInEffect(style->textDecoration());

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (119064 => 119065)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2012-05-31 06:58:10 UTC (rev 119064)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2012-05-31 07:12:48 UTC (rev 119065)
@@ -2646,7 +2646,7 @@
                 linethrough = decorationColor(styleToUse);
             }
         }
-        if (curr->isFloating() || curr->isPositioned() || curr->isRubyText())
+        if (curr->isRubyText())
             return;
         curr = curr->parent();
         if (curr && curr->isAnonymousBlock() && toRenderBlock(curr)->continuation())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to