<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>16049</bug_id>
          
          <creation_ts>2007-11-19 07:24:58 -0800</creation_ts>
          <short_desc>execCommand(&apos;backColor&apos;) fails on collapsed selections</short_desc>
          <delta_ts>2008-06-19 18:16:35 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>HTML Editing</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://nick-santos.com/tests/background_color.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nick Santos">nicksantos</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>jparent</cc>
    
    <cc>justin.garcia</cc>
    
    <cc>mrowe</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>61674</commentid>
    <comment_count>0</comment_count>
    <who name="Nick Santos">nicksantos</who>
    <bug_when>2007-11-19 07:24:58 -0800</bug_when>
    <thetext>Repro Steps:
1) Place the cursor in a contentEditable element.
2) Execute document.execCommand(&apos;backColor&apos;, false, &apos;#f00&apos;) in JavaScript.
3) Type some text.

Expected Result:
The new text should have a red background.

Actual Result:
The new text keeps the same background.

Notes:
&apos;backColor&apos; works ok when text is actually selected.
If we replace &apos;backColor&apos; with &apos;foreColor&apos; in step #2, the new text is red as expected.
Verified on Safari3/Win and Webkit-Nightly/OSX.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61682</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-11-19 08:11:45 -0800</bug_when>
    <thetext>JSEditor.cpp shows that BackColor and ForeColor have different values for the enabledFn member of their CommandImp:

WebCore/editing/JSEditor.cpp:        { &quot;BackColor&quot;, { execBackColor, enabledAnyRichlyEditableRangeSelection, stateNone, valueBackColor } },
WebCore/editing/JSEditor.cpp:        { &quot;ForeColor&quot;, { execForeColor, enabledAnySelection, stateNone, valueForeColor } },


BackColor requires a range selection which would cause the command to be disabled for collapsed selections.  The fix here may be as simple as changing the enabledFn to enabledAnyRichlyEditableSelection.  A quick test suggests that this gives the same behaviour as IE on the test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66782</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-01-10 12:58:33 -0800</bug_when>
    <thetext>So it sounds like all this bug needs is some understanding of what a change to enabledAnyRichlyEditableSelection would mean for the rest of the web. :)  I guess we solve that with a test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83928</commentid>
    <comment_count>3</comment_count>
    <who name="Julie Parent">jparent</who>
    <bug_when>2008-06-19 15:54:40 -0700</bug_when>
    <thetext>+1 on fixing this. We have horrible, horrible hacks in place to get this working in the Google editor.  I&apos;d love to get rid of them!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83929</commentid>
    <comment_count>4</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2008-06-19 16:11:14 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; JSEditor.cpp shows that BackColor and ForeColor have different values for the
&gt; enabledFn member of their CommandImp:
&gt; 
&gt; WebCore/editing/JSEditor.cpp:        { &quot;BackColor&quot;, { execBackColor,
&gt; enabledAnyRichlyEditableRangeSelection, stateNone, valueBackColor } },
&gt; WebCore/editing/JSEditor.cpp:        { &quot;ForeColor&quot;, { execForeColor,
&gt; enabledAnySelection, stateNone, valueForeColor } },

Yikes that&apos;s completely wrong, BackColor should have enabledAnyRichlyEditableRangeSelection, and I don&apos;t know why ForeColor has enabledAnySelection, it should be disabled in a plain text region too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83930</commentid>
    <comment_count>5</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2008-06-19 16:12:04 -0700</bug_when>
    <thetext>&gt; BackColor should have enabledAnyRichlyEditableRangeSelection

that should read &quot;enabledAnyRichlyEditableSelection&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83944</commentid>
    <comment_count>6</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2008-06-19 18:16:35 -0700</bug_when>
    <thetext>http://trac.webkit.org/changeset/34682</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>