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

Unified 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, 4 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
index ebc714cd7033d20b045e957f2297a0cc04605211..f3b839a11ef8ae6d5242aff27004a9ee2394f938 100644
--- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -36,6 +36,7 @@
#include "core/css/CSSValueList.h"
#include "core/css/StylePropertySet.h"
#include "core/dom/DocumentFragment.h"
+#include "core/dom/TagCollection.h"
#include "core/editing/EditingUtilities.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/SelectionModifier.h"
@@ -358,6 +359,11 @@ static bool expandSelectionToGranularity(LocalFrame& frame, TextGranularity gran
return true;
}
+static bool hasChildTags(Element& element, const QualifiedName& tagName)
+{
+ return !element.getElementsByTagName(tagName.localName())->isEmpty();
+}
+
static TriState selectionListState(const FrameSelection& selection, const QualifiedName& tagName)
{
if (selection.isCaret()) {
@@ -366,8 +372,14 @@ static TriState selectionListState(const FrameSelection& selection, const Qualif
} else if (selection.isRange()) {
Element* startElement = enclosingElementWithTag(selection.selection().start(), tagName);
Element* endElement = enclosingElementWithTag(selection.selection().end(), tagName);
- if (startElement && endElement && startElement == endElement)
+
+ if (startElement && endElement && startElement == endElement) {
+ // If the selected list has the different type of list as child, return |FalseTriState|.
+ // See http://crbug.com/385374
+ if (hasChildTags(*startElement, tagName.matches(ulTag) ? olTag : ulTag))
+ return FalseTriState;
return TrueTriState;
+ }
}
return FalseTriState;
« 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