Skip to content

Commit e9fc1e2

Browse files
[Attachment Support] Implement delegate hooks for attachment element insertion and removal
https://bugs.webkit.org/show_bug.cgi?id=179016 <rdar://problem/35250890> Reviewed by Tim Horton. Source/WebCore: Implements a mechanism for notifying WebKit2 clients when attachment elements are inserted into or removed from the document. See per-change comments below for more details. API tests: WKAttachmentTests.AttachmentElementInsertion WKAttachmentTests.AttachmentUpdatesWhenInsertingAndDeletingNewline WKAttachmentTests.AttachmentUpdatesWhenUndoingAndRedoing WKAttachmentTests.AttachmentUpdatesWhenChangingFontStyles WKAttachmentTests.AttachmentUpdatesWhenInsertingLists WKAttachmentTests.AttachmentUpdatesWhenInsertingRichMarkup * editing/Editor.cpp: (WebCore::Editor::respondToChangedSelection): (WebCore::Editor::editorUIUpdateTimerFired): Additionally notify the client of any attachment updates. (WebCore::Editor::scheduleEditorUIUpdate): Add a new helper that starts the editor UI update timer with 0 delay, and use it everywhere we schedule an editor UI update. (WebCore::Editor::didInsertAttachmentElement): (WebCore::Editor::didRemoveAttachmentElement): Maintain two sets of attachment element identifiers -- the first one tracking insertions, and the second one tracking removals. When an attachment element is inserted, we first check to see if that attachment element has just been removed; if so, we don't add it to the inserted identifiers set, but instead remove it from the set of removed identifiers. We perform a similar check in the opposite case. This prevents us from notifying the client of extraneous insertions and removals during certain editing commands which may reparent and move attachment elements around. In both cases, we schedule an editor UI update afterwards, where we will notify the client of attachment updates. (WebCore::Editor::notifyClientOfAttachmentUpdates): (WebCore::Editor::insertAttachmentFromFile): * editing/Editor.h: * html/HTMLAttachmentElement.cpp: (WebCore::HTMLAttachmentElement::HTMLAttachmentElement): Remove the version of HTMLAttachmentElement's constructor that takes a unique identifier. (WebCore::HTMLAttachmentElement::insertedIntoAncestor): (WebCore::HTMLAttachmentElement::removedFromAncestor): Implement these hooks to observe insertion into and removal from the DOM. If the element was attached to or removed from an ancestor that was connected to the document, call out to the document's frame's editor. This "document-connected" rule prevents us from calling out to the client in cases where (for instance) we append an attachment element to a newly created DocumentFragment in preparation for executing a ReplaceSelectionCommand. (WebCore::HTMLAttachmentElement::uniqueIdentifier const): (WebCore::HTMLAttachmentElement::setUniqueIdentifier): Refactor unique identifier to refer to the new attachment identifier attribute instead of a member variable. * html/HTMLAttachmentElement.h: * html/HTMLAttributeNames.in: Add a new attribute representing an attachment element's identifier. This enables us to keep track of particular attachments as they are destroyed and recreated as different objects, as a result of some editing commands. * page/EditorClient.h: (WebCore::EditorClient::didInsertAttachment): (WebCore::EditorClient::didRemoveAttachment): Add boilerplate editor client hooks for attachment insertion and removal. Source/WebKit: Adds boilerplate plumbing to WebEditorClient, WebPage, and the usual machinery in the UI process to notify WebKit2 clients when attachment elements have been inserted or removed from the document. See the WebCore ChangeLog for more details about the implementation, or the Tools ChangeLog for more information about new API tests. * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _didInsertAttachment:]): (-[WKWebView _didRemoveAttachment:]): * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/Cocoa/PageClientImplCocoa.h: * UIProcess/Cocoa/PageClientImplCocoa.mm: (WebKit::PageClientImplCocoa::didInsertAttachment): (WebKit::PageClientImplCocoa::didRemoveAttachment): * UIProcess/PageClient.h: (WebKit::PageClient::didInsertAttachment): (WebKit::PageClient::didRemoveAttachment): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::didInsertAttachment): (WebKit::WebPageProxy::didRemoveAttachment): * UIProcess/WebPageProxy.h: * UIProcess/WebPageProxy.messages.in: * WebProcess/WebCoreSupport/WebEditorClient.cpp: (WebKit::WebEditorClient::didInsertAttachment): (WebKit::WebEditorClient::didRemoveAttachment): * WebProcess/WebCoreSupport/WebEditorClient.h: Tools: Introduces new API tests to check that various editing operations will or won't result in the new attachment insertion and removal delegate hooks being fired. Additionally refactors an existing test to verify that attachments insertion and removal is observable by the UI delegate. * TestWebKitAPI/Tests/WebKitCocoa/WKAttachmentTests.mm: (-[AttachmentUpdateObserver init]): (-[AttachmentUpdateObserver inserted]): (-[AttachmentUpdateObserver removed]): (-[AttachmentUpdateObserver _webView:didInsertAttachment:]): (-[AttachmentUpdateObserver _webView:didRemoveAttachment:]): (TestWebKitAPI::ObserveAttachmentUpdatesForScope::ObserveAttachmentUpdatesForScope): (TestWebKitAPI::ObserveAttachmentUpdatesForScope::~ObserveAttachmentUpdatesForScope): (TestWebKitAPI::ObserveAttachmentUpdatesForScope::expectAttachmentUpdates): Implement a testing mechanism to temporarily bind a UI delegate to a given WKWebView and listen for inserted or removed attachments over the course of a particular scope. The API tests use this mechanism to check that the UI delegate hooks added in this patch are invoked with the right attachments when performing edit commands. (-[TestWKWebView _synchronouslyExecuteEditCommand:argument:]): (-[TestWKWebView expectUpdatesAfterCommand:withArgument:expectedRemovals:expectedInsertions:]): (TestWebKitAPI::TEST): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@224512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 224f2ea commit e9fc1e2

