RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (0,0) size 784x56 [border: (2px solid #FF0000)]
- RenderInline {SPAN} at (0,0) size 167x28
- RenderText {TEXT} at (14,14) size 118x28
- text run at (14,14) width 118: "here is xxxx"
- RenderInline {I} at (0,0) size 6x28
- RenderText {TEXT} at (132,14) size 6x28
- text run at (132,14) width 6: " "
- RenderText {TEXT} at (138,14) size 43x28
- text run at (138,14) width 43: " text"
+ RenderInline {SPAN} at (0,0) size 157x28
+ RenderText {TEXT} at (14,14) size 70x28
+ text run at (14,14) width 70: "here is "
+ RenderInline {I} at (0,0) size 44x28
+ RenderText {TEXT} at (84,14) size 44x28
+ text run at (84,14) width 44: "xxxx"
+ RenderText {TEXT} at (128,14) size 43x28
+ text run at (128,14) width 43: " text"
RenderText {TEXT} at (0,0) size 0x0
selection is CARET:
-start: position 12 of child 1 {TEXT} of child 2 {SPAN} of root {DIV}
-upstream: position 12 of child 1 {TEXT} of child 2 {SPAN} of root {DIV}
-downstream: position 0 of child 1 {TEXT} of child 2 {I} of child 2 {SPAN} of root {DIV}
+start: position 4 of child 1 {TEXT} of child 2 {I} of child 2 {SPAN} of root {DIV}
+upstream: position 4 of child 1 {TEXT} of child 2 {I} of child 2 {SPAN} of root {DIV}
+downstream: position 0 of child 3 {TEXT} of child 2 {SPAN} of root {DIV}
+2004-08-19 Ken Kocienda <kocienda@apple.com>
+
+ Reviewed by Darin
+
+ * khtml/css/css_computedstyle.cpp:
+ (DOM::): Changed CopyProperties constant to InheritableProperties. This reflects the
+ name change of copy() to copyInheritableProperties()
+ (DOM::CSSComputedStyleDeclarationImpl::copyInheritableProperties: Renamed from copy().
+ Now just copies those properties which can be inherited.
+ (DOM::CSSComputedStyleDeclarationImpl::diff): Add a couple null checks.
+ * khtml/css/css_computedstyle.h: copyInheritableProperties name change. No longer needs to be virtual.
+ * khtml/css/css_valueimpl.cpp: Removed unneeded copy() function from CSSStyleDeclarationImpl.
+ * khtml/css/css_valueimpl.h: Ditto.
+ * khtml/editing/htmlediting.cpp:
+ (khtml::EditCommand::typingStyle): Added.
+ (khtml::EditCommand::setTypingStyle): Added.
+ * khtml/editing/htmlediting.h:
+ * khtml/editing/htmlediting_impl.cpp:
+ (khtml::StyleChange::currentlyHasStyle): Fix leak of computed style used in this function.
+ (khtml::EditCommandImpl::EditCommandImpl): Initialize m_typingStyle.
+ (khtml::EditCommandImpl::~EditCommandImpl): Deref m_typingStyle.
+ (khtml::EditCommandImpl::assignTypingStyle): New helper used in setting typing style.
+ (khtml::EditCommandImpl::setTypingStyle): New setter.
+ (khtml::DeleteSelectionCommandImpl::doApply): Use new method for managing typing style.
+ * khtml/editing/htmlediting_impl.h:
+ (khtml::EditCommandImpl::typingStyle): New accessor.
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::appliedEditing): Restores typing style from command after setting selection.
+ (KHTMLPart::applyStyle): Does a diff between the current style and the style of the caret.
+ * khtml/khtml_part.h:
+ * khtml/xml/dom_position.cpp:
+ (DOM::Position::computedStyle): Now returns a CSSComputedStyleDeclarationImpl instead of a plain
+ CSSStyleDeclarationImpl.
+ * khtml/xml/dom_position.h:
+ * layout-tests/editing/style/style-3681552-fix-002-expected.txt:
+
2004-08-20 Trey Matteson <trey@apple.com>
3655407 - Editing: -complete: method unimplemented (WebKit editing API)
(DOM::XSLTProcessorImpl::transformDocument):
* khtml/xsl/xslt_processorimpl.h:
+>>>>>>> 1.3109
=== Safari-158 ===
2004-08-18 Trey Matteson <trey@apple.com>
2004-08-18 Richard Williamson <rjw@apple.com>
+<<<<<<< ChangeLog
+ Replace horrible pollForAppletInView: with new
+ webPlugInGetApplet. The details of how the applet instance
+ is provided now belong to the Java team. Yeh.
+
+ Reviewed by Chris.
+
+=======
Replace horrible pollForAppletInView: with new
webPlugInGetApplet. The details of how the applet instance
is provided now belong to the Java team. Yeh.
Reviewed by Chris.
+>>>>>>> 1.3109
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::getAppletInstanceForView):
* kwq/WebCoreBridge.h:
#include "cssproperties.h"
#include "dom_atomicstring.h"
+#include "dom_string.h"
#include "font.h"
#include "khtmllayout.h"
#include "loader.h"
namespace DOM {
-static const int CopyProperties[] = {
- CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING,
- CSS_PROP__KHTML_BORDER_VERTICAL_SPACING,
- CSS_PROP_BACKGROUND_ATTACHMENT,
- CSS_PROP_BACKGROUND_COLOR,
- CSS_PROP_BACKGROUND_IMAGE,
- CSS_PROP_BACKGROUND_POSITION_X,
- CSS_PROP_BACKGROUND_POSITION_Y,
- CSS_PROP_BACKGROUND_POSITION,
- CSS_PROP_BACKGROUND_REPEAT,
- CSS_PROP_BORDER_BOTTOM_COLOR,
- CSS_PROP_BORDER_BOTTOM_STYLE,
- CSS_PROP_BORDER_BOTTOM_WIDTH,
+// This is the list of properties we want to copy in the copyInheritableProperties() function.
+// It is the intersection of the list of inherited CSS properties and the
+// properties for which we have a computed implementation in this file.
+static const int InheritableProperties[] = {
CSS_PROP_BORDER_COLLAPSE,
- CSS_PROP_BORDER_LEFT_COLOR,
- CSS_PROP_BORDER_LEFT_STYLE,
- CSS_PROP_BORDER_LEFT_WIDTH,
- CSS_PROP_BORDER_RIGHT_COLOR,
- CSS_PROP_BORDER_RIGHT_STYLE,
- CSS_PROP_BORDER_RIGHT_WIDTH,
CSS_PROP_BORDER_SPACING,
- CSS_PROP_BORDER_TOP_COLOR,
- CSS_PROP_BORDER_TOP_STYLE,
- CSS_PROP_BORDER_TOP_WIDTH,
CSS_PROP_COLOR,
- CSS_PROP_DISPLAY,
- CSS_PROP_FLOAT,
CSS_PROP_FONT_FAMILY,
CSS_PROP_FONT_SIZE,
CSS_PROP_FONT_STYLE,
CSS_PROP_FONT_VARIANT,
CSS_PROP_FONT_WEIGHT,
- CSS_PROP_HEIGHT,
CSS_PROP_LETTER_SPACING,
CSS_PROP_LINE_HEIGHT,
- CSS_PROP_MARGIN_BOTTOM,
- CSS_PROP_MARGIN_LEFT,
- CSS_PROP_MARGIN_RIGHT,
- CSS_PROP_MARGIN_TOP,
- CSS_PROP_OVERFLOW,
- CSS_PROP_PADDING_BOTTOM,
- CSS_PROP_PADDING_LEFT,
- CSS_PROP_PADDING_RIGHT,
- CSS_PROP_PADDING_TOP,
CSS_PROP_TEXT_ALIGN,
- CSS_PROP_TEXT_DECORATION,
CSS_PROP_TEXT_INDENT,
- CSS_PROP_VERTICAL_ALIGN,
CSS_PROP_WHITE_SPACE,
- CSS_PROP_WIDTH,
CSS_PROP_WORD_SPACING,
};
return prop;
}
-CSSStyleDeclarationImpl *CSSComputedStyleDeclarationImpl::copy() const
+CSSStyleDeclarationImpl *CSSComputedStyleDeclarationImpl::copyInheritableProperties() const
{
QPtrList<CSSProperty> *list = new QPtrList<CSSProperty>;
- for (unsigned i = 0; i < sizeof(CopyProperties) / sizeof(CopyProperties[0]); i++) {
- CSSProperty *property = new CSSProperty;
- property->m_id = CopyProperties[i];
- property->setValue(getPropertyCSSValue(CopyProperties[i]));
- list->append(property);
+ list->setAutoDelete(true);
+ for (unsigned i = 0; i < sizeof(InheritableProperties) / sizeof(InheritableProperties[0]); i++) {
+ CSSValueImpl *value = getPropertyCSSValue(InheritableProperties[i]);
+ if (value) {
+ CSSProperty *property = new CSSProperty;
+ property->m_id = InheritableProperties[i];
+ property->setValue(value);
+ list->append(property);
+ }
}
return new CSSStyleDeclarationImpl(0, list);
}
void CSSComputedStyleDeclarationImpl::diff(CSSStyleDeclarationImpl *style) const
{
+ if (!style)
+ return;
+
QValueList<int> properties;
for (QPtrListIterator<CSSProperty> it(*style->values()); it.current(); ++it) {
CSSProperty *property = it.current();
CSSValueImpl *value = getPropertyCSSValue(property->id());
- if (value->cssText() == property->value()->cssText()) {
+ if (value && value->cssText() == property->value()->cssText()) {
properties.append(property->id());
}
}
virtual void setProperty(const DOMString &propertyString);
virtual DOMString item(unsigned long index) const;
- virtual CSSStyleDeclarationImpl *copy() const;
+ CSSStyleDeclarationImpl *copyInheritableProperties() const;
void diff(CSSStyleDeclarationImpl *) const;
private:
}
}
-CSSStyleDeclarationImpl *CSSStyleDeclarationImpl::copy() const
-{
- QPtrList<CSSProperty> *list = new QPtrList<CSSProperty>;
- list->setAutoDelete(true);
- for (QPtrListIterator<CSSProperty> it(*values()); it.current(); ++it) {
- CSSProperty *property = it.current();
- if (getPropertyCSSValue(property->id())) {
- list->append(new CSSProperty(*property));
- }
- }
- return new CSSStyleDeclarationImpl(0, list);
-}
-
// --------------------------------------------------------------------------------------
CSSValueImpl::CSSValueImpl()
void merge(CSSStyleDeclarationImpl *, bool argOverridesOnConflict=true);
- virtual CSSStyleDeclarationImpl *copy() const;
-
void setChanged();
protected:
get()->setEndingSelection(s);
}
+CSSStyleDeclarationImpl *EditCommand::typingStyle() const
+{
+ IF_IMPL_NULL_RETURN_ARG(0);
+ return get()->typingStyle();
+}
+
+void EditCommand::setTypingStyle(CSSStyleDeclarationImpl *style)
+{
+ IF_IMPL_NULL_RETURN;
+ get()->setTypingStyle(style);
+}
+
EditCommand EditCommand::parent() const
{
IF_IMPL_NULL_RETURN_ARG(0);
virtual void setStartingSelection(const DOM::Selection &s) = 0;
virtual void setEndingSelection(const DOM::Selection &s) = 0;
+ virtual DOM::CSSStyleDeclarationImpl *typingStyle() const = 0;
+ virtual void setTypingStyle(DOM::CSSStyleDeclarationImpl *) = 0;
+
virtual EditCommand parent() const = 0;
virtual void setParent(const EditCommand &) = 0;
};
void setStartingSelection(const DOM::Selection &s);
void setEndingSelection(const DOM::Selection &s);
+ DOM::CSSStyleDeclarationImpl *typingStyle() const;
+ void setTypingStyle(DOM::CSSStyleDeclarationImpl *);
+
EditCommand parent() const;
void setParent(const EditCommand &);
#include "htmlediting_impl.h"
#include "cssproperties.h"
+#include "css/css_computedstyle.h"
#include "css/css_valueimpl.h"
#include "dom/css_value.h"
#include "dom/dom_position.h"
#endif
using DOM::AttrImpl;
+using DOM::CSSComputedStyleDeclarationImpl;
using DOM::CSSPrimitiveValue;
using DOM::CSSPrimitiveValueImpl;
using DOM::CSSProperty;
bool StyleChange::currentlyHasStyle(const Position &pos, const CSSProperty *property)
{
ASSERT(pos.notEmpty());
- CSSStyleDeclarationImpl *style = pos.computedStyle();
+ CSSComputedStyleDeclarationImpl *style = pos.computedStyle();
ASSERT(style);
+ style->ref();
CSSValueImpl *value = style->getPropertyCSSValue(property->id());
+ style->deref();
return strcasecmp(value->cssText(), property->value()->cssText()) == 0;
}
// EditCommandImpl
EditCommandImpl::EditCommandImpl(DocumentImpl *document)
- : SharedCommandImpl(), m_document(document), m_state(NotApplied), m_parent(0)
+ : SharedCommandImpl(), m_document(document), m_state(NotApplied), m_typingStyle(0), m_parent(0)
{
ASSERT(m_document);
ASSERT(m_document->part());
{
ASSERT(m_document);
m_document->deref();
+ if (m_typingStyle)
+ m_typingStyle->deref();
}
int EditCommandImpl::commandID() const
m_state = Applied;
+ // The delete selection command is a special case where we want the
+ // typing style retained. For all other commands, clear it after
+ // applying.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
+ if (commandID() != DeleteSelectionCommandID)
+ setTypingStyle(0);
+
if (!isCompositeStep()) {
EditCommand cmd(this);
m_document->part()->appliedEditing(cmd);
}
}
+void EditCommandImpl::assignTypingStyle(DOM::CSSStyleDeclarationImpl *style)
+{
+ CSSStyleDeclarationImpl *old = m_typingStyle;
+ m_typingStyle = style;
+ if (m_typingStyle)
+ m_typingStyle->ref();
+ if (old)
+ old->deref();
+}
+
+void EditCommandImpl::setTypingStyle(CSSStyleDeclarationImpl *style)
+{
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
+ assignTypingStyle(style);
+ EditCommand cmd = parent();
+ while (cmd.notNull()) {
+ cmd.handle()->assignTypingStyle(style);
+ cmd = cmd.parent();
+ }
+}
+
void EditCommandImpl::markMisspellingsInSelection(const Selection &s)
{
KWQ(document()->part())->markMisspellingsInSelection(s);
// and ApplyStyleCommandImpl::computeStyleChange.
// Both function do similar work, and the common parts could be factored out.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
StyleChange styleChange(document()->part()->typingStyle());
NodeImpl *childToAppend = child;
// be nice to be able to deal with this, but for now, bail.
return;
- //
- // Figure out the typing style and set it on the part.
- // This point in the code is a "bottleneck" that takes care
- // of updating the typing style for the delete key, the return
- // key, typed characters, and other deleting functions like the
- // cut command.
- //
- document()->part()->setTypingStyle(computeTypingStyle(downstreamStart));
+ // Figure out the typing style in effect before the delete is done.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
+ CSSComputedStyleDeclarationImpl *computedStyle = downstreamStart.computedStyle();
+ computedStyle->ref();
+ CSSStyleDeclarationImpl *style = computedStyle->copyInheritableProperties();
+ style->ref();
+ computedStyle->deref();
NodeImpl *startNode = upstreamStart.node();
int startOffset = upstreamStart.offset();
}
}
+ // Compute the difference between the style before the delete and the style now
+ // after the delete has been done. Set this style on the part, so other editing
+ // commands being composed with this one will work, and also cache it on the command,
+ // so the KHTMLPart::appliedEditing can set it after the whole composite command
+ // has completed.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
+ CSSComputedStyleDeclarationImpl endingStyle(endingPosition.node());
+ endingStyle.diff(style);
+ document()->part()->setTypingStyle(style);
+ setTypingStyle(style);
+ style->deref();
+
setEndingSelection(endingPosition);
}
NodeImpl *nodeToInsert = breakNode;
// Handle the case where there is a typing style.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
CSSStyleDeclarationImpl *typingStyle = document()->part()->typingStyle();
if (typingStyle && typingStyle->length() > 0)
nodeToInsert = applyTypingStyle(breakNode);
NodeImpl *nodeToInsert = textNode;
// Handle the case where there is a typing style.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
CSSStyleDeclarationImpl *typingStyle = document()->part()->typingStyle();
if (typingStyle && typingStyle->length() > 0)
nodeToInsert = applyTypingStyle(textNode);
}
else {
// Handle the case where there is a typing style.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
CSSStyleDeclarationImpl *typingStyle = document()->part()->typingStyle();
if (typingStyle && typingStyle->length() > 0) {
if (pos.node()->isTextNode() && pos.offset() > pos.node()->caretMinOffset() && pos.offset() < pos.node()->caretMaxOffset()) {
if (selection.state() == Selection::RANGE)
deleteSelection();
+ // This command does not use any typing style that is set as a residual effect of
+ // a delete.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
+ document()->part()->clearTypingStyle();
+ setTypingStyle(0);
+
selection = endingSelection();
ASSERT(!selection.isEmpty());
// TypingCommandImpl
TypingCommandImpl::TypingCommandImpl(DocumentImpl *document, TypingCommand::ETypingCommand commandType, const DOM::DOMString &textToInsert)
- : CompositeEditCommandImpl(document), m_commandType(commandType), m_textToInsert(textToInsert), m_openForMoreTyping(true)
+ : CompositeEditCommandImpl(document), m_commandType(commandType), m_textToInsert(textToInsert), m_openForMoreTyping(true), m_applyEditing(false)
{
}
void TypingCommandImpl::typingAddedToOpenCommand()
{
- ASSERT(document());
- ASSERT(document()->part());
markMisspellingsAfterTyping();
- EditCommand cmd(this);
- document()->part()->appliedEditing(cmd);
+ // Do not apply editing to the part on the first time through.
+ // The part will get told in the same way as all other commands.
+ // But since this command stays open and is used for additional typing,
+ // we need to tell the part here as other commands are added.
+ if (m_applyEditing) {
+ EditCommand cmd(this);
+ document()->part()->appliedEditing(cmd);
+ }
+ m_applyEditing = true;
}
void TypingCommandImpl::insertText(const DOMString &text)
{
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
if (document()->part()->typingStyle() || m_cmds.count() == 0) {
InputTextCommand cmd(document());
applyCommandToComposite(cmd);
void setStartingSelection(const DOM::Selection &s);
void setEndingSelection(const DOM::Selection &s);
+
+ DOM::CSSStyleDeclarationImpl *typingStyle() const { return m_typingStyle; };
+ void setTypingStyle(DOM::CSSStyleDeclarationImpl *);
void markMisspellingsInSelection(const DOM::Selection &s);
private:
+ void assignTypingStyle(DOM::CSSStyleDeclarationImpl *);
+
DOM::DocumentImpl *m_document;
ECommandState m_state;
DOM::Selection m_startingSelection;
DOM::Selection m_endingSelection;
+ DOM::CSSStyleDeclarationImpl *m_typingStyle;
EditCommand m_parent;
};
TypingCommand::ETypingCommand m_commandType;
DOM::DOMString m_textToInsert;
bool m_openForMoreTyping;
+ bool m_applyEditing;
};
//------------------------------------------------------------------------------------------
#include "xml/dom_selection.h"
#include "xml/dom2_eventsimpl.h"
#include "xml/xml_tokenizer.h"
+#include "css/css_computedstyle.h"
#include "css/cssstyleselector.h"
#include "css/csshelper.h"
#include "misc/khtml_text_operations.h"
void KHTMLPart::appliedEditing(EditCommand &cmd)
{
setSelection(cmd.endingSelection(), false);
+
+ // Now set the typing style from the command. Clear it when done.
+ // This helps make the case work where you completely delete a piece
+ // of styled text and then type a character immediately after.
+ // That new character needs to take on the style of the just-deleted text.
+ // FIXME: Improve typing style.
+ // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
+ if (cmd.typingStyle()) {
+ setTypingStyle(cmd.typingStyle());
+ cmd.setTypingStyle(0);
+ }
+
// Command will be equal to last edit command only in the case of typing
if (d->m_lastEditCommand == cmd) {
assert(cmd.commandID() == khtml::TypingCommandID);
case Selection::NONE:
// do nothing
break;
- case Selection::CARET:
- if (typingStyle())
+ case Selection::CARET: {
+ if (typingStyle()) {
typingStyle()->merge(style);
- else
- setTypingStyle(style);
+ style = typingStyle();
+ }
+ CSSComputedStyleDeclarationImpl diff(selection().start().upstream(StayInBlock).node());
+ diff.diff(style);
+ setTypingStyle(style);
break;
+ }
case Selection::RANGE:
if (xmlDocImpl() && style) {
ApplyStyleCommand cmd(xmlDocImpl(), style);
namespace DOM
{
+ class CSSComputedStyleDeclarationImpl;
class CSSStyleDeclarationImpl;
class DocumentImpl;
class EventListener;
#include "dom_position.h"
+#include "css_computedstyle.h"
#include "css_valueimpl.h"
#include "dom2_viewsimpl.h"
#include "helper.h"
return static_cast<ElementImpl *>(n);
}
-CSSStyleDeclarationImpl *Position::computedStyle() const
+CSSComputedStyleDeclarationImpl *Position::computedStyle() const
{
if (isEmpty())
return 0;
-
+
ElementImpl *elem = element();
if (!elem)
return 0;
- return elem->getDocument()->defaultView()->getComputedStyle(elem, 0);
+ return new CSSComputedStyleDeclarationImpl(elem);
}
long Position::renderedOffset() const
namespace DOM {
+class CSSComputedStyleDeclarationImpl;
class CSSStyleDeclarationImpl;
class ElementImpl;
class NodeImpl;
long offset() const { return m_offset; }
ElementImpl *element() const;
- CSSStyleDeclarationImpl *computedStyle() const;
+ CSSComputedStyleDeclarationImpl *computedStyle() const;
long renderedOffset() const;