Reviewed by Harrison
Fix for this bug:
<rdar://problem/
3655241> setTypingStyle: does not set the real typing style, and typingStyle does not return it
* khtml/khtml_part.cpp:
(KHTMLPart::computeAndSetTypingStyle): New helper that does the work of reducing a passed-in style
declaration given the current selection, and then sets the minimum necessary style as the typing
style on the part.
(KHTMLPart::applyStyle): Call new computeAndSetTypingStyle. The guts of computeAndSetTypingStyle used
to be here in the selection-as-caret case. But now [WebCoreBridge setTypingStyle:] needs this code
as well.
* khtml/khtml_part.h: Declare new computeAndSetTypingStyle() function.
* kwq/WebCoreBridge.h: Declare new typingStyle and setTypingStyle: methods.
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge typingStyle]): Calls through to the part to retrieve the typing style.
(-[WebCoreBridge setTypingStyle:]): Calls through to the part to set the typing style.
WebKit:
Reviewed by Harrison
Fix for this bug:
<rdar://problem/
3655241> setTypingStyle: does not set the real typing style, and typingStyle does not return it
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge respondToChangedContents]): No longer call through to WebKit to set the typing style. The call
was part of the misguided use of the setTypingStyle: and typingStyle as a cache of what was stored on
the WebCore side.
(-[WebBridge respondToChangedSelection]): Ditto.
* WebView.subproj/WebView.m:
(-[WebViewPrivate dealloc]): Object no longer has typingStyle ivar.
(-[WebView setTypingStyle:]): Call over the bridge to set typing style.
(-[WebView typingStyle]): Call over the bridge to retrieve typing style.
* WebView.subproj/WebViewInternal.h: Object no longer has typingStyle ivar.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8047
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-11-19 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Harrison
+
+ Fix for this bug:
+
+ <rdar://problem/3655241> setTypingStyle: does not set the real typing style, and typingStyle does not return it
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::computeAndSetTypingStyle): New helper that does the work of reducing a passed-in style
+ declaration given the current selection, and then sets the minimum necessary style as the typing
+ style on the part.
+ (KHTMLPart::applyStyle): Call new computeAndSetTypingStyle. The guts of computeAndSetTypingStyle used
+ to be here in the selection-as-caret case. But now [WebCoreBridge setTypingStyle:] needs this code
+ as well.
+ * khtml/khtml_part.h: Declare new computeAndSetTypingStyle() function.
+ * kwq/WebCoreBridge.h: Declare new typingStyle and setTypingStyle: methods.
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge typingStyle]): Calls through to the part to retrieve the typing style.
+ (-[WebCoreBridge setTypingStyle:]): Calls through to the part to set the typing style.
+
2004-11-18 David Harrison <harrison@apple.com>
Reviewed by Darin.
#endif
+void KHTMLPart::computeAndSetTypingStyle(CSSStyleDeclarationImpl *style)
+{
+ if (!style || style->length() == 0) {
+ clearTypingStyle();
+ return;
+ }
+
+ // Calculate the current typing style.
+ CSSMutableStyleDeclarationImpl *mutableStyle = style->makeMutable();
+ mutableStyle->ref();
+ if (typingStyle()) {
+ typingStyle()->merge(mutableStyle);
+ mutableStyle->deref();
+ mutableStyle = typingStyle();
+ mutableStyle->ref();
+ }
+ CSSComputedStyleDeclarationImpl computedStyle(selection().start().upstream(StayInBlock).node());
+ computedStyle.diff(mutableStyle);
+
+ // Handle block styles, substracting these from the typing style.
+ CSSMutableStyleDeclarationImpl *blockStyle = mutableStyle->copyBlockProperties();
+ blockStyle->ref();
+ blockStyle->diff(mutableStyle);
+ if (xmlDocImpl() && blockStyle->length() > 0) {
+ EditCommandPtr cmd(new ApplyStyleCommand(xmlDocImpl(), blockStyle));
+ cmd.apply();
+ }
+ blockStyle->deref();
+
+ // Set the remaining style as the typing style.
+ setTypingStyle(mutableStyle);
+ mutableStyle->deref();
+}
+
void KHTMLPart::applyStyle(CSSStyleDeclarationImpl *style)
{
switch (selection().state()) {
// do nothing
break;
case Selection::CARET: {
- // Calculate the current typing style.
- CSSMutableStyleDeclarationImpl *mutableStyle = style->makeMutable();
- mutableStyle->ref();
- if (typingStyle()) {
- typingStyle()->merge(mutableStyle);
- mutableStyle->deref();
- mutableStyle = typingStyle();
- mutableStyle->ref();
- }
- CSSComputedStyleDeclarationImpl computedStyle(selection().start().upstream(StayInBlock).node());
- computedStyle.diff(mutableStyle);
-
- // Handle block styles, substracting these from the typing style.
- CSSMutableStyleDeclarationImpl *blockStyle = mutableStyle->copyBlockProperties();
- blockStyle->ref();
- blockStyle->diff(mutableStyle);
- if (xmlDocImpl() && blockStyle->length() > 0) {
- EditCommandPtr cmd(new ApplyStyleCommand(xmlDocImpl(), blockStyle));
- cmd.apply();
- }
- blockStyle->deref();
-
- // Set the remaining style as the typing style.
- setTypingStyle(mutableStyle);
- mutableStyle->deref();
+ computeAndSetTypingStyle(style);
break;
}
case Selection::RANGE:
void undo();
bool canRedo() const;
bool canUndo() const;
+ void computeAndSetTypingStyle(DOM::CSSStyleDeclarationImpl *);
void applyStyle(DOM::CSSStyleDeclarationImpl *);
TriState selectionHasStyle(DOM::CSSStyleDeclarationImpl *) const;
bool selectionStartHasStyle(DOM::CSSStyleDeclarationImpl *) const;
- (void)deleteSelectionWithSmartDelete:(BOOL)smartDelete;
- (void)deleteKeyPressed;
+- (DOMCSSStyleDeclaration *)typingStyle;
+- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style;
- (void)applyStyle:(DOMCSSStyleDeclaration *)style;
- (BOOL)selectionStartHasStyle:(DOMCSSStyleDeclaration *)style;
- (void)applyEditingStyleToBodyElement;
[self ensureSelectionVisible];
}
+- (DOMCSSStyleDeclaration *)typingStyle
+{
+ if (!_part || !_part->typingStyle())
+ return nil;
+ return [DOMCSSStyleDeclaration _styleDeclarationWithImpl:_part->typingStyle()];
+}
+
+- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style
+{
+ if (!_part)
+ return;
+ _part->computeAndSetTypingStyle([style _styleDeclarationImpl]);
+}
+
- (void)applyStyle:(DOMCSSStyleDeclaration *)style
{
if (!_part)
+2004-11-19 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Harrison
+
+ Fix for this bug:
+
+ <rdar://problem/3655241> setTypingStyle: does not set the real typing style, and typingStyle does not return it
+
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge respondToChangedContents]): No longer call through to WebKit to set the typing style. The call
+ was part of the misguided use of the setTypingStyle: and typingStyle as a cache of what was stored on
+ the WebCore side.
+ (-[WebBridge respondToChangedSelection]): Ditto.
+ * WebView.subproj/WebView.m:
+ (-[WebViewPrivate dealloc]): Object no longer has typingStyle ivar.
+ (-[WebView setTypingStyle:]): Call over the bridge to set typing style.
+ (-[WebView typingStyle]): Call over the bridge to retrieve typing style.
+ * WebView.subproj/WebViewInternal.h: Object no longer has typingStyle ivar.
+
2004-11-18 John Sullivan <sullivan@apple.com>
Reviewed by Darin.
if ([view isKindOfClass:[WebHTMLView class]]) {
[(WebHTMLView *)view _updateFontPanel];
}
- [[_frame webView] setTypingStyle:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidChangeNotification object:[_frame webView]];
}
if ([view isKindOfClass:[WebHTMLView class]]) {
[(WebHTMLView *)view _selectionChanged];
}
- [[_frame webView] setTypingStyle:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:WebViewDidChangeSelectionNotification object:[_frame webView]];
}
[progressItems release];
[mediaStyle release];
- [typingStyle release];
[super dealloc];
}
- (void)setTypingStyle:(DOMCSSStyleDeclaration *)style
{
- // FIXME: We do nothing with this typing style right now other than store it.
- if (style == _private->typingStyle)
- return;
-
- DOMCSSStyleDeclaration *oldStyle = _private->typingStyle;
- _private->typingStyle = [style retain];
- if (oldStyle)
- [oldStyle release];
+ [[self _bridgeForCurrentSelection] setTypingStyle:style];
}
- (DOMCSSStyleDeclaration *)typingStyle
{
- // FIXME: We do nothing with this typing style right now other than store it.
- return _private->typingStyle;
+ return [[self _bridgeForCurrentSelection] typingStyle];
}
- (void)setSmartInsertDeleteEnabled:(BOOL)flag
unsigned int dragDestinationActionMask;
WebBridge *dragCaretBridge;
- DOMCSSStyleDeclaration *typingStyle;
-
BOOL hasSpellCheckerDocumentTag;
int spellCheckerDocumentTag;