Diff
Modified: trunk/Source/WebCore/dom/Node.cpp (294972 => 294973)
--- trunk/Source/WebCore/dom/Node.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/dom/Node.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -754,44 +754,33 @@
document().page()->inspectorController().inspect(this);
}
-static Node::Editability computeEditabilityFromComputedStyle(const Node& startNode, Node::UserSelectAllTreatment treatment, PageIsEditable pageIsEditable)
+static Node::Editability computeEditabilityFromComputedStyle(const RenderStyle& style, Node::UserSelectAllTreatment treatment, PageIsEditable pageIsEditable)
{
// Ideally we'd call ASSERT(!needsStyleRecalc()) here, but
// ContainerNode::setFocus() calls invalidateStyleForSubtree(), so the assertion
// would fire in the middle of Document::setFocusedElement().
- for (const Node* node = &startNode; node; node = node->parentNode()) {
- auto* style = node->isDocumentNode() ? node->renderStyle() : const_cast<Node*>(node)->computedStyle();
- if (!style)
- continue;
-
- // Elements with user-select: all style are considered atomic
- // therefore non editable.
- if (treatment == Node::UserSelectAllIsAlwaysNonEditable && style->effectiveUserSelect() == UserSelect::All)
- return Node::Editability::ReadOnly;
-
- if (pageIsEditable == PageIsEditable::Yes)
- return Node::Editability::CanEditRichly;
-
- switch (style->effectiveUserModify()) {
- case UserModify::ReadOnly:
- return Node::Editability::ReadOnly;
- case UserModify::ReadWrite:
- return Node::Editability::CanEditRichly;
- case UserModify::ReadWritePlaintextOnly:
- return Node::Editability::CanEditPlainText;
- }
- ASSERT_NOT_REACHED();
+ // Elements with user-select: all style are considered atomic
+ // therefore non editable.
+ if (treatment == Node::UserSelectAllIsAlwaysNonEditable && style.effectiveUserSelect() == UserSelect::All)
return Node::Editability::ReadOnly;
- }
if (pageIsEditable == PageIsEditable::Yes)
return Node::Editability::CanEditRichly;
+ switch (style.effectiveUserModify()) {
+ case UserModify::ReadOnly:
+ return Node::Editability::ReadOnly;
+ case UserModify::ReadWrite:
+ return Node::Editability::CanEditRichly;
+ case UserModify::ReadWritePlaintextOnly:
+ return Node::Editability::CanEditPlainText;
+ }
+ ASSERT_NOT_REACHED();
return Node::Editability::ReadOnly;
}
-Node::Editability Node::computeEditability(UserSelectAllTreatment treatment, ShouldUpdateStyle shouldUpdateStyle) const
+Node::Editability Node::computeEditabilityWithStyle(const RenderStyle* style, UserSelectAllTreatment treatment, ShouldUpdateStyle shouldUpdateStyle) const
{
if (!document().hasLivingRenderTree() || isPseudoElement())
return Editability::ReadOnly;
@@ -808,9 +797,19 @@
document->updateStyleIfNeeded();
}
- return computeEditabilityFromComputedStyle(*this, treatment, pageIsEditable);
+ if (!style)
+ style = isDocumentNode() ? renderStyle() : const_cast<Node*>(this)->computedStyle();
+ if (!style)
+ return Editability::ReadOnly;
+
+ return computeEditabilityFromComputedStyle(*style, treatment, pageIsEditable);
}
+Node::Editability Node::computeEditability(UserSelectAllTreatment treatment, ShouldUpdateStyle shouldUpdateStyle) const
+{
+ return computeEditabilityWithStyle(nullptr, treatment, shouldUpdateStyle);
+}
+
RenderBox* Node::renderBox() const
{
return dynamicDowncast<RenderBox>(renderer());
@@ -2540,24 +2539,42 @@
});
}
+Node::Editability Node::computeEditabilityForMouseClickEvents(const RenderStyle* style) const
+{
+ // FIXME: Why is the iOS code path different from the non-iOS code path?
+#if PLATFORM(IOS_FAMILY)
+ auto userSelectAllTreatment = UserSelectAllDoesNotAffectEditability;
+#else
+ auto userSelectAllTreatment = UserSelectAllIsAlwaysNonEditable;
+#endif
+
+ return computeEditabilityWithStyle(style, userSelectAllTreatment, style ? ShouldUpdateStyle::DoNotUpdate : ShouldUpdateStyle::Update);
+}
+
bool Node::willRespondToMouseClickEvents() const
{
+ return willRespondToMouseClickEventsWithEditability(computeEditabilityForMouseClickEvents());
+}
+
+bool Node::willRespondToMouseClickEventsWithEditability(Editability editability) const
+{
// FIXME: Why is the iOS code path different from the non-iOS code path?
-#if PLATFORM(IOS_FAMILY)
- if (isContentEditable())
- return true;
- auto& eventNames = WebCore::eventNames();
- return hasEventListeners(eventNames.mouseupEvent) || hasEventListeners(eventNames.mousedownEvent) || hasEventListeners(eventNames.clickEvent);
-#else
+#if !PLATFORM(IOS_FAMILY)
if (!is<Element>(*this))
return false;
if (downcast<Element>(*this).isDisabledFormControl())
return false;
- if (computeEditability(UserSelectAllIsAlwaysNonEditable, ShouldUpdateStyle::Update) != Editability::ReadOnly)
+#endif
+ if (editability != Editability::ReadOnly)
return true;
auto& eventNames = WebCore::eventNames();
- return hasEventListeners(eventNames.mouseupEvent) || hasEventListeners(eventNames.mousedownEvent) || hasEventListeners(eventNames.clickEvent) || hasEventListeners(eventNames.DOMActivateEvent);
+ return hasEventListeners(eventNames.mouseupEvent)
+ || hasEventListeners(eventNames.mousedownEvent)
+ || hasEventListeners(eventNames.clickEvent)
+#if !PLATFORM(IOS_FAMILY)
+ || hasEventListeners(eventNames.DOMActivateEvent)
#endif
+ ;
}
bool Node::willRespondToMouseWheelEvents() const
Modified: trunk/Source/WebCore/dom/Node.h (294972 => 294973)
--- trunk/Source/WebCore/dom/Node.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/dom/Node.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -352,6 +352,7 @@
enum class Editability { ReadOnly, CanEditPlainText, CanEditRichly };
enum class ShouldUpdateStyle { Update, DoNotUpdate };
WEBCORE_EXPORT Editability computeEditability(UserSelectAllTreatment, ShouldUpdateStyle) const;
+ Editability computeEditabilityWithStyle(const RenderStyle*, UserSelectAllTreatment, ShouldUpdateStyle) const;
WEBCORE_EXPORT LayoutRect renderRect(bool* isReplaced);
IntRect pixelSnappedRenderRect(bool* isReplaced) { return snappedIntRect(renderRect(isReplaced)); }
@@ -461,7 +462,9 @@
void clearNodeLists();
virtual bool willRespondToMouseMoveEvents() const;
- virtual bool willRespondToMouseClickEvents() const;
+ bool willRespondToMouseClickEvents() const;
+ Editability computeEditabilityForMouseClickEvents(const RenderStyle* = nullptr) const;
+ virtual bool willRespondToMouseClickEventsWithEditability(Editability) const;
virtual bool willRespondToMouseWheelEvents() const;
virtual bool willRespondToTouchEvents() const;
Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -676,9 +676,9 @@
return isInSVGImage(element);
}
-bool HTMLAnchorElement::willRespondToMouseClickEvents() const
+bool HTMLAnchorElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
- return isLink() || HTMLElement::willRespondToMouseClickEvents();
+ return isLink() || HTMLElement::willRespondToMouseClickEventsWithEditability(editability);
}
static auto& rootEditableElementMap()
Modified: trunk/Source/WebCore/html/HTMLAnchorElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLAnchorElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -64,7 +64,7 @@
bool isLiveLink() const;
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
bool hasRel(Relation) const;
Modified: trunk/Source/WebCore/html/HTMLButtonElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLButtonElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLButtonElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -183,7 +183,7 @@
HTMLFormControlElement::defaultEventHandler(event);
}
-bool HTMLButtonElement::willRespondToMouseClickEvents() const
+bool HTMLButtonElement::willRespondToMouseClickEventsWithEditability(Editability) const
{
return !isDisabledFormControl();
}
Modified: trunk/Source/WebCore/html/HTMLButtonElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLButtonElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLButtonElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -38,7 +38,7 @@
const AtomString& value() const;
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
RenderButton* renderer() const;
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -1005,9 +1005,9 @@
return !isDisabledFormControl() && Element::willRespondToMouseWheelEvents();
}
-bool HTMLElement::willRespondToMouseClickEvents() const
+bool HTMLElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
- return !isDisabledFormControl() && Element::willRespondToMouseClickEvents();
+ return !isDisabledFormControl() && Element::willRespondToMouseClickEventsWithEditability(editability);
}
bool HTMLElement::canBeActuallyDisabled() const
Modified: trunk/Source/WebCore/html/HTMLElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -96,7 +96,7 @@
bool willRespondToMouseMoveEvents() const override;
bool willRespondToMouseWheelEvents() const override;
- bool willRespondToMouseClickEvents() const override;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const override;
virtual bool isLabelable() const { return false; }
virtual FormNamedItem* asFormNamedItem();
Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLImageElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -790,12 +790,12 @@
#if PLATFORM(IOS_FAMILY)
// FIXME: We should find a better place for the touch callout logic. See rdar://problem/48937767.
-bool HTMLImageElement::willRespondToMouseClickEvents() const
+bool HTMLImageElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
auto renderer = this->renderer();
if (!renderer || renderer->style().touchCalloutEnabled())
return true;
- return HTMLElement::willRespondToMouseClickEvents();
+ return HTMLElement::willRespondToMouseClickEventsWithEditability(editability);
}
#endif
Modified: trunk/Source/WebCore/html/HTMLImageElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLImageElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLImageElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -101,7 +101,7 @@
WEBCORE_EXPORT void decode(Ref<DeferredPromise>&&);
#if PLATFORM(IOS_FAMILY)
- bool willRespondToMouseClickEvents() const override;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const override;
#endif
#if ENABLE(ATTACHMENT_ELEMENT)
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -1224,12 +1224,12 @@
HTMLTextFormControlElement::defaultEventHandler(event);
}
-bool HTMLInputElement::willRespondToMouseClickEvents() const
+bool HTMLInputElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
if (!isDisabledFormControl())
return true;
- return HTMLTextFormControlElement::willRespondToMouseClickEvents();
+ return HTMLTextFormControlElement::willRespondToMouseClickEventsWithEditability(editability);
}
bool HTMLInputElement::isURLAttribute(const Attribute& attribute) const
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -268,7 +268,7 @@
void addSearchResult();
void onSearch();
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
#if ENABLE(DATALIST_ELEMENT)
WEBCORE_EXPORT RefPtr<HTMLElement> list() const;
Modified: trunk/Source/WebCore/html/HTMLLabelElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLLabelElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLLabelElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -167,10 +167,10 @@
HTMLElement::defaultEventHandler(event);
}
-bool HTMLLabelElement::willRespondToMouseClickEvents() const
+bool HTMLLabelElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
auto element = control();
- return (element && element->willRespondToMouseClickEvents()) || HTMLElement::willRespondToMouseClickEvents();
+ return (element && element->willRespondToMouseClickEventsWithEditability(editability)) || HTMLElement::willRespondToMouseClickEventsWithEditability(editability);
}
void HTMLLabelElement::focus(const FocusOptions& options)
Modified: trunk/Source/WebCore/html/HTMLLabelElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLLabelElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLLabelElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -35,7 +35,7 @@
WEBCORE_EXPORT RefPtr<LabelableElement> control() const;
WEBCORE_EXPORT HTMLFormElement* form() const final;
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
private:
HTMLLabelElement(const QualifiedName&, Document&);
Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -72,7 +72,7 @@
ASSERT(!m_instance); // cleared in detach()
}
-bool HTMLPlugInElement::willRespondToMouseClickEvents() const
+bool HTMLPlugInElement::willRespondToMouseClickEventsWithEditability(Editability) const
{
if (isDisabledFormControl())
return false;
Modified: trunk/Source/WebCore/html/HTMLPlugInElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLPlugInElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -65,7 +65,7 @@
#if PLATFORM(IOS_FAMILY)
bool willRespondToMouseMoveEvents() const final { return false; }
#endif
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
virtual bool isPlugInImageElement() const = 0;
Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLSelectElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -531,12 +531,13 @@
return isRequired();
}
-bool HTMLSelectElement::willRespondToMouseClickEvents() const
+bool HTMLSelectElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
#if PLATFORM(IOS_FAMILY)
+ UNUSED_PARAM(editability);
return !isDisabledFormControl();
#else
- return HTMLFormControlElementWithState::willRespondToMouseClickEvents();
+ return HTMLFormControlElementWithState::willRespondToMouseClickEventsWithEditability(editability);
#endif
}
Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLSelectElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -142,7 +142,7 @@
void reset() final;
void defaultEventHandler(Event&) final;
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
void dispatchChangeEventForMenuList();
Modified: trunk/Source/WebCore/html/HTMLSummaryElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLSummaryElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -156,12 +156,12 @@
HTMLElement::defaultEventHandler(event);
}
-bool HTMLSummaryElement::willRespondToMouseClickEvents() const
+bool HTMLSummaryElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
if (isActiveSummary() && renderer())
return true;
- return HTMLElement::willRespondToMouseClickEvents();
+ return HTMLElement::willRespondToMouseClickEventsWithEditability(editability);
}
}
Modified: trunk/Source/WebCore/html/HTMLSummaryElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLSummaryElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -32,7 +32,7 @@
static Ref<HTMLSummaryElement> create(const QualifiedName&, Document&);
bool isActiveSummary() const;
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
private:
HTMLSummaryElement(const QualifiedName&, Document&);
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -565,7 +565,7 @@
m_placeholder->setInnerText(String { placeholderText });
}
-bool HTMLTextAreaElement::willRespondToMouseClickEvents() const
+bool HTMLTextAreaElement::willRespondToMouseClickEventsWithEditability(Editability) const
{
return !isDisabledFormControl();
}
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -66,7 +66,7 @@
WEBCORE_EXPORT void setCols(unsigned);
WEBCORE_EXPORT void setRows(unsigned);
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
RenderTextControlMultiLine* renderer() const;
Modified: trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -350,13 +350,13 @@
return HTMLDivElement::willRespondToMouseMoveEvents();
}
-bool SliderThumbElement::willRespondToMouseClickEvents() const
+bool SliderThumbElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
const auto input = hostInput();
if (input && !input->isDisabledFormControl())
return true;
- return HTMLDivElement::willRespondToMouseClickEvents();
+ return HTMLDivElement::willRespondToMouseClickEventsWithEditability(editability);
}
void SliderThumbElement::willDetachRenderers()
Modified: trunk/Source/WebCore/html/shadow/SliderThumbElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/shadow/SliderThumbElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/shadow/SliderThumbElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -66,7 +66,7 @@
void defaultEventHandler(Event&) final;
bool willRespondToMouseMoveEvents() const final;
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
#if ENABLE(IOS_TOUCH_EVENTS)
void didAttachRenderers() final;
Modified: trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -180,12 +180,12 @@
return HTMLDivElement::willRespondToMouseMoveEvents();
}
-bool SpinButtonElement::willRespondToMouseClickEvents() const
+bool SpinButtonElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
if (renderBox() && shouldRespondToMouseEvents())
return true;
- return HTMLDivElement::willRespondToMouseClickEvents();
+ return HTMLDivElement::willRespondToMouseClickEventsWithEditability(editability);
}
void SpinButtonElement::doStepAction(int amount)
Modified: trunk/Source/WebCore/html/shadow/SpinButtonElement.h (294972 => 294973)
--- trunk/Source/WebCore/html/shadow/SpinButtonElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/shadow/SpinButtonElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -62,7 +62,7 @@
void step(int amount);
bool willRespondToMouseMoveEvents() const override;
- bool willRespondToMouseClickEvents() const override;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const override;
void forwardEvent(Event&);
Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (294972 => 294973)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -278,7 +278,7 @@
}
#if !PLATFORM(IOS_FAMILY)
-bool SearchFieldResultsButtonElement::willRespondToMouseClickEvents() const
+bool SearchFieldResultsButtonElement::willRespondToMouseClickEventsWithEditability(Editability) const
{
return true;
}
@@ -338,13 +338,13 @@
}
#if !PLATFORM(IOS_FAMILY)
-bool SearchFieldCancelButtonElement::willRespondToMouseClickEvents() const
+bool SearchFieldCancelButtonElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
const RefPtr<HTMLInputElement> input = downcast<HTMLInputElement>(shadowHost());
if (input && !input->isDisabledOrReadOnly())
return true;
- return HTMLDivElement::willRespondToMouseClickEvents();
+ return HTMLDivElement::willRespondToMouseClickEventsWithEditability(editability);
}
#endif
Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.h (294972 => 294973)
--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -98,7 +98,7 @@
void defaultEventHandler(Event&) override;
#if !PLATFORM(IOS_FAMILY)
- bool willRespondToMouseClickEvents() const override;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const override;
#endif
bool canAdjustStyleForAppearance() const { return m_canAdjustStyleForAppearance; }
@@ -119,7 +119,7 @@
void defaultEventHandler(Event&) override;
#if !PLATFORM(IOS_FAMILY)
- bool willRespondToMouseClickEvents() const override;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const override;
#endif
private:
Modified: trunk/Source/WebCore/mathml/MathMLElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/mathml/MathMLElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/mathml/MathMLElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -180,9 +180,9 @@
return is<MathMLElement>(child);
}
-bool MathMLElement::willRespondToMouseClickEvents() const
+bool MathMLElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
- return isLink() || StyledElement::willRespondToMouseClickEvents();
+ return isLink() || StyledElement::willRespondToMouseClickEventsWithEditability(editability);
}
void MathMLElement::defaultEventHandler(Event& event)
Modified: trunk/Source/WebCore/mathml/MathMLElement.h (294972 => 294973)
--- trunk/Source/WebCore/mathml/MathMLElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/mathml/MathMLElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -98,7 +98,7 @@
bool hasPresentationalHintsForAttribute(const QualifiedName&) const override;
void collectPresentationalHintsForAttribute(const QualifiedName&, const AtomString&, MutableStyleProperties&) override;
- bool willRespondToMouseClickEvents() const override;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const override;
void defaultEventHandler(Event&) override;
private:
Modified: trunk/Source/WebCore/mathml/MathMLSelectElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/mathml/MathMLSelectElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/mathml/MathMLSelectElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -225,9 +225,9 @@
MathMLRowElement::defaultEventHandler(event);
}
-bool MathMLSelectElement::willRespondToMouseClickEvents() const
+bool MathMLSelectElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
- return attributeWithoutSynchronization(MathMLNames::actiontypeAttr) == "toggle" || MathMLRowElement::willRespondToMouseClickEvents();
+ return attributeWithoutSynchronization(MathMLNames::actiontypeAttr) == "toggle" || MathMLRowElement::willRespondToMouseClickEventsWithEditability(editability);
}
void MathMLSelectElement::toggle()
Modified: trunk/Source/WebCore/mathml/MathMLSelectElement.h (294972 => 294973)
--- trunk/Source/WebCore/mathml/MathMLSelectElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/mathml/MathMLSelectElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -49,7 +49,7 @@
void childrenChanged(const ChildChange&) final;
void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason = ModifiedDirectly) final;
void defaultEventHandler(Event&) final;
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
void toggle();
int getSelectedActionChildAndIndex(Element*& selectedChild);
Modified: trunk/Source/WebCore/page/InteractionRegion.cpp (294972 => 294973)
--- trunk/Source/WebCore/page/InteractionRegion.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/page/InteractionRegion.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -174,8 +174,12 @@
if (!is<Element>(node.get()))
continue;
auto& element = downcast<Element>(node.get());
+ if (!element.renderer())
+ continue;
- if (!element.willRespondToMouseClickEvents() && !element.willRespondToTouchEvents())
+ auto& renderer = *element.renderer();
+ // FIXME: Consider also allowing elements that only receive touch events.
+ if (!renderer.style().eventListenerRegionTypes().contains(EventListenerRegionType::MouseClick))
continue;
if (cursorTypeForElement(element) != CursorType::Pointer && !is<HTMLFormControlElement>(element))
Modified: trunk/Source/WebCore/rendering/EventRegion.cpp (294972 => 294973)
--- trunk/Source/WebCore/rendering/EventRegion.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/rendering/EventRegion.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -299,6 +299,8 @@
return m_wheelEventListenerRegion;
case EventListenerRegionType::NonPassiveWheel:
return m_nonPassiveWheelEventListenerRegion;
+ case EventListenerRegionType::MouseClick:
+ break;
}
ASSERT_NOT_REACHED();
return m_wheelEventListenerRegion;
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (294972 => 294973)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -3399,6 +3399,8 @@
return { "wheel"_s, { }, Color::darkGreen.colorWithAlphaByte(128) };
case EventListenerRegionType::NonPassiveWheel:
return { "sync"_s, { 0, 9 }, SRGBA<uint8_t> { 200, 0, 0, 128 } };
+ case EventListenerRegionType::MouseClick:
+ break;
}
ASSERT_NOT_REACHED();
return { ""_s, { }, Color::black };
Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp (294972 => 294973)
--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -441,6 +441,7 @@
switch (listenerType) {
case EventListenerRegionType::Wheel: ts << "wheel"; break;
case EventListenerRegionType::NonPassiveWheel: ts << "active wheel"; break;
+ case EventListenerRegionType::MouseClick: ts << "mouse click"; break;
}
return ts;
}
Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (294972 => 294973)
--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -1190,6 +1190,7 @@
enum class EventListenerRegionType : uint8_t {
Wheel = 1 << 0,
NonPassiveWheel = 1 << 1,
+ MouseClick = 1 << 2,
};
enum class MathStyle : uint8_t {
Modified: trunk/Source/WebCore/style/StyleAdjuster.cpp (294972 => 294973)
--- trunk/Source/WebCore/style/StyleAdjuster.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/style/StyleAdjuster.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -212,21 +212,18 @@
void Adjuster::adjustEventListenerRegionTypesForRootStyle(RenderStyle& rootStyle, const Document& document)
{
- auto regionTypes = computeEventListenerRegionTypes(document, { });
+ auto regionTypes = computeEventListenerRegionTypes(document, rootStyle, document, { });
if (auto* window = document.domWindow())
- regionTypes.add(computeEventListenerRegionTypes(*window, { }));
+ regionTypes.add(computeEventListenerRegionTypes(document, rootStyle, *window, { }));
rootStyle.setEventListenerRegionTypes(regionTypes);
}
-OptionSet<EventListenerRegionType> Adjuster::computeEventListenerRegionTypes(const EventTarget& eventTarget, OptionSet<EventListenerRegionType> parentTypes)
+OptionSet<EventListenerRegionType> Adjuster::computeEventListenerRegionTypes(const Document& document, const RenderStyle& style, const EventTarget& eventTarget, OptionSet<EventListenerRegionType> parentTypes)
{
-#if ENABLE(WHEEL_EVENT_REGIONS)
- if (!eventTarget.hasEventListeners())
- return parentTypes;
-
auto types = parentTypes;
+#if ENABLE(WHEEL_EVENT_REGIONS)
auto findListeners = [&](auto& eventName, auto type, auto nonPassiveType) {
auto* eventListenerVector = eventTarget.eventTargetData()->eventListenerMap.find(eventName);
if (!eventListenerVector)
@@ -246,15 +243,28 @@
types.add(nonPassiveType);
};
- findListeners(eventNames().wheelEvent, EventListenerRegionType::Wheel, EventListenerRegionType::NonPassiveWheel);
- findListeners(eventNames().mousewheelEvent, EventListenerRegionType::Wheel, EventListenerRegionType::NonPassiveWheel);
+ if (eventTarget.hasEventListeners()) {
+ findListeners(eventNames().wheelEvent, EventListenerRegionType::Wheel, EventListenerRegionType::NonPassiveWheel);
+ findListeners(eventNames().mousewheelEvent, EventListenerRegionType::Wheel, EventListenerRegionType::NonPassiveWheel);
+ }
+#endif
- return types;
+#if ENABLE(INTERACTION_REGIONS_IN_EVENT_REGION)
+ if (document.page() && document.page()->shouldBuildInteractionRegions() && eventTarget.isNode()) {
+ const auto& node = downcast<Node>(eventTarget);
+ if (node.willRespondToMouseClickEventsWithEditability(node.computeEditabilityForMouseClickEvents(&style)))
+ types.add(EventListenerRegionType::MouseClick);
+ }
#else
+ UNUSED_PARAM(document);
+ UNUSED_PARAM(style);
+#endif
+
+#if !ENABLE(WHEEL_EVENT_REGIONS) && !ENABLE(INTERACTION_REGIONS_IN_EVENT_REGION)
UNUSED_PARAM(eventTarget);
- UNUSED_PARAM(parentTypes);
- return { };
#endif
+
+ return types;
}
void Adjuster::adjust(RenderStyle& style, const RenderStyle* userAgentAppearanceStyle) const
@@ -556,7 +566,7 @@
if (m_element == m_document.activeModalDialog() && !hasInertAttribute(m_element))
style.setEffectiveInert(false);
- style.setEventListenerRegionTypes(computeEventListenerRegionTypes(*m_element, m_parentStyle.eventListenerRegionTypes()));
+ style.setEventListenerRegionTypes(computeEventListenerRegionTypes(m_document, style, *m_element, m_parentStyle.eventListenerRegionTypes()));
#if ENABLE(TEXT_AUTOSIZING)
if (m_document.settings().textAutosizingUsesIdempotentMode())
Modified: trunk/Source/WebCore/style/StyleAdjuster.h (294972 => 294973)
--- trunk/Source/WebCore/style/StyleAdjuster.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/style/StyleAdjuster.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -67,7 +67,7 @@
private:
void adjustDisplayContentsStyle(RenderStyle&) const;
void adjustForSiteSpecificQuirks(RenderStyle&) const;
- static OptionSet<EventListenerRegionType> computeEventListenerRegionTypes(const EventTarget&, OptionSet<EventListenerRegionType>);
+ static OptionSet<EventListenerRegionType> computeEventListenerRegionTypes(const Document&, const RenderStyle&, const EventTarget&, OptionSet<EventListenerRegionType>);
const Document& m_document;
const RenderStyle& m_parentStyle;
Modified: trunk/Source/WebCore/svg/SVGAElement.cpp (294972 => 294973)
--- trunk/Source/WebCore/svg/SVGAElement.cpp 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/svg/SVGAElement.cpp 2022-05-28 01:06:44 UTC (rev 294973)
@@ -210,9 +210,9 @@
return SVGElement::childShouldCreateRenderer(child);
}
-bool SVGAElement::willRespondToMouseClickEvents() const
+bool SVGAElement::willRespondToMouseClickEventsWithEditability(Editability editability) const
{
- return isLink() || SVGGraphicsElement::willRespondToMouseClickEvents();
+ return isLink() || SVGGraphicsElement::willRespondToMouseClickEventsWithEditability(editability);
}
SharedStringHash SVGAElement::visitedLinkHash() const
Modified: trunk/Source/WebCore/svg/SVGAElement.h (294972 => 294973)
--- trunk/Source/WebCore/svg/SVGAElement.h 2022-05-28 00:56:02 UTC (rev 294972)
+++ trunk/Source/WebCore/svg/SVGAElement.h 2022-05-28 01:06:44 UTC (rev 294973)
@@ -65,7 +65,7 @@
bool canStartSelection() const final;
int defaultTabIndex() const final;
- bool willRespondToMouseClickEvents() const final;
+ bool willRespondToMouseClickEventsWithEditability(Editability) const final;
PropertyRegistry m_propertyRegistry { *this };
Ref<SVGAnimatedString> m_target { SVGAnimatedString::create(this) };