WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
132200
Add a selection overlay
https://bugs.webkit.org/show_bug.cgi?id=132200
Summary
Add a selection overlay
Brady Eidson
Reported
2014-04-25 11:42:37 PDT
Add a basic (non-functional) selection overlay that tracks the rects for the current selection. <
rdar://problem/16727797
>
Attachments
Patch v1
(31.99 KB, patch)
2014-04-25 12:01 PDT
,
Brady Eidson
no flags
Details
Formatted Diff
Diff
Patch v2
(31.63 KB, patch)
2014-04-25 13:08 PDT
,
Brady Eidson
hyatt
: review-
hyatt
: commit-queue-
Details
Formatted Diff
Diff
Patch v3 with Hyatt's suggestion
(42.49 KB, patch)
2014-04-25 14:17 PDT
,
Brady Eidson
beidson
: review-
beidson
: commit-queue-
Details
Formatted Diff
Diff
Patch v4
(41.98 KB, patch)
2014-04-25 14:23 PDT
,
Brady Eidson
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Brady Eidson
Comment 1
2014-04-25 12:01:54 PDT
Created
attachment 230189
[details]
Patch v1
WebKit Commit Bot
Comment 2
2014-04-25 12:03:25 PDT
Attachment 230189
[details]
did not pass style-queue: ERROR: Source/WebCore/rendering/RenderView.cpp:772: Missing space inside { }. [whitespace/braces] [5] Total errors found: 1 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
Tim Horton
Comment 3
2014-04-25 12:14:45 PDT
Comment on
attachment 230189
[details]
Patch v1 View in context:
https://bugs.webkit.org/attachment.cgi?id=230189&action=review
> Source/WebCore/rendering/RenderView.cpp:776 > + m_view->view().frame().editor().client()->selectionRectsDidChange(m_view->m_currentSelectionRects);
What if client is null?
> Source/WebCore/rendering/RenderView.cpp:779 > + RenderView* m_view;
reference
> Source/WebKit2/WebProcess/WebPage/SelectionOverlayController.cpp:81 > + m_selectionOverlay = 0;
nullptr. And, remind me why you don't hold a reference to your overlay?
> Source/WebKit2/WebProcess/WebPage/SelectionOverlayController.h:34 > +#if PLATFORM(MAC)
don't think there's any reason for this (or any of the other PLATFORM(MAC)s. Isn't ENABLE(SERVICE_CONTROLS) already pretty PLATFORM(MAC) specific?
> Source/WebKit2/WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm:76 > + // FIXME: We need to do the following, but SOFT_LINK isn't working for this method. > +// if (m_mouseIsOverHighlight && onButton && m_mouseDownPosition != IntPoint()) > +// DDHighlightSetButtonPressed(m_currentHighlight.get(), true);
get rid of this for now? at least put the // in the right place
> Source/WebKit2/WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm:151 > + // DDHighlightSetButtonPressed(m_currentHighlight.get(), true);
:|
> Source/WebKit2/WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm:170 > + m_mouseDownPosition = IntPoint();
that is a valid mouse position. what makes 0,0 special? is there any reason to do this? should you be setting a bool regarding its validity instead?
Brady Eidson
Comment 4
2014-04-25 12:51:18 PDT
(In reply to
comment #3
)
> (From update of
attachment 230189
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=230189&action=review
> > > Source/WebCore/rendering/RenderView.cpp:776 > > + m_view->view().frame().editor().client()->selectionRectsDidChange(m_view->m_currentSelectionRects); > > What if client is null?
There's some spots in the project where EditorClient is null checked, and some where it's not. Appears to be about 50/50. What a mess. I'll null check just for giggles.
> > Source/WebCore/rendering/RenderView.cpp:779 > > + RenderView* m_view; > > reference
Sure.
> > Source/WebKit2/WebProcess/WebPage/SelectionOverlayController.cpp:81 > > + m_selectionOverlay = 0; > > nullptr. And, remind me why you don't hold a reference to your overlay?
Find, WebInspector, and Telephone number overlays are also raw pointers. Not sure why the first of those didn't hold a ref, but none of the clients truly own their overlays.
> > > Source/WebKit2/WebProcess/WebPage/SelectionOverlayController.h:34 > > +#if PLATFORM(MAC) > > don't think there's any reason for this (or any of the other PLATFORM(MAC)s. Isn't ENABLE(SERVICE_CONTROLS) already pretty PLATFORM(MAC) specific?
I removed some of them, but not all of them.
> > Source/WebKit2/WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm:76 > > + // FIXME: We need to do the following, but SOFT_LINK isn't working for this method. > > +// if (m_mouseIsOverHighlight && onButton && m_mouseDownPosition != IntPoint()) > > +// DDHighlightSetButtonPressed(m_currentHighlight.get(), true); > > get rid of this for now? at least put the // in the right place
I'll put the // in the right place. If the comment and code is completely removed, it's *much* more likely to be forgotten even in the short term.
> > Source/WebKit2/WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm:170 > > + m_mouseDownPosition = IntPoint(); > > that is a valid mouse position. what makes 0,0 special? is there any reason to do this? should you be setting a bool regarding its validity instead?
You didn't catch this in the telephone number version! :) There's definitely a reason to track the mouse down position. I'll add a bool.
Brady Eidson
Comment 5
2014-04-25 12:54:38 PDT
(In reply to
comment #4
)
> > > Source/WebKit2/WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm:170 > > > + m_mouseDownPosition = IntPoint(); > > > > that is a valid mouse position. what makes 0,0 special? is there any reason to do this? should you be setting a bool regarding its validity instead? > > You didn't catch this in the telephone number version! :) > > There's definitely a reason to track the mouse down position. I'll add a bool.
Actually, just the bool is good enough. sweet.
Brady Eidson
Comment 6
2014-04-25 13:08:01 PDT
Created
attachment 230194
[details]
Patch v2
Dave Hyatt
Comment 7
2014-04-25 13:12:06 PDT
Comment on
attachment 230194
[details]
Patch v2 View in context:
https://bugs.webkit.org/attachment.cgi?id=230194&action=review
r-
> Source/WebCore/rendering/RenderView.cpp:784 > +#if ENABLE(SERVICE_CONTROLS) > + m_currentSelectionRects.clear(); > + > + // Always notify the EditorClient of the new selection rects, no matter what they are. > + struct SelectionRectNotifier { > + SelectionRectNotifier(RenderView& view) > + : m_view(view) > + { } > + > + ~SelectionRectNotifier() > + { > + if (EditorClient* client = m_view.view().frame().editor().client()) > + client->selectionRectsDidChange(m_view.m_currentSelectionRects); > + } > + > + RenderView& m_view; > + }; > + > + SelectionRectNotifier notifier(*this); > +#endif // ENABLE(SERVICE_CONTROLS)
It's gross to have this big block of code right in RenderView::setSelection. I would put this in a helper. I'd even define SelectionRectNotifier in a header and get it out of here too.
> Source/WebCore/rendering/RenderView.cpp:967 > +#if ENABLE(SERVICE_CONTROLS) > + LayoutRect rect = selectionInfo->rect(); > + if (!rect.isEmpty()) > + m_currentSelectionRects.append(rect); > +#endif > + > + newSelectedObjects.set(o, std::move(selectionInfo));
Beef up SelectionRectNotifier into some kind of controller class and move the currentSelectionRects there. Then this becomes one call on the new class.
> Source/WebCore/rendering/RenderView.cpp:985 > +#if ENABLE(SERVICE_CONTROLS) > + GapRects rects = blockInfo->rects(); > + if (!rects.left().isEmpty()) > + m_currentSelectionRects.append(rects.left()); > + if (!rects.right().isEmpty()) > + m_currentSelectionRects.append(rects.right()); > + if (!rects.center().isEmpty()) > + m_currentSelectionRects.append(rects.center()); > +#endif
Same here. You could make this a single function call on a separate object.
> Source/WebCore/rendering/RenderView.h:360 > +#if ENABLE(SERVICE_CONTROLS) > + Vector<LayoutRect> m_currentSelectionRects; > +#endif
Have a separate class here instead (similar to how we keep flow thread controller logic in a separate class).
Brady Eidson
Comment 8
2014-04-25 14:17:48 PDT
Created
attachment 230198
[details]
Patch v3 with Hyatt's suggestion
Brady Eidson
Comment 9
2014-04-25 14:18:21 PDT
Comment on
attachment 230198
[details]
Patch v3 with Hyatt's suggestion Nevermind
Brady Eidson
Comment 10
2014-04-25 14:23:09 PDT
Created
attachment 230200
[details]
Patch v4
Dave Hyatt
Comment 11
2014-04-25 14:25:27 PDT
Comment on
attachment 230200
[details]
Patch v4 r=me
WebKit Commit Bot
Comment 12
2014-04-25 15:22:46 PDT
Comment on
attachment 230200
[details]
Patch v4 Clearing flags on attachment: 230200 Committed
r167830
: <
http://trac.webkit.org/changeset/167830
>
WebKit Commit Bot
Comment 13
2014-04-25 15:22:49 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug