Title: [117610] trunk
Revision
117610
Author
[email protected]
Date
2012-05-18 11:42:11 -0700 (Fri, 18 May 2012)

Log Message

Expose FrameSelection::absoluteCaretBounds via window.internals
https://bugs.webkit.org/show_bug.cgi?id=86390

Patch by Shezan Baig <[email protected]> on 2012-05-18
Reviewed by Ryosuke Niwa.

.:

Exports necessary symbols.

* Source/autotools/symbols.filter:

Source/WebCore:

Add 'absoluteCaretBounds' method to Internals, which returns the
FrameSelection::absoluteCaretBounds.

Test: editing/selection/internal-caret-rect.html

* WebCore.exp.in: Export the necessary symbols.
* testing/Internals.cpp:
(WebCore::Internals::absoluteCaretBounds): Implementation of new method.
(WebCore):
* testing/Internals.h: Declare the new method.
(Internals):
* testing/Internals.idl: Declare the new method.

Source/WebKit2:

Exports necessary symbols.

* win/WebKit2.def:
* win/WebKit2CFLite.def:

LayoutTests:

A simple test case for the new 'absoluteCaretBounds' method.

* editing/selection/internal-caret-rect-expected.txt: Added.
* editing/selection/internal-caret-rect.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (117609 => 117610)


--- trunk/ChangeLog	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/ChangeLog	2012-05-18 18:42:11 UTC (rev 117610)
@@ -1,3 +1,14 @@
+2012-05-18  Shezan Baig  <[email protected]>
+
+        Expose FrameSelection::absoluteCaretBounds via window.internals
+        https://bugs.webkit.org/show_bug.cgi?id=86390
+
+        Reviewed by Ryosuke Niwa.
+
+        Exports necessary symbols.
+
+        * Source/autotools/symbols.filter:
+
 2012-05-18  Martin Robinson  <[email protected]>
 
         Get IndexedDB closer to building for GTK+.

Modified: trunk/LayoutTests/ChangeLog (117609 => 117610)


--- trunk/LayoutTests/ChangeLog	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/LayoutTests/ChangeLog	2012-05-18 18:42:11 UTC (rev 117610)
@@ -1,3 +1,15 @@
+2012-05-18  Shezan Baig  <[email protected]>
+
+        Expose FrameSelection::absoluteCaretBounds via window.internals
+        https://bugs.webkit.org/show_bug.cgi?id=86390
+
+        Reviewed by Ryosuke Niwa.
+
+        A simple test case for the new 'absoluteCaretBounds' method.
+
+        * editing/selection/internal-caret-rect-expected.txt: Added.
+        * editing/selection/internal-caret-rect.html: Added.
+
 2012-05-18  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening, adding test expectations for a few tests

Added: trunk/LayoutTests/editing/selection/internal-caret-rect-expected.txt (0 => 117610)


--- trunk/LayoutTests/editing/selection/internal-caret-rect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/internal-caret-rect-expected.txt	2012-05-18 18:42:11 UTC (rev 117610)
@@ -0,0 +1,29 @@
+Bug 86390: Expose FrameSelection::absoluteCaretBounds via window.internals
+
+This test demonstrates the usage of window.internals.absoluteCaretBounds()
+
+abcd
+PASS caretRects[0].left is 8
+PASS caretRects[0].top is 160
+PASS caretRects[0].width is 1
+PASS caretRects[0].height is 20
+PASS caretRects[1].left is 28
+PASS caretRects[1].top is 160
+PASS caretRects[1].width is 1
+PASS caretRects[1].height is 20
+PASS caretRects[2].left is 48
+PASS caretRects[2].top is 160
+PASS caretRects[2].width is 1
+PASS caretRects[2].height is 20
+PASS caretRects[3].left is 68
+PASS caretRects[3].top is 160
+PASS caretRects[3].width is 1
+PASS caretRects[3].height is 20
+PASS caretRects[4].left is 88
+PASS caretRects[4].top is 160
+PASS caretRects[4].width is 1
+PASS caretRects[4].height is 20
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/selection/internal-caret-rect.html (0 => 117610)


