Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing api.SVGGeometryElement.isPointInFill.point_parameter_DOMPoint feature #21490

Conversation

queengooborg
Copy link
Collaborator

@queengooborg queengooborg commented Dec 6, 2023

This PR is a part of a project to add missing interfaces and interface features to BCD that are from an active spec (including WICG specs) and is supported in at least one browser. This particular PR adds the missing isPointInFill.point_parameter_DOMPoint member of the SVGGeometryElement API. The data comes from manual testing, running test code through BrowserStack, SauceLabs and custom VMs.

Test Code:

<svg
  viewBox="0 0 100 100"
  width="150"
  height="150"
  xmlns="http://www.w3.org/2000/svg">
  <circle
	id="circle"
	cx="50"
	cy="50"
	r="45"
	fill="white"
	stroke="blue"
	stroke-width="10" />
</svg>

<p id="usedSVGPoint"><code>DOMPoint()</code> failed and <code>SVGPoint</code> was used instead.</p>

<script>
	var svg = document.getElementsByTagName("svg")[0];
	var circle = document.getElementById("circle");
	var points = [["10", "10"], ["40", "30"]];

	for (var i = 0; i < points.length; i++) {
		var point = points[i];
		var isPointInFill;
		try {
			var pointObj = new DOMPoint(point[0], point[1]);
			isPointInFill = circle.isPointInFill(pointObj);
		} catch(e) {
			var pointObj = svg.createSVGPoint();
			pointObj.x = point[0];
			pointObj.y = point[1];
			isPointInFill = circle.isPointInFill(pointObj);
			document.getElementById('usedSVGPoint').style.display = 'block';
		}

		console.log(`Point at ${point[0]},${point[1]}: ${isPointInFill}`);

		svg.innerHTML += `<circle cx="${point[0]}" cy="${point[1]}" r="5" fill="${isPointInFill ? "seagreen" : "red"}" />`;
	}
</script>

Fixes #15662.

…oint feature

This PR is a part of a project to add missing interfaces and interface features to BCD that are from an active spec (including WICG specs) and is supported in at least one browser. This particular PR adds the missing `isPointInFill.point_parameter_DOMPoint` member of the `SVGGeometryElement` API. The data comes from manual testing, running test code through BrowserStack, SauceLabs and custom VMs.

Test Code:

```
<svg
  viewBox="0 0 100 100"
  width="150"
  height="150"
  xmlns="http://www.w3.org/2000/svg">
  <circle
	id="circle"
	cx="50"
	cy="50"
	r="45"
	fill="white"
	stroke="blue"
	stroke-width="10" />
</svg>

<p id="usedSVGPoint"><code>DOMPoint()</code> failed and <code>SVGPoint</code> was used instead.</p>

<script>
	var svg = document.getElementsByTagName("svg")[0];
	var circle = document.getElementById("circle");
	var points = [["10", "10"], ["40", "30"]];

	for (var i = 0; i < points.length; i++) {
		var point = points[i];
		var isPointInFill;
		try {
			var pointObj = new DOMPoint(point[0], point[1]);
			isPointInFill = circle.isPointInFill(pointObj);
		} catch(e) {
			var pointObj = svg.createSVGPoint();
			point.x = point[0];
			point.y = point[1];
			isPointInFill = circle.isPointInFill(pointObj);
			document.getElementById('usedSVGPoint').style.display = 'block';
		}

		console.log(`Point at ${point[0]},${point[1]}: ${isPointInFill}`);

		svg.innerHTML += `<circle cx="${point[0]}" cy="${point[1]}" r="5" fill="${isPointInFill ? "seagreen" : "red"}" />`;
	}
</script>
```
@queengooborg queengooborg added the data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API label Dec 6, 2023
@Elchi3 Elchi3 merged commit 13a6281 into mdn:main Dec 12, 2023
5 checks passed
@queengooborg queengooborg deleted the api/SVGGeometryElement/isPointInFill/point_parameter_DOMPoint/additions branch December 12, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with "SVGGeometryElement.isPointInFill()": Not working in chrome
2 participants