haikuwebkit/LayoutTests/editing/input/focus-change-with-marked-te...

28 lines
1.0 KiB
HTML
Raw Permalink Normal View History

Composition state should be cleared when changing focus to a non-editable element https://bugs.webkit.org/show_bug.cgi?id=164595 <rdar://problem/26412551> Reviewed by Enrica Casucci. Source/WebCore: When canceling or confirming a composition, always ensure that the composition node and composition underlines being tracked are reset, even when there is no current selection. This prevents us from getting into a bad state where focus has already changed from an element with a pending composition to a different element and the composition is canceled, but the Editor still maintains its composition node. Test: editing/input/focus-change-with-marked-text.html * editing/Editor.cpp: (WebCore::Editor::setComposition): Tools: Adds support for window.textInputController in DumpRenderTree on iOS. So far, only the methods needed for the new layout test (editing/focus-change-with-marked-text.html) are supported. These are insertText, setMarkedText, and markedRange. * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: * DumpRenderTree/TextInputController.h: Renamed from Tools/DumpRenderTree/mac/TextInputController.h. Remove the PLATFORM(MAC) guard for defining the TextInputController. Also, move the TextInputController header out of the /mac platform directory. * DumpRenderTree/ios/TextInputControllerIOS.m: Added. (+[TextInputController isSelectorExcludedFromWebScript:]): (+[TextInputController webScriptNameForSelector:]): (-[TextInputController initWithWebView:]): (-[TextInputController markedRange]): (-[TextInputController insertText:]): (-[TextInputController setMarkedText:selectedFrom:length:]): Introduces TextInputControllerIOS.m, which contains an iOS implementation of TextInputController. Only a subset of the methods available on the Mac version will be available on iOS for now (see above). * DumpRenderTree/mac/FrameLoadDelegate.mm: Remove the PLATFORM(MAC) guard for initializing the TextInputController and binding it to the window object. (-[FrameLoadDelegate didClearWindowObjectInStandardWorldForFrame:]): * DumpRenderTree/mac/TextInputControllerMac.m: Renamed from Tools/DumpRenderTree/mac/TextInputController.m. (-[WebHTMLView interpretKeyEvents:]): (-[WebNSRange initWithNSRange:]): (-[WebNSRange location]): (-[WebNSRange length]): (+[WebNSRange isSelectorExcludedFromWebScript:]): (+[NSMutableAttributedString isSelectorExcludedFromWebScript:]): (+[NSMutableAttributedString webScriptNameForSelector:]): (-[NSMutableAttributedString getLength]): (-[NSMutableAttributedString ranges]): (-[NSMutableAttributedString attributeNamesAtIndex:]): (-[NSMutableAttributedString valueOfAttribute:atIndex:]): (-[NSMutableAttributedString addAttribute:value:]): (-[NSMutableAttributedString addAttribute:value:from:length:]): (-[NSMutableAttributedString addColorAttribute:red:green:blue:alpha:]): (-[NSMutableAttributedString addColorAttribute:red:green:blue:alpha:from:length:]): (-[NSMutableAttributedString addFontAttribute:fontName:size:]): (-[NSMutableAttributedString addFontAttribute:fontName:size:from:length:]): (+[TextInputController isSelectorExcludedFromWebScript:]): (+[TextInputController webScriptNameForSelector:]): (-[TextInputController initWithWebView:]): (-[TextInputController dealloc]): (-[TextInputController textInput]): (-[TextInputController insertText:]): (-[TextInputController doCommand:]): (-[TextInputController setMarkedText:selectedFrom:length:]): (-[TextInputController unmarkText]): (-[TextInputController hasMarkedText]): (-[TextInputController conversationIdentifier]): (-[TextInputController substringFrom:length:]): (-[TextInputController attributedSubstringFrom:length:]): (-[TextInputController legacyAttributedString:]): (-[TextInputController markedRange]): (-[TextInputController selectedRange]): (-[TextInputController firstRectForCharactersFrom:length:]): (-[TextInputController characterIndexForPointX:Y:]): (-[TextInputController validAttributesForMarkedText]): (-[TextInputController attributedStringWithString:]): (-[TextInputController stringWithUndoGroupingInsertion:]): (-[TextInputController dictatedStringWithPrimaryString:alternative:alternativeOffset:alternativeLength:]): (-[TextInputController setInputMethodHandler:]): (-[TextInputController interpretKeyEvents:withSender:]): Fixes miscellaneous style issues. LayoutTests: Adds a new layout test to ensure that when changing focus from an element with pending composition text to another element, the composition is committed and there should not still be a pending composition. * editing/input/focus-change-with-marked-text-expected.txt: Added. * editing/input/focus-change-with-marked-text.html: Added. * platform/ios-simulator-wk2/TestExpectations: * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/182316@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208593 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-11 18:38:01 +00:00
<!DOCTYPE html>
<html>
<body>
<input id="input" contenteditable></input>
<select id="select"><option></option></select>
<div id="output"></div>
<script type="text/javascript">
let write = s => output.innerHTML += `${s}<br>`;
input.focus();
if (window.testRunner) {
testRunner.dumpAsText();
textInputController.setMarkedText("a", 1, 0);
textInputController.setMarkedText("ab", 2, 0);
textInputController.setMarkedText("abc", 3, 0);
select.focus();
textInputController.insertText(null);
write(`The text field's value is: "${input.value}"`);
write(`Is there marked text? ${!!textInputController.markedRange()}`);
} else {
write(`To manually test, insert some marked text in the left text field without committing it, then focus
the right select menu. The composition text should be committed, and the composition should no longer
be highlighted.`);
}
</script>
</body>
</html>