summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2012-02-27 18:05:37 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-02-27 18:05:37 -0800
commit7adab1830575d4438d058b5d7f6e932e97451c56 (patch)
treef3fa07f63bed38596c597fe92c4456cab59aa4dd /Source
parentf4e31f648003cd6873ade49cb7b0766b4898912a (diff)
parent9b759976fec55ad944eba534a560c9c83400ed91 (diff)
downloadexternal_webkit-7adab1830575d4438d058b5d7f6e932e97451c56.zip
external_webkit-7adab1830575d4438d058b5d7f6e932e97451c56.tar.gz
external_webkit-7adab1830575d4438d058b5d7f6e932e97451c56.tar.bz2
Merge "Fix content detector crashes"
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/dom/DOMTextContentWalker.cpp13
-rw-r--r--Source/WebKit/android/jni/AndroidHitTestResult.cpp5
2 files changed, 14 insertions, 4 deletions
diff --git a/Source/WebCore/dom/DOMTextContentWalker.cpp b/Source/WebCore/dom/DOMTextContentWalker.cpp
index ccbe1ec..5e77db1 100644
--- a/Source/WebCore/dom/DOMTextContentWalker.cpp
+++ b/Source/WebCore/dom/DOMTextContentWalker.cpp
@@ -44,15 +44,20 @@ DOMTextContentWalker::DOMTextContentWalker(const VisiblePosition& position, unsi
: m_hitOffsetInContent(0)
{
const unsigned halfMaxLength = maxLength / 2;
- CharacterIterator forwardChar(makeRange(position, endOfDocument(position)).get(), TextIteratorStopsOnFormControls);
+ RefPtr<Range> forwardRange = makeRange(position, endOfDocument(position));
+ if (!forwardRange)
+ return;
+ CharacterIterator forwardChar(forwardRange.get(), TextIteratorStopsOnFormControls);
forwardChar.advance(maxLength - halfMaxLength);
// No forward contents, started inside form control.
- RefPtr<Range> range = getRange(position.deepEquivalent(), forwardChar.range()->startPosition());
- if (!range.get() || range->text().length() == 0)
+ if (getRange(position.deepEquivalent(), forwardChar.range()->startPosition())->text().length() == 0)
return;
- BackwardsCharacterIterator backwardsChar(makeRange(startOfDocument(position), position).get(), TextIteratorStopsOnFormControls);
+ RefPtr<Range> backwardsRange = makeRange(startOfDocument(position), position);
+ if (!backwardsRange)
+ return;
+ BackwardsCharacterIterator backwardsChar(backwardsRange.get(), TextIteratorStopsOnFormControls);
backwardsChar.advance(halfMaxLength);
m_hitOffsetInContent = getRange(backwardsChar.range()->endPosition(), position.deepEquivalent())->text().length();
diff --git a/Source/WebKit/android/jni/AndroidHitTestResult.cpp b/Source/WebKit/android/jni/AndroidHitTestResult.cpp
index f5dcc48..16dd809 100644
--- a/Source/WebKit/android/jni/AndroidHitTestResult.cpp
+++ b/Source/WebKit/android/jni/AndroidHitTestResult.cpp
@@ -151,6 +151,11 @@ void AndroidHitTestResult::searchContentDetectors()
{
AddressDetector address;
PhoneEmailDetector phoneEmail;
+ Node* node = m_hitTestResult.innerNode();
+ if (!node || !node->isTextNode())
+ return;
+ if (!m_hitTestResult.absoluteLinkURL().isEmpty())
+ return;
WebKit::WebHitTestInfo webHitTest(m_hitTestResult);
m_searchResult = address.FindTappedContent(webHitTest);
if (!m_searchResult.valid) {