Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: Source/core/editing/FrameSelection.cpp

Issue 640023002: The selection bounds should be clipped to the viewport (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaseline a test. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index d9373f79f9e469e434f73a6a7c88aa4069a7f0fe..e926915f5b7dda89c0a78697375a17edb1f7c485 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -1715,7 +1715,16 @@ String FrameSelection::selectedTextForClipboard() const
return selectedText();
}
-FloatRect FrameSelection::bounds() const
+LayoutRect FrameSelection::bounds() const
+{
+ FrameView* view = m_frame->view();
+ if (!view)
+ return LayoutRect();
+
+ return intersection(unclippedBounds(), view->visibleContentRect());
+}
+
+LayoutRect FrameSelection::unclippedBounds() const
{
m_frame->document()->updateRenderTreeIfNeeded();
@@ -1723,10 +1732,9 @@ FloatRect FrameSelection::bounds() const
RenderView* renderView = m_frame->contentRenderer();
if (!view || !renderView)
- return FloatRect();
+ return LayoutRect();
- LayoutRect selectionRect = renderView->selectionBounds();
- return selectionRect;
+ return renderView->selectionBounds();
}
static inline HTMLFormElement* associatedFormElement(HTMLElement& element)
@@ -1787,7 +1795,7 @@ void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt
rect = absoluteCaretBounds();
break;
case RangeSelection:
- rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).absoluteCaretBounds() : enclosingIntRect(bounds());
+ rect = revealExtentOption == RevealExtent ? VisiblePosition(extent()).absoluteCaretBounds() : enclosingIntRect(unclippedBounds());
break;
}
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698