Reviewed by harrison
* editing/selection/focus-body-expected.checksum: Added.
* editing/selection/focus-body-expected.png: Added.
* editing/selection/focus-body-expected.txt: Added.
* editing/selection/focus-body.html: Added.
* editing/selection/focus_editable_html-expected.checksum:
* editing/selection/focus_editable_html-expected.png:
* editing/selection/focus_editable_html-expected.txt:
WebCore:
Reviewed by harrison
<rdar://problem/
4567752> When forwarding a message, pressing TAB key to place caret in body actually selects the entire message instead
* dom/Element.cpp:
(WebCore::Element::focus):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14666
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-06-01 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by harrison
+
+ * editing/selection/focus-body-expected.checksum: Added.
+ * editing/selection/focus-body-expected.png: Added.
+ * editing/selection/focus-body-expected.txt: Added.
+ * editing/selection/focus-body.html: Added.
+ * editing/selection/focus_editable_html-expected.checksum:
+ * editing/selection/focus_editable_html-expected.png:
+ * editing/selection/focus_editable_html-expected.txt:
+
2006-06-01 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
--- /dev/null
+644ab869c9d1c6eed300c149d45f701c
\ No newline at end of file
--- /dev/null
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 2 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderText {#text} at (0,0) size 438x18
+ text run at (0,0) width 220: "This test focuses an editable body. "
+ text run at (220,0) width 218: "Its contents should not be selected."
+ RenderText {#text} at (0,0) size 0x0
+caret: position 0 of child 0 {#text} of child 0 {BODY} of child 0 {HTML} of document
--- /dev/null
+<body contenteditable="true">This test focuses an editable body. Its contents should not be selected.
+<script>
+document.body.focus();
+</script>
+</body>
\ No newline at end of file
-9e5e54bf429185536353247bf42831c1
\ No newline at end of file
+64766d8472ce9c0a9a039ab9874f480d
\ No newline at end of file
EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of HTML > #document to 1 of HTML > #document
EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > BODY > HTML > #document to 42 of #text > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of BODY > HTML > #document to 0 of BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
layer at (0,0) size 2008x2088
RenderCanvas at (0,0) size 785x585
RenderText {#text} at (0,0) size 237x18
text run at (0,0) width 237: "If the document scrolls here, test fails."
RenderText {#text} at (0,0) size 0x0
-selection start: position 1 of child 0 {#text} of child 0 {BODY} of child 0 {HTML} of document
-selection end: position 42 of child 8 {#text} of child 0 {BODY} of child 0 {HTML} of document
-scrolled to 0,8
+caret: position 1 of child 0 {#text} of child 0 {BODY} of child 0 {HTML} of document
+2006-06-01 Justin Garcia <justin.garcia@apple.com>
+
+ Reviewed by harrison
+
+ <rdar://problem/4567752> When forwarding a message, pressing TAB key to place caret in body actually selects the entire message instead
+
+ * dom/Element.cpp:
+ (WebCore::Element::focus):
+
2006-06-01 David Kilzer <ddkilzer@kilzer.net>
Reviewed by darin.
#include "HTMLNames.h"
#include "NamedAttrMap.h"
#include "RenderBlock.h"
+#include "SelectionController.h"
#include "KWQTextStream.h"
namespace WebCore {
void Element::focus()
{
+ if (!isFocusable())
+ return;
+
Document* doc = document();
doc->updateLayout();
- if (isFocusable()) {
- doc->setFocusNode(this);
- if (rootEditableElement() == this) {
- // FIXME: we should restore the previous selection if there is one, instead of always selecting all.
- if (doc->frame()->selectContentsOfNode(this))
- doc->frame()->revealSelection();
- } else if (renderer() && !renderer()->isWidget())
- renderer()->enclosingLayer()->scrollRectToVisible(getRect());
- }
+
+ doc->setFocusNode(this);
+
+ if (this == rootEditableElement()) {
+ Frame* frame = doc->frame();
+ if (!frame)
+ return;
+
+ // FIXME: We should restore the previous selection if there is one.
+ Selection s = hasTagName(htmlTag) || hasTagName(bodyTag) ? Selection(Position(this, 0), DOWNSTREAM) : Selection::selectionFromContentsOfNode(this);
+ SelectionController sc(s);
+
+ if (frame->shouldChangeSelection(sc)) {
+ frame->setSelection(sc);
+ frame->revealSelection();
+ }
+ } else if (renderer() && !renderer()->isWidget())
+ renderer()->enclosingLayer()->scrollRectToVisible(getRect());
}
void Element::blur()