LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2007 00:26:12 +0000 (00:26 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2007 00:26:12 +0000 (00:26 +0000)
        Reviewed by Hyatt.

        Test for <rdar://problem/4100616> Doing a "find" in RSS doesn't scroll to result

        * fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.checksum: Added.
        * fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.png: Added.
        * fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.txt: Added.
        * fast/overflow/scroll-nested-positioned-layer-in-overflow.html: Added.

WebCore:

        Reviewed by Hyatt.

        WebCore part of fix for <rdar://problem/4100616> Doing a "find" in RSS doesn't scroll to result

        Test: fast/overflow/scroll-nested-positioned-layer-in-overflow.html

        Merged visibleSelectionRect into selectionRect.  selectionRect() now takes an argument to determine
        whether or not to return a rect that clips to the visible content.  This change makes all of the implementations of selectionRect
        consistent by having them all consider the repaint rect when clipping to visible content.

        * page/Frame.cpp:
        (WebCore::Frame::revealSelection): Call selectionRect with clipToVisibleContent = false, so we can get a rect that's not visible to reveal.
        (WebCore::Frame::selectionRect): Added clipToVisibleContent argument, and merged visibleSelectionRect into this method.
        (WebCore::Frame::setIsActive): Use selectionRect instead of visibleSelectionRect.
        * page/Frame.h:
        * page/mac/FrameMac.mm: (WebCore::Frame::selectionImage): Update layout before creating the image.  Use selectionRect instead of visibleSelectionRect.
        * page/DragController.cpp: (WebCore::dragLocForSelectionDrag): Use selectionRect instead of visibleSelectionRect.

        * rendering/RenderBR.h: (WebCore::RenderBR::selectionRect): Updated argument.
        * rendering/RenderBlock.h: (WebCore::RenderBlock::selectionRect): ditto.
        * rendering/RenderSVGInlineText.cpp: (WebCore::RenderSVGInlineText::selectionRect): ditto.
        * rendering/RenderSVGInlineText.h: ditto.
        * rendering/RenderObject.h:
        (WebCore::RenderObject::selectionRect): ditto.
        (WebCore::RenderObject::SelectionInfo::SelectionInfo): ditto.
        * rendering/RenderView.cpp:
        (WebCore::RenderView::selectionRect): ditto.
        (WebCore::RenderView::setSelection): ditto.
        * rendering/RenderView.h:

        * rendering/RenderText.h:
        * rendering/RenderText.cpp: (WebCore::RenderText::selectionRect): Only call computeAbsoluteRepaintRect when clipping to visible content.
        Otherwise, just adjust the rect to the correct position.
        * rendering/RenderListMarker.h:
        * rendering/RenderListMarker.cpp: (WebCore::RenderListMarker::selectionRect):
          To match what we do in RenderText, if we're trying to clip to visible content, just call computeAbsoluteRepaintRect.
        * rendering/RenderReplaced.h:
        * rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::selectionRect): ditto.

        * rendering/RenderLayer.cpp: (WebCore::RenderLayer::scrollRectToVisible): Check for a parent layer at the beginning, so we can try to scroll all of our parent layers
          first, before trying to scroll the top level view.  Also, don't try to scroll overflow layers that have -webkit-line-clamp restricting the height.
          This will prevent us from revealing text hidden by the slider in Safari RSS.

        * WebCore.exp: Update symbols for WebKit.

WebKit:

        Reviewed by Hyatt.

        WebKit part of fix for <rdar://problem/4100616> Doing a "find" in RSS doesn't scroll to result

        Updated to use selectionRect instead of visibleSelectionRect.  selectionRect() now returns the visible rect by default.

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _lookUpInDictionaryFromMenu:]):
        (-[WebHTMLView selectionImageRect]):

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

28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.checksum [new file with mode: 0644]
LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.png [new file with mode: 0644]
LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.txt [new file with mode: 0644]
LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/page/DragController.cpp
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/page/mac/FrameMac.mm
WebCore/rendering/RenderBR.h
WebCore/rendering/RenderBlock.h
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderListMarker.cpp
WebCore/rendering/RenderListMarker.h
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderReplaced.cpp
WebCore/rendering/RenderReplaced.h
WebCore/rendering/RenderSVGInlineText.cpp
WebCore/rendering/RenderSVGInlineText.h
WebCore/rendering/RenderText.cpp
WebCore/rendering/RenderText.h
WebCore/rendering/RenderView.cpp
WebCore/rendering/RenderView.h
WebKit/ChangeLog
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView/WebHTMLView.mm

