Changeset 143313 in webkit


Ignore:
Timestamp:
Feb 19, 2013 2:14:07 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Caret is not displayed when trying to focus inside a contenteditable element containing an empty block.
https://bugs.webkit.org/show_bug.cgi?id=108053

Source/WebCore:

Patch by Arpita Bahuguna <a.bah@samsung.com> on 2013-02-19
Reviewed by Ryosuke Niwa.

Test: editing/selection/caret-in-div-containing-empty-block.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::localCaretRect):
When trying to compute the caret rect for the contenteditable div, the
border and the padding were not considered. Because of this, for the
given test case, which had a border defined on the containing div, the
caret was being painted just atop the border, thereby masking it.

Have modified the code to ensure that the computed caret rect takes
into account the border and padding (if any) specified on the box, but only
if the node doesn't have content that shall be skipped for editing.

We do not add border and padding while computing the caret rect for any
element that either has no content or has content that shall be skipped
for editing purposes. This holds true for table elements as well.

This helps avoid the caret displacement previsouly observed before/after
any controls placed within the contenteditable box, when considering
border and padding in computation of the caret rect.

LayoutTests:

Patch by Arpita Bahuguna <arpitabahuguna@gmail.com> on 2013-02-19
Reviewed by Ryosuke Niwa.

  • editing/selection/caret-in-div-containing-empty-block-expected.txt: Added.
  • editing/selection/caret-in-div-containing-empty-block.html: Added.

Layout test added for verifying that a caret is displayed within a
contenteditable div having a border, both for the horizontal
as well as the vertical writing modes.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r143312 r143313  
     12013-02-19  Arpita Bahuguna  <arpitabahuguna@gmail.com>
     2
     3        Caret is not displayed when trying to focus inside a contenteditable element containing an empty block.
     4        https://bugs.webkit.org/show_bug.cgi?id=108053
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * editing/selection/caret-in-div-containing-empty-block-expected.txt: Added.
     9        * editing/selection/caret-in-div-containing-empty-block.html: Added.
     10        Layout test added for verifying that a caret is displayed within a
     11        contenteditable div having a border, both for the horizontal
     12        as well as the vertical writing modes.
     13
    1142013-02-19  Mihnea Ovidenie  <mihnea@adobe.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r143312 r143313  
     12013-02-19  Arpita Bahuguna  <a.bah@samsung.com>
     2
     3        Caret is not displayed when trying to focus inside a contenteditable element containing an empty block.
     4        https://bugs.webkit.org/show_bug.cgi?id=108053
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Test: editing/selection/caret-in-div-containing-empty-block.html
     9
     10        * rendering/RenderBox.cpp:
     11        (WebCore::RenderBox::localCaretRect):
     12        When trying to compute the caret rect for the contenteditable div, the
     13        border and the padding were not considered. Because of this, for the
     14        given test case, which had a border defined on the containing div, the
     15        caret was being painted just atop the border, thereby masking it.
     16
     17        Have modified the code to ensure that the computed caret rect takes
     18        into account the border and padding (if any) specified on the box, but only
     19        if the node doesn't have content that shall be skipped for editing.
     20
     21        We do not add border and padding while computing the caret rect for any
     22        element that either has no content or has content that shall be skipped
     23        for editing purposes. This holds true for table elements as well.
     24
     25        This helps avoid the caret displacement previsouly observed before/after
     26        any controls placed within the contenteditable box, when considering
     27        border and padding in computation of the caret rect.
     28
    1292013-02-19  Mihnea Ovidenie  <mihnea@adobe.com>
    230
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r143312 r143313  
    38203820    // FIXME: Paint the carets inside empty blocks differently than the carets before/after elements.
    38213821
    3822     // FIXME: What about border and padding?
    38233822    LayoutRect rect(location(), LayoutSize(caretWidth, height()));
    38243823    bool ltr = box ? box->isLeftToRightDirection() : style()->isLeftToRightDirection();
     
    38513850    // Move to local coords
    38523851    rect.moveBy(-location());
     3852
     3853    // FIXME: Border/padding should be added for all elements but this workaround
     3854    // is needed because we use offsets inside an "atomic" element to represent
     3855    // positions before and after the element in deprecated editing offsets.
     3856    if (!(editingIgnoresContent(node()) || isTableElement(node()))) {
     3857        rect.setX(rect.x() + borderLeft() + paddingLeft());
     3858        rect.setY(rect.y() + paddingTop() + borderTop());
     3859    }
    38533860
    38543861    if (!isHorizontalWritingMode())
Note: See TracChangeset for help on using the changeset viewer.