diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp | 84 |
1 files changed, 73 insertions, 11 deletions
diff --git a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp index cb3f9b6e6..46cfa34a0 100644 --- a/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp +++ b/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp @@ -28,13 +28,29 @@ #include "WKBundleNodeHandlePrivate.h" #include "InjectedBundleNodeHandle.h" +#include "InjectedBundleRangeHandle.h" #include "WKAPICast.h" #include "WKBundleAPICast.h" #include "WebFrame.h" #include "WebImage.h" +#include <WebCore/HTMLTextFormControlElement.h> using namespace WebKit; +static WebCore::AutoFillButtonType toAutoFillButtonType(WKAutoFillButtonType wkAutoFillButtonType) +{ + switch (wkAutoFillButtonType) { + case kWKAutoFillButtonTypeNone: + return WebCore::AutoFillButtonType::None; + case kWKAutoFillButtonTypeContacts: + return WebCore::AutoFillButtonType::Contacts; + case kWKAutoFillButtonTypeCredentials: + return WebCore::AutoFillButtonType::Credentials; + } + ASSERT_NOT_REACHED(); + return WebCore::AutoFillButtonType::None; +} + WKTypeID WKBundleNodeHandleGetTypeID() { return toAPI(InjectedBundleNodeHandle::APIType); @@ -43,13 +59,13 @@ WKTypeID WKBundleNodeHandleGetTypeID() WKBundleNodeHandleRef WKBundleNodeHandleCreate(JSContextRef contextRef, JSObjectRef objectRef) { RefPtr<InjectedBundleNodeHandle> nodeHandle = InjectedBundleNodeHandle::getOrCreate(contextRef, objectRef); - return toAPI(nodeHandle.release().leakRef()); + return toAPI(nodeHandle.leakRef()); } WKBundleNodeHandleRef WKBundleNodeHandleCopyDocument(WKBundleNodeHandleRef nodeHandleRef) { RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(nodeHandleRef)->document(); - return toAPI(nodeHandle.release().leakRef()); + return toAPI(nodeHandle.leakRef()); } WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandleRef, bool* isReplaced) @@ -60,7 +76,13 @@ WKRect WKBundleNodeHandleGetRenderRect(WKBundleNodeHandleRef nodeHandleRef, bool WKImageRef WKBundleNodeHandleCopySnapshotWithOptions(WKBundleNodeHandleRef nodeHandleRef, WKSnapshotOptions options) { RefPtr<WebImage> image = toImpl(nodeHandleRef)->renderedImage(toSnapshotOptions(options)); - return toAPI(image.release().leakRef()); + return toAPI(image.leakRef()); +} + +WKBundleRangeHandleRef WKBundleNodeHandleCopyVisibleRange(WKBundleNodeHandleRef nodeHandleRef) +{ + RefPtr<InjectedBundleRangeHandle> rangeHandle = toImpl(nodeHandleRef)->visibleRange(); + return toAPI(rangeHandle.leakRef()); } WKRect WKBundleNodeHandleGetElementBounds(WKBundleNodeHandleRef elementHandleRef) @@ -73,14 +95,34 @@ void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htm toImpl(htmlInputElementHandleRef)->setHTMLInputElementValueForUser(toWTFString(valueRef)); } -bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef) +void WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool enabled) { - return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutofilled(); + toImpl(htmlInputElementHandleRef)->setHTMLInputElementSpellcheckEnabled(enabled); } -void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) +bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef) +{ + return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFilled(); +} + +void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) +{ + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFilled(filled); +} + +bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef) +{ + return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFillButtonEnabled(); +} + +void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef htmlInputElementHandleRef, WKAutoFillButtonType autoFillButtonType) +{ + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFillButtonEnabled(toAutoFillButtonType(autoFillButtonType)); +} + +WKRect WKBundleNodeHandleGetHTMLInputElementAutoFillButtonBounds(WKBundleNodeHandleRef htmlInputElementHandleRef) { - toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutofilled(filled); + return toAPI(toImpl(htmlInputElementHandleRef)->htmlInputElementAutoFillButtonBounds()); } bool WKBundleNodeHandleGetHTMLInputElementLastChangeWasUserEdit(WKBundleNodeHandleRef htmlInputElementHandleRef) @@ -96,23 +138,43 @@ bool WKBundleNodeHandleGetHTMLTextAreaElementLastChangeWasUserEdit(WKBundleNodeH WKBundleNodeHandleRef WKBundleNodeHandleCopyHTMLTableCellElementCellAbove(WKBundleNodeHandleRef htmlTableCellElementHandleRef) { RefPtr<InjectedBundleNodeHandle> nodeHandle = toImpl(htmlTableCellElementHandleRef)->htmlTableCellElementCellAbove(); - return toAPI(nodeHandle.release().leakRef()); + return toAPI(nodeHandle.leakRef()); } WKBundleFrameRef WKBundleNodeHandleCopyDocumentFrame(WKBundleNodeHandleRef documentHandleRef) { RefPtr<WebFrame> frame = toImpl(documentHandleRef)->documentFrame(); - return toAPI(frame.release().leakRef()); + return toAPI(frame.leakRef()); } WKBundleFrameRef WKBundleNodeHandleCopyHTMLFrameElementContentFrame(WKBundleNodeHandleRef htmlFrameElementHandleRef) { RefPtr<WebFrame> frame = toImpl(htmlFrameElementHandleRef)->htmlFrameElementContentFrame(); - return toAPI(frame.release().leakRef()); + return toAPI(frame.leakRef()); } WKBundleFrameRef WKBundleNodeHandleCopyHTMLIFrameElementContentFrame(WKBundleNodeHandleRef htmlIFrameElementHandleRef) { RefPtr<WebFrame> frame = toImpl(htmlIFrameElementHandleRef)->htmlIFrameElementContentFrame(); - return toAPI(frame.release().leakRef()); + return toAPI(frame.leakRef()); +} + +// Deprecated - use WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef). +bool WKBundleNodeHandleGetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef) +{ + return toImpl(htmlInputElementHandleRef)->isHTMLInputElementAutoFilled(); +} + +// Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef, bool). +void WKBundleNodeHandleSetHTMLInputElementAutofilled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool filled) +{ + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFilled(filled); +} + +// Deprecated - use WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabledWithButtonType(WKBundleNodeHandleRef, WKAutoFillButtonType). +void WKBundleNodeHandleSetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool enabled) +{ + WebCore::AutoFillButtonType autoFillButtonType = enabled ? WebCore::AutoFillButtonType::Credentials : WebCore::AutoFillButtonType::None; + + toImpl(htmlInputElementHandleRef)->setHTMLInputElementAutoFillButtonEnabled(autoFillButtonType); } |