<?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>25222</bug_id>
          
          <creation_ts>2009-04-15 16:10:42 -0700</creation_ts>
          <short_desc>RTL: extending selection after change text directionality behaves differently for textarea and div element</short_desc>
          <delta_ts>2011-01-26 15:45:41 -0800</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>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></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="Xiaomei Ji">xji</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>jparent</cc>
    
    <cc>jshin</cc>
    
    <cc>leviw</cc>
    
    <cc>mitz</cc>
    
    <cc>playmobil</cc>
    
    <cc>progame+wk</cc>
    
    <cc>rniwa</cc>
    
    <cc>xji</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>117688</commentid>
    <comment_count>0</comment_count>
    <who name="Xiaomei Ji">xji</who>
    <bug_when>2009-04-15 16:10:42 -0700</bug_when>
    <thetext>Steps to reproduce:
1. open the attached test case
2. repeat the following steps to the first line (&apos;div&apos;) and 2nd line (&apos;textarea&apos;) separately.
a). select word &quot;two&quot; by place cursor after &apos;o&apos; and continuing press shift+left arrow.
b) change directionality to &apos;right-to-left&apos; using context menu (while still selects word &quot;two&quot;)
c) press shift+left arrow 

Results:
1. for &apos;div&apos; element (the first line), selection became &quot;two &quot;, which extends the original selection to include the space between &apos;two&apos; and &apos;three&quot;. 
2. for &apos;textarea&apos; (the 2nd line), selection became &apos;wo&apos;, &apos;t&apos; in &apos;two&apos; was un-selected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117689</commentid>
    <comment_count>1</comment_count>
      <attachid>29520</attachid>
    <who name="Xiaomei Ji">xji</who>
    <bug_when>2009-04-15 16:11:05 -0700</bug_when>
    <thetext>Created attachment 29520
test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117692</commentid>
    <comment_count>2</comment_count>
    <who name="Xiaomei Ji">xji</who>
    <bug_when>2009-04-15 16:28:00 -0700</bug_when>
    <thetext>The reason of such difference is inside Editor::setBaseWritingDirection(WritingDirection direction).

&apos;textarea&apos; was handled in the &apos;if&apos; block. And the original selection&apos;s (base, extent) was not changed, stays as (7,4). So, continuing press shift+left arrow select the logically next character of position &apos;4&apos; (which un-select &apos;t&apos;) in RTL environment

&apos;div&apos; was handled in the other path, and Editor::applyParagraphStyleToSelection() was called.
Following the call stack, Editor::applyParagraphStyle() --&gt; EditCommand::apply() --&gt; ApplyStyleCommand::doApply() --&gt; ApplyStyleCommand::applyBlockStyle(),
the cmd&apos;s ending selection was updated at the last statement updateStartEnd().
cmd&apos;s ending selection is used as the new selection, its (base, extend) changed from (7, 4) to (4, 7). So, continuing press shift+left arrow select the logically next character of position 7 (the space between &apos;two&apos; and &apos;three&apos;) in RTL environment.


Both FF and IE handle the above extending selection after changing directionality the same way for &apos;div&apos; and &apos;textarea&apos;. They both un-select &apos;t&apos; in  both &apos;div&apos; and &apos;textarea&apos;. 

My question is:
1. Is the webkit handling difference by intention? or it is a bug?
2. If it is by intention, why? why &apos;textarea&apos; and &apos;input type&apos; are  handled differently than &apos;div&apos;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117693</commentid>
    <comment_count>3</comment_count>
    <who name="Xiaomei Ji">xji</who>
    <bug_when>2009-04-15 16:29:07 -0700</bug_when>
    <thetext>in Chromium bug:
http://code.google.com/p/chromium/issues/detail?id=9842
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>214395</commentid>
    <comment_count>4</comment_count>
    <who name="Xiaomei Ji">xji</who>
    <bug_when>2010-04-19 18:01:04 -0700</bug_when>
    <thetext>marked the bug as &quot;resolved&quot; by mistake. Reopen....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>340406</commentid>
    <comment_count>5</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2011-01-26 12:35:14 -0800</bug_when>
    <thetext>&gt; My question is:
&gt; 1. Is the webkit handling difference by intention? or it is a bug?
&gt; 2. If it is by intention, why? why &apos;textarea&apos; and &apos;input type&apos; are  handled differently than &apos;div&apos;?

