WebCore:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 23:03:57 +0000 (23:03 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 23:03:57 +0000 (23:03 +0000)
commit34dedb830d42ccbab60fb98e24c01e2599828c1d
tree7c2936f14ceee2ea28b0bd4e714bda64dbe04108
parent867ffe735666a1e4c6e4e8da4e35fdd3deba295f
WebCore:

        Reviewed by Oliver.

        - fix <rdar://problem/5470457> REGRESSION: Input method inline hole is mishandled in text
          <input> elements with maxlength limit

        * editing/Editor.h: Moved MarkedTextUnderline here and renamed it CompositionUnderline.
        Moved the rest of the marked text API here and used the term that will be more familiar
        to those on platforms other than Macintosh, "composition". This helps prevent confusion
        with the other kinds of mark -- the emacs "mark" and spelling/grammar marks. Also
        cleaned up the conditionals a bit for the Macintosh-specific parts of this header.

        * editing/Editor.cpp:
        (WebCore::Editor::Editor): Updated for name change.
        (WebCore::Editor::clear): Added. To be called by FrameLoader::clear().
        (WebCore::Editor::insertTextWithoutSendingTextEvent): Removed code to make inserted
        text replace the marked text range -- we now deal with this explicitly by not
        calling this function to replace marked text. Also removed unneeded code that was
        specific to the use of this to replace the marked text.
        (WebCore::Editor::selectComposition): Renamed from selectMarkedText. Updated since
        the composition range is not stored as a Range.
        (WebCore::Editor::confirmComposition): Added. To be called when changing a composition
        into actual text. Unlike the old code path, deletes the composition first, then inserts
        the text, triggering the normal insertion code path and events. This is helpful because
        it means the inserted text will be truncated by the <input> element, for example.
        (WebCore::Editor::confirmCompositionWithoutDisturbingSelection): Added.
        (WebCore::Editor::setComposition): Added. To be called when changing the composition.
        Takes parameters for the underlines and selection. Unlike the old code path, this passes
        a flag down that indicates the inserted text is part of a composition. This is helpful
        because we don't send the event that will cause the <input> element to do truncation.
        It's also a better API for future improvements to our input method handling.
        (WebCore::Editor::revealSelectionAfterEditingOperation): Updated for name change.
        (WebCore::Editor::setIgnoreCompositionSelectionChange): Ditto.
        (WebCore::Editor::compositionRange): Added. Needed now that the composition is not
        stored as a Range.
        (WebCore::Editor::getCompositionSelection): Added.

        * editing/TypingCommand.h:
        * editing/TypingCommand.cpp: (WebCore::TypingCommand::insertText):
        Added an insertedTextIsComposition parameter, and don't send the BeforeTextInsertedEvent
        if it's true.

        * loader/FrameLoader.cpp: (WebCore::FrameLoader::clear): Replaced the Macintosh-specific
        call to setMarkedTextRange with a call to the new Editor::clear().

        * page/Frame.h:
        * page/Frame.cpp:
        * page/FramePrivate.h:
        * page/mac/FrameMac.mm:
        Removed the marked text code. It was streamlined and moved to Editor, except for the
        Mac-specific code, which was moved into WebKit.

        * page/mac/WebCoreFrameBridge.h:
        * page/mac/WebCoreFrameBridge.mm: Removed some now-unneeded marked text code.
        (-[WebCoreFrameBridge markedTextNSRange]): Updated for name/API change.

        * rendering/InlineTextBox.h:
        * rendering/InlineTextBox.cpp:
        (WebCore::InlineTextBox::paint): Updated marked text code for name changes, and also
        streamlined the code a bit for the case where there is no composition.
        (WebCore::InlineTextBox::paintCompositionBackground): Name change.
        (WebCore::InlineTextBox::paintCompositionUnderline): Ditto.

        * rendering/RenderTextControl.h:
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::finishText): Added. Helper function shared by the
        (WebCore::RenderTextControl::text):
        (WebCore::getNextSoftBreak):
        (WebCore::RenderTextControl::textWithHardLineBreaks):

        * platform/CharacterNames.h: Added newlineCharacter.

        * dom/Range.h: Remove the now-unneeded version of toString that converts <br>
        elements into newlines.
        * dom/Range.cpp:
        (WebCore::Range::toString): Changed this to use a Vector<UChar> instead of
        a String so it will not have pathological reallocation performance, and removed
        the <br> feature.
        (WebCore::Range::pastEndNode): Made this return 0 when there is no start node.
        This bit of extra robustness guarantees you can't do a null dereference if the
        start node is 0 and the end node is not. Not sure this case really exists.

        * page/ContextMenuController.cpp: (ContextMenuController::contextMenuItemSelected):
        Removed a semi-bogus use of Range::toString(true). The right function to use here
        is plainText().

        * bridge/EditorClient.h: Removed obsolete markedTextAbandoned function.

        * WebCore.exp: Updated for above changes.

