Changeset 125648 in webkit


Ignore:
Timestamp:
Aug 14, 2012 10:20:45 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Text selection in text area in auto scroll mode goes wrong.
https://bugs.webkit.org/show_bug.cgi?id=74346

Patch by Sukolsak Sakshuwong <sukolsak@google.com> on 2012-08-14
Reviewed by Ojan Vafai.

Source/WebCore:

WebKit triggers autoscroll in text area when the user drags the cursor from inside
the text area to the outside. When that happens, it gets the local cursor position
relative to the node under the cursor from hit-testing, converts it to
the absolute position, and then converts it to the local position relative to the
text area. However, the hit-testing method of text area did not take scrolling
offset into account. This caused it to give an incorrect value of the local cursor
position. Make the hit-testing take scrolling offset into account.

Test: fast/events/autoscroll-in-textarea.html

  • html/shadow/TextControlInnerElements.cpp:

(WebCore::TextControlInnerTextElement::createRenderer):

  • rendering/RenderTextControl.cpp:

(WebCore::RenderTextControl::hitInnerTextElement):

  • rendering/RenderTextControlSingleLine.cpp:

(WebCore):

  • rendering/RenderTextControlSingleLine.h:

(WebCore::RenderTextControlInnerBlock::RenderTextControlInnerBlock):
(WebCore::RenderTextControlInnerBlock::hasLineIfEmpty):

LayoutTests:

  • fast/events/autoscroll-in-textarea-expected.txt: Added.
  • fast/events/autoscroll-in-textarea.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r125647 r125648  
     12012-08-14  Sukolsak Sakshuwong  <sukolsak@google.com>
     2
     3        Text selection in text area in auto scroll mode goes wrong.
     4        https://bugs.webkit.org/show_bug.cgi?id=74346
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * fast/events/autoscroll-in-textarea-expected.txt: Added.
     9        * fast/events/autoscroll-in-textarea.html: Added.
     10
    1112012-08-14  Yuta Kitamura  <yutak@google.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r125644 r125648  
     12012-08-14  Sukolsak Sakshuwong  <sukolsak@google.com>
     2
     3        Text selection in text area in auto scroll mode goes wrong.
     4        https://bugs.webkit.org/show_bug.cgi?id=74346
     5
     6        Reviewed by Ojan Vafai.
     7
     8        WebKit triggers autoscroll in text area when the user drags the cursor from inside
     9        the text area to the outside. When that happens, it gets the local cursor position
     10        relative to the node under the cursor from hit-testing, converts it to
     11        the absolute position, and then converts it to the local position relative to the
     12        text area. However, the hit-testing method of text area did not take scrolling
     13        offset into account. This caused it to give an incorrect value of the local cursor
     14        position. Make the hit-testing take scrolling offset into account.
     15
     16        Test: fast/events/autoscroll-in-textarea.html
     17
     18        * html/shadow/TextControlInnerElements.cpp:
     19        (WebCore::TextControlInnerTextElement::createRenderer):
     20        * rendering/RenderTextControl.cpp:
     21        (WebCore::RenderTextControl::hitInnerTextElement):
     22        * rendering/RenderTextControlSingleLine.cpp:
     23        (WebCore):
     24        * rendering/RenderTextControlSingleLine.h:
     25        (WebCore::RenderTextControlInnerBlock::RenderTextControlInnerBlock):
     26        (WebCore::RenderTextControlInnerBlock::hasLineIfEmpty):
     27
    1282012-08-14  Shinya Kawanaka  <shinyak@chromium.org>
    229
  • trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp

    r125529 r125648  
    103103RenderObject* TextControlInnerTextElement::createRenderer(RenderArena* arena, RenderStyle*)
    104104{
    105     bool multiLine = false;
    106     Element* shadowAncestor = shadowHost();
    107     if (shadowAncestor && shadowAncestor->renderer()) {
    108         ASSERT(shadowAncestor->renderer()->isTextField() || shadowAncestor->renderer()->isTextArea());
    109         multiLine = shadowAncestor->renderer()->isTextArea();
    110     }
    111     return new (arena) RenderTextControlInnerBlock(this, multiLine);
     105    return new (arena) RenderTextControlInnerBlock(this);
    112106}
    113107
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r124556 r125648  
    156156void RenderTextControl::hitInnerTextElement(HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset)
    157157{
     158    HTMLElement* innerText = innerTextElement();
    158159    LayoutPoint adjustedLocation = accumulatedOffset + location();
    159     HTMLElement* innerText = innerTextElement();
     160    LayoutPoint localPoint = pointInContainer - toLayoutSize(adjustedLocation + innerText->renderBox()->location());
     161    if (hasOverflowClip())
     162        localPoint += scrolledContentOffset();
    160163    result.setInnerNode(innerText);
    161164    result.setInnerNonSharedNode(innerText);
    162     result.setLocalPoint(pointInContainer - toLayoutSize(adjustedLocation + innerText->renderBox()->location()));
     165    result.setLocalPoint(localPoint);
    163166}
    164167
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r123329 r125648  
    5050using namespace HTMLNames;
    5151
    52 VisiblePosition RenderTextControlInnerBlock::positionForPoint(const LayoutPoint& point)
    53 {
    54     LayoutPoint contentsPoint(point);
    55 
    56     // Multiline text controls have the scroll on shadowHost, so we need to take
    57     // that into account here.
    58     if (m_multiLine) {
    59         RenderTextControl* renderer = toRenderTextControl(node()->shadowHost()->renderer());
    60         if (renderer->hasOverflowClip())
    61             contentsPoint += renderer->scrolledContentOffset();
    62     }
    63 
    64     return RenderBlock::positionForPoint(contentsPoint);
    65 }
    66 
    67 // ----------------------------
    68 
    6952RenderTextControlSingleLine::RenderTextControlSingleLine(Node* node)
    7053    : RenderTextControl(node)
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h

    r120824 r125648  
    111111class RenderTextControlInnerBlock : public RenderBlock {
    112112public:
    113     RenderTextControlInnerBlock(Node* node, bool isMultiLine) : RenderBlock(node), m_multiLine(isMultiLine) { }
     113    RenderTextControlInnerBlock(Node* node) : RenderBlock(node) { }
    114114
    115115private:
    116116    virtual bool hasLineIfEmpty() const { return true; }
    117     virtual VisiblePosition positionForPoint(const LayoutPoint&);
    118 
    119     bool m_multiLine;
    120117};
    121118
Note: See TracChangeset for help on using the changeset viewer.