[Webkit-unassigned] [Bug 15999] New: Use differenceSquared() to detect similar fg/bg text selection colours

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Nov 15 03:34:08 PST 2007


           Summary: Use differenceSquared() to detect similar fg/bg text
                    selection colours
           Product: WebKit
           Version: 525+ (Nightly build)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Minor
          Priority: P2
         Component: Text
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: alp at atoker.com

It would be nice to use correctedTextColor() or a similar differenceSquared()
algorithm to identify and avoid situations where the text selection foreground
colour is similar to the selection background colour.

This situation is more likely to arise in the GTK+ port when users are using a
high contrast/inverted video accessibility colour scheme. It is also more
likely to arise if text selection opacity is disabled in a port for whatever
reason, say due to limited graphics capabilities.

This feature could be implemented in InlineTextBox and SVGInlineTextBox, or
possibly directly in RenderObject. (It seems right now there's code that could
be shared between InlineTextBox and SVGInlineTextBox to avoid implementing this
in two places.)

correctedTextColor() is already used in InlineTextBox to ensure that text is
legible when printed, so the necessary clever bits have already been written.

There is actually already simple support for inverting the text selection
background colour:

    Color textColor = style->color();
    Color c = object()->selectionBackgroundColor();
    if (!c.isValid() || c.alpha() == 0)

    if (textColor == c)
        c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());

I'm a bit suspicious that this code is not doing the right thing.

I wonder also if it should be:

    -Color textColor = style->color();
    +Color textColor = object()->selectionForegroundColor();

Is there a text selection/text legibility test suite? I'm not too familiar with
the tests yet.

Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

More information about the webkit-unassigned mailing list