[Webkit-unassigned] [Bug 74775] New: WebKit editing throws exception when monochrome color dragged onto text

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Dec 16 18:12:17 PST 2011


           Summary: WebKit editing throws exception when monochrome color
                    dragged onto text
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Macintosh Intel
        OS/Version: Mac OS X 10.7
            Status: UNCONFIRMED
          Severity: Major
          Priority: P2
         Component: HTML Editing
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: jalkut at red-sweater.com

Note: this was reproduced with WebKit nightly as of two days ago. 

In any app that supports WebKit editing, if a color is dragged onto text, typically the dragged color is interpreted to mean that the text should be changed to that color.

If the color being dragged happens to be monochrome, e.g. of the NSCalibratedWhiteColorSpace, then WebKit throws an exception because it fails to get the expected RGB components from the dragged color.

This is an issue for any WebKit editing app that allows users to display a standard color panel, and then to drag a color swatch onto the edited text. It's an especially heinous issues in apps, like my own, that treat uncaught exceptions as crash-worthy events ;)

To reproduce in Safari or WebKit nightly:

1. Open the Snippet editor.
2. Enter this HTML content:

<div contentEditable="true">Hello - try dragging a black/white colorspace color to me.</div>

3. Select the editable section in the rendering pane of the snippet editor.
4. From another app, e.g. TextEdit, open the standard Color panel.
5. Switch to the "Sliders" color panel pane, and choose "Gray Scale Slider" from the popup. 
6. Drag whatever color you have selected from the large color preview rectangle next to the magnifying glass, while cmd-tabbing back to Safari to your snippet content.
7. Drag it to the text and release.

Result: nothing happens, and Safari logs to the console:

2011-12-16 21:04:10.792 Safari[40273:1d07] *** Canceling drag because exception 'NSInvalidArgumentException' (reason '*** -redComponent not valid for the NSColor NSCalibratedWhiteColorSpace 0.375912 1; need to first convert colorspace.') was raised during a dragging session

More typically, in an app that supports the Color panel natively, the exception is thrown with a full backtrace. For example, I interrupted Safari with gdb and called:

call (void) [[NSColorPanel sharedColorPanel] makeKeyAndOrderFront:nil]

Then I dragged a color to the text and received this in gdb:

2011-12-16 21:02:39.357 Safari[40273:1d07] *** -redComponent not valid for the NSColor NSCalibratedWhiteColorSpace 0.754032 1; need to first convert colorspace.
2011-12-16 21:02:39.367 Safari[40273:1d07] (
    0   CoreFoundation                      0x00007fff8b04b286 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8f80dd5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8b04b0ba +[NSException raise:format:arguments:] + 106
    3   CoreFoundation                      0x00007fff8b04b044 +[NSException raise:format:] + 116
    4   AppKit                              0x00007fff8dfbd46c -[NSColor redComponent] + 65
    5   WebCore                             0x0000000100c427a7 _ZNK7WebCore8DragData7asColorEv + 55
    6   WebCore                             0x0000000100c3efcc _ZN7WebCore14DragController16concludeEditDragEPNS_8DragDataE + 236
    7   WebCore                             0x0000000100c3ed01 _ZN7WebCore14DragController11performDragEPNS_8DragDataE + 593
    8   WebKit                              0x00000001003963a7 -[WebView performDragOperation:] + 199
    9   AppKit                              0x00007fff8e05cc6a NSCoreDragReceiveMessageProc + 1462
    10  HIServices                          0x00007fff86fe760f CallReceiveMessageCollectionWithMessage + 70
    11  HIServices                          0x00007fff86fe7714 DoMultipartDropMessage + 126
    12  HIServices                          0x00007fff86fe791d DoDropMessage + 55
    13  HIServices                          0x00007fff86fe7df5 SendDropMessage + 39
    14  HIServices                          0x00007fff86feab08 DragInApplication + 717
    15  HIServices                          0x00007fff86feadaa CoreDragStartDragging + 517
    16  AppKit                              0x00007fff8e05ab4c -[NSCoreDragManager _dragUntilMouseUp:accepted:] + 885
    17  AppKit                              0x00007fff8e05a218 -[NSCoreDragManager dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:] + 1455
    18  AppKit                              0x00007fff8e34ed86 -[NSWindow(NSDrag) dragImage:at:offset:event:pasteboard:source:slideBack:] + 132
    19  AppKit                              0x00007fff8dfd1260 +[NSColorPanel dragColor:withEvent:fromView:] + 785
    20  AppKit                              0x00007fff8dfcc80e -[NSColorSwatch mouseDown:] + 547
    21  AppKit                              0x00007fff8dd520e0 -[NSWindow sendEvent:] + 6306
    22  AppKit                              0x00007fff8dcea68f -[NSApplication sendEvent:] + 5593
    23  Safari                              0x00007fff895496f8 -[BrowserApplication sendEvent:] + 822
    24  AppKit                              0x00007fff8dc80682 -[NSApplication run] + 555
    25  AppKit                              0x00007fff8deff80c NSApplicationMain + 867
    26  Safari                              0x00007fff896ffa6f SafariMain + 197
    27  Safari                              0x0000000100000f24 Safari + 3876

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

More information about the webkit-unassigned mailing list