Title: [231266] trunk
Revision
231266
Author
[email protected]
Date
2018-05-02 14:38:53 -0700 (Wed, 02 May 2018)

Log Message

getCharNumAtPosition should take DOMPointInit as argument
https://bugs.webkit.org/show_bug.cgi?id=184695

Patch by Dirk Schulze <[email protected]> on 2018-05-02
Reviewed by Antti Koivisto.

Source/WebCore:

Extend existing tests for getCharNumAtPosition.

* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::getCharNumAtPosition):
* svg/SVGTextContentElement.h:
* svg/SVGTextContentElement.idl: Use DOMPointInit argument.

LayoutTests:

* svg/text/lengthAdjust-text-metrics.html: Run tests with dictionary.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231265 => 231266)


--- trunk/LayoutTests/ChangeLog	2018-05-02 21:38:04 UTC (rev 231265)
+++ trunk/LayoutTests/ChangeLog	2018-05-02 21:38:53 UTC (rev 231266)
@@ -1,3 +1,12 @@
+2018-05-02  Dirk Schulze  <[email protected]>
+
+        getCharNumAtPosition should take DOMPointInit as argument
+        https://bugs.webkit.org/show_bug.cgi?id=184695
+
+        Reviewed by Antti Koivisto.
+
+        * svg/text/lengthAdjust-text-metrics.html: Run tests with dictionary.
+
 2018-05-02  Youenn Fablet  <[email protected]>
 
         Use NetworkLoadChecker for navigation loads

Modified: trunk/LayoutTests/svg/text/lengthAdjust-text-metrics-expected.txt (231265 => 231266)


--- trunk/LayoutTests/svg/text/lengthAdjust-text-metrics-expected.txt	2018-05-02 21:38:04 UTC (rev 231265)
+++ trunk/LayoutTests/svg/text/lengthAdjust-text-metrics-expected.txt	2018-05-02 21:38:53 UTC (rev 231266)
@@ -52,10 +52,13 @@
 Test getCharNumAtPosition() API
 > Testing point=(0.0,10.0)
 PASS svgText.getCharNumAtPosition(point) is -1
+PASS svgText.getCharNumAtPosition(pointDict) is -1
 > Testing point=(9.9,10.0)
 PASS svgText.getCharNumAtPosition(point) is -1
+PASS svgText.getCharNumAtPosition(pointDict) is -1
 > Testing point=(10.1,10.0)
 PASS svgText.getCharNumAtPosition(point) is 0
+PASS svgText.getCharNumAtPosition(pointDict) is 0
 > Testing point=(71.4,10.0)
 PASS svgText.getCharNumAtPosition(point) is 0
 > Testing point=(71.6,10.0)
@@ -62,10 +65,12 @@
 PASS svgText.getCharNumAtPosition(point) is 0
 > Testing point=(127.8,10.0)
 PASS svgText.getCharNumAtPosition(point) is 1
+PASS svgText.getCharNumAtPosition(pointDict) is 1
 > Testing point=(128.0,10.0)
 PASS svgText.getCharNumAtPosition(point) is 1
 > Testing point=(179.1,10.0)
 PASS svgText.getCharNumAtPosition(point) is 3
+PASS svgText.getCharNumAtPosition(pointDict) is 3
 > Testing point=(179.3,10.0)
 PASS svgText.getCharNumAtPosition(point) is 3
 > Testing point=(209.9,10.0)

Modified: trunk/LayoutTests/svg/text/lengthAdjust-text-metrics.html (231265 => 231266)


--- trunk/LayoutTests/svg/text/lengthAdjust-text-metrics.html	2018-05-02 21:38:04 UTC (rev 231265)
+++ trunk/LayoutTests/svg/text/lengthAdjust-text-metrics.html	2018-05-02 21:38:53 UTC (rev 231266)
@@ -131,6 +131,7 @@
 shouldBeEqualToString("svgText.getRotationOfChar(3).toFixed(1)", "0.0");
 
 var point = svgRoot.createSVGPoint();
+var pointDict;
 point.y = 10.0;
 
 debug("");
@@ -140,16 +141,22 @@
 point = point.matrixTransform(inverseScaleMatrix);
 debug("> Testing point=" + pointToString(point));
 shouldBe("svgText.getCharNumAtPosition(point)", "-1");
+pointDict = {x: point.x, y: point.y};
+shouldBe("svgText.getCharNumAtPosition(pointDict)", "-1");
 
 point.x = 9.9;
 point = point.matrixTransform(inverseScaleMatrix);
 debug("> Testing point=" + pointToString(point));
 shouldBe("svgText.getCharNumAtPosition(point)", "-1");
+pointDict = {x: point.x, y: point.y};
+shouldBe("svgText.getCharNumAtPosition(pointDict)", "-1");
 
 point.x = 10.1;
 point = point.matrixTransform(inverseScaleMatrix);
 debug("> Testing point=" + pointToString(point));
 shouldBe("svgText.getCharNumAtPosition(point)", "0");
+pointDict = {x: point.x, y: point.y};
+shouldBe("svgText.getCharNumAtPosition(pointDict)", "0");
 
 point.x = 71.4;
 point = point.matrixTransform(inverseScaleMatrix);
@@ -165,6 +172,8 @@
 point = point.matrixTransform(inverseScaleMatrix);
 debug("> Testing point=" + pointToString(point));
 shouldBe("svgText.getCharNumAtPosition(point)", "1");
