Diff
Modified: trunk/Source/WebKit/win/ChangeLog (178964 => 178965)
--- trunk/Source/WebKit/win/ChangeLog 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Source/WebKit/win/ChangeLog 2015-01-22 23:46:41 UTC (rev 178965)
@@ -1,3 +1,76 @@
+2015-01-22 Brent Fulgham <bfulg...@apple.com>
+
+ [Win] Expose missing editing features through WebView interface
+ https://bugs.webkit.org/show_bug.cgi?id=140773
+ <rdar://problem/19565421>
+
+ Reviewed by Dean Jackson.
+
+ Connect the various WebView editing delegate methods to our
+ test infrastructure. Also prefer _bstr_t to raw BSTR types
+ to simplify life cycle management.
+
+ * DOMCoreClasses.cpp: Flesh out the DOMRange object.
+ (DOMElement::createInstance):
+ (DOMRange::QueryInterface):
+ (DOMRange::DOMRange):
+ (DOMRange::~DOMRange):
+ (DOMRange::createInstance):
+ (DOMRange::startContainer):
+ (DOMRange::startOffset):
+ (DOMRange::endContainer):
+ (DOMRange::endOffset):
+ (DOMRange::collapsed):
+ (DOMRange::commonAncestorContainer):
+ (DOMRange::setStart):
+ (DOMRange::setEnd):
+ (DOMRange::setStartBefore):
+ (DOMRange::setStartAfter):
+ (DOMRange::setEndBefore):
+ (DOMRange::setEndAfter):
+ (DOMRange::collapse):
+ (DOMRange::selectNode):
+ (DOMRange::selectNodeContents):
+ (DOMRange::compareBoundaryPoints):
+ (DOMRange::deleteContents):
+ (DOMRange::extractContents):
+ (DOMRange::cloneContents):
+ (DOMRange::insertNode):
+ (DOMRange::surroundContents):
+ (DOMRange::cloneRange):
+ (DOMRange::toString):
+ (DOMRange::detach):
+ * DOMCoreClasses.h:
+ (DOMRange::AddRef):
+ (DOMRange::Release):
+ (DOMRange::throwException):
+ (DOMRange::callWebScriptMethod):
+ (DOMRange::evaluateWebScript):
+ (DOMRange::removeWebScriptKey):
+ (DOMRange::stringRepresentation):
+ (DOMRange::webScriptValueAtIndex):
+ (DOMRange::setWebScriptValueAtIndex):
+ (DOMRange::setException):
+ * Interfaces/IWebEditingDelegate.idl:
+ * Interfaces/IWebView.idl:
+ * WebCoreSupport/WebEditorClient.cpp: Connect more methods
+ to actual editing features in WebCore.
+ (WebEditorClient::shouldBeginEditing):
+ (WebEditorClient::shouldEndEditing):
+ (WebEditorClient::didBeginEditing):
+ (WebEditorClient::respondToChangedContents):
+ (WebEditorClient::respondToChangedSelection):
+ (WebEditorClient::didEndEditing):
+ (WebEditorClient::shouldDeleteRange):
+ (WebEditorClient::shouldInsertNode):
+ (WebEditorClient::shouldInsertText):
+ (WebEditorClient::shouldChangeSelectedRange):
+ (WebEditorClient::webViewDidChangeTypingStyle):
+ (WebEditorClient::webViewDidChangeSelection):
+ (WebEditorClient::isSelectTrailingWhitespaceEnabled):
+ * WebView.cpp:
+ (WebView::setEditingDelegate): Added.
+
2015-01-21 Brent Fulgham <bfulg...@apple.com>
[Win] eventSender does not support scalePageBy
Modified: trunk/Source/WebKit/win/DOMCoreClasses.cpp (178964 => 178965)
--- trunk/Source/WebKit/win/DOMCoreClasses.cpp 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Source/WebKit/win/DOMCoreClasses.cpp 2015-01-22 23:46:41 UTC (rev 178965)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2009, 2014-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -47,6 +47,7 @@
#include <WebCore/HTMLSelectElement.h>
#include <WebCore/HTMLTextAreaElement.h>
#include <WebCore/NodeList.h>
+#include <WebCore/Range.h>
#include <WebCore/RenderElement.h>
#include <WebCore/RenderTreeAsText.h>
@@ -1530,3 +1531,212 @@
return domElement;
}
+
+// DOMRange - IUnknown -----------------------------------------------------
+
+HRESULT DOMRange::QueryInterface(REFIID riid, void** ppvObject)
+{
+ *ppvObject = nullptr;
+ if (IsEqualGUID(riid, IID_IDOMRange))
+ *ppvObject = static_cast<IDOMRange*>(this);
+ else
+ return DOMObject::QueryInterface(riid, ppvObject);
+
+ AddRef();
+ return S_OK;
+}
+
+// DOMRange -----------------------------------------------------------------
+
+DOMRange::DOMRange(WebCore::Range* e)
+ : m_range(e)
+{
+}
+
+DOMRange::~DOMRange()
+{
+}
+
+IDOMRange* DOMRange::createInstance(WebCore::Range* range)
+{
+ if (!range)
+ return nullptr;
+
+ DOMRange* newRange = new DOMRange(range);
+
+ IDOMRange* domRange = nullptr;
+ if (FAILED(newRange->QueryInterface(IID_IDOMRange, reinterpret_cast<void**>(&domRange))))
+ return nullptr;
+
+ return newRange;
+}
+
+HRESULT DOMRange::startContainer(IDOMNode** node)
+{
+ if (!node)
+ return E_POINTER;
+
+ if (!m_range)
+ return E_UNEXPECTED;
+
+ *node = DOMNode::createInstance(m_range->startContainer());
+
+ return S_OK;
+}
+
+HRESULT DOMRange::startOffset(int* offset)
+{
+ if (!offset)
+ return E_POINTER;
+
+ if (!m_range)
+ return E_UNEXPECTED;
+
+ *offset = m_range->startOffset();
+
+ return S_OK;
+}
+
+HRESULT DOMRange::endContainer(IDOMNode** node)
+{
+ if (!node)
+ return E_POINTER;
+
+ if (!m_range)
+ return E_UNEXPECTED;
+
+ *node = DOMNode::createInstance(m_range->endContainer());
+
+ return S_OK;
+}
+
+HRESULT DOMRange::endOffset(int* offset)
+{
+ if (!offset)
+ return E_POINTER;
+
+ if (!m_range)
+ return E_UNEXPECTED;
+
+ *offset = m_range->endOffset();
+
+ return S_OK;
+}
+
+HRESULT DOMRange::collapsed(BOOL* result)
+{
+ if (!result)
+ return E_POINTER;
+
+ if (!m_range)
+ return E_UNEXPECTED;
+
+ WebCore::ExceptionCode ec = 0;
+ *result = m_range->collapsed(ec);
+
+ return S_OK;
+}
+
+HRESULT DOMRange::commonAncestorContainer(IDOMNode** container)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::setStart(IDOMNode* refNode, int offset)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::setEnd(IDOMNode* refNode, int offset)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::setStartBefore(IDOMNode* refNode)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::setStartAfter(IDOMNode* refNode)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::setEndBefore(IDOMNode* refNode)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::setEndAfter(IDOMNode* refNode)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::collapse(BOOL toStart)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::selectNode(IDOMNode* refNode)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::selectNodeContents(IDOMNode* refNode)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::compareBoundaryPoints(unsigned short how, IDOMRange* sourceRange)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::deleteContents()
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::extractContents(IDOMDocumentFragment** fragment)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::cloneContents(IDOMDocumentFragment** fragment)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::insertNode(IDOMNode* newNode)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::surroundContents(IDOMNode* newParent)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::cloneRange(IDOMRange** range)
+{
+ return E_NOTIMPL;
+}
+
+HRESULT DOMRange::toString(BSTR* str)
+{
+ if (!str)
+ return E_POINTER;
+
+ if (!m_range)
+ return E_UNEXPECTED;
+
+ WebCore::ExceptionCode ec = 0;
+ *str = BString(m_range->toString(ec)).release();
+
+ return S_OK;
+}
+
+HRESULT DOMRange::detach()
+{
+ return E_NOTIMPL;
+}
Modified: trunk/Source/WebKit/win/DOMCoreClasses.h (178964 => 178965)
--- trunk/Source/WebKit/win/DOMCoreClasses.h 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Source/WebKit/win/DOMCoreClasses.h 2015-01-22 23:46:41 UTC (rev 178965)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,6 +35,7 @@
class DOMWindow;
class Node;
class NodeList;
+class Range;
}
@@ -925,4 +926,87 @@
WebCore::Element* m_element;
};
+class DOMRange : public DOMObject, public IDOMRange {
+protected:
+ DOMRange(WebCore::Range*);
+ ~DOMRange();
+
+public:
+ static IDOMRange* createInstance(WebCore::Range*);
+
+public:
+ // IUnknown
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
+ virtual ULONG STDMETHODCALLTYPE AddRef(void) { return DOMObject::AddRef(); }
+ virtual ULONG STDMETHODCALLTYPE Release(void) { return DOMObject::Release(); }
+
+ // IWebScriptObject
+ virtual HRESULT STDMETHODCALLTYPE throwException(BSTR exceptionMessage, BOOL* result)
+ {
+ return DOMObject::throwException(exceptionMessage, result);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE callWebScriptMethod(BSTR name, const VARIANT args[], int cArgs, VARIANT* result)
+ {
+ return DOMObject::callWebScriptMethod(name, args, cArgs, result);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE evaluateWebScript(BSTR script, VARIANT* result)
+ {
+ return DOMObject::evaluateWebScript(script, result);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE removeWebScriptKey(BSTR name)
+ {
+ return DOMObject::removeWebScriptKey(name);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE stringRepresentation(BSTR* stringRepresentation)
+ {
+ return DOMObject::stringRepresentation(stringRepresentation);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE webScriptValueAtIndex(unsigned index, VARIANT* result)
+ {
+ return DOMObject::webScriptValueAtIndex(index, result);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE setWebScriptValueAtIndex(unsigned index, VARIANT val)
+ {
+ return DOMObject::setWebScriptValueAtIndex(index, val);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE setException(BSTR description)
+ {
+ return DOMObject::setException(description);
+ }
+
+ virtual HRESULT STDMETHODCALLTYPE startContainer(IDOMNode**);
+ virtual HRESULT STDMETHODCALLTYPE startOffset(int*);
+ virtual HRESULT STDMETHODCALLTYPE endContainer(IDOMNode**);
+ virtual HRESULT STDMETHODCALLTYPE endOffset(int*);
+ virtual HRESULT STDMETHODCALLTYPE collapsed(BOOL*);
+ virtual HRESULT STDMETHODCALLTYPE commonAncestorContainer(IDOMNode**);
+ virtual HRESULT STDMETHODCALLTYPE setStart(IDOMNode*, int offset);
+ virtual HRESULT STDMETHODCALLTYPE setEnd(IDOMNode*, int offset);
+ virtual HRESULT STDMETHODCALLTYPE setStartBefore(IDOMNode*);
+ virtual HRESULT STDMETHODCALLTYPE setStartAfter(IDOMNode*);
+ virtual HRESULT STDMETHODCALLTYPE setEndBefore(IDOMNode*);
+ virtual HRESULT STDMETHODCALLTYPE setEndAfter(IDOMNode*);
+ virtual HRESULT STDMETHODCALLTYPE collapse(BOOL);
+ virtual HRESULT STDMETHODCALLTYPE selectNode(IDOMNode*);
+ virtual HRESULT STDMETHODCALLTYPE selectNodeContents(IDOMNode*);
+ virtual HRESULT STDMETHODCALLTYPE compareBoundaryPoints(unsigned short how, IDOMRange* sourceRange);
+ virtual HRESULT STDMETHODCALLTYPE deleteContents();
+ virtual HRESULT STDMETHODCALLTYPE extractContents(IDOMDocumentFragment**);
+ virtual HRESULT STDMETHODCALLTYPE cloneContents(IDOMDocumentFragment**);
+ virtual HRESULT STDMETHODCALLTYPE insertNode(IDOMNode*);
+ virtual HRESULT STDMETHODCALLTYPE surroundContents(IDOMNode* newParent);
+ virtual HRESULT STDMETHODCALLTYPE cloneRange(IDOMRange**);
+ virtual HRESULT STDMETHODCALLTYPE toString(BSTR*);
+ virtual HRESULT STDMETHODCALLTYPE detach();
+
+protected:
+ WebCore::Range* m_range;
+};
#endif
Modified: trunk/Source/WebKit/win/Interfaces/IWebEditingDelegate.idl (178964 => 178965)
--- trunk/Source/WebKit/win/Interfaces/IWebEditingDelegate.idl 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Source/WebKit/win/Interfaces/IWebEditingDelegate.idl 2015-01-22 23:46:41 UTC (rev 178965)
@@ -113,7 +113,7 @@
/*
- (BOOL)webView:(WebView *)webView shouldInsertNode:(DOMNode *)node replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action;
*/
- HRESULT shouldInsertNode([in] IWebView* webView, [in] IDOMNode* node, [in] IDOMRange* range, [in] WebViewInsertAction action);
+ HRESULT shouldInsertNode([in] IWebView* webView, [in] IDOMNode* node, [in] IDOMRange* range, [in] WebViewInsertAction action, [out, retval] BOOL* result);
/*
- (BOOL)webView:(WebView *)webView shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action;
Modified: trunk/Source/WebKit/win/Interfaces/IWebView.idl (178964 => 178965)
--- trunk/Source/WebKit/win/Interfaces/IWebView.idl 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Source/WebKit/win/Interfaces/IWebView.idl 2015-01-22 23:46:41 UTC (rev 178965)
@@ -30,6 +30,10 @@
cpp_quote("#define WebViewProgressEstimateChangedNotification TEXT(\"WebProgressEstimateChangedNotification\")")
cpp_quote("#define WebViewProgressFinishedNotification TEXT(\"WebProgressFinishedNotification\")")
cpp_quote("#define WebViewDidChangeSelectionNotification TEXT(\"WebViewDidChangeSelectionNotification\")")
+cpp_quote("#define WebViewDidBeginEditingNotification TEXT(\"WebViewDidBeginEditingNotification\")")
+cpp_quote("#define WebViewDidEndEditingNotification TEXT(\"WebViewDidEndEditingNotification\")")
+cpp_quote("#define WebViewDidChangeTypingStyleNotification TEXT(\"WebViewDidChangeTypingStyleNotification\")")
+cpp_quote("#define WebViewDidChangeNotification TEXT(\"WebViewDidChangeNotification\")")
#ifndef DO_NO_IMPORTS
import "oaidl.idl";
Modified: trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp (178964 => 178965)
--- trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp 2015-01-22 23:46:41 UTC (rev 178965)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2011, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,6 +31,7 @@
#include "WebNotificationCenter.h"
#include "WebView.h"
#include "DOMCoreClasses.h"
+#include <comutil.h>
#include <WebCore/BString.h>
#include <WebCore/Document.h>
#include <WebCore/HTMLElement.h>
@@ -188,35 +189,57 @@
return 0;
}
-bool WebEditorClient::shouldBeginEditing(Range*)
+bool WebEditorClient::shouldBeginEditing(WebCore::Range* range)
{
- notImplemented();
- return true;
+ COMPtr<IWebEditingDelegate> ed;
+ if (FAILED(m_webView->editingDelegate(&ed)) || !ed.get())
+ return true;
+
+ COMPtr<IDOMRange> currentRange(AdoptCOM, DOMRange::createInstance(range));
+
+ BOOL shouldBegin = FALSE;
+ if (FAILED(ed->shouldBeginEditingInDOMRange(m_webView, currentRange.get(), &shouldBegin)))
+ return true;
+
+ return shouldBegin;
}
-bool WebEditorClient::shouldEndEditing(Range*)
+bool WebEditorClient::shouldEndEditing(Range* range)
{
- notImplemented();
- return true;
+ COMPtr<IWebEditingDelegate> ed;
+ if (FAILED(m_webView->editingDelegate(&ed)) || !ed.get())
+ return true;
+
+ COMPtr<IDOMRange> currentRange(AdoptCOM, DOMRange::createInstance(range));
+
+ BOOL shouldEnd = FALSE;
+ if (FAILED(ed->shouldEndEditingInDOMRange(m_webView, currentRange.get(), &shouldEnd)))
+ return true;
+
+ return shouldEnd;
}
void WebEditorClient::didBeginEditing()
{
- notImplemented();
+ static _bstr_t webViewDidBeginEditingNotificationName(WebViewDidBeginEditingNotification);
+ IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
+ notifyCenter->postNotificationName(webViewDidBeginEditingNotificationName.GetBSTR(), static_cast<IWebView*>(m_webView), nullptr);
}
void WebEditorClient::respondToChangedContents()
{
- notImplemented();
+ static _bstr_t webViewDidChangeNotificationName(WebViewDidChangeNotification);
+ IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
+ notifyCenter->postNotificationName(webViewDidChangeNotificationName.GetBSTR(), static_cast<IWebView*>(m_webView), 0);
}
void WebEditorClient::respondToChangedSelection(Frame*)
{
m_webView->selectionChanged();
- static BSTR webViewDidChangeSelectionNotificationName = SysAllocString(WebViewDidChangeSelectionNotification);
+ static _bstr_t webViewDidChangeSelectionNotificationName(WebViewDidChangeSelectionNotification);
IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
- notifyCenter->postNotificationName(webViewDidChangeSelectionNotificationName, static_cast<IWebView*>(m_webView), 0);
+ notifyCenter->postNotificationName(webViewDidChangeSelectionNotificationName.GetBSTR(), static_cast<IWebView*>(m_webView), 0);
}
void WebEditorClient::discardedComposition(Frame*)
@@ -226,7 +249,9 @@
void WebEditorClient::didEndEditing()
{
- notImplemented();
+ static _bstr_t webViewDidEndEditingNotificationName(WebViewDidEndEditingNotification);
+ IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
+ notifyCenter->postNotificationName(webViewDidEndEditingNotificationName.GetBSTR(), static_cast<IWebView*>(m_webView), nullptr);
}
void WebEditorClient::didWriteSelectionToPasteboard()
@@ -244,50 +269,76 @@
notImplemented();
}
-bool WebEditorClient::shouldDeleteRange(Range* /*range*/)
+bool WebEditorClient::shouldDeleteRange(Range* range)
{
- notImplemented();
- return true;
+ COMPtr<IWebEditingDelegate> ed;
+ if (FAILED(m_webView->editingDelegate(&ed)) || !ed.get())
+ return true;
- // FIXME: calling m_webView->editingDelegate() will cause an assertion failure so we don't want to enable this code until that's implemented.
- //BOOL result = false;
- //IWebViewEditingDelegate* editingDelegate;
- //// FIXME: DOMRange needs to be implemented before anything meaningful can be done here
- //IDOMRange* domRange(0);
- //if (SUCCEEDED(m_webView->editingDelegate(&editingDelegate))) {
- // editingDelegate->shouldDeleteDOMRange(m_webView, domRange, &result);
- // editingDelegate->Release();
- //}
- //return !!result;
+ COMPtr<IDOMRange> currentRange(AdoptCOM, DOMRange::createInstance(range));
+
+ BOOL shouldDelete = FALSE;
+ if (FAILED(ed->shouldDeleteDOMRange(m_webView, currentRange.get(), &shouldDelete)))
+ return true;
+
+ return shouldDelete;
}
-bool WebEditorClient::shouldInsertNode(Node* /*node*/, Range* /*replacingRange*/, EditorInsertAction /*givenAction*/)
+bool WebEditorClient::shouldInsertNode(Node* node, Range* insertingRange, EditorInsertAction givenAction)
{
- notImplemented();
- return true;
+ COMPtr<IWebEditingDelegate> editingDelegate;
+ if (FAILED(m_webView->editingDelegate(&editingDelegate)) || !editingDelegate.get())
+ return true;
+
+ COMPtr<IDOMRange> insertingDOMRange(AdoptCOM, DOMRange::createInstance(insertingRange));
+ if (!insertingDOMRange)
+ return true;
+
+ COMPtr<IDOMNode> insertDOMNode(AdoptCOM, DOMNode::createInstance(node));
+ if (!insertDOMNode)
+ return true;
+
+ BOOL shouldInsert = FALSE;
+ if (FAILED(editingDelegate->shouldInsertNode(m_webView, insertDOMNode.get(), insertingDOMRange.get(), static_cast<WebViewInsertAction>(givenAction), &shouldInsert)))
+ return true;
+
+ return shouldInsert;
}
-bool WebEditorClient::shouldInsertText(const String& /*str*/, Range* /* replacingRange */, EditorInsertAction /*givenAction*/)
-{
- notImplemented();
- return true;
+bool WebEditorClient::shouldInsertText(const String& str, Range* insertingRange, EditorInsertAction givenAction)
+{
+ COMPtr<IWebEditingDelegate> editingDelegate;
+ if (FAILED(m_webView->editingDelegate(&editingDelegate)) || !editingDelegate.get())
+ return true;
- // FIXME: calling m_webView->editingDelegate() will cause an assertion failure so we don't want to enable this code until that's implemented.
- //BOOL result = false;
- //IWebViewEditingDelegate* editingDelegate;
- //// FIXME: DOMRange needs to be implemented before anything meaningful can be done here
- //IDOMRange* domRange(0); // make a DOMRange from replacingRange
- //BString text(str);
- //if (SUCCEEDED(m_webView->editingDelegate(&editingDelegate))) {
- // editingDelegate->shouldInsertText(m_webView, text, domRange, (WebViewInsertAction) givenAction, &result);
- // editingDelegate->Release();
- //}
- //return !!result;
+ COMPtr<IDOMRange> insertingDOMRange(AdoptCOM, DOMRange::createInstance(insertingRange));
+ if (!insertingDOMRange)
+ return true;
+
+ BString text(str);
+ BOOL shouldInsert = FALSE;
+ if (FAILED(editingDelegate->shouldInsertText(m_webView, text, insertingDOMRange.get(), static_cast<WebViewInsertAction>(givenAction), &shouldInsert)))
+ return true;
+
+ return shouldInsert;
}
-//bool WebEditorClient::shouldChangeSelectedRange(Range *currentRange, Range *toProposedRange, SelectionAffinity selectionAffinity, bool stillSelecting)
-//{ notImplemented(); return false; }
+bool WebEditorClient::shouldChangeSelectedRange(WebCore::Range* currentRange, WebCore::Range* proposedRange, WebCore::EAffinity selectionAffinity, bool flag)
+{
+ COMPtr<IWebEditingDelegate> ed;
+ if (FAILED(m_webView->editingDelegate(&ed)) || !ed.get())
+ return true;
+ COMPtr<IDOMRange> currentIDOMRange(AdoptCOM, DOMRange::createInstance(currentRange));
+ COMPtr<IDOMRange> proposedIDOMRange(AdoptCOM, DOMRange::createInstance(proposedRange));
+
+ BOOL shouldChange = FALSE;
+ if (FAILED(ed->shouldChangeSelectedDOMRange(m_webView, currentIDOMRange.get(), proposedIDOMRange.get(), static_cast<WebSelectionAffinity>(selectionAffinity), flag, &shouldChange)))
+ return true;
+
+ return shouldChange;
+}
+
bool WebEditorClient::shouldApplyStyle(StyleProperties* /*style*/, Range* /*toElementsInDOMRange*/)
{ notImplemented(); return true; }
@@ -298,10 +349,14 @@
{ notImplemented(); return false; }
void WebEditorClient::webViewDidChangeTypingStyle(WebNotification* /*notification*/)
-{ notImplemented(); }
+{
+ notImplemented();
+}
void WebEditorClient::webViewDidChangeSelection(WebNotification* /*notification*/)
-{ notImplemented(); }
+{
+ notImplemented();
+}
bool WebEditorClient::smartInsertDeleteEnabled(void)
{
@@ -319,9 +374,6 @@
return page->settings().selectTrailingWhitespaceEnabled();
}
-bool WebEditorClient::shouldChangeSelectedRange(WebCore::Range*, WebCore::Range*, WebCore::EAffinity, bool)
-{ notImplemented(); return true; }
-
void WebEditorClient::textFieldDidBeginEditing(Element* e)
{
IWebFormDelegate* formDelegate;
Modified: trunk/Source/WebKit/win/WebView.cpp (178964 => 178965)
--- trunk/Source/WebKit/win/WebView.cpp 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Source/WebKit/win/WebView.cpp 2015-01-22 23:46:41 UTC (rev 178965)
@@ -4340,10 +4340,39 @@
return E_NOTIMPL;
}
-HRESULT STDMETHODCALLTYPE WebView::setEditingDelegate(
- /* [in] */ IWebEditingDelegate* d)
+HRESULT WebView::setEditingDelegate(IWebEditingDelegate* d)
{
+ if (m_editingDelegate == d)
+ return S_OK;
+
+ static BSTR webViewDidBeginEditingNotificationName = SysAllocString(WebViewDidBeginEditingNotification);
+ static BSTR webViewDidChangeSelectionNotificationName = SysAllocString(WebViewDidChangeSelectionNotification);
+ static BSTR webViewDidEndEditingNotificationName = SysAllocString(WebViewDidEndEditingNotification);
+ static BSTR webViewDidChangeTypingStyleNotificationName = SysAllocString(WebViewDidChangeTypingStyleNotification);
+ static BSTR webViewDidChangeNotificationName = SysAllocString(WebViewDidChangeNotification);
+
+ IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
+
+ COMPtr<IWebNotificationObserver> wasObserver(Query, m_editingDelegate);
+ if (wasObserver) {
+ notifyCenter->removeObserver(wasObserver.get(), webViewDidBeginEditingNotificationName, nullptr);
+ notifyCenter->removeObserver(wasObserver.get(), webViewDidChangeSelectionNotificationName, nullptr);
+ notifyCenter->removeObserver(wasObserver.get(), webViewDidEndEditingNotificationName, nullptr);
+ notifyCenter->removeObserver(wasObserver.get(), webViewDidChangeTypingStyleNotificationName, nullptr);
+ notifyCenter->removeObserver(wasObserver.get(), webViewDidChangeNotificationName, nullptr);
+ }
+
m_editingDelegate = d;
+
+ COMPtr<IWebNotificationObserver> isObserver(Query, m_editingDelegate);
+ if (isObserver) {
+ notifyCenter->addObserver(isObserver.get(), webViewDidBeginEditingNotificationName, nullptr);
+ notifyCenter->addObserver(isObserver.get(), webViewDidChangeSelectionNotificationName, nullptr);
+ notifyCenter->addObserver(isObserver.get(), webViewDidEndEditingNotificationName, nullptr);
+ notifyCenter->addObserver(isObserver.get(), webViewDidChangeTypingStyleNotificationName, nullptr);
+ notifyCenter->addObserver(isObserver.get(), webViewDidChangeNotificationName, nullptr);
+ }
+
return S_OK;
}
Modified: trunk/Tools/ChangeLog (178964 => 178965)
--- trunk/Tools/ChangeLog 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Tools/ChangeLog 2015-01-22 23:46:41 UTC (rev 178965)
@@ -1,3 +1,39 @@
+2015-01-22 Brent Fulgham <bfulg...@apple.com>
+
+ [Win] Expose missing editing features through WebView interface
+ https://bugs.webkit.org/show_bug.cgi?id=140773
+ <rdar://problem/19565421>
+
+ Reviewed by Dean Jackson.
+
+ Connect the various WebView editing delegate methods to our
+ test infrastructure. Also prefer _bstr_t to raw BSTR types
+ to simplify life cycle management.
+
+ * DumpRenderTree/win/DumpRenderTree.cpp:
+ (resetWebViewToConsistentStateBeforeTesting):
+ * DumpRenderTree/win/EditingDelegate.cpp:
+ (EditingDelegate::QueryInterface):
+ (dumpPath):
+ (dump):
+ (EditingDelegate::shouldBeginEditingInDOMRange):
+ (EditingDelegate::shouldEndEditingInDOMRange):
+ (EditingDelegate::shouldInsertNode):
+ (EditingDelegate::shouldInsertText):
+ (EditingDelegate::shouldDeleteDOMRange):
+ (EditingDelegate::shouldChangeSelectedDOMRange):
+ (EditingDelegate::shouldApplyStyle):
+ (EditingDelegate::shouldChangeTypingStyle):
+ (EditingDelegate::doPlatformCommand):
+ (EditingDelegate::webViewDidBeginEditing):
+ (EditingDelegate::webViewDidChange):
+ (EditingDelegate::webViewDidEndEditing):
+ (EditingDelegate::webViewDidChangeTypingStyle):
+ (EditingDelegate::webViewDidChangeSelection):
+ (EditingDelegate::checkSpellingOfString):
+ (EditingDelegate::onNotify):
+ * DumpRenderTree/win/EditingDelegate.h:
+
2015-01-22 Ryosuke Niwa <rn...@webkit.org>
Add a build flag for ES6 class syntax
Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (178964 => 178965)
--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp 2015-01-22 23:46:41 UTC (rev 178965)
@@ -866,6 +866,19 @@
if (FAILED(frame->webView(&webView)))
return;
+ COMPtr<IWebViewEditing> viewEditing;
+ if (SUCCEEDED(webView->QueryInterface(&viewEditing)) && viewEditing) {
+
+ viewEditing->setEditable(FALSE);
+
+ COMPtr<IWebEditingDelegate> delegate;
+ if (SUCCEEDED(viewEditing->editingDelegate(&delegate)) && delegate) {
+ COMPtr<EditingDelegate> editingDelegate(Query, viewEditing.get());
+ if (editingDelegate)
+ editingDelegate->setAcceptsEditing(TRUE);
+ }
+ }
+
COMPtr<IWebIBActions> webIBActions(Query, webView);
if (webIBActions) {
webIBActions->makeTextStandardSize(0);
Modified: trunk/Tools/DumpRenderTree/win/EditingDelegate.cpp (178964 => 178965)
--- trunk/Tools/DumpRenderTree/win/EditingDelegate.cpp 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Tools/DumpRenderTree/win/EditingDelegate.cpp 2015-01-22 23:46:41 UTC (rev 178965)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2014-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,6 +35,7 @@
#include <WebCore/COMPtr.h>
#include <wtf/Assertions.h>
#include <wtf/Platform.h>
+#include <wtf/StringExtras.h>
#include <string>
#include <tchar.h>
@@ -54,6 +55,8 @@
*ppvObject = static_cast<IWebEditingDelegate*>(this);
else if (IsEqualGUID(riid, IID_IWebEditingDelegate))
*ppvObject = static_cast<IWebEditingDelegate*>(this);
+ else if (IsEqualGUID(riid, IID_IWebNotificationObserver))
+ *ppvObject = static_cast<IWebNotificationObserver*>(this);
else
return E_NOINTERFACE;
@@ -75,46 +78,47 @@
return newRef;
}
-static wstring dumpPath(IDOMNode* node)
+static std::string dumpPath(IDOMNode* node)
{
ASSERT(node);
- wstring result;
+ std::string result;
_bstr_t name;
if (FAILED(node->nodeName(&name.GetBSTR())))
return result;
- result.assign(static_cast<wchar_t*>(name), name.length());
+ result.assign(static_cast<const char*>(name), name.length());
COMPtr<IDOMNode> parent;
if (SUCCEEDED(node->parentNode(&parent)))
- result += TEXT(" > ") + dumpPath(parent.get());
+ result += " > " + dumpPath(parent.get());
return result;
}
-static wstring dump(IDOMRange* range)
+static std::string dump(IDOMRange* range)
{
- ASSERT(range);
+ if (!range)
+ return std::string();
int startOffset;
if (FAILED(range->startOffset(&startOffset)))
- return 0;
+ return std::string();
int endOffset;
if (FAILED(range->endOffset(&endOffset)))
- return 0;
+ return std::string();
COMPtr<IDOMNode> startContainer;
if (FAILED(range->startContainer(&startContainer)))
- return 0;
+ return std::string();
COMPtr<IDOMNode> endContainer;
if (FAILED(range->endContainer(&endContainer)))
- return 0;
+ return std::string();
- wchar_t buffer[1024];
- _snwprintf(buffer, ARRAYSIZE(buffer), L"range from %ld of %s to %ld of %s", startOffset, dumpPath(startContainer.get()).c_str(), endOffset, dumpPath(endContainer.get()).c_str());
+ char buffer[1024];
+ snprintf(buffer, ARRAYSIZE(buffer), "range from %ld of %s to %ld of %s", startOffset, dumpPath(startContainer.get()).c_str(), endOffset, dumpPath(endContainer.get()).c_str());
return buffer;
}
@@ -126,7 +130,7 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n"), dump(range).c_str());
+ printf("EDITING DELEGATE: shouldBeginEditingInDOMRange:%s\n", dump(range).c_str());
*result = m_acceptsEditing;
return S_OK;
@@ -140,23 +144,24 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n"), dump(range).c_str());
+ printf("EDITING DELEGATE: shouldEndEditingInDOMRange:%s\n", dump(range).c_str());
*result = m_acceptsEditing;
return S_OK;
}
-HRESULT EditingDelegate::shouldInsertNode(IWebView* /*webView*/, IDOMNode* node, IDOMRange* range, WebViewInsertAction action)
+HRESULT EditingDelegate::shouldInsertNode(IWebView* /*webView*/, IDOMNode* node, IDOMRange* range, WebViewInsertAction action, BOOL* result)
{
- static LPCTSTR insertactionstring[] = {
- TEXT("WebViewInsertActionTyped"),
- TEXT("WebViewInsertActionPasted"),
- TEXT("WebViewInsertActionDropped"),
+ static const char* insertActionString[] = {
+ "WebViewInsertActionTyped",
+ "WebViewInsertActionPasted",
+ "WebViewInsertActionDropped",
};
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n"), dumpPath(node).c_str(), dump(range).c_str(), insertactionstring[action]);
+ printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", dumpPath(node).c_str(), dump(range).c_str(), insertActionString[action]);
+ *result = m_acceptsEditing;
return S_OK;
}
@@ -167,14 +172,16 @@
return E_POINTER;
}
- static LPCTSTR insertactionstring[] = {
- TEXT("WebViewInsertActionTyped"),
- TEXT("WebViewInsertActionPasted"),
- TEXT("WebViewInsertActionDropped"),
+ static const char* insertactionstring[] = {
+ "WebViewInsertActionTyped",
+ "WebViewInsertActionPasted",
+ "WebViewInsertActionDropped",
};
- if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n"), text ? text : TEXT(""), dump(range).c_str(), insertactionstring[action]);
+ if (::gTestRunner->dumpEditingCallbacks() && !done) {
+ _bstr_t textBstr(text);
+ printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n", static_cast<const char*>(textBstr), dump(range).c_str(), insertactionstring[action]);
+ }
*result = m_acceptsEditing;
return S_OK;
@@ -188,7 +195,7 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldDeleteDOMRange:%s\n"), dump(range).c_str());
+ printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", dump(range).c_str());
*result = m_acceptsEditing;
return S_OK;
@@ -202,17 +209,17 @@
return E_POINTER;
}
- static LPCTSTR affinitystring[] = {
- TEXT("NSSelectionAffinityUpstream"),
- TEXT("NSSelectionAffinityDownstream")
+ static const char* affinityString[] = {
+ "NSSelectionAffinityUpstream",
+ "NSSelectionAffinityDownstream"
};
- static LPCTSTR boolstring[] = {
- TEXT("FALSE"),
- TEXT("TRUE")
+ static const char* boolstring[] = {
+ "FALSE",
+ "TRUE"
};
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n"), dump(currentRange).c_str(), dump(proposedRange).c_str(), affinitystring[selectionAffinity], boolstring[stillSelecting]);
+ printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n", dump(currentRange).c_str(), dump(proposedRange).c_str(), affinityString[selectionAffinity], boolstring[stillSelecting]);
*result = m_acceptsEditing;
return S_OK;
@@ -226,7 +233,7 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n"), TEXT("'style description'")/*[[style description] UTF8String]*/, dump(range).c_str());
+ printf("EDITING DELEGATE: shouldApplyStyle:%s toElementsInDOMRange:%s\n", "'style description'"/*[[style description] UTF8String]*/, dump(range).c_str());
*result = m_acceptsEditing;
return S_OK;
@@ -240,7 +247,7 @@
}
if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: shouldChangeTypingStyle:%s toStyle:%s\n"), TEXT("'currentStyle description'"), TEXT("'proposedStyle description'"));
+ printf("EDITING DELEGATE: shouldChangeTypingStyle:%s toStyle:%s\n", "'currentStyle description'", "'proposedStyle description'");
*result = m_acceptsEditing;
return S_OK;
@@ -253,8 +260,10 @@
return E_POINTER;
}
- if (::gTestRunner->dumpEditingCallbacks() && !done)
- _tprintf(TEXT("EDITING DELEGATE: doPlatformCommand:%s\n"), command ? command : TEXT(""));
+ if (::gTestRunner->dumpEditingCallbacks() && !done) {
+ _bstr_t commandBSTR(command);
+ printf("EDITING DELEGATE: doPlatformCommand:%s\n", static_cast<const char*>(commandBSTR));
+ }
*result = m_acceptsEditing;
return S_OK;
@@ -265,7 +274,7 @@
if (::gTestRunner->dumpEditingCallbacks() && !done) {
_bstr_t name;
notification->name(&name.GetBSTR());
- _tprintf(TEXT("EDITING DELEGATE: webViewDidBeginEditing:%s\n"), static_cast<TCHAR*>(name));
+ printf("EDITING DELEGATE: webViewDidBeginEditing:%s\n", static_cast<const char*>(name));
}
return S_OK;
}
@@ -275,7 +284,7 @@
if (::gTestRunner->dumpEditingCallbacks() && !done) {
_bstr_t name;
notification->name(&name.GetBSTR());
- _tprintf(TEXT("EDITING DELEGATE: webViewDidBeginEditing:%s\n"), static_cast<TCHAR*>(name));
+ printf("EDITING DELEGATE: webViewDidChange:%s\n", static_cast<const char*>(name));
}
return S_OK;
}
@@ -285,7 +294,7 @@
if (::gTestRunner->dumpEditingCallbacks() && !done) {
_bstr_t name;
notification->name(&name.GetBSTR());
- _tprintf(TEXT("EDITING DELEGATE: webViewDidEndEditing:%s\n"), static_cast<TCHAR*>(name));
+ printf("EDITING DELEGATE: webViewDidEndEditing:%s\n", static_cast<const char*>(name));
}
return S_OK;
}
@@ -295,7 +304,7 @@
if (::gTestRunner->dumpEditingCallbacks() && !done) {
_bstr_t name;
notification->name(&name.GetBSTR());
- _tprintf(TEXT("EDITING DELEGATE: webViewDidChangeTypingStyle:%s\n"), static_cast<TCHAR*>(name));
+ printf("EDITING DELEGATE: webViewDidChangeTypingStyle:%s\n", static_cast<const char*>(name));
}
return S_OK;
}
@@ -305,7 +314,7 @@
if (::gTestRunner->dumpEditingCallbacks() && !done) {
_bstr_t name;
notification->name(&name.GetBSTR());
- _tprintf(TEXT("EDITING DELEGATE: webViewDidChangeSelection:%s\n"), static_cast<TCHAR*>(name));
+ printf("EDITING DELEGATE: webViewDidChangeSelection:%s\n", static_cast<const char*>(name));
}
return S_OK;
}
@@ -378,3 +387,34 @@
return S_OK;
}
+
+HRESULT EditingDelegate::onNotify(IWebNotification* notification)
+{
+ _bstr_t notificationName;
+ HRESULT hr = notification->name(¬ificationName.GetBSTR());
+ if (FAILED(hr))
+ return hr;
+
+ static _bstr_t webViewDidBeginEditingNotificationName(WebViewDidBeginEditingNotification);
+ static _bstr_t webViewDidChangeSelectionNotificationName(WebViewDidChangeSelectionNotification);
+ static _bstr_t webViewDidEndEditingNotificationName(WebViewDidEndEditingNotification);
+ static _bstr_t webViewDidChangeTypingStyleNotificationName(WebViewDidChangeTypingStyleNotification);
+ static _bstr_t webViewDidChangeNotificationName(WebViewDidChangeNotification);
+
+ if (!wcscmp(notificationName, webViewDidBeginEditingNotificationName))
+ return webViewDidBeginEditing(notification);
+
+ if (!wcscmp(notificationName, webViewDidChangeSelectionNotificationName))
+ return webViewDidChangeSelection(notification);
+
+ if (!wcscmp(notificationName, webViewDidEndEditingNotificationName))
+ return webViewDidEndEditing(notification);
+
+ if (!wcscmp(notificationName, webViewDidChangeTypingStyleNotificationName))
+ return webViewDidChangeTypingStyle(notification);
+
+ if (!wcscmp(notificationName, webViewDidChangeNotificationName))
+ return webViewDidChange(notification);
+
+ return S_OK;
+}
Modified: trunk/Tools/DumpRenderTree/win/EditingDelegate.h (178964 => 178965)
--- trunk/Tools/DumpRenderTree/win/EditingDelegate.h 2015-01-22 23:42:46 UTC (rev 178964)
+++ trunk/Tools/DumpRenderTree/win/EditingDelegate.h 2015-01-22 23:46:41 UTC (rev 178965)
@@ -31,7 +31,7 @@
#include <WebKit/WebKit.h>
-class __declspec(uuid("265DCD4B-79C3-44a2-84BC-511C3EDABD6F")) EditingDelegate : public IWebEditingDelegate {
+class __declspec(uuid("265DCD4B-79C3-44a2-84BC-511C3EDABD6F")) EditingDelegate : public IWebEditingDelegate, public IWebNotificationObserver {
public:
EditingDelegate();
@@ -53,11 +53,7 @@
/* [in] */ IDOMRange *range,
/* [retval][out] */ BOOL *result);
- virtual HRESULT STDMETHODCALLTYPE shouldInsertNode(
- /* [in] */ IWebView *webView,
- /* [in] */ IDOMNode *node,
- /* [in] */ IDOMRange *range,
- /* [in] */ WebViewInsertAction action);
+ virtual HRESULT STDMETHODCALLTYPE shouldInsertNode(IWebView*, IDOMNode*, IDOMRange*, WebViewInsertAction, BOOL* result);
virtual HRESULT STDMETHODCALLTYPE shouldInsertText(
/* [in] */ IWebView *webView,
@@ -168,6 +164,9 @@
virtual HRESULT STDMETHODCALLTYPE updateGrammar( void) { return E_NOTIMPL; }
+ // IWebNotificationObserver
+ virtual HRESULT STDMETHODCALLTYPE onNotify(IWebNotification* notification);
+
private:
bool m_acceptsEditing;
ULONG m_refCount;