21 files changed

+547
-33
lines changed

Source/WebCore/ChangeLog

+73
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,76 @@
1+
2017-11-06 Wenson Hsieh <[email protected]>
2+
3+
[Attachment Support] Implement delegate hooks for attachment element insertion and removal
4+
https://bugs.webkit.org/show_bug.cgi?id=179016
5+
<rdar://problem/35250890>
6+
7+
Reviewed by Tim Horton.
8+
9+
Implements a mechanism for notifying WebKit2 clients when attachment elements are inserted into or removed from
10+
the document. See per-change comments below for more details.
11+
12+
API tests: WKAttachmentTests.AttachmentElementInsertion
13+
WKAttachmentTests.AttachmentUpdatesWhenInsertingAndDeletingNewline
14+
WKAttachmentTests.AttachmentUpdatesWhenUndoingAndRedoing
15+
WKAttachmentTests.AttachmentUpdatesWhenChangingFontStyles
16+
WKAttachmentTests.AttachmentUpdatesWhenInsertingLists
17+
WKAttachmentTests.AttachmentUpdatesWhenInsertingRichMarkup
18+
19+
* editing/Editor.cpp:
20+
(WebCore::Editor::respondToChangedSelection):
21+
(WebCore::Editor::editorUIUpdateTimerFired):
22+
23+
Additionally notify the client of any attachment updates.
24+
25+
(WebCore::Editor::scheduleEditorUIUpdate):
26+
27+
Add a new helper that starts the editor UI update timer with 0 delay, and use it everywhere we schedule an
28+
editor UI update.
29+
30+
(WebCore::Editor::didInsertAttachmentElement):
31+
(WebCore::Editor::didRemoveAttachmentElement):
32+
33+
Maintain two sets of attachment element identifiers -- the first one tracking insertions, and the second one
34+
tracking removals. When an attachment element is inserted, we first check to see if that attachment element has
35+
just been removed; if so, we don't add it to the inserted identifiers set, but instead remove it from the set of
36+
removed identifiers. We perform a similar check in the opposite case. This prevents us from notifying the client
37+
of extraneous insertions and removals during certain editing commands which may reparent and move attachment
38+
elements around. In both cases, we schedule an editor UI update afterwards, where we will notify the client of
39+
attachment updates.
40+
41+
(WebCore::Editor::notifyClientOfAttachmentUpdates):
42+
(WebCore::Editor::insertAttachmentFromFile):
43+
* editing/Editor.h:
44+
* html/HTMLAttachmentElement.cpp:
45+
(WebCore::HTMLAttachmentElement::HTMLAttachmentElement):
46+
47+
Remove the version of HTMLAttachmentElement's constructor that takes a unique identifier.
48+
49+
(WebCore::HTMLAttachmentElement::insertedIntoAncestor):
50+
(WebCore::HTMLAttachmentElement::removedFromAncestor):
51+
52+
Implement these hooks to observe insertion into and removal from the DOM. If the element was attached to or
53+
removed from an ancestor that was connected to the document, call out to the document's frame's editor. This
54+
"document-connected" rule prevents us from calling out to the client in cases where (for instance) we append an
55+
attachment element to a newly created DocumentFragment in preparation for executing a ReplaceSelectionCommand.
56+
57+
(WebCore::HTMLAttachmentElement::uniqueIdentifier const):
58+
(WebCore::HTMLAttachmentElement::setUniqueIdentifier):
59+
60+
Refactor unique identifier to refer to the new attachment identifier attribute instead of a member variable.
61+
62+
* html/HTMLAttachmentElement.h:
63+
* html/HTMLAttributeNames.in:
64+
65+
Add a new attribute representing an attachment element's identifier. This enables us to keep track of particular
66+
attachments as they are destroyed and recreated as different objects, as a result of some editing commands.
67+
68+
* page/EditorClient.h:
69+
(WebCore::EditorClient::didInsertAttachment):
70+
(WebCore::EditorClient::didRemoveAttachment):
71+
72+
Add boilerplate editor client hooks for attachment insertion and removal.
73+
174
2017-11-06 Ryan Haddad <[email protected]>
275