index e915ff81150839fdeedebb3edb3ee51db747e823..0555d069a5b6ee424387cfaeb07a92d0c011b063 100644 (file)
@@ -1,3 +1,14 @@
+2007-05-10  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Hyatt.
+
+        Test for <rdar://problem/4100616> Doing a "find" in RSS doesn't scroll to result
+
+        * fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.checksum: Added.
+        * fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.png: Added.
+        * fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.txt: Added.
+        * fast/overflow/scroll-nested-positioned-layer-in-overflow.html: Added.
+
 2007-05-08  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Oliver.
diff --git a/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.checksum b/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.checksum
new file mode 100644 (file)
index 0000000..16100cd
--- /dev/null
@@ -0,0 +1 @@
+375725727830bd7d3172f7b49a605545
\ No newline at end of file
diff --git a/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.png b/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.png
new file mode 100644 (file)
index 0000000..39fa85d
Binary files /dev/null and b/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.png differ
diff --git a/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.txt b/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow-expected.txt
new file mode 100644 (file)
index 0000000..fc538db
--- /dev/null
@@ -0,0 +1,19 @@
+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
+layer at (0,42) size 800x558 clip at (0,42) size 785x558 scrollY 282 scrollHeight 840
+  RenderBlock (positioned) {DIV} at (0,42) size 800x558
+layer at (0,-240) size 560x840 backgroundClip at (0,42) size 785x558 clip at (0,42) size 785x558 outlineClip at (0,42) size 785x558
+  RenderBlock (positioned) {DIV} at (0,0) size 560x840
+    RenderBlock (anonymous) at (0,0) size 560x18
+      RenderText {#text} at (0,0) size 560x18
+        text run at (0,0) width 560: "This tests that we can scroll to reveal something in a nested positioned block in overflow."
+    RenderBlock {DIV} at (0,18) size 560x800
+    RenderBlock (anonymous) at (0,818) size 560x22
+      RenderButton {INPUT} at (2,2) size 203x18 [bgcolor=#C0C0C0]
+        RenderBlock (anonymous) at (8,2) size 187x13
+          RenderText at (0,0) size 187x13
+            text run at (0,0) width 187: "If you can see this, test has passed"
+      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow.html b/LayoutTests/fast/overflow/scroll-nested-positioned-layer-in-overflow.html
new file mode 100644 (file)
index 0000000..f54abe7
--- /dev/null
@@ -0,0 +1,27 @@
+<html>
+<head>
+    <style>
+        #scroller {
+            position: absolute;
+            top: 42px;
+            bottom: 0px;
+            left: 0px;
+            right: 0px;
+            overflow: overlay;
+        }
+
+        #contentarea {
+            position: absolute;
+        }
+    </style>
+</head>
+<body onload="document.getElementById('bt').focus()">
+    <div id="scroller">
+        <div id="contentarea">
+            This tests that we can scroll to reveal something in a nested positioned block in overflow. 
+            <div style="height: 800px"></div>
+            <input type="button" id="bt" value="If you can see this, test has passed"></input>
+        </div>   
+    </div>
+</body>
+</html>
index d5985176ed61cb6419fbc236dd0fc3140b0afd11..5945bb4584a15fee7d43b79b127aa737b69e33a5 100644 (file)
@@ -1,3 +1,50 @@
+2007-05-10  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Hyatt.
+
+        WebCore part of fix for <rdar://problem/4100616> Doing a "find" in RSS doesn't scroll to result
+
+        Test: fast/overflow/scroll-nested-positioned-layer-in-overflow.html
+
+        Merged visibleSelectionRect into selectionRect.  selectionRect() now takes an argument to determine
+        whether or not to return a rect that clips to the visible content.  This change makes all of the implementations of selectionRect
+        consistent by having them all consider the repaint rect when clipping to visible content.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::revealSelection): Call selectionRect with clipToVisibleContent = false, so we can get a rect that's not visible to reveal.
+        (WebCore::Frame::selectionRect): Added clipToVisibleContent argument, and merged visibleSelectionRect into this method.
+        (WebCore::Frame::setIsActive): Use selectionRect instead of visibleSelectionRect.
+        * page/Frame.h:
+        * page/mac/FrameMac.mm: (WebCore::Frame::selectionImage): Update layout before creating the image.  Use selectionRect instead of visibleSelectionRect.
+        * page/DragController.cpp: (WebCore::dragLocForSelectionDrag): Use selectionRect instead of visibleSelectionRect.
+
+        * rendering/RenderBR.h: (WebCore::RenderBR::selectionRect): Updated argument.
+        * rendering/RenderBlock.h: (WebCore::RenderBlock::selectionRect): ditto.
+        * rendering/RenderSVGInlineText.cpp: (WebCore::RenderSVGInlineText::selectionRect): ditto.
+        * rendering/RenderSVGInlineText.h: ditto.
+        * rendering/RenderObject.h: 
+        (WebCore::RenderObject::selectionRect): ditto.
+        (WebCore::RenderObject::SelectionInfo::SelectionInfo): ditto.
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::selectionRect): ditto.
+        (WebCore::RenderView::setSelection): ditto.
+        * rendering/RenderView.h:
+
+        * rendering/RenderText.h:
+        * rendering/RenderText.cpp: (WebCore::RenderText::selectionRect): Only call computeAbsoluteRepaintRect when clipping to visible content.
+        Otherwise, just adjust the rect to the correct position.
+        * rendering/RenderListMarker.h:
+        * rendering/RenderListMarker.cpp: (WebCore::RenderListMarker::selectionRect):
+          To match what we do in RenderText, if we're trying to clip to visible content, just call computeAbsoluteRepaintRect.
+        * rendering/RenderReplaced.h:
+        * rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::selectionRect): ditto.
+
+        * rendering/RenderLayer.cpp: (WebCore::RenderLayer::scrollRectToVisible): Check for a parent layer at the beginning, so we can try to scroll all of our parent layers 
+          first, before trying to scroll the top level view.  Also, don't try to scroll overflow layers that have -webkit-line-clamp restricting the height.
+          This will prevent us from revealing text hidden by the slider in Safari RSS.
+
+        * WebCore.exp: Update symbols for WebKit.
+
 2007-05-10  David Hyatt  <hyatt@apple.com>
 
         Fix for:
