2 * Copyright (C) 2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
31 #include "PluginComplexTextInputState.h"
32 #include "WKLayoutMode.h"
33 #include "WebPageProxy.h"
34 #include "_WKOverlayScrollbarStyle.h"
35 #include <WebCore/TextIndicatorWindow.h>
36 #include <WebCore/UserInterfaceLayoutDirection.h>
38 #include <wtf/BlockPtr.h>
39 #include <wtf/RetainPtr.h>
40 #include <wtf/WeakPtr.h>
41 #include <wtf/text/WTFString.h>
43 OBJC_CLASS NSImmediateActionGestureRecognizer;
44 OBJC_CLASS NSTextInputContext;
46 OBJC_CLASS WKBrowsingContextController;
47 OBJC_CLASS WKEditorUndoTargetObjC;
48 OBJC_CLASS WKFullScreenWindowController;
49 OBJC_CLASS WKImmediateActionController;
50 OBJC_CLASS WKViewLayoutStrategy;
52 OBJC_CLASS WKWindowVisibilityObserver;
53 OBJC_CLASS _WKThumbnailView;
56 OBJC_CLASS AVFunctionBarPlaybackControlsProvider;
57 OBJC_CLASS AVFunctionBarScrubber;
58 OBJC_CLASS NSCandidateListTouchBarItem;
59 OBJC_CLASS NSCustomTouchBarItem;
60 OBJC_CLASS NSTouchBar;
61 OBJC_CLASS NSTouchBarItem;
62 OBJC_CLASS NSPopoverTouchBarItem;
63 OBJC_CLASS WKTextTouchBarItemController;
64 OBJC_CLASS WebPlaybackControlsManager;
65 #endif // HAVE(TOUCH_BAR)
67 @protocol WebViewImplDelegate
69 - (NSTextInputContext *)_web_superInputContext;
70 - (void)_web_superQuickLookWithEvent:(NSEvent *)event;
71 - (void)_web_superRemoveTrackingRect:(NSTrackingRectTag)tag;
72 - (void)_web_superSwipeWithEvent:(NSEvent *)event;
73 - (void)_web_superMagnifyWithEvent:(NSEvent *)event;
74 - (void)_web_superSmartMagnifyWithEvent:(NSEvent *)event;
75 - (id)_web_superAccessibilityAttributeValue:(NSString *)attribute;
76 - (void)_web_superDoCommandBySelector:(SEL)selector;
77 - (BOOL)_web_superPerformKeyEquivalent:(NSEvent *)event;
78 - (void)_web_superKeyDown:(NSEvent *)event;
79 - (NSView *)_web_superHitTest:(NSPoint)point;
81 - (id)_web_immediateActionAnimationControllerForHitTestResultInternal:(API::HitTestResult*)hitTestResult withType:(uint32_t)type userData:(API::Object*)userData;
82 - (void)_web_prepareForImmediateActionAnimation;
83 - (void)_web_cancelImmediateActionAnimation;
84 - (void)_web_completeImmediateActionAnimation;
86 - (void)_web_dismissContentRelativeChildWindows;
87 - (void)_web_dismissContentRelativeChildWindowsWithAnimation:(BOOL)animate;
89 - (void)_web_gestureEventWasNotHandledByWebCore:(NSEvent *)event;
91 - (void)_web_didChangeContentSize:(NSSize)newSize;
94 - (void)_web_didAddMediaControlsManager:(id)controlsManager;
95 - (void)_web_didRemoveMediaControlsManager;
96 - (void)_didHandleAcceptedCandidate;
97 - (void)_didUpdateCandidateListVisibility:(BOOL)visible;
102 struct KeyPressCommand;
107 class PageClientImpl;
108 class DrawingAreaProxy;
109 class ViewGestureController;
110 class WebEditCommandProxy;
112 struct ColorSpaceData;
114 typedef id <NSValidatedUserInterfaceItem> ValidationItem;
115 typedef Vector<RetainPtr<ValidationItem>> ValidationVector;
116 typedef HashMap<String, ValidationVector> ValidationMap;
119 WTF_MAKE_FAST_ALLOCATED;
120 WTF_MAKE_NONCOPYABLE(WebViewImpl);
122 WebViewImpl(NSView <WebViewImplDelegate> *, WKWebView *outerWebView, WebProcessPool&, Ref<API::PageConfiguration>&&);
128 WebPageProxy& page() { return m_page.get(); }
130 void processDidExit();
132 void didRelaunchProcess();
134 void setDrawsBackground(bool);
135 bool drawsBackground() const;
136 bool isOpaque() const;
138 bool acceptsFirstMouse(NSEvent *);
139 bool acceptsFirstResponder();
140 bool becomeFirstResponder();
141 bool resignFirstResponder();
142 bool isFocused() const;
144 void viewWillStartLiveResize();
145 void viewDidEndLiveResize();
148 void setFrameSize(CGSize);
149 void disableFrameSizeUpdates();
150 void enableFrameSizeUpdates();
151 bool frameSizeUpdatesDisabled() const;
152 void setFrameAndScrollBy(CGRect, CGSize);
153 void updateWindowAndViewFrames();
155 void setFixedLayoutSize(CGSize);
156 CGSize fixedLayoutSize() const;
158 std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy();
159 bool isUsingUISideCompositing() const;
160 void setDrawingAreaSize(CGSize);
162 static bool wantsUpdateLayer() { return true; }
164 void drawRect(CGRect);
165 bool canChangeFrameLayout(WebFrameProxy&);
166 NSPrintOperation *printOperationWithPrintInfo(NSPrintInfo *, WebFrameProxy&);
168 void setAutomaticallyAdjustsContentInsets(bool);
169 bool automaticallyAdjustsContentInsets() const { return m_automaticallyAdjustsContentInsets; }
170 void updateContentInsetsIfAutomatic();
171 void setTopContentInset(CGFloat);
172 CGFloat topContentInset() const { return m_topContentInset; }
174 void prepareContentInRect(CGRect);
175 void updateViewExposedRect();
176 void setClipsToVisibleRect(bool);
177 bool clipsToVisibleRect() const { return m_clipsToVisibleRect; }
179 void setMinimumSizeForAutoLayout(CGSize);
180 CGSize minimumSizeForAutoLayout() const;
181 void setShouldExpandToViewHeightForAutoLayout(bool);
182 bool shouldExpandToViewHeightForAutoLayout() const;
183 void setIntrinsicContentSize(CGSize);
184 CGSize intrinsicContentSize() const;
186 void setViewScale(CGFloat);
187 CGFloat viewScale() const;
189 WKLayoutMode layoutMode() const;
190 void setLayoutMode(WKLayoutMode);
191 void updateSupportsArbitraryLayoutModes();
193 void setOverrideDeviceScaleFactor(CGFloat);
194 CGFloat overrideDeviceScaleFactor() const { return m_overrideDeviceScaleFactor; }
196 void windowDidOrderOffScreen();
197 void windowDidOrderOnScreen();
198 void windowDidBecomeKey(NSWindow *);
199 void windowDidResignKey(NSWindow *);
200 void windowDidMiniaturize();
201 void windowDidDeminiaturize();
202 void windowDidMove();
203 void windowDidResize();
204 void windowDidChangeBackingProperties(CGFloat oldBackingScaleFactor);
205 void windowDidChangeScreen();
206 void windowDidChangeLayerHosting();
207 void windowDidChangeOcclusionState();
208 bool shouldDelayWindowOrderingForEvent(NSEvent *);
209 bool windowResizeMouseLocationIsInVisibleScrollerThumb(CGPoint);
211 // -[NSView mouseDownCanMoveWindow] returns YES when the NSView is transparent,
212 // but we don't want a drag in the NSView to move the window, even if it's transparent.
213 static bool mouseDownCanMoveWindow() { return false; }
215 void viewWillMoveToWindow(NSWindow *);
216 void viewDidMoveToWindow();
217 void viewDidChangeBackingProperties();
219 void viewDidUnhide();
220 void activeSpaceDidChange();
222 NSView *hitTest(CGPoint);
224 ColorSpaceData colorSpace();
226 void setUnderlayColor(NSColor *);
227 NSColor *underlayColor() const;
228 NSColor *pageExtendedBackgroundColor() const;
230 void setOverlayScrollbarStyle(WTF::Optional<WebCore::ScrollbarOverlayStyle> scrollbarStyle);
231 WTF::Optional<WebCore::ScrollbarOverlayStyle> overlayScrollbarStyle() const;
233 void beginDeferringViewInWindowChanges();
234 // FIXME: Merge these two?
235 void endDeferringViewInWindowChanges();
236 void endDeferringViewInWindowChangesSync();
237 bool isDeferringViewInWindowChanges() const { return m_shouldDeferViewInWindowChanges; }
239 void setWindowOcclusionDetectionEnabled(bool enabled) { m_windowOcclusionDetectionEnabled = enabled; }
240 bool windowOcclusionDetectionEnabled() const { return m_windowOcclusionDetectionEnabled; }
242 void prepareForMoveToWindow(NSWindow *targetWindow, std::function<void()> completionHandler);
243 NSWindow *targetWindowForMovePreparation() const { return m_targetWindowForMovePreparation; }
245 void updateSecureInputState();
246 void resetSecureInputState();
247 bool inSecureInputState() const { return m_inSecureInputState; }
248 void notifyInputContextAboutDiscardedComposition();
249 void setPluginComplexTextInputStateAndIdentifier(PluginComplexTextInputState, uint64_t identifier);
250 void disableComplexTextInputIfNecessary();
251 bool handlePluginComplexTextInputKeyDown(NSEvent *);
252 bool tryHandlePluginComplexTextInputKeyDown(NSEvent *);
253 void pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus, uint64_t pluginComplexTextInputIdentifier);
254 bool tryPostProcessPluginComplexTextInputKeyDown(NSEvent *);
255 PluginComplexTextInputState pluginComplexTextInputState() const { return m_pluginComplexTextInputState; }
256 uint64_t pluginComplexTextInputIdentifier() const { return m_pluginComplexTextInputIdentifier; }
258 void handleAcceptedAlternativeText(const String&);
259 NSInteger spellCheckerDocumentTag();
261 void pressureChangeWithEvent(NSEvent *);
262 NSEvent *lastPressureEvent() { return m_lastPressureEvent.get(); }
264 #if ENABLE(FULLSCREEN_API)
265 bool hasFullScreenWindowController() const;
266 WKFullScreenWindowController *fullScreenWindowController();
267 void closeFullScreenWindowController();
269 NSView *fullScreenPlaceholderView();
270 NSWindow *createFullScreenWindow();
272 bool isEditable() const;
273 bool executeSavedCommandBySelector(SEL);
274 void executeEditCommandForSelector(SEL, const String& argument = String());
275 void registerEditCommand(RefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
276 void clearAllEditCommands();
277 bool writeSelectionToPasteboard(NSPasteboard *, NSArray *types);
278 bool readSelectionFromPasteboard(NSPasteboard *);
279 id validRequestorForSendAndReturnTypes(NSString *sendType, NSString *returnType);
280 void centerSelectionInVisibleArea();
281 void selectionDidChange();
282 void startObservingFontPanel();
283 void updateFontPanelIfNeeded();
284 void changeFontFromFontPanel();
285 bool validateUserInterfaceItem(id <NSValidatedUserInterfaceItem>);
286 void setEditableElementIsFocused(bool);
288 void startSpeaking();
289 void stopSpeaking(id);
291 void showGuessPanel(id);
292 void checkSpelling();
293 void changeSpelling(id);
294 void toggleContinuousSpellChecking();
296 bool isGrammarCheckingEnabled();
297 void setGrammarCheckingEnabled(bool);
298 void toggleGrammarChecking();
299 void toggleAutomaticSpellingCorrection();
300 void orderFrontSubstitutionsPanel(id);
301 void toggleSmartInsertDelete();
302 bool isAutomaticQuoteSubstitutionEnabled();
303 void setAutomaticQuoteSubstitutionEnabled(bool);
304 void toggleAutomaticQuoteSubstitution();
305 bool isAutomaticDashSubstitutionEnabled();
306 void setAutomaticDashSubstitutionEnabled(bool);
307 void toggleAutomaticDashSubstitution();
308 bool isAutomaticLinkDetectionEnabled();
309 void setAutomaticLinkDetectionEnabled(bool);
310 void toggleAutomaticLinkDetection();
311 bool isAutomaticTextReplacementEnabled();
312 void setAutomaticTextReplacementEnabled(bool);
313 void toggleAutomaticTextReplacement();
314 void uppercaseWord();
315 void lowercaseWord();
316 void capitalizeWord();
318 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
319 void requestCandidatesForSelectionIfNeeded();
322 void preferencesDidChange();
324 void setTextIndicator(WebCore::TextIndicator&, WebCore::TextIndicatorWindowLifetime = WebCore::TextIndicatorWindowLifetime::Permanent);
325 void clearTextIndicatorWithAnimation(WebCore::TextIndicatorWindowDismissalAnimation);
326 void setTextIndicatorAnimationProgress(float);
327 void dismissContentRelativeChildWindows();
328 void dismissContentRelativeChildWindowsFromViewOnly();
329 void dismissContentRelativeChildWindowsWithAnimation(bool);
330 void dismissContentRelativeChildWindowsWithAnimationFromViewOnly(bool);
331 static void hideWordDefinitionWindow();
333 void quickLookWithEvent(NSEvent *);
334 void prepareForDictionaryLookup();
335 void setAllowsLinkPreview(bool);
336 bool allowsLinkPreview() const { return m_allowsLinkPreview; }
337 void* immediateActionAnimationControllerForHitTestResult(API::HitTestResult*, uint32_t type, API::Object* userData);
338 void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object* userData);
339 void prepareForImmediateActionAnimation();
340 void cancelImmediateActionAnimation();
341 void completeImmediateActionAnimation();
342 void didChangeContentSize(CGSize);
343 void didHandleAcceptedCandidate();
344 void videoControlsManagerDidChange();
346 void setIgnoresNonWheelEvents(bool);
347 bool ignoresNonWheelEvents() const { return m_ignoresNonWheelEvents; }
348 void setIgnoresAllEvents(bool);
349 bool ignoresAllEvents() const { return m_ignoresAllEvents; }
350 void setIgnoresMouseDraggedEvents(bool);
351 bool ignoresMouseDraggedEvents() const { return m_ignoresMouseDraggedEvents; }
353 void setAccessibilityWebProcessToken(NSData *);
354 void accessibilityRegisterUIProcessTokens();
355 void updateRemoteAccessibilityRegistration(bool registerProcess);
356 id accessibilityFocusedUIElement();
357 bool accessibilityIsIgnored() const { return false; }
358 id accessibilityHitTest(CGPoint);
359 void enableAccessibilityIfNecessary();
360 id accessibilityAttributeValue(NSString *);
362 NSTrackingArea *primaryTrackingArea() const { return m_primaryTrackingArea.get(); }
363 void setPrimaryTrackingArea(NSTrackingArea *);
365 NSTrackingRectTag addTrackingRect(CGRect, id owner, void* userData, bool assumeInside);
366 NSTrackingRectTag addTrackingRectWithTrackingNum(CGRect, id owner, void* userData, bool assumeInside, int tag);
367 void addTrackingRectsWithTrackingNums(CGRect*, id owner, void** userDataList, bool assumeInside, NSTrackingRectTag *trackingNums, int count);
368 void removeTrackingRect(NSTrackingRectTag);
369 void removeTrackingRects(NSTrackingRectTag *, int count);
370 NSString *stringForToolTip(NSToolTipTag tag);
371 void toolTipChanged(const String& oldToolTip, const String& newToolTip);
373 void setAcceleratedCompositingRootLayer(CALayer *);
374 CALayer *acceleratedCompositingRootLayer() const { return m_rootLayer.get(); }
377 void setThumbnailView(_WKThumbnailView *);
378 _WKThumbnailView *thumbnailView() const { return m_thumbnailView; }
380 void setInspectorAttachmentView(NSView *);
381 NSView *inspectorAttachmentView();
383 _WKRemoteObjectRegistry *remoteObjectRegistry();
385 WKBrowsingContextController *browsingContextController();
386 #endif // WK_API_ENABLED
388 #if ENABLE(DRAG_SUPPORT)
389 void draggedImage(NSImage *, CGPoint endPoint, NSDragOperation);
390 NSDragOperation draggingEntered(id <NSDraggingInfo>);
391 NSDragOperation draggingUpdated(id <NSDraggingInfo>);
392 void draggingExited(id <NSDraggingInfo>);
393 bool prepareForDragOperation(id <NSDraggingInfo>);
394 bool performDragOperation(id <NSDraggingInfo>);
395 NSView *hitTestForDragTypes(CGPoint, NSSet *types);
396 void registerDraggedTypes();
399 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
400 void startWindowDrag();
403 void dragImageForView(NSView *, NSImage *, CGPoint clientPoint, bool linkDrag);
404 void setFileAndURLTypes(NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, NSPasteboard *);
405 void setPromisedDataForImage(WebCore::Image*, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName);
406 #if ENABLE(ATTACHMENT_ELEMENT)
407 void setPromisedDataForAttachment(NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, NSString *pasteboardName);
409 void pasteboardChangedOwner(NSPasteboard *);
410 void provideDataForPasteboard(NSPasteboard *, NSString *type);
411 NSArray *namesOfPromisedFilesDroppedAtDestination(NSURL *dropDestination);
413 RefPtr<ViewSnapshot> takeViewSnapshot();
414 void saveBackForwardSnapshotForCurrentItem();
415 void saveBackForwardSnapshotForItem(WebBackForwardListItem&);
417 ViewGestureController* gestureController() { return m_gestureController.get(); }
418 ViewGestureController& ensureGestureController();
419 void setAllowsBackForwardNavigationGestures(bool);
420 bool allowsBackForwardNavigationGestures() const { return m_allowsBackForwardNavigationGestures; }
421 void setAllowsMagnification(bool);
422 bool allowsMagnification() const { return m_allowsMagnification; }
424 void setMagnification(double, CGPoint centerPoint);
425 void setMagnification(double);
426 double magnification() const;
427 void setCustomSwipeViews(NSArray *);
428 void setCustomSwipeViewsTopContentInset(float);
429 bool tryToSwipeWithEvent(NSEvent *, bool ignoringPinnedState);
430 void setDidMoveSwipeSnapshotCallback(BlockPtr<void (CGRect)>&&);
432 void scrollWheel(NSEvent *);
433 void swipeWithEvent(NSEvent *);
434 void magnifyWithEvent(NSEvent *);
435 void rotateWithEvent(NSEvent *);
436 void smartMagnifyWithEvent(NSEvent *);
438 void setLastMouseDownEvent(NSEvent *);
440 void gestureEventWasNotHandledByWebCore(NSEvent *);
441 void gestureEventWasNotHandledByWebCoreFromViewOnly(NSEvent *);
443 void didRestoreScrollPosition();
445 void setTotalHeightOfBanners(CGFloat totalHeightOfBanners) { m_totalHeightOfBanners = totalHeightOfBanners; }
446 CGFloat totalHeightOfBanners() const { return m_totalHeightOfBanners; }
448 void doneWithKeyEvent(NSEvent *, bool eventWasHandled);
449 NSArray *validAttributesForMarkedText();
450 void doCommandBySelector(SEL);
451 void insertText(id string);
452 void insertText(id string, NSRange replacementRange);
453 NSTextInputContext *inputContext();
455 void setMarkedText(id string, NSRange selectedRange, NSRange replacementRange);
456 NSRange selectedRange();
457 bool hasMarkedText();
458 NSRange markedRange();
459 NSAttributedString *attributedSubstringForProposedRange(NSRange, NSRangePointer actualRange);
460 NSUInteger characterIndexForPoint(NSPoint);
461 NSRect firstRectForCharacterRange(NSRange, NSRangePointer actualRange);
462 bool performKeyEquivalent(NSEvent *);
463 void keyUp(NSEvent *);
464 void keyDown(NSEvent *);
465 void flagsChanged(NSEvent *);
467 // Override this so that AppKit will send us arrow keys as key down events so we can
468 // support them via the key bindings mechanism.
469 static bool wantsKeyDownForEvent(NSEvent *) { return true; }
471 void selectedRangeWithCompletionHandler(void(^)(NSRange));
472 void hasMarkedTextWithCompletionHandler(void(^)(BOOL hasMarkedText));
473 void markedRangeWithCompletionHandler(void(^)(NSRange));
474 void attributedSubstringForProposedRange(NSRange, void(^)(NSAttributedString *attrString, NSRange actualRange));
475 void firstRectForCharacterRange(NSRange, void(^)(NSRect firstRect, NSRange actualRange));
476 void characterIndexForPoint(NSPoint, void(^)(NSUInteger));
478 void mouseMoved(NSEvent *);
479 void mouseDown(NSEvent *);
480 void mouseUp(NSEvent *);
481 void mouseDragged(NSEvent *);
482 void mouseEntered(NSEvent *);
483 void mouseExited(NSEvent *);
484 void otherMouseDown(NSEvent *);
485 void otherMouseDragged(NSEvent *);
486 void otherMouseUp(NSEvent *);
487 void rightMouseDown(NSEvent *);
488 void rightMouseDragged(NSEvent *);
489 void rightMouseUp(NSEvent *);
491 void forceRequestCandidatesForTesting();
492 bool shouldRequestCandidates() const;
493 void showCandidates(NSArray *candidates, NSString *, NSRect rectOfTypedString, NSRange selectedRange, NSView *, void (^completionHandler)(NSTextCheckingResult *acceptedCandidate));
495 bool windowIsFrontWindowUnderMouse(NSEvent *);
497 void setRequiresUserActionForEditingControlsManager(bool requiresUserActionForEditingControlsManager) { m_requiresUserActionForEditingControlsManager = requiresUserActionForEditingControlsManager; }
498 bool requiresUserActionForEditingControlsManager() const { return m_requiresUserActionForEditingControlsManager; }
500 WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection();
501 void setUserInterfaceLayoutDirection(NSUserInterfaceLayoutDirection);
503 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
504 void handleAcceptedCandidate(NSTextCheckingResult *acceptedCandidate);
508 NSTouchBar *makeTouchBar();
509 void updateTouchBar();
510 NSTouchBar *currentTouchBar() const { return m_currentTouchBar.get(); }
511 NSCandidateListTouchBarItem *candidateListTouchBarItem() const;
512 AVFunctionBarScrubber *mediaPlaybackControlsView() const;
513 NSTouchBar *textTouchBar() const;
514 void dismissTextTouchBarPopoverItemWithIdentifier(NSString *);
516 bool clientWantsMediaPlaybackControlsView() const { return m_clientWantsMediaPlaybackControlsView; }
517 void setClientWantsMediaPlaybackControlsView(bool clientWantsMediaPlaybackControlsView) { m_clientWantsMediaPlaybackControlsView = clientWantsMediaPlaybackControlsView; }
519 void updateTouchBarAndRefreshTextBarIdentifiers();
520 void setIsCustomizingTouchBar(bool isCustomizingTouchBar) { m_isCustomizingTouchBar = isCustomizingTouchBar; };
521 #endif // HAVE(TOUCH_BAR)
525 void setUpTextTouchBar(NSTouchBar *);
526 void updateTextTouchBar();
527 void updateMediaTouchBar();
529 bool useMediaPlaybackControlsView() const;
530 bool isRichlyEditable() const;
532 bool m_clientWantsMediaPlaybackControlsView { false };
533 bool m_canCreateTouchBars { false };
534 bool m_startedListeningToCustomizationEvents { false };
535 bool m_isUpdatingTextTouchBar { false };
536 bool m_isCustomizingTouchBar { false };
538 RetainPtr<NSTouchBar> m_currentTouchBar;
539 RetainPtr<NSTouchBar> m_richTextTouchBar;
540 RetainPtr<NSTouchBar> m_plainTextTouchBar;
541 RetainPtr<WKTextTouchBarItemController> m_textTouchBarItemController;
542 RetainPtr<NSCandidateListTouchBarItem> m_richTextCandidateListTouchBarItem;
543 RetainPtr<NSCandidateListTouchBarItem> m_plainTextCandidateListTouchBarItem;
544 RetainPtr<NSArray> m_emptyCandidatesArray;
545 RetainPtr<WebPlaybackControlsManager> m_playbackControlsManager;
546 RetainPtr<NSCustomTouchBarItem> m_exitFullScreenButton;
548 #if ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
549 RetainPtr<AVFunctionBarPlaybackControlsProvider> m_mediaTouchBarProvider;
550 RetainPtr<AVFunctionBarScrubber> m_mediaPlaybackControlsView;
551 #endif // ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
552 #endif // HAVE(TOUCH_BAR)
554 WeakPtr<WebViewImpl> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
556 bool supportsArbitraryLayoutModes() const;
557 float intrinsicDeviceScaleFactor() const;
558 void dispatchSetTopContentInset();
560 void postFakeMouseMovedEventForFlagsChangedEvent(NSEvent *);
562 void setPluginComplexTextInputState(PluginComplexTextInputState);
564 void sendToolTipMouseExited();
565 void sendToolTipMouseEntered();
567 void reparentLayerTreeInThumbnailView();
568 void updateThumbnailViewLayer();
570 void setUserInterfaceItemState(NSString *commandName, bool enabled, int state);
572 Vector<WebCore::KeypressCommand> collectKeyboardLayoutCommandsForEvent(NSEvent *);
573 void interpretKeyEvent(NSEvent *, void(^completionHandler)(BOOL handled, const Vector<WebCore::KeypressCommand>&));
575 void mouseMovedInternal(NSEvent *);
576 void mouseDownInternal(NSEvent *);
577 void mouseUpInternal(NSEvent *);
578 void mouseDraggedInternal(NSEvent *);
580 bool mightBeginDragWhileInactive();
581 bool mightBeginScrollWhileInactive();
583 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
584 void handleRequestedCandidates(NSInteger sequenceNumber, NSArray<NSTextCheckingResult *> *candidates);
587 NSView <WebViewImplDelegate> *m_view;
588 std::unique_ptr<PageClient> m_pageClient;
589 Ref<WebPageProxy> m_page;
591 WeakPtrFactory<WebViewImpl> m_weakPtrFactory;
593 bool m_willBecomeFirstResponderAgain { false };
594 bool m_inBecomeFirstResponder { false };
595 bool m_inResignFirstResponder { false };
597 CGRect m_contentPreparationRect { { 0, 0 }, { 0, 0 } };
598 bool m_useContentPreparationRectForVisibleRect { false };
599 bool m_clipsToVisibleRect { false };
600 bool m_needsViewFrameInWindowCoordinates;
601 bool m_didScheduleWindowAndViewFrameUpdate { false };
602 bool m_windowOcclusionDetectionEnabled { true };
604 bool m_automaticallyAdjustsContentInsets { false };
605 CGFloat m_topContentInset { 0 };
606 bool m_didScheduleSetTopContentInset { false };
608 CGSize m_resizeScrollOffset { 0, 0 };
610 CGSize m_intrinsicContentSize { 0, 0 };
611 CGFloat m_overrideDeviceScaleFactor { 0 };
613 RetainPtr<WKViewLayoutStrategy> m_layoutStrategy;
614 WKLayoutMode m_lastRequestedLayoutMode { kWKLayoutModeViewSize };
615 CGFloat m_lastRequestedViewScale { 1 };
616 CGSize m_lastRequestedFixedLayoutSize { 0, 0 };
618 bool m_inSecureInputState { false };
619 RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
621 ValidationMap m_validationMap;
623 // The identifier of the plug-in we want to send complex text input to, or 0 if there is none.
624 uint64_t m_pluginComplexTextInputIdentifier { 0 };
626 // The state of complex text input for the plug-in.
627 PluginComplexTextInputState m_pluginComplexTextInputState { PluginComplexTextInputDisabled };
629 #if ENABLE(FULLSCREEN_API)
630 RetainPtr<WKFullScreenWindowController> m_fullScreenWindowController;
633 RetainPtr<WKWindowVisibilityObserver> m_windowVisibilityObserver;
635 bool m_shouldDeferViewInWindowChanges { false };
636 bool m_viewInWindowChangeWasDeferred { false };
637 NSWindow *m_targetWindowForMovePreparation { nullptr };
639 id m_flagsChangedEventMonitor { nullptr };
641 std::unique_ptr<WebCore::TextIndicatorWindow> m_textIndicatorWindow;
643 RetainPtr<NSColorSpace> m_colorSpace;
645 RetainPtr<NSEvent> m_lastMouseDownEvent;
646 RetainPtr<NSEvent> m_lastPressureEvent;
648 bool m_ignoresNonWheelEvents { false };
649 bool m_ignoresAllEvents { false };
650 bool m_ignoresMouseDraggedEvents { false };
652 RetainPtr<WKImmediateActionController> m_immediateActionController;
653 RetainPtr<NSImmediateActionGestureRecognizer> m_immediateActionGestureRecognizer;
655 bool m_allowsLinkPreview { true };
656 bool m_didRegisterForLookupPopoverCloseNotifications { false };
658 RetainPtr<NSTrackingArea> m_primaryTrackingArea;
660 NSToolTipTag m_lastToolTipTag { 0 };
661 id m_trackingRectOwner { nil };
662 void* m_trackingRectUserData { nullptr };
664 RetainPtr<CALayer> m_rootLayer;
665 RetainPtr<NSView> m_layerHostingView;
668 _WKThumbnailView *m_thumbnailView { nullptr };
670 RetainPtr<_WKRemoteObjectRegistry> m_remoteObjectRegistry;
672 RetainPtr<WKBrowsingContextController> m_browsingContextController;
675 std::unique_ptr<ViewGestureController> m_gestureController;
676 bool m_allowsBackForwardNavigationGestures { false };
677 bool m_allowsMagnification { false };
679 RetainPtr<id> m_remoteAccessibilityChild;
681 RefPtr<WebCore::Image> m_promisedImage;
682 String m_promisedFilename;
683 String m_promisedURL;
685 WTF::Optional<NSInteger> m_spellCheckerDocumentTag;
687 CGFloat m_totalHeightOfBanners { 0 };
689 RetainPtr<NSView> m_inspectorAttachmentView;
691 // We keep here the event when resending it to
692 // the application to distinguish the case of a new event from one
693 // that has been already sent to WebCore.
694 RetainPtr<NSEvent> m_keyDownEventBeingResent;
695 Vector<WebCore::KeypressCommand>* m_collectedKeypressCommands { nullptr };
697 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
698 String m_lastStringForCandidateRequest;
699 NSInteger m_lastCandidateRequestSequenceNumber;
701 NSRange m_softSpaceRange { NSNotFound, 0 };
702 bool m_isHandlingAcceptedCandidate { false };
703 bool m_requiresUserActionForEditingControlsManager { false };
704 bool m_editableElementIsFocused { false };
705 bool m_isTextInsertionReplacingSoftSpace { false };
708 } // namespace WebKit
710 #endif // PLATFORM(MAC)
712 #endif // WebViewImpl_h