Reviewed by Rob.
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2007 13:08:48 +0000 (13:08 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2007 13:08:48 +0000 (13:08 +0000)
Fix invisible-text-after-scrolling.xhtml regression. Scroll offset not
taken into account properly. Also fix RenderSVGInlineText::selectionRect(),
so that SVG text can be selected, when being embedded in XHTML.

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

LayoutTests/ChangeLog
WebCore/ChangeLog
WebCore/rendering/RenderSVGInlineText.cpp
WebCore/rendering/RenderSVGRoot.cpp

index 467289c3690cb15c3d5a86ade830660f63c384db..ac56c33bf4fb4c04ec050ecca8f65e2590ee5525 100644 (file)
@@ -1,3 +1,12 @@
+2007-07-15  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed by Rob.
+        
+        Land new test result, after scroll offsets are now respected again.
+
+        * svg/custom/invisible-text-after-scrolling-expected.checksum:
+        * svg/custom/invisible-text-after-scrolling-expected.png:
+
 2007-07-15  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Oliver.
index 99892f15eaf90e107fc84082c6d1c4b0a24c6b7a..c737aaa31260780c5cf2470a490a7871e742bd10 100644 (file)
@@ -1,3 +1,16 @@
+2007-07-15  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed by Rob.
+
+        Fix invisible-text-after-scrolling.xhtml regression. Scroll offset not
+        taken into account properly. Also fix RenderSVGInlineText::selectionRect(),
+        so that SVG text can be selected, when being embedded in XHTML.
+
+        * rendering/RenderSVGInlineText.cpp:
+        (WebCore::RenderSVGInlineText::selectionRect):
+        * rendering/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::applyContentTransforms):
+
 2007-07-15  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Oliver.
index 1d4a134c84cc5863a0248124d99dec36a3429705..253d3ca20f1868d1a95bd298bef78e5092c3dd0d 100644 (file)
@@ -59,11 +59,54 @@ void RenderSVGInlineText::absoluteRects(Vector<IntRect>& rects, int, int, bool)
     }
 }
 
-IntRect RenderSVGInlineText::selectionRect(bool clipToVisibleContent)
+IntRect RenderSVGInlineText::selectionRect(bool)
 {
-    IntRect rect = RenderText::selectionRect(clipToVisibleContent);
-    rect = parent()->absoluteTransform().mapRect(rect);
-    return rect;
+    ASSERT(!needsLayout());
+
+    IntRect rect;
+    if (selectionState() == SelectionNone)
+        return rect;
+
+    RenderBlock* cb = containingBlock();
+    if (!cb)
+        return rect;
+
+    // Now calculate startPos and endPos for painting selection.
+    // We include a selection while endPos > 0
+    int startPos, endPos;
+    if (selectionState() == SelectionInside) {
+        // We are fully selected.
+        startPos = 0;
+        endPos = textLength();
+    } else {
+        selectionStartEnd(startPos, endPos);
+        if (selectionState() == SelectionStart)
+            endPos = textLength();
+        else if (selectionState() == SelectionEnd)
+            startPos = 0;
+    }
+
+    if (startPos == endPos)
+        return rect;
+
+    InlineTextBox* firstBox = firstTextBox();
+    SVGRootInlineBox* rootBox = firstBox ? static_cast<SVGInlineTextBox*>(firstBox)->svgRootInlineBox() : 0;
+    RenderObject* object = rootBox ? rootBox->object() : 0;
+
+    if (!object)
+        return rect;
+
+    int xRef = xPos() + object->xPos();
+    int yRef = yPos() + object->yPos();
+
+    for (InlineTextBox* box = firstBox; box; box = box->nextTextBox()) {
+        IntRect origin(box->selectionRect(0, 0, startPos, endPos));
+        origin.setX(xRef - origin.x());
+        origin.setY(yRef - origin.y());
+        rect.unite(origin);
+    }
+
+    return absoluteTransform().mapRect(rect);
 }
 
 InlineTextBox* RenderSVGInlineText::createInlineTextBox()
index 672c253b3fc049d60f180c5aa01516d4dd154c53..b4e45c40bba84dd794892b97567143c858f2cd71 100644 (file)
@@ -127,6 +127,10 @@ void RenderSVGRoot::applyContentTransforms(PaintInfo& paintInfo, int parentX, in
         paintInfo.rect.move(-origin.x(), -origin.y());
     }
 
+    // Respect scroll offset caused by html parents
+    AffineTransform ctm = RenderContainer::absoluteTransform();
+    paintInfo.rect.move(ctm.e(), ctm.f());
+
     SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
     paintInfo.context->concatCTM(AffineTransform().scale(svg->currentScale()));