index ef432e2e17df4a8579466f6444e20ac969bfd43b..a092643f44891d43da7652d6749f0b71817cf2b4 100644 (file)
@@ -573,13 +573,12 @@ __ZNK7WebCore4KURL8getNSURLEv
 __ZNK7WebCore5Frame10isFrameSetEv
 __ZNK7WebCore5Frame12eventHandlerEv
 __ZNK7WebCore5Frame12ownerElementEv
-__ZNK7WebCore5Frame13selectionRectEv
+__ZNK7WebCore5Frame13selectionRectEb
 __ZNK7WebCore5Frame14selectionImageEb
 __ZNK7WebCore5Frame15revealSelectionERKNS_11RenderLayer15ScrollAlignmentE
 __ZNK7WebCore5Frame16inViewSourceModeEv
 __ZNK7WebCore5Frame19selectionControllerEv
 __ZNK7WebCore5Frame19setInViewSourceModeEb
-__ZNK7WebCore5Frame20visibleSelectionRectEv
 __ZNK7WebCore5Frame30applyEditingStyleToBodyElementEv
 __ZNK7WebCore5Frame31fontAttributesForSelectionStartEv
 __ZNK7WebCore5Frame33removeEditingStyleFromBodyElementEv
index f4becd323d8ac93babcaa09a32fa143e1b398bb6..4c142b9ec149e1f80c72ecccc4c23bc024d6095e 100644 (file)
@@ -529,7 +529,7 @@ static IntPoint dragLocForDHTMLDrag(const IntPoint& mouseDraggedPoint, const Int
     
 static IntPoint dragLocForSelectionDrag(Frame* src)
 {
-    IntRect draggingRect = enclosingIntRect(src->visibleSelectionRect());
+    IntRect draggingRect = enclosingIntRect(src->selectionRect());
     int xpos = draggingRect.right();
     xpos = draggingRect.x() < xpos ? draggingRect.x() : xpos;
     int ypos = draggingRect.bottom();
index 6820a9ec9554d266cdb320a1f5ede5049d85d897..31e3f7d6cdb9f03f1f1ee7e4cfdc88f3629a8fe5 100644 (file)
@@ -1179,22 +1179,15 @@ RenderPart* Frame::ownerRenderer()
     return static_cast<RenderPart*>(ownerElement->renderer());
 }
 
-IntRect Frame::selectionRect() const
+// returns FloatRect because going through IntRect would truncate any floats
+FloatRect Frame::selectionRect(bool clipToVisibleContent) const
 {
     RenderView *root = static_cast<RenderView*>(renderer());
     if (!root)
         return IntRect();
-
-    return root->selectionRect();
-}
-
-// returns FloatRect because going through IntRect would truncate any floats
-FloatRect Frame::visibleSelectionRect() const
-{
-    if (!d->m_view)
-        return FloatRect();
     
-    return intersection(selectionRect(), d->m_view->visibleContentRect());
+    IntRect selectionRect = root->selectionRect(clipToVisibleContent);
+    return clipToVisibleContent ? intersection(selectionRect, d->m_view->visibleContentRect()) : selectionRect;
 }
 
 bool Frame::isFrameSet() const
@@ -1260,7 +1253,7 @@ void Frame::revealSelection(const RenderLayer::ScrollAlignment& alignment) const
             break;
             
         case Selection::RANGE:
-            rect = selectionRect();
+            rect = enclosingIntRect(selectionRect(false));
             break;
     }
 
