Changeset 167830 in webkit


Ignore:
Timestamp:
Apr 25, 2014 3:22:14 PM (10 years ago)
Author:
beidson@apple.com
Message:

Add a selection overlay.
<rdar://problem/16727797> and https://bugs.webkit.org/show_bug.cgi?id=132200

Reviewed by David Hyatt.

Source/WebCore:
No new tests (WK2 feature in development).

  • WebCore.xcodeproj/project.pbxproj:

Add a SelectionRectGathterer class.
It creates a Notifier (given a RenderView) then accepts Rects from the RenderView.
When the Notifier is destroyed, the appropriate EditorClient is notified of the gathered rects.

  • editing/SelectionRectGatherer.cpp: Added.

(WebCore::SelectionRectGatherer::SelectionRectGatherer):
(WebCore::SelectionRectGatherer::addRect):
(WebCore::SelectionRectGatherer::addRects):
(WebCore::SelectionRectGatherer::Notifier::Notifier):
(WebCore::SelectionRectGatherer::Notifier::~Notifier):
(WebCore::SelectionRectGatherer::clearAndCreateNotifier):

  • editing/SelectionRectGatherer.h: Added.
  • page/EditorClient.h:

(WebCore::EditorClient::selectionRectsDidChange):

  • rendering/RenderView.cpp:

(WebCore::RenderView::RenderView):
(WebCore::RenderView::setSelection): Clear the gatherer’s rects then create a Notifier.
(WebCore::RenderView::setSubtreeSelection): Give all the selection rects to be painted to

the SelectionRectGatherer.

  • rendering/RenderView.h:

Source/WebKit2:

  • WebKit2.xcodeproj/project.pbxproj:
  • WebProcess/WebCoreSupport/WebEditorClient.cpp:

(WebKit::WebEditorClient::selectionRectsDidChange): Pass the new selection rects on

to the selection overlay controller.

  • WebProcess/WebCoreSupport/WebEditorClient.h:
  • WebProcess/WebPage/SelectionOverlayController.cpp: Added.

(WebKit::SelectionOverlayController::SelectionOverlayController):
(WebKit::SelectionOverlayController::createOverlayIfNeeded):
(WebKit::SelectionOverlayController::destroyOverlay):
(WebKit::SelectionOverlayController::pageOverlayDestroyed):
(WebKit::SelectionOverlayController::willMoveToWebPage):
(WebKit::SelectionOverlayController::didMoveToWebPage):
(WebKit::SelectionOverlayController::selectionRectsDidChange):
(WebKit::SelectionOverlayController::drawRect):
(WebKit::SelectionOverlayController::mouseEvent):

  • WebProcess/WebPage/SelectionOverlayController.h: Added.

(WebKit::SelectionOverlayController::create):

  • WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm: Added.

(WebKit::SelectionOverlayController::drawRect):
(WebKit::SelectionOverlayController::mouseEvent):
(WebKit::SelectionOverlayController::handleClick):
(WebKit::SelectionOverlayController::clearHighlight):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::selectionOverlayController):

  • WebProcess/WebPage/WebPage.h:
Location:
trunk/Source
Files:
5 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167828 r167830  
     12014-04-25  Brady Eidson  <beidson@apple.com>
     2
     3        Add a selection overlay.
     4        <rdar://problem/16727797> and https://bugs.webkit.org/show_bug.cgi?id=132200
     5
     6        Reviewed by David Hyatt.
     7
     8        No new tests (WK2 feature in development).
     9
     10        * WebCore.xcodeproj/project.pbxproj:
     11
     12        Add a SelectionRectGathterer class.
     13        It creates a Notifier (given a RenderView) then accepts Rects from the RenderView.
     14        When the Notifier is destroyed, the appropriate EditorClient is notified of the gathered rects.
     15        * editing/SelectionRectGatherer.cpp: Added.
     16        (WebCore::SelectionRectGatherer::SelectionRectGatherer):
     17        (WebCore::SelectionRectGatherer::addRect):
     18        (WebCore::SelectionRectGatherer::addRects):
     19        (WebCore::SelectionRectGatherer::Notifier::Notifier):
     20        (WebCore::SelectionRectGatherer::Notifier::~Notifier):
     21        (WebCore::SelectionRectGatherer::clearAndCreateNotifier):
     22        * editing/SelectionRectGatherer.h: Added.
     23
     24        * page/EditorClient.h:
     25        (WebCore::EditorClient::selectionRectsDidChange):
     26
     27        * rendering/RenderView.cpp:
     28        (WebCore::RenderView::RenderView):
     29        (WebCore::RenderView::setSelection): Clear the gatherer’s rects then create a Notifier.
     30        (WebCore::RenderView::setSubtreeSelection): Give all the selection rects to be painted to
     31          the SelectionRectGatherer.
     32        * rendering/RenderView.h:
     33
    1342014-04-08  Jer Noble  <jer.noble@apple.com>
    235
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r167730 r167830  
    18181818                513F14530AB634C400094DDF /* IconLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 513F14510AB634C400094DDF /* IconLoader.cpp */; };
    18191819                513F14540AB634C400094DDF /* IconLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 513F14520AB634C400094DDF /* IconLoader.h */; };
     1820                51405C88190B014400754F94 /* SelectionRectGatherer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51405C86190B014400754F94 /* SelectionRectGatherer.cpp */; };
     1821                51405C89190B014400754F94 /* SelectionRectGatherer.h in Headers */ = {isa = PBXBuildFile; fileRef = 51405C87190B014400754F94 /* SelectionRectGatherer.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18201822                514B3F730C722047000530DF /* FileSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 514B3F720C722047000530DF /* FileSystem.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18211823                514B3F760C722055000530DF /* FileSystemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 514B3F750C722055000530DF /* FileSystemMac.mm */; };
     
    88098811                513F14510AB634C400094DDF /* IconLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IconLoader.cpp; sourceTree = "<group>"; };
    88108812                513F14520AB634C400094DDF /* IconLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IconLoader.h; sourceTree = "<group>"; };
     8813                51405C86190B014400754F94 /* SelectionRectGatherer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionRectGatherer.cpp; sourceTree = "<group>"; };
     8814                51405C87190B014400754F94 /* SelectionRectGatherer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionRectGatherer.h; sourceTree = "<group>"; };
    88118815                514B3F720C722047000530DF /* FileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystem.h; sourceTree = "<group>"; };
    88128816                514B3F750C722055000530DF /* FileSystemMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSystemMac.mm; sourceTree = "<group>"; };
     
    1719117195                                93309DBA099E64910056E581 /* ReplaceSelectionCommand.cpp */,
    1719217196                                93309DBB099E64910056E581 /* ReplaceSelectionCommand.h */,
     17197                                51405C86190B014400754F94 /* SelectionRectGatherer.cpp */,
     17198                                51405C87190B014400754F94 /* SelectionRectGatherer.h */,
    1719317199                                93309DC0099E64910056E581 /* SetNodeAttributeCommand.cpp */,
    1719417200                                93309DC1099E64910056E581 /* SetNodeAttributeCommand.h */,
     
    2364323649                                859A9C4F0AA5E3BD00B694B2 /* DOMHTMLStyleElement.h in Headers */,
    2364423650                                85E711C70AC5D5350053270F /* DOMHTMLStyleElementInternal.h in Headers */,
     23651                                51405C89190B014400754F94 /* SelectionRectGatherer.h in Headers */,
    2364523652                                85DF821D0AA7849E00486AD7 /* DOMHTMLTableCaptionElement.h in Headers */,
    2364623653                                85E711C80AC5D5350053270F /* DOMHTMLTableCaptionElementInternal.h in Headers */,
     
    2852128528                                85031B490A44EFC700F992E0 /* MutationEvent.cpp in Sources */,
    2852228529                                C6F0900E14327B6100685849 /* MutationObserver.cpp in Sources */,
     28530                                51405C88190B014400754F94 /* SelectionRectGatherer.cpp in Sources */,
    2852328531                                D6E528A3149A926D00EFE1F3 /* MutationObserverInterestGroup.cpp in Sources */,
    2852428532                                D6E276AF14637455001D280A /* MutationObserverRegistration.cpp in Sources */,
  • trunk/Source/WebCore/page/EditorClient.h

    r166818 r167830  
    5656class HTMLElement;
    5757class KeyboardEvent;
     58class LayoutRect;
    5859class Node;
    5960class Range;
     
    183184#endif
    184185
     186#if ENABLE(SERVICE_CONTROLS)
     187    virtual void selectionRectsDidChange(const Vector<LayoutRect>&) { }
     188#endif
     189
    185190    // Support for global selections, used on platforms like the X Window System that treat
    186191    // selection as a type of clipboard.
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r167675 r167830  
    7373    , m_hasSoftwareFilters(false)
    7474#endif
     75#if ENABLE(SERVICE_CONTROLS)
     76    , m_selectionRectGatherer(*this)
     77#endif
    7578{
    7679    setIsRenderView();
     
    761764void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* end, int endPos, SelectionRepaintMode blockRepaintMode)
    762765{
     766#if ENABLE(SERVICE_CONTROLS)
     767    // Clear the current rects and create a notifier for the new rects we are about to gather.
     768    // The Notifier updates the Editor when it goes out of scope and is destroyed.
     769    std::unique_ptr<SelectionRectGatherer::Notifier> rectNotifier = m_selectionRectGatherer.clearAndCreateNotifier();
     770#endif // ENABLE(SERVICE_CONTROLS)
     771
    763772    // Make sure both our start and end objects are defined.
    764773    // Check www.msnbc.com and try clicking around to find the case where this happened.
     
    934943    while (o && o != stop) {
    935944        if ((o->canBeSelectionLeaf() || o == start || o == end) && o->selectionState() != SelectionNone) {
    936             newSelectedObjects.set(o, std::make_unique<RenderSelectionInfo>(o, true));
     945            std::unique_ptr<RenderSelectionInfo> selectionInfo = std::make_unique<RenderSelectionInfo>(o, true);
     946
     947#if ENABLE(SERVICE_CONTROLS)
     948            m_selectionRectGatherer.addRect(selectionInfo->rect());
     949#endif
     950
     951            newSelectedObjects.set(o, std::move(selectionInfo));
     952
    937953            RenderBlock* cb = o->containingBlock();
    938954            while (cb && !cb->isRenderView()) {
     
    942958                blockInfo = std::make_unique<RenderBlockSelectionInfo>(cb);
    943959                cb = cb->containingBlock();
     960
     961#if ENABLE(SERVICE_CONTROLS)
     962                m_selectionRectGatherer.addRects(blockInfo->rects());
     963#endif
    944964            }
    945965        }
  • trunk/Source/WebCore/rendering/RenderView.h

    r167652 r167830  
    3333#include <wtf/OwnPtr.h>
    3434
     35#if ENABLE(SERVICE_CONTROLS)
     36#include "SelectionRectGatherer.h"
     37#endif
     38
    3539namespace WebCore {
    3640
     
    355359
    356360    HashSet<RenderElement*> m_renderersWithPausedImageAnimation;
     361
     362#if ENABLE(SERVICE_CONTROLS)
     363    SelectionRectGatherer m_selectionRectGatherer;
     364#endif
    357365};
    358366
  • trunk/Source/WebKit2/ChangeLog

    r167826 r167830  
     12014-04-25  Brady Eidson  <beidson@apple.com>
     2
     3        Add a selection overlay.
     4        <rdar://problem/16727797> and https://bugs.webkit.org/show_bug.cgi?id=132200
     5
     6        Reviewed by David Hyatt.
     7
     8        * WebKit2.xcodeproj/project.pbxproj:
     9
     10        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
     11        (WebKit::WebEditorClient::selectionRectsDidChange): Pass the new selection rects on
     12          to the selection overlay controller.
     13        * WebProcess/WebCoreSupport/WebEditorClient.h:
     14
     15        * WebProcess/WebPage/SelectionOverlayController.cpp: Added.
     16        (WebKit::SelectionOverlayController::SelectionOverlayController):
     17        (WebKit::SelectionOverlayController::createOverlayIfNeeded):
     18        (WebKit::SelectionOverlayController::destroyOverlay):
     19        (WebKit::SelectionOverlayController::pageOverlayDestroyed):
     20        (WebKit::SelectionOverlayController::willMoveToWebPage):
     21        (WebKit::SelectionOverlayController::didMoveToWebPage):
     22        (WebKit::SelectionOverlayController::selectionRectsDidChange):
     23        (WebKit::SelectionOverlayController::drawRect):
     24        (WebKit::SelectionOverlayController::mouseEvent):
     25        * WebProcess/WebPage/SelectionOverlayController.h: Added.
     26        (WebKit::SelectionOverlayController::create):
     27        * WebProcess/WebPage/mac/SelectionOverlayControllerMac.mm: Added.
     28        (WebKit::SelectionOverlayController::drawRect):
     29        (WebKit::SelectionOverlayController::mouseEvent):
     30        (WebKit::SelectionOverlayController::handleClick):
     31        (WebKit::SelectionOverlayController::clearHighlight):
     32
     33        * WebProcess/WebPage/WebPage.cpp:
     34        (WebKit::WebPage::selectionOverlayController):
     35        * WebProcess/WebPage/WebPage.h:
     36
    1372014-04-25  Enrica Casucci  <enrica@apple.com>
    238
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r167633 r167830  
    906906                51E35209180F5D6B00E53BE9 /* DatabaseServiceEntryPoint.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E35208180F5D6B00E53BE9 /* DatabaseServiceEntryPoint.mm */; };
    907907                51E3B67F16F266B3009968DC /* NetworkResourceLoaderMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E3B67E16F266B3009968DC /* NetworkResourceLoaderMac.mm */; };
     908                51EF124E19098522008A6532 /* SelectionOverlayController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51EF124C19098522008A6532 /* SelectionOverlayController.cpp */; };
     909                51EF124F19098523008A6532 /* SelectionOverlayController.h in Headers */ = {isa = PBXBuildFile; fileRef = 51EF124D19098522008A6532 /* SelectionOverlayController.h */; };
     910                51EF125119098531008A6532 /* SelectionOverlayControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51EF125019098531008A6532 /* SelectionOverlayControllerMac.mm */; };
    908911                51EFC1CF1524E62500C9A938 /* WKBundleDOMWindowExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 51FA2D541521118600C1BA0B /* WKBundleDOMWindowExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
    909912                51F060E01654317F00F3281B /* WebResourceLoaderMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */; };
     
    27582761                51E35208180F5D6B00E53BE9 /* DatabaseServiceEntryPoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseServiceEntryPoint.mm; sourceTree = "<group>"; };
    27592762                51E3B67E16F266B3009968DC /* NetworkResourceLoaderMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkResourceLoaderMac.mm; sourceTree = "<group>"; };
     2763                51EF124C19098522008A6532 /* SelectionOverlayController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionOverlayController.cpp; sourceTree = "<group>"; };
     2764                51EF124D19098522008A6532 /* SelectionOverlayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionOverlayController.h; sourceTree = "<group>"; };
     2765                51EF125019098531008A6532 /* SelectionOverlayControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SelectionOverlayControllerMac.mm; sourceTree = "<group>"; };
    27602766                51F060DD1654317500F3281B /* WebResourceLoaderMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoaderMessageReceiver.cpp; sourceTree = "<group>"; };
    27612767                51F060DE1654317500F3281B /* WebResourceLoaderMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebResourceLoaderMessages.h; sourceTree = "<group>"; };
     
    53175323                                2D140EAD18F37BE0005E75A0 /* PageOverlayController.cpp */,
    53185324                                2D140EAE18F37BE0005E75A0 /* PageOverlayController.h */,
     5325                                51EF124C19098522008A6532 /* SelectionOverlayController.cpp */,
     5326                                51EF124D19098522008A6532 /* SelectionOverlayController.h */,
    53195327                                519EF58F18EF77210003B7F4 /* TelephoneNumberOverlayController.cpp */,
    53205328                                519EF59018EF77210003B7F4 /* TelephoneNumberOverlayController.h */,
     
    60726080                                1AB16ADC1648598400290D62 /* RemoteLayerTreeDrawingArea.h */,
    60736081                                1AB16ADB1648598400290D62 /* RemoteLayerTreeDrawingArea.mm */,
     6082                                51EF125019098531008A6532 /* SelectionOverlayControllerMac.mm */,
    60746083                                519EF58D18EF770D0003B7F4 /* TelephoneNumberOverlayControllerMac.mm */,
    60756084                                1AAF263714687C39004A1E8A /* TiledCoreAnimationDrawingArea.h */,
     
    73477356                                1F7506B61859165700EC0FF7 /* WKWebProcessPlugInNodeHandleInternal.h in Headers */,
    73487357                                1F7506B51859165400EC0FF7 /* WKWebProcessPlugInScriptWorldInternal.h in Headers */,
     7358                                51EF124F19098523008A6532 /* SelectionOverlayController.h in Headers */,
    73497359                                373CEAD6185417AE008C363D /* WKNSData.h in Headers */,
    73507360                                1AB8A1F018400B0000E9AE69 /* WKPageFormClient.h in Headers */,
     
    84488458                                F62A76B812B1B25F0005F1B6 /* WebDatabaseManagerProxyMessageReceiver.cpp in Sources */,
    84498459                                517DD5C5180DC3E10081660B /* DatabaseProcessProxyMac.mm in Sources */,
     8460                                51EF125119098531008A6532 /* SelectionOverlayControllerMac.mm in Sources */,
    84508461                                BC111A5D112F4FBB00337BAB /* WebDragClient.cpp in Sources */,
    84518462                                C574A37712E6099D002DFE98 /* WebDragClientMac.mm in Sources */,
     
    85908601                                33F9D5B91312F1EE000D683F /* WebResourceCacheManagerCFNet.cpp in Sources */,
    85918602                                33367655130C9ECA006C9DE2 /* WebResourceCacheManagerMessageReceiver.cpp in Sources */,
     8603                                51EF124E19098522008A6532 /* SelectionOverlayController.cpp in Sources */,
    85928604                                33367635130C99B2006C9DE2 /* WebResourceCacheManagerProxy.cpp in Sources */,
    85938605                                33367657130C9ECA006C9DE2 /* WebResourceCacheManagerProxyMessageReceiver.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp

    r167388 r167830  
    2828
    2929#include "EditorState.h"
     30#include "SelectionOverlayController.h"
    3031#include "TelephoneNumberOverlayController.h"
    3132#include "WebCoreArgumentCoders.h"
     
    532533#endif
    533534
     535#if ENABLE(SERVICE_CONTROLS)
     536void WebEditorClient::selectionRectsDidChange(const Vector<LayoutRect>& rects)
     537{
     538    m_page->selectionOverlayController().selectionRectsDidChange(rects);
     539}
     540#endif // ENABLE(SERVICE_CONTROLS)
     541
    534542} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h

    r167116 r167830  
    171171    virtual void selectedTelephoneNumberRangesChanged(const Vector<RefPtr<WebCore::Range>>&) override;
    172172#endif
     173#if ENABLE(SERVICE_CONTROLS)
     174    virtual void selectionRectsDidChange(const Vector<WebCore::LayoutRect>&) override;
     175#endif
    173176
    174177    WebPage* m_page;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r167786 r167830  
    5050#include "PluginView.h"
    5151#include "PrintInfo.h"
     52#include "SelectionOverlayController.h"
    5253#include "SessionState.h"
    5354#include "SessionTracker.h"
     
    45714572#endif
    45724573
     4574#if ENABLE(SERVICE_CONTROLS)
     4575SelectionOverlayController& WebPage::selectionOverlayController()
     4576{
     4577    if (!m_selectionOverlayController)
     4578        m_selectionOverlayController = SelectionOverlayController::create(this);
     4579
     4580    return *m_selectionOverlayController;
     4581}
     4582#endif
     4583
    45734584void WebPage::didChangeScrollOffsetForFrame(Frame* frame)
    45744585{
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r167786 r167830  
    141141class PageOverlay;
    142142class PluginView;
     143class SelectionOverlayController;
    143144class SessionState;
    144145class VisibleContentRectUpdateInfo;
     
    784785    void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&);
    785786#endif
     787#if ENABLE(SERVICE_CONTROLS)
     788    SelectionOverlayController& selectionOverlayController();
     789#endif
    786790
    787791    void didChangeScrollOffsetForFrame(WebCore::Frame*);
     
    12011205    RefPtr<TelephoneNumberOverlayController> m_telephoneNumberOverlayController;
    12021206#endif
     1207#if ENABLE(SERVICE_CONTROLS)
     1208    RefPtr<SelectionOverlayController> m_selectionOverlayController;
     1209#endif
    12031210
    12041211    PageOverlayController m_pageOverlayController;
Note: See TracChangeset for help on using the changeset viewer.