Reviewed by Maciej.
<rdar://problem/
4671286> Candidate Window isn't displayed and only first candidate is displayed at typing location.
Updated test so that it actually shows the caret rect for the caret position.
Before, it was showing the caret rect for the 9th character of the test description.
* fast/text/justified-text-rect-expected.checksum:
* fast/text/justified-text-rect-expected.png:
* fast/text/justified-text-rect-expected.txt:
* fast/text/justified-text-rect.html:
WebCore:
Reviewed by Maciej.
<rdar://problem/
4671286> Candidate Window isn't displayed and only first candidate is displayed at typing location.
Updated test:
* fast/text/justified-text-rect.html
* bridge/mac/WebCoreFrameBridge.mm:
(-[WebCoreFrameBridge convertToNSRange:]):
(-[WebCoreFrameBridge convertToDOMRange:]):
Make the selection's root editable element (or the document itself) be
the basis for NSRange conversions. This supports "shadow DOM" like
that for text fields and text areas.
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::moveParagraphs):
Pass the document element as the scope.
* editing/TextIterator.cpp:
(WebCore::TextIterator::rangeFromLocationAndLength):
Make the first parameter the scope.
* editing/TextIterator.h:
Make the first parameter of rangeFromLocationAndLength() the scope.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16737
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-10-03 David Harrison <harrison@apple.com>
+
+ Reviewed by Maciej.
+
+ <rdar://problem/4671286> Candidate Window isn't displayed and only first candidate is displayed at typing location.
+
+ Updated test so that it actually shows the caret rect for the caret position.
+ Before, it was showing the caret rect for the 9th character of the test description.
+
+ * fast/text/justified-text-rect-expected.checksum:
+ * fast/text/justified-text-rect-expected.png:
+ * fast/text/justified-text-rect-expected.txt:
+ * fast/text/justified-text-rect.html:
+
2006-10-02 Justin Garcia <justin.garcia@apple.com>
Reviewed by john
-a29ef9f14534f7c1ec660153a7e26d2b
\ No newline at end of file
+913f637b065759f731e303b8e54a4007
\ No newline at end of file
text run at (0,18) width 50: "justified"
RenderBlock (anonymous) at (0,136) size 800x18
RenderText {#text} at (0,0) size 76x18
- text run at (0,0) width 76: "53,582,4,18"
+ text run at (0,0) width 76: "38,512,4,18"
RenderText {#text} at (0,0) size 0x0
RenderText {#text} at (0,0) size 0x0
caret: position 8 of child 0 {#text} of child 3 {P} of child 1 {BODY} of child 0 {HTML} of document
var s = window.getSelection();
var e = document.getElementById("testspan");
s.setPosition(e, 0);
- rect = textInputController.firstRectForCharacterRange(9, 1);
+ rect = textInputController.firstRectForCharacterRange(8, 1);
document.write(rect);
- } catch (ex) {
- document.write("Exception: " + ex.description);
- }
- } else {
- document.write("(cannot run interactively)");
- }
+ } catch (ex) {
+ document.write("Exception: " + ex.description);
+ }
+ } else {
+ document.write("(cannot run interactively)");
+ }
</script>
</body>
</html>
+2006-10-03 David Harrison <harrison@apple.com>
+
+ Reviewed by Maciej.
+
+ <rdar://problem/4671286> Candidate Window isn't displayed and only first candidate is displayed at typing location.
+
+ Updated test:
+ * fast/text/justified-text-rect.html
+
+ * bridge/mac/WebCoreFrameBridge.mm:
+ (-[WebCoreFrameBridge convertToNSRange:]):
+ (-[WebCoreFrameBridge convertToDOMRange:]):
+ Make the selection's root editable element (or the document itself) be
+ the basis for NSRange conversions. This supports "shadow DOM" like
+ that for text fields and text areas.
+
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::CompositeEditCommand::moveParagraphs):
+ Pass the document element as the scope.
+
+ * editing/TextIterator.cpp:
+ (WebCore::TextIterator::rangeFromLocationAndLength):
+ Make the first parameter the scope.
+
+ * editing/TextIterator.h:
+ Make the first parameter of rangeFromLocationAndLength() the scope.
+
2006-10-03 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Eric.
- (NSRange)convertToNSRange:(Range *)range
{
- if (!range || range->isDetached()) {
- return NSMakeRange(NSNotFound, 0);
- }
-
- RefPtr<Range> fromStartRange(m_frame->document()->createRange());
int exception = 0;
- fromStartRange->setEnd(range->startContainer(exception), range->startOffset(exception), exception);
- int startPosition = TextIterator::rangeLength(fromStartRange.get());
+ if (!range || range->isDetached())
+ return NSMakeRange(NSNotFound, 0);
+
+ Element* selectionRoot = m_frame->selectionController()->rootEditableElement();
+ Element* scope = selectionRoot ? selectionRoot : m_frame->document()->documentElement();
+
+ // our critical assumption is that we are only called by input methods that
+ // concentrate on a given area containing the selection. See comments in convertToDOMRange.
+ ASSERT(range->startContainer(exception) == scope || range->startContainer(exception)->isDescendantOf(scope));
+ ASSERT(range->endContainer(exception) == scope || range->endContainer(exception)->isDescendantOf(scope));
+
+ RefPtr<Range> testRange = new Range(scope->document(), scope, 0, range->startContainer(exception), range->startOffset(exception));
+ ASSERT(testRange->startContainer(exception) == scope);
+ int startPosition = TextIterator::rangeLength(testRange.get());
- fromStartRange->setEnd(range->endContainer(exception), range->endOffset(exception), exception);
- int endPosition = TextIterator::rangeLength(fromStartRange.get());
+ testRange->setEnd(range->endContainer(exception), range->endOffset(exception), exception);
+ ASSERT(testRange->startContainer(exception) == scope);
+ int endPosition = TextIterator::rangeLength(testRange.get());
return NSMakeRange(startPosition, endPosition - startPosition);
}
if (nsrange.length > INT_MAX || nsrange.location + nsrange.length > INT_MAX)
nsrange.length = INT_MAX - nsrange.location;
- return TextIterator::rangeFromLocationAndLength(m_frame->document(), nsrange.location, nsrange.length);
+ // our critical assumption is that we are only called by input methods that
+ // concentrate on a given area containing the selection
+ // We have to do this because of text fields and textareas. The DOM for those is not
+ // directly in the document DOM, so serialization is problematic. Our solution is
+ // to use the root editable element of the selection start as the positional base.
+ // That fits with AppKit's idea of an input context.
+ Element* selectionRoot = m_frame->selectionController()->rootEditableElement();
+ Element* scope = selectionRoot ? selectionRoot : m_frame->document()->documentElement();
+ return TextIterator::rangeFromLocationAndLength(scope, nsrange.location, nsrange.length);
}
- (DOMRange *)convertNSRangeToDOMRange:(NSRange)nsrange
applyCommandToComposite(new ReplaceSelectionCommand(document(), fragment.get(), true, false, !preserveStyle, false));
if (preserveSelection && startIndex != -1) {
- setEndingSelection(Selection(TextIterator::rangeFromLocationAndLength(document(), destinationIndex + startIndex, 0)->startPosition(),
- TextIterator::rangeFromLocationAndLength(document(), destinationIndex + endIndex, 0)->startPosition(),
+ setEndingSelection(Selection(TextIterator::rangeFromLocationAndLength(document()->documentElement(), destinationIndex + startIndex, 0)->startPosition(),
+ TextIterator::rangeFromLocationAndLength(document()->documentElement(), destinationIndex + endIndex, 0)->startPosition(),
DOWNSTREAM));
}
}
return length;
}
-PassRefPtr<Range> TextIterator::rangeFromLocationAndLength(Document *doc, int rangeLocation, int rangeLength)
+PassRefPtr<Range> TextIterator::rangeFromLocationAndLength(Element *scope, int rangeLocation, int rangeLength)
{
- RefPtr<Range> resultRange = doc->createRange();
+ RefPtr<Range> resultRange = scope->document()->createRange();
int docTextPosition = 0;
int rangeEnd = rangeLocation + rangeLength;
RefPtr<Range> textRunRange;
- TextIterator it(rangeOfContents(doc).get());
+ TextIterator it(rangeOfContents(scope).get());
// FIXME: the atEnd() check shouldn't be necessary, workaround for <http://bugzilla.opendarwin.org/show_bug.cgi?id=6289>.
if (rangeLocation == 0 && rangeLength == 0 && it.atEnd()) {
PassRefPtr<Range> range() const;
static int rangeLength(const Range *r);
- static PassRefPtr<Range> rangeFromLocationAndLength(Document *doc, int rangeLocation, int rangeLength);
+ static PassRefPtr<Range> rangeFromLocationAndLength(Element *scope, int rangeLocation, int rangeLength);
private:
void exitNode();