| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. | 4 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #endif | 52 #endif |
| 53 { | 53 { |
| 54 } | 54 } |
| 55 | 55 |
| 56 template <typename Strategy> | 56 template <typename Strategy> |
| 57 VisiblePositionTemplate<Strategy>::VisiblePositionTemplate( | 57 VisiblePositionTemplate<Strategy>::VisiblePositionTemplate( |
| 58 const PositionWithAffinityTemplate<Strategy>& positionWithAffinity) | 58 const PositionWithAffinityTemplate<Strategy>& positionWithAffinity) |
| 59 : m_positionWithAffinity(positionWithAffinity) | 59 : m_positionWithAffinity(positionWithAffinity) |
| 60 #if DCHECK_IS_ON() | 60 #if DCHECK_IS_ON() |
| 61 , | 61 , |
| 62 m_domTreeVersion( | 62 m_domTreeVersion(positionWithAffinity.document()->domTreeVersion()), |
| 63 positionWithAffinity.position().document()->domTreeVersion()), | 63 m_styleVersion(positionWithAffinity.document()->styleVersion()) |
| 64 m_styleVersion(positionWithAffinity.position().document()->styleVersion()) | |
| 65 #endif | 64 #endif |
| 66 { | 65 { |
| 67 } | 66 } |
| 68 | 67 |
| 69 template <typename Strategy> | 68 template <typename Strategy> |
| 70 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::create( | 69 VisiblePositionTemplate<Strategy> VisiblePositionTemplate<Strategy>::create( |
| 71 const PositionWithAffinityTemplate<Strategy>& positionWithAffinity) { | 70 const PositionWithAffinityTemplate<Strategy>& positionWithAffinity) { |
| 72 if (positionWithAffinity.isNull()) | 71 if (positionWithAffinity.isNull()) |
| 73 return VisiblePositionTemplate<Strategy>(); | 72 return VisiblePositionTemplate<Strategy>(); |
| 74 DCHECK(positionWithAffinity.position().isConnected()) << positionWithAffinity; | 73 DCHECK(positionWithAffinity.isConnected()) << positionWithAffinity; |
| 75 | 74 |
| 76 Document& document = *positionWithAffinity.position().document(); | 75 Document& document = *positionWithAffinity.document(); |
| 77 DCHECK(!document.needsLayoutTreeUpdate()); | 76 DCHECK(!document.needsLayoutTreeUpdate()); |
| 78 DocumentLifecycle::DisallowTransitionScope disallowTransition( | 77 DocumentLifecycle::DisallowTransitionScope disallowTransition( |
| 79 document.lifecycle()); | 78 document.lifecycle()); |
| 80 | 79 |
| 81 const PositionTemplate<Strategy> deepPosition = | 80 const PositionTemplate<Strategy> deepPosition = |
| 82 canonicalPositionOf(positionWithAffinity.position()); | 81 canonicalPositionOf(positionWithAffinity.position()); |
| 83 if (deepPosition.isNull()) | 82 if (deepPosition.isNull()) |
| 84 return VisiblePositionTemplate<Strategy>(); | 83 return VisiblePositionTemplate<Strategy>(); |
| 85 const PositionWithAffinityTemplate<Strategy> downstreamPosition(deepPosition); | 84 const PositionWithAffinityTemplate<Strategy> downstreamPosition(deepPosition); |
| 86 if (positionWithAffinity.affinity() == TextAffinity::Downstream) | 85 if (positionWithAffinity.affinity() == TextAffinity::Downstream) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 deepEquivalent().showTreeForThis(); | 239 deepEquivalent().showTreeForThis(); |
| 241 } | 240 } |
| 242 | 241 |
| 243 #endif | 242 #endif |
| 244 | 243 |
| 245 template <typename Strategy> | 244 template <typename Strategy> |
| 246 bool VisiblePositionTemplate<Strategy>::isValid() const { | 245 bool VisiblePositionTemplate<Strategy>::isValid() const { |
| 247 #if DCHECK_IS_ON() | 246 #if DCHECK_IS_ON() |
| 248 if (isNull()) | 247 if (isNull()) |
| 249 return true; | 248 return true; |
| 250 Document& document = *m_positionWithAffinity.position().document(); | 249 Document& document = *m_positionWithAffinity.document(); |
| 251 return m_domTreeVersion == document.domTreeVersion() && | 250 return m_domTreeVersion == document.domTreeVersion() && |
| 252 m_styleVersion == document.styleVersion() && | 251 m_styleVersion == document.styleVersion() && |
| 253 !document.needsLayoutTreeUpdate(); | 252 !document.needsLayoutTreeUpdate(); |
| 254 #else | 253 #else |
| 255 return true; | 254 return true; |
| 256 #endif | 255 #endif |
| 257 } | 256 } |
| 258 | 257 |
| 259 template class CORE_TEMPLATE_EXPORT VisiblePositionTemplate<EditingStrategy>; | 258 template class CORE_TEMPLATE_EXPORT VisiblePositionTemplate<EditingStrategy>; |
| 260 template class CORE_TEMPLATE_EXPORT | 259 template class CORE_TEMPLATE_EXPORT |
| (...skipping 19 matching lines...) Expand all Loading... |
| 280 return; | 279 return; |
| 281 } | 280 } |
| 282 DVLOG(0) << "Cannot showTree for (nil) VisiblePosition."; | 281 DVLOG(0) << "Cannot showTree for (nil) VisiblePosition."; |
| 283 } | 282 } |
| 284 | 283 |
| 285 void showTree(const blink::VisiblePosition& vpos) { | 284 void showTree(const blink::VisiblePosition& vpos) { |
| 286 vpos.showTreeForThis(); | 285 vpos.showTreeForThis(); |
| 287 } | 286 } |
| 288 | 287 |
| 289 #endif | 288 #endif |
| OLD | NEW |