summaryrefslogtreecommitdiffstats
path: root/WebCore/editing
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/editing')
-rw-r--r--WebCore/editing/ApplyStyleCommand.cpp18
-rw-r--r--WebCore/editing/ApplyStyleCommand.h13
-rw-r--r--WebCore/editing/CompositeEditCommand.cpp4
-rw-r--r--WebCore/editing/DeleteButtonController.cpp2
-rw-r--r--WebCore/editing/DeleteSelectionCommand.cpp4
-rw-r--r--WebCore/editing/IndentOutdentCommand.cpp8
-rw-r--r--WebCore/editing/InsertParagraphSeparatorCommand.cpp2
-rw-r--r--WebCore/editing/RemoveFormatCommand.cpp2
-rw-r--r--WebCore/editing/ReplaceNodeWithSpanCommand.cpp1
-rw-r--r--WebCore/editing/ReplaceSelectionCommand.cpp8
-rw-r--r--WebCore/editing/SelectionController.cpp2
-rw-r--r--WebCore/editing/VisiblePosition.h1
-rw-r--r--WebCore/editing/brew/EditorBrew.cpp39
-rw-r--r--WebCore/editing/markup.cpp16
-rw-r--r--WebCore/editing/markup.h2
15 files changed, 88 insertions, 34 deletions
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index 529d9d3..c50c988 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -416,7 +416,7 @@ static const int editingStyleProperties[] = {
};
size_t numEditingStyleProperties = sizeof(editingStyleProperties)/sizeof(editingStyleProperties[0]);
-PassRefPtr<CSSMutableStyleDeclaration> editingStyleAtPosition(Position pos, ShouldIncludeTypingStyle shouldIncludeTypingStyle)
+PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::editingStyleAtPosition(Position pos, ShouldIncludeTypingStyle shouldIncludeTypingStyle)
{
RefPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = pos.computedStyle();
RefPtr<CSSMutableStyleDeclaration> style;
@@ -454,7 +454,7 @@ void prepareEditingStyleToApplyAt(CSSMutableStyleDeclaration* editingStyle, Posi
// ReplaceSelectionCommand::handleStyleSpans() requires that this function only removes the editing style.
// If this function was modified in the future to delete all redundant properties, then add a boolean value to indicate
// which one of editingStyleAtPosition or computedStyle is called.
- RefPtr<CSSMutableStyleDeclaration> style = editingStyleAtPosition(pos);
+ RefPtr<CSSMutableStyleDeclaration> style = ApplyStyleCommand::editingStyleAtPosition(pos);
style->diff(editingStyle);
// if alpha value is zero, we don't add the background color.
@@ -472,8 +472,8 @@ void removeStylesAddedByNode(CSSMutableStyleDeclaration* editingStyle, Node* nod
{
ASSERT(node);
ASSERT(node->parentNode());
- RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleAtPosition(Position(node->parentNode(), 0));
- RefPtr<CSSMutableStyleDeclaration> style = editingStyleAtPosition(Position(node, 0));
+ RefPtr<CSSMutableStyleDeclaration> parentStyle = ApplyStyleCommand::editingStyleAtPosition(Position(node->parentNode(), 0));
+ RefPtr<CSSMutableStyleDeclaration> style = ApplyStyleCommand::editingStyleAtPosition(Position(node, 0));
parentStyle->diff(style.get());
style->diff(editingStyle);
}
@@ -619,7 +619,11 @@ void ApplyStyleCommand::applyBlockStyle(CSSMutableStyleDeclaration *style)
if (!m_removeOnly)
addBlockStyle(styleChange, static_cast<HTMLElement*>(block.get()));
}
+
+ if (nextParagraphStart.isOrphan())
+ nextParagraphStart = endOfParagraph(paragraphStart).next();
}
+
paragraphStart = nextParagraphStart;
nextParagraphStart = endOfParagraph(paragraphStart).next();
}
@@ -1753,10 +1757,10 @@ void ApplyStyleCommand::addBlockStyle(const StyleChange& styleChange, HTMLElemen
setNodeAttribute(block, styleAttr, cssText);
}
-static bool fontColorChangesComputedStyle(RenderStyle* computedStyle, StyleChange styleChange)
+static bool fontColorChangesComputedStyle(const Color& computedStyleColor, StyleChange styleChange)
{
if (styleChange.applyFontColor()) {
- if (Color(styleChange.fontColor()) != computedStyle->color())
+ if (Color(styleChange.fontColor()) != computedStyleColor)
return true;
}
return false;
@@ -1797,7 +1801,7 @@ void ApplyStyleCommand::addInlineStyleIfNeeded(CSSMutableStyleDeclaration *style
// We only want to insert a font element if it will end up changing the style of the
// text somehow. Otherwise it will be a garbage node that will create problems for us
// most notably when we apply a blockquote style for a message reply.
- if (fontColorChangesComputedStyle(computedStyle, styleChange)
+ if (fontColorChangesComputedStyle(computedStyle->color(), styleChange)
|| fontFaceChangesComputedStyle(computedStyle, styleChange)
|| fontSizeChangesComputedStyle(computedStyle, styleChange)) {
if (styleChange.applyFontColor())
diff --git a/WebCore/editing/ApplyStyleCommand.h b/WebCore/editing/ApplyStyleCommand.h
index 2804604..8326329 100644
--- a/WebCore/editing/ApplyStyleCommand.h
+++ b/WebCore/editing/ApplyStyleCommand.h
@@ -34,6 +34,11 @@ class CSSPrimitiveValue;
class HTMLElement;
class StyleChange;
+enum ShouldIncludeTypingStyle {
+ IncludeTypingStyle,
+ IgnoreTypingStyle
+};
+
class ApplyStyleCommand : public CompositeEditCommand {
public:
enum EPropertyLevel { PropertyDefault, ForceBlockProperties };
@@ -50,6 +55,8 @@ public:
{
return adoptRef(new ApplyStyleCommand(element, removeOnly, action));
}
+
+ static PassRefPtr<CSSMutableStyleDeclaration> editingStyleAtPosition(Position pos, ShouldIncludeTypingStyle shouldIncludeTypingStyle = IgnoreTypingStyle);
private:
ApplyStyleCommand(Document*, CSSStyleDeclaration*, EditAction, EPropertyLevel);
@@ -117,12 +124,6 @@ bool isStyleSpan(const Node*);
PassRefPtr<HTMLElement> createStyleSpanElement(Document*);
RefPtr<CSSMutableStyleDeclaration> getPropertiesNotInComputedStyle(CSSStyleDeclaration* style, CSSComputedStyleDeclaration* computedStyle);
-enum ShouldIncludeTypingStyle {
- IncludeTypingStyle,
- IgnoreTypingStyle
-};
-
-PassRefPtr<CSSMutableStyleDeclaration> editingStyleAtPosition(Position, ShouldIncludeTypingStyle = IgnoreTypingStyle);
void prepareEditingStyleToApplyAt(CSSMutableStyleDeclaration*, Position);
void removeStylesAddedByNode(CSSMutableStyleDeclaration*, Node*);
diff --git a/WebCore/editing/CompositeEditCommand.cpp b/WebCore/editing/CompositeEditCommand.cpp
index 9dc918d..e33f143 100644
--- a/WebCore/editing/CompositeEditCommand.cpp
+++ b/WebCore/editing/CompositeEditCommand.cpp
@@ -940,7 +940,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
// too, <div><b><br></b></div> for example. Save it so that we can preserve it later.
RefPtr<CSSMutableStyleDeclaration> styleInEmptyParagraph;
if (startOfParagraphToMove == endOfParagraphToMove && preserveStyle) {
- styleInEmptyParagraph = editingStyleAtPosition(startOfParagraphToMove.deepEquivalent(), IncludeTypingStyle);
+ styleInEmptyParagraph = ApplyStyleCommand::editingStyleAtPosition(startOfParagraphToMove.deepEquivalent(), IncludeTypingStyle);
// The moved paragraph should assume the block style of the destination.
styleInEmptyParagraph->removeBlockProperties();
}
@@ -1003,7 +1003,7 @@ bool CompositeEditCommand::breakOutOfEmptyListItem()
if (!emptyListItem)
return false;
- RefPtr<CSSMutableStyleDeclaration> style = editingStyleAtPosition(endingSelection().start(), IncludeTypingStyle);
+ RefPtr<CSSMutableStyleDeclaration> style = ApplyStyleCommand::editingStyleAtPosition(endingSelection().start(), IncludeTypingStyle);
Node* listNode = emptyListItem->parentNode();
// FIXME: Can't we do something better when the immediate parent wasn't a list node?
diff --git a/WebCore/editing/DeleteButtonController.cpp b/WebCore/editing/DeleteButtonController.cpp
index d999f84..24c8270 100644
--- a/WebCore/editing/DeleteButtonController.cpp
+++ b/WebCore/editing/DeleteButtonController.cpp
@@ -133,7 +133,7 @@ static bool isDeletableElement(const Node* node)
if (!parentStyle)
return false;
- if (style->hasBackground() && (!parentStyle->hasBackground() || style->backgroundColor() != parentStyle->backgroundColor()))
+ if (renderer->hasBackground() && (!parentRenderer->hasBackground() || style->visitedDependentColor(CSSPropertyBackgroundColor) != parentStyle->visitedDependentColor(CSSPropertyBackgroundColor)))
return true;
}
diff --git a/WebCore/editing/DeleteSelectionCommand.cpp b/WebCore/editing/DeleteSelectionCommand.cpp
index 5e81d50..623b188 100644
--- a/WebCore/editing/DeleteSelectionCommand.cpp
+++ b/WebCore/editing/DeleteSelectionCommand.cpp
@@ -294,14 +294,14 @@ void DeleteSelectionCommand::saveTypingStyleState()
return;
// Figure out the typing style in effect before the delete is done.
- m_typingStyle = editingStyleAtPosition(positionBeforeTabSpan(m_selectionToDelete.start()));
+ m_typingStyle = ApplyStyleCommand::editingStyleAtPosition(positionBeforeTabSpan(m_selectionToDelete.start()));
removeEnclosingAnchorStyle(m_typingStyle.get(), m_selectionToDelete.start());
// If we're deleting into a Mail blockquote, save the style at end() instead of start()
// We'll use this later in computeTypingStyleAfterDelete if we end up outside of a Mail blockquote
if (nearestMailBlockquote(m_selectionToDelete.start().node()))
- m_deleteIntoBlockquoteStyle = editingStyleAtPosition(m_selectionToDelete.end());
+ m_deleteIntoBlockquoteStyle = ApplyStyleCommand::editingStyleAtPosition(m_selectionToDelete.end());
else
m_deleteIntoBlockquoteStyle = 0;
}
diff --git a/WebCore/editing/IndentOutdentCommand.cpp b/WebCore/editing/IndentOutdentCommand.cpp
index 0f3975b..9830ca0 100644
--- a/WebCore/editing/IndentOutdentCommand.cpp
+++ b/WebCore/editing/IndentOutdentCommand.cpp
@@ -75,12 +75,8 @@ bool IndentOutdentCommand::tryIndentingAsListItem(const VisiblePosition& endOfCu
if (!listNode)
return false;
- // Find the list item enclosing the current paragraph
+ // Find the block that we want to indent. If it's not a list item (e.g., a div inside a list item), we bail out.
Element* selectedListItem = static_cast<Element*>(enclosingBlock(lastNodeInSelectedParagraph));
- // FIXME: enclosingBlock shouldn't return the passed in element. See the
- // comment on the function about how to fix rather than having to adjust here.
- if (selectedListItem == lastNodeInSelectedParagraph)
- selectedListItem = static_cast<Element*>(enclosingBlock(lastNodeInSelectedParagraph->parentNode()));
// FIXME: we need to deal with the case where there is no li (malformed HTML)
if (!selectedListItem->hasTagName(liTag))
@@ -117,7 +113,7 @@ void IndentOutdentCommand::indentIntoBlockquote(const VisiblePosition& endOfCurr
else
nodeToSplitTo = editableRootForPosition(start);
- RefPtr<Node> outerBlock = splitTreeToNode(start.node(), nodeToSplitTo);
+ RefPtr<Node> outerBlock = (start.node() == nodeToSplitTo) ? start.node() : splitTreeToNode(start.node(), nodeToSplitTo);
if (!targetBlockquote) {
// Create a new blockquote and insert it as a child of the root editable element. We accomplish
diff --git a/WebCore/editing/InsertParagraphSeparatorCommand.cpp b/WebCore/editing/InsertParagraphSeparatorCommand.cpp
index affb639..47c6efd 100644
--- a/WebCore/editing/InsertParagraphSeparatorCommand.cpp
+++ b/WebCore/editing/InsertParagraphSeparatorCommand.cpp
@@ -82,7 +82,7 @@ void InsertParagraphSeparatorCommand::calculateStyleBeforeInsertion(const Positi
if (!isStartOfParagraph(visiblePos) && !isEndOfParagraph(visiblePos))
return;
- m_style = editingStyleAtPosition(pos, IncludeTypingStyle);
+ m_style = ApplyStyleCommand::editingStyleAtPosition(pos, IncludeTypingStyle);
}
void InsertParagraphSeparatorCommand::applyStyleAfterInsertion(Node* originalEnclosingBlock)
diff --git a/WebCore/editing/RemoveFormatCommand.cpp b/WebCore/editing/RemoveFormatCommand.cpp
index 9243adc..e456df6 100644
--- a/WebCore/editing/RemoveFormatCommand.cpp
+++ b/WebCore/editing/RemoveFormatCommand.cpp
@@ -56,7 +56,7 @@ void RemoveFormatCommand::doApply()
// Get the default style for this editable root, it's the style that we'll give the
// content that we're operating on.
Node* root = frame->selection()->rootEditableElement();
- RefPtr<CSSMutableStyleDeclaration> defaultStyle = editingStyleAtPosition(Position(root, 0));
+ RefPtr<CSSMutableStyleDeclaration> defaultStyle = ApplyStyleCommand::editingStyleAtPosition(Position(root, 0));
// Delete the selected content.
// FIXME: We should be able to leave this to insertText, but its delete operation
diff --git a/WebCore/editing/ReplaceNodeWithSpanCommand.cpp b/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
index 0874201..c3b6b89 100644
--- a/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
+++ b/WebCore/editing/ReplaceNodeWithSpanCommand.cpp
@@ -34,7 +34,6 @@
#include "htmlediting.h"
#include "HTMLElement.h"
#include "HTMLNames.h"
-#include "NamedAttrMap.h"
#include <wtf/Assertions.h>
diff --git a/WebCore/editing/ReplaceSelectionCommand.cpp b/WebCore/editing/ReplaceSelectionCommand.cpp
index e4acf85..2f0bddf 100644
--- a/WebCore/editing/ReplaceSelectionCommand.cpp
+++ b/WebCore/editing/ReplaceSelectionCommand.cpp
@@ -577,7 +577,7 @@ static bool handleStyleSpansBeforeInsertion(ReplacementFragment& fragment, const
Node* sourceDocumentStyleSpan = topNode;
RefPtr<Node> copiedRangeStyleSpan = sourceDocumentStyleSpan->firstChild();
- RefPtr<CSSMutableStyleDeclaration> styleAtInsertionPos = editingStyleAtPosition(rangeCompliantEquivalent(insertionPos));
+ RefPtr<CSSMutableStyleDeclaration> styleAtInsertionPos = ApplyStyleCommand::editingStyleAtPosition(rangeCompliantEquivalent(insertionPos));
String styleText = styleAtInsertionPos->cssText();
@@ -634,8 +634,8 @@ void ReplaceSelectionCommand::handleStyleSpans()
// styles from blockquoteNode are allowed to override those from the source document, see <rdar://problem/4930986> and <rdar://problem/5089327>.
Node* blockquoteNode = isMailPasteAsQuotationNode(context) ? context : nearestMailBlockquote(context);
if (blockquoteNode) {
- RefPtr<CSSMutableStyleDeclaration> blockquoteStyle = editingStyleAtPosition(Position(blockquoteNode, 0));
- RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleAtPosition(Position(blockquoteNode->parentNode(), 0));
+ RefPtr<CSSMutableStyleDeclaration> blockquoteStyle = ApplyStyleCommand::editingStyleAtPosition(Position(blockquoteNode, 0));
+ RefPtr<CSSMutableStyleDeclaration> parentStyle = ApplyStyleCommand::editingStyleAtPosition(Position(blockquoteNode->parentNode(), 0));
parentStyle->diff(blockquoteStyle.get());
CSSMutableStyleDeclaration::const_iterator end = blockquoteStyle->end();
@@ -794,7 +794,7 @@ void ReplaceSelectionCommand::doApply()
return;
if (m_matchStyle)
- m_insertionStyle = editingStyleAtPosition(selection.start(), IncludeTypingStyle);
+ m_insertionStyle = ApplyStyleCommand::editingStyleAtPosition(selection.start(), IncludeTypingStyle);
VisiblePosition visibleStart = selection.visibleStart();
VisiblePosition visibleEnd = selection.visibleEnd();
diff --git a/WebCore/editing/SelectionController.cpp b/WebCore/editing/SelectionController.cpp
index 002226d..db0e04d 100644
--- a/WebCore/editing/SelectionController.cpp
+++ b/WebCore/editing/SelectionController.cpp
@@ -1082,7 +1082,7 @@ void SelectionController::paintCaret(GraphicsContext* context, int tx, int ty, c
ColorSpace colorSpace = DeviceColorSpace;
Element* element = rootEditableElement();
if (element && element->renderer()) {
- caretColor = element->renderer()->style()->color();
+ caretColor = element->renderer()->style()->visitedDependentColor(CSSPropertyColor);
colorSpace = element->renderer()->style()->colorSpace();
}
diff --git a/WebCore/editing/VisiblePosition.h b/WebCore/editing/VisiblePosition.h
index d888806..fe795a1 100644
--- a/WebCore/editing/VisiblePosition.h
+++ b/WebCore/editing/VisiblePosition.h
@@ -61,6 +61,7 @@ public:
bool isNull() const { return m_deepPosition.isNull(); }
bool isNotNull() const { return m_deepPosition.isNotNull(); }
+ bool isOrphan() const { return m_deepPosition.isOrphan(); }
Position deepEquivalent() const { return m_deepPosition; }
EAffinity affinity() const { ASSERT(m_affinity == UPSTREAM || m_affinity == DOWNSTREAM); return m_affinity; }
diff --git a/WebCore/editing/brew/EditorBrew.cpp b/WebCore/editing/brew/EditorBrew.cpp
new file mode 100644
index 0000000..b610b62
--- /dev/null
+++ b/WebCore/editing/brew/EditorBrew.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Company 100, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Editor.h"
+
+#include "ClipboardBrew.h"
+
+namespace WebCore {
+
+PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
+{
+ return new ClipboardBrew(policy, false);
+}
+
+} // namespace WebCore
diff --git a/WebCore/editing/markup.cpp b/WebCore/editing/markup.cpp
index 606f141..46f0e94 100644
--- a/WebCore/editing/markup.cpp
+++ b/WebCore/editing/markup.cpp
@@ -49,6 +49,7 @@
#include "HTMLElement.h"
#include "HTMLNames.h"
#include "InlineTextBox.h"
+#include "KURL.h"
#include "Logging.h"
#include "ProcessingInstruction.h"
#include "QualifiedName.h"
@@ -1018,7 +1019,7 @@ String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
// Add a wrapper span with the styles that all of the nodes in the markup inherit.
Node* parentOfLastClosed = lastClosed ? lastClosed->parentNode() : 0;
if (parentOfLastClosed && parentOfLastClosed->renderer()) {
- RefPtr<CSSMutableStyleDeclaration> style = editingStyleAtPosition(Position(parentOfLastClosed, 0));
+ RefPtr<CSSMutableStyleDeclaration> style = ApplyStyleCommand::editingStyleAtPosition(Position(parentOfLastClosed, 0));
// Styles that Mail blockquotes contribute should only be placed on the Mail blockquote, to help
// us differentiate those styles from ones that the user has applied. This helps us
@@ -1042,7 +1043,7 @@ String createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotateForInterc
// Add a style span with the document's default styles. We add these in a separate
// span so that at paste time we can differentiate between document defaults and user
// applied styles.
- RefPtr<CSSMutableStyleDeclaration> defaultStyle = editingStyleAtPosition(Position(document->documentElement(), 0));
+ RefPtr<CSSMutableStyleDeclaration> defaultStyle = ApplyStyleCommand::editingStyleAtPosition(Position(document->documentElement(), 0));
if (defaultStyle->length() > 0)
addStyleMarkup(preMarkups, markups, defaultStyle.get(), document);
@@ -1287,4 +1288,15 @@ String createFullMarkup(const Range* range)
return frame->documentTypeString() + createMarkup(range, 0, AnnotateForInterchange);
}
+String urlToMarkup(const KURL& url, const String& title)
+{
+ Vector<UChar> markup;
+ append(markup, "<a href=\"");
+ append(markup, url.string());
+ append(markup, "\">");
+ appendEscapedContent(markup, make_pair(title.characters(), title.length()), false);
+ append(markup, "</a>");
+ return String::adopt(markup);
+}
+
}
diff --git a/WebCore/editing/markup.h b/WebCore/editing/markup.h
index 5ace04a..dd34159 100644
--- a/WebCore/editing/markup.h
+++ b/WebCore/editing/markup.h
@@ -35,6 +35,7 @@ namespace WebCore {
class Document;
class DocumentFragment;
+ class KURL;
class Node;
class Range;
class String;
@@ -54,6 +55,7 @@ namespace WebCore {
String createFullMarkup(const Node*);
String createFullMarkup(const Range*);
+ String urlToMarkup(const KURL&, const String& title);
}
#endif // markup_h