| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. | 3 * Portions Copyright (c) 2011 Motorola Mobility, 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "platform/geometry/FloatQuad.h" | 38 #include "platform/geometry/FloatQuad.h" |
| 39 #include "wtf/text/CString.h" | 39 #include "wtf/text/CString.h" |
| 40 #include <ostream> // NOLINT | 40 #include <ostream> // NOLINT |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 using namespace HTMLNames; | 44 using namespace HTMLNames; |
| 45 | 45 |
| 46 template <typename Strategy> | 46 template <typename Strategy> |
| 47 VisiblePositionTemplate<Strategy>::VisiblePositionTemplate() | 47 VisiblePositionTemplate<Strategy>::VisiblePositionTemplate() |
| 48 #if DCHECK_IS_ON() |
| 49 : m_domTreeVersion(0) |
| 50 , m_styleVersion(0) |
| 51 #endif |
| 48 { | 52 { |
| 49 } | 53 } |
| 50 | 54 |
| 51 template <typename Strategy> | 55 template <typename Strategy> |
| 52 VisiblePositionTemplate<Strategy>::VisiblePositionTemplate(const PositionWithAff
inityTemplate<Strategy>& positionWithAffinity) | 56 VisiblePositionTemplate<Strategy>::VisiblePositionTemplate(const PositionWithAff
inityTemplate<Strategy>& positionWithAffinity) |
| 53 : m_positionWithAffinity(positionWithAffinity) | 57 : m_positionWithAffinity(positionWithAffinity) |
| 58 #if DCHECK_IS_ON() |
| 59 , m_domTreeVersion(positionWithAffinity.position().document()->domTreeVersio
n()) |
| 60 , m_styleVersion(positionWithAffinity.position().document()->styleVersion()) |
| 61 #endif |
| 54 { | 62 { |
| 55 } | 63 } |
| 56 | 64 |
| 57 template<typename Strategy> | 65 template<typename Strategy> |
| 58 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::create(cons
t PositionWithAffinityTemplate<Strategy>& positionWithAffinity) | 66 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::create(cons
t PositionWithAffinityTemplate<Strategy>& positionWithAffinity) |
| 59 { | 67 { |
| 60 if (positionWithAffinity.isNull()) | 68 if (positionWithAffinity.isNull()) |
| 61 return VisiblePositionTemplate<Strategy>(); | 69 return VisiblePositionTemplate<Strategy>(); |
| 62 DCHECK(positionWithAffinity.position().isConnected()) << positionWithAffinit
y; | 70 DCHECK(positionWithAffinity.position().isConnected()) << positionWithAffinit
y; |
| 63 | 71 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 #ifndef NDEBUG | 215 #ifndef NDEBUG |
| 208 | 216 |
| 209 template<typename Strategy> | 217 template<typename Strategy> |
| 210 void VisiblePositionTemplate<Strategy>::showTreeForThis() const | 218 void VisiblePositionTemplate<Strategy>::showTreeForThis() const |
| 211 { | 219 { |
| 212 deepEquivalent().showTreeForThis(); | 220 deepEquivalent().showTreeForThis(); |
| 213 } | 221 } |
| 214 | 222 |
| 215 #endif | 223 #endif |
| 216 | 224 |
| 225 template <typename Strategy> |
| 226 bool VisiblePositionTemplate<Strategy>::isValid() const |
| 227 { |
| 228 #if DCHECK_IS_ON() |
| 229 if (isNull()) |
| 230 return true; |
| 231 Document& document = *m_positionWithAffinity.position().document(); |
| 232 return m_domTreeVersion == document.domTreeVersion() && m_styleVersion == do
cument.styleVersion() && !document.needsLayoutTreeUpdate(); |
| 233 #else |
| 234 return true; |
| 235 #endif |
| 236 } |
| 237 |
| 217 template class CORE_TEMPLATE_EXPORT VisiblePositionTemplate<EditingStrategy>; | 238 template class CORE_TEMPLATE_EXPORT VisiblePositionTemplate<EditingStrategy>; |
| 218 template class CORE_TEMPLATE_EXPORT VisiblePositionTemplate<EditingInFlatTreeStr
ategy>; | 239 template class CORE_TEMPLATE_EXPORT VisiblePositionTemplate<EditingInFlatTreeStr
ategy>; |
| 219 | 240 |
| 220 std::ostream& operator<<(std::ostream& ostream, const VisiblePosition& position) | 241 std::ostream& operator<<(std::ostream& ostream, const VisiblePosition& position) |
| 221 { | 242 { |
| 222 return ostream << position.deepEquivalent() << '/' << position.affinity(); | 243 return ostream << position.deepEquivalent() << '/' << position.affinity(); |
| 223 } | 244 } |
| 224 | 245 |
| 225 std::ostream& operator<<(std::ostream& ostream, const VisiblePositionInFlatTree&
position) | 246 std::ostream& operator<<(std::ostream& ostream, const VisiblePositionInFlatTree&
position) |
| 226 { | 247 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 239 } | 260 } |
| 240 DVLOG(0) << "Cannot showTree for (nil) VisiblePosition."; | 261 DVLOG(0) << "Cannot showTree for (nil) VisiblePosition."; |
| 241 } | 262 } |
| 242 | 263 |
| 243 void showTree(const blink::VisiblePosition& vpos) | 264 void showTree(const blink::VisiblePosition& vpos) |
| 244 { | 265 { |
| 245 vpos.showTreeForThis(); | 266 vpos.showTreeForThis(); |
| 246 } | 267 } |
| 247 | 268 |
| 248 #endif | 269 #endif |
| OLD | NEW |