Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 122464
Collapse All | Expand All

(-)mozilla/gfx/src/gtk/nsFontMetricsPango.cpp (-13 / +2 lines)
Lines 948-960 nsFontMetricsPango::GetClusterInfo(const Link Here
948
PRInt32
948
PRInt32
949
nsFontMetricsPango::GetPosition(const PRUnichar *aText, PRUint32 aLength,
949
nsFontMetricsPango::GetPosition(const PRUnichar *aText, PRUint32 aLength,
950
                                nsPoint aPt)
950
                                nsPoint aPt)
951
{
951
{
952
    int trailing = 0;
952
    int trailing = 0;
953
    int inx = 0;
953
    int inx = 0;
954
    gboolean found = FALSE;
955
    const gchar *curChar;
954
    const gchar *curChar;
956
    PRInt32 retval = 0;
955
    PRInt32 retval = 0;
957
956
958
    float f = mDeviceContext->AppUnitsToDevUnits();
957
    float f = mDeviceContext->AppUnitsToDevUnits();
959
    
958
    
960
    PangoLayout *layout = pango_layout_new(mPangoContext);
959
    PangoLayout *layout = pango_layout_new(mPangoContext);
Lines 974-1001 nsFontMetricsPango::GetPosition(const PR Link Here
974
    }
973
    }
975
974
976
    // Set up the pango layout
975
    // Set up the pango layout
977
    pango_layout_set_text(layout, text, strlen(text));
976
    pango_layout_set_text(layout, text, strlen(text));
978
    FixupSpaceWidths(layout, text);
977
    FixupSpaceWidths(layout, text);
979
    
978
    
980
    found = pango_layout_xy_to_index(layout, localX, localY,
979
    pango_layout_xy_to_index(layout, localX, localY,
981
                                     &inx, &trailing);
980
                             &inx, &trailing);
982
981
983
    // Convert the index back to the utf-16 index
982
    // Convert the index back to the utf-16 index
984
    curChar = text;
983
    curChar = text;
985
984
986
    // Jump to the end if it's not found.
987
    if (!found) {
988
        if (inx == 0)
989
            retval = 0;
990
        else if (trailing)
991
            retval = aLength;
992
993
        goto loser;
994
    }
995
996
    for (PRUint32 curOffset=0; curOffset < aLength;
985
    for (PRUint32 curOffset=0; curOffset < aLength;
997
         curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
986
         curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
998
987
999
        // Check for a match before checking for a surrogate pair
988
        // Check for a match before checking for a surrogate pair
1000
        if (curChar - text == inx) {
989
        if (curChar - text == inx) {
1001
            retval = curOffset;
990
            retval = curOffset;

Return to bug 122464