Changeset 68670 in webkit
- Timestamp:
- Sep 29, 2010 11:44:02 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r68665 r68670 1 2010-09-29 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 queryCommandValue "formatBlock" always returns false 6 https://bugs.webkit.org/show_bug.cgi?id=21305 7 8 Added a test for queryCommandValue('formatBlock'). 9 10 * editing/execCommand/query-format-block-expected.txt: Added. 11 * editing/execCommand/query-format-block.html: Added. 12 * editing/execCommand/script-tests/query-format-block.js: Added. 13 (queryFormatBlock): 14 (selectFirstPosition): 15 (selectMiddleOfHelloWorld): 16 1 17 2010-09-29 Martin Robinson <mrobinson@igalia.com> 2 18 -
trunk/WebCore/ChangeLog
r68666 r68670 1 2010-09-29 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 queryCommandValue "formatBlock" always returns false 6 https://bugs.webkit.org/show_bug.cgi?id=21305 7 8 Implemented queryCommandValue('formatBlock'). We match the Firefox's behavior exactly 9 because Firefox and Internet Explorer support the same set of elements 10 (address, h1, h2, h3, h4, h5, h6, and p) and Firefox's behavior is more compatible with Opera. 11 See the bug for the detailed discussion. 12 13 WebKit's implementation returns the local name of the lowest common ancestor 14 of the selection with the tag name address, h1, h2, h3, h4, h5, h6, or p. 15 It returns "" when there is no such an ancestor or there is no selection. 16 17 Test: editing/execCommand/query-format-block.html 18 19 * editing/Editor.cpp: 20 (WebCore::isElementForFormatBlockCommand): 21 (WebCore::Editor::elementForFormatBlockCommand): 22 * editing/Editor.h: 23 * editing/EditorCommand.cpp: 24 (WebCore::valueFormatBlock): 25 (WebCore::createCommandMap): 26 1 27 2010-09-29 Matt Perry <mpcomplete@chromium.org> 2 28 -
trunk/WebCore/editing/Editor.cpp
r68547 r68670 967 967 } 968 968 969 static bool isElementForFormatBlockCommand(const Node* node) 970 { 971 return node->hasTagName(addressTag) 972 || node->hasTagName(h1Tag) 973 || node->hasTagName(h2Tag) 974 || node->hasTagName(h3Tag) 975 || node->hasTagName(h4Tag) 976 || node->hasTagName(h5Tag) 977 || node->hasTagName(h6Tag) 978 || node->hasTagName(pTag) 979 || node->hasTagName(preTag); 980 } 981 982 Element* Editor::elementForFormatBlockCommand() const 983 { 984 const VisibleSelection& selection = m_frame->selection()->selection(); 985 if (!selection.isNonOrphanedCaretOrRange() || !selection.isContentEditable()) 986 return 0; 987 988 ExceptionCode ec; 989 Node* commonAncestor = selection.firstRange()->commonAncestorContainer(ec); 990 while (commonAncestor && !isElementForFormatBlockCommand(commonAncestor)) 991 commonAncestor = commonAncestor->parentNode(); 992 993 if (!commonAncestor) 994 return 0; 995 996 ASSERT(commonAncestor->isElementNode()); 997 return static_cast<Element*>(commonAncestor); 998 } 999 969 1000 void Editor::indent() 970 1001 { -
trunk/WebCore/editing/Editor.h
r68103 r68670 126 126 TriState selectionHasStyle(CSSStyleDeclaration*) const; 127 127 String selectionStartCSSPropertyValue(int propertyID); 128 Element* elementForFormatBlockCommand() const; 128 129 const SimpleFontData* fontForSelection(bool&) const; 129 130 WritingDirection textDirectionForSelection(bool&) const; -
trunk/WebCore/editing/EditorCommand.cpp
r68465 r68670 1347 1347 } 1348 1348 1349 static String valueFormatBlock(Frame* frame, Event*) 1350 { 1351 Element* formatBlockElement = frame->editor()->elementForFormatBlockCommand(); 1352 if (!formatBlockElement) 1353 return ""; 1354 return formatBlockElement->localName(); 1355 } 1356 1349 1357 // Map of functions 1350 1358 … … 1383 1391 { "FontSizeDelta", { executeFontSizeDelta, supported, enabledInEditableText, stateNone, valueFontSizeDelta, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1384 1392 { "ForeColor", { executeForeColor, supported, enabledInRichlyEditableText, stateNone, valueForeColor, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1385 { "FormatBlock", { executeFormatBlock, supported, enabledInRichlyEditableText, stateNone, value Null, notTextInsertion, doNotAllowExecutionWhenDisabled } },1393 { "FormatBlock", { executeFormatBlock, supported, enabledInRichlyEditableText, stateNone, valueFormatBlock, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1386 1394 { "ForwardDelete", { executeForwardDelete, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, 1387 1395 { "HiliteColor", { executeBackColor, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
Note: See TracChangeset
for help on using the changeset viewer.