@@ -1504,7 +1497,7 @@ void Frame::setIsActive(bool flag)
     // RenderObject::selectionForegroundColor() check if the frame is active,
     // we have to update places those colors were painted.
     if (d->m_view)
-        d->m_view->updateContents(enclosingIntRect(visibleSelectionRect()));
+        d->m_view->updateContents(enclosingIntRect(selectionRect()));
 
     // Caret appears in the active frame.
     if (flag)
index 9f92350e74cb794801503ae59ed1e0b5f1c4ff1e..3c2b39033657f22fb06a1793200513a1b24e3c8b 100644 (file)
@@ -322,8 +322,7 @@ public:
     void setTypingStyle(CSSMutableStyleDeclaration*);
     void clearTypingStyle();
 
-    IntRect selectionRect() const;
-    FloatRect visibleSelectionRect() const;
+    FloatRect selectionRect(bool clipToVisibleContent = true) const;
 
     HTMLFormElement* currentForm() const;
 
index e18d3017f4af631787878c01fa2555a0af612123..8c2609ef320cfc9cd87ecb7f59662c2e5d4fcf72 100644 (file)
@@ -372,7 +372,8 @@ NSImage* Frame::imageFromRect(NSRect rect) const
 NSImage* Frame::selectionImage(bool forceWhiteText) const
 {
     d->m_paintRestriction = forceWhiteText ? PaintRestrictionSelectionOnlyWhiteText : PaintRestrictionSelectionOnly;
-    NSImage* result = imageFromRect(visibleSelectionRect());
+    d->m_doc->updateLayout();
+    NSImage* result = imageFromRect(selectionRect());
     d->m_paintRestriction = PaintRestrictionNone;
     return result;
 }
index 4c63390c95d0b6e6a5da70b0367e894b0366fbc2..658e3bdb2f6f525bbcac83d86035ffddc96eaa9c 100644 (file)
@@ -40,7 +40,7 @@ public:
 
     virtual const char* renderName() const { return "RenderBR"; }
  
-    virtual IntRect selectionRect() { return IntRect(); }
+    virtual IntRect selectionRect(bool) { return IntRect(); }
 
     virtual unsigned width(unsigned /*from*/, unsigned /*len*/, const Font&, int /*xpos*/) const { return 0; }
     virtual unsigned width(unsigned /*from*/, unsigned /*len*/, int /*xpos*/, bool /*firstLine = false*/) const { return 0; }
