Changeset 209976 in webkit
- Timestamp:
- Dec 18, 2016 5:14:10 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r209973 r209976 1 2016-12-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Changing text direction fires input events with null inputTypes and no data 4 https://bugs.webkit.org/show_bug.cgi?id=166007 5 <rdar://problem/29557205> 6 7 Reviewed by Sam Weinig. 8 9 Verifies that changing text direction causes beforeinput and input events with appropriate inputType and data to 10 be dispatched, and that preventing this beforeinput event causes no change in text direction. 11 12 * fast/events/before-input-events-prevent-text-direction-expected.txt: Added. 13 * fast/events/before-input-events-prevent-text-direction.html: Added. 14 1 15 2016-12-18 Simon Fraser <simon.fraser@apple.com> 2 16 -
trunk/Source/WebCore/ChangeLog
r209971 r209976 1 2016-12-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Changing text direction fires input events with null inputTypes and no data 4 https://bugs.webkit.org/show_bug.cgi?id=166007 5 <rdar://problem/29557205> 6 7 Reviewed by Sam Weinig. 8 9 Adds support for the "formatSetInlineTextDirection" input type, triggered when using the context menu on Mac in 10 an editable area (for both plain and rich text cases) to change paragraph direction. To do this, we add cases 11 for EditActionSetWritingDirection in inputTypeNameForEditingAction and inputEventDataForEditingStyleAndAction. 12 13 When changing text direction for a plaintext editable element, we have logic in Editor::setBaseWritingDirection 14 that sets the focused element's dir attribute to the requested value (ltr or rtl). We add similar hooks here to 15 dispatch input events and handle preventing default. 16 17 Test: fast/events/before-input-events-prevent-text-direction.html 18 19 * editing/EditCommand.cpp: 20 (WebCore::inputTypeNameForEditingAction): 21 22 Handle the EditActionSetWritingDirection case. 23 24 * editing/Editor.cpp: 25 (WebCore::inputEventDataForEditingStyleAndAction): 26 (WebCore::Editor::applyParagraphStyle): 27 28 Include input event data when dispatching an input event here. 29 30 (WebCore::Editor::setBaseWritingDirection): 31 * testing/Internals.cpp: 32 (WebCore::Internals::setBaseWritingDirection): 33 * testing/Internals.h: 34 * testing/Internals.idl: 35 36 Introduce an internal testing support hook for setting base writing direction (the same codepath taken when 37 using the context menu to change paragraph direction). Currently, using testRunner.execCommand creates and 38 applies style with an additional `unicode-bidi` attribute, and appears to also be intentionally disabled for 39 plaintext editable elements. 40 1 41 2016-12-17 Simon Fraser <simon.fraser@apple.com> 2 42 -
trunk/Source/WebCore/editing/EditCommand.cpp
r208014 r209976 111 111 case EditActionOutdent: 112 112 return ASCIILiteral("formatOutdent"); 113 case EditActionSetWritingDirection: 114 return ASCIILiteral("formatSetInlineTextDirection"); 113 115 default: 114 116 return emptyString(); -
trunk/Source/WebCore/editing/Editor.cpp
r209943 r209976 131 131 case EditActionSetColor: 132 132 return style->getPropertyValue(CSSPropertyColor); 133 case EditActionSetWritingDirection: 134 return style->getPropertyValue(CSSPropertyDirection); 133 135 default: 134 136 return { }; … … 830 832 831 833 String inputTypeName = inputTypeNameForEditingAction(editingAction); 834 String inputEventData = inputEventDataForEditingStyleAndAction(style, editingAction); 832 835 RefPtr<Element> element = m_frame.selection().selection().rootEditableElement(); 833 if (element && !dispatchBeforeInputEvent(*element, inputTypeName ))836 if (element && !dispatchBeforeInputEvent(*element, inputTypeName, inputEventData)) 834 837 return; 835 838 … … 837 840 client()->didApplyStyle(); 838 841 if (element) 839 dispatchInputEvent(*element, inputTypeName );842 dispatchInputEvent(*element, inputTypeName, inputEventData); 840 843 } 841 844 … … 1587 1590 if (direction == NaturalWritingDirection) 1588 1591 return; 1589 downcast<HTMLTextFormControlElement>(*focusedElement).setAttributeWithoutSynchronization(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl"); 1590 focusedElement->dispatchInputEvent(); 1592 1593 auto& focusedFormElement = downcast<HTMLTextFormControlElement>(*focusedElement); 1594 auto directionValue = direction == LeftToRightWritingDirection ? "ltr" : "rtl"; 1595 auto writingDirectionInputTypeName = inputTypeNameForEditingAction(EditActionSetWritingDirection); 1596 if (!dispatchBeforeInputEvent(focusedFormElement, writingDirectionInputTypeName, directionValue)) 1597 return; 1598 1599 focusedFormElement.setAttributeWithoutSynchronization(dirAttr, directionValue); 1600 dispatchInputEvent(focusedFormElement, writingDirectionInputTypeName, directionValue); 1591 1601 document().updateStyleIfNeeded(); 1592 1602 return; -
trunk/Source/WebCore/testing/Internals.cpp
r209964 r209976 135 135 #include "WebCoreJSClientData.h" 136 136 #include "WorkerThread.h" 137 #include "WritingDirection.h" 137 138 #include "XMLHttpRequest.h" 138 139 #include <bytecode/CodeBlock.h> … … 3518 3519 } 3519 3520 3521 void Internals::setBaseWritingDirection(BaseWritingDirection direction) 3522 { 3523 if (auto* document = contextDocument()) { 3524 if (auto* frame = document->frame()) { 3525 switch (direction) { 3526 case BaseWritingDirection::Ltr: 3527 frame->editor().setBaseWritingDirection(LeftToRightWritingDirection); 3528 break; 3529 case BaseWritingDirection::Rtl: 3530 frame->editor().setBaseWritingDirection(RightToLeftWritingDirection); 3531 break; 3532 case BaseWritingDirection::Natural: 3533 frame->editor().setBaseWritingDirection(NaturalWritingDirection); 3534 break; 3535 } 3536 } 3537 } 3538 } 3539 3520 3540 #if ENABLE(POINTER_LOCK) 3521 3541 bool Internals::pageHasPendingPointerLock() const -
trunk/Source/WebCore/testing/Internals.h
r209964 r209976 520 520 void reportBacktrace(); 521 521 522 enum class BaseWritingDirection { Natural, Ltr, Rtl }; 523 void setBaseWritingDirection(BaseWritingDirection); 524 522 525 #if ENABLE(POINTER_LOCK) 523 526 bool pageHasPendingPointerLock() const; -
trunk/Source/WebCore/testing/Internals.idl
r209964 r209976 71 71 }; 72 72 73 enum BaseWritingDirection { 74 "Natural", 75 "Ltr", 76 "Rtl" 77 }; 78 73 79 enum EventThrottlingBehavior { 74 80 "responsive", … … 486 492 487 493 void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection); 494 void setBaseWritingDirection(BaseWritingDirection direction); 488 495 489 496 boolean userPrefersReducedMotion();
Note: See TracChangeset
for help on using the changeset viewer.