WebEditorClientGLib.cpp [plain text]
#include "config.h"
#include "WebEditorClient.h"
#include <WebCore/CompositionHighlight.h>
#include <WebCore/Document.h>
#include <WebCore/Editor.h>
#include <WebCore/Frame.h>
#include <WebCore/KeyboardEvent.h>
#include <WebCore/PlatformKeyboardEvent.h>
#include <WebPage.h>
namespace WebKit {
using namespace WebCore;
void WebEditorClient::handleInputMethodKeydown(KeyboardEvent& event)
{
auto* platformEvent = event.underlyingPlatformEvent();
if (platformEvent && platformEvent->handledByInputMethod())
event.setDefaultHandled();
}
void WebEditorClient::didDispatchInputMethodKeydown(KeyboardEvent& event)
{
auto* platformEvent = event.underlyingPlatformEvent();
ASSERT(event.target());
auto* frame = downcast<Node>(event.target())->document().frame();
ASSERT(frame);
if (const auto& underlines = platformEvent->preeditUnderlines()) {
auto rangeStart = platformEvent->preeditSelectionRangeStart().valueOr(0);
auto rangeLength = platformEvent->preeditSelectionRangeLength().valueOr(0);
frame->editor().setComposition(platformEvent->text(), underlines.value(), { }, rangeStart, rangeStart + rangeLength);
} else
frame->editor().confirmComposition(platformEvent->text());
}
}