https://bugs.webkit.org/show_bug.cgi?id=179714
Patch by Aishwarya Nirmal <anirmal@apple.com> on 2017-12-01
Reviewed by Wenson Hsieh.
Source/WebCore:
These changes allow the HTMLMenuElement and HTMLMenuItemElement to parse attributes relating
to the touch bar and convey changes to the elements that will eventually be propogated to the
UI process.
No new tests at this point because the changes to HTMLMenuElement and HTMLMenuItemElement are
new properties, which might not be worth testing, and overriden methods for insertedIntoAncestor
and removedFromAncestor, which are involved in sending a message to a UI process but might be
difficult to test at this point since the UI process only receives (and does not yet process)
the message.
* html/HTMLMenuElement.cpp:
(WebCore::HTMLMenuElement::insertedIntoAncestor):
(WebCore::HTMLMenuElement::removedFromAncestor):
(WebCore::HTMLMenuElement::parseAttribute):
* html/HTMLMenuElement.h:
* html/HTMLMenuItemElement.cpp:
(WebCore::HTMLMenuItemElement::insertedIntoAncestor):
(WebCore::HTMLMenuItemElement::removedFromAncestor):
* html/HTMLMenuItemElement.h:
* page/ChromeClient.h:
Source/WebKit:
These changes define the TouchBarMenuData and TouchBarMenuItemData objects which draw information
from touch bar HTMLMenuElement and HTMLMenuItemElement. These objects represent the contents of
the page-customized touch bar. Changes to the html elements representing the touch bar are sent
to the UI process.
* Shared/TouchBarMenuData.cpp: Copied from Source/WebCore/html/HTMLMenuItemElement.cpp.
(WebKit::TouchBarMenuData::TouchBarMenuData):
(WebKit::TouchBarMenuData::addMenuItem):
(WebKit::TouchBarMenuData::removeMenuItem):
(WebKit::TouchBarMenuData::encode const):
(WebKit::TouchBarMenuData::decode):
* Shared/TouchBarMenuData.h: Copied from Source/WebCore/html/HTMLMenuItemElement.h.
(WebKit::TouchBarMenuData::items):
(WebKit::TouchBarMenuData::isPageCustomized):
(WebKit::TouchBarMenuData::setIsPageCustomized):
* Shared/TouchBarMenuItemData.cpp: Added.
(WebKit::TouchBarMenuItemData::getItemType):
(WebKit::TouchBarMenuItemData::TouchBarMenuItemData):
(WebKit::TouchBarMenuItemData::encode const):
(WebKit::TouchBarMenuItemData::decode):
* Shared/TouchBarMenuItemData.h: Added.
(WebKit::operator<):
(WebKit::operator>):
(WebKit::operator<=):
(WebKit::operator>=):
(WebKit::operator==):
(WebKit::operator!=):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::touchBarMenuDataChanged):
(WebKit::WebPageProxy::touchBarMenuItemDataAdded):
(WebKit::WebPageProxy::touchBarMenuItemDataRemoved):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::touchBarMenuData const):
* UIProcess/WebPageProxy.messages.in:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::didInsertMenuElement):
(WebKit::WebChromeClient::didRemoveMenuElement):
(WebKit::WebChromeClient::didInsertMenuItemElement):
(WebKit::WebChromeClient::didRemoveMenuItemElement):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didInsertMenuElement):
(WebKit::WebPage::didRemoveMenuElement):
(WebKit::WebPage::didInsertMenuItemElement):
(WebKit::WebPage::didRemoveMenuItemElement):
(WebKit::WebPage::sendTouchBarMenuDataRemovedUpdate):
(WebKit::WebPage::sendTouchBarMenuDataAddedUpdate):
(WebKit::WebPage::sendTouchBarMenuItemDataAddedUpdate):
(WebKit::WebPage::sendTouchBarMenuItemDataRemovedUpdate):
* WebProcess/WebPage/WebPage.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225438
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-12-01 Aishwarya Nirmal <anirmal@apple.com>
+
+ [Touch Bar Web API] Object representing Touch Bar Menu to send between Web and UI Processes
+ https://bugs.webkit.org/show_bug.cgi?id=179714
+
+ Reviewed by Wenson Hsieh.
+
+ These changes allow the HTMLMenuElement and HTMLMenuItemElement to parse attributes relating
+ to the touch bar and convey changes to the elements that will eventually be propogated to the
+ UI process.
+
+ No new tests at this point because the changes to HTMLMenuElement and HTMLMenuItemElement are
+ new properties, which might not be worth testing, and overriden methods for insertedIntoAncestor
+ and removedFromAncestor, which are involved in sending a message to a UI process but might be
+ difficult to test at this point since the UI process only receives (and does not yet process)
+ the message.
+
+ * html/HTMLMenuElement.cpp:
+ (WebCore::HTMLMenuElement::insertedIntoAncestor):
+ (WebCore::HTMLMenuElement::removedFromAncestor):
+ (WebCore::HTMLMenuElement::parseAttribute):
+ * html/HTMLMenuElement.h:
+ * html/HTMLMenuItemElement.cpp:
+ (WebCore::HTMLMenuItemElement::insertedIntoAncestor):
+ (WebCore::HTMLMenuItemElement::removedFromAncestor):
+ * html/HTMLMenuItemElement.h:
+ * page/ChromeClient.h:
+
2017-12-01 Daniel Bates <dabates@apple.com>
AlternativePresentationButtonSubstitution::unapply() may not undo substitution
#include "config.h"
#include "HTMLMenuElement.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Document.h"
+#include "HTMLMenuItemElement.h"
#include "HTMLNames.h"
+#include "Page.h"
namespace WebCore {
ASSERT(hasTagName(menuTag));
}
+Node::InsertedIntoAncestorResult HTMLMenuElement::insertedIntoAncestor(InsertionType type, ContainerNode& ancestor)
+{
+ auto result = HTMLElement::insertedIntoAncestor(type, ancestor);
+ if (type.connectedToDocument && RuntimeEnabledFeatures::sharedFeatures().menuItemElementEnabled() && m_isTouchBarMenu) {
+ if (auto* page = document().page())
+ page->chrome().client().didInsertMenuElement(*this);
+ }
+ return result;
+}
+
+void HTMLMenuElement::removedFromAncestor(RemovalType type, ContainerNode& ancestor)
+{
+ HTMLElement::removedFromAncestor(type, ancestor);
+ if (type.disconnectedFromDocument && RuntimeEnabledFeatures::sharedFeatures().menuItemElementEnabled() && m_isTouchBarMenu) {
+ if (auto* page = document().page())
+ page->chrome().client().didRemoveMenuElement(*this);
+ }
+}
+
+void HTMLMenuElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+{
+ if (name != typeAttr || !RuntimeEnabledFeatures::sharedFeatures().menuItemElementEnabled()) {
+ HTMLElement::parseAttribute(name, value);
+ return;
+ }
+ bool wasTouchBarMenu = m_isTouchBarMenu;
+ m_isTouchBarMenu = equalLettersIgnoringASCIICase(value, "touchbar");
+ if (!wasTouchBarMenu && m_isTouchBarMenu) {
+ if (auto* page = document().page()) {
+ page->chrome().client().didInsertMenuElement(*this);
+ for (auto& child : childrenOfType<Element>(*this))
+ page->chrome().client().didInsertMenuItemElement(downcast<HTMLMenuItemElement>(child));
+ }
+ } else if (wasTouchBarMenu && !m_isTouchBarMenu) {
+ if (auto* page = document().page())
+ page->chrome().client().didRemoveMenuElement(*this);
+ }
+}
+
Ref<HTMLMenuElement> HTMLMenuElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new HTMLMenuElement(tagName, document));
public:
static Ref<HTMLMenuElement> create(const QualifiedName&, Document&);
+ bool isTouchBarMenu() const { return m_isTouchBarMenu; }
+
private:
HTMLMenuElement(const QualifiedName&, Document&);
+
+ InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
+ void removedFromAncestor(RemovalType, ContainerNode&) final;
+ void parseAttribute(const QualifiedName&, const AtomicString&) final;
+
+ bool m_isTouchBarMenu;
};
} // namespace WebCore
#include "config.h"
#include "HTMLMenuItemElement.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Document.h"
+#include "HTMLMenuElement.h"
#include "HTMLNames.h"
+#include "Page.h"
namespace WebCore {
{
ASSERT(hasTagName(menuitemTag));
}
-
+
+Node::InsertedIntoAncestorResult HTMLMenuItemElement::insertedIntoAncestor(InsertionType type, ContainerNode& ancestor)
+{
+ auto result = HTMLElement::insertedIntoAncestor(type, ancestor);
+ if (type.connectedToDocument) {
+ if (auto* page = document().page()) {
+ if (is<HTMLMenuElement>(ancestor) && downcast<HTMLMenuElement>(ancestor).isTouchBarMenu())
+ page->chrome().client().didInsertMenuItemElement(*this);
+ }
+ }
+ return result;
+}
+
+void HTMLMenuItemElement::removedFromAncestor(RemovalType type, ContainerNode& ancestor)
+{
+ HTMLElement::removedFromAncestor(type, ancestor);
+ if (type.disconnectedFromDocument) {
+ if (auto* page = document().page()) {
+ if (is<HTMLMenuElement>(ancestor) && downcast<HTMLMenuElement>(ancestor).isTouchBarMenu())
+ page->chrome().client().didRemoveMenuItemElement(*this);
+ }
+ }
+}
+
Ref<HTMLMenuItemElement> HTMLMenuItemElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new HTMLMenuItemElement(tagName, document));
}
-
+
}
private:
HTMLMenuItemElement(const QualifiedName&, Document&);
+
+ InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
+ void removedFromAncestor(RemovalType, ContainerNode&) final;
};
} // namespace WebCore
virtual void requestStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, WTF::Function<void (bool)>&& callback) { callback(false); }
+ virtual void didInsertMenuElement(HTMLMenuElement&) { }
+ virtual void didRemoveMenuElement(HTMLMenuElement&) { }
+ virtual void didInsertMenuItemElement(HTMLMenuItemElement&) { }
+ virtual void didRemoveMenuItemElement(HTMLMenuItemElement&) { }
+
protected:
virtual ~ChromeClient() = default;
};
+2017-12-01 Aishwarya Nirmal <anirmal@apple.com>
+
+ [Touch Bar Web API] Object representing Touch Bar Menu to send between Web and UI Processes
+ https://bugs.webkit.org/show_bug.cgi?id=179714
+
+ Reviewed by Wenson Hsieh.
+
+ These changes define the TouchBarMenuData and TouchBarMenuItemData objects which draw information
+ from touch bar HTMLMenuElement and HTMLMenuItemElement. These objects represent the contents of
+ the page-customized touch bar. Changes to the html elements representing the touch bar are sent
+ to the UI process.
+
+ * Shared/TouchBarMenuData.cpp: Copied from Source/WebCore/html/HTMLMenuItemElement.cpp.
+ (WebKit::TouchBarMenuData::TouchBarMenuData):
+ (WebKit::TouchBarMenuData::addMenuItem):
+ (WebKit::TouchBarMenuData::removeMenuItem):
+ (WebKit::TouchBarMenuData::encode const):
+ (WebKit::TouchBarMenuData::decode):
+ * Shared/TouchBarMenuData.h: Copied from Source/WebCore/html/HTMLMenuItemElement.h.
+ (WebKit::TouchBarMenuData::items):
+ (WebKit::TouchBarMenuData::isPageCustomized):
+ (WebKit::TouchBarMenuData::setIsPageCustomized):
+ * Shared/TouchBarMenuItemData.cpp: Added.
+ (WebKit::TouchBarMenuItemData::getItemType):
+ (WebKit::TouchBarMenuItemData::TouchBarMenuItemData):
+ (WebKit::TouchBarMenuItemData::encode const):
+ (WebKit::TouchBarMenuItemData::decode):
+ * Shared/TouchBarMenuItemData.h: Added.
+ (WebKit::operator<):
+ (WebKit::operator>):
+ (WebKit::operator<=):
+ (WebKit::operator>=):
+ (WebKit::operator==):
+ (WebKit::operator!=):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::touchBarMenuDataChanged):
+ (WebKit::WebPageProxy::touchBarMenuItemDataAdded):
+ (WebKit::WebPageProxy::touchBarMenuItemDataRemoved):
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::touchBarMenuData const):
+ * UIProcess/WebPageProxy.messages.in:
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::didInsertMenuElement):
+ (WebKit::WebChromeClient::didRemoveMenuElement):
+ (WebKit::WebChromeClient::didInsertMenuItemElement):
+ (WebKit::WebChromeClient::didRemoveMenuItemElement):
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::didInsertMenuElement):
+ (WebKit::WebPage::didRemoveMenuElement):
+ (WebKit::WebPage::didInsertMenuItemElement):
+ (WebKit::WebPage::didRemoveMenuItemElement):
+ (WebKit::WebPage::sendTouchBarMenuDataRemovedUpdate):
+ (WebKit::WebPage::sendTouchBarMenuDataAddedUpdate):
+ (WebKit::WebPage::sendTouchBarMenuItemDataAddedUpdate):
+ (WebKit::WebPage::sendTouchBarMenuItemDataRemovedUpdate):
+ * WebProcess/WebPage/WebPage.h:
+
2017-12-01 Daniel Bates <dabates@apple.com>
Alternative Presentation Button: Provide a way to query for the replaced elements
--- /dev/null
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TouchBarMenuData.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+#include "TouchBarMenuItemData.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/HTMLElement.h>
+#include <WebCore/HTMLMenuElement.h>
+#include <WebCore/HTMLNames.h>
+#include <WebCore/Node.h>
+
+namespace WebKit {
+
+TouchBarMenuData::TouchBarMenuData()
+{
+}
+
+TouchBarMenuData::TouchBarMenuData(WebCore::HTMLMenuElement& element)
+{
+ if (!element.isTouchBarMenu())
+ return;
+ m_id = element.attributeWithoutSynchronization(WebCore::HTMLNames::idAttr);
+ m_isPageCustomized = true;
+}
+
+TouchBarMenuData::TouchBarMenuData(const TouchBarMenuData& touchBarMenuData)
+ : m_items(touchBarMenuData.m_items)
+ , m_id(touchBarMenuData.m_id)
+ , m_isPageCustomized(touchBarMenuData.m_isPageCustomized)
+{
+}
+
+void TouchBarMenuData::addMenuItem(const TouchBarMenuItemData& data)
+{
+ m_items.append(data);
+}
+
+void TouchBarMenuData::removeMenuItem(const TouchBarMenuItemData& data)
+{
+ m_items.removeFirst(data);
+}
+
+void TouchBarMenuData::encode(IPC::Encoder& encoder) const
+{
+ encoder << m_items;
+}
+
+bool TouchBarMenuData::decode(IPC::Decoder& decoder, TouchBarMenuData& data)
+{
+ if (!decoder.decode(data.m_items))
+ return false;
+
+ return true;
+}
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+#include "ArgumentCoders.h"
+#include "TouchBarMenuItemData.h"
+#include <WebCore/HTMLMenuElement.h>
+#include <wtf/text/WTFString.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+class TouchBarMenuData {
+public:
+ explicit TouchBarMenuData();
+ explicit TouchBarMenuData(WebCore::HTMLMenuElement&);
+ explicit TouchBarMenuData(const TouchBarMenuData&);
+
+ void addMenuItem(const TouchBarMenuItemData&);
+ void removeMenuItem(const TouchBarMenuItemData&);
+
+ const Vector<TouchBarMenuItemData>& items() { return m_items; }
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, TouchBarMenuData&);
+
+ void setID(String);
+ bool isPageCustomized() { return m_isPageCustomized; }
+ void setIsPageCustomized(bool customized) { m_isPageCustomized = customized; }
+
+private:
+ Vector<TouchBarMenuItemData> m_items;
+ String m_id;
+
+ bool m_isPageCustomized { false };
+};
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+#include "TouchBarMenuItemData.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/HTMLElement.h>
+#include <WebCore/HTMLMenuItemElement.h>
+#include <WebCore/HTMLNames.h>
+#include <WebCore/Node.h>
+#include <vector>
+
+namespace WebKit {
+
+ItemType TouchBarMenuItemData::getItemType(String value)
+{
+ return ItemType::Button;
+}
+
+TouchBarMenuItemData::TouchBarMenuItemData()
+{
+}
+
+TouchBarMenuItemData::TouchBarMenuItemData(WebCore::HTMLMenuItemElement& element)
+{
+ itemType = getItemType(element.attributeWithoutSynchronization(WebCore::HTMLNames::typeAttr));
+ identifier = element.attributeWithoutSynchronization(WebCore::HTMLNames::idAttr);
+ commandName = element.attributeWithoutSynchronization(WebCore::HTMLNames::onclickAttr);
+ priority = element.attributeWithoutSynchronization(WebCore::HTMLNames::valueAttr).toFloat();
+}
+
+TouchBarMenuItemData::TouchBarMenuItemData(const TouchBarMenuItemData& other)
+ : itemType(other.itemType)
+ , identifier(other.identifier)
+ , commandName(other.commandName)
+ , priority(other.priority)
+{
+}
+
+void TouchBarMenuItemData::encode(IPC::Encoder& encoder) const
+{
+ encoder.encodeEnum(itemType);
+
+ encoder << identifier;
+ encoder << commandName;
+ encoder << priority;
+}
+
+std::optional<TouchBarMenuItemData> TouchBarMenuItemData::decode(IPC::Decoder& decoder)
+{
+ TouchBarMenuItemData result;
+ if (!decoder.decodeEnum(result.itemType))
+ return std::nullopt;
+
+ if (!decoder.decode(result.identifier))
+ return std::nullopt;
+
+ if (!decoder.decode(result.commandName))
+ return std::nullopt;
+
+ if (!decoder.decode(result.priority))
+ return std::nullopt;
+
+ return WTFMove(result);
+}
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+#include "ArgumentCoders.h"
+#include <WebCore/HTMLMenuItemElement.h>
+#include <wtf/text/WTFString.h>
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+// Based on NSTouchBarItem types.
+enum ItemType {
+ Button
+};
+
+struct TouchBarMenuItemData {
+ explicit TouchBarMenuItemData();
+ explicit TouchBarMenuItemData(WebCore::HTMLMenuItemElement&);
+ explicit TouchBarMenuItemData(const TouchBarMenuItemData&);
+
+ void encode(IPC::Encoder&) const;
+ static std::optional<TouchBarMenuItemData> decode(IPC::Decoder&);
+ static ItemType getItemType(String);
+
+ bool validTouchBarDisplay { true };
+
+ ItemType itemType { ItemType::Button };
+ String identifier;
+ String commandName;
+ float priority { 0.0 };
+};
+
+// Touch Bar Menu Items will be ordered based on priority.
+inline bool operator<(const TouchBarMenuItemData& lhs, const TouchBarMenuItemData& rhs)
+{
+ return lhs.priority < rhs.priority;
+}
+
+inline bool operator>(const TouchBarMenuItemData& lhs, const TouchBarMenuItemData& rhs)
+{
+ return rhs < lhs;
+}
+
+inline bool operator<=(const TouchBarMenuItemData& lhs, const TouchBarMenuItemData& rhs)
+{
+ return !(lhs > rhs);
+}
+
+inline bool operator>=(const TouchBarMenuItemData& lhs, const TouchBarMenuItemData& rhs)
+{
+ return !(lhs < rhs);
+}
+
+inline bool operator==(const TouchBarMenuItemData& lhs, const TouchBarMenuItemData& rhs)
+{
+ return lhs.itemType == rhs.itemType
+ && lhs.identifier == rhs.identifier
+ && lhs.commandName == rhs.commandName
+ && lhs.priority == rhs.priority;
+}
+
+inline bool operator!=(const TouchBarMenuItemData& lhs, const TouchBarMenuItemData& rhs)
+{
+ return !(lhs == rhs);
+}
+
+}
#if PLATFORM(COCOA)
#include "RemoteLayerTreeDrawingAreaProxy.h"
#include "RemoteLayerTreeScrollingPerformanceData.h"
+#include "TouchBarMenuData.h"
+#include "TouchBarMenuItemData.h"
#include "VideoFullscreenManagerProxy.h"
#include "VideoFullscreenManagerProxyMessages.h"
#include "ViewSnapshotStore.h"
});
}
+#if PLATFORM(COCOA)
+void WebPageProxy::touchBarMenuDataChanged(const TouchBarMenuData& touchBarMenuData)
+{
+ m_touchBarMenuData = touchBarMenuData;
+}
+
+void WebPageProxy::touchBarMenuItemDataAdded(const TouchBarMenuItemData& touchBarMenuItemData)
+{
+ m_touchBarMenuData.addMenuItem(touchBarMenuItemData);
+}
+
+void WebPageProxy::touchBarMenuItemDataRemoved(const TouchBarMenuItemData& touchBarMenuItemData)
+{
+ m_touchBarMenuData.removeMenuItem(touchBarMenuItemData);
+}
+#endif
+
#if ENABLE(ATTACHMENT_ELEMENT)
void WebPageProxy::insertAttachment(const String& identifier, const AttachmentDisplayOptions& options, const String& filename, std::optional<String> contentType, SharedBuffer& data, Function<void(CallbackBase::Error)>&& callback)
#if PLATFORM(COCOA)
#include "LayerRepresentation.h"
+#include "TouchBarMenuData.h"
+#include "TouchBarMenuItemData.h"
#endif
#if PLATFORM(GTK)
bool canDelete() const { return hasSelectedRange() && isContentEditable(); }
bool hasSelectedRange() const { return m_editorState.selectionIsRange; }
bool isContentEditable() const { return m_editorState.isContentEditable; }
-
+
+#if PLATFORM(COCOA)
+ const TouchBarMenuData& touchBarMenuData() const { return m_touchBarMenuData; }
+#endif
+
bool maintainsInactiveSelection() const;
void setMaintainsInactiveSelection(bool);
void setEditable(bool);
#endif
void editorStateChanged(const EditorState&);
+#if PLATFORM(COCOA)
+ void touchBarMenuDataRemoved();
+ void touchBarMenuDataChanged(const TouchBarMenuData&);
+ void touchBarMenuItemDataAdded(const TouchBarMenuItemData&);
+ void touchBarMenuItemDataRemoved(const TouchBarMenuItemData&);
+#endif
+
void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t webProcessContextId);
#if ENABLE(ATTACHMENT_ELEMENT)
EditorState m_editorState;
bool m_isEditable { false };
+#if PLATFORM(COCOA)
+ TouchBarMenuData m_touchBarMenuData;
+#endif
+
double m_textZoomFactor { 1 };
double m_pageZoomFactor { 1 };
double m_pageScaleFactor { 1 };
StartDrag(struct WebKit::WebSelectionData selection, uint64_t dragOperation, WebKit::ShareableBitmap::Handle dragImage)
#endif
+
#if ENABLE(DATA_INTERACTION)
DidPerformDataInteractionControllerOperation(bool handled)
DidHandleStartDataInteractionRequest(bool started)
SearchWithSpotlight(String string)
SearchTheWeb(String string)
+
+ TouchBarMenuDataChanged(WebKit::TouchBarMenuData touchBarMenuData)
+ TouchBarMenuItemDataAdded(struct WebKit::TouchBarMenuItemData touchBarMenuItemData)
+ TouchBarMenuItemDataRemoved(struct WebKit::TouchBarMenuItemData touchBarMenuItemData)
#endif
#if USE(APPKIT)
2E5C770E1FA7D429005932C3 /* APIAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E5C770C1FA7D429005932C3 /* APIAttachment.h */; };
2E5C770F1FA7D429005932C3 /* APIAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E5C770D1FA7D429005932C3 /* APIAttachment.cpp */; };
2E7A944A1BBD97C300945547 /* _WKFocusedElementInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E7A94491BBD95C600945547 /* _WKFocusedElementInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 2F809DD71FBD1BC9005FE63A /* TouchBarMenuItemData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2F809DD51FBD1BC9005FE63A /* TouchBarMenuItemData.cpp */; };
+ 2F8336861FA139DF00C6E080 /* TouchBarMenuData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FD43B911FA006A10083F51C /* TouchBarMenuData.h */; };
+ 2F8336871FA13A1E00C6E080 /* TouchBarMenuData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2FD43B921FA006A30083F51C /* TouchBarMenuData.cpp */; };
31099973146C75A20029DEB9 /* WebNotificationClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31099971146C759B0029DEB9 /* WebNotificationClient.cpp */; };
310999C7146C9E3D0029DEB9 /* WebNotificationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31099968146C71F50029DEB9 /* WebNotificationClient.h */; };
312C0C4A146DDC8A0016C911 /* WKNotificationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 312C0C49146DDC8A0016C911 /* WKNotificationProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
2E5C770C1FA7D429005932C3 /* APIAttachment.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIAttachment.h; sourceTree = "<group>"; };
2E5C770D1FA7D429005932C3 /* APIAttachment.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = APIAttachment.cpp; sourceTree = "<group>"; };
2E7A94491BBD95C600945547 /* _WKFocusedElementInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKFocusedElementInfo.h; sourceTree = "<group>"; };
+ 2F809DD51FBD1BC9005FE63A /* TouchBarMenuItemData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TouchBarMenuItemData.cpp; sourceTree = "<group>"; };
+ 2F809DD91FBD1BF2005FE63A /* TouchBarMenuItemData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarMenuItemData.h; sourceTree = "<group>"; };
+ 2FD43B911FA006A10083F51C /* TouchBarMenuData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TouchBarMenuData.h; sourceTree = "<group>"; };
+ 2FD43B921FA006A30083F51C /* TouchBarMenuData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TouchBarMenuData.cpp; sourceTree = "<group>"; };
31099968146C71F50029DEB9 /* WebNotificationClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebNotificationClient.h; sourceTree = "<group>"; };
31099971146C759B0029DEB9 /* WebNotificationClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationClient.cpp; sourceTree = "<group>"; };
312C0C49146DDC8A0016C911 /* WKNotificationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNotificationProvider.h; sourceTree = "<group>"; };
5272B2881406985D0096A5D0 /* StatisticsData.cpp */,
5272B2891406985D0096A5D0 /* StatisticsData.h */,
1A5E4DA312D3BD3D0099A2BB /* TextCheckerState.h */,
+ 2FD43B921FA006A30083F51C /* TouchBarMenuData.cpp */,
+ 2FD43B911FA006A10083F51C /* TouchBarMenuData.h */,
+ 2F809DD51FBD1BC9005FE63A /* TouchBarMenuItemData.cpp */,
+ 2F809DD91FBD1BF2005FE63A /* TouchBarMenuItemData.h */,
1A64245D12DE29A100CAAE2C /* UpdateInfo.cpp */,
1A64245C12DE29A100CAAE2C /* UpdateInfo.h */,
5C19A51E1FD0B14600EEA323 /* URLSchemeTaskParameters.cpp */,
CE1A0BD71A48E6C60054EF74 /* TextInputSPI.h in Headers */,
1AAF263914687C39004A1E8A /* TiledCoreAnimationDrawingArea.h in Headers */,
1AF05D8714688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h in Headers */,
+ 2F8336861FA139DF00C6E080 /* TouchBarMenuData.h in Headers */,
1AFE436618B6C081009C7A48 /* UIDelegate.h in Headers */,
515BE1B51D5917FF00DD7C68 /* UIGamepad.h in Headers */,
515BE1A91D55293400DD7C68 /* UIGamepadProvider.h in Headers */,
1AA417EF12C00D87002BE67B /* TextCheckerMac.mm in Sources */,
1AAF263814687C39004A1E8A /* TiledCoreAnimationDrawingArea.mm in Sources */,
1AF05D8614688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.mm in Sources */,
+ 2F8336871FA13A1E00C6E080 /* TouchBarMenuData.cpp in Sources */,
+ 2F809DD71FBD1BC9005FE63A /* TouchBarMenuItemData.cpp in Sources */,
1AFE436518B6C081009C7A48 /* UIDelegate.mm in Sources */,
515BE1B41D5917FF00DD7C68 /* UIGamepad.cpp in Sources */,
515BE1A81D55293400DD7C68 /* UIGamepadProvider.cpp in Sources */,
{
}
+void WebChromeClient::didInsertMenuElement(HTMLMenuElement& element)
+{
+ m_page.didInsertMenuElement(element);
+}
+
+void WebChromeClient::didRemoveMenuElement(HTMLMenuElement& element)
+{
+ m_page.didRemoveMenuElement(element);
+}
+
+void WebChromeClient::didInsertMenuItemElement(HTMLMenuItemElement& element)
+{
+ m_page.didInsertMenuItemElement(element);
+}
+
+void WebChromeClient::didRemoveMenuItemElement(HTMLMenuItemElement& element)
+{
+ m_page.didRemoveMenuItemElement(element);
+}
+
inline WebChromeClient::~WebChromeClient()
{
}
private:
~WebChromeClient();
+ void didInsertMenuElement(WebCore::HTMLMenuElement&);
+ void didRemoveMenuElement(WebCore::HTMLMenuElement&);
+ void didInsertMenuItemElement(WebCore::HTMLMenuItemElement&);
+ void didRemoveMenuItemElement(WebCore::HTMLMenuItemElement&);
+
void chromeDestroyed() final;
void setWindowRect(const WebCore::FloatRect&) final;
#include <WebCore/HTMLFormElement.h>
#include <WebCore/HTMLImageElement.h>
#include <WebCore/HTMLInputElement.h>
+#include <WebCore/HTMLMenuElement.h>
+#include <WebCore/HTMLMenuItemElement.h>
#include <WebCore/HTMLOListElement.h>
#include <WebCore/HTMLPlugInElement.h>
#include <WebCore/HTMLPlugInImageElement.h>
#include "PDFPlugin.h"
#include "PlaybackSessionManager.h"
#include "RemoteLayerTreeTransaction.h"
+#include "TouchBarMenuData.h"
+#include "TouchBarMenuItemData.h"
#include "VideoFullscreenManager.h"
#include "WKStringCF.h"
#include <WebCore/LegacyWebArchive.h>
#endif
}
+void WebPage::didInsertMenuElement(HTMLMenuElement& element)
+{
+#if PLATFORM(COCOA)
+ sendTouchBarMenuDataAddedUpdate(element);
+#else
+ ASSERT_UNUSED(element, element);
+#endif
+}
+
+void WebPage::didRemoveMenuElement(HTMLMenuElement& element)
+{
+#if PLATFORM(COCOA)
+ sendTouchBarMenuDataRemovedUpdate(element);
+#else
+ ASSERT_UNUSED(element, element);
+#endif
+}
+
+void WebPage::didInsertMenuItemElement(HTMLMenuItemElement& element)
+{
+#if PLATFORM(COCOA)
+ sendTouchBarMenuItemDataAddedUpdate(element);
+#else
+ ASSERT_UNUSED(element, element);
+#endif
+}
+
+void WebPage::didRemoveMenuItemElement(HTMLMenuItemElement& element)
+{
+#if PLATFORM(COCOA)
+ sendTouchBarMenuItemDataRemovedUpdate(element);
+#else
+ ASSERT_UNUSED(element, element);
+#endif
+}
+
#if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
static const int primarySnapshottedPlugInSearchLimit = 3000;
static const float primarySnapshottedPlugInSearchBucketSize = 1.1;
}
}
+#if PLATFORM(COCOA)
+void WebPage::sendTouchBarMenuDataRemovedUpdate(HTMLMenuElement& element)
+{
+ send(Messages::WebPageProxy::TouchBarMenuDataChanged(TouchBarMenuData { }));
+}
+
+void WebPage::sendTouchBarMenuDataAddedUpdate(HTMLMenuElement& element)
+{
+ send(Messages::WebPageProxy::TouchBarMenuDataChanged(TouchBarMenuData {element}));
+}
+
+void WebPage::sendTouchBarMenuItemDataAddedUpdate(HTMLMenuItemElement& element)
+{
+ send(Messages::WebPageProxy::TouchBarMenuItemDataAdded(TouchBarMenuItemData {element}));
+}
+
+void WebPage::sendTouchBarMenuItemDataRemovedUpdate(HTMLMenuItemElement& element)
+{
+ send(Messages::WebPageProxy::TouchBarMenuItemDataRemoved(TouchBarMenuItemData {element}));
+}
+#endif
+
void WebPage::sendPartialEditorStateAndSchedulePostLayoutUpdate()
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
#include <WebCore/ActivityState.h>
#include <WebCore/DictionaryPopupInfo.h>
#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/HTMLMenuElement.h>
+#include <WebCore/HTMLMenuItemElement.h>
#include <WebCore/IntRect.h>
#include <WebCore/IntSizeHash.h>
#include <WebCore/Page.h>
class FrameSelection;
class FrameView;
class GraphicsContext;
+class HTMLMenuElement;
+class HTMLMenuItemElement;
class HTMLPlugInElement;
class HTMLPlugInImageElement;
class IntPoint;
String platformUserAgent(const WebCore::URL&) const;
WebCore::KeyboardUIMode keyboardUIMode();
+ void didInsertMenuElement(WebCore::HTMLMenuElement&);
+ void didRemoveMenuElement(WebCore::HTMLMenuElement&);
+ void didInsertMenuItemElement(WebCore::HTMLMenuItemElement&);
+ void didRemoveMenuItemElement(WebCore::HTMLMenuItemElement&);
+
const String& overrideContentSecurityPolicy() const { return m_overrideContentSecurityPolicy; }
WebUndoStep* webUndoStep(uint64_t);
void platformEditorState(WebCore::Frame&, EditorState& result, IncludePostLayoutDataHint) const;
void sendEditorStateUpdate();
+#if PLATFORM(COCOA)
+ void sendTouchBarMenuDataAddedUpdate(WebCore::HTMLMenuElement&);
+ void sendTouchBarMenuDataRemovedUpdate(WebCore::HTMLMenuElement&);
+ void sendTouchBarMenuItemDataAddedUpdate(WebCore::HTMLMenuItemElement&);
+ void sendTouchBarMenuItemDataRemovedUpdate(WebCore::HTMLMenuItemElement&);
+#endif
+
void didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&);
void didReceiveSyncWebPageMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);