index 152ef9bdc65ce8a6dab0cf266e68dc12156de4bf..cc3d3ec12dbf32bea53b99ed7f4f1e413d878c97 100644 (file)
@@ -249,7 +249,7 @@ public:
         SelectionState state() const { return m_state; }
     };
 
-    virtual IntRect selectionRect() { return selectionGapRects(); }
+    virtual IntRect selectionRect(bool) { return selectionGapRects(); }
     GapRects selectionGapRects();
     virtual bool shouldPaintSelectionGaps() const;
     bool isSelectionRoot() const;
index 19e9de520f32b1dba473b0deac2d75139a00c8d0..a43a2da5d4ac4355c8c6712139adcd6a9d5452cf 100644 (file)
@@ -707,8 +707,16 @@ void RenderLayer::scrollRectToVisible(const IntRect &rect, const ScrollAlignment
     FrameView* frameView = m_object->document()->view();
     if (frameView)
         frameView->pauseScheduledEvents();
-    
-    if (m_object->hasOverflowClip()) {
+
+    bool restrictedByLineClamp = false;
+    if (m_object->parent()) {
+        parentLayer = m_object->parent()->enclosingLayer();
+        restrictedByLineClamp = m_object->parent()->style()->lineClamp() >= 0;
+    }
+
+    if (m_object->hasOverflowClip() && !restrictedByLineClamp) {
+        // Don't scroll to reveal an overflow layer that is restricted by the -webkit-line-clamp property.
+        // This will prevent us from revealing text hidden by the slider in Safari RSS.
         int x, y;
         m_object->absolutePosition(x, y);
         IntRect layerBounds = IntRect(x + scrollXOffset(), y + scrollYOffset(), 
@@ -731,10 +739,7 @@ void RenderLayer::scrollRectToVisible(const IntRect &rect, const ScrollAlignment
             newRect.setX(rect.x() - diffX);
             newRect.setY(rect.y() - diffY);
         }
-    
-        if (m_object->parent())
-            parentLayer = m_object->parent()->enclosingLayer();
-    } else {
+    } else if (!parentLayer) {
         if (frameView) {
             if (m_object->document() && m_object->document()->ownerElement() && m_object->document()->ownerElement()->renderer()) {
                 IntRect viewRect = enclosingIntRect(frameView->visibleContentRect());
index 200e0c7a898b36edceee113ea2a290b1718e6435..3be496ee618858c225722673e64b5bd55fca589c 100644 (file)
@@ -878,21 +878,28 @@ void RenderListMarker::setSelectionState(SelectionState state)
     containingBlock()->setSelectionState(state);
 }
 
-IntRect RenderListMarker::selectionRect()
+IntRect RenderListMarker::selectionRect(bool clipToVisibleContent)
 {
     ASSERT(!needsLayout());
 
     if (selectionState() == SelectionNone || !inlineBoxWrapper())
         return IntRect();
 
-    int absx, absy;
-    RenderBlock* cb = containingBlock();
-    cb->absolutePosition(absx, absy);
-    if (cb->hasOverflowClip())
-        cb->layer()->subtractScrollOffset(absx, absy);
-
     RootInlineBox* root = inlineBoxWrapper()->root();
-    return IntRect(absx + xPos(), absy + root->selectionTop(), width(), root->selectionHeight());
+    IntRect rect(xPos(), root->selectionTop(), width(), root->selectionHeight());
+            
+    if (clipToVisibleContent)
+        computeAbsoluteRepaintRect(rect);
+    else {
+        int absx, absy;
+        RenderBlock* cb = containingBlock();
+        cb->absolutePosition(absx, absy);
+        if (cb->hasOverflowClip())
+            cb->layer()->subtractScrollOffset(absx, absy);
+        rect.move(absx, absy);
+    }
+    
+    return rect;
 }
 
 } // namespace WebCore
index 670492ec76051f0f17d8fb3aa046712b3081ef97..414ec3153f0049a16fae7a2f5deba9c4114fa02c 100644 (file)
@@ -64,7 +64,7 @@ public:
 
     virtual SelectionState selectionState() const { return m_selectionState; }
     virtual void setSelectionState(SelectionState);
-    virtual IntRect selectionRect();
+    virtual IntRect selectionRect(bool clipToVisibleContent = true);
     virtual bool canBeSelectionLeaf() const { return true; }
 
     void updateMargins();
index 0950ef1c4dc6d1803f16e040ab1a94bbda0ef401..944606f0b21540991760c35cb6c8cfc822e769dc 100644 (file)
@@ -746,7 +746,7 @@ public:
 
     // A single rectangle that encompasses all of the selected objects within this object.  Used to determine the tightest
     // possible bounding box for the selection.
-    virtual IntRect selectionRect() { return IntRect(); }
+    virtual IntRect selectionRect(bool) { return IntRect(); }
 
     // Whether or not an object can be part of the leaf elements of the selection.
     virtual bool canBeSelectionLeaf() const { return false; }
@@ -776,9 +776,9 @@ public:
         {
         }
 
-        SelectionInfo(RenderObject* o)
+        SelectionInfo(RenderObject* o, bool clipToVisibleContent)
             : m_object(o)
-            , m_rect(o->needsLayout() ? IntRect() : o->selectionRect())
+            , m_rect(o->needsLayout() ? IntRect() : o->selectionRect(clipToVisibleContent))
             , m_state(o->selectionState())
         {
         }
index d1207c5730cfe9aad2d4698e9f6b3cd880c6f0a4..97273c22491420ab00b7d0eec133fa0c71a1e3b3 100644 (file)
@@ -152,7 +152,7 @@ VisiblePosition RenderReplaced::positionForCoordinates(int x, int y)
     return RenderBox::positionForCoordinates(x, y);
 }
 
-IntRect RenderReplaced::selectionRect()
+IntRect RenderReplaced::selectionRect(bool clipToVisibleContent)
 {
     ASSERT(!needsLayout());
 
@@ -172,12 +172,19 @@ IntRect RenderReplaced::selectionRect()
     int selectionLeft = xPos();
     int selectionRight = xPos() + width();
     
-    int absx, absy;
-    cb->absolutePositionForContent(absx, absy);
-    if (cb->hasOverflowClip())
-        cb->layer()->subtractScrollOffset(absx, absy);
-
-    return IntRect(selectionLeft + absx, selectionTop + absy, selectionRight - selectionLeft, selectionHeight);
+    IntRect rect(selectionLeft, selectionTop, selectionRight - selectionLeft, selectionHeight);
+    
+    if (clipToVisibleContent)
+        computeAbsoluteRepaintRect(rect);
+    else {
+        int absx, absy;
+        cb->absolutePositionForContent(absx, absy);
+        if (cb->hasOverflowClip())
+            cb->layer()->subtractScrollOffset(absx, absy);
+        rect.move(absx, absy);
+    }
+    
+    return rect;
 }
 
 void RenderReplaced::setSelectionState(SelectionState s)
index b1af1e0ac9f9396a67bbaaf538d7340c3fc27824..bd77122a2ac286c464321c2714826d236c2bceb9 100644 (file)
@@ -50,7 +50,7 @@ public:
     virtual bool canBeSelectionLeaf() const { return true; }
     virtual SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
     virtual void setSelectionState(SelectionState);
-    virtual IntRect selectionRect();
+    virtual IntRect selectionRect(bool clipToVisibleContent = true);
 
     bool isSelected() const;
 
index 6978ce4a5d410cda5becae81c5a77c5f848e3eaa..139c55ca6ef9fb1d3b3cf3dc584430eb82b7c0a2 100644 (file)
@@ -45,9 +45,9 @@ void RenderSVGInlineText::absoluteRects(Vector<IntRect>& rects, int tx, int ty)
     rects.append(enclosingIntRect(absoluteRect));
 }
 
-IntRect RenderSVGInlineText::selectionRect()
+IntRect RenderSVGInlineText::selectionRect(bool clipToVisibleContent)
 {
-    IntRect rect = RenderText::selectionRect();
+    IntRect rect = RenderText::selectionRect(clipToVisibleContent);
     rect = parent()->absoluteTransform().mapRect(rect);
     return rect;
 }
index 0ec2135e0d4a7dc3f02307f6d4ae877bd90db7f4..491df3fce7bbe5609a5330a45cfbb225d75e429a 100644 (file)
@@ -35,7 +35,7 @@ public:
     virtual const char* renderName() const { return "RenderSVGInlineText"; }
     virtual void absoluteRects(Vector<IntRect>& rects, int tx, int ty);
     virtual bool requiresLayer() { return false; }
-    virtual IntRect selectionRect();
+    virtual IntRect selectionRect(bool clipToVisibleContent = true);
     virtual bool isSVGText() const { return true; }
     virtual InlineTextBox* createInlineTextBox();
 };
index 182e4ebda467d4b062d5a1b6af6268062f54b343..a6a92273faae515682ee19e89cb17bef6ae8c73f 100644 (file)
@@ -1026,7 +1026,7 @@ IntRect RenderText::absoluteClippedOverflowRect()
     return cb->absoluteClippedOverflowRect();
 }
 