There was definitely a conscious decision made in r34935 to handle text inputs differently, but it seems inconsistent that the function changes the writing direction for all contents of the textarea, but only acts paragraph-level for the div.

If we want the difference in behavior I just mentioned but want consistent selection behavior, we can explicitly update the selection in the special case for text inputs, but it seems hacky.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>340417</commentid>
    <comment_count>6</comment_count>
    <who name="Xiaomei Ji">xji</who>
    <bug_when>2011-01-26 12:50:05 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; &gt; My question is:
&gt; &gt; 1. Is the webkit handling difference by intention? or it is a bug?
&gt; &gt; 2. If it is by intention, why? why &apos;textarea&apos; and &apos;input type&apos; are  handled differently than &apos;div&apos;?
&gt; 
&gt; There was definitely a conscious decision made in r34935 to handle text inputs differently, but it seems inconsistent that the function changes the writing direction for all contents of the textarea, but only acts paragraph-level for the div.
&gt; 
&gt; If we want the difference in behavior I just mentioned but want consistent selection behavior, we can explicitly update the selection in the special case for text inputs, but it seems hacky.


Feedback from Uri who&apos;s been a go-to person of RTL editing in Mozilla:
&quot;Behavior on text area is correct, behavior on div is incorrect.&quot;, from which I imply that the behavior of textarea and div on this matter should be consistent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>340430</commentid>
    <comment_count>7</comment_count>
    <who name="Yair Yogev">progame+wk</who>
    <bug_when>2011-01-26 13:18:57 -0800</bug_when>
    <thetext>I expect a rich editing box to act like a word document - &quot;only acts paragraph-level&quot;, not like a textarea - that should change the writing direction for all content.

Will changing the behavior for divs affect the behavior for rich editing (in Gmail for example)?
if it will, then it should not be changed IMO.
if not, then i don&apos;t have a strong opinion in this matter- while I see the paragraph-level behavior as superior, and generally a good thing... being consistent with FF/IE is also good.

btw if you test Firefox with the test case above, and press Ctrl+Shift+X while the div has focus (won&apos;t work the other way around), you will find that it changes the direction in the textarea too! that makes no sense... only FF does that</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>340530</commentid>
    <comment_count>8</comment_count>
    <who name="Levi Weintraub">leviw</who>
    <bug_when>2011-01-26 15:45:41 -0800</bug_when>
    <thetext>(In reply to comment #7)
&gt; I expect a rich editing box to act like a word document - &quot;only acts paragraph-level&quot;, not like a textarea - that should change the writing direction for all content.
&gt; 
&gt; Will changing the behavior for divs affect the behavior for rich editing (in Gmail for example)?
&gt; if it will, then it should not be changed IMO.
&gt; if not, then i don&apos;t have a strong opinion in this matter- while I see the paragraph-level behavior as superior, and generally a good thing... being consistent with FF/IE is also good.

It would, and you&apos;re right.

I now think the issue here lies with the current editing command behavior of only preserving the start/end positions, and not the base/extent positions. It would be a large change to update them all to support this, and it may make sense to roll this into a larger reworking of how editing commands deal with selection preservation.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>29520</attachid>
            <date>2009-04-15 16:11:05 -0700</date>
            <delta_ts>2009-04-15 16:11:05 -0700</delta_ts>
            <desc>test case</desc>
            <filename>mouse_selection.htm</filename>
            <type>text/html</type>
            <size>340</size>
            <attacher name="Xiaomei Ji">xji</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNpdGlvbmFs
Ly9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXRyYW5zaXRpb25h
bC5kdGQiPg0KPGh0bWwgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiID4NCjxo
ZWFkPg0KICAgIDx0aXRsZT5VbnRpdGxlZCBQYWdlPC90aXRsZT4NCjwvaGVhZD4NCjxib2R5Pg0K
PGRpdiBjb250ZW50ZWRpdGFibGU+b25lIHR3byB0aHJlZTwvZGl2Pg0KPHRleHRhcmVhIGNvbnRl
bnRlZGl0YWJsZT5vbmUgdHdvIHRocmVlPC90ZXh0YXJlYT4NCjwvYm9keT4NCjwvaHRtbD4NCg==
</data>

          </attachment>
      

    </bug>

</bugzilla>