Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleanup the interface of FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=128481

Reviewed by Andreas Kling.

Source/WebCore:

Removed FrameSelection::end() as intended in r163232, and the stale declaration of
paintDragCaret() which was supposed to be removed when we extracted DragCaretController.

Renamed caretRenderer() to caretRendererWithoutUpdatingLayout() to clarify the contract
as the only caller of this function is RenderBlock::paintCaret. Also renamed bounds()
to selectionBounds() to make it more easily identifiable / grep'able.

In addition, made recomputeCaretRect() and invalidateCaretRect() private.

* WebCore.exp.in:
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::caretRendererWithoutUpdatingLayout):
(WebCore::FrameSelection::selectionBounds):
(WebCore::FrameSelection::revealSelection):
* editing/FrameSelection.h:
(WebCore::FrameSelection::setCaretVisible):
* page/DragController.cpp:
(WebCore::dragLocForSelectionDrag):
* page/FrameSnapshotting.cpp:
(WebCore::snapshotSelection):
* page/win/FrameWin.cpp:
(WebCore::imageFromSelection):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintCaret):
* testing/Internals.cpp:
(WebCore::Internals::selectionBounds):

Source/WebKit/efl:

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
(DumpRenderTreeSupportEfl::selectionRectangle):

Source/WebKit/gtk:

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::rectangleForSelection):

Source/WebKit/mac:

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

Source/WebKit/win:

* WebView.cpp:
(WebView::selectionRect):

Source/WebKit2:

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::getFindIndicatorBitmapAndRect):
(WebKit::FindController::drawRect):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::scaledSnapshotWithOptions):


Canonical link: https://commits.webkit.org/146507@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Feb 9, 2014
1 parent 0d52722 commit 72760cb
Show file tree
Hide file tree
Showing 21 changed files with 112 additions and 27 deletions.
34 changes: 34 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,37 @@
2014-02-08 Ryosuke Niwa <rniwa@webkit.org>

Cleanup the interface of FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=128481

Reviewed by Andreas Kling.

Removed FrameSelection::end() as intended in r163232, and the stale declaration of
paintDragCaret() which was supposed to be removed when we extracted DragCaretController.

Renamed caretRenderer() to caretRendererWithoutUpdatingLayout() to clarify the contract
as the only caller of this function is RenderBlock::paintCaret. Also renamed bounds()
to selectionBounds() to make it more easily identifiable / grep'able.

In addition, made recomputeCaretRect() and invalidateCaretRect() private.

* WebCore.exp.in:
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::caretRendererWithoutUpdatingLayout):
(WebCore::FrameSelection::selectionBounds):
(WebCore::FrameSelection::revealSelection):
* editing/FrameSelection.h:
(WebCore::FrameSelection::setCaretVisible):
* page/DragController.cpp:
(WebCore::dragLocForSelectionDrag):
* page/FrameSnapshotting.cpp:
(WebCore::snapshotSelection):
* page/win/FrameWin.cpp:
(WebCore::imageFromSelection):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintCaret):
* testing/Internals.cpp:
(WebCore::Internals::selectionBounds):

2014-02-08 Dan Bernstein <mitz@apple.com>

Reverted part of r163734, because the assertion it enabled still fails when running
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/WebCore.exp.in
Expand Up @@ -1555,10 +1555,10 @@ __ZNK7WebCore14DocumentLoader9isLoadingEv
__ZNK7WebCore14DocumentMarker11descriptionEv
__ZNK7WebCore14FrameSelection11currentFormEv
__ZNK7WebCore14FrameSelection15copyTypingStyleEv
__ZNK7WebCore14FrameSelection15selectionBoundsEb
__ZNK7WebCore14FrameSelection18isFocusedAndActiveEv
__ZNK7WebCore14FrameSelection31getClippedVisibleTextRectanglesERN3WTF6VectorINS_9FloatRectELm0ENS1_15CrashOnOverflowEEE
__ZNK7WebCore14FrameSelection36rootEditableElementOrDocumentElementEv
__ZNK7WebCore14FrameSelection6boundsEb
__ZNK7WebCore14InsertionPoint8isActiveEv
__ZNK7WebCore14RenderListItem10markerTextEv
__ZNK7WebCore14ResourceBuffer4dataEv
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/editing/FrameSelection.cpp
Expand Up @@ -1344,7 +1344,7 @@ bool CaretBase::updateCaretRect(Document* document, const VisiblePosition& caret
return true;
}

