Fixed: <rdar://problem/
3781290> REGRESSION (Mail): Crash in ReplaceSelectionCommandImpl attaching file to new message
Reviewed by kocienda.
* khtml/khtml_part.cpp:
(KHTMLPart::setSelection): setFocusNodeIfNeeded now works on the current selection so call setFocusNodeIfNeeded after setting the selection
(KHTMLPart::clearSelection): don't call setFocusNodeIfNeeded with the current selection
(KHTMLPart::setCaretVisible): ditto
(KHTMLPart::setFocusNodeIfNeeded): do nothing if the part isn't focused, work with the current selection
* khtml/khtml_part.h:
* khtml/khtmlpart_p.h:
(KHTMLPartPrivate::KHTMLPartPrivate): added m_isFocused
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::KWQKHTMLPart): removed _displaysWithFocusAttributes this is replaced by m_isFocused
(KWQKHTMLPart::setSelectionFromNone): new, code factored out from setDisplaysWithFocusAttributes
(KWQKHTMLPart::setDisplaysWithFocusAttributes): call setSelectionFromNone
(KWQKHTMLPart::displaysWithFocusAttributes): now returns m_isFocused
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge setSelectionFromNone]): new
WebKit:
Fixed: <rdar://problem/
3781290> REGRESSION (Mail): Crash in ReplaceSelectionCommandImpl attaching file to new message
Reviewed by kocienda.
* WebView.subproj/WebView.m:
(-[WebView setEditable:]): call updateSelectionFromEmpty on the bridge if there is no selection
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7613
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-09-20 Chris Blumenberg <cblu@apple.com>
+
+ Fixed: <rdar://problem/3781290> REGRESSION (Mail): Crash in ReplaceSelectionCommandImpl attaching file to new message
+
+ Reviewed by kocienda.
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::setSelection): setFocusNodeIfNeeded now works on the current selection so call setFocusNodeIfNeeded after setting the selection
+ (KHTMLPart::clearSelection): don't call setFocusNodeIfNeeded with the current selection
+ (KHTMLPart::setCaretVisible): ditto
+ (KHTMLPart::setFocusNodeIfNeeded): do nothing if the part isn't focused, work with the current selection
+ * khtml/khtml_part.h:
+ * khtml/khtmlpart_p.h:
+ (KHTMLPartPrivate::KHTMLPartPrivate): added m_isFocused
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::KWQKHTMLPart): removed _displaysWithFocusAttributes this is replaced by m_isFocused
+ (KWQKHTMLPart::setSelectionFromNone): new, code factored out from setDisplaysWithFocusAttributes
+ (KWQKHTMLPart::setDisplaysWithFocusAttributes): call setSelectionFromNone
+ (KWQKHTMLPart::displaysWithFocusAttributes): now returns m_isFocused
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge setSelectionFromNone]): new
+
2004-09-20 Darin Adler <darin@apple.com>
Reviewed by Dave.
{
if (d->m_selection != s) {
clearCaretRectIfNeeded();
- setFocusNodeIfNeeded(s);
#if APPLE_CHANGES
// Mark misspellings in the soon-to-be previous selection. When typing we check spelling
// elsewhere, so don't redo it here
}
#endif
d->m_selection = s;
+ setFocusNodeIfNeeded();
notifySelectionChanged(closeTyping);
}
}
void KHTMLPart::clearSelection()
{
clearCaretRectIfNeeded();
- setFocusNodeIfNeeded(d->m_selection);
+ setFocusNodeIfNeeded();
d->m_selection = Selection();
notifySelectionChanged();
}
return;
clearCaretRectIfNeeded();
- setFocusNodeIfNeeded(d->m_selection);
+ setFocusNodeIfNeeded();
d->m_caretVisible = flag;
selectionLayoutChanged();
}
}
}
-void KHTMLPart::setFocusNodeIfNeeded(const Selection &s)
+void KHTMLPart::setFocusNodeIfNeeded()
{
- if (!xmlDocImpl() || s.state() == Selection::NONE)
+ if (!xmlDocImpl() || d->m_selection.state() == Selection::NONE || !d->m_isFocused)
return;
- NodeImpl *n = s.start().node();
+ NodeImpl *n = d->m_selection.start().node();
NodeImpl *target = (n && n->isContentEditable()) ? n : 0;
if (!target) {
- while (n && n != s.end().node()) {
+ while (n && n != d->m_selection.end().node()) {
if (n->isContentEditable()) {
target = n;
break;
/**
* @internal
*/
- void setFocusNodeIfNeeded(const DOM::Selection &);
+ void setFocusNodeIfNeeded();
/**
* @internal
}
}
+ m_isFocused = false;
m_focusNodeNumber = -1;
m_focusNodeRestored = false;
m_opener = 0;
bool m_bCleared:1;
bool m_bSecurityInQuestion:1;
bool m_focusNodeRestored:1;
+ bool m_isFocused:1;
khtml::EditCommand m_lastEditCommand;
int m_xPosForVerticalArrowNavigation;
bool m_cancelWithLoadInProgress;
QTimer m_lifeSupportTimer;
+
};
#endif
void setMediaType(const QString &);
+ void setSelectionFromNone();
void setDisplaysWithFocusAttributes(bool flag);
- bool displaysWithFocusAttributes() const { return _displaysWithFocusAttributes; }
+ bool displaysWithFocusAttributes() const;
// Convenience, to avoid repeating the code to dig down to get this.
QChar backslashAsCurrencySymbol() const;
KWQWindowWidget *_windowWidget;
- bool _displaysWithFocusAttributes;
mutable bool _drawSelectionOnly;
bool _haveUndoRedoOperations;
, _formValuesAboutToBeSubmitted(nil)
, _formAboutToBeSubmitted(nil)
, _windowWidget(NULL)
- , _displaysWithFocusAttributes(false)
, _drawSelectionOnly(false)
, _bindingRoot(0)
, _windowScriptObject(0)
}
}
-void KWQKHTMLPart::setDisplaysWithFocusAttributes(bool flag)
+void KWQKHTMLPart::setSelectionFromNone()
{
- if (_displaysWithFocusAttributes == flag)
- return;
- _displaysWithFocusAttributes = flag;
-
- // This method does the job of updating the view based on whether the view is "active".
- // This involves three kinds of drawing updates:
-
- // 1. The background color used to draw behind selected content (active | inactive color)
- if (d->m_view)
- d->m_view->updateContents(QRect(visibleSelectionRect()));
-
- // 2. Caret blinking (blinks | does not blink)
- // Also, put the caret someplace if the selection is empty and the part is editable.
+ // Put the caret someplace if the selection is empty and the part is editable.
// This has the effect of flashing the caret in a contentEditable view automatically
// without requiring the programmer to set a selection explicitly.
DocumentImpl *doc = xmlDocImpl();
- if (doc && flag && selection().state() == Selection::NONE && isContentEditable()) {
+ if (doc && selection().state() == Selection::NONE && isContentEditable()) {
NodeImpl *node = doc->documentElement();
while (node) {
// Look for a block flow, but skip over the HTML element, since we really
if (node)
setSelection(Position(node, 0));
}
- setCaretVisible(flag);
+}
+void KWQKHTMLPart::setDisplaysWithFocusAttributes(bool flag)
+{
+ if (d->m_isFocused == flag)
+ return;
+ d->m_isFocused = flag;
+
+ // This method does the job of updating the view based on whether the view is "active".
+ // This involves three kinds of drawing updates:
+
+ // 1. The background color used to draw behind selected content (active | inactive color)
+ if (d->m_view)
+ d->m_view->updateContents(QRect(visibleSelectionRect()));
+
+ // 2. Caret blinking (blinks | does not blink)
+ if (flag)
+ setSelectionFromNone();
+ setCaretVisible(d->m_isFocused);
+
// 3. The drawing of a focus ring around links in web pages.
+ DocumentImpl *doc = xmlDocImpl();
if (doc) {
NodeImpl *node = doc->focusNode();
if (node && node->renderer())
}
}
+bool KWQKHTMLPart::displaysWithFocusAttributes() const
+{
+ return d->m_isFocused;
+}
+
QChar KWQKHTMLPart::backslashAsCurrencySymbol() const
{
DocumentImpl *doc = xmlDocImpl();
- (NSAttributedString *)selectedAttributedString;
- (NSString *)selectedString;
+- (void)setSelectionFromNone;
- (void)setDisplaysWithFocusAttributes:(BOOL)flag;
- (NSString *)stringForRange:(DOMRange *)range;
return externalRepresentation(_part->renderer()).getNSString();
}
+- (void)setSelectionFromNone
+{
+ _part->setSelectionFromNone();
+}
+
- (void)setDisplaysWithFocusAttributes:(BOOL)flag
{
_part->setDisplaysWithFocusAttributes(flag);
+2004-09-20 Chris Blumenberg <cblu@apple.com>
+
+ Fixed: <rdar://problem/3781290> REGRESSION (Mail): Crash in ReplaceSelectionCommandImpl attaching file to new message
+
+ Reviewed by kocienda.
+
+ * WebView.subproj/WebView.m:
+ (-[WebView setEditable:]): call updateSelectionFromEmpty on the bridge if there is no selection
+
2004-09-20 Chris Blumenberg <cblu@apple.com>
Changes to implement renamed bridge methods.
- (void)setEditable:(BOOL)flag
{
- _private->editable = flag;
+ if (_private->editable != flag) {
+ _private->editable = flag;
+ if (flag && [self selectedDOMRange] == nil) {
+ // If the WebView is made editable and the selection is empty, set it to something.
+ [[[self mainFrame] _bridge] setSelectionFromNone];
+ }
+ }
}
- (BOOL)isEditable