WebKit:

        Reviewed by Oliver.

        - fix <rdar://problem/5470457> REGRESSION: Input method inline hole is mishandled in text
          <input> elements with maxlength limit

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _selectionChanged]): Tweaked code a bit.
        (-[WebHTMLView markedRange]): Simplified logic, since markedTextNSRange works when there's
        no composition range.
        (-[WebHTMLView hasMarkedText]): Call directly to Editor instead of bridge.
        (-[WebHTMLView unmarkText]): Call new confirmComposition to make it clear that this is
        confirming text, not just unmarking it to discard it.
        (extractUnderlines): Added. Converts directly from an NSAttributedString to the
        CompositionUnderline vector that's used by WebCore.
        (-[WebHTMLView setMarkedText:selectedRange:]): Changed to use the new setComposition.
        (-[WebHTMLView insertText:]): Changed to use confirmComposition when appropriate, instead
        of relying on special behavior of Editor::insertText.
        (-[WebHTMLView _updateSelectionForInputManager]): Rewrote to use getCompositionSelection
        and confirmCompositionWithoutDisturbingSelection.

        * WebCoreSupport/WebEditorClient.h:
        * WebCoreSupport/WebEditorClient.mm:
        Removed obsolete markedTextAbandoned function.

win:

        Reviewed by Oliver.

        - fix <rdar://problem/5470457> REGRESSION: Input method inline hole is mishandled in text
          <input> elements with maxlength limit

        * WebView.cpp:
        (WebView::resetIME): Change to use confirmCompositionWithoutDisturbingSelection.
        (WebView::updateSelectionForIME): Update for name changes, and to use new functions
        in Editor.
        (WebView::onIMEStartComposition): Removed unneeded call to unmarkText.
        (compositionToUnderlines): Removed startOffset parameter, since setComposition now
        handles this.
        (WebView::onIMEComposition): Changed to use confirmComposition and setComposition.
        Logic gets a lot cleaner.
        (WebView::onIMEEndComposition): Removed unneeded calls to Editor.
        (WebView::onIMERequestCharPosition): Updated for name changes.

LayoutTests:

        Reviewed by Oliver.

        - updated test results changed by change in input manager logic

        * platform/mac/editing/input/firstrectforcharacterrange-styled-expected.txt:
        * platform/mac/editing/input/text-input-controller-expected.txt:
        * platform/mac/editing/input/wrapped-line-char-rect-expected.txt:
        Updated. Small changes in which delegate methods are called.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25547 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-styled-expected.txt
LayoutTests/platform/mac/editing/input/text-input-controller-expected.txt
LayoutTests/platform/mac/editing/input/wrapped-line-char-rect-expected.txt
WebCore/ChangeLog
WebCore/WebCore.exp
WebCore/bridge/EditorClient.h
WebCore/dom/Range.cpp
WebCore/dom/Range.h
WebCore/editing/Editor.cpp
WebCore/editing/Editor.h
WebCore/editing/TypingCommand.cpp
WebCore/editing/TypingCommand.h
WebCore/loader/FrameLoader.cpp
WebCore/page/ContextMenuController.cpp
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/page/FramePrivate.h
WebCore/page/mac/FrameMac.mm
WebCore/page/mac/WebCoreFrameBridge.h
WebCore/page/mac/WebCoreFrameBridge.mm
WebCore/platform/CharacterNames.h
WebCore/rendering/InlineTextBox.cpp
WebCore/rendering/InlineTextBox.h
WebCore/rendering/RenderTextControl.cpp
WebCore/rendering/RenderTextControl.h
WebKit/ChangeLog
WebKit/WebCoreSupport/WebEditorClient.h
WebKit/WebCoreSupport/WebEditorClient.mm
WebKit/WebView/WebHTMLView.mm
WebKit/win/ChangeLog
WebKit/win/WebView.cpp