[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 12:49:26 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 81ef173d204dcff986304c92de4ccc2a5fdb3190
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 31 05:05:40 2010 +0000

    2010-08-30  Kamil Blank  <k.blank at samsung.com>
    
            Reviewed by Adam Barth.
    
            [EFL] Added API which returns position of n-th text matches mark
            https://bugs.webkit.org/show_bug.cgi?id=44258
    
            * ewk/ewk_frame.cpp:
            (_ewk_frame_rect_cmp_less_than): Private.
            (_ewk_frame_rect_is_negative_value): Private.
            (ewk_frame_text_matches_nth_pos_get): Added. Function returns position of
            n-th text match in frame.
            * ewk/ewk_frame.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66454 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/efl/ChangeLog b/WebKit/efl/ChangeLog
index 5c62d84..8399ce9 100644
--- a/WebKit/efl/ChangeLog
+++ b/WebKit/efl/ChangeLog
@@ -1,3 +1,17 @@
+2010-08-30  Kamil Blank  <k.blank at samsung.com>
+
+        Reviewed by Adam Barth.
+
+        [EFL] Added API which returns position of n-th text matches mark
+        https://bugs.webkit.org/show_bug.cgi?id=44258
+
+        * ewk/ewk_frame.cpp: 
+        (_ewk_frame_rect_cmp_less_than): Private.
+        (_ewk_frame_rect_is_negative_value): Private.
+        (ewk_frame_text_matches_nth_pos_get): Added. Function returns position of
+        n-th text match in frame.
+        * ewk/ewk_frame.h:
+
 2010-08-30  Ryuan Choi  <ryuan.choi at samsung.com>
 
         Reviewed by Adam Barth.
diff --git a/WebKit/efl/ewk/ewk_frame.cpp b/WebKit/efl/ewk/ewk_frame.cpp
index 5275bf3..539c500 100644
--- a/WebKit/efl/ewk/ewk_frame.cpp
+++ b/WebKit/efl/ewk/ewk_frame.cpp
@@ -44,14 +44,15 @@
 #include "ScriptValue.h"
 #include "SharedBuffer.h"
 #include "SubstituteData.h"
-#include "ZoomMode.h"
 #include "WindowsKeyboardCodes.h"
+#include "ZoomMode.h"
 #include "ewk_private.h"
-#include <wtf/text/CString.h>
 
 #include <Eina.h>
 #include <Evas.h>
+#include <algorithm>
 #include <eina_safety_checks.h>
+#include <wtf/text/CString.h>
 
 static const char EWK_FRAME_TYPE_STR[] = "EWK_Frame";
 
@@ -820,6 +821,55 @@ Eina_Bool ewk_frame_text_matches_highlight_get(const Evas_Object* o)
     return sd->frame->markedTextMatchesAreHighlighted();
 }
 
+/** 
+ * Comparison function used by ewk_frame_text_matches_nth_pos_get
+ */
+static bool _ewk_frame_rect_cmp_less_than(const WebCore::IntRect& i, const WebCore::IntRect& j)
+{
+    return (i.y() < j.y() || (i.y() == j.y() && i.x() < j.x()));
+}   
+    
+/**
+ * Predicate used by ewk_frame_text_matches_nth_pos_get
+ */
+static bool _ewk_frame_rect_is_negative_value(const WebCore::IntRect& i)
+{
+    return (i.x() < 0 || i.y() < 0);
+}
+
+/**
+ * Get x, y position of n-th text match in frame
+ *
+ * @param o frame object where matches are highlighted.
+ * @param n index of element 
+ * @param x where to return x position. May be @c NULL. 
+ * @param y where to return y position. May be @c NULL.
+ *
+ * @return @c EINA_TRUE on success, @c EINA_FALSE for failure - when no matches found or 
+ *         n bigger than search results.
+ */
+Eina_Bool ewk_frame_text_matches_nth_pos_get(Evas_Object* o, int n, int* x, int* y)
+{
+    EWK_FRAME_SD_GET_OR_RETURN(o, sd, EINA_FALSE);
+    EINA_SAFETY_ON_NULL_RETURN_VAL(sd->frame, EINA_FALSE);
+
+    Vector<WebCore::IntRect> intRects = sd->frame->document()->markers()->firstRectsForMarkers(WebCore::DocumentMarker::TextMatch);
+
+    /* remove useless values */
+    std::remove_if(intRects.begin(), intRects.end(), _ewk_frame_rect_is_negative_value);
+
+    if (intRects.isEmpty() || n > intRects.size())
+      return EINA_FALSE;
+
+    std::sort(intRects.begin(), intRects.end(), _ewk_frame_rect_cmp_less_than);
+
+    if (x)
+      *x = intRects[n - 1].x();
+    if (y)
+      *y = intRects[n - 1].y();
+    return EINA_TRUE;
+}
+
 /**
  * Ask frame to stop loading.
  *
diff --git a/WebKit/efl/ewk/ewk_frame.h b/WebKit/efl/ewk/ewk_frame.h
index 1a9fe81..9394446 100644
--- a/WebKit/efl/ewk/ewk_frame.h
+++ b/WebKit/efl/ewk/ewk_frame.h
@@ -160,6 +160,7 @@ EAPI unsigned int ewk_frame_text_matches_mark(Evas_Object *o, const char *string
 EAPI Eina_Bool    ewk_frame_text_matches_unmark_all(Evas_Object *o);
 EAPI Eina_Bool    ewk_frame_text_matches_highlight_set(Evas_Object *o, Eina_Bool highlight);
 EAPI Eina_Bool    ewk_frame_text_matches_highlight_get(const Evas_Object *o);
+EAPI Eina_Bool    ewk_frame_text_matches_nth_pos_get(Evas_Object *o, int n, int *x, int *y);
 
 EAPI Eina_Bool    ewk_frame_stop(Evas_Object *o);
 EAPI Eina_Bool    ewk_frame_reload(Evas_Object *o);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list