Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp

Issue 2268843002: queryCommandState should consider the nested list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/execCommand/queryCommandState-list.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2009 Igalia S.L. 4 * Copyright (C) 2009 Igalia S.L.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 18 matching lines...) Expand all
29 29
30 #include "bindings/core/v8/ExceptionState.h" 30 #include "bindings/core/v8/ExceptionState.h"
31 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 31 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
32 #include "core/CSSPropertyNames.h" 32 #include "core/CSSPropertyNames.h"
33 #include "core/CSSValueKeywords.h" 33 #include "core/CSSValueKeywords.h"
34 #include "core/HTMLNames.h" 34 #include "core/HTMLNames.h"
35 #include "core/clipboard/Pasteboard.h" 35 #include "core/clipboard/Pasteboard.h"
36 #include "core/css/CSSValueList.h" 36 #include "core/css/CSSValueList.h"
37 #include "core/css/StylePropertySet.h" 37 #include "core/css/StylePropertySet.h"
38 #include "core/dom/DocumentFragment.h" 38 #include "core/dom/DocumentFragment.h"
39 #include "core/dom/TagCollection.h"
39 #include "core/editing/EditingUtilities.h" 40 #include "core/editing/EditingUtilities.h"
40 #include "core/editing/FrameSelection.h" 41 #include "core/editing/FrameSelection.h"
41 #include "core/editing/SelectionModifier.h" 42 #include "core/editing/SelectionModifier.h"
42 #include "core/editing/commands/CreateLinkCommand.h" 43 #include "core/editing/commands/CreateLinkCommand.h"
43 #include "core/editing/commands/EditorCommandNames.h" 44 #include "core/editing/commands/EditorCommandNames.h"
44 #include "core/editing/commands/FormatBlockCommand.h" 45 #include "core/editing/commands/FormatBlockCommand.h"
45 #include "core/editing/commands/IndentOutdentCommand.h" 46 #include "core/editing/commands/IndentOutdentCommand.h"
46 #include "core/editing/commands/InsertListCommand.h" 47 #include "core/editing/commands/InsertListCommand.h"
47 #include "core/editing/commands/ReplaceSelectionCommand.h" 48 #include "core/editing/commands/ReplaceSelectionCommand.h"
48 #include "core/editing/commands/TypingCommand.h" 49 #include "core/editing/commands/TypingCommand.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 const EphemeralRange newRange = selection.toNormalizedEphemeralRange(); 352 const EphemeralRange newRange = selection.toNormalizedEphemeralRange();
352 if (newRange.isNull()) 353 if (newRange.isNull())
353 return false; 354 return false;
354 if (newRange.isCollapsed()) 355 if (newRange.isCollapsed())
355 return false; 356 return false;
356 TextAffinity affinity = frame.selection().affinity(); 357 TextAffinity affinity = frame.selection().affinity();
357 frame.selection().setSelectedRange(newRange, affinity, SelectionDirectionalM ode::NonDirectional, FrameSelection::CloseTyping); 358 frame.selection().setSelectedRange(newRange, affinity, SelectionDirectionalM ode::NonDirectional, FrameSelection::CloseTyping);
358 return true; 359 return true;
359 } 360 }
360 361
362 static bool hasChildTags(Element& element, const QualifiedName& tagName)
363 {
364 return !element.getElementsByTagName(tagName.localName())->isEmpty();
365 }
366
361 static TriState selectionListState(const FrameSelection& selection, const Qualif iedName& tagName) 367 static TriState selectionListState(const FrameSelection& selection, const Qualif iedName& tagName)
362 { 368 {
363 if (selection.isCaret()) { 369 if (selection.isCaret()) {
364 if (enclosingElementWithTag(selection.selection().start(), tagName)) 370 if (enclosingElementWithTag(selection.selection().start(), tagName))
365 return TrueTriState; 371 return TrueTriState;
366 } else if (selection.isRange()) { 372 } else if (selection.isRange()) {
367 Element* startElement = enclosingElementWithTag(selection.selection().st art(), tagName); 373 Element* startElement = enclosingElementWithTag(selection.selection().st art(), tagName);
368 Element* endElement = enclosingElementWithTag(selection.selection().end( ), tagName); 374 Element* endElement = enclosingElementWithTag(selection.selection().end( ), tagName);
369 if (startElement && endElement && startElement == endElement) 375
376 if (startElement && endElement && startElement == endElement) {
377 // If the selected list has the different type of list as child, ret urn |FalseTriState|.
378 // See http://crbug.com/385374
379 if (hasChildTags(*startElement, tagName.matches(ulTag) ? olTag : ulT ag))
380 return FalseTriState;
370 return TrueTriState; 381 return TrueTriState;
382 }
371 } 383 }
372 384
373 return FalseTriState; 385 return FalseTriState;
374 } 386 }
375 387
376 static TriState stateStyle(LocalFrame& frame, CSSPropertyID propertyID, const ch ar* desiredValue) 388 static TriState stateStyle(LocalFrame& frame, CSSPropertyID propertyID, const ch ar* desiredValue)
377 { 389 {
378 if (frame.editor().behavior().shouldToggleStyleBasedOnStartOfSelection()) 390 if (frame.editor().behavior().shouldToggleStyleBasedOnStartOfSelection())
379 return frame.editor().selectionStartHasStyle(propertyID, desiredValue) ? TrueTriState : FalseTriState; 391 return frame.editor().selectionStartHasStyle(propertyID, desiredValue) ? TrueTriState : FalseTriState;
380 return frame.editor().selectionHasStyle(propertyID, desiredValue); 392 return frame.editor().selectionHasStyle(propertyID, desiredValue);
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 case WebEditingCommandType::DeleteWordBackward: 1970 case WebEditingCommandType::DeleteWordBackward:
1959 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionBackwa rd, WordGranularity); 1971 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionBackwa rd, WordGranularity);
1960 case WebEditingCommandType::DeleteWordForward: 1972 case WebEditingCommandType::DeleteWordForward:
1961 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForwar d, WordGranularity); 1973 return RangesFromCurrentSelectionOrExtendCaret(*m_frame, DirectionForwar d, WordGranularity);
1962 default: 1974 default:
1963 return nullptr; 1975 return nullptr;
1964 } 1976 }
1965 } 1977 }
1966 1978
1967 } // namespace blink 1979 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/execCommand/queryCommandState-list.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698