376
Unreviewed, rolling out r224494.

Source/WebCore/editing/Editor.cpp

+46-2
Original file line numberDiff line numberDiff line change
@@ -3428,7 +3428,7 @@ void Editor::respondToChangedSelection(const VisibleSelection&, FrameSelection::
34283428
m_editorUIUpdateTimerShouldCheckSpellingAndGrammar = options & FrameSelection::CloseTyping
34293429
&& !(options & FrameSelection::SpellCorrectionTriggered);
34303430
m_editorUIUpdateTimerWasTriggeredByDictation = options & FrameSelection::DictationTriggered;
3431-
m_editorUIUpdateTimer.startOneShot(0_s);
3431+
scheduleEditorUIUpdate();
34323432
}
34333433

34343434
#if ENABLE(TELEPHONE_NUMBER_DETECTION) && !PLATFORM(IOS)
@@ -3601,6 +3601,10 @@ void Editor::editorUIUpdateTimerFired()
36013601
m_alternativeTextController->respondToChangedSelection(oldSelection);
36023602

36033603
m_oldSelectionForEditorUIUpdate = m_frame.selection().selection();
3604+
3605+
#if ENABLE(ATTACHMENT_ELEMENT)
3606+
notifyClientOfAttachmentUpdates();
3607+
#endif
36043608
}
36053609

36063610
static Node* findFirstMarkable(Node* node)
@@ -3733,8 +3737,48 @@ RefPtr<Range> Editor::rangeForTextCheckingResult(const TextCheckingResult& resul
37333737
return TextIterator::subrange(*contextRange, result.location, result.length);
37343738
}
37353739

3740+
void Editor::scheduleEditorUIUpdate()
3741+
{
3742+
m_editorUIUpdateTimer.startOneShot(0_s);
3743+
}
3744+
37363745
#if ENABLE(ATTACHMENT_ELEMENT)
37373746