RenderObject* FrameSelection::caretRenderer() const
RenderObject* FrameSelection::caretRendererWithoutUpdatingLayout() const
{
return WebCore::caretRenderer(m_selection.start().deprecatedNode());
}
Expand Down Expand Up @@ -1977,7 +1977,7 @@ bool FrameSelection::shouldDeleteSelection(const VisibleSelection& selection) co
return m_frame->editor().client()->shouldDeleteRange(selection.toNormalizedRange().get());
}

FloatRect FrameSelection::bounds(bool clipToVisibleContent) const
FloatRect FrameSelection::selectionBounds(bool clipToVisibleContent) const
{
if (!m_frame->document())
return LayoutRect();
Expand Down Expand Up @@ -2065,7 +2065,7 @@ void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt
rect = absoluteCaretBounds();
break;
case VisibleSelection::RangeSelection:
rect = revealExtentOption == RevealExtent ? VisiblePosition(m_selection.extent()).absoluteCaretBounds() : enclosingIntRect(bounds(false));
rect = revealExtentOption == RevealExtent ? VisiblePosition(m_selection.extent()).absoluteCaretBounds() : enclosingIntRect(selectionBounds(false));
break;
}

Expand Down
12 changes: 4 additions & 8 deletions Source/WebCore/editing/FrameSelection.h
Expand Up @@ -165,10 +165,8 @@ class FrameSelection : private CaretBase {
void setExtent(const VisiblePosition&, EUserTriggered = NotUserTriggered);
void setExtent(const Position&, EAffinity, EUserTriggered = NotUserTriggered);

Position end() const { return m_selection.end(); }

// Return the renderer that is responsible for painting the caret (in the selection start node)
RenderObject* caretRenderer() const;
RenderObject* caretRendererWithoutUpdatingLayout() const;

// Caret rect local to the caret's renderer
LayoutRect localCaretRect();
Expand All @@ -193,8 +191,6 @@ class FrameSelection : private CaretBase {
void textWasReplaced(CharacterData*, unsigned offset, unsigned oldLength, unsigned newLength);

void setCaretVisible(bool caretIsVisible) { setCaretVisibility(caretIsVisible ? Visible : Hidden); }
bool recomputeCaretRect();
void invalidateCaretRect();
void paintCaret(GraphicsContext*, const LayoutPoint&, const LayoutRect& clipRect);

// Used to suspend caret blinking while the mouse is down.
Expand Down Expand Up @@ -257,14 +253,12 @@ class FrameSelection : private CaretBase {
enum EndPointsAdjustmentMode { AdjustEndpointsAtBidiBoundary, DoNotAdjsutEndpoints };
void setSelectionByMouseIfDifferent(const VisibleSelection&, TextGranularity, EndPointsAdjustmentMode = DoNotAdjsutEndpoints);

void paintDragCaret(GraphicsContext*, const LayoutPoint&, const LayoutRect& clipRect) const;

EditingStyle* typingStyle() const;
PassRefPtr<MutableStyleProperties> copyTypingStyle() const;
void setTypingStyle(PassRefPtr<EditingStyle>);
void clearTypingStyle();

FloatRect bounds(bool clipToVisibleContent = true) const;
FloatRect selectionBounds(bool clipToVisibleContent = true) const;

void getClippedVisibleTextRectangles(Vector<FloatRect>&) const;

Expand Down Expand Up @@ -317,6 +311,8 @@ class FrameSelection : private CaretBase {
void caretBlinkTimerFired(Timer<FrameSelection>&);

void setCaretVisibility(CaretVisibility);
bool recomputeCaretRect();
void invalidateCaretRect();

bool dispatchSelectStart();

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/DragController.cpp
Expand Up @@ -697,7 +697,7 @@ static IntPoint dragLocForDHTMLDrag(const IntPoint& mouseDraggedPoint, const Int

static IntPoint dragLocForSelectionDrag(Frame& src)
{
IntRect draggingRect = enclosingIntRect(src.selection().bounds());
IntRect draggingRect = enclosingIntRect(src.selection().selectionBounds());
int xpos = draggingRect.maxX();
xpos = draggingRect.x() < xpos ? draggingRect.x() : xpos;
int ypos = draggingRect.maxY();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/FrameSnapshotting.cpp
Expand Up @@ -105,7 +105,7 @@ std::unique_ptr<ImageBuffer> snapshotSelection(Frame& frame, SnapshotOptions opt
return nullptr;

options |= SnapshotOptionsPaintSelectionOnly;
return snapshotFrameRect(frame, enclosingIntRect(frame.selection().bounds()), options);
return snapshotFrameRect(frame, enclosingIntRect(frame.selection().selectionBounds()), options);
}

std::unique_ptr<ImageBuffer> snapshotNode(Frame& frame, Node& node)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/win/FrameWin.cpp
Expand Up @@ -50,7 +50,7 @@ GDIObject<HBITMAP> imageFromSelection(Frame* frame, bool forceBlackText)
frame->document()->updateLayout();

frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0));
FloatRect fr = frame->selection().bounds();
FloatRect fr = frame->selection().selectionBounds();
IntRect ir(static_cast<int>(fr.x()), static_cast<int>(fr.y()), static_cast<int>(fr.width()), static_cast<int>(fr.height()));
GDIObject<HBITMAP> image = imageFromRect(frame, ir);
frame->view()->setPaintBehavior(PaintBehaviorNormal);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderBlock.cpp
Expand Up @@ -2277,7 +2277,7 @@ void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffse
RenderObject* caretPainter;
bool isContentEditable;
if (type == CursorCaret) {
caretPainter = frame().selection().caretRenderer();
caretPainter = frame().selection().caretRendererWithoutUpdatingLayout();
isContentEditable = frame().selection().selection().hasEditableStyle();
} else {
caretPainter = frame().page()->dragCaretController().caretRenderer();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/testing/Internals.cpp
Expand Up @@ -2135,7 +2135,7 @@ PassRefPtr<ClientRect> Internals::selectionBounds(ExceptionCode& ec)
return ClientRect::create();
}

return ClientRect::create(document->frame()->selection().bounds());
return ClientRect::create(document->frame()->selection().selectionBounds());
}

#if ENABLE(VIBRATION)
Expand Down
Expand Up @@ -198,7 +198,7 @@ EXPORTS
symbolWithPointer(?absoluteCaretBounds@FrameSelection@WebCore@@QAE?AVIntRect@2@XZ, ?absoluteCaretBounds@FrameSelection@WebCore@@QEAA?AVIntRect@2@XZ)
symbolWithPointer(?afterPseudoElement@Element@WebCore@@QBEPAVPseudoElement@2@XZ, ?afterPseudoElement@Element@WebCore@@QEBAPEAVPseudoElement@2@XZ)
symbolWithPointer(?beforePseudoElement@Element@WebCore@@QBEPAVPseudoElement@2@XZ, ?beforePseudoElement@Element@WebCore@@QEBAPEAVPseudoElement@2@XZ)
symbolWithPointer(?bounds@FrameSelection@WebCore@@QBE?AVFloatRect@2@_N@Z, ?bounds@FrameSelection@WebCore@@QEBA?AVFloatRect@2@_N@Z)
symbolWithPointer(?selectionBounds@FrameSelection@WebCore@@QBE?AVFloatRect@2@_N@Z, ?bounds@FrameSelection@WebCore@@QEBA?AVFloatRect@2@_N@Z)
symbolWithPointer(?fromUTF8@String@WTF@@SA?AV12@PBE@Z, ?fromUTF8@String@WTF@@SA?AV12@PEBE_K@Z)
symbolWithPointer(?fromUTF8WithLatin1Fallback@String@WTF@@SA?AV12@PBEI@Z, ?fromUTF8WithLatin1Fallback@String@WTF@@SA?AV12@PEBE_K@Z)
symbolWithPointer(?garbageCollectDocumentResources@CachedResourceLoader@WebCore@@QAEXXZ, ?garbageCollectDocumentResources@CachedResourceLoader@WebCore@@QEAAXXZ)
Expand Down
10 changes: 10 additions & 0 deletions Source/WebKit/efl/ChangeLog
@@ -1,3 +1,13 @@
2014-02-08 Ryosuke Niwa <rniwa@webkit.org>

Cleanup the interface of FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=128481

Reviewed by Andreas Kling.

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
(DumpRenderTreeSupportEfl::selectionRectangle):

2014-02-08 Darin Adler <darin@apple.com>

Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
Expand Down
Expand Up @@ -199,7 +199,7 @@ WebCore::IntRect DumpRenderTreeSupportEfl::selectionRectangle(const Evas_Object*
{
DRT_SUPPORT_FRAME_GET_OR_RETURN(ewkFrame, frame, WebCore::IntRect());

return enclosingIntRect(frame->selection().bounds());
return enclosingIntRect(frame->selection().selectionBounds());
}

// Compare with "WebKit/Tools/DumpRenderTree/mac/FrameLoadDelegate.mm
Expand Down
10 changes: 10 additions & 0 deletions Source/WebKit/gtk/ChangeLog
@@ -1,3 +1,13 @@
2014-02-08 Ryosuke Niwa <rniwa@webkit.org>

Cleanup the interface of FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=128481

Reviewed by Andreas Kling.

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::rectangleForSelection):

2014-02-08 Darin Adler <darin@apple.com>

Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
Expand Down
Expand Up @@ -500,7 +500,7 @@ void DumpRenderTreeSupportGtk::rectangleForSelection(WebKitWebFrame* frame, cair
if (!coreFrame)
return;

IntRect bounds = enclosingIntRect(coreFrame->selection().bounds());
IntRect bounds = enclosingIntRect(coreFrame->selection().selectionBounds());
rectangle->x = bounds.x();
rectangle->y = bounds.y();
rectangle->width = bounds.width();
Expand Down
12 changes: 12 additions & 0 deletions Source/WebKit/mac/ChangeLog
@@ -1,3 +1,15 @@
2014-02-08 Ryosuke Niwa <rniwa@webkit.org>

Cleanup the interface of FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=128481

Reviewed by Andreas Kling.

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

2014-02-08 Dan Bernstein <mitz@apple.com>

Remove use of PLATFORM(MAC) from WebKit/mac
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/mac/WebView/WebHTMLView.mm
Expand Up @@ -5682,7 +5682,7 @@ - (void)_lookUpInDictionaryFromMenu:(id)sender
if (!coreFrame)
return;

NSRect rect = coreFrame->selection().bounds();
NSRect rect = coreFrame->selection().selectionBounds();

NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0,1)];
NSFont *font = [attributes objectForKey:NSFontAttributeName];
Expand Down Expand Up @@ -6528,7 +6528,7 @@ - (NSRect)selectionRect
{
if (![self _hasSelection])
return NSZeroRect;
return core([self _frame])->selection().bounds();
return core([self _frame])->selection().selectionBounds();
}

- (NSArray *)selectionTextRects
Expand Down Expand Up @@ -6579,7 +6579,7 @@ - (NSRect)selectionImageRect
{
if (![self _hasSelection])
return NSZeroRect;
return core([self _frame])->selection().bounds();
return core([self _frame])->selection().selectionBounds();
}

#if !PLATFORM(IOS)
Expand Down
10 changes: 10 additions & 0 deletions Source/WebKit/win/ChangeLog
@@ -1,3 +1,13 @@
2014-02-08 Ryosuke Niwa <rniwa@webkit.org>

Cleanup the interface of FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=128481

Reviewed by Andreas Kling.

* WebView.cpp:
(WebView::selectionRect):

2014-02-08 Darin Adler <darin@apple.com>

Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/win/WebView.cpp
Expand Up @@ -3605,7 +3605,7 @@ HRESULT STDMETHODCALLTYPE WebView::selectionRect(RECT* rc)
{
WebCore::Frame& frame = m_page->focusController().focusedOrMainFrame();

IntRect ir = enclosingIntRect(frame.selection().bounds());
IntRect ir = enclosingIntRect(frame.selection().selectionBounds());
ir = frame.view()->convertToContainingWindow(ir);
ir.move(-frame.view()->scrollOffset().width(), -frame.view()->scrollOffset().height());
rc->left = ir.x();
Expand Down
13 changes: 13 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,16 @@
2014-02-08 Ryosuke Niwa <rniwa@webkit.org>

Cleanup the interface of FrameSelection
https://bugs.webkit.org/show_bug.cgi?id=128481

Reviewed by Andreas Kling.

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::getFindIndicatorBitmapAndRect):
(WebKit::FindController::drawRect):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::scaledSnapshotWithOptions):

2014-02-08 Brady Eidson <beidson@apple.com>

IDB: storage/indexeddb/mozilla/cursors.html fails
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit2/WebProcess/WebPage/FindController.cpp
Expand Up @@ -201,7 +201,7 @@ void FindController::findStringMatches(const String& string, FindOptions options

bool FindController::getFindIndicatorBitmapAndRect(Frame* frame, ShareableBitmap::Handle& handle, IntRect& selectionRect)
{
selectionRect = enclosingIntRect(frame->selection().bounds());
selectionRect = enclosingIntRect(frame->selection().selectionBounds());

// Selection rect can be empty for matches that are currently obscured from view.
if (selectionRect.isEmpty())
Expand Down Expand Up @@ -427,7 +427,7 @@ void FindController::drawRect(PageOverlay* /*pageOverlay*/, GraphicsContext& gra
return;

if (Frame* selectedFrame = frameWithSelection(m_webPage->corePage())) {
IntRect findIndicatorRect = selectedFrame->view()->contentsToWindow(enclosingIntRect(selectedFrame->selection().bounds()));
IntRect findIndicatorRect = selectedFrame->view()->contentsToWindow(enclosingIntRect(selectedFrame->selection().selectionBounds()));

if (findIndicatorRect != m_findIndicatorRect)
hideFindIndicator();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Expand Up @@ -1524,7 +1524,7 @@ PassRefPtr<WebImage> WebPage::scaledSnapshotWithOptions(const IntRect& rect, dou
frameView->paintContentsForSnapshot(graphicsContext.get(), rect, shouldPaintSelection, coordinateSpace);

if (options & SnapshotOptionsPaintSelectionRectangle) {
FloatRect selectionRectangle = m_mainFrame->coreFrame()->selection().bounds();
FloatRect selectionRectangle = m_mainFrame->coreFrame()->selection().selectionBounds();
graphicsContext->setStrokeColor(Color(0xFF, 0, 0), ColorSpaceDeviceRGB);
graphicsContext->strokeRect(selectionRectangle, 1);
}
Expand Down

0 comments on commit 72760cb

Please sign in to comment.