summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/editing/VisibleSelection.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-18 13:36:51 +0100
committerSteve Block <steveblock@google.com>2011-05-24 15:38:28 +0100
commit2fc2651226baac27029e38c9d6ef883fa32084db (patch)
treee396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebCore/editing/VisibleSelection.cpp
parentb3725cedeb43722b3b175aaeff70552e562d2c94 (diff)
downloadexternal_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz
external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebCore/editing/VisibleSelection.cpp')
-rw-r--r--Source/WebCore/editing/VisibleSelection.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/Source/WebCore/editing/VisibleSelection.cpp b/Source/WebCore/editing/VisibleSelection.cpp
index 035afb8..9096dc5 100644
--- a/Source/WebCore/editing/VisibleSelection.cpp
+++ b/Source/WebCore/editing/VisibleSelection.cpp
@@ -26,7 +26,6 @@
#include "config.h"
#include "VisibleSelection.h"
-#include "CharacterNames.h"
#include "Document.h"
#include "Element.h"
#include "htmlediting.h"
@@ -34,10 +33,10 @@
#include "VisiblePosition.h"
#include "visible_units.h"
#include "Range.h"
-
+#include <stdio.h>
#include <wtf/Assertions.h>
#include <wtf/text/CString.h>
-#include <stdio.h>
+#include <wtf/unicode/CharacterNames.h>
namespace WebCore {
@@ -173,6 +172,9 @@ PassRefPtr<Range> VisibleSelection::toNormalizedRange() const
s = s.parentAnchoredEquivalent();
e = e.parentAnchoredEquivalent();
}
+
+ if (s.isNull() || e.isNull())
+ return 0;
// VisibleSelections are supposed to always be valid. This constructor will ASSERT
// if a valid range could not be created, which is fine for this callsite.
@@ -432,7 +434,6 @@ void VisibleSelection::setWithoutValidation(const Position& base, const Position
{
ASSERT(!base.isNull());
ASSERT(!extent.isNull());
- ASSERT(base != extent);
ASSERT(m_affinity == DOWNSTREAM);
m_base = base;
m_extent = extent;
@@ -444,7 +445,7 @@ void VisibleSelection::setWithoutValidation(const Position& base, const Position
m_start = extent;
m_end = base;
}
- m_selectionType = RangeSelection;
+ m_selectionType = base == extent ? CaretSelection : RangeSelection;
}
void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
@@ -526,13 +527,13 @@ void VisibleSelection::adjustSelectionToAvoidCrossingEditingBoundaries()
Position p = nextVisuallyDistinctCandidate(m_start);
Node* shadowAncestor = startRoot ? startRoot->shadowAncestorNode() : 0;
if (p.isNull() && startRoot && (shadowAncestor != startRoot))
- p = Position(shadowAncestor, 0);
+ p = positionBeforeNode(shadowAncestor);
while (p.isNotNull() && !(lowestEditableAncestor(p.node()) == baseEditableAncestor && !isEditablePosition(p))) {
Node* root = editableRootForPosition(p);
shadowAncestor = root ? root->shadowAncestorNode() : 0;
p = isAtomicNode(p.node()) ? positionInParentAfterNode(p.node()) : nextVisuallyDistinctCandidate(p);
if (p.isNull() && (shadowAncestor != root))
- p = Position(shadowAncestor, 0);
+ p = positionBeforeNode(shadowAncestor);
}
VisiblePosition next(p);