3747+
void Editor::didInsertAttachmentElement(HTMLAttachmentElement& attachment)
3748+
{
3749+
auto identifier = attachment.uniqueIdentifier();
3750+
if (identifier.isEmpty())
3751+
return;
3752+
3753+
if (!m_removedAttachmentIdentifiers.take(identifier))
3754+
m_insertedAttachmentIdentifiers.add(identifier);
3755+
scheduleEditorUIUpdate();
3756+
}
3757+
3758+
void Editor::didRemoveAttachmentElement(HTMLAttachmentElement& attachment)
3759+
{
3760+
auto identifier = attachment.uniqueIdentifier();
3761+
if (identifier.isEmpty())
3762+
return;
3763+
3764+
if (!m_insertedAttachmentIdentifiers.take(identifier))
3765+
m_removedAttachmentIdentifiers.add(identifier);
3766+
scheduleEditorUIUpdate();
3767+
}
3768+
3769+
void Editor::notifyClientOfAttachmentUpdates()
3770+
{
3771+
if (auto* editorClient = client()) {
3772+
for (auto& identifier : m_removedAttachmentIdentifiers)
3773+
editorClient->didRemoveAttachment(identifier);
3774+
for (auto& identifier : m_insertedAttachmentIdentifiers)
3775+
editorClient->didInsertAttachment(identifier);
3776+
}
3777+
3778+
m_removedAttachmentIdentifiers.clear();
3779+
m_insertedAttachmentIdentifiers.clear();
3780+
}
3781+
37383782
void Editor::insertAttachment(const String& identifier, const String& filename, const String& filepath, std::optional<String> contentType)
37393783
{
37403784
if (!contentType)
@@ -3751,7 +3795,7 @@ void Editor::insertAttachment(const String& identifier, const String& filename,
37513795

37523796
void Editor::insertAttachmentFromFile(const String& identifier, const String& filename, const String& contentType, Ref<File>&& file)
37533797
{
3754-
auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document(), identifier);
3798+
auto attachment = HTMLAttachmentElement::create(HTMLNames::attachmentTag, document());
37553799
attachment->setAttribute(HTMLNames::titleAttr, filename);
37563800
attachment->setAttribute(HTMLNames::subtitleAttr, fileSizeDescription(file->size()));
37573801
attachment->setAttribute(HTMLNames::typeAttr, contentType);

Source/WebCore/editing/Editor.h

+13
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ class Editor {
503503
#if ENABLE(ATTACHMENT_ELEMENT)
504504
WEBCORE_EXPORT void insertAttachment(const String& identifier, const String& filename, const String& filepath, std::optional<String> contentType = std::nullopt);
505505
WEBCORE_EXPORT void insertAttachment(const String& identifier, const String& filename, Ref<SharedBuffer>&& data, std::optional<String> contentType = std::nullopt);
506+
void didInsertAttachmentElement(HTMLAttachmentElement&);
507+
void didRemoveAttachmentElement(HTMLAttachmentElement&);
506508
#endif
507509

508510
private:
@@ -550,6 +552,12 @@ class Editor {
550552
static RefPtr<SharedBuffer> dataInRTFFormat(NSAttributedString *);
551553
#endif
552554

555+
void scheduleEditorUIUpdate();
556+
557+
#if ENABLE(ATTACHMENT_ELEMENT)
558+
void notifyClientOfAttachmentUpdates();
559+
#endif
560+
553561
void postTextStateChangeNotificationForCut(const String&, const VisibleSelection&);
554562

555563
Frame& m_frame;
@@ -569,6 +577,11 @@ class Editor {
569577
EditorParagraphSeparator m_defaultParagraphSeparator { EditorParagraphSeparatorIsDiv };
570578
bool m_overwriteModeEnabled { false };
571579

580+
#if ENABLE(ATTACHMENT_ELEMENT)
581+
HashSet<String> m_insertedAttachmentIdentifiers;
582+
HashSet<String> m_removedAttachmentIdentifiers;
583+
#endif
584+
572585
VisibleSelection m_oldSelectionForEditorUIUpdate;
573586
Timer m_editorUIUpdateTimer;
574587
bool m_editorUIUpdateTimerShouldCheckSpellingAndGrammar { false };

Source/WebCore/html/HTMLAttachmentElement.cpp

+30-13
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,24 @@
3333
#include "Frame.h"
3434
#include "HTMLNames.h"
3535
#include "RenderAttachment.h"
36-
#include <wtf/UUID.h>
3736

3837
namespace WebCore {
3938

4039
using namespace HTMLNames;
4140

42-
HTMLAttachmentElement::HTMLAttachmentElement(const QualifiedName& tagName, Document& document, const String& identifier)
41+
HTMLAttachmentElement::HTMLAttachmentElement(const QualifiedName& tagName, Document& document)
4342
: HTMLElement(tagName, document)
44-
, m_uniqueIdentifier(identifier)
4543
{
4644
ASSERT(hasTagName(attachmentTag));
4745
}
4846

49-
HTMLAttachmentElement::HTMLAttachmentElement(const QualifiedName& tagName, Document& document)
50-
: HTMLAttachmentElement(tagName, document, createCanonicalUUIDString())
51-
{
52-
}
53-
5447
HTMLAttachmentElement::~HTMLAttachmentElement() = default;
5548

5649
Ref<HTMLAttachmentElement> HTMLAttachmentElement::create(const QualifiedName& tagName, Document& document)
5750
{
5851
return adoptRef(*new HTMLAttachmentElement(tagName, document));
5952
}
6053

61-
Ref<HTMLAttachmentElement> HTMLAttachmentElement::create(const QualifiedName& tagName, Document& document, const String& identifier)
62-
{
63-
return adoptRef(*new HTMLAttachmentElement(tagName, document, identifier));
64-
}
65-
6654
RenderPtr<RenderElement> HTMLAttachmentElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
6755
{
6856
return createRenderer<RenderAttachment>(*this, WTFMove(style));
@@ -81,6 +69,25 @@ void HTMLAttachmentElement::setFile(File* file)
8169
renderer->invalidate();
8270
}
8371

72+
Node::InsertedIntoAncestorResult HTMLAttachmentElement::insertedIntoAncestor(InsertionType type, ContainerNode& ancestor)
73+
{
74+
auto result = HTMLElement::insertedIntoAncestor(type, ancestor);
75+
if (auto* frame = document().frame()) {
76+
if (type.connectedToDocument)
77+
frame->editor().didInsertAttachmentElement(*this);
78+
}
79+
return result;
80+
}
81+
82+
void HTMLAttachmentElement::removedFromAncestor(RemovalType type, ContainerNode& ancestor)
83+
{
84+
HTMLElement::removedFromAncestor(type, ancestor);
85+
if (auto* frame = document().frame()) {
86+
if (type.disconnectedFromDocument)
87+
frame->editor().didRemoveAttachmentElement(*this);
88+
}
89+
}
90+
8491
void HTMLAttachmentElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
8592
{
8693
if (name == progressAttr || name == subtitleAttr || name == titleAttr || name == typeAttr) {
@@ -91,6 +98,16 @@ void HTMLAttachmentElement::parseAttribute(const QualifiedName& name, const Atom
9198
HTMLElement::parseAttribute(name, value);
9299
}
93100

101+
String HTMLAttachmentElement::uniqueIdentifier() const
102+
{
103+
return attributeWithoutSynchronization(HTMLNames::webkitattachmentidAttr);
104+
}
105+
106+
void HTMLAttachmentElement::setUniqueIdentifier(const String& identifier)
107+
{
108+
setAttributeWithoutSynchronization(HTMLNames::webkitattachmentidAttr, identifier);
109+
}
110+
94111
String HTMLAttachmentElement::attachmentTitle() const
95112
{
96113
auto& title = attributeWithoutSynchronization(titleAttr);

Source/WebCore/html/HTMLAttachmentElement.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ class RenderAttachment;
3737
class HTMLAttachmentElement final : public HTMLElement {
3838
public:
3939
static Ref<HTMLAttachmentElement> create(const QualifiedName&, Document&);
40-
static Ref<HTMLAttachmentElement> create(const QualifiedName&, Document&, const String& identifier);
4140

4241
WEBCORE_EXPORT File* file() const;
4342
void setFile(File*);
4443

45-
WEBCORE_EXPORT String uniqueIdentifier() const { return m_uniqueIdentifier; }
46-
void setUniqueIdentifier(const String& identifier) { m_uniqueIdentifier = identifier; }
44+
WEBCORE_EXPORT String uniqueIdentifier() const;
45+
void setUniqueIdentifier(const String&);
46+
47+
InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
48+
void removedFromAncestor(RemovalType, ContainerNode&) final;
4749

4850
WEBCORE_EXPORT String attachmentTitle() const;
4951
String attachmentType() const;
@@ -52,7 +54,6 @@ class HTMLAttachmentElement final : public HTMLElement {
5254

5355
private:
5456
HTMLAttachmentElement(const QualifiedName&, Document&);
55-
HTMLAttachmentElement(const QualifiedName&, Document&, const String& identifier);
5657
virtual ~HTMLAttachmentElement();
5758

5859
RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
@@ -68,7 +69,6 @@ class HTMLAttachmentElement final : public HTMLElement {
6869
void parseAttribute(const QualifiedName&, const AtomicString&) final;
6970

7071
RefPtr<File> m_file;
71-
String m_uniqueIdentifier;
7272
};
7373

7474
} // namespace WebCore

Source/WebCore/html/HTMLAttributeNames.in

+1
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ version
381381
vlink
382382
vspace
383383
webkitallowfullscreen
384+
webkitattachmentid
384385
webkitattachmentpath
385386
webkitdirectory
386387
width

Source/WebCore/page/EditorClient.h

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ class EditorClient {
7272
virtual void didApplyStyle() = 0;
7373
virtual bool shouldMoveRangeAfterDelete(Range*, Range*) = 0;
7474

75+
#if ENABLE(ATTACHMENT_ELEMENT)
76+
virtual void didInsertAttachment(const String&) { }
77+
virtual void didRemoveAttachment(const String&) { }
78+
#endif
79+
7580
virtual void didBeginEditing() = 0;
7681
virtual void respondToChangedContents() = 0;
7782
virtual void respondToChangedSelection(Frame*) = 0;

Source/WebKit/ChangeLog

+35
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
2017-11-06 Wenson Hsieh <[email protected]>
2+
3+
[Attachment Support] Implement delegate hooks for attachment element insertion and removal
4+
https://bugs.webkit.org/show_bug.cgi?id=179016
5+
<rdar://problem/35250890>
6+
7+
Reviewed by Tim Horton.
8+
9+
Adds boilerplate plumbing to WebEditorClient, WebPage, and the usual machinery in the UI process to notify
10+
WebKit2 clients when attachment elements have been inserted or removed from the document. See the WebCore
11+
ChangeLog for more details about the implementation, or the Tools ChangeLog for more information about new API
12+
tests.
13+
14+
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
15+
* UIProcess/API/Cocoa/WKWebView.mm:
16+
(-[WKWebView _didInsertAttachment:]):
17+
(-[WKWebView _didRemoveAttachment:]):
18+
* UIProcess/API/Cocoa/WKWebViewInternal.h:
19+
* UIProcess/Cocoa/PageClientImplCocoa.h:
20+
* UIProcess/Cocoa/PageClientImplCocoa.mm:
21+
(WebKit::PageClientImplCocoa::didInsertAttachment):
22+
(WebKit::PageClientImplCocoa::didRemoveAttachment):
23+
* UIProcess/PageClient.h:
24+
(WebKit::PageClient::didInsertAttachment):
25+
(WebKit::PageClient::didRemoveAttachment):
26+
* UIProcess/WebPageProxy.cpp:
27+
(WebKit::WebPageProxy::didInsertAttachment):
28+
(WebKit::WebPageProxy::didRemoveAttachment):
29+
* UIProcess/WebPageProxy.h:
30+
* UIProcess/WebPageProxy.messages.in:
31+
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
32+
(WebKit::WebEditorClient::didInsertAttachment):
33+
(WebKit::WebEditorClient::didRemoveAttachment):
34+
* WebProcess/WebCoreSupport/WebEditorClient.h:
35+
136
2017-11-06 Jeremy Jones <[email protected]>
237

338
iOS element fullscreen should use a UIGestureRecognizer to detect user interaction.

Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ struct UIEdgeInsets;
110110
- (void)_webView:(WKWebView *)webView runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler WK_API_AVAILABLE(macosx(10.13), ios(11.0));
111111
- (void)_webView:(WKWebView *)webView editorStateDidChange:(NSDictionary *)editorState WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
112112

113+
- (void)_webView:(WKWebView *)webView didRemoveAttachment:(_WKAttachment *)attachment WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
114+
- (void)_webView:(WKWebView *)webView didInsertAttachment:(_WKAttachment *)attachment WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
115+
113116
#if TARGET_OS_IPHONE
114117
- (BOOL)_webView:(WKWebView *)webView shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element WK_API_AVAILABLE(ios(9.0));
115118
- (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray<_WKElementAction *> *)defaultActions;

Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

+18
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,24 @@ - (void)_didChangeEditorState
11971197
[uiDelegate _webView:self editorStateDidChange:dictionaryRepresentationForEditorState(_page->editorState())];
11981198
}
11991199

1200+
#if ENABLE(ATTACHMENT_ELEMENT)
1201+
1202+
- (void)_didInsertAttachment:(NSString *)identifier
1203+
{
1204+
id <WKUIDelegatePrivate> uiDelegate = (id <WKUIDelegatePrivate>)self.UIDelegate;
1205+
if ([uiDelegate respondsToSelector:@selector(_webView:didInsertAttachment:)])
1206+
[uiDelegate _webView:self didInsertAttachment:[wrapper(API::Attachment::create(identifier, *_page).leakRef()) autorelease]];
1207+
}
1208+
1209+
- (void)_didRemoveAttachment:(NSString *)identifier
1210+
{
1211+
id <WKUIDelegatePrivate> uiDelegate = (id <WKUIDelegatePrivate>)self.UIDelegate;
1212+
if ([uiDelegate respondsToSelector:@selector(_webView:didRemoveAttachment:)])
1213+
[uiDelegate _webView:self didRemoveAttachment:[wrapper(API::Attachment::create(identifier, *_page).leakRef()) autorelease]];
1214+
}
1215+
1216+
#endif // ENABLE(ATTACHMENT_ELEMENT)
1217+
12001218
#pragma mark iOS-specific methods
12011219

12021220
#if PLATFORM(IOS)

0 commit comments

Comments
 (0)