+pointDict = {x: point.x, y: point.y};
+shouldBe("svgText.getCharNumAtPosition(pointDict)", "1");
 
 point.x = 128.0;
 point = point.matrixTransform(inverseScaleMatrix);
@@ -175,6 +184,8 @@
 point = point.matrixTransform(inverseScaleMatrix);
 debug("> Testing point=" + pointToString(point));
 shouldBe("svgText.getCharNumAtPosition(point)", "3");
+pointDict = {x: point.x, y: point.y};
+shouldBe("svgText.getCharNumAtPosition(pointDict)", "3");
 
 point.x = 179.3;
 point = point.matrixTransform(inverseScaleMatrix);

Modified: trunk/Source/WebCore/ChangeLog (231265 => 231266)


--- trunk/Source/WebCore/ChangeLog	2018-05-02 21:38:04 UTC (rev 231265)
+++ trunk/Source/WebCore/ChangeLog	2018-05-02 21:38:53 UTC (rev 231266)
@@ -1,3 +1,17 @@
+2018-05-02  Dirk Schulze  <[email protected]>
+
+        getCharNumAtPosition should take DOMPointInit as argument
+        https://bugs.webkit.org/show_bug.cgi?id=184695
+
+        Reviewed by Antti Koivisto.
+
+        Extend existing tests for getCharNumAtPosition.
+
+        * svg/SVGTextContentElement.cpp:
+        (WebCore::SVGTextContentElement::getCharNumAtPosition):
+        * svg/SVGTextContentElement.h:
+        * svg/SVGTextContentElement.idl: Use DOMPointInit argument.
+
 2018-05-02  Youenn Fablet  <[email protected]>
 
         Use NetworkLoadChecker for navigation loads

Modified: trunk/Source/WebCore/svg/SVGTextContentElement.cpp (231265 => 231266)


--- trunk/Source/WebCore/svg/SVGTextContentElement.cpp	2018-05-02 21:38:04 UTC (rev 231265)
+++ trunk/Source/WebCore/svg/SVGTextContentElement.cpp	2018-05-02 21:38:53 UTC (rev 231266)
@@ -23,6 +23,7 @@
 
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
+#include "DOMPoint.h"
 #include "Frame.h"
 #include "FrameSelection.h"
 #include "RenderObject.h"
@@ -158,10 +159,11 @@
     return SVGTextQuery(renderer()).rotationOfCharacter(charnum);
 }
 
-int SVGTextContentElement::getCharNumAtPosition(SVGPoint& point)
+int SVGTextContentElement::getCharNumAtPosition(DOMPointInit&& pointInit)
 {
     document().updateLayoutIgnorePendingStylesheets();
-    return SVGTextQuery(renderer()).characterNumberAtPosition(point.propertyReference());
+    FloatPoint transformPoint {static_cast<float>(pointInit.x), static_cast<float>(pointInit.y)};
+    return SVGTextQuery(renderer()).characterNumberAtPosition(transformPoint);
 }
 
 ExceptionOr<void> SVGTextContentElement::selectSubString(unsigned charnum, unsigned nchars)

Modified: trunk/Source/WebCore/svg/SVGTextContentElement.h (231265 => 231266)


--- trunk/Source/WebCore/svg/SVGTextContentElement.h	2018-05-02 21:38:04 UTC (rev 231265)
+++ trunk/Source/WebCore/svg/SVGTextContentElement.h	2018-05-02 21:38:53 UTC (rev 231266)
@@ -28,6 +28,8 @@
 
 namespace WebCore {
 
+struct DOMPointInit;
+
 enum SVGLengthAdjustType {
     SVGLengthAdjustUnknown,
     SVGLengthAdjustSpacing,
@@ -78,7 +80,7 @@
     ExceptionOr<Ref<SVGPoint>> getEndPositionOfChar(unsigned charnum);
     ExceptionOr<Ref<SVGRect>> getExtentOfChar(unsigned charnum);
     ExceptionOr<float> getRotationOfChar(unsigned charnum);
-    int getCharNumAtPosition(SVGPoint&);
+    int getCharNumAtPosition(DOMPointInit&&);
     ExceptionOr<void> selectSubString(unsigned charnum, unsigned nchars);
 
     static SVGTextContentElement* elementFromRenderer(RenderObject*);

Modified: trunk/Source/WebCore/svg/SVGTextContentElement.idl (231265 => 231266)


--- trunk/Source/WebCore/svg/SVGTextContentElement.idl	2018-05-02 21:38:04 UTC (rev 231265)
+++ trunk/Source/WebCore/svg/SVGTextContentElement.idl	2018-05-02 21:38:53 UTC (rev 231266)
@@ -39,7 +39,7 @@
     [MayThrowException, NewObject] SVGPoint getEndPositionOfChar(optional unsigned long offset = 0);
     [MayThrowException, NewObject] SVGRect getExtentOfChar(optional unsigned long offset = 0);
     [MayThrowException] unrestricted float getRotationOfChar(optional unsigned long offset = 0);
-    long getCharNumAtPosition(SVGPoint point);
+    long getCharNumAtPosition(DOMPointInit point);
     [MayThrowException] void selectSubString(optional unsigned long offset = 0, optional unsigned long length = 0);
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to