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

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

Issue 2835063002: Selection API: type attribute should return 'Range' for range-selection in text controls. (Closed)
Patch Set: . Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 String DOMSelection::type() const { 200 String DOMSelection::type() const {
201 if (!IsAvailable()) 201 if (!IsAvailable())
202 return String(); 202 return String();
203 // This is a WebKit DOM extension, incompatible with an IE extension 203 // This is a WebKit DOM extension, incompatible with an IE extension
204 // IE has this same attribute, but returns "none", "text" and "control" 204 // IE has this same attribute, but returns "none", "text" and "control"
205 // http://msdn.microsoft.com/en-us/library/ms534692(VS.85).aspx 205 // http://msdn.microsoft.com/en-us/library/ms534692(VS.85).aspx
206 if (rangeCount() == 0) 206 if (rangeCount() == 0)
207 return "None"; 207 return "None";
208 if (isCollapsed()) 208 // Do not use isCollapsed() here. We'd like to return "Range" for
209 // range-selection in text control elements.
210 if (GetFrame()->Selection().GetSelectionInDOMTree().IsCaret())
209 return "Caret"; 211 return "Caret";
210 return "Range"; 212 return "Range";
211 } 213 }
212 214
213 unsigned DOMSelection::rangeCount() const { 215 unsigned DOMSelection::rangeCount() const {
214 if (!IsAvailable()) 216 if (!IsAvailable())
215 return 0; 217 return 0;
216 if (DocumentCachedRange()) 218 if (DocumentCachedRange())
217 return 1; 219 return 1;
218 if (GetFrame() 220 if (GetFrame()
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 tree_scope_->GetDocument().AddConsoleMessage( 826 tree_scope_->GetDocument().AddConsoleMessage(
825 ConsoleMessage::Create(kJSMessageSource, kErrorMessageLevel, message)); 827 ConsoleMessage::Create(kJSMessageSource, kErrorMessageLevel, message));
826 } 828 }
827 829
828 DEFINE_TRACE(DOMSelection) { 830 DEFINE_TRACE(DOMSelection) {
829 visitor->Trace(tree_scope_); 831 visitor->Trace(tree_scope_);
830 ContextClient::Trace(visitor); 832 ContextClient::Trace(visitor);
831 } 833 }
832 834
833 } // namespace blink 835 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698