Diff
Modified: trunk/Source/WebCore/ChangeLog (289245 => 289246)
--- trunk/Source/WebCore/ChangeLog 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/ChangeLog 2022-02-07 23:17:34 UTC (rev 289246)
@@ -1,3 +1,31 @@
+2022-02-07 Megan Gardner <[email protected]>
+
+ Update hover state based on pointer type.
+ https://bugs.webkit.org/show_bug.cgi?id=236249
+
+ Reviewed by Tim Horton.
+
+ * dom/Document.cpp:
+ (WebCore::Document::updateHoverActiveState):
+ * dom/Element.cpp:
+ (WebCore::Element::setHovered):
+ * dom/Element.h:
+ * html/HTMLLabelElement.cpp:
+ (WebCore::HTMLLabelElement::setHovered):
+ * html/HTMLLabelElement.h:
+ * html/HTMLTextFormControlElement.cpp:
+ (WebCore::pointerTypeFromHitTestRequest):
+ (WebCore::showPlaceholderForPointer):
+ (WebCore::HTMLTextFormControlElement::setHovered):
+ (WebCore::HTMLTextFormControlElement::placeholderShouldBeVisible const):
+ * html/HTMLTextFormControlElement.h:
+ * html/shadow/SpinButtonElement.cpp:
+ (WebCore::SpinButtonElement::setHovered):
+ * html/shadow/SpinButtonElement.h:
+ * page/EventHandler.cpp:
+ (addPointerTypeToHitTestRequest):
+ (WebCore::EventHandler::handleMouseMoveEvent):
+
2022-02-07 Alan Bujtas <[email protected]>
Updating grid gap value does not recalculate styles
Modified: trunk/Source/WebCore/dom/Document.cpp (289245 => 289246)
--- trunk/Source/WebCore/dom/Document.cpp 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/dom/Document.cpp 2022-02-07 23:17:34 UTC (rev 289246)
@@ -7437,11 +7437,11 @@
changeState(elementsToSetActive, CSSSelector::PseudoClassActive, true, [](auto& element) {
element.setActive(true, false, Style::InvalidationScope::SelfChildrenAndSiblings);
});
- changeState(elementsToClearHover, CSSSelector::PseudoClassHover, false, [](auto& element) {
- element.setHovered(false, Style::InvalidationScope::SelfChildrenAndSiblings);
+ changeState(elementsToClearHover, CSSSelector::PseudoClassHover, false, [request](auto& element) {
+ element.setHovered(false, Style::InvalidationScope::SelfChildrenAndSiblings, request);
});
- changeState(elementsToSetHover, CSSSelector::PseudoClassHover, true, [](auto& element) {
- element.setHovered(true, Style::InvalidationScope::SelfChildrenAndSiblings);
+ changeState(elementsToSetHover, CSSSelector::PseudoClassHover, true, [request](auto& element) {
+ element.setHovered(true, Style::InvalidationScope::SelfChildrenAndSiblings, request);
});
}
Modified: trunk/Source/WebCore/dom/Element.cpp (289245 => 289246)
--- trunk/Source/WebCore/dom/Element.cpp 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/dom/Element.cpp 2022-02-07 23:17:34 UTC (rev 289246)
@@ -888,7 +888,7 @@
}
}
-void Element::setHovered(bool value, Style::InvalidationScope invalidationScope)
+void Element::setHovered(bool value, Style::InvalidationScope invalidationScope, HitTestRequest)
{
if (value == hovered())
return;
Modified: trunk/Source/WebCore/dom/Element.h (289245 => 289246)
--- trunk/Source/WebCore/dom/Element.h 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/dom/Element.h 2022-02-07 23:17:34 UTC (rev 289246)
@@ -29,6 +29,7 @@
#include "ElementIdentifier.h"
#include "EventOptions.h"
#include "FocusOptions.h"
+#include "HitTestRequest.h"
#include "QualifiedName.h"
#include "RenderPtr.h"
#include "ScrollTypes.h"
@@ -342,7 +343,7 @@
bool hasFocusWithin() const { return isUserActionElement() && isUserActionElementHasFocusWithin(); };
virtual void setActive(bool = true, bool pause = false, Style::InvalidationScope = Style::InvalidationScope::All);
- virtual void setHovered(bool = true, Style::InvalidationScope = Style::InvalidationScope::All);
+ virtual void setHovered(bool = true, Style::InvalidationScope = Style::InvalidationScope::All, HitTestRequest = {});
virtual void setFocus(bool, FocusVisibility = FocusVisibility::Invisible);
void setBeingDragged(bool);
void setHasFocusVisible(bool);
Modified: trunk/Source/WebCore/html/HTMLLabelElement.cpp (289245 => 289246)
--- trunk/Source/WebCore/html/HTMLLabelElement.cpp 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/html/HTMLLabelElement.cpp 2022-02-07 23:17:34 UTC (rev 289246)
@@ -99,13 +99,13 @@
element->setActive(down, pause);
}
-void HTMLLabelElement::setHovered(bool over, Style::InvalidationScope invalidationScope)
+void HTMLLabelElement::setHovered(bool over, Style::InvalidationScope invalidationScope, HitTestRequest request)
{
if (over == hovered())
return;
// Update our status first.
- HTMLElement::setHovered(over, invalidationScope);
+ HTMLElement::setHovered(over, invalidationScope, request);
// Also update our corresponding control.
if (auto element = control())
Modified: trunk/Source/WebCore/html/HTMLLabelElement.h (289245 => 289246)
--- trunk/Source/WebCore/html/HTMLLabelElement.h 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/html/HTMLLabelElement.h 2022-02-07 23:17:34 UTC (rev 289246)
@@ -46,7 +46,7 @@
// Overridden to update the hover/active state of the corresponding control.
void setActive(bool, bool pause, Style::InvalidationScope) final;
- void setHovered(bool, Style::InvalidationScope) final;
+ void setHovered(bool, Style::InvalidationScope, HitTestRequest) final;
// Overridden to either click() or focus() the corresponding control.
void defaultEventHandler(Event&) final;
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (289245 => 289246)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2022-02-07 23:17:34 UTC (rev 289246)
@@ -64,6 +64,23 @@
static Position positionForIndex(TextControlInnerTextElement*, unsigned);
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/HTMLTextFormControlElementAdditions.mm>
+#else
+
+static String pointerTypeFromHitTestRequest(HitTestRequest)
+{
+ return WebCore::mousePointerEventType();
+}
+
+static bool showPlaceholderForPointer(bool, String)
+{
+ return true;
+}
+
+#endif
+
+
HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
: HTMLFormControlElementWithState(tagName, document, form)
, m_cachedSelectionDirection(SelectionHasNoDirection)
@@ -96,6 +113,18 @@
return InsertedIntoAncestorResult;
}
+void HTMLTextFormControlElement::setHovered(bool over, Style::InvalidationScope invalidationScope, HitTestRequest request)
+{
+ if (over == hovered())
+ return;
+
+ m_pointerType = pointerTypeFromHitTestRequest(request);
+
+ HTMLElement::setHovered(over, invalidationScope, request);
+
+ updatePlaceholderVisibility();
+}
+
void HTMLTextFormControlElement::dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection direction)
{
if (supportsPlaceholder())
@@ -143,7 +172,7 @@
{
// This function is used by the style resolver to match the :placeholder-shown pseudo class.
// Since it is used for styling, it must not use any value depending on the style.
- return supportsPlaceholder() && isEmptyValue() && !isPlaceholderEmpty() && m_canShowPlaceholder;
+ return supportsPlaceholder() && isEmptyValue() && !isPlaceholderEmpty() && m_canShowPlaceholder && showPlaceholderForPointer(hovered(), m_pointerType);
}
void HTMLTextFormControlElement::updatePlaceholderVisibility()
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (289245 => 289246)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2022-02-07 23:17:34 UTC (rev 289246)
@@ -25,6 +25,7 @@
#pragma once
#include "HTMLFormControlElementWithState.h"
+#include "PointerEventTypeNames.h"
namespace WebCore {
@@ -146,6 +147,8 @@
void dispatchFocusEvent(RefPtr<Element>&& oldFocusedElement, FocusDirection) final;
void dispatchBlurEvent(RefPtr<Element>&& newFocusedElement) final;
bool childShouldCreateRenderer(const Node&) const override;
+
+ void setHovered(bool, Style::InvalidationScope, HitTestRequest) final;
unsigned indexForPosition(const Position&) const;
@@ -162,6 +165,8 @@
unsigned m_lastChangeWasUserEdit : 1;
unsigned m_isPlaceholderVisible : 1;
unsigned m_canShowPlaceholder : 1;
+
+ String m_pointerType { mousePointerEventType() };
String m_textAsOfLastFormControlChangeEvent;
Modified: trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp (289245 => 289246)
--- trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/html/shadow/SpinButtonElement.cpp 2022-02-07 23:17:34 UTC (rev 289246)
@@ -249,11 +249,11 @@
step(m_upDownState == Up ? 1 : -1);
}
-void SpinButtonElement::setHovered(bool flag, Style::InvalidationScope invalidationScope)
+void SpinButtonElement::setHovered(bool flag, Style::InvalidationScope invalidationScope, HitTestRequest request)
{
if (!flag)
m_upDownState = Indeterminate;
- HTMLDivElement::setHovered(flag, invalidationScope);
+ HTMLDivElement::setHovered(flag, invalidationScope, request);
}
bool SpinButtonElement::shouldRespondToMouseEvents()
Modified: trunk/Source/WebCore/html/shadow/SpinButtonElement.h (289245 => 289246)
--- trunk/Source/WebCore/html/shadow/SpinButtonElement.h 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/html/shadow/SpinButtonElement.h 2022-02-07 23:17:34 UTC (rev 289246)
@@ -79,7 +79,7 @@
void startRepeatingTimer();
void stopRepeatingTimer();
void repeatingTimerFired();
- void setHovered(bool, Style::InvalidationScope) override;
+ void setHovered(bool, Style::InvalidationScope, HitTestRequest) override;
bool shouldRespondToMouseEvents();
bool isMouseFocusable() const override { return false; }
Modified: trunk/Source/WebCore/page/EventHandler.cpp (289245 => 289246)
--- trunk/Source/WebCore/page/EventHandler.cpp 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2022-02-07 23:17:34 UTC (rev 289246)
@@ -85,6 +85,7 @@
#include "PlatformKeyboardEvent.h"
#include "PlatformWheelEvent.h"
#include "PluginDocument.h"
+#include "PointerEventTypeNames.h"
#include "PseudoClassChangeInvalidation.h"
#include "Range.h"
#include "RenderFrameSet.h"
@@ -152,6 +153,12 @@
#if USE(APPLE_INTERNAL_SDK)
#include <WebKitAdditions/EventHandlerAdditions.cpp>
+#else
+
+static void addPointerTypeToHitTestRequest(OptionSet<WebCore::HitTestRequest::Type> &, String )
+{
+}
+
#endif
namespace WebCore {
@@ -1992,6 +1999,9 @@
hitType.add(HitTestRequest::Type::ReadOnly);
}
#endif
+
+ addPointerTypeToHitTestRequest(hitType, platformMouseEvent.pointerType());
+
HitTestRequest request(hitType);
MouseEventWithHitTestResults mouseEvent = prepareMouseEvent(request, platformMouseEvent);
if (hitTestResult)
Modified: trunk/Source/WebKit/ChangeLog (289245 => 289246)
--- trunk/Source/WebKit/ChangeLog 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebKit/ChangeLog 2022-02-07 23:17:34 UTC (rev 289246)
@@ -1,3 +1,15 @@
+2022-02-07 Megan Gardner <[email protected]>
+
+ Update hover state based on pointer type.
+ https://bugs.webkit.org/show_bug.cgi?id=236249
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/ios/WKMouseGestureRecognizer.mm:
+ (pointerTypeForUITouchType):
+ (-[WKMouseGestureRecognizer createMouseEventWithType:wasCancelled:]):
+ (-[WKMouseGestureRecognizer checkTouches:]):
+
2022-02-07 Commit Queue <[email protected]>
Unreviewed, reverting r289239.
Modified: trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.mm (289245 => 289246)
--- trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.mm 2022-02-07 23:13:29 UTC (rev 289245)
+++ trunk/Source/WebKit/UIProcess/ios/WKMouseGestureRecognizer.mm 2022-02-07 23:17:34 UTC (rev 289246)
@@ -50,6 +50,15 @@
return modifiers;
}
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/WKMouseGestureRecognizerAdditions.mm>
+#else
+static String pointerTypeForUITouchType(UITouchType)
+{
+ return WebCore::mousePointerEventType();
+}
+#endif
+
@implementation WKMouseGestureRecognizer {
RetainPtr<UIEvent> _currentHoverEvent;
RetainPtr<UITouch> _currentTouch;
@@ -130,10 +139,8 @@
auto delta = point - WebCore::IntPoint { [_currentTouch previousLocationInView:self.view] };
// UITouch's timestamp uses mach_absolute_time as its timebase, same as MonotonicTime.
auto timestamp = MonotonicTime::fromRawSeconds([_currentTouch timestamp]).approximateWallTime();
-
- String pointerType = WebCore::mousePointerEventType();
-
- return WTF::makeUnique<WebKit::NativeWebMouseEvent>(type, button, buttons, point, point, delta.width(), delta.height(), 0, [_currentTouch tapCount], modifiers, timestamp, 0, cancelled ? WebKit::GestureWasCancelled::Yes : WebKit::GestureWasCancelled::No, pointerType);
+
+ return WTF::makeUnique<WebKit::NativeWebMouseEvent>(type, button, buttons, point, point, delta.width(), delta.height(), 0, [_currentTouch tapCount], modifiers, timestamp, 0, cancelled ? WebKit::GestureWasCancelled::Yes : WebKit::GestureWasCancelled::No, pointerTypeForUITouchType([_currentTouch type]));
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event