<!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>[180465] trunk/Source</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/180465">180465</a></dd>
<dt>Author</dt> <dd>enrica@apple.com</dd>
<dt>Date</dt> <dd>2015-02-20 16:09:48 -0800 (Fri, 20 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WK2] Add support for font panel on OS X.
https://bugs.webkit.org/show_bug.cgi?id=141777
Reviewed by Tim Horton.
Source/WebCore:
This patch adds the necessary hooks to the Editor class to support
the font panel.
* editing/Editor.h:
* editing/mac/EditorMac.mm:
(WebCore::Editor::applyFontStyles):
Source/WebKit2:
This patch adds the necessary hooks to WKView to support
the font panel. It also includes refactoring of WebPage::editorState
and WebPageProxy::editorStateChanged to separate the different platform
specific tasks.
* Shared/EditorState.cpp:
(WebKit::EditorState::encode):
(WebKit::EditorState::decode):
* Shared/EditorState.h:
(WebKit::EditorState::EditorState):
* UIProcess/API/mac/WKView.mm:
(-[WKView _selectionChanged]):
(-[WKView changeFont:]):
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::editorStateChanged): Deleted.
* UIProcess/WebPageProxy.h:
* UIProcess/efl/WebPageProxyEfl.cpp:
(WebKit::WebPageProxy::editorStateChanged):
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::WebPageProxy::editorStateChanged):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::editorStateChanged):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::selectionDidChange):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::setFont):
(WebKit::WebPageProxy::editorStateChanged):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/efl/WebPageEfl.cpp:
(WebKit::WebPage::platformEditorState):
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::platformEditorState):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::platformEditorState):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformEditorState):
(WebKit::WebPage::setFont):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorh">trunk/Source/WebCore/editing/Editor.h</a></li>
<li><a href="#trunkSourceWebCoreeditingmacEditorMacmm">trunk/Source/WebCore/editing/mac/EditorMac.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedEditorStatecpp">trunk/Source/WebKit2/Shared/EditorState.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedEditorStateh">trunk/Source/WebKit2/Shared/EditorState.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewInternalh">trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcesseflWebPageProxyEflcpp">trunk/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWebPageProxyGtkcpp">trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWebPageProxyMacmm">trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageeflWebPageEflcpp">trunk/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkWebPageGtkcpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebCore/ChangeLog        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-02-20 Enrica Casucci <enrica@apple.com>
+
+ [WK2] Add support for font panel on OS X.
+ https://bugs.webkit.org/show_bug.cgi?id=141777
+
+ Reviewed by Tim Horton.
+
+ This patch adds the necessary hooks to the Editor class to support
+ the font panel.
+
+ * editing/Editor.h:
+ * editing/mac/EditorMac.mm:
+ (WebCore::Editor::applyFontStyles):
+
</ins><span class="cx"> 2015-02-20 Zalan Bujtas <zalan@apple.com>
</span><span class="cx">
</span><span class="cx"> Invalid assert in CompositeEditCommand::insertNodeAfter/insertNodeBefore
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.h (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.h        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebCore/editing/Editor.h        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -432,6 +432,7 @@
</span><span class="cx"> WEBCORE_EXPORT void readSelectionFromPasteboard(const String& pasteboardName, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
</span><span class="cx"> WEBCORE_EXPORT void replaceNodeFromPasteboard(Node*, const String& pasteboardName);
</span><span class="cx"> WEBCORE_EXPORT PassRefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName);
</span><ins>+ WEBCORE_EXPORT void applyFontStyles(const String& fontFamily, double fontSize, unsigned fontTraits);
</ins><span class="cx"> #endif // !PLATFORM(IOS)
</span><span class="cx"> WEBCORE_EXPORT void replaceSelectionWithAttributedString(NSAttributedString *, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingmacEditorMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/mac/EditorMac.mm        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -27,6 +27,8 @@
</span><span class="cx"> #import "Editor.h"
</span><span class="cx">
</span><span class="cx"> #import "BlockExceptions.h"
</span><ins>+#import "CSSPrimitiveValueMappings.h"
+#import "CSSValuePool.h"
</ins><span class="cx"> #import "CachedResourceLoader.h"
</span><span class="cx"> #import "ColorMac.h"
</span><span class="cx"> #import "DOMRangeInternal.h"
</span><span class="lines">@@ -681,4 +683,14 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void Editor::applyFontStyles(const String& fontFamily, double fontSize, unsigned fontTraits)
+{
+ Ref<MutableStyleProperties> style = MutableStyleProperties::create();
+ style->setProperty(CSSPropertyFontFamily, cssValuePool().createFontFamilyValue(fontFamily));
+ style->setProperty(CSSPropertyFontStyle, (fontTraits & NSFontItalicTrait) ? CSSValueItalic : CSSValueNormal);
+ style->setProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontTraits & NSFontBoldTrait ? FontWeightBold : FontWeightNormal));
+ style->setProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPrimitiveValue::CSS_PX));
+ applyStyleToSelection(style.ptr(), EditActionSetFont);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/ChangeLog        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2015-02-20 Enrica Casucci <enrica@apple.com>
+
+ [WK2] Add support for font panel on OS X.
+ https://bugs.webkit.org/show_bug.cgi?id=141777
+
+ Reviewed by Tim Horton.
+
+ This patch adds the necessary hooks to WKView to support
+ the font panel. It also includes refactoring of WebPage::editorState
+ and WebPageProxy::editorStateChanged to separate the different platform
+ specific tasks.
+
+ * Shared/EditorState.cpp:
+ (WebKit::EditorState::encode):
+ (WebKit::EditorState::decode):
+ * Shared/EditorState.h:
+ (WebKit::EditorState::EditorState):
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _selectionChanged]):
+ (-[WKView changeFont:]):
+ * UIProcess/API/mac/WKViewInternal.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::editorStateChanged): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/efl/WebPageProxyEfl.cpp:
+ (WebKit::WebPageProxy::editorStateChanged):
+ * UIProcess/gtk/WebPageProxyGtk.cpp:
+ (WebKit::WebPageProxy::editorStateChanged):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::editorStateChanged):
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::selectionDidChange):
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::setFont):
+ (WebKit::WebPageProxy::editorStateChanged):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::editorState):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/efl/WebPageEfl.cpp:
+ (WebKit::WebPage::platformEditorState):
+ * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+ (WebKit::WebPage::platformEditorState):
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::platformEditorState):
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::platformEditorState):
+ (WebKit::WebPage::setFont):
+
</ins><span class="cx"> 2015-02-20 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> [WK2] Add more detailed diagnostic logging for measuring network cache efficacy
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEditorStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EditorState.cpp (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EditorState.cpp        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/Shared/EditorState.cpp        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -42,6 +42,12 @@
</span><span class="cx"> encoder << isInPlugin;
</span><span class="cx"> encoder << hasComposition;
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC)
+ encoder << fontName;
+ encoder << fontSize;
+ encoder << selectionHasMultipleFonts;
+#endif
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> encoder << isReplaceAllowed;
</span><span class="cx"> encoder << hasContent;
</span><span class="lines">@@ -90,6 +96,17 @@
</span><span class="cx"> if (!decoder.decode(result.hasComposition))
</span><span class="cx"> return false;
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC)
+ if (!decoder.decode(result.fontName))
+ return false;
+
+ if (!decoder.decode(result.fontSize))
+ return false;
+
+ if (!decoder.decode(result.selectionHasMultipleFonts))
+ return false;
+#endif
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> if (!decoder.decode(result.isReplaceAllowed))
</span><span class="cx"> return false;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEditorStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EditorState.h (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EditorState.h        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/Shared/EditorState.h        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -53,6 +53,10 @@
</span><span class="cx"> , isInPasswordField(false)
</span><span class="cx"> , isInPlugin(false)
</span><span class="cx"> , hasComposition(false)
</span><ins>+#if PLATFORM(MAC)
+ , selectionHasMultipleFonts(false)
+ , fontSize(0)
+#endif
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> , isReplaceAllowed(false)
</span><span class="cx"> , hasContent(false)
</span><span class="lines">@@ -75,6 +79,12 @@
</span><span class="cx"> bool isInPlugin;
</span><span class="cx"> bool hasComposition;
</span><span class="cx">
</span><ins>+#if PLATFORM(MAC)
+ bool selectionHasMultipleFonts;
+ String fontName;
+ double fontSize;
+#endif
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> bool isReplaceAllowed;
</span><span class="cx"> bool hasContent;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -737,6 +737,26 @@
</span><span class="cx"> return _data->_page->readSelectionFromPasteboard([pasteboard name]);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// Font panel support.
+
+- (void)_selectionChanged
+{
+ const EditorState& editorState = _data->_page->editorState();
+ if (editorState.selectionIsNone || !editorState.isContentEditable)
+ return;
+ NSFont *font = [NSFont fontWithName:editorState.fontName size:editorState.fontSize];
+ [[NSFontManager sharedFontManager] setSelectedFont:font isMultiple:editorState.selectionHasMultipleFonts];
+}
+
+- (void)changeFont:(id)sender
+{
+ NSFontManager *fontManager = [NSFontManager sharedFontManager];
+ NSFont *font = [fontManager convertFont:[fontManager selectedFont]];
+ if (!font)
+ return;
+ _data->_page->setFont([font familyName], [font pointSize], [[font fontDescriptor] symbolicTraits]);
+}
+
</ins><span class="cx"> /*
</span><span class="cx">
</span><span class="cx"> When possible, editing-related methods should be implemented in WebCore with the
</span><span class="lines">@@ -745,7 +765,6 @@
</span><span class="cx">
</span><span class="cx"> Editing-related methods still unimplemented that are implemented in WebKit1:
</span><span class="cx">
</span><del>-- (void)changeFont:(id)sender;
</del><span class="cx"> - (void)complete:(id)sender;
</span><span class="cx"> - (void)copyFont:(id)sender;
</span><span class="cx"> - (void)makeBaseWritingDirectionLeftToRight:(id)sender;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -87,6 +87,7 @@
</span><span class="cx"> - (NSRect)_convertToUserSpace:(NSRect)rect;
</span><span class="cx"> - (void)_setTextIndicator:(PassRefPtr<WebCore::TextIndicator>)textIndicator fadeOut:(BOOL)fadeOut;
</span><span class="cx"> - (void)_setTextIndicatorAnimationProgress:(float)progress;
</span><ins>+- (void)_selectionChanged;
</ins><span class="cx">
</span><span class="cx"> - (void)_setAcceleratedCompositingModeRootLayer:(CALayer *)rootLayer;
</span><span class="cx"> - (CALayer *)_acceleratedCompositingModeRootLayer;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -181,6 +181,7 @@
</span><span class="cx"> virtual LayerOrView *acceleratedCompositingRootLayer() const = 0;
</span><span class="cx"> virtual PassRefPtr<ViewSnapshot> takeViewSnapshot() = 0;
</span><span class="cx"> virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) = 0;
</span><ins>+ virtual void selectionDidChange() = 0;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
</span><span class="lines">@@ -268,7 +269,6 @@
</span><span class="cx"> virtual void startAssistingNode(const AssistedNodeInformation&, bool userIsInteracting, bool blurPreviousNode, API::Object* userData) = 0;
</span><span class="cx"> virtual void stopAssistingNode() = 0;
</span><span class="cx"> virtual bool isAssistingNode() = 0;
</span><del>- virtual void selectionDidChange() = 0;
</del><span class="cx"> virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, bool isCharEvent) = 0;
</span><span class="cx"> virtual void positionInformationDidChange(const InteractionInformationAtPosition&) = 0;
</span><span class="cx"> virtual void saveImageToLibrary(PassRefPtr<WebCore::SharedBuffer>) = 0;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -3758,50 +3758,6 @@
</span><span class="cx"> count = m_backForwardList->forwardListCount();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void WebPageProxy::editorStateChanged(const EditorState& editorState)
-{
-#if PLATFORM(COCOA)
- bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
-#endif
-#if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
- bool closedComposition = !editorState.shouldIgnoreCompositionSelectionChange && !editorState.hasComposition && (m_editorState.hasComposition || m_temporarilyClosedComposition);
- m_temporarilyClosedComposition = editorState.shouldIgnoreCompositionSelectionChange && (m_temporarilyClosedComposition || m_editorState.hasComposition) && !editorState.hasComposition;
- bool editabilityChanged = m_editorState.isContentEditable != editorState.isContentEditable;
-#endif
-
- m_editorState = editorState;
-
-#if PLATFORM(COCOA)
- // Selection being none is a temporary state when editing. Flipping secure input state too quickly was causing trouble (not fully understood).
- if (couldChangeSecureInputState && !editorState.selectionIsNone)
- m_pageClient.updateSecureInputState();
-#endif
-
- if (editorState.shouldIgnoreCompositionSelectionChange)
- return;
-
-#if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
- if (closedComposition)
- m_pageClient.notifyInputContextAboutDiscardedComposition();
- if (editabilityChanged) {
- // This is only needed in sync code path, because AppKit automatically refreshes input context for async clients (<rdar://problem/18604360>).
- m_pageClient.notifyApplicationAboutInputContextChange();
- }
- if (editorState.hasComposition) {
- // Abandon the current inline input session if selection changed for any other reason but an input method changing the composition.
- // FIXME: This logic should be in WebCore, no need to round-trip to UI process to cancel the composition.
- cancelComposition();
- m_pageClient.notifyInputContextAboutDiscardedComposition();
- }
-#elif PLATFORM(IOS)
- // We always need to notify the client on iOS to make sure the selection is redrawn,
- // even during composition to support phrase boundary gesture.
- notifyRevealedSelection();
-#elif PLATFORM(EFL) || PLATFORM(GTK)
- m_pageClient.updateTextInputState();
-#endif
-}
-
</del><span class="cx"> void WebPageProxy::compositionWasCanceled(const EditorState& editorState)
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -538,6 +538,7 @@
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> void insertDictatedTextAsync(const String& text, const EditingRange& replacementRange, const Vector<WebCore::TextAlternativeWithRange>& dictationAlternatives, bool registerUndoGroup);
</span><span class="cx"> void attributedSubstringForCharacterRangeAsync(const EditingRange&, std::function<void (const AttributedString&, const EditingRange&, CallbackBase::Error)>);
</span><ins>+ void setFont(const String& fontFamily, double fontSize, uint64_t fontTraits);
</ins><span class="cx">
</span><span class="cx"> #if !USE(ASYNC_NSTEXTINPUTCLIENT)
</span><span class="cx"> bool insertText(const String& text, const EditingRange& replacementRange);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcesseflWebPageProxyEflcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -83,6 +83,15 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPageProxy::editorStateChanged(const EditorState& editorState)
+{
+ m_editorState = editorState;
+
+ if (editorState.shouldIgnoreCompositionSelectionChange)
+ return;
+ m_pageClient.updateTextInputState();
+}
+
</ins><span class="cx"> void WebPageProxy::setThemePath(const String& themePath)
</span><span class="cx"> {
</span><span class="cx"> if (!isValid())
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkWebPageProxyGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -76,6 +76,15 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPageProxy::editorStateChanged(const EditorState& editorState)
+{
+ m_editorState = editorState;
+
+ if (editorState.shouldIgnoreCompositionSelectionChange)
+ return;
+ m_pageClient.updateTextInputState();
+}
+
</ins><span class="cx"> #if PLUGIN_ARCHITECTURE(X11)
</span><span class="cx"> typedef HashMap<uint64_t, GtkWidget* > PluginWindowMap;
</span><span class="cx"> static PluginWindowMap& pluginWindowMap()
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -884,6 +884,24 @@
</span><span class="cx"> process().send(Messages::WebPage::ContentSizeCategoryDidChange(contentSizeCategory), m_pageID);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPageProxy::editorStateChanged(const EditorState& editorState)
+{
+ bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
+
+ m_editorState = editorState;
+
+ // Selection being none is a temporary state when editing. Flipping secure input state too quickly was causing trouble (not fully understood).
+ if (couldChangeSecureInputState && !editorState.selectionIsNone)
+ m_pageClient.updateSecureInputState();
+
+ if (editorState.shouldIgnoreCompositionSelectionChange)
+ return;
+
+ // We always need to notify the client on iOS to make sure the selection is redrawn,
+ // even during composition to support phrase boundary gesture.
+ notifyRevealedSelection();
+}
+
</ins><span class="cx"> #if USE(QUICK_LOOK)
</span><span class="cx">
</span><span class="cx"> void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx"> virtual void updateSecureInputState() override;
</span><span class="cx"> virtual void resetSecureInputState() override;
</span><span class="cx"> virtual void notifyInputContextAboutDiscardedComposition() override;
</span><ins>+ virtual void selectionDidChange();
</ins><span class="cx"> #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
</span><span class="cx"> virtual void notifyApplicationAboutInputContextChange() override;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -531,6 +531,11 @@
</span><span class="cx"> return [m_wkView _takeViewSnapshot];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void PageClientImpl::selectionDidChange()
+{
+ [m_wkView _selectionChanged];
+}
+
</ins><span class="cx"> void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
</span><span class="cx"> {
</span><span class="cx"> [m_wkView _wheelEventWasNotHandledByWebCore:event.nativeEvent()];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWebPageProxyMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -665,7 +665,51 @@
</span><span class="cx"> {
</span><span class="cx"> return applicationIsAppleMail();
</span><span class="cx"> }
</span><ins>+
+void WebPageProxy::setFont(const String& fontFamily, double fontSize, uint64_t fontTraits)
+{
+ if (!isValid())
+ return;
+
+ process().send(Messages::WebPage::SetFont(fontFamily, fontSize, fontTraits), m_pageID);
+}
+
+void WebPageProxy::editorStateChanged(const EditorState& editorState)
+{
+ bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
+#if !USE(ASYNC_NSTEXTINPUTCLIENT)
+ bool closedComposition = !editorState.shouldIgnoreCompositionSelectionChange && !editorState.hasComposition && (m_editorState.hasComposition || m_temporarilyClosedComposition);
+ m_temporarilyClosedComposition = editorState.shouldIgnoreCompositionSelectionChange && (m_temporarilyClosedComposition || m_editorState.hasComposition) && !editorState.hasComposition;
+ bool editabilityChanged = m_editorState.isContentEditable != editorState.isContentEditable;
+#endif
</ins><span class="cx">
</span><ins>+ m_editorState = editorState;
+
+ // Selection being none is a temporary state when editing. Flipping secure input state too quickly was causing trouble (not fully understood).
+ if (couldChangeSecureInputState && !editorState.selectionIsNone)
+ m_pageClient.updateSecureInputState();
+
+ if (editorState.shouldIgnoreCompositionSelectionChange)
+ return;
+
+ m_pageClient.selectionDidChange();
+
+#if !USE(ASYNC_NSTEXTINPUTCLIENT)
+ if (closedComposition)
+ m_pageClient.notifyInputContextAboutDiscardedComposition();
+ if (editabilityChanged) {
+ // This is only needed in sync code path, because AppKit automatically refreshes input context for async clients (<rdar://problem/18604360>).
+ m_pageClient.notifyApplicationAboutInputContextChange();
+ }
+ if (editorState.hasComposition) {
+ // Abandon the current inline input session if selection changed for any other reason but an input method changing the composition.
+ // FIXME: This logic should be in WebCore, no need to round-trip to UI process to cancel the composition.
+ cancelComposition();
+ m_pageClient.notifyInputContextAboutDiscardedComposition();
+ }
+#endif
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -764,77 +764,9 @@
</span><span class="cx"> result.isInPasswordField = selection.isInPasswordField();
</span><span class="cx"> result.hasComposition = frame.editor().hasComposition();
</span><span class="cx"> result.shouldIgnoreCompositionSelectionChange = frame.editor().ignoreCompositionSelectionChange();
</span><ins>+
+ platformEditorState(frame, result);
</ins><span class="cx">
</span><del>-#if PLATFORM(IOS)
- if (frame.editor().hasComposition()) {
- RefPtr<Range> compositionRange = frame.editor().compositionRange();
- Vector<WebCore::SelectionRect> compositionRects;
- compositionRange->collectSelectionRects(compositionRects);
- if (compositionRects.size())
- result.firstMarkedRect = compositionRects[0].rect();
- if (compositionRects.size() > 1)
- result.lastMarkedRect = compositionRects.last().rect();
- else
- result.lastMarkedRect = result.firstMarkedRect;
- result.markedText = plainTextReplacingNoBreakSpace(compositionRange.get());
- }
- FrameView* view = frame.view();
- if (selection.isCaret()) {
- result.caretRectAtStart = view->contentsToRootView(frame.selection().absoluteCaretBounds());
- result.caretRectAtEnd = result.caretRectAtStart;
- // FIXME: The following check should take into account writing direction.
- result.isReplaceAllowed = result.isContentEditable && atBoundaryOfGranularity(selection.start(), WordGranularity, DirectionForward);
- result.wordAtSelection = plainTextReplacingNoBreakSpace(wordRangeFromPosition(selection.start()).get());
- if (selection.isContentEditable()) {
- charactersAroundPosition(selection.start(), result.characterAfterSelection, result.characterBeforeSelection, result.twoCharacterBeforeSelection);
- Node* root = selection.rootEditableElement();
- result.hasContent = root && root->hasChildNodes() && !isEndOfEditableOrNonEditableContent(firstPositionInNode(root));
- }
- } else if (selection.isRange()) {
- result.caretRectAtStart = view->contentsToRootView(VisiblePosition(selection.start()).absoluteCaretBounds());
- result.caretRectAtEnd = view->contentsToRootView(VisiblePosition(selection.end()).absoluteCaretBounds());
- RefPtr<Range> selectedRange = selection.toNormalizedRange();
- selectedRange->collectSelectionRects(result.selectionRects);
- convertSelectionRectsToRootView(view, result.selectionRects);
- String selectedText = plainTextReplacingNoBreakSpace(selectedRange.get(), TextIteratorDefaultBehavior, true);
- // FIXME: We should disallow replace when the string contains only CJ characters.
- result.isReplaceAllowed = result.isContentEditable && !result.isInPasswordField && !selectedText.containsOnlyWhitespace();
- result.selectedTextLength = selectedText.length();
- const int maxSelectedTextLength = 200;
- if (selectedText.length() <= maxSelectedTextLength)
- result.wordAtSelection = selectedText;
- }
- if (!selection.isNone()) {
- Node* nodeToRemove;
- if (RenderStyle* style = Editor::styleForSelectionStart(&frame, nodeToRemove)) {
- CTFontRef font = style->fontCascade().primaryFont().getCTFont();
- CTFontSymbolicTraits traits = font ? CTFontGetSymbolicTraits(font) : 0;
-
- if (traits & kCTFontTraitBold)
- result.typingAttributes |= AttributeBold;
- if (traits & kCTFontTraitItalic)
- result.typingAttributes |= AttributeItalics;
-
- RefPtr<EditingStyle> typingStyle = frame.selection().typingStyle();
- if (typingStyle && typingStyle->style()) {
- String value = typingStyle->style()->getPropertyValue(CSSPropertyWebkitTextDecorationsInEffect);
- if (value.contains("underline"))
- result.typingAttributes |= AttributeUnderline;
- } else {
- if (style->textDecorationsInEffect() & TextDecorationUnderline)
- result.typingAttributes |= AttributeUnderline;
- }
-
- if (nodeToRemove)
- nodeToRemove->remove(ASSERT_NO_EXCEPTION);
- }
- }
-#endif
-
-#if PLATFORM(GTK)
- result.cursorRect = frame.selection().absoluteCaretBounds();
-#endif
-
</del><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -872,6 +872,7 @@
</span><span class="cx">
</span><span class="cx"> void platformInitialize();
</span><span class="cx"> void platformDetach();
</span><ins>+ void platformEditorState(WebCore::Frame&, EditorState& result) const;
</ins><span class="cx">
</span><span class="cx"> void didReceiveWebPageMessage(IPC::Connection&, IPC::MessageDecoder&);
</span><span class="cx"> void didReceiveSyncWebPageMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
</span><span class="lines">@@ -1082,6 +1083,7 @@
</span><span class="cx"> PassRefPtr<WebCore::Range> lookupTextAtLocation(WebCore::FloatPoint, NSDictionary **options);
</span><span class="cx"> void selectLastActionMenuRange();
</span><span class="cx"> void focusAndSelectLastActionMenuHitTestResult();
</span><ins>+ void setFont(const String& fontFamily, double fontSize, uint64_t fontTraits);
</ins><span class="cx">
</span><span class="cx"> void dataDetectorsDidPresentUI(WebCore::PageOverlay::PageOverlayID);
</span><span class="cx"> void dataDetectorsDidChangeUI(WebCore::PageOverlay::PageOverlayID);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -166,6 +166,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> PerformDictionaryLookupOfCurrentSelection()
</span><ins>+ SetFont(String fontFamily, double fontSize, uint64_t fontTraits)
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> PreferencesDidChange(struct WebKit::WebPreferencesStore store)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageeflWebPageEflcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/WebProcess/WebPage/efl/WebPageEfl.cpp        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -82,6 +82,10 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPage::platformEditorState(Frame&, EditorState&) const
+{
+}
+
</ins><span class="cx"> bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
</span><span class="cx"> {
</span><span class="cx"> if (keyboardEvent.type() != WebEvent::KeyDown && keyboardEvent.type() != WebEvent::RawKeyDown)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkWebPageGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "WebPage.h"
</span><span class="cx">
</span><ins>+#include "EditorState.h"
</ins><span class="cx"> #include "NotImplemented.h"
</span><span class="cx"> #include "WebEvent.h"
</span><span class="cx"> #include "WebPageAccessibilityObject.h"
</span><span class="lines">@@ -67,6 +68,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPage::platformEditorState(Frame& frame, EditorState& result) const
+{
+ result.cursorRect = frame.selection().absoluteCaretBounds();
+}
+
</ins><span class="cx"> #if HAVE(ACCESSIBILITY)
</span><span class="cx"> void WebPage::updateAccessibilityTree()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -86,6 +86,7 @@
</span><span class="cx"> #import <WebCore/RenderThemeIOS.h>
</span><span class="cx"> #import <WebCore/RenderView.h>
</span><span class="cx"> #import <WebCore/SharedBuffer.h>
</span><ins>+#import <WebCore/StyleProperties.h>
</ins><span class="cx"> #import <WebCore/TextIterator.h>
</span><span class="cx"> #import <WebCore/VisibleUnits.h>
</span><span class="cx"> #import <WebCore/WKContentObservation.h>
</span><span class="lines">@@ -127,6 +128,74 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPage::platformEditorState(Frame& frame, EditorState& result) const
+{
+ const VisibleSelection& selection = frame.selection().selection();
+ if (frame.editor().hasComposition()) {
+ RefPtr<Range> compositionRange = frame.editor().compositionRange();
+ Vector<WebCore::SelectionRect> compositionRects;
+ compositionRange->collectSelectionRects(compositionRects);
+ if (compositionRects.size())
+ result.firstMarkedRect = compositionRects[0].rect();
+ if (compositionRects.size() > 1)
+ result.lastMarkedRect = compositionRects.last().rect();
+ else
+ result.lastMarkedRect = result.firstMarkedRect;
+ result.markedText = plainTextReplacingNoBreakSpace(compositionRange.get());
+ }
+ FrameView* view = frame.view();
+ if (selection.isCaret()) {
+ result.caretRectAtStart = view->contentsToRootView(frame.selection().absoluteCaretBounds());
+ result.caretRectAtEnd = result.caretRectAtStart;
+ // FIXME: The following check should take into account writing direction.
+ result.isReplaceAllowed = result.isContentEditable && atBoundaryOfGranularity(selection.start(), WordGranularity, DirectionForward);
+ result.wordAtSelection = plainTextReplacingNoBreakSpace(wordRangeFromPosition(selection.start()).get());
+ if (selection.isContentEditable()) {
+ charactersAroundPosition(selection.start(), result.characterAfterSelection, result.characterBeforeSelection, result.twoCharacterBeforeSelection);
+ Node* root = selection.rootEditableElement();
+ result.hasContent = root && root->hasChildNodes() && !isEndOfEditableOrNonEditableContent(firstPositionInNode(root));
+ }
+ } else if (selection.isRange()) {
+ result.caretRectAtStart = view->contentsToRootView(VisiblePosition(selection.start()).absoluteCaretBounds());
+ result.caretRectAtEnd = view->contentsToRootView(VisiblePosition(selection.end()).absoluteCaretBounds());
+ RefPtr<Range> selectedRange = selection.toNormalizedRange();
+ selectedRange->collectSelectionRects(result.selectionRects);
+ convertSelectionRectsToRootView(view, result.selectionRects);
+ String selectedText = plainTextReplacingNoBreakSpace(selectedRange.get(), TextIteratorDefaultBehavior, true);
+ // FIXME: We should disallow replace when the string contains only CJ characters.
+ result.isReplaceAllowed = result.isContentEditable && !result.isInPasswordField && !selectedText.containsOnlyWhitespace();
+ result.selectedTextLength = selectedText.length();
+ const int maxSelectedTextLength = 200;
+ if (selectedText.length() <= maxSelectedTextLength)
+ result.wordAtSelection = selectedText;
+ }
+ if (!selection.isNone()) {
+ Node* nodeToRemove;
+ if (RenderStyle* style = Editor::styleForSelectionStart(&frame, nodeToRemove)) {
+ CTFontRef font = style->fontCascade().primaryFont().getCTFont();
+ CTFontSymbolicTraits traits = font ? CTFontGetSymbolicTraits(font) : 0;
+
+ if (traits & kCTFontTraitBold)
+ result.typingAttributes |= AttributeBold;
+ if (traits & kCTFontTraitItalic)
+ result.typingAttributes |= AttributeItalics;
+
+ RefPtr<EditingStyle> typingStyle = frame.selection().typingStyle();
+ if (typingStyle && typingStyle->style()) {
+ String value = typingStyle->style()->getPropertyValue(CSSPropertyWebkitTextDecorationsInEffect);
+ if (value.contains("underline"))
+ result.typingAttributes |= AttributeUnderline;
+ } else {
+ if (style->textDecorationsInEffect() & TextDecorationUnderline)
+ result.typingAttributes |= AttributeUnderline;
+ }
+
+ if (nodeToRemove)
+ nodeToRemove->remove(ASSERT_NO_EXCEPTION);
+ }
+ }
+}
+
</ins><span class="cx"> FloatSize WebPage::screenSize() const
</span><span class="cx"> {
</span><span class="cx"> return m_screenSize;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (180464 => 180465)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2015-02-20 23:27:39 UTC (rev 180464)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2015-02-21 00:09:48 UTC (rev 180465)
</span><span class="lines">@@ -117,7 +117,20 @@
</span><span class="cx"> {
</span><span class="cx"> [m_mockAccessibilityElement setWebPage:nullptr];
</span><span class="cx"> }
</span><ins>+
+void WebPage::platformEditorState(Frame& frame, EditorState& result) const
+{
+ if (frame.selection().selection().isNone())
+ return;
</ins><span class="cx">
</span><ins>+ const Font* font = frame.editor().fontForSelection(result.selectionHasMultipleFonts);
+ NSFont *nsFont = font ? font->getNSFont() : nil;
+ if (nsFont) {
+ result.fontName = nsFont.fontName;
+ result.fontSize = nsFont.pointSize;
+ }
+}
+
</ins><span class="cx"> NSObject *WebPage::accessibilityObjectForMainFramePlugin()
</span><span class="cx"> {
</span><span class="cx"> if (!m_page)
</span><span class="lines">@@ -1159,6 +1172,12 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPage::setFont(const String& fontFamily, double fontSize, uint64_t fontTraits)
+{
+ Frame& frame = m_page->focusController().focusedOrMainFrame();
+ frame.editor().applyFontStyles(fontFamily, fontSize, fontTraits);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre>
</div>
</div>
</body>
</html>