OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |