Ejemplo n.º 1
0
WKArrayRef WKBundlePageCopyContextMenuItemTitles(WKBundlePageRef pageRef)
{
#if ENABLE(CONTEXT_MENUS)
    WebContextMenu* contextMenu = toImpl(pageRef)->contextMenu();
    const Vector<WebContextMenuItemData> &items = contextMenu->items();
    size_t arrayLength = items.size();
    OwnArrayPtr<WKTypeRef> itemNames = adoptArrayPtr(new WKTypeRef[arrayLength]);
    for (size_t i = 0; i < arrayLength; ++i)
        itemNames[i] = WKStringCreateWithUTF8CString(items[i].title().utf8().data());

    return WKArrayCreateAdoptingValues(itemNames.get(), arrayLength);
#else
    return 0;
#endif
}
Ejemplo n.º 2
0
WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef pageRef)
{
#if ENABLE(CONTEXT_MENUS)
    WebContextMenu* contextMenu = toImpl(pageRef)->contextMenu();
    const Vector<WebContextMenuItemData>& items = contextMenu->items();
    size_t arrayLength = items.size();

    auto wkItems = std::make_unique<WKTypeRef[]>(arrayLength);
    for (size_t i = 0; i < arrayLength; ++i)
        wkItems[i] = toAPI(WebContextMenuItem::create(items[i]).leakRef());

    return WKArrayCreate(wkItems.get(), arrayLength);
#else
    return 0;
#endif
}
Ejemplo n.º 3
0
WKArrayRef WKBundlePageCopyContextMenuAtPointInWindow(WKBundlePageRef pageRef, WKPoint point)
{
#if ENABLE(CONTEXT_MENUS)
    WebContextMenu* contextMenu = toImpl(pageRef)->contextMenuAtPointInWindow(toIntPoint(point));
    if (!contextMenu)
        return 0;

    const Vector<WebContextMenuItemData>& items = contextMenu->items();
    size_t arrayLength = items.size();

    RefPtr<MutableArray> menuArray = MutableArray::create();
    menuArray->reserveCapacity(arrayLength);
    for (unsigned i = 0; i < arrayLength; ++i)
        menuArray->append(WebContextMenuItem::create(items[i]).get());
    
    return toAPI(menuArray.release().leakRef());
#else
    return 0;
#endif
}
Ejemplo n.º 4
0
static PassRefPtr<API::Array> contextMenuItems(const WebContextMenu& contextMenu)
{
    auto items = contextMenu.items();

    Vector<RefPtr<API::Object>> menuItems;
    menuItems.reserveInitialCapacity(items.size());

    for (const auto& item : items)
        menuItems.uncheckedAppend(WebContextMenuItem::create(item));

    return API::Array::create(std::move(menuItems));
}