Commit 37eb57a6 authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

Only log hotspot and image for custom blink::Cursor

Internals::getCurrentCursorInfo() was logging hotspot and image
attributes unconditionally. Those should only be available for custom
cursors.

Bug: 1040499
Change-Id: I9c59b425e922cfa15deb891ea70cb13c3eacd522
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095095
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749141}
parent 65a17212
......@@ -2788,11 +2788,13 @@ String Internals::getCurrentCursorInfo() {
StringBuilder result;
result.Append("type=");
result.Append(CursorTypeToString(cursor.GetType()));
result.Append(" hotSpot=");
result.AppendNumber(cursor.HotSpot().X());
result.Append(',');
result.AppendNumber(cursor.HotSpot().Y());
if (cursor.GetImage()) {
if (cursor.GetType() == ui::mojom::CursorType::kCustom) {
result.Append(" hotSpot=");
result.AppendNumber(cursor.HotSpot().X());
result.Append(',');
result.AppendNumber(cursor.HotSpot().Y());
DCHECK(cursor.GetImage());
IntSize size = cursor.GetImage()->Size();
result.Append(" image=");
result.AppendNumber(size.Width());
......
......@@ -3,7 +3,7 @@ Tests whether explicitly set caret style is retained on performing text selectio
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Try selecting this text by dragging the cursor. Progress cursor should be displayed while doing so.
PASS currentCursorType is "Progress"
PASS cursorInfo is "type=Progress"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -28,8 +28,7 @@ if (window.eventSender && window.internals) {
leapForwardAndMove(div.offsetWidth - 10);
var cursorInfo = internals.getCurrentCursorInfo();
var currentCursorType = cursorInfo.substring(cursorInfo.indexOf('=') + 1, cursorInfo.lastIndexOf(' '));
shouldBeEqualToString('currentCursorType', 'Progress');
shouldBeEqualToString('cursorInfo', 'type=Progress');
}
</script>
</body>
......
......@@ -2,7 +2,7 @@ Test that mouse cursors are applied correctly to ::before/::after pseudo element
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Cursor Info: type=Wait hotSpot=0,0
Cursor Info: type=Wait
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,7 +3,7 @@ Links should be clickable even when their content is projected into them.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
PASS window.location.hash is "#link-clicked"
PASS successfullyParsed is true
......
......@@ -18,7 +18,7 @@ var cursorTest = async_test('Test cursor update after image loaded');
cursorTest.step(function() {
assert_not_equals(window.eventSender, undefined, 'This test requires eventSender.');
assert_equals(internals.getCurrentCursorInfo(), "type=Pointer hotSpot=0,0");
assert_equals(internals.getCurrentCursorInfo(), "type=Pointer");
var target = document.getElementById('target');
var rect = target.getBoundingClientRect();
......
......@@ -7,19 +7,19 @@ Bug 53341
Mouse move
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
Mouse down
Cursor Info: type=Progress hotSpot=0,0
Cursor Info: type=Progress
Mouse hold down, move
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
Mouse up
Cursor Info: type=Help hotSpot=0,0
Cursor Info: type=Help
PASS successfullyParsed is true
......
......@@ -7,47 +7,47 @@ Bug 100550
TEST CASE: Implicit default cursor
Cursor Info: type=IBeam hotSpot=0,0
Cursor Info: type=IBeam
TEST CASE: Explicit default
Cursor Info: type=Pointer hotSpot=0,0
Cursor Info: type=Pointer
TEST CASE: Explicit auto
Cursor Info: type=IBeam hotSpot=0,0
Cursor Info: type=IBeam
TEST CASE: No cursor
Cursor Info: type=None hotSpot=0,0
Cursor Info: type=None
TEST CASE: Pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: grab
Cursor Info: type=Grab hotSpot=0,0
Cursor Info: type=Grab
TEST CASE: grabbing
Cursor Info: type=Grabbing hotSpot=0,0
Cursor Info: type=Grabbing
TEST CASE: -webkit-grab
Cursor Info: type=Grab hotSpot=0,0
Cursor Info: type=Grab
TEST CASE: -webkit-grabbing
Cursor Info: type=Grabbing hotSpot=0,0
Cursor Info: type=Grabbing
TEST CASE: Existing 25x25 image
Cursor Info: type=IBeam hotSpot=0,0
Cursor Info: type=IBeam
TEST CASE: Invalid URL with fallback to pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: Invalid with fallback to 25x25 image
......@@ -83,31 +83,31 @@ Cursor Info: type=Custom hotSpot=0,0 image=25x25
TEST CASE: Over large image with fallback to pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: Local element reference
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: Multiple invalid cursors with fallback to pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: Nonexistent local element reference with fallback to pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: A link with default cursor
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: Link with default cursor overriding wait
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: Wait cursor which should not be affected by unknown cursor rule
Cursor Info: type=Wait hotSpot=0,0
Cursor Info: type=Wait
PASS successfullyParsed is true
......
......@@ -25,11 +25,11 @@ Cursor Info: type=Custom hotSpot=0,0 image=25x25 scale=1.5
TEST CASE: Invalid tiny scale with fallback to pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: Over-large image with fallback to pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: 200x200 image at 4x (not over-large in UI pixels)
......@@ -71,11 +71,11 @@ Cursor Info: type=Custom hotSpot=0,0 image=30x30 scale=5
TEST CASE: Invalid tiny scale with fallback to pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: Over-large image with fallback to pointer
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
TEST CASE: 200x200 image at 4x (not over-large in UI pixels)
......
......@@ -7,7 +7,7 @@ Bug 100059
TEST CASE: Implicit default cursor
Cursor Info: type=IBeam hotSpot=0,0
Cursor Info: type=IBeam
TEST CASE: CUR file with 3 frames, largest of which (2nd frame) is 20x12 with hotspot at (18,11).
......
......@@ -7,8 +7,8 @@ Bug 85343
TEST CASE: Mouse idle, change cursor should not fire mousemove event
Cursor Info: type=Pointer hotSpot=0,0
Cursor Info: type=Help hotSpot=0,0
Cursor Info: type=Pointer
Cursor Info: type=Help
PASS successfullyParsed is true
......
......@@ -3,18 +3,18 @@ Test that a cursor change that occurs due only to a style change correctly consi
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Mouse moved to cursor changing div
PASS internals.getCurrentCursorInfo() is "type=Hand hotSpot=0,0"
PASS internals.getCurrentCursorInfo() is "type=Hand"
Changing cursor style
PASS internals.getCurrentCursorInfo() is "type=Wait hotSpot=0,0"
PASS internals.getCurrentCursorInfo() is "type=Wait"
Now move mouse onto iframe above cursor changing div
PASS document.elementFromPoint(100, y) is frame
PASS document.elementsFromPoint(100, y).indexOf(container) > 0 is true
PASS internals.cursorUpdatePending is false
PASS internals.getCurrentCursorInfo() is "type=IBeam hotSpot=0,0"
PASS internals.getCurrentCursorInfo() is "type=IBeam"
Changing cursor style of the background should not affect the cursor as it sits over the iframe
PASS internals.getCurrentCursorInfo() is "type=IBeam hotSpot=0,0"
PASS internals.getCurrentCursorInfo() is "type=IBeam"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -46,11 +46,11 @@
frame.onload = function() {
debug('Mouse moved to cursor changing div');
eventSender.mouseMoveTo(100, container.offsetTop + 5);
shouldBeEqualToString('internals.getCurrentCursorInfo()', 'type=Hand hotSpot=0,0');
shouldBeEqualToString('internals.getCurrentCursorInfo()', 'type=Hand');
debug('Changing cursor style');
container.classList.add('wait');
expectCursorUpdate('type=Wait hotSpot=0,0', function() {
expectCursorUpdate('type=Wait', function() {
debug('');
debug('Now move mouse onto iframe above cursor changing div');
......@@ -59,12 +59,12 @@
shouldBe('document.elementFromPoint(100, y)', 'frame');
shouldBeTrue('document.elementsFromPoint(100, y).indexOf(container) > 0');
shouldBeFalse('internals.cursorUpdatePending');
shouldBeEqualToString('internals.getCurrentCursorInfo()', 'type=IBeam hotSpot=0,0');
shouldBeEqualToString('internals.getCurrentCursorInfo()', 'type=IBeam');
debug('');
debug('Changing cursor style of the background should not affect the cursor as it sits over the iframe');
container.classList.remove('wait');
expectCursorUpdate('type=IBeam hotSpot=0,0', function() {
expectCursorUpdate('type=IBeam', function() {
finishJSTest();
});
});
......
This tests that hovering over a TEXTAREA resizer turns the mouse cursor into the SouthEastResize cursor.
Inside TEXTAREA: type=IBeam hotSpot=0,0
Over dragger: type=SouthEastResize hotSpot=0,0
Over BODY: type=Hand hotSpot=0,0
Over dragger: type=SouthEastResize hotSpot=0,0
Inside TEXTAREA: type=IBeam
Over dragger: type=SouthEastResize
Over BODY: type=Hand
Over dragger: type=SouthEastResize
This tests that hovering over a scrollbar resets the mouse cursor to the default pointer.
Hovered pointer: type=Hand hotSpot=0,0
Scrollbar pointer: type=Pointer hotSpot=0,0
Hovered pointer: type=Hand
Scrollbar pointer: type=Pointer
......@@ -56,8 +56,7 @@ function testSetUp(param) {
// Wait for the cursor shape to go back to normal.
await waitFor(() => {
var cursorInfo = internals.getCurrentCursorInfo();
return cursorInfo == "type=Pointer hotSpot=0,0" ||
cursorInfo == "type=IBeam hotSpot=0,0";
return cursorInfo == "type=Pointer" || cursorInfo == "type=IBeam";
});
finishTest();
......
......@@ -42,9 +42,9 @@ window.onload = async () => {
var target = document.getElementById('target');
var rect = target.getBoundingClientRect();
await mouseMoveTo(rect.left + 3, rect.top + 3);
assert_equals(internals.getCurrentCursorInfo(), 'type=IBeam hotSpot=0,0', 'wait for move to target');
assert_equals(internals.getCurrentCursorInfo(), 'type=IBeam', 'wait for move to target');
await mouseClickOn(rect.left + 3, rect.top + 3);
assert_equals(internals.getCurrentCursorInfo(), 'type=Wait hotSpot=0,0', 'wait for mouse cursor change');
assert_equals(internals.getCurrentCursorInfo(), 'type=Wait', 'wait for mouse cursor change');
}, 'Tests that there is mouse cursor update when the element underneath the mouse cursor is changed.');
}
</script>
\ No newline at end of file
</script>
......@@ -15,7 +15,7 @@ test(function() {
eventSender.dragMode = false;
eventSender.mouseMoveTo(10, 10);
var originalInfo = internals.getCurrentCursorInfo();
assert_equals(originalInfo, "type=Pointer hotSpot=0,0");
assert_equals(originalInfo, "type=Pointer");
}
}, 'crbug.com/706324: Middle continuations should inherit the style of their inline parent, so when the cursor is placed over the anonymous block it should remain a pointer.');
</script>
Cursor Info: type=Hand hotSpot=0,0
Cursor Info: type=Hand
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -43,8 +43,7 @@
// Wait for the cursor shape to go back to normal.
await waitFor(() => {
var cursorInfo = internals.getCurrentCursorInfo();
return cursorInfo === "type=Pointer hotSpot=0,0" ||
cursorInfo === "type=IBeam hotSpot=0,0";
return cursorInfo === "type=Pointer" || cursorInfo === "type=IBeam";
});
t.step(() => { assert_greater_than(container.scrollTop, 0 ,
......@@ -58,4 +57,4 @@
<iframe id="target-iframe1"
src="http://localhost:8080/misc/resources/cross-origin-subframe-for-scrolling.html">
</iframe>
</div>
\ No newline at end of file
</div>
......@@ -14,7 +14,7 @@
.pointerMove(20, 20, {origin: portal});
actions.send();
await new Promise(r => portal.onpointermove = r);
assert_equals('type=Hand hotSpot=0,0', internals.getCurrentCursorInfo());
assert_equals('type=Hand', internals.getCurrentCursorInfo());
}, 'test that cursor is updated over portal');
</script>
</body>
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