AXPress event coordinates are always sent as (0, 0)

    https://bugs.webkit.org/show_bug.cgi?id=76677

    Reviewed by Simon Fraser.

    Make sure a press targets an element's center point.

    * accessibility/press-targets-center-point-expected.txt: Added.
    * accessibility/press-targets-center-point.html: Added.

    Set the coordinates of a simulated press equal to the center of the target
    element when the simulated press does not have a related mouse event.

    Test: accessibility/press-targets-center-point.html

    * dom/Element.cpp:
    (WebCore::Element::clientRect):
    (WebCore::Element::screenRect):
    * dom/Element.h:
    * dom/EventDispatcher.cpp:
    (WebCore::EventDispatcher::dispatchSimulatedClick):
    * dom/MouseEvent.cpp:
    (WebCore::SimulatedMouseEvent::create):
    (WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
    * dom/MouseEvent.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160032 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2a15d14b
2013-12-03 Samuel White <samuel_white@apple.com>
AXPress event coordinates are always sent as (0, 0)
https://bugs.webkit.org/show_bug.cgi?id=76677
Reviewed by Simon Fraser.
Make sure a press targets an element's center point.
* accessibility/press-targets-center-point-expected.txt: Added.
* accessibility/press-targets-center-point.html: Added.
2013-12-03 Dean Jackson <dino@apple.com>
[WebGL] Implement OES texture float linear
......
target
Actual: (89, 18)
Expected: (89, 18)
translate transform target
Actual: (289, 266)
Expected: (289, 266)
vertical left-to-right writing mode target
Actual: (18, 309)
Expected: (18, 309)
right-to-left direction target
Actual: (129, 512)
Expected: (129, 512)
This tests that press targets the receiving elements center point.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
<style>
.result {
font-family:monospace;
}
.target {
background-color:silver;
border:1px solid;
cursor:default;
}
</style>
<title>Press Targets Center Point</title>
</head>
<body>
<div class="target" id="t0" style="width:160px;">target</div>
<p>Actual: <span class="result" id="a0">waiting</span><br>Expected: <span class="result" id="e0">waiting</span></p>
<div class="target" id="t1" style="-webkit-transform:translate(160px, 160px); width:240px;">translate transform target</div>
<p>Actual: <span class="result" id="a1">waiting</span><br>Expected: <span class="result" id="e1">waiting</span></p>
<div class="target" id="t2" style="-webkit-writing-mode:vertical-lr;">vertical left-to-right writing mode target</div>
<p>Actual: <span class="result" id="a2">waiting</span><br>Expected: <span class="result" id="e2">waiting</span></p>
<div class="target" id="t3" style="direction:rtl; width:240px;">right-to-left direction target</div>
<p>Actual: <span class="result" id="a3">waiting</span><br>Expected: <span class="result" id="e3">waiting</span></p>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests that press targets the receiving elements center point.");
var targetCount = document.getElementsByClassName("target").length;
for (var i = 0; i < targetCount; ++i) {
(function(i) {
document.getElementById("t" + i).addEventListener("click", function(e) {
document.getElementById("a" + i).innerHTML = "(" + e.clientX + ", " + e.clientY + ")";
});
})(i);
var targetClientRect = document.getElementById("t" + i).getBoundingClientRect();
var targetClientX = Math.round(targetClientRect.left + targetClientRect.width / 2);
var targetClientY = Math.round(targetClientRect.top + targetClientRect.height / 2);
document.getElementById("e" + i).innerHTML = "(" + targetClientX + ", " + targetClientY + ")";
}
if (window.accessibilityController) {
// Press all targets.
for (var i = 0; i < targetCount; ++i)
accessibilityController.accessibleElementById("t" + i).press();
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
2013-12-03 Samuel White <samuel_white@apple.com>
AXPress event coordinates are always sent as (0, 0)
https://bugs.webkit.org/show_bug.cgi?id=76677
Reviewed by Simon Fraser.
Set the coordinates of a simulated press equal to the center of the target
element when the simulated press does not have a related mouse event.
Test: accessibility/press-targets-center-point.html
* dom/Element.cpp:
(WebCore::Element::clientRect):
(WebCore::Element::screenRect):
* dom/Element.h:
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchSimulatedClick):
* dom/MouseEvent.cpp:
(WebCore::SimulatedMouseEvent::create):
(WebCore::SimulatedMouseEvent::SimulatedMouseEvent):
* dom/MouseEvent.h:
2013-12-03 Dean Jackson <dino@apple.com>
[WebGL] Implement OES texture float linear
......@@ -982,13 +982,19 @@ PassRefPtr<ClientRect> Element::getBoundingClientRect()
document().adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(result, renderer()->style());
return ClientRect::create(result);
}
IntRect Element::clientRect() const
{
if (RenderObject* renderer = this->renderer())
return document().view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
return IntRect();
}
IntRect Element::screenRect() const
{
if (!renderer())
return IntRect();
// FIXME: this should probably respect transforms
return document().view()->contentsToScreen(renderer()->absoluteBoundingBoxRectIgnoringTransforms());
if (RenderObject* renderer = this->renderer())
return document().view()->contentsToScreen(renderer->absoluteBoundingBoxRect());
return IntRect();
}
const AtomicString& Element::getAttribute(const AtomicString& localName) const
......
......@@ -219,7 +219,9 @@ public:
PassRefPtr<ClientRectList> getClientRects();
PassRefPtr<ClientRect> getBoundingClientRect();
// Returns the absolute bounding box translated into screen coordinates:
// Returns the absolute bounding box translated into client coordinates.
IntRect clientRect() const;
// Returns the absolute bounding box translated into screen coordinates.
IntRect screenRect() const;
void removeAttribute(const AtomicString& name);
......
......@@ -218,17 +218,17 @@ void EventDispatcher::dispatchSimulatedClick(Element* element, Event* underlying
return;
if (mouseEventOptions == SendMouseOverUpDownEvents)
dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseoverEvent, element->document().defaultView(), underlyingEvent));
dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseoverEvent, element->document().defaultView(), underlyingEvent, element));
if (mouseEventOptions != SendNoEvents)
dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mousedownEvent, element->document().defaultView(), underlyingEvent));
dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mousedownEvent, element->document().defaultView(), underlyingEvent, element));
element->setActive(true, visualOptions == ShowPressedLook);
if (mouseEventOptions != SendNoEvents)
dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseupEvent, element->document().defaultView(), underlyingEvent));
dispatchEvent(element, SimulatedMouseEvent::create(eventNames().mouseupEvent, element->document().defaultView(), underlyingEvent, element));
element->setActive(false);
// always send click
dispatchEvent(element, SimulatedMouseEvent::create(eventNames().clickEvent, element->document().defaultView(), underlyingEvent));
dispatchEvent(element, SimulatedMouseEvent::create(eventNames().clickEvent, element->document().defaultView(), underlyingEvent, element));
elementsDispatchingSimulatedClicks.remove(element);
}
......
......@@ -252,16 +252,16 @@ PassRefPtr<Event> MouseEvent::cloneFor(HTMLIFrameElement* iframe) const
return clonedMouseEvent.release();
}
PassRefPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const AtomicString& eventType, PassRefPtr<AbstractView> view, PassRefPtr<Event> underlyingEvent)
PassRefPtr<SimulatedMouseEvent> SimulatedMouseEvent::create(const AtomicString& eventType, PassRefPtr<AbstractView> view, PassRefPtr<Event> underlyingEvent, Element* target)
{
return adoptRef(new SimulatedMouseEvent(eventType, view, underlyingEvent));
return adoptRef(new SimulatedMouseEvent(eventType, view, underlyingEvent, target));
}
SimulatedMouseEvent::~SimulatedMouseEvent()
{
}
SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView> view, PassRefPtr<Event> underlyingEvent)
SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView> view, PassRefPtr<Event> underlyingEvent, Element* target)
: MouseEvent(eventType, true, true, underlyingEvent ? underlyingEvent->timeStamp() : currentTime(), view, 0, 0, 0, 0, 0,
#if ENABLE(POINTER_LOCK)
0, 0,
......@@ -280,6 +280,9 @@ SimulatedMouseEvent::SimulatedMouseEvent(const AtomicString& eventType, PassRefP
MouseEvent* mouseEvent = static_cast<MouseEvent*>(this->underlyingEvent());
m_screenLocation = mouseEvent->screenLocation();
initCoordinates(mouseEvent->clientLocation());
} else if (target) {
m_screenLocation = target->screenRect().center();
initCoordinates(LayoutPoint(target->clientRect().center()));
}
}
......
......@@ -124,11 +124,11 @@ private:
class SimulatedMouseEvent : public MouseEvent {
public:
static PassRefPtr<SimulatedMouseEvent> create(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent);
static PassRefPtr<SimulatedMouseEvent> create(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent, Element* target);
virtual ~SimulatedMouseEvent();
private:
SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent);
SimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<AbstractView>, PassRefPtr<Event> underlyingEvent, Element* target);
};
inline MouseEvent* toMouseEvent(Event* event)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment