LayoutTests:
authorantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2007 13:42:11 +0000 (13:42 +0000)
committerantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2007 13:42:11 +0000 (13:42 +0000)
        Reviewed by Maciej.

        Test for REGRESSION: misplaced selection ring remains after link is no longer focused.
        <rdar://problem/5205580>

        * fast/repaint/focus-layers-expected.checksum: Added.
        * fast/repaint/focus-layers-expected.png: Added.
        * fast/repaint/focus-layers-expected.txt: Added.
        * fast/repaint/focus-layers.html: Added.

WebCore:

        Reviewed by Maciej.

        REGRESSION: misplaced selection ring remains after link is no longer focused.
        <rdar://problem/5205580>

        Fix placement of selection ring when part of the ring is in a different layer.

        * rendering/RenderFlow.cpp:
        (WebCore::RenderFlow::addFocusRingRects): Get coordinates right when moving to a different layer.
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::setStyle):
        Don't reset state variables when not necessary.  When repaint() was called at the end of setSyle() it would
        get repaint rects wrong in some cases.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@23944 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/repaint/focus-layers-expected.checksum [new file with mode: 0644]
LayoutTests/fast/repaint/focus-layers-expected.png [new file with mode: 0644]
LayoutTests/fast/repaint/focus-layers-expected.txt [new file with mode: 0644]
LayoutTests/fast/repaint/focus-layers.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderFlow.cpp
WebCore/rendering/RenderObject.cpp

index 2250b427f4f30bced4861ce984bfdb9e7dab61b9..792ee5c17285a6be2cbf9746315f0555c20bbdba 100644 (file)
@@ -1,3 +1,15 @@
+2007-07-03  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Maciej.
+        
+        Test for REGRESSION: misplaced selection ring remains after link is no longer focused.
+        <rdar://problem/5205580>
+
+        * fast/repaint/focus-layers-expected.checksum: Added.
+        * fast/repaint/focus-layers-expected.png: Added.
+        * fast/repaint/focus-layers-expected.txt: Added.
+        * fast/repaint/focus-layers.html: Added.
+
 2007-07-02  Adam Roben  <aroben@apple.com>
 
         Update the Windows Skipped list.
diff --git a/LayoutTests/fast/repaint/focus-layers-expected.checksum b/LayoutTests/fast/repaint/focus-layers-expected.checksum
new file mode 100644 (file)
index 0000000..ea53482
--- /dev/null
@@ -0,0 +1 @@
+7d91c4650b664bb938a6a77525b68797
\ No newline at end of file
diff --git a/LayoutTests/fast/repaint/focus-layers-expected.png b/LayoutTests/fast/repaint/focus-layers-expected.png
new file mode 100644 (file)
index 0000000..2814af3
Binary files /dev/null and b/LayoutTests/fast/repaint/focus-layers-expected.png differ
diff --git a/LayoutTests/fast/repaint/focus-layers-expected.txt b/LayoutTests/fast/repaint/focus-layers-expected.txt
new file mode 100644 (file)
index 0000000..7f953b8
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 35x18
+          text run at (0,0) width 35: "Both "
+        RenderText {#text} at (0,0) size 0x0
+layer at (8,8) size 53x22
+  RenderInline (relative positioned) {A} at (0,0) size 53x22 [color=#0000EE] [border: (2px solid #FF0000)]
+    RenderText {#text} at (37,0) size 49x18
+      text run at (37,0) width 49: "this and"
+layer at (45,168) size 283x22
+  RenderBlock (positioned) {SPAN} at (2,162) size 283x22 [border: (2px solid #0000FF)]
+    RenderText {#text} at (2,2) size 279x18
+      text run at (2,2) width 279: "this should have correctly placed focus rings"
diff --git a/LayoutTests/fast/repaint/focus-layers.html b/LayoutTests/fast/repaint/focus-layers.html
new file mode 100644 (file)
index 0000000..b073cb5
--- /dev/null
@@ -0,0 +1,29 @@
+<html>
+<head>
+<style type="text/css">
+a {
+    border: 2px solid red;
+    position:relative;
+}
+a span{
+    border: 2px solid blue;
+    white-space:nowrap;
+    position:absolute;
+    top:10em;
+    left:0;
+}
+</style>
+
+</head>
+<body>
+<div>
+
+Both <a href="#" id=link>this and<span>this should have correctly placed focus rings</span></a>    
+</div>
+
+<script>
+document.getElementById('link').focus();
+</script>
+</div>
+</body>
+</html>
index 4d6e73dc718fa469c6205e48f435d55af56f9e95..7fa71f069b8fd30376730c75a7418e9d5eb93062 100644 (file)
@@ -1,3 +1,19 @@
+2007-07-03  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Maciej.
+        
+        REGRESSION: misplaced selection ring remains after link is no longer focused.
+        <rdar://problem/5205580>
+        
+        Fix placement of selection ring when part of the ring is in a different layer.
+
+        * rendering/RenderFlow.cpp:
+        (WebCore::RenderFlow::addFocusRingRects): Get coordinates right when moving to a different layer.
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::setStyle): 
+        Don't reset state variables when not necessary.  When repaint() was called at the end of setSyle() it would
+        get repaint rects wrong in some cases.
+
 2007-07-03  Antti Koivisto  <antti@apple.com>
 
         Reviewed by Maciej.
index c920dd0eef7666f70fda7d9099b1a6a2a02290df..12697a1dffb68c16f34c38b03205ff1810a5e729 100644 (file)
@@ -689,8 +689,17 @@ void RenderFlow::addFocusRingRects(GraphicsContext* graphicsContext, int tx, int
             graphicsContext->addFocusRingRect(IntRect(tx + curr->xPos(), ty + curr->yPos(), curr->width(), curr->height()));
 
         for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
-            if (!curr->isText() && !curr->isListMarker())
-                curr->addFocusRingRects(graphicsContext, tx + curr->xPos(), ty + curr->yPos());
+            if (!curr->isText() && !curr->isListMarker()) {
+                int x = 0;
+                int y = 0;
+                if (curr->layer()) 
+                    curr->absolutePosition(x, y);
+                else {
+                    x = tx + curr->xPos();
+                    y = ty + curr->yPos();
+                }
+                curr->addFocusRingRects(graphicsContext, x, y);
+            }
     }
 
     if (continuation()) {
index 1f387e09abc276ee3c07e29ebb6932a21498b43d..9fbb419e1968555b9a3fec653d520dd47c6e861c 100644 (file)
@@ -2274,9 +2274,11 @@ void RenderObject::setStyle(RenderStyle* style)
             && parent() && (parent()->isBlockFlow() || parent()->isInlineFlow());
 
         // reset style flags
-        m_floating = false;
-        m_positioned = false;
-        m_relPositioned = false;
+        if (d == RenderStyle::Layout) {
+            m_floating = false;
+            m_positioned = false;
+            m_relPositioned = false;
+        }
         m_paintBackground = false;
         m_hasOverflowClip = false;
     }