--- trunk/LayoutTests/editing/selection/internal-caret-rect.html	                        (rev 0)
+++ trunk/LayoutTests/editing/selection/internal-caret-rect.html	2012-05-18 18:42:11 UTC (rev 117610)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="" type="text/_javascript_"></script>
+<style>
+    body {
+        font: 20px Ahem;
+    }
+</style>
+</head>
+<body>
+<p> Bug <a href="" Expose FrameSelection::absoluteCaretBounds via window.internals</p>
+<p>This test demonstrates the usage of window.internals.absoluteCaretBounds()</p>
+<div id="testDiv" CONTENTEDITABLE>abcd</div>
+<div id="console"></div>
+</body>
+<script>
+    var caretRects = [];
+    function verifyCaretRect(left, top, width, height)
+    {
+        if (window.internals) {
+            var index = caretRects.length;
+            caretRects.push(internals.absoluteCaretBounds(document));
+            shouldBe("caretRects[" + index + "].left", left.toString());
+            shouldBe("caretRects[" + index + "].top", top.toString());
+            shouldBe("caretRects[" + index + "].width", width.toString());
+            shouldBe("caretRects[" + index + "].height", height.toString());
+        }
+    }
+
+    var textNode = document.getElementById("testDiv").firstChild;
+    getSelection().collapse(textNode, 0);  // before a
+    verifyCaretRect(8, 160, 1, 20);
+    getSelection().collapse(textNode, 1);  // after a
+    verifyCaretRect(28, 160, 1, 20);
+    getSelection().collapse(textNode, 2);  // after b
+    verifyCaretRect(48, 160, 1, 20);
+    getSelection().collapse(textNode, 3);  // after c
+    verifyCaretRect(68, 160, 1, 20);
+    getSelection().collapse(textNode, 4);  // after d
+    verifyCaretRect(88, 160, 1, 20);
+</script>
+<script src="" type="text/_javascript_"></script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (117609 => 117610)


--- trunk/Source/WebCore/ChangeLog	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/WebCore/ChangeLog	2012-05-18 18:42:11 UTC (rev 117610)
@@ -1,3 +1,23 @@
+2012-05-18  Shezan Baig  <[email protected]>
+
+        Expose FrameSelection::absoluteCaretBounds via window.internals
+        https://bugs.webkit.org/show_bug.cgi?id=86390
+
+        Reviewed by Ryosuke Niwa.
+
+        Add 'absoluteCaretBounds' method to Internals, which returns the
+        FrameSelection::absoluteCaretBounds.
+
+        Test: editing/selection/internal-caret-rect.html
+
+        * WebCore.exp.in: Export the necessary symbols.
+        * testing/Internals.cpp:
+        (WebCore::Internals::absoluteCaretBounds): Implementation of new method.
+        (WebCore):
+        * testing/Internals.h: Declare the new method.
+        (Internals):
+        * testing/Internals.idl: Declare the new method.
+
 2012-05-18  Dan Bernstein  <[email protected]>
 
         <rdar://problem/11467250> No focus ring around popup buttons

Modified: trunk/Source/WebCore/WebCore.exp.in (117609 => 117610)


--- trunk/Source/WebCore/WebCore.exp.in	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-05-18 18:42:11 UTC (rev 117610)
@@ -345,6 +345,7 @@
 __ZN7WebCore14FrameSelection12setSelectionERKNS_16VisibleSelectionEjNS0_19CursorAlignOnScrollENS_15TextGranularityE
 __ZN7WebCore14FrameSelection15revealSelectionERKNS_15ScrollAlignmentEb
 __ZN7WebCore14FrameSelection16setSelectedRangeEPNS_5RangeENS_9EAffinityEb
+__ZN7WebCore14FrameSelection19absoluteCaretBoundsEv
 __ZN7WebCore14FrameSelection20setSelectionFromNoneEv
 __ZN7WebCore14FrameSelection5clearEv
 __ZN7WebCore14FrameSelection6modifyENS0_11EAlterationENS_18SelectionDirectionENS_15TextGranularityENS_14EUserTriggeredE

Modified: trunk/Source/WebCore/testing/Internals.cpp (117609 => 117610)


--- trunk/Source/WebCore/testing/Internals.cpp	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/WebCore/testing/Internals.cpp	2012-05-18 18:42:11 UTC (rev 117610)
@@ -399,6 +399,16 @@
 }
 #endif
 
