<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[191757] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/191757">191757</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-10-29 15:07:42 -0700 (Thu, 29 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>WKView being inside WKWebView leads to weird API issues
https://bugs.webkit.org/show_bug.cgi?id=150174
Reviewed by Darin Adler.
* UIProcess/API/mac/WKView.mm:
(-[WKView browsingContextController]):
(-[WKView validateUserInterfaceItem:]):
(-[WKView saveBackForwardSnapshotForCurrentItem]):
(-[WKView saveBackForwardSnapshotForItem:]):
(-[WKView updateLayer]):
(-[WKView minimumSizeForAutoLayout]):
(-[WKView setMinimumSizeForAutoLayout:]):
(-[WKView shouldExpandToViewHeightForAutoLayout]):
(-[WKView setShouldExpandToViewHeightForAutoLayout:]):
(-[WKView underlayColor]):
(-[WKView setUnderlayColor:]):
(-[WKView _setOverlayScrollbarStyle:]):
(-[WKView _overlayScrollbarStyle]):
(-[WKView _pageExtendedBackgroundColor]):
(-[WKView forceAsyncDrawingAreaSizeUpdate:]):
(-[WKView waitForAsyncDrawingAreaSizeUpdate]):
(-[WKView isUsingUISideCompositing]):
(createSelectorExceptionMap): Deleted.
(commandNameForSelector): Deleted.
(menuItem): Deleted.
(toolbarItem): Deleted.
(-[WKView _setUserInterfaceItemState:enabled:state:]): Deleted.
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::createDrawingAreaProxy):
(WebKit::WebViewImpl::isUsingUISideCompositing):
(WebKit::WebViewImpl::forceAsyncDrawingAreaSizeUpdate):
(WebKit::WebViewImpl::waitForAsyncDrawingAreaSizeUpdate):
(WebKit::WebViewImpl::updateLayer):
(WebKit::WebViewImpl::setMinimumSizeForAutoLayout):
(WebKit::WebViewImpl::minimumSizeForAutoLayout):
(WebKit::WebViewImpl::setShouldExpandToViewHeightForAutoLayout):
(WebKit::WebViewImpl::shouldExpandToViewHeightForAutoLayout):
(WebKit::WebViewImpl::setUnderlayColor):
(WebKit::WebViewImpl::underlayColor):
(WebKit::WebViewImpl::pageExtendedBackgroundColor):
(WebKit::WebViewImpl::setOverlayScrollbarStyle):
(WebKit::WebViewImpl::overlayScrollbarStyle):
(WebKit::createSelectorExceptionMap):
(WebKit::commandNameForSelector):
(WebKit::WebViewImpl::executeSavedCommandBySelector):
(WebKit::WebViewImpl::executeEditCommandForSelector):
(WebKit::menuItem):
(WebKit::toolbarItem):
(WebKit::WebViewImpl::validateUserInterfaceItem):
(WebKit::WebViewImpl::setUserInterfaceItemState):
(WebKit::WebViewImpl::browsingContextController):
(WebKit::WebViewImpl::saveBackForwardSnapshotForCurrentItem):
(WebKit::WebViewImpl::saveBackForwardSnapshotForItem):
(WebKit::WebViewImpl::executeEditCommand): Deleted.
Move UI validation and a grab-bag of other things.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (191756 => 191757)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-10-29 21:54:24 UTC (rev 191756)
+++ trunk/Source/WebKit2/ChangeLog        2015-10-29 22:07:42 UTC (rev 191757)
</span><span class="lines">@@ -1,3 +1,63 @@
</span><ins>+2015-10-29 Tim Horton <timothy_horton@apple.com>
+
+ WKView being inside WKWebView leads to weird API issues
+ https://bugs.webkit.org/show_bug.cgi?id=150174
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView browsingContextController]):
+ (-[WKView validateUserInterfaceItem:]):
+ (-[WKView saveBackForwardSnapshotForCurrentItem]):
+ (-[WKView saveBackForwardSnapshotForItem:]):
+ (-[WKView updateLayer]):
+ (-[WKView minimumSizeForAutoLayout]):
+ (-[WKView setMinimumSizeForAutoLayout:]):
+ (-[WKView shouldExpandToViewHeightForAutoLayout]):
+ (-[WKView setShouldExpandToViewHeightForAutoLayout:]):
+ (-[WKView underlayColor]):
+ (-[WKView setUnderlayColor:]):
+ (-[WKView _setOverlayScrollbarStyle:]):
+ (-[WKView _overlayScrollbarStyle]):
+ (-[WKView _pageExtendedBackgroundColor]):
+ (-[WKView forceAsyncDrawingAreaSizeUpdate:]):
+ (-[WKView waitForAsyncDrawingAreaSizeUpdate]):
+ (-[WKView isUsingUISideCompositing]):
+ (createSelectorExceptionMap): Deleted.
+ (commandNameForSelector): Deleted.
+ (menuItem): Deleted.
+ (toolbarItem): Deleted.
+ (-[WKView _setUserInterfaceItemState:enabled:state:]): Deleted.
+ * UIProcess/Cocoa/WebViewImpl.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::createDrawingAreaProxy):
+ (WebKit::WebViewImpl::isUsingUISideCompositing):
+ (WebKit::WebViewImpl::forceAsyncDrawingAreaSizeUpdate):
+ (WebKit::WebViewImpl::waitForAsyncDrawingAreaSizeUpdate):
+ (WebKit::WebViewImpl::updateLayer):
+ (WebKit::WebViewImpl::setMinimumSizeForAutoLayout):
+ (WebKit::WebViewImpl::minimumSizeForAutoLayout):
+ (WebKit::WebViewImpl::setShouldExpandToViewHeightForAutoLayout):
+ (WebKit::WebViewImpl::shouldExpandToViewHeightForAutoLayout):
+ (WebKit::WebViewImpl::setUnderlayColor):
+ (WebKit::WebViewImpl::underlayColor):
+ (WebKit::WebViewImpl::pageExtendedBackgroundColor):
+ (WebKit::WebViewImpl::setOverlayScrollbarStyle):
+ (WebKit::WebViewImpl::overlayScrollbarStyle):
+ (WebKit::createSelectorExceptionMap):
+ (WebKit::commandNameForSelector):
+ (WebKit::WebViewImpl::executeSavedCommandBySelector):
+ (WebKit::WebViewImpl::executeEditCommandForSelector):
+ (WebKit::menuItem):
+ (WebKit::toolbarItem):
+ (WebKit::WebViewImpl::validateUserInterfaceItem):
+ (WebKit::WebViewImpl::setUserInterfaceItemState):
+ (WebKit::WebViewImpl::browsingContextController):
+ (WebKit::WebViewImpl::saveBackForwardSnapshotForCurrentItem):
+ (WebKit::WebViewImpl::saveBackForwardSnapshotForItem):
+ (WebKit::WebViewImpl::executeEditCommand): Deleted.
+ Move UI validation and a grab-bag of other things.
+
</ins><span class="cx"> 2015-10-29 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Fix Mac CMake build
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (191756 => 191757)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-10-29 21:54:24 UTC (rev 191756)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-10-29 22:07:42 UTC (rev 191757)
</span><span class="lines">@@ -106,7 +106,6 @@
</span><span class="cx"> #import <wtf/RunLoop.h>
</span><span class="cx">
</span><span class="cx"> /* API internals. */
</span><del>-#import "WKBrowsingContextControllerInternal.h"
</del><span class="cx"> #import "WKBrowsingContextGroupPrivate.h"
</span><span class="cx"> #import "WKProcessGroupPrivate.h"
</span><span class="cx">
</span><span class="lines">@@ -126,14 +125,6 @@
</span><span class="cx"> using namespace WebKit;
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><del>-namespace WebKit {
-
-typedef id <NSValidatedUserInterfaceItem> ValidationItem;
-typedef Vector<RetainPtr<ValidationItem>> ValidationVector;
-typedef HashMap<String, ValidationVector> ValidationMap;
-
-}
-
</del><span class="cx"> #if !USE(ASYNC_NSTEXTINPUTCLIENT)
</span><span class="cx"> struct WKViewInterpretKeyEventsParameters {
</span><span class="cx"> bool eventInterpretationHadSideEffects;
</span><span class="lines">@@ -149,13 +140,6 @@
</span><span class="cx"> RefPtr<WebPageProxy> _page;
</span><span class="cx"> std::unique_ptr<WebViewImpl> _impl;
</span><span class="cx">
</span><del>-#if WK_API_ENABLED
- RetainPtr<WKBrowsingContextController> _browsingContextController;
-#endif
-
- // For asynchronous validation.
- ValidationMap _validationMap;
-
</del><span class="cx"> // We keep here the event when resending it to
</span><span class="cx"> // the application to distinguish the case of a new event from one
</span><span class="cx"> // that has been already sent to WebCore.
</span><span class="lines">@@ -213,15 +197,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span><del>-
</del><span class="cx"> - (WKBrowsingContextController *)browsingContextController
</span><span class="cx"> {
</span><del>- if (!_data->_browsingContextController)
- _data->_browsingContextController = adoptNS([[WKBrowsingContextController alloc] _initWithPageRef:toAPI(_data->_page.get())]);
-
- return _data->_browsingContextController.get();
</del><ins>+ return _data->_impl->browsingContextController();
</ins><span class="cx"> }
</span><del>-
</del><span class="cx"> #endif // WK_API_ENABLED
</span><span class="cx">
</span><span class="cx"> - (void)setDrawsBackground:(BOOL)drawsBackground
</span><span class="lines">@@ -297,49 +276,8 @@
</span><span class="cx"> [super renewGState];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-typedef HashMap<SEL, String> SelectorNameMap;
</del><ins>+#define WEBCORE_COMMAND(command) - (void)command:(id)sender { _data->_impl->executeEditCommandForSelector(_cmd); }
</ins><span class="cx">
</span><del>-// Map selectors into Editor command names.
-// This is not needed for any selectors that have the same name as the Editor command.
-static const SelectorNameMap* createSelectorExceptionMap()
-{
- SelectorNameMap* map = new HashMap<SEL, String>;
-
- map->add(@selector(insertNewlineIgnoringFieldEditor:), "InsertNewline");
- map->add(@selector(insertParagraphSeparator:), "InsertNewline");
- map->add(@selector(insertTabIgnoringFieldEditor:), "InsertTab");
- map->add(@selector(pageDown:), "MovePageDown");
- map->add(@selector(pageDownAndModifySelection:), "MovePageDownAndModifySelection");
- map->add(@selector(pageUp:), "MovePageUp");
- map->add(@selector(pageUpAndModifySelection:), "MovePageUpAndModifySelection");
- map->add(@selector(scrollPageDown:), "ScrollPageForward");
- map->add(@selector(scrollPageUp:), "ScrollPageBackward");
-
- return map;
-}
-
-static String commandNameForSelector(SEL selector)
-{
- // Check the exception map first.
- static const SelectorNameMap* exceptionMap = createSelectorExceptionMap();
- SelectorNameMap::const_iterator it = exceptionMap->find(selector);
- if (it != exceptionMap->end())
- return it->value;
-
- // Remove the trailing colon.
- // No need to capitalize the command name since Editor command names are
- // not case sensitive.
- const char* selectorName = sel_getName(selector);
- size_t selectorNameLength = strlen(selectorName);
- if (selectorNameLength < 2 || selectorName[selectorNameLength - 1] != ':')
- return String();
- return String(selectorName, selectorNameLength - 1);
-}
-
-// Editing commands
-
-#define WEBCORE_COMMAND(command) - (void)command:(id)sender { _data->_impl->executeEditCommand(commandNameForSelector(_cmd)); }
-
</del><span class="cx"> WEBCORE_COMMAND(alignCenter)
</span><span class="cx"> WEBCORE_COMMAND(alignJustified)
</span><span class="cx"> WEBCORE_COMMAND(alignLeft)
</span><span class="lines">@@ -530,126 +468,9 @@
</span><span class="cx">
</span><span class="cx"> */
</span><span class="cx">
</span><del>-// Menu items validation
-
-static NSMenuItem *menuItem(id <NSValidatedUserInterfaceItem> item)
-{
- if (![(NSObject *)item isKindOfClass:[NSMenuItem class]])
- return nil;
- return (NSMenuItem *)item;
-}
-
-static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
-{
- if (![(NSObject *)item isKindOfClass:[NSToolbarItem class]])
- return nil;
- return (NSToolbarItem *)item;
-}
-
</del><span class="cx"> - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
</span><span class="cx"> {
</span><del>- SEL action = [item action];
-
- if (action == @selector(showGuessPanel:)) {
- if (NSMenuItem *menuItem = ::menuItem(item))
- [menuItem setTitle:contextMenuItemTagShowSpellingPanel(![[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible])];
- return _data->_page->editorState().isContentEditable;
- }
-
- if (action == @selector(checkSpelling:) || action == @selector(changeSpelling:))
- return _data->_page->editorState().isContentEditable;
-
- if (action == @selector(toggleContinuousSpellChecking:)) {
- bool enabled = TextChecker::isContinuousSpellCheckingAllowed();
- bool checked = enabled && TextChecker::state().isContinuousSpellCheckingEnabled;
- [menuItem(item) setState:checked ? NSOnState : NSOffState];
- return enabled;
- }
-
- if (action == @selector(toggleGrammarChecking:)) {
- bool checked = TextChecker::state().isGrammarCheckingEnabled;
- [menuItem(item) setState:checked ? NSOnState : NSOffState];
- return YES;
- }
-
- if (action == @selector(toggleAutomaticSpellingCorrection:)) {
- bool checked = TextChecker::state().isAutomaticSpellingCorrectionEnabled;
- [menuItem(item) setState:checked ? NSOnState : NSOffState];
- return _data->_page->editorState().isContentEditable;
- }
-
- if (action == @selector(orderFrontSubstitutionsPanel:)) {
- if (NSMenuItem *menuItem = ::menuItem(item))
- [menuItem setTitle:contextMenuItemTagShowSubstitutions(![[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])];
- return _data->_page->editorState().isContentEditable;
- }
-
- if (action == @selector(toggleSmartInsertDelete:)) {
- bool checked = _data->_page->isSmartInsertDeleteEnabled();
- [menuItem(item) setState:checked ? NSOnState : NSOffState];
- return _data->_page->editorState().isContentEditable;
- }
-
- if (action == @selector(toggleAutomaticQuoteSubstitution:)) {
- bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
- [menuItem(item) setState:checked ? NSOnState : NSOffState];
- return _data->_page->editorState().isContentEditable;
- }
-
- if (action == @selector(toggleAutomaticDashSubstitution:)) {
- bool checked = TextChecker::state().isAutomaticDashSubstitutionEnabled;
- [menuItem(item) setState:checked ? NSOnState : NSOffState];
- return _data->_page->editorState().isContentEditable;
- }
-
- if (action == @selector(toggleAutomaticLinkDetection:)) {
- bool checked = TextChecker::state().isAutomaticLinkDetectionEnabled;
- [menuItem(item) setState:checked ? NSOnState : NSOffState];
- return _data->_page->editorState().isContentEditable;
- }
-
- if (action == @selector(toggleAutomaticTextReplacement:)) {
- bool checked = TextChecker::state().isAutomaticTextReplacementEnabled;
- [menuItem(item) setState:checked ? NSOnState : NSOffState];
- return _data->_page->editorState().isContentEditable;
- }
-
- if (action == @selector(uppercaseWord:) || action == @selector(lowercaseWord:) || action == @selector(capitalizeWord:))
- return _data->_page->editorState().selectionIsRange && _data->_page->editorState().isContentEditable;
-
- if (action == @selector(stopSpeaking:))
- return [NSApp isSpeaking];
-
- // The centerSelectionInVisibleArea: selector is enabled if there's a selection range or if there's an insertion point in an editable area.
- if (action == @selector(centerSelectionInVisibleArea:))
- return _data->_page->editorState().selectionIsRange || (_data->_page->editorState().isContentEditable && !_data->_page->editorState().selectionIsNone);
-
- // Next, handle editor commands. Start by returning YES for anything that is not an editor command.
- // Returning YES is the default thing to do in an AppKit validate method for any selector that is not recognized.
- String commandName = commandNameForSelector([item action]);
- if (!Editor::commandIsSupportedFromMenuOrKeyBinding(commandName))
- return YES;
-
- // Add this item to the vector of items for a given command that are awaiting validation.
- ValidationMap::AddResult addResult = _data->_validationMap.add(commandName, ValidationVector());
- addResult.iterator->value.append(item);
- if (addResult.isNewEntry) {
- // If we are not already awaiting validation for this command, start the asynchronous validation process.
- // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
- // we asked for the same command; there is no guarantee the answer is still valid.
- _data->_page->validateCommand(commandName, [self](const String& commandName, bool isEnabled, int32_t state, WebKit::CallbackBase::Error error) {
- // If the process exits before the command can be validated, we'll be called back with an error.
- if (error != WebKit::CallbackBase::Error::None)
- return;
-
- [self _setUserInterfaceItemState:commandName enabled:isEnabled state:state];
- });
- }
-
- // Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called.
- // FIXME <rdar://problem/8803459>: This means disabled items will flash enabled at first for a moment.
- // But returning NO here would be worse; that would make keyboard commands such as command-C fail.
- return YES;
</del><ins>+ return _data->_impl->validateUserInterfaceItem(item);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (IBAction)startSpeaking:(id)sender
</span><span class="lines">@@ -2171,19 +1992,6 @@
</span><span class="cx"> _data->_impl->quickLookWithEvent(event);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState
-{
- ValidationVector items = _data->_validationMap.take(commandName);
- size_t size = items.size();
- for (size_t i = 0; i < size; ++i) {
- ValidationItem item = items[i].get();
- [menuItem(item) setState:newState];
- [menuItem(item) setEnabled:isEnabled];
- [toolbarItem(item) setEnabled:isEnabled];
- // FIXME <rdar://problem/8803392>: If the item is neither a menu nor toolbar item, it will be left enabled.
- }
-}
-
</del><span class="cx"> - (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled
</span><span class="cx"> {
</span><span class="cx"> if ([event type] != NSKeyDown)
</span><span class="lines">@@ -2325,12 +2133,12 @@
</span><span class="cx">
</span><span class="cx"> - (void)saveBackForwardSnapshotForCurrentItem
</span><span class="cx"> {
</span><del>- _data->_page->recordNavigationSnapshot();
</del><ins>+ _data->_impl->saveBackForwardSnapshotForCurrentItem();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)saveBackForwardSnapshotForItem:(WKBackForwardListItemRef)item
</span><span class="cx"> {
</span><del>- _data->_page->recordNavigationSnapshot(*toImpl(item));
</del><ins>+ _data->_impl->saveBackForwardSnapshotForItem(*toImpl(item));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef
</span><span class="lines">@@ -2363,19 +2171,7 @@
</span><span class="cx">
</span><span class="cx"> - (void)updateLayer
</span><span class="cx"> {
</span><del>- if ([self drawsBackground] && ![self drawsTransparentBackground])
- self.layer.backgroundColor = CGColorGetConstantColor(kCGColorWhite);
- else
- self.layer.backgroundColor = CGColorGetConstantColor(kCGColorClear);
-
- // If asynchronous geometry updates have been sent by forceAsyncDrawingAreaSizeUpdate,
- // then subsequent calls to setFrameSize should not result in us waiting for the did
- // udpate response if setFrameSize is called.
- if ([self frameSizeUpdatesDisabled])
- return;
-
- if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea())
- drawingArea->waitForPossibleGeometryUpdate();
</del><ins>+ _data->_impl->updateLayer();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (WKPageRef)pageRef
</span><span class="lines">@@ -2431,27 +2227,22 @@
</span><span class="cx">
</span><span class="cx"> - (NSSize)minimumSizeForAutoLayout
</span><span class="cx"> {
</span><del>- return _data->_page->minimumLayoutSize();
</del><ins>+ return NSSizeFromCGSize(_data->_impl->minimumSizeForAutoLayout());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)setMinimumSizeForAutoLayout:(NSSize)minimumSizeForAutoLayout
</span><span class="cx"> {
</span><del>- BOOL expandsToFit = minimumSizeForAutoLayout.width > 0;
-
- _data->_page->setMinimumLayoutSize(IntSize(minimumSizeForAutoLayout.width, minimumSizeForAutoLayout.height));
- _data->_page->setMainFrameIsScrollable(!expandsToFit);
-
- [self setShouldClipToVisibleRect:expandsToFit];
</del><ins>+ _data->_impl->setMinimumSizeForAutoLayout(NSSizeToCGSize(minimumSizeForAutoLayout));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)shouldExpandToViewHeightForAutoLayout
</span><span class="cx"> {
</span><del>- return _data->_page->autoSizingShouldExpandToViewHeight();
</del><ins>+ return _data->_impl->shouldExpandToViewHeightForAutoLayout();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)setShouldExpandToViewHeightForAutoLayout:(BOOL)shouldExpand
</span><span class="cx"> {
</span><del>- return _data->_page->setAutoSizingShouldExpandToViewHeight(shouldExpand);
</del><ins>+ return _data->_impl->setShouldExpandToViewHeightForAutoLayout(shouldExpand);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)shouldClipToVisibleRect
</span><span class="lines">@@ -2466,16 +2257,12 @@
</span><span class="cx">
</span><span class="cx"> - (NSColor *)underlayColor
</span><span class="cx"> {
</span><del>- Color webColor = _data->_page->underlayColor();
- if (!webColor.isValid())
- return nil;
-
- return nsColor(webColor);
</del><ins>+ return _data->_impl->underlayColor();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)setUnderlayColor:(NSColor *)underlayColor
</span><span class="cx"> {
</span><del>- _data->_page->setUnderlayColor(colorFromNSColor(underlayColor));
</del><ins>+ _data->_impl->setUnderlayColor(underlayColor);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="lines">@@ -2642,103 +2429,68 @@
</span><span class="cx"> return _data->_impl->totalHeightOfBanners();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_setOverlayScrollbarStyle:(_WKOverlayScrollbarStyle)scrollbarStyle
</del><ins>+static WTF::Optional<WebCore::ScrollbarOverlayStyle> toCoreScrollbarStyle(_WKOverlayScrollbarStyle scrollbarStyle)
</ins><span class="cx"> {
</span><del>- WTF::Optional<WebCore::ScrollbarOverlayStyle> coreScrollbarStyle;
-
</del><span class="cx"> switch (scrollbarStyle) {
</span><span class="cx"> case _WKOverlayScrollbarStyleDark:
</span><del>- coreScrollbarStyle = ScrollbarOverlayStyleDark;
- break;
</del><ins>+ return WebCore::ScrollbarOverlayStyleDark;
</ins><span class="cx"> case _WKOverlayScrollbarStyleLight:
</span><del>- coreScrollbarStyle = ScrollbarOverlayStyleLight;
- break;
</del><ins>+ return WebCore::ScrollbarOverlayStyleLight;
</ins><span class="cx"> case _WKOverlayScrollbarStyleDefault:
</span><del>- coreScrollbarStyle = ScrollbarOverlayStyleDefault;
- break;
</del><ins>+ return WebCore::ScrollbarOverlayStyleDefault;
</ins><span class="cx"> case _WKOverlayScrollbarStyleAutomatic:
</span><span class="cx"> default:
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- _data->_page->setOverlayScrollbarStyle(coreScrollbarStyle);
</del><ins>+ return Nullopt;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-- (_WKOverlayScrollbarStyle)_overlayScrollbarStyle
</del><ins>+static _WKOverlayScrollbarStyle toAPIScrollbarStyle(WTF::Optional<WebCore::ScrollbarOverlayStyle> coreScrollbarStyle)
</ins><span class="cx"> {
</span><del>- WTF::Optional<WebCore::ScrollbarOverlayStyle> coreScrollbarStyle = _data->_page->overlayScrollbarStyle();
-
</del><span class="cx"> if (!coreScrollbarStyle)
</span><span class="cx"> return _WKOverlayScrollbarStyleAutomatic;
</span><span class="cx">
</span><span class="cx"> switch (coreScrollbarStyle.value()) {
</span><del>- case ScrollbarOverlayStyleDark:
</del><ins>+ case WebCore::ScrollbarOverlayStyleDark:
</ins><span class="cx"> return _WKOverlayScrollbarStyleDark;
</span><del>- case ScrollbarOverlayStyleLight:
</del><ins>+ case WebCore::ScrollbarOverlayStyleLight:
</ins><span class="cx"> return _WKOverlayScrollbarStyleLight;
</span><del>- case ScrollbarOverlayStyleDefault:
</del><ins>+ case WebCore::ScrollbarOverlayStyleDefault:
</ins><span class="cx"> return _WKOverlayScrollbarStyleDefault;
</span><span class="cx"> default:
</span><span class="cx"> return _WKOverlayScrollbarStyleAutomatic;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (NSColor *)_pageExtendedBackgroundColor
</del><ins>+- (void)_setOverlayScrollbarStyle:(_WKOverlayScrollbarStyle)scrollbarStyle
</ins><span class="cx"> {
</span><del>- WebCore::Color color = _data->_page->pageExtendedBackgroundColor();
- if (!color.isValid())
- return nil;
</del><ins>+ _data->_impl->setOverlayScrollbarStyle(toCoreScrollbarStyle(scrollbarStyle));
+}
</ins><span class="cx">
</span><del>- return nsColor(color);
</del><ins>+- (_WKOverlayScrollbarStyle)_overlayScrollbarStyle
+{
+ return toAPIScrollbarStyle(_data->_impl->overlayScrollbarStyle());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wmissing-noreturn"
-// This method forces a drawing area geometry update, even if frame size updates are disabled.
-// The updated is performed asynchronously; we don't wait for the geometry update before returning.
-// The area drawn need not match the current frame size - if it differs it will be anchored to the
-// frame according to the current contentAnchor.
-- (void)forceAsyncDrawingAreaSizeUpdate:(NSSize)size
</del><ins>+- (NSColor *)_pageExtendedBackgroundColor
</ins><span class="cx"> {
</span><del>- // This SPI is only used on 10.9 and below, and is incompatible with the fence-based drawing area size synchronization in 10.10+.
-#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
- if (_data->_impl->clipsToVisibleRect())
- _data->_impl->updateViewExposedRect();
- _data->_impl->setDrawingAreaSize(NSSizeToCGSize(size));
</del><ins>+ return _data->_impl->pageExtendedBackgroundColor();
+}
</ins><span class="cx">
</span><del>- // If a geometry update is pending the new update won't be sent. Poll without waiting for any
- // pending did-update message now, such that the new update can be sent. We do so after setting
- // the drawing area size such that the latest update is sent.
- if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea())
- drawingArea->waitForPossibleGeometryUpdate(std::chrono::milliseconds::zero());
-#else
- ASSERT_NOT_REACHED();
-#endif
</del><ins>+- (void)forceAsyncDrawingAreaSizeUpdate:(NSSize)size
+{
+ _data->_impl->forceAsyncDrawingAreaSizeUpdate(NSSizeToCGSize(size));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)waitForAsyncDrawingAreaSizeUpdate
</span><span class="cx"> {
</span><del>- // This SPI is only used on 10.9 and below, and is incompatible with the fence-based drawing area size synchronization in 10.10+.
-#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
- if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea()) {
- // If a geometry update is still pending then the action of receiving the
- // first geometry update may result in another update being scheduled -
- // we should wait for this to complete too.
- drawingArea->waitForPossibleGeometryUpdate(DrawingAreaProxy::didUpdateBackingStoreStateTimeout() / 2);
- drawingArea->waitForPossibleGeometryUpdate(DrawingAreaProxy::didUpdateBackingStoreStateTimeout() / 2);
- }
-#else
- ASSERT_NOT_REACHED();
-#endif
</del><ins>+ _data->_impl->waitForAsyncDrawingAreaSizeUpdate();
</ins><span class="cx"> }
</span><del>-#pragma clang diagnostic pop
</del><span class="cx">
</span><span class="cx"> - (BOOL)isUsingUISideCompositing
</span><span class="cx"> {
</span><del>- if (DrawingAreaProxy* drawingArea = _data->_page->drawingArea())
- return drawingArea->type() == DrawingAreaTypeRemoteLayerTree;
-
- return NO;
</del><ins>+ return _data->_impl->isUsingUISideCompositing();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)setAllowsMagnification:(BOOL)allowsMagnification
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (191756 => 191757)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-10-29 21:54:24 UTC (rev 191756)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-10-29 22:07:42 UTC (rev 191757)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "PluginComplexTextInputState.h"
</span><span class="cx"> #include "WKLayoutMode.h"
</span><span class="cx"> #include "WebPageProxy.h"
</span><ins>+#include "_WKOverlayScrollbarStyle.h"
</ins><span class="cx"> #include <WebCore/TextIndicatorWindow.h>
</span><span class="cx"> #include <functional>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="lines">@@ -40,6 +41,7 @@
</span><span class="cx"> OBJC_CLASS NSImmediateActionGestureRecognizer;
</span><span class="cx"> OBJC_CLASS NSTextInputContext;
</span><span class="cx"> OBJC_CLASS NSView;
</span><ins>+OBJC_CLASS WKBrowsingContextController;
</ins><span class="cx"> OBJC_CLASS WKEditorUndoTargetObjC;
</span><span class="cx"> OBJC_CLASS WKFullScreenWindowController;
</span><span class="cx"> OBJC_CLASS WKImmediateActionController;
</span><span class="lines">@@ -80,6 +82,10 @@
</span><span class="cx"> class WebPageProxy;
</span><span class="cx"> struct ColorSpaceData;
</span><span class="cx">
</span><ins>+typedef id <NSValidatedUserInterfaceItem> ValidationItem;
+typedef Vector<RetainPtr<ValidationItem>> ValidationVector;
+typedef HashMap<String, ValidationVector> ValidationMap;
+
</ins><span class="cx"> class WebViewImpl {
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(WebViewImpl);
</span><span class="lines">@@ -119,7 +125,11 @@
</span><span class="cx"> CGSize fixedLayoutSize() const;
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy();
</span><ins>+ bool isUsingUISideCompositing() const;
</ins><span class="cx"> void setDrawingAreaSize(CGSize);
</span><ins>+ void forceAsyncDrawingAreaSizeUpdate(CGSize);
+ void waitForAsyncDrawingAreaSizeUpdate();
+ void updateLayer();
</ins><span class="cx">
</span><span class="cx"> void setAutomaticallyAdjustsContentInsets(bool);
</span><span class="cx"> bool automaticallyAdjustsContentInsets() const { return m_automaticallyAdjustsContentInsets; }
</span><span class="lines">@@ -132,6 +142,10 @@
</span><span class="cx"> void setClipsToVisibleRect(bool);
</span><span class="cx"> bool clipsToVisibleRect() const { return m_clipsToVisibleRect; }
</span><span class="cx">
</span><ins>+ void setMinimumSizeForAutoLayout(CGSize);
+ CGSize minimumSizeForAutoLayout() const;
+ void setShouldExpandToViewHeightForAutoLayout(bool);
+ bool shouldExpandToViewHeightForAutoLayout() const;
</ins><span class="cx"> void setIntrinsicContentSize(CGSize);
</span><span class="cx"> CGSize intrinsicContentSize() const;
</span><span class="cx">
</span><span class="lines">@@ -164,6 +178,13 @@
</span><span class="cx">
</span><span class="cx"> ColorSpaceData colorSpace();
</span><span class="cx">
</span><ins>+ void setUnderlayColor(NSColor *);
+ NSColor *underlayColor() const;
+ NSColor *pageExtendedBackgroundColor() const;
+
+ void setOverlayScrollbarStyle(WTF::Optional<WebCore::ScrollbarOverlayStyle> scrollbarStyle);
+ WTF::Optional<WebCore::ScrollbarOverlayStyle> overlayScrollbarStyle() const;
+
</ins><span class="cx"> void beginDeferringViewInWindowChanges();
</span><span class="cx"> // FIXME: Merge these two?
</span><span class="cx"> void endDeferringViewInWindowChanges();
</span><span class="lines">@@ -204,7 +225,8 @@
</span><span class="cx"> NSWindow *createFullScreenWindow();
</span><span class="cx">
</span><span class="cx"> bool isEditable() const;
</span><del>- void executeEditCommand(const String& commandName, const String& argument = String());
</del><ins>+ bool executeSavedCommandBySelector(SEL);
+ void executeEditCommandForSelector(SEL, const String& argument = String());
</ins><span class="cx"> void registerEditCommand(RefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
</span><span class="cx"> void clearAllEditCommands();
</span><span class="cx"> bool writeSelectionToPasteboard(NSPasteboard *, NSArray *types);
</span><span class="lines">@@ -212,6 +234,7 @@
</span><span class="cx"> void selectionDidChange();
</span><span class="cx"> void startObservingFontPanel();
</span><span class="cx"> void updateFontPanelIfNeeded();
</span><ins>+ bool validateUserInterfaceItem(id <NSValidatedUserInterfaceItem>);
</ins><span class="cx">
</span><span class="cx"> void preferencesDidChange();
</span><span class="cx">
</span><span class="lines">@@ -274,6 +297,8 @@
</span><span class="cx">
</span><span class="cx"> _WKRemoteObjectRegistry *remoteObjectRegistry();
</span><span class="cx"> void destroyRemoteObjectRegistry(); // FIXME: Temporary. Can fold in after we move ownership of WebPageProxy here.
</span><ins>+
+ WKBrowsingContextController *browsingContextController();
</ins><span class="cx"> #endif // WK_API_ENABLED
</span><span class="cx">
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="lines">@@ -302,6 +327,8 @@
</span><span class="cx"> NSArray *namesOfPromisedFilesDroppedAtDestination(NSURL *dropDestination);
</span><span class="cx">
</span><span class="cx"> RefPtr<ViewSnapshot> takeViewSnapshot();
</span><ins>+ void saveBackForwardSnapshotForCurrentItem();
+ void saveBackForwardSnapshotForItem(WebBackForwardListItem&);
</ins><span class="cx">
</span><span class="cx"> ViewGestureController* gestureController() { return m_gestureController.get(); }
</span><span class="cx"> ViewGestureController& ensureGestureController();
</span><span class="lines">@@ -329,8 +356,6 @@
</span><span class="cx"> void gestureEventWasNotHandledByWebCore(NSEvent *);
</span><span class="cx"> void gestureEventWasNotHandledByWebCoreFromViewOnly(NSEvent *);
</span><span class="cx">
</span><del>- bool executeSavedCommandBySelector(SEL);
-
</del><span class="cx"> void setTotalHeightOfBanners(CGFloat totalHeightOfBanners) { m_totalHeightOfBanners = totalHeightOfBanners; }
</span><span class="cx"> CGFloat totalHeightOfBanners() const { return m_totalHeightOfBanners; }
</span><span class="cx">
</span><span class="lines">@@ -351,6 +376,8 @@
</span><span class="cx"> void reparentLayerTreeInThumbnailView();
</span><span class="cx"> void updateThumbnailViewLayer();
</span><span class="cx">
</span><ins>+ void setUserInterfaceItemState(NSString *commandName, bool enabled, int state);
+
</ins><span class="cx"> NSView <WebViewImplDelegate> *m_view;
</span><span class="cx"> WebPageProxy& m_page;
</span><span class="cx"> PageClient& m_pageClient;
</span><span class="lines">@@ -385,6 +412,8 @@
</span><span class="cx"> bool m_inSecureInputState { false };
</span><span class="cx"> RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
</span><span class="cx">
</span><ins>+ ValidationMap m_validationMap;
+
</ins><span class="cx"> // The identifier of the plug-in we want to send complex text input to, or 0 if there is none.
</span><span class="cx"> uint64_t m_pluginComplexTextInputIdentifier { 0 };
</span><span class="cx">
</span><span class="lines">@@ -435,6 +464,8 @@
</span><span class="cx"> _WKThumbnailView *m_thumbnailView { nullptr };
</span><span class="cx">
</span><span class="cx"> RetainPtr<_WKRemoteObjectRegistry> m_remoteObjectRegistry;
</span><ins>+
+ RetainPtr<WKBrowsingContextController> m_browsingContextController;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<ViewGestureController> m_gestureController;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (191756 => 191757)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-10-29 21:54:24 UTC (rev 191756)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-10-29 22:07:42 UTC (rev 191757)
</span><span class="lines">@@ -41,8 +41,11 @@
</span><span class="cx"> #import "RemoteObjectRegistry.h"
</span><span class="cx"> #import "RemoteObjectRegistryMessages.h"
</span><span class="cx"> #import "StringUtilities.h"
</span><ins>+#import "TextChecker.h"
+#import "TextCheckerState.h"
</ins><span class="cx"> #import "TiledCoreAnimationDrawingAreaProxy.h"
</span><span class="cx"> #import "ViewGestureController.h"
</span><ins>+#import "WKBrowsingContextControllerInternal.h"
</ins><span class="cx"> #import "WKFullScreenWindowController.h"
</span><span class="cx"> #import "WKImmediateActionController.h"
</span><span class="cx"> #import "WKTextInputWindowController.h"
</span><span class="lines">@@ -57,11 +60,14 @@
</span><span class="cx"> #import "_WKThumbnailViewInternal.h"
</span><span class="cx"> #import <HIToolbox/CarbonEventsCore.h>
</span><span class="cx"> #import <WebCore/AXObjectCache.h>
</span><ins>+#import <WebCore/ColorMac.h>
</ins><span class="cx"> #import <WebCore/CoreGraphicsSPI.h>
</span><span class="cx"> #import <WebCore/DataDetectorsSPI.h>
</span><span class="cx"> #import <WebCore/DictionaryLookup.h>
</span><span class="cx"> #import <WebCore/DragData.h>
</span><ins>+#import <WebCore/Editor.h>
</ins><span class="cx"> #import <WebCore/KeypressCommand.h>
</span><ins>+#import <WebCore/LocalizedStrings.h>
</ins><span class="cx"> #import <WebCore/LookupSPI.h>
</span><span class="cx"> #import <WebCore/NSImmediateActionGestureRecognizerSPI.h>
</span><span class="cx"> #import <WebCore/NSWindowSPI.h>
</span><span class="lines">@@ -453,14 +459,6 @@
</span><span class="cx"> return m_view.window;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-std::unique_ptr<WebKit::DrawingAreaProxy> WebViewImpl::createDrawingAreaProxy()
-{
- if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"WebKit2UseRemoteLayerTreeDrawingArea"] boolValue])
- return std::make_unique<RemoteLayerTreeDrawingAreaProxy>(m_page);
-
- return std::make_unique<TiledCoreAnimationDrawingAreaProxy>(m_page);
-}
-
</del><span class="cx"> void WebViewImpl::processDidExit()
</span><span class="cx"> {
</span><span class="cx"> notifyInputContextAboutDiscardedComposition();
</span><span class="lines">@@ -682,6 +680,20 @@
</span><span class="cx"> return m_page.fixedLayoutSize();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+std::unique_ptr<WebKit::DrawingAreaProxy> WebViewImpl::createDrawingAreaProxy()
+{
+ if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"WebKit2UseRemoteLayerTreeDrawingArea"] boolValue])
+ return std::make_unique<RemoteLayerTreeDrawingAreaProxy>(m_page);
+
+ return std::make_unique<TiledCoreAnimationDrawingAreaProxy>(m_page);
+}
+
+bool WebViewImpl::isUsingUISideCompositing() const
+{
+ auto* drawingArea = m_page.drawingArea();
+ return drawingArea && drawingArea->type() == DrawingAreaTypeRemoteLayerTree;
+}
+
</ins><span class="cx"> void WebViewImpl::setDrawingAreaSize(CGSize size)
</span><span class="cx"> {
</span><span class="cx"> if (!m_page.drawingArea())
</span><span class="lines">@@ -691,6 +703,64 @@
</span><span class="cx"> m_resizeScrollOffset = CGSizeZero;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wmissing-noreturn"
+// This method forces a drawing area geometry update, even if frame size updates are disabled.
+// The updated is performed asynchronously; we don't wait for the geometry update before returning.
+// The area drawn need not match the current frame size - if it differs it will be anchored to the
+// frame according to the current contentAnchor.
+void WebViewImpl::forceAsyncDrawingAreaSizeUpdate(CGSize size)
+{
+ // This SPI is only used on 10.9 and below, and is incompatible with the fence-based drawing area size synchronization in 10.10+.
+#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
+ if (m_clipsToVisibleRect)
+ updateViewExposedRect();
+ setDrawingAreaSize(size);
+
+ // If a geometry update is pending the new update won't be sent. Poll without waiting for any
+ // pending did-update message now, such that the new update can be sent. We do so after setting
+ // the drawing area size such that the latest update is sent.
+ if (DrawingAreaProxy* drawingArea = m_page.drawingArea())
+ drawingArea->waitForPossibleGeometryUpdate(std::chrono::milliseconds::zero());
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
+void WebViewImpl::waitForAsyncDrawingAreaSizeUpdate()
+{
+ // This SPI is only used on 10.9 and below, and is incompatible with the fence-based drawing area size synchronization in 10.10+.
+#if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
+ if (DrawingAreaProxy* drawingArea = m_page.drawingArea()) {
+ // If a geometry update is still pending then the action of receiving the
+ // first geometry update may result in another update being scheduled -
+ // we should wait for this to complete too.
+ drawingArea->waitForPossibleGeometryUpdate(DrawingAreaProxy::didUpdateBackingStoreStateTimeout() / 2);
+ drawingArea->waitForPossibleGeometryUpdate(DrawingAreaProxy::didUpdateBackingStoreStateTimeout() / 2);
+ }
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+#pragma clang diagnostic pop
+
+void WebViewImpl::updateLayer()
+{
+ if (drawsBackground() && !drawsTransparentBackground())
+ m_view.layer.backgroundColor = CGColorGetConstantColor(kCGColorWhite);
+ else
+ m_view.layer.backgroundColor = CGColorGetConstantColor(kCGColorClear);
+
+ // If asynchronous geometry updates have been sent by forceAsyncDrawingAreaSizeUpdate,
+ // then subsequent calls to setFrameSize should not result in us waiting for the did
+ // udpate response if setFrameSize is called.
+ if (frameSizeUpdatesDisabled())
+ return;
+
+ if (DrawingAreaProxy* drawingArea = m_page.drawingArea())
+ drawingArea->waitForPossibleGeometryUpdate();
+}
+
</ins><span class="cx"> void WebViewImpl::setAutomaticallyAdjustsContentInsets(bool automaticallyAdjustsContentInsets)
</span><span class="cx"> {
</span><span class="cx"> m_automaticallyAdjustsContentInsets = automaticallyAdjustsContentInsets;
</span><span class="lines">@@ -763,6 +833,31 @@
</span><span class="cx"> updateViewExposedRect();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebViewImpl::setMinimumSizeForAutoLayout(CGSize minimumSizeForAutoLayout)
+{
+ bool expandsToFit = minimumSizeForAutoLayout.width > 0;
+
+ m_page.setMinimumLayoutSize(WebCore::IntSize(minimumSizeForAutoLayout));
+ m_page.setMainFrameIsScrollable(!expandsToFit);
+
+ setClipsToVisibleRect(expandsToFit);
+}
+
+CGSize WebViewImpl::minimumSizeForAutoLayout() const
+{
+ return m_page.minimumLayoutSize();
+}
+
+void WebViewImpl::setShouldExpandToViewHeightForAutoLayout(bool shouldExpandToViewHeightForAutoLayout)
+{
+ m_page.setAutoSizingShouldExpandToViewHeight(shouldExpandToViewHeightForAutoLayout);
+}
+
+bool WebViewImpl::shouldExpandToViewHeightForAutoLayout() const
+{
+ return m_page.autoSizingShouldExpandToViewHeight();
+}
+
</ins><span class="cx"> void WebViewImpl::setIntrinsicContentSize(CGSize intrinsicContentSize)
</span><span class="cx"> {
</span><span class="cx"> // If the intrinsic content size is less than the minimum layout width, the content flowed to fit,
</span><span class="lines">@@ -1052,6 +1147,39 @@
</span><span class="cx"> return colorSpaceData;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebViewImpl::setUnderlayColor(NSColor *underlayColor)
+{
+ m_page.setUnderlayColor(WebCore::colorFromNSColor(underlayColor));
+}
+
+NSColor *WebViewImpl::underlayColor() const
+{
+ WebCore::Color webColor = m_page.underlayColor();
+ if (!webColor.isValid())
+ return nil;
+
+ return WebCore::nsColor(webColor);
+}
+
+NSColor *WebViewImpl::pageExtendedBackgroundColor() const
+{
+ WebCore::Color color = m_page.pageExtendedBackgroundColor();
+ if (!color.isValid())
+ return nil;
+
+ return WebCore::nsColor(color);
+}
+
+void WebViewImpl::setOverlayScrollbarStyle(WTF::Optional<WebCore::ScrollbarOverlayStyle> scrollbarStyle)
+{
+ m_page.setOverlayScrollbarStyle(scrollbarStyle);
+}
+
+WTF::Optional<WebCore::ScrollbarOverlayStyle> WebViewImpl::overlayScrollbarStyle() const
+{
+ return m_page.overlayScrollbarStyle();
+}
+
</ins><span class="cx"> void WebViewImpl::beginDeferringViewInWindowChanges()
</span><span class="cx"> {
</span><span class="cx"> if (m_shouldDeferViewInWindowChanges) {
</span><span class="lines">@@ -1357,11 +1485,71 @@
</span><span class="cx"> return m_page.isEditable();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebViewImpl::executeEditCommand(const String& commandName, const String& argument)
</del><ins>+typedef HashMap<SEL, String> SelectorNameMap;
+
+// Map selectors into Editor command names.
+// This is not needed for any selectors that have the same name as the Editor command.
+static const SelectorNameMap& selectorExceptionMap()
</ins><span class="cx"> {
</span><del>- m_page.executeEditCommand(commandName, argument);
</del><ins>+ static NeverDestroyed<SelectorNameMap> map;
+
+ struct SelectorAndCommandName {
+ SEL selector;
+ ASCIILiteral commandName;
+ };
+
+ static const SelectorAndCommandName names[] = {
+ { @selector(insertNewlineIgnoringFieldEditor:), ASCIILiteral("InsertNewline") },
+ { @selector(insertParagraphSeparator:), ASCIILiteral("InsertNewline") },
+ { @selector(insertTabIgnoringFieldEditor:), ASCIILiteral("InsertTab") },
+ { @selector(pageDown:), ASCIILiteral("MovePageDown") },
+ { @selector(pageDownAndModifySelection:), ASCIILiteral("MovePageDownAndModifySelection") },
+ { @selector(pageUp:), ASCIILiteral("MovePageUp") },
+ { @selector(pageUpAndModifySelection:), ASCIILiteral("MovePageUpAndModifySelection") },
+ { @selector(scrollPageDown:), ASCIILiteral("ScrollPageForward") },
+ { @selector(scrollPageUp:), ASCIILiteral("ScrollPageBackward") }
+ };
+
+ for (auto& name : names)
+ map.get().add(name.selector, name.commandName);
+
+ return map;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+static String commandNameForSelector(SEL selector)
+{
+ // Check the exception map first.
+ static const SelectorNameMap& exceptionMap = selectorExceptionMap();
+ SelectorNameMap::const_iterator it = exceptionMap.find(selector);
+ if (it != exceptionMap.end())
+ return it->value;
+
+ // Remove the trailing colon.
+ // No need to capitalize the command name since Editor command names are
+ // not case sensitive.
+ const char* selectorName = sel_getName(selector);
+ size_t selectorNameLength = strlen(selectorName);
+ if (selectorNameLength < 2 || selectorName[selectorNameLength - 1] != ':')
+ return String();
+ return String(selectorName, selectorNameLength - 1);
+}
+
+bool WebViewImpl::executeSavedCommandBySelector(SEL selector)
+{
+ LOG(TextInput, "Executing previously saved command %s", sel_getName(selector));
+ // The sink does two things: 1) Tells us if the responder went unhandled, and
+ // 2) prevents any NSBeep; we don't ever want to beep here.
+ RetainPtr<WKResponderChainSink> sink = adoptNS([[WKResponderChainSink alloc] initWithResponderChain:m_view]);
+ [m_view _superDoCommandBySelector:selector];
+ [sink detach];
+ return ![sink didReceiveUnhandledCommand];
+}
+
+void WebViewImpl::executeEditCommandForSelector(SEL selector, const String& argument)
+{
+ m_page.executeEditCommand(commandNameForSelector(selector), argument);
+}
+
</ins><span class="cx"> void WebViewImpl::registerEditCommand(RefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
</span><span class="cx"> {
</span><span class="cx"> RefPtr<WebEditCommandProxy> command = prpCommand;
</span><span class="lines">@@ -1424,6 +1612,141 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static NSMenuItem *menuItem(id <NSValidatedUserInterfaceItem> item)
+{
+ if (![(NSObject *)item isKindOfClass:[NSMenuItem class]])
+ return nil;
+ return (NSMenuItem *)item;
+}
+
+static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
+{
+ if (![(NSObject *)item isKindOfClass:[NSToolbarItem class]])
+ return nil;
+ return (NSToolbarItem *)item;
+}
+
+bool WebViewImpl::validateUserInterfaceItem(id <NSValidatedUserInterfaceItem> item)
+{
+ SEL action = [item action];
+
+ if (action == @selector(showGuessPanel:)) {
+ if (NSMenuItem *menuItem = WebKit::menuItem(item))
+ [menuItem setTitle:WebCore::contextMenuItemTagShowSpellingPanel(![[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible])];
+ return m_page.editorState().isContentEditable;
+ }
+
+ if (action == @selector(checkSpelling:) || action == @selector(changeSpelling:))
+ return m_page.editorState().isContentEditable;
+
+ if (action == @selector(toggleContinuousSpellChecking:)) {
+ bool enabled = TextChecker::isContinuousSpellCheckingAllowed();
+ bool checked = enabled && TextChecker::state().isContinuousSpellCheckingEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return enabled;
+ }
+
+ if (action == @selector(toggleGrammarChecking:)) {
+ bool checked = TextChecker::state().isGrammarCheckingEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return true;
+ }
+
+ if (action == @selector(toggleAutomaticSpellingCorrection:)) {
+ bool checked = TextChecker::state().isAutomaticSpellingCorrectionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return m_page.editorState().isContentEditable;
+ }
+
+ if (action == @selector(orderFrontSubstitutionsPanel:)) {
+ if (NSMenuItem *menuItem = WebKit::menuItem(item))
+ [menuItem setTitle:WebCore::contextMenuItemTagShowSubstitutions(![[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])];
+ return m_page.editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleSmartInsertDelete:)) {
+ bool checked = m_page.isSmartInsertDeleteEnabled();
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return m_page.editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticQuoteSubstitution:)) {
+ bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return m_page.editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticDashSubstitution:)) {
+ bool checked = TextChecker::state().isAutomaticDashSubstitutionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return m_page.editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticLinkDetection:)) {
+ bool checked = TextChecker::state().isAutomaticLinkDetectionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return m_page.editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticTextReplacement:)) {
+ bool checked = TextChecker::state().isAutomaticTextReplacementEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return m_page.editorState().isContentEditable;
+ }
+
+ if (action == @selector(uppercaseWord:) || action == @selector(lowercaseWord:) || action == @selector(capitalizeWord:))
+ return m_page.editorState().selectionIsRange && m_page.editorState().isContentEditable;
+
+ if (action == @selector(stopSpeaking:))
+ return [NSApp isSpeaking];
+
+ // The centerSelectionInVisibleArea: selector is enabled if there's a selection range or if there's an insertion point in an editable area.
+ if (action == @selector(centerSelectionInVisibleArea:))
+ return m_page.editorState().selectionIsRange || (m_page.editorState().isContentEditable && !m_page.editorState().selectionIsNone);
+
+ // Next, handle editor commands. Start by returning true for anything that is not an editor command.
+ // Returning true is the default thing to do in an AppKit validate method for any selector that is not recognized.
+ String commandName = commandNameForSelector([item action]);
+ if (!WebCore::Editor::commandIsSupportedFromMenuOrKeyBinding(commandName))
+ return true;
+
+ // Add this item to the vector of items for a given command that are awaiting validation.
+ ValidationMap::AddResult addResult = m_validationMap.add(commandName, ValidationVector());
+ addResult.iterator->value.append(item);
+ if (addResult.isNewEntry) {
+ // If we are not already awaiting validation for this command, start the asynchronous validation process.
+ // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
+ // we asked for the same command; there is no guarantee the answer is still valid.
+ auto weakThis = createWeakPtr();
+ m_page.validateCommand(commandName, [weakThis](const String& commandName, bool isEnabled, int32_t state, WebKit::CallbackBase::Error error) {
+ if (!weakThis)
+ return;
+
+ // If the process exits before the command can be validated, we'll be called back with an error.
+ if (error != WebKit::CallbackBase::Error::None)
+ return;
+
+ weakThis->setUserInterfaceItemState(commandName, isEnabled, state);
+ });
+ }
+
+ // Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called.
+ // FIXME <rdar://problem/8803459>: This means disabled items will flash enabled at first for a moment.
+ // But returning NO here would be worse; that would make keyboard commands such as command-C fail.
+ return true;
+}
+
+void WebViewImpl::setUserInterfaceItemState(NSString *commandName, bool enabled, int state)
+{
+ ValidationVector items = m_validationMap.take(commandName);
+ for (auto& item : items) {
+ [menuItem(item.get()) setState:state];
+ [menuItem(item.get()) setEnabled:enabled];
+ [toolbarItem(item.get()) setEnabled:enabled];
+ // FIXME <rdar://problem/8803392>: If the item is neither a menu nor toolbar item, it will be left enabled.
+ }
+}
+
</ins><span class="cx"> void WebViewImpl::preferencesDidChange()
</span><span class="cx"> {
</span><span class="cx"> BOOL needsViewFrameInWindowCoordinates = m_page.preferences().pluginsEnabled();
</span><span class="lines">@@ -1908,6 +2231,14 @@
</span><span class="cx"> [m_remoteObjectRegistry _invalidate];
</span><span class="cx"> m_remoteObjectRegistry = nil;
</span><span class="cx"> }
</span><ins>+
+WKBrowsingContextController *WebViewImpl::browsingContextController()
+{
+ if (!m_browsingContextController)
+ m_browsingContextController = adoptNS([[WKBrowsingContextController alloc] _initWithPageRef:toAPI(&m_page)]);
+
+ return m_browsingContextController.get();
+}
</ins><span class="cx"> #endif // WK_API_ENABLED
</span><span class="cx">
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="lines">@@ -2294,6 +2625,16 @@
</span><span class="cx"> return ViewSnapshot::create(WTF::move(surface));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebViewImpl::saveBackForwardSnapshotForCurrentItem()
+{
+ m_page.recordNavigationSnapshot();
+}
+
+void WebViewImpl::saveBackForwardSnapshotForItem(WebBackForwardListItem& item)
+{
+ m_page.recordNavigationSnapshot(item);
+}
+
</ins><span class="cx"> ViewGestureController& WebViewImpl::ensureGestureController()
</span><span class="cx"> {
</span><span class="cx"> if (!m_gestureController)
</span><span class="lines">@@ -2488,17 +2829,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool WebViewImpl::executeSavedCommandBySelector(SEL selector)
-{
- LOG(TextInput, "Executing previously saved command %s", sel_getName(selector));
- // The sink does two things: 1) Tells us if the responder went unhandled, and
- // 2) prevents any NSBeep; we don't ever want to beep here.
- RetainPtr<WKResponderChainSink> sink = adoptNS([[WKResponderChainSink alloc] initWithResponderChain:m_view]);
- [m_view _superDoCommandBySelector:selector];
- [sink detach];
- return ![sink didReceiveUnhandledCommand];
-}
-
</del><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre>
</div>
</div>
</body>
</html>