Diff
Modified: trunk/Source/WebCore/ChangeLog (171014 => 171015)
--- trunk/Source/WebCore/ChangeLog 2014-07-11 22:36:14 UTC (rev 171014)
+++ trunk/Source/WebCore/ChangeLog 2014-07-11 23:24:24 UTC (rev 171015)
@@ -1,3 +1,16 @@
+2014-07-11 Enrica Casucci <[email protected]>
+
+ Implement textStylingAtPosition in WK2.
+ https://bugs.webkit.org/show_bug.cgi?id=134843
+ <rdar://problem/17614981>
+
+ Reviewed by Benjamin Poulain.
+
+ Adding some exports and making styleForSelectionStart public.
+
+ * WebCore.exp.in:
+ * editing/Editor.h:
+
2014-07-11 Zalan Bujtas <[email protected]>
REGRESSION (r168868): eBay 'see all' links fail due to different JS bindings conversion behavior.
Modified: trunk/Source/WebCore/WebCore.exp.in (171014 => 171015)
--- trunk/Source/WebCore/WebCore.exp.in 2014-07-11 22:36:14 UTC (rev 171014)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-07-11 23:24:24 UTC (rev 171015)
@@ -1091,6 +1091,7 @@
__ZN7WebCore4Node17stopIgnoringLeaksEv
__ZN7WebCore4Node18startIgnoringLeaksEv
__ZN7WebCore4Node19setNeedsStyleRecalcENS_15StyleChangeTypeE
+__ZN7WebCore4Node6removeERi
__ZN7WebCore4Page10findStringERKN3WTF6StringEh
__ZN7WebCore4Page11PageClientsC1Ev
__ZN7WebCore4Page11PageClientsD1Ev
@@ -1204,6 +1205,7 @@
__ZN7WebCore6Editor19deleteWithDirectionENS_18SelectionDirectionENS_15TextGranularityEbb
__ZN7WebCore6Editor19insertUnorderedListEv
__ZN7WebCore6Editor21applyStyleToSelectionEPNS_15StylePropertiesENS_10EditActionE
+__ZN7WebCore6Editor22styleForSelectionStartEPNS_5FrameERPNS_4NodeE
__ZN7WebCore6Editor22writeImageToPasteboardERNS_10PasteboardERNS_7ElementERKNS_3URLERKN3WTF6StringE
__ZN7WebCore6Editor23setBaseWritingDirectionE16WritingDirection
__ZN7WebCore6Editor24computeAndSetTypingStyleEPNS_15StylePropertiesENS_10EditActionE
Modified: trunk/Source/WebCore/editing/Editor.h (171014 => 171015)
--- trunk/Source/WebCore/editing/Editor.h 2014-07-11 22:36:14 UTC (rev 171014)
+++ trunk/Source/WebCore/editing/Editor.h 2014-07-11 23:24:24 UTC (rev 171015)
@@ -427,6 +427,7 @@
#endif
#if PLATFORM(COCOA)
+ static RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove);
bool insertParagraphSeparatorInQuotedContent();
const SimpleFontData* fontForSelection(bool&) const;
NSDictionary* fontAttributesForSelectionStart() const;
@@ -489,8 +490,6 @@
PassRefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(PassRefPtr<ArchiveResource>);
PassRefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *);
void fillInUserVisibleForm(PasteboardURL&);
-
- static RenderStyle* styleForSelectionStart(Frame* , Node *&nodeToRemove);
#endif
Frame& m_frame;
Modified: trunk/Source/WebKit2/ChangeLog (171014 => 171015)
--- trunk/Source/WebKit2/ChangeLog 2014-07-11 22:36:14 UTC (rev 171014)
+++ trunk/Source/WebKit2/ChangeLog 2014-07-11 23:24:24 UTC (rev 171015)
@@ -1,3 +1,28 @@
+2014-07-11 Enrica Casucci <[email protected]>
+
+ Implement textStylingAtPosition in WK2.
+ https://bugs.webkit.org/show_bug.cgi?id=134843
+ <rdar://problem/17614981>
+
+ Reviewed by Benjamin Poulain.
+
+ Adding information about typing attributes to EditorState so
+ that we can implement textStylingAtPosition.
+
+ * Shared/EditorState.cpp:
+ (WebKit::EditorState::encode):
+ (WebKit::EditorState::decode):
+ * Shared/EditorState.h:
+ (WebKit::EditorState::EditorState):
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView textStylingAtPosition:inDirection:]):
+ (-[WKContentView canPerformAction:withSender:]):
+ (-[WKContentView toggleBoldface:]):
+ (-[WKContentView toggleItalics:]):
+ (-[WKContentView toggleUnderline:]):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::editorState):
+
2014-07-11 Oliver Hunt <[email protected]>
Tighten WebContent sandbox
Modified: trunk/Source/WebKit2/Shared/EditorState.cpp (171014 => 171015)
--- trunk/Source/WebKit2/Shared/EditorState.cpp 2014-07-11 22:36:14 UTC (rev 171014)
+++ trunk/Source/WebKit2/Shared/EditorState.cpp 2014-07-11 23:24:24 UTC (rev 171015)
@@ -59,6 +59,7 @@
encoder << firstMarkedRect;
encoder << lastMarkedRect;
encoder << markedText;
+ encoder << typingAttributes;
#endif
#if PLATFORM(GTK)
@@ -117,6 +118,8 @@
return false;
if (!decoder.decode(result.markedText))
return false;
+ if (!decoder.decode(result.typingAttributes))
+ return false;
#endif
#if PLATFORM(GTK)
Modified: trunk/Source/WebKit2/Shared/EditorState.h (171014 => 171015)
--- trunk/Source/WebKit2/Shared/EditorState.h 2014-07-11 22:36:14 UTC (rev 171014)
+++ trunk/Source/WebKit2/Shared/EditorState.h 2014-07-11 23:24:24 UTC (rev 171015)
@@ -36,6 +36,13 @@
namespace WebKit {
+enum TypingAttributes {
+ AttributeNone = 0,
+ AttributeBold = 1,
+ AttributeItalics = 2,
+ AttributeUnderline = 4
+};
+
struct EditorState {
EditorState()
: shouldIgnoreCompositionSelectionChange(false)
@@ -52,6 +59,7 @@
, characterBeforeSelection(0)
, twoCharacterBeforeSelection(0)
, selectedTextLength(0)
+ , typingAttributes(AttributeNone)
#endif
{
}
@@ -79,6 +87,7 @@
WebCore::IntRect firstMarkedRect;
WebCore::IntRect lastMarkedRect;
String markedText;
+ uint32_t typingAttributes;
#endif
#if PLATFORM(GTK)
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (171014 => 171015)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2014-07-11 22:36:14 UTC (rev 171014)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2014-07-11 23:24:24 UTC (rev 171015)
@@ -44,6 +44,7 @@
#import "WebProcessProxy.h"
#import "_WKFormDelegate.h"
#import "_WKFormInputSession.h"
+#import <CoreText/CTFontDescriptor.h>
#import <DataDetectorsUI/DDDetectionController.h>
#import <TextInput/TI_NSStringExtras.h>
#import <UIKit/UIApplication_Private.h>
@@ -1190,6 +1191,36 @@
[[UIKeyboardImpl sharedInstance] replaceText:sender];
}
+- (NSDictionary *)textStylingAtPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction
+{
+ if (!position || !_page->editorState().isContentRichlyEditable)
+ return nil;
+
+ NSMutableDictionary* result = [NSMutableDictionary dictionary];
+
+ CTFontSymbolicTraits symbolicTraits = 0;
+ if (_page->editorState().typingAttributes & AttributeBold)
+ symbolicTraits |= kCTFontBoldTrait;
+ if (_page->editorState().typingAttributes & AttributeItalics)
+ symbolicTraits |= kCTFontTraitItalic;
+
+ // We chose a random font family and size.
+ // What matters are the traits but the caller expects a font object
+ // in the dictionary for NSFontAttributeName.
+ RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontDescriptorCreateWithNameAndSize(CFSTR("Helvetica"), 10));
+ if (symbolicTraits)
+ fontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithSymbolicTraits(fontDescriptor.get(), symbolicTraits, symbolicTraits));
+
+ RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 10, nullptr));
+ if (font)
+ [result setObject:(id)font.get() forKey:NSFontAttributeName];
+
+ if (_page->editorState().typingAttributes & AttributeUnderline)
+ [result setObject:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
+
+ return result;
+}
+
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
BOOL hasWebSelection = _webSelectionAssistant && !CGRectIsEmpty(_webSelectionAssistant.get().selectionFrame);
@@ -1198,6 +1229,8 @@
return _page->editorState().isContentRichlyEditable && _page->editorState().selectionIsRange && !_showingTextStyleOptions;
if (_showingTextStyleOptions)
return (action == @selector(toggleBoldface:) || action == @selector(toggleItalics:) || action == @selector(toggleUnderline:));
+ if (action == @selector(toggleBoldface:) || action == @selector(toggleItalics:) || action == @selector(toggleUnderline:))
+ return _page->editorState().isContentRichlyEditable;
if (action == @selector(cut:))
return !_page->editorState().isInPasswordField && _page->editorState().isContentEditable && _page->editorState().selectionIsRange;
@@ -1336,7 +1369,7 @@
if (!_page->editorState().isContentRichlyEditable)
return;
- _page->executeEditCommand(ASCIILiteral("toggleBold"));
+ [self executeEditCommandWithCallback:@"toggleBold"];
}
- (void)toggleItalics:(id)sender
@@ -1344,7 +1377,7 @@
if (!_page->editorState().isContentRichlyEditable)
return;
- _page->executeEditCommand(ASCIILiteral("toggleItalic"));
+ [self executeEditCommandWithCallback:@"toggleItalic"];
}
- (void)toggleUnderline:(id)sender
@@ -1352,7 +1385,7 @@
if (!_page->editorState().isContentRichlyEditable)
return;
- _page->executeEditCommand(ASCIILiteral("toggleUnderline"));
+ [self executeEditCommandWithCallback:@"toggleUnderline"];
}
- (void)_showTextStyleOptions:(id)sender
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (171014 => 171015)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2014-07-11 22:36:14 UTC (rev 171014)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2014-07-11 23:24:24 UTC (rev 171015)
@@ -192,6 +192,8 @@
#include "RemoteLayerTreeDrawingArea.h"
#include "WebVideoFullscreenManager.h"
#include <CoreGraphics/CoreGraphics.h>
+#include <CoreText/CTFontDescriptorPriv.h>
+#include <CoreText/CTFontPriv.h>
#include <WebCore/Icon.h>
#endif
@@ -744,6 +746,24 @@
if (selectedText.length() <= maxSelectedTextLength)
result.wordAtSelection = selectedText;
}
+ if (!selection.isNone()) {
+ Node* nodeToRemove;
+ if (RenderStyle* style = Editor::styleForSelectionStart(&frame, nodeToRemove)) {
+ CTFontRef font = style->font().primaryFont()->getCTFont();
+ CTFontSymbolicTraits traits = font ? CTFontGetSymbolicTraits(font) : 0;
+
+ if (traits & kCTFontTraitBold)
+ result.typingAttributes |= AttributeBold;
+ if (traits & kCTFontTraitItalic)
+ result.typingAttributes |= AttributeItalics;
+
+ if (style->textDecorationsInEffect() & TextDecorationUnderline)
+ result.typingAttributes |= AttributeUnderline;
+
+ if (nodeToRemove)
+ nodeToRemove->remove(ASSERT_NO_EXCEPTION);
+ }
+ }
#endif
#if PLATFORM(GTK)