• mitz@apple.com's avatar
    WebCore: · 576e84e8
    mitz@apple.com authored
            Reviewed by Darin Adler.
            - preparation for https://bugs.webkit.org/show_bug.cgi?id=3729
              <rdar://problem/4036353> REGRESSION: arrow keys move insertion bar backwards in RTL text
            The three main changes in this patch are:
            1) Making all inline boxes know their bidi level, instead of just text
               boxes knowing whether their bidi level is odd or even. This is
               required for the next change.
            2) Replacing RenderObject::inlineBox() with
               Position::getInlineBoxAndOffset() in recognition of the fact that the
               inline box containing the primary caret for a position in a given
               node may belong to a different node's renderer.
            3) Changing RenderObject::caretRect() to take an InlineBox parameter,
               and changing callers to call VisiblePosition::caretRect(), which
               locates the inline box, then calls caretRect() on the renderer for
               that box. This, combined with the previous change, ensures that the
               primary caret is rendered at the right place for positions that
               lie on a directionality boundary.
            Test: platform/mac/editing/input/caret-primary-bidi.html
            * WebCore.base.exp: Added the VisiblePosition(Node*, int, EAffinity)
            constructor and VisiblePosition::caretRect(), and sorted.
            * dom/Position.cpp:
            (WebCore::nextRenderedEditable): Adjusted for the removal of
            (WebCore::previousRenderedEditable): Ditto.
            (WebCore::Position::rendersInDifferentPosition): Ditto.
            (WebCore::Position::getInlineBoxAndOffset): Added. Gets the inline box
            and the offset within that box at which the primary caret for this
            position should render.
            * dom/Position.h:
            * editing/DeleteSelectionCommand.cpp:
            (WebCore::DeleteSelectionCommand::mergeParagraphs): Changed to call
            VisiblePosition::caretRect() instead of calling the RenderObject method.
            * editing/SelectionController.cpp:
            (WebCore::caretY): Ditto.
            (WebCore::SelectionController::xPosForVerticalArrowNavigation): Ditto.
            (WebCore::SelectionController::layout): Ditto.
            * editing/VisiblePosition.cpp:
            (WebCore::VisiblePosition::caretRect): Changed to call
            getInlineBoxAndOffset() to get the correct inline box and call the
            renderer for that box.
            * editing/VisiblePosition.h:
            (WebCore::VisiblePosition::getInlineBoxAndOffset): Added convenience
            methods for getting the inline box and caret offset for a visible
            position, accounting for its affinity.
            * editing/visible_units.cpp:
            (WebCore::rootBoxForLine): Changed to use getInlineBoxAndOffset()
            instead of RenderObject::inlineBox().
            (WebCore::previousLinePosition): Ditto.
            (WebCore::nextLinePosition): Ditto.
            * page/AccessibilityObject.cpp:
            (WebCore::updateAXLineStartForVisiblePosition): Ditto.
            * page/Frame.cpp:
            (WebCore::Frame::firstRectForRange): Ditto.
            * rendering/InlineBox.cpp:
            (WebCore::InlineBox::caretMinOffset): Changed to forward to the
            (WebCore::InlineBox::caretMaxOffset): Ditto.
            * rendering/InlineBox.h: Replaced the m_reversed bit, intended for use
            in InlineTextBox only, with six bits of the bidi level of the box,
            intended for use in all leaf inline boxes.
            (WebCore::InlineBox::InlineBox): Added missing initializer for
            m_dirOverride and initialized the bidi level.
            (WebCore::InlineBox::bidiLevel): Added this accessor.
            (WebCore::InlineBox::setBidiLevel): Ditto.
            (WebCore::InlineBox::direction): Ditto.
            (WebCore::InlineBox::caretLeftmostOffset): Added this convenience
            (WebCore::InlineBox::caretRightmostOffset): Ditto.
            * rendering/InlineTextBox.cpp: Replaced all references to m_reversed
            with checking of direction().
            * rendering/RenderBR.cpp: Removed inlineBox().
            * rendering/RenderBR.h: Ditto.
            * rendering/RenderBox.cpp:
            (WebCore::RenderBox::caretRect): Changed to take an inline box and
            account for the direction of the box (or the renderer) in positioning
            the caret: in right-to-left boxes, the "before" position is to the right
            while "after" is to the left.
            * rendering/RenderBox.h:
            * rendering/RenderFlow.cpp:
            (WebCore::RenderFlow::caretRect): Updated the signature.
            * rendering/RenderFlow.h:
            * rendering/RenderObject.cpp:
            (WebCore::RenderObject::caretRect): Updated the signature.
            (WebCore::RenderObject::caretMaxOffset): Changed to return the child
            node count (or 1 if there are no children) for replaced elements, such
            as <select>s.
            * rendering/RenderObject.h:
            * rendering/RenderReplaced.cpp: Removed caretMinOffset() and
            caretMaxOffset() because the base class implementation does the right
            thing for replaced objects now.
            * rendering/RenderReplaced.h:
            * rendering/RenderSVGInlineText.cpp:
            (WebCore::RenderSVGInlineText::caretRect): Updated the signature.
            (WebCore::RenderSVGInlineText::positionForCoordinates): Updated for
            the change from m_reversed to direction().
            * rendering/RenderSVGInlineText.h:
            * rendering/RenderText.cpp:
            (WebCore::RenderText::caretRect): Changed to take an inline box and
            removed the code that used to find the inline for the given position.
            Changed use of m_reversed to use direction().
            (WebCore::RenderText::position): Changed use of m_reversed to use
            * rendering/RenderText.h:
            * rendering/RenderTextControl.cpp:
            (WebCore::RenderTextControl::textWithHardLineBreaks): Adjusted for the
            removal of RenderObject::inlineBox().
            * rendering/RenderTreeAsText.cpp:
            (WebCore::writeTextRun): Changed to use direction() instead of
            * rendering/SVGInlineTextBox.cpp: Ditto.
            * rendering/SVGRenderTreeAsText.cpp: Ditto.
            * rendering/SVGRootInlineBox.cpp: Ditto.
            * rendering/bidi.cpp:
            (WebCore::RenderBlock::constructLine): Made this function set the
            bidi level on all leaf boxes.
            * svg/SVGTextContentElement.cpp: Changed to use direction() instead of
            Reviewed by Darin Adler.
            - preparation for https://bugs.webkit.org/show_bug.cgi?id=3729
              <rdar://problem/4036353> REGRESSION: arrow keys move insertion bar backwards in RTL text
            * WebView/WebFrame.mm:
            (-[WebFrame _caretRectAtNode:offset:affinity:]): Changed to use
            VisiblePosition::caretRect() instead of the RenderObject method which
            was removed.
            Reviewed by Darin Adler.
            - test the visual position of the primary caret in bidirectional text
            * platform/mac/editing/input/caret-primary-bidi-expected.txt: Added.
            * platform/mac/editing/input/caret-primary-bidi.html: Added.
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32508 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebCore.base.exp 39.8 KB