12010-11-19 Ryosuke Niwa <rniwa@webkit.org>
2
3 Reviewed by NOBODY (OOPS!).
4
5 SelectionController::typingStyle() should return EditingStyle*
6 https://bugs.webkit.org/show_bug.cgi?id=49813
7
8 Changed the return type of SelectionController::typingStyle to EditingStyle*.
9
10 Extracted textDirection from Editor::textDirectionForSelection to hide the underlying
11 CSSMutableStyleDeclaration.
12
13 Also extracted the code to preserve unicode-bidi and direction CSS properties in
14 InsertTextCommand::input, and moved into EditingStyle::prepareToApplyAt. ShouldPreserveWritingDirection,
15 which is added to the argument list of EditingStyle::prepareToApplyAt, decides whether or not
16 these two properties are preserved.
17
18 Also added SelectionController::copyTypingStyle() to copy the typing style as an instance of
19 CSSMutableStyleDeclaration.
20
21 No new tests are added since this is a refactoring.
22
23 * editing/EditingStyle.cpp:
24 (WebCore::EditingStyle::textDirection): Extracted from Editor::textDirectionForSelection.
25 (WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode): Added a missing null check.
26 (WebCore::EditingStyle::prepareToApplyAt): See above.
27 (WebCore::editingStyleIncludingTypingStyle): Calls SelectionController::typingStyle.
28 * editing/EditingStyle.h: Moved WritingDirection from Editor.h
29 * editing/Editor.cpp:
30 (WebCore::Editor::textDirectionForSelection): Calls EditingStyle::textDirection.
31 (WebCore::Editor::computeAndSetTypingStyle): Calls SelectionController::typingStyle.
32 (WebCore::Editor::selectionComputedStyle): Ditto.
33 (WebCore::Editor::styleForSelectionStart): Ditto.
34 * editing/Editor.h:
35 * editing/InsertLineBreakCommand.cpp:
36 (WebCore::InsertLineBreakCommand::doApply): Ditto.
37 * editing/InsertTextCommand.cpp:
38 (WebCore::InsertTextCommand::input): Calls EditingStyle::prepareToApplyAt with PreserveWritingDirection.
39 * editing/SelectionController.h:
40 (WebCore::SelectionController::typingStyle): Returns EditingStyle* rather than CSSMutableStyleDeclaration*.
41 (WebCore::SelectionController::copyTypingStyle): Added.
42