summaryrefslogtreecommitdiffstats
path: root/WebCore/editing/InsertTextCommand.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
commit635860845790a19bf50bbc51ba8fb66a96dde068 (patch)
treeef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/editing/InsertTextCommand.cpp
parent8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff)
downloadexternal_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/editing/InsertTextCommand.cpp')
-rw-r--r--WebCore/editing/InsertTextCommand.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/WebCore/editing/InsertTextCommand.cpp b/WebCore/editing/InsertTextCommand.cpp
index a831859..46e9a94 100644
--- a/WebCore/editing/InsertTextCommand.cpp
+++ b/WebCore/editing/InsertTextCommand.cpp
@@ -27,8 +27,9 @@
#include "InsertTextCommand.h"
#include "CharacterNames.h"
-#include "CSSMutableStyleDeclaration.h"
#include "CSSComputedStyleDeclaration.h"
+#include "CSSMutableStyleDeclaration.h"
+#include "CSSPropertyNames.h"
#include "Document.h"
#include "Element.h"
#include "EditingText.h"
@@ -55,13 +56,6 @@ void InsertTextCommand::doApply()
Position InsertTextCommand::prepareForTextInsertion(const Position& p)
{
Position pos = p;
- // If an anchor was removed and the selection hasn't changed, we restore it.
- RefPtr<Node> anchor = document()->frame()->editor()->removedAnchor();
- if (anchor) {
- insertNodeAt(anchor.get(), pos);
- document()->frame()->editor()->setRemovedAnchor(0);
- pos = Position(anchor.get(), 0);
- }
// Prepare for text input by looking at the specified position.
// It may be necessary to insert a text node to receive characters.
if (!pos.node()->isTextNode()) {
@@ -147,10 +141,7 @@ void InsertTextCommand::input(const String& originalText, bool selectInsertedTex
if (!startPosition.isCandidate())
startPosition = startPosition.downstream();
- // FIXME: This typing around anchor behavior doesn't exactly match TextEdit. In TextEdit,
- // you won't be placed inside a link when typing after it if you've just placed the caret
- // there with the mouse.
- startPosition = positionAvoidingSpecialElementBoundary(startPosition, false);
+ startPosition = positionAvoidingSpecialElementBoundary(startPosition);
Position endPosition;
@@ -188,8 +179,23 @@ void InsertTextCommand::input(const String& originalText, bool selectInsertedTex
// Handle the case where there is a typing style.
CSSMutableStyleDeclaration* typingStyle = document()->frame()->typingStyle();
RefPtr<CSSComputedStyleDeclaration> endingStyle = endPosition.computedStyle();
+ RefPtr<CSSValue> unicodeBidi;
+ RefPtr<CSSValue> direction;
+ if (typingStyle) {
+ unicodeBidi = typingStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi);
+ direction = typingStyle->getPropertyCSSValue(CSSPropertyDirection);
+ }
endingStyle->diff(typingStyle);
- if (typingStyle && typingStyle->length() > 0)
+ if (typingStyle && unicodeBidi) {
+ ASSERT(unicodeBidi->isPrimitiveValue());
+ typingStyle->setProperty(CSSPropertyUnicodeBidi, static_cast<CSSPrimitiveValue*>(unicodeBidi.get())->getIdent());
+ if (direction) {
+ ASSERT(direction->isPrimitiveValue());
+ typingStyle->setProperty(CSSPropertyDirection, static_cast<CSSPrimitiveValue*>(direction.get())->getIdent());
+ }
+ }
+
+ if (typingStyle && typingStyle->length())
applyStyle(typingStyle);
if (!selectInsertedText)
@@ -226,7 +232,7 @@ Position InsertTextCommand::insertTab(const Position& pos)
// insert the span before it.
if (offset > 0)
splitTextNode(textNode, offset);
- insertNodeBefore(spanNode.get(), textNode);
+ insertNodeBefore(spanNode, textNode);
}
}