summaryrefslogtreecommitdiff
path: root/Source/WebKit/win
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/win')
-rw-r--r--Source/WebKit/win/ChangeLog17
-rw-r--r--Source/WebKit/win/Interfaces/IWebViewPrivate.idl13
-rw-r--r--Source/WebKit/win/WebView.cpp138
-rw-r--r--Source/WebKit/win/WebView.h19
4 files changed, 187 insertions, 0 deletions
diff --git a/Source/WebKit/win/ChangeLog b/Source/WebKit/win/ChangeLog
index 471fef3de..8e6d35209 100644
--- a/Source/WebKit/win/ChangeLog
+++ b/Source/WebKit/win/ChangeLog
@@ -1,3 +1,20 @@
+2012-05-25 Lynn Neir <lynn.neir@skype.net>
+
+ Added methods needed to implement backend for DRT's TextInputController on windows, https://bugs.webkit.org/show_bug.cgi?id=32021
+
+ Reviewed by Eric Seidel.
+
+ * Interfaces/IWebViewPrivate.idl:
+ * WebView.cpp:
+ (WebView::setCompositionForTesting):
+ (WebView::hasCompositionForTesting):
+ (WebView::confirmCompositionForTesting):
+ (WebView::compositionRangeForTesting):
+ (WebView::firstRectForCharacterRangeForTesting):
+ (WebView::selectedRangeForTesting):
+ * WebView.h:
+ (WebView):
+
2012-05-21 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Move setEditingBehavior() from layoutTestController to window.internals
diff --git a/Source/WebKit/win/Interfaces/IWebViewPrivate.idl b/Source/WebKit/win/Interfaces/IWebViewPrivate.idl
index b4619494f..6b51cb3e5 100644
--- a/Source/WebKit/win/Interfaces/IWebViewPrivate.idl
+++ b/Source/WebKit/win/Interfaces/IWebViewPrivate.idl
@@ -277,4 +277,17 @@ interface IWebViewPrivate : IUnknown
HRESULT registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing([in] BSTR scheme);
HRESULT registerURLSchemeAsAllowingDatabaseAccessInPrivateBrowsing([in] BSTR scheme);
+ // Used by TextInputController in DumpRenderTree
+
+ HRESULT setCompositionForTesting([in] BSTR composition,[in] UINT from,[in] UINT length);
+
+ HRESULT hasCompositionForTesting([out, retval] BOOL* result);
+
+ HRESULT confirmCompositionForTesting([in] BSTR composition);
+
+ HRESULT compositionRangeForTesting([out] UINT* startPosition, [out] UINT* length);
+
+ HRESULT firstRectForCharacterRangeForTesting([in] UINT location, [in] UINT length, [out, retval] RECT* resultRect);
+
+ HRESULT selectedRangeForTesting([out] UINT* location, [out] UINT* length);
}
diff --git a/Source/WebKit/win/WebView.cpp b/Source/WebKit/win/WebView.cpp
index faebc7533..cc2df329b 100644
--- a/Source/WebKit/win/WebView.cpp
+++ b/Source/WebKit/win/WebView.cpp
@@ -33,6 +33,7 @@
#include "FullscreenVideoController.h"
#include "MarshallingHelpers.h"
#include "SoftLinking.h"
+#include "TextIterator.h"
#include "WebBackForwardList.h"
#include "WebChromeClient.h"
#include "WebContextMenuClient.h"
@@ -6883,3 +6884,140 @@ void WebView::fullScreenClientForceRepaint()
}
#endif
+// Used by TextInputController in DumpRenderTree
+
+HRESULT STDMETHODCALLTYPE WebView::setCompositionForTesting(
+ /* [in] */ BSTR composition,
+ /* [in] */ UINT from,
+ /* [in] */ UINT length)
+{
+ if (!m_page)
+ return E_FAIL;
+
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame || !frame->editor()->canEdit())
+ return E_FAIL;
+
+ String compositionStr(composition, SysStringLen(composition));
+
+ Vector<CompositionUnderline> underlines;
+ underlines.append(CompositionUnderline(0, compositionStr.length(), Color(Color::black), false));
+ frame->editor()->setComposition(compositionStr, underlines, from, from + length);
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebView::hasCompositionForTesting(/* [out, retval] */ BOOL* result)
+{
+ if (!m_page)
+ return E_FAIL;
+
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame)
+ return E_FAIL;
+
+ *result = frame && frame->editor()->hasComposition();
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebView::confirmCompositionForTesting(/* [in] */ BSTR composition)
+{
+ if (!m_page)
+ return E_FAIL;
+
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame || !frame->editor()->canEdit())
+ return E_FAIL;
+
+ String compositionStr(composition, SysStringLen(composition));
+
+ if (compositionStr.isNull())
+ frame->editor()->confirmComposition();
+
+ frame->editor()->confirmComposition(compositionStr);
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebView::compositionRangeForTesting(/* [out] */ UINT* startPosition, /* [out] */ UINT* length)
+{
+ if (!m_page)
+ return E_FAIL;
+
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame || !frame->editor()->canEdit())
+ return E_FAIL;
+
+ RefPtr<Range> range = frame->editor()->compositionRange();
+
+ if (!range)
+ return E_FAIL;
+
+ *startPosition = range->startOffset();
+ *length = range->startOffset() + range->endOffset();
+
+ return S_OK;
+}
+
+
+HRESULT STDMETHODCALLTYPE WebView::firstRectForCharacterRangeForTesting(
+ /* [in] */ UINT location,
+ /* [in] */ UINT length,
+ /* [out, retval] */ RECT* resultRect)
+{
+ if (!m_page)
+ return E_FAIL;
+
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame)
+ return E_FAIL;
+
+ IntRect resultIntRect;
+ resultIntRect.setLocation(IntPoint(0, 0));
+ resultIntRect.setSize(IntSize(0, 0));
+
+ if (location > INT_MAX)
+ return E_FAIL;
+ if (length > INT_MAX || location + length > INT_MAX)
+ length = INT_MAX - location;
+
+ RefPtr<Range> range = TextIterator::rangeFromLocationAndLength(frame->selection()->rootEditableElementOrDocumentElement(), location, length);
+
+ if (!range)
+ return E_FAIL;
+
+ ASSERT(range->startContainer());
+ ASSERT(range->endContainer());
+
+ IntRect rect = frame->editor()->firstRectForRange(range.get());
+ resultIntRect = frame->view()->contentsToWindow(rect);
+
+ resultRect->left = resultIntRect.x();
+ resultRect->top = resultIntRect.y();
+ resultRect->right = resultIntRect.x() + resultIntRect.width();
+ resultRect->bottom = resultIntRect.y() + resultIntRect.height();
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebView::selectedRangeForTesting(/* [out] */ UINT* location, /* [out] */ UINT* length)
+{
+ if (!m_page)
+ return E_FAIL;
+
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame)
+ return E_FAIL;
+
+ RefPtr<Range> range = frame->editor()->selectedRange();
+
+ size_t locationSize;
+ size_t lengthSize;
+ if (range && TextIterator::getLocationAndLengthFromRange(frame->selection()->rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) {
+ *location = static_cast<UINT>(locationSize);
+ *length = static_cast<UINT>(lengthSize);
+ }
+
+ return S_OK;
+}
diff --git a/Source/WebKit/win/WebView.h b/Source/WebKit/win/WebView.h
index 3a0f95aff..821c7e9f4 100644
--- a/Source/WebKit/win/WebView.h
+++ b/Source/WebKit/win/WebView.h
@@ -962,6 +962,25 @@ public:
WebCore::Element* fullScreenElement() const { return m_fullScreenElement.get(); }
#endif
+ // Used by TextInputController in DumpRenderTree
+
+ HRESULT STDMETHODCALLTYPE setCompositionForTesting(
+ /* [in] */ BSTR composition,
+ /* [in] */ UINT from,
+ /* [in] */ UINT length);
+
+ HRESULT STDMETHODCALLTYPE hasCompositionForTesting(/* [out, retval] */ BOOL* result);
+
+ HRESULT STDMETHODCALLTYPE confirmCompositionForTesting(/* [in] */ BSTR composition);
+
+ HRESULT STDMETHODCALLTYPE compositionRangeForTesting(/* [out] */ UINT* startPosition, /* [out] */ UINT* length);
+
+ HRESULT STDMETHODCALLTYPE firstRectForCharacterRangeForTesting(
+ /* [in] */ UINT location,
+ /* [in] */ UINT length,
+ /* [out, retval] */ RECT* resultRect);
+
+ HRESULT STDMETHODCALLTYPE selectedRangeForTesting(/* [out] */ UINT* location, /* [out] */ UINT* length);
private:
void setZoomMultiplier(float multiplier, bool isTextOnly);
float zoomMultiplier(bool isTextOnly);