Index: src/orca/scripts/apps/Thunderbird/script.py
===================================================================
--- src/orca/scripts/apps/Thunderbird/script.py	(revision 4071)
+++ src/orca/scripts/apps/Thunderbird/script.py	(working copy)
@@ -499,14 +499,6 @@
             self.sayAll(None)
         self._messageLoaded = False
 
-    def isLineBreakChar(self, obj, offset):
-        """Returns True of the character at the given offset within
-        obj is a newline.
-        """
-
-        char = self.getCharacterAtOffset(obj, offset)
-        return char == "\n"
-
     def getDocumentFrame(self):
         """Returns the document frame that holds the content being shown.
         Overridden here because multiple open messages are not arranged
Index: src/orca/scripts/toolkits/Gecko/script.py
===================================================================
--- src/orca/scripts/toolkits/Gecko/script.py	(revision 4071)
+++ src/orca/scripts/toolkits/Gecko/script.py	(working copy)
@@ -1866,7 +1866,7 @@
                 candidate = candidate.parent
 
             if self.isSameObject(obj, candidate) \
-               and start <= offset <= end:
+               and start <= offset < end:
                 index = contents.index(content)
                 break
 
@@ -3052,29 +3052,6 @@
 
         return isField
 
-    def isLineBreakChar(self, obj, offset):
-        """Returns True of the character at the given offset within
-        obj is a line break character (i.e. <br />) or is a newline
-        character within preformatted text.
-        """
-
-        isBreak = False
-
-        text = self.queryNonEmptyText(obj)
-        if text:
-            char = text.getText(offset, offset + 1)
-            [attributeSet, start, end] = text.getAttributeRun(offset, True)
-            isBreak = 'tag:BR' in attributeSet
-            if not isBreak and char == "\n":
-                attributes = obj.getAttributes()
-                if attributes:
-                    for attribute in attributes:
-                        if attribute == "tag:PRE":
-                            isBreak = True
-                            break
-
-        return isBreak
-
     def isUselessObject(self, obj):
         """Returns true if the given object is an obj that doesn't
         have any meaning associated with it and it is not inside a
@@ -5252,12 +5229,13 @@
 
         prevObj = currentLine[0][0]
         prevOffset = currentLine[0][1]
-        [prevObj, prevOffset] = self.findPreviousCaretInOrder(prevObj,
-                                                              prevOffset)
 
-        if self.isLineBreakChar(prevObj, prevOffset):
-            [prevObj, prevOffset] = self.findPreviousCaretInOrder(prevObj,
-                                                                  prevOffset)
+        extents = self.getExtents(obj, characterOffset, characterOffset + 1)
+        prevExtents = self.getExtents(prevObj, prevOffset, prevOffset + 1)
+        while self.onSameLine(extents, prevExtents):
+            [prevObj, prevOffset] = \
+                self.findPreviousCaretInOrder(prevObj, prevOffset)
+            prevExtents = self.getExtents(prevObj, prevOffset, prevOffset + 1)
 
         # If the user did some back-to-back arrowing, we might already have
         # the line contents.
@@ -5346,15 +5324,13 @@
         nextObj = currentLine[-1][0]
         nextOffset = currentLine[-1][2] - 1
 
-        [nextObj, nextOffset] = self.findNextCaretInOrder(nextObj, nextOffset)
+        extents = self.getExtents(obj, characterOffset, characterOffset + 1)
+        nextExtents = self.getExtents(nextObj, nextOffset, nextOffset + 1)
+        while self.onSameLine(extents, nextExtents):
+            [nextObj, nextOffset] = \
+                self.findNextCaretInOrder(nextObj, nextOffset)
+            nextExtents = self.getExtents(nextObj, nextOffset, nextOffset + 1)
 
-        if self.getCharacterAtOffset(nextObj, nextOffset) == " ":
-            nextOffset += 1
-
-        if self.isLineBreakChar(nextObj, nextOffset):
-            [nextObj, nextOffset] = self.findNextCaretInOrder(nextObj,
-                                                              nextOffset)
-
         # If the user did some back-to-back arrowing, we might already have
         # the line contents.
         #
@@ -5374,8 +5350,10 @@
             #print "find next line failed", nextObj, nextOffset
             [nextObj, nextOffset] = \
                       self.findNextCaretInOrder(nextObj, nextOffset)
-            nextLine = self.getLineContentsAtOffset(nextObj, nextOffset)
-            failureCount += 1
+            if nextObj:
+                nextLine = self.getLineContentsAtOffset(nextObj, nextOffset)
+                failureCount += 1
+
         if currentLine == nextLine:
             #print "find next line still stuck", nextObj, nextOffset
             documentFrame = self.getDocumentFrame()
