Changeset 91481 in webkit


Ignore:
Timestamp:
Jul 21, 2011, 11:45:44 AM (14 years ago)
Author:
enrica@apple.com
Message:

Cannot click to position the caret to the right of an image with display:block style.
https://bugs.webkit.org/show_bug.cgi?id=64962
<rdar://problem/9446343>

Reviewed by David Hyatt.

Source/WebCore:

Test: editing/selection/click-on-block-image.html

The current implementation of positionForPoint always returns the visible
position to the left of the image, if the image has a block style.
This patch changes the behavior for block styled images to match the behavior
for inline images.

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::positionForPoint): Modified to avoid relying entirely
on InlineBox to calculate the position.

LayoutTests:

  • editing/selection/click-on-block-image-expected.txt: Added.
  • editing/selection/click-on-block-image.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r91480 r91481  
     12011-07-21  Enrica Casucci  <enrica@apple.com>
     2
     3        Cannot click to position the caret to the right of an image with display:block style.
     4        https://bugs.webkit.org/show_bug.cgi?id=64962
     5        <rdar://problem/9446343>
     6
     7        Reviewed by David Hyatt.
     8
     9        * editing/selection/click-on-block-image-expected.txt: Added.
     10        * editing/selection/click-on-block-image.html: Added.
     11
    1122011-07-21  Ryosuke Niwa  <rniwa@webkit.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r91475 r91481  
     12011-07-21  Enrica Casucci  <enrica@apple.com>
     2
     3        Cannot click to position the caret to the right of an image with display:block style.
     4        https://bugs.webkit.org/show_bug.cgi?id=64962
     5        <rdar://problem/9446343>
     6
     7        Reviewed by David Hyatt.
     8
     9        Test: editing/selection/click-on-block-image.html
     10
     11        The current implementation of positionForPoint always returns the visible
     12        position to the left of the image, if the image has a block style.
     13        This patch changes the behavior for block styled images to match the behavior
     14        for inline images.
     15
     16        * rendering/RenderReplaced.cpp:
     17        (WebCore::RenderReplaced::positionForPoint): Modified to avoid relying entirely
     18        on InlineBox to calculate the position.
     19
    1202011-07-21  Pavel Feldman  <pfeldman@google.com>
    221
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r91242 r91481  
    417417VisiblePosition RenderReplaced::positionForPoint(const LayoutPoint& point)
    418418{
     419    // FIXME: This code is buggy if the replaced element is relative positioned.
    419420    InlineBox* box = inlineBoxWrapper();
    420     if (!box)
    421         return createVisiblePosition(0, DOWNSTREAM);
    422 
    423     // FIXME: This code is buggy if the replaced element is relative positioned.
    424 
    425     RootInlineBox* root = box->root();
    426 
    427     LayoutUnit top = root->selectionTop();
    428     LayoutUnit bottom = root->selectionBottom();
    429 
    430     LayoutUnit blockDirectionPosition = box->isHorizontal() ? point.y() + y() : point.x() + x();
    431     LayoutUnit lineDirectionPosition = box->isHorizontal() ? point.x() + x() : point.y() + y();
    432 
     421    RootInlineBox* rootBox = box ? box->root() : 0;
     422   
     423    LayoutUnit top = rootBox ? rootBox->selectionTop() : logicalTop();
     424    LayoutUnit bottom = rootBox ? rootBox->selectionBottom() : logicalBottom();
     425   
     426    LayoutUnit blockDirectionPosition = isHorizontalWritingMode() ? point.y() + y() : point.x() + x();
     427    LayoutUnit lineDirectionPosition = isHorizontalWritingMode() ? point.x() + x() : point.y() + y();
     428   
    433429    if (blockDirectionPosition < top)
    434430        return createVisiblePosition(caretMinOffset(), DOWNSTREAM); // coordinates are above
     
    438434   
    439435    if (node()) {
    440         if (lineDirectionPosition <= box->logicalLeft() + (box->logicalWidth() / 2))
     436        if (lineDirectionPosition <= logicalLeft() + (logicalWidth() / 2))
    441437            return createVisiblePosition(0, DOWNSTREAM);
    442438        return createVisiblePosition(1, DOWNSTREAM);
Note: See TracChangeset for help on using the changeset viewer.