+PassRefPtr<ClientRect> Internals::absoluteCaretBounds(Document* document, ExceptionCode& ec)
+{
+    if (!document || !document->frame() || !document->frame()->selection()) {
+        ec = INVALID_ACCESS_ERR;
+        return ClientRect::create();
+    }
+
+    return ClientRect::create(document->frame()->selection()->absoluteCaretBounds());
+}
+
 PassRefPtr<ClientRect> Internals::boundingBox(Element* element, ExceptionCode& ec)
 {
     if (!element) {

Modified: trunk/Source/WebCore/testing/Internals.h (117609 => 117610)


--- trunk/Source/WebCore/testing/Internals.h	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/WebCore/testing/Internals.h	2012-05-18 18:42:11 UTC (rev 117610)
@@ -96,6 +96,8 @@
     void selectColorInColorChooser(Element*, const String& colorValue);
 #endif
 
+    PassRefPtr<ClientRect> absoluteCaretBounds(Document*, ExceptionCode&);
+
     PassRefPtr<ClientRect> boundingBox(Element*, ExceptionCode&);
 
     PassRefPtr<ClientRectList> inspectorHighlightRects(Document*, ExceptionCode&);

Modified: trunk/Source/WebCore/testing/Internals.idl (117609 => 117610)


--- trunk/Source/WebCore/testing/Internals.idl	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/WebCore/testing/Internals.idl	2012-05-18 18:42:11 UTC (rev 117610)
@@ -68,6 +68,8 @@
         void selectColorInColorChooser(in Element element, in DOMString colorValue);
 #endif
 
+        ClientRect absoluteCaretBounds(in Document document) raises(DOMException);
+
         ClientRect boundingBox(in Element element) raises(DOMException);
 
         ClientRectList inspectorHighlightRects(in Document document) raises (DOMException);

Modified: trunk/Source/WebKit2/ChangeLog (117609 => 117610)


--- trunk/Source/WebKit2/ChangeLog	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/WebKit2/ChangeLog	2012-05-18 18:42:11 UTC (rev 117610)
@@ -1,3 +1,15 @@
+2012-05-18  Shezan Baig  <[email protected]>
+
+        Expose FrameSelection::absoluteCaretBounds via window.internals
+        https://bugs.webkit.org/show_bug.cgi?id=86390
+
+        Reviewed by Ryosuke Niwa.
+
+        Exports necessary symbols.
+
+        * win/WebKit2.def:
+        * win/WebKit2CFLite.def:
+
 2012-05-18  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Allow to attach/detach the inspector in WebKit2

Modified: trunk/Source/WebKit2/win/WebKit2.def (117609 => 117610)


--- trunk/Source/WebKit2/win/WebKit2.def	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/WebKit2/win/WebKit2.def	2012-05-18 18:42:11 UTC (rev 117610)
@@ -172,6 +172,7 @@
         ?find@StringImpl@WTF@@QAEIPAV12@I@Z
         ?find@StringImpl@WTF@@QAEIPAV12@@Z
         ?frameDestroyed@FrameDestructionObserver@WebCore@@UAEXXZ
+        ?absoluteCaretBounds@FrameSelection@WebCore@@QAE?AVIntRect@2@XZ
         ?fromUTF8WithLatin1Fallback@String@WTF@@SA?AV12@PBEI@Z
         ?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z
         ?getData16SlowCase@StringImpl@WTF@@ABEPB_WXZ

Modified: trunk/Source/WebKit2/win/WebKit2CFLite.def (117609 => 117610)


--- trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/WebKit2/win/WebKit2CFLite.def	2012-05-18 18:42:11 UTC (rev 117610)
@@ -165,6 +165,7 @@
         ?find@StringImpl@WTF@@QAEIPAV12@I@Z
         ?find@StringImpl@WTF@@QAEIPAV12@@Z
         ?frameDestroyed@FrameDestructionObserver@WebCore@@UAEXXZ
+        ?absoluteCaretBounds@FrameSelection@WebCore@@QAE?AVIntRect@2@XZ
         ?fromUTF8WithLatin1Fallback@String@WTF@@SA?AV12@PBEI@Z
         ?getCachedDOMStructure@WebCore@@YAPAVStructure@JSC@@PAVJSDOMGlobalObject@1@PBUClassInfo@3@@Z
         ?getData16SlowCase@StringImpl@WTF@@ABEPB_WXZ

Modified: trunk/Source/autotools/symbols.filter (117609 => 117610)


--- trunk/Source/autotools/symbols.filter	2012-05-18 18:33:30 UTC (rev 117609)
+++ trunk/Source/autotools/symbols.filter	2012-05-18 18:42:11 UTC (rev 117610)
@@ -53,6 +53,7 @@
 _ZN7WebCore14ClientRectListC1ERKN3WTF6VectorINS_9FloatQuadELm0EEE;
 _ZN7WebCore14ClientRectListC1Ev;
 _ZN7WebCore14ClientRectListD1Ev;
+_ZN7WebCore14FrameSelection19absoluteCaretBoundsEv;
 _ZN7WebCore15setDOMExceptionEPN3JSC9ExecStateEi;
 _ZN7WebCore16HTMLInputElement17setSuggestedValueERKN3WTF6StringE;
 _ZN7WebCore16HTMLInputElement15setEditingValueERKN3WTF6StringE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to