-IntRect RenderText::selectionRect()
+IntRect RenderText::selectionRect(bool clipToVisibleContent)
 {
     ASSERT(!needsLayout());
 
@@ -1064,12 +1064,21 @@ IntRect RenderText::selectionRect()
     if (cb->hasOverflowClip()) {
         int x = rect.x();
         int y = rect.y();
-        IntRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
         cb->layer()->subtractScrollOffset(x, y);
-        IntRect repaintRect(x, y, rect.width(), rect.height());
-        rect = intersection(repaintRect, boxRect);
+        if (clipToVisibleContent) {
+            IntRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
+            IntRect repaintRect(x, y, rect.width(), rect.height());
+            rect = intersection(repaintRect, boxRect);
+        }
+    }
+
+    if (clipToVisibleContent)
+        cb->computeAbsoluteRepaintRect(rect);
+    else {
+        int absx, absy;
+        cb->absolutePosition(absx, absy);
+        rect.move(absx, absy);
     }
-    cb->computeAbsoluteRepaintRect(rect);
 
     return rect;
 }
index 50c8b943be30a208127b1c709b72c46ed5b80430..8cab1e95d43d21cd0ae83f701b903a7faa46ba8a 100644 (file)
@@ -100,7 +100,7 @@ public:
     virtual bool canBeSelectionLeaf() const { return true; }
     virtual SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
     virtual void setSelectionState(SelectionState s);
-    virtual IntRect selectionRect();
+    virtual IntRect selectionRect(bool clipToVisibleContent = true);
     virtual IntRect caretRect(int offset, EAffinity, int* extraWidthToEndOfLine = 0);
 
     virtual int marginLeft() const { return style()->marginLeft().calcMinValue(0); }
index 56d2919d35e1b63508413ed607fec2e5ffa66e15..9424e09251a570d46dba7ec72b5bd6ff22296405 100644 (file)
@@ -228,7 +228,7 @@ RenderObject* rendererAfterPosition(RenderObject* object, unsigned offset)
     return child ? child : object->nextInPreOrderAfterChildren();
 }
 
-IntRect RenderView::selectionRect() const
+IntRect RenderView::selectionRect(bool clipToVisibleContent) const
 {
     document()->updateRendering();
 
@@ -240,13 +240,13 @@ IntRect RenderView::selectionRect() const
     while (os && os != stop) {
         if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
             // Blocks are responsible for painting line gaps and margin gaps. They must be examined as well.
-            selectedObjects.set(os, new SelectionInfo(os));
+            selectedObjects.set(os, new SelectionInfo(os, clipToVisibleContent));
             RenderBlock* cb = os->containingBlock();
             while (cb && !cb->isRenderView()) {
                 SelectionInfo* blockInfo = selectedObjects.get(cb);
                 if (blockInfo)
                     break;
-                selectedObjects.set(cb, new SelectionInfo(cb));
+                selectedObjects.set(cb, new SelectionInfo(cb, clipToVisibleContent));
                 cb = cb->containingBlock();
             }
         }
@@ -299,7 +299,7 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
     while (os && os != stop) {
         if ((os->canBeSelectionLeaf() || os == m_selectionStart || os == m_selectionEnd) && os->selectionState() != SelectionNone) {
             // Blocks are responsible for painting line gaps and margin gaps.  They must be examined as well.
-            oldSelectedObjects.set(os, new SelectionInfo(os));
+            oldSelectedObjects.set(os, new SelectionInfo(os, false));
             RenderBlock* cb = os->containingBlock();
             while (cb && !cb->isRenderView()) {
                 BlockSelectionInfo* blockInfo = oldSelectedBlocks.get(cb);
@@ -348,7 +348,7 @@ void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* e
     o = start;
     while (o && o != stop) {
         if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionState() != SelectionNone) {
-            newSelectedObjects.set(o, new SelectionInfo(o));
+            newSelectedObjects.set(o, new SelectionInfo(o, false));
             RenderBlock* cb = o->containingBlock();
             while (cb && !cb->isRenderView()) {
                 BlockSelectionInfo* blockInfo = newSelectedBlocks.get(cb);
index c9334a5884f2a882f0936eed954cb7b1a495f752..3a616ca1ef77f2b5b8248b941bcda5b67639d75f 100644 (file)
@@ -74,7 +74,7 @@ public:
 
     virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
 
-    IntRect selectionRect() const;
+    IntRect selectionRect(bool clipToVisibleContent = true) const;
 
     void setMaximalOutlineSize(int o) { m_maximalOutlineSize = o; }
     int maximalOutlineSize() const { return m_maximalOutlineSize; }
index 97e4f22185679f6413912f6023bfbd53b238b608..c12b571e9700cbd1c398a66bce098af397d734a3 100644 (file)
@@ -1,3 +1,15 @@
+2007-05-10  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Hyatt.
+
+        WebKit part of fix for <rdar://problem/4100616> Doing a "find" in RSS doesn't scroll to result
+
+        Updated to use selectionRect instead of visibleSelectionRect.  selectionRect() now returns the visible rect by default.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _lookUpInDictionaryFromMenu:]):
+        (-[WebHTMLView selectionImageRect]):
+
 2007-05-10  dethbakin  <bdakin@apple.com>
 
         Reviewed by Darin.
index f8373861fa609cd457d82dfab482dd3fbece2fa5..7ae0fb0641890267b1f90dcf2a8062f722ec123a 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
                        projectRoot = "";
-                       shouldCheckCompatibility = 1;
                        targets = (
                                9398100A0824BF01008DF038 /* WebKit */,
                        );
index d211923b69b5ee66efa9afff349ce2a422c7d25b..6790a5743834f8532c9ad00a8d28967dd9b8006a 100644 (file)
@@ -5237,7 +5237,7 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
     // FIXME: the dictionary API expects the rect for the first line of selection. Passing
     // the rect for the entire selection, as we do here, positions the pop-up window near
     // the bottom of the selection rather than at the selected word.
-    NSRect rect = [self convertRect:core([self _frame])->visibleSelectionRect() toView:nil];
+    NSRect rect = [self convertRect:core([self _frame])->selectionRect() toView:nil];
     rect.origin = [[self window] convertBaseToScreen:rect.origin];
     NSData *data = [attrString RTFFromRange:NSMakeRange(0, [attrString length]) documentAttributes:nil];
     dictionaryServiceWindowShow(data, rect, (writingDirection == NSWritingDirectionRightToLeft) ? 1 : 0);
@@ -5245,7 +5245,7 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
     // The DictionaryServices API requires the origin, in CG screen coordinates, of the first character of text in the selection.
     // FIXME 4945808: We approximate this in a way that works well when a single word is selected, and less well in some other cases
     // (but no worse than we did in Tiger)
-    NSRect rect = core([self _frame])->visibleSelectionRect();
+    NSRect rect = core([self _frame])->selectionRect();
 
     NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0,1)];
     NSFont *font = [attributes objectForKey:NSFontAttributeName];
@@ -5946,7 +5946,7 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
 - (NSRect)selectionImageRect
 {
     if ([self _hasSelection])
-        return core([self _frame])->visibleSelectionRect();
+        return core([self _frame])->selectionRect();
     return NSZeroRect;
 }