예제 #1
0
// Change plain CR and plain LF to CRLF pairs.
static DeprecatedCString fixLineBreaks(const DeprecatedCString &s)
{
    // Compute the length.
    unsigned newLen = 0;
    const char *p = s.data();
    while (char c = *p++) {
        if (c == '\r') {
            // Safe to look ahead because of trailing '\0'.
            if (*p != '\n') {
                // Turn CR into CRLF.
                newLen += 2;
            }
        } else if (c == '\n') {
            // Turn LF into CRLF.
            newLen += 2;
        } else {
            // Leave other characters alone.
            newLen += 1;
        }
    }
    if (newLen == s.length()) {
        return s;
    }
    
    // Make a copy of the string.
    p = s.data();
    DeprecatedCString result(newLen + 1);
    char *q = result.data();
    while (char c = *p++) {
        if (c == '\r') {
            // Safe to look ahead because of trailing '\0'.
            if (*p != '\n') {
                // Turn CR into CRLF.
                *q++ = '\r';
                *q++ = '\n';
            }
        } else if (c == '\n') {
            // Turn LF into CRLF.
            *q++ = '\r';
            *q++ = '\n';
        } else {
            // Leave other characters alone.
            *q++ = c;
        }
    }
    return result;
}
예제 #2
0
DeprecatedCString DeprecatedCString::upper() const
{
    DeprecatedCString tmp = *this;       // copy
    char* str = tmp.data();
    if( str )
    {
        while( *str != 0 )
        {
            *str = toupper(*str);
            str++;
        }
    }

    return tmp;
}
예제 #3
0
void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags)
{
	iSeeLogA("ChromeClient::mouseDidMoveOverElement()\n");
	// check if the element is a link...
	bool isLink = hit.isLiveLink();
	if (isLink) {
#if 0
		KURL url = hit.absoluteLinkURL();
		if (!url.isEmpty() && url != m_hoveredLinkURL) {
			CString titleString = hit.title().utf8();
			DeprecatedCString urlString = url.prettyURL().utf8();
			g_signal_emit_by_name(m_webView, "hovering-over-link", titleString.data(), urlString.data());
			m_hoveredLinkURL = url;
		}
#endif
	} else if (!isLink && !m_hoveredLinkURL.isEmpty()) {
#if 0
		g_signal_emit_by_name(m_webView, "hovering-over-link", 0, 0);
		m_hoveredLinkURL = KURL();
#endif
	}
}