summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/editing
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-06-10 16:52:27 +0100
committerSteve Block <steveblock@google.com>2011-06-14 01:14:02 +0100
commit54cdeeebc7adcbcd900e8b6a141a8cae27d9a631 (patch)
tree845b0d338b204a48560eca3b51b34cf92ed96840 /Source/WebCore/editing
parentd2c5226a647dc21d0c15267e09a3d19cf3e0d593 (diff)
downloadexternal_webkit-54cdeeebc7adcbcd900e8b6a141a8cae27d9a631.zip
external_webkit-54cdeeebc7adcbcd900e8b6a141a8cae27d9a631.tar.gz
external_webkit-54cdeeebc7adcbcd900e8b6a141a8cae27d9a631.tar.bz2
Merge WebKit at branches/chromium/742 r88085: Initial merge by git.
Change-Id: I0501b484b9528e31b0026e5ad64416dd6541cdde
Diffstat (limited to 'Source/WebCore/editing')
-rw-r--r--Source/WebCore/editing/Editor.cpp4
-rw-r--r--Source/WebCore/editing/Editor.h1
-rw-r--r--Source/WebCore/editing/SpellChecker.cpp16
-rw-r--r--Source/WebCore/editing/SpellChecker.h4
-rw-r--r--Source/WebCore/editing/VisiblePosition.cpp65
-rw-r--r--Source/WebCore/editing/markup.cpp2
6 files changed, 65 insertions, 27 deletions
diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp
index e7c5c1d..b72a546 100644
--- a/Source/WebCore/editing/Editor.cpp
+++ b/Source/WebCore/editing/Editor.cpp
@@ -916,7 +916,7 @@ TriState Editor::selectionHasStyle(int propertyID, const String& value) const
return state;
}
-bool Editor::hasTransparentBackgroundColor(CSSStyleDeclaration* style)
+static bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
{
RefPtr<CSSValue> cssValue = style->getPropertyCSSValue(CSSPropertyBackgroundColor);
if (!cssValue)
@@ -1051,7 +1051,7 @@ Editor::Editor(Frame* frame)
// This is off by default, since most editors want this behavior (this matches IE but not FF).
, m_shouldStyleWithCSS(false)
, m_killRing(adoptPtr(new KillRing))
- , m_spellChecker(adoptPtr(new SpellChecker(frame, frame->page() ? frame->page()->editorClient()->textChecker() : 0)))
+ , m_spellChecker(adoptPtr(new SpellChecker(frame)))
, m_spellingCorrector(adoptPtr(new SpellingCorrectionController(frame)))
, m_areMarkedTextMatchesHighlighted(false)
{
diff --git a/Source/WebCore/editing/Editor.h b/Source/WebCore/editing/Editor.h
index 24d5c87..1105ce9 100644
--- a/Source/WebCore/editing/Editor.h
+++ b/Source/WebCore/editing/Editor.h
@@ -198,7 +198,6 @@ public:
Command command(const String& commandName); // Command source is CommandFromMenuOrKeyBinding.
Command command(const String& commandName, EditorCommandSource);
static bool commandIsSupportedFromMenuOrKeyBinding(const String& commandName); // Works without a frame.
- static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);
bool insertText(const String&, Event* triggeringEvent);
bool insertTextForConfirmedComposition(const String& text);
diff --git a/Source/WebCore/editing/SpellChecker.cpp b/Source/WebCore/editing/SpellChecker.cpp
index fedcc07..c6ca926 100644
--- a/Source/WebCore/editing/SpellChecker.cpp
+++ b/Source/WebCore/editing/SpellChecker.cpp
@@ -33,6 +33,7 @@
#include "HTMLInputElement.h"
#include "HTMLTextAreaElement.h"
#include "Node.h"
+#include "Page.h"
#include "PositionIterator.h"
#include "Range.h"
#include "RenderObject.h"
@@ -43,9 +44,8 @@
namespace WebCore {
-SpellChecker::SpellChecker(Frame* frame, TextCheckerClient* client)
+SpellChecker::SpellChecker(Frame* frame)
: m_frame(frame)
- , m_client(client)
, m_requestSequence(0)
{
}
@@ -54,6 +54,14 @@ SpellChecker::~SpellChecker()
{
}
+TextCheckerClient* SpellChecker::client() const
+{
+ Page* page = m_frame->page();
+ if (!page)
+ return 0;
+ return page->editorClient()->textChecker();
+}
+
bool SpellChecker::initRequest(Node* node)
{
ASSERT(canCheckAsynchronously(node));
@@ -82,7 +90,7 @@ bool SpellChecker::isAsynchronousEnabled() const
bool SpellChecker::canCheckAsynchronously(Node* node) const
{
- return isCheckable(node) && isAsynchronousEnabled() && !isBusy();
+ return client() && isCheckable(node) && isAsynchronousEnabled() && !isBusy();
}
bool SpellChecker::isBusy() const
@@ -106,7 +114,7 @@ void SpellChecker::requestCheckingFor(TextCheckingTypeMask mask, Node* node)
if (!initRequest(node))
return;
- m_client->requestCheckingOfString(this, m_requestSequence, mask, m_requestText);
+ client()->requestCheckingOfString(this, m_requestSequence, mask, m_requestText);
}
static bool forwardIterator(PositionIterator& iterator, int distance)
diff --git a/Source/WebCore/editing/SpellChecker.h b/Source/WebCore/editing/SpellChecker.h
index 4bcb89e..1ed9011 100644
--- a/Source/WebCore/editing/SpellChecker.h
+++ b/Source/WebCore/editing/SpellChecker.h
@@ -39,7 +39,7 @@ class Node;
class SpellChecker {
WTF_MAKE_NONCOPYABLE(SpellChecker);
public:
- explicit SpellChecker(Frame*, TextCheckerClient*);
+ explicit SpellChecker(Frame*);
~SpellChecker();
bool isAsynchronousEnabled() const;
@@ -53,9 +53,9 @@ public:
private:
bool initRequest(Node*);
void clearRequest();
+ TextCheckerClient* client() const;
Frame* m_frame;
- TextCheckerClient* m_client;
RefPtr<Node> m_requestNode;
String m_requestText;
diff --git a/Source/WebCore/editing/VisiblePosition.cpp b/Source/WebCore/editing/VisiblePosition.cpp
index c3c05fd..cfaec47 100644
--- a/Source/WebCore/editing/VisiblePosition.cpp
+++ b/Source/WebCore/editing/VisiblePosition.cpp
@@ -33,6 +33,7 @@
#include "InlineTextBox.h"
#include "Logging.h"
#include "Range.h"
+#include "RootInlineBox.h"
#include "Text.h"
#include "htmlediting.h"
#include "visible_units.h"
@@ -134,8 +135,18 @@ Position VisiblePosition::leftVisuallyDistinctCandidate() const
if (box->isLeftToRightDirection() ? offset < caretMinOffset : offset > caretMaxOffset) {
// Overshot to the left.
InlineBox* prevBox = box->prevLeafChild();
- if (!prevBox)
- return primaryDirection == LTR ? previousVisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
+ if (!prevBox) {
+ Position positionOnLeft = primaryDirection == LTR ? previousVisuallyDistinctCandidate(m_deepPosition) : nextVisuallyDistinctCandidate(m_deepPosition);
+ if (positionOnLeft.isNull())
+ return Position();
+
+ InlineBox* boxOnLeft;
+ int offsetOnLeft;
+ positionOnLeft.getInlineBoxAndOffset(m_affinity, primaryDirection, boxOnLeft, offsetOnLeft);
+ if (boxOnLeft && boxOnLeft->root() == box->root())
+ return Position();
+ return positionOnLeft;
+ }
// Reposition at the other logical position corresponding to our edge's visual position and go for another round.
box = prevBox;
@@ -150,7 +161,16 @@ Position VisiblePosition::leftVisuallyDistinctCandidate() const
InlineBox* prevBox = box->prevLeafChild();
if (box->direction() == primaryDirection) {
- if (!prevBox || prevBox->bidiLevel() >= level)
+ if (!prevBox) {
+ InlineBox* logicalStart = 0;
+ if (primaryDirection == LTR ? box->root()->getLogicalStartBoxWithNode(logicalStart) : box->root()->getLogicalEndBoxWithNode(logicalStart)) {
+ box = logicalStart;
+ renderer = box->renderer();
+ offset = primaryDirection == LTR ? box->caretMinOffset() : box->caretMaxOffset();
+ }
+ break;
+ }
+ if (prevBox->bidiLevel() >= level)
break;
level = prevBox->bidiLevel();
@@ -163,11 +183,7 @@ Position VisiblePosition::leftVisuallyDistinctCandidate() const
if (nextBox && nextBox->bidiLevel() == level)
break;
- while (InlineBox* prevBox = box->prevLeafChild()) {
- if (prevBox->bidiLevel() < level)
- break;
- box = prevBox;
- }
+ box = prevBox;
renderer = box->renderer();
offset = box->caretRightmostOffset();
if (box->direction() == primaryDirection)
@@ -270,8 +286,18 @@ Position VisiblePosition::rightVisuallyDistinctCandidate() const
if (box->isLeftToRightDirection() ? offset > caretMaxOffset : offset < caretMinOffset) {
// Overshot to the right.
InlineBox* nextBox = box->nextLeafChild();
- if (!nextBox)
- return primaryDirection == LTR ? nextVisuallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
+ if (!nextBox) {
+ Position positionOnRight = primaryDirection == LTR ? nextVisuallyDistinctCandidate(m_deepPosition) : previousVisuallyDistinctCandidate(m_deepPosition);
+ if (positionOnRight.isNull())
+ return Position();
+
+ InlineBox* boxOnRight;
+ int offsetOnRight;
+ positionOnRight.getInlineBoxAndOffset(m_affinity, primaryDirection, boxOnRight, offsetOnRight);
+ if (boxOnRight && boxOnRight->root() == box->root())
+ return Position();
+ return positionOnRight;
+ }
// Reposition at the other logical position corresponding to our edge's visual position and go for another round.
box = nextBox;
@@ -286,7 +312,16 @@ Position VisiblePosition::rightVisuallyDistinctCandidate() const
InlineBox* nextBox = box->nextLeafChild();
if (box->direction() == primaryDirection) {
- if (!nextBox || nextBox->bidiLevel() >= level)
+ if (!nextBox) {
+ InlineBox* logicalEnd = 0;
+ if (primaryDirection == LTR ? box->root()->getLogicalEndBoxWithNode(logicalEnd) : box->root()->getLogicalStartBoxWithNode(logicalEnd)) {
+ box = logicalEnd;
+ renderer = box->renderer();
+ offset = primaryDirection == LTR ? box->caretMaxOffset() : box->caretMinOffset();
+ }
+ break;
+ }
+ if (nextBox->bidiLevel() >= level)
break;
level = nextBox->bidiLevel();
@@ -299,12 +334,8 @@ Position VisiblePosition::rightVisuallyDistinctCandidate() const
if (prevBox && prevBox->bidiLevel() == level) // For example, abc FED 123 ^ CBA
break;
- // For example, abc 123 ^ CBA
- while (InlineBox* nextBox = box->nextLeafChild()) {
- if (nextBox->bidiLevel() < level)
- break;
- box = nextBox;
- }
+ // For example, abc 123 ^ CBA or 123 ^ CBA abc
+ box = nextBox;
renderer = box->renderer();
offset = box->caretLeftmostOffset();
if (box->direction() == primaryDirection)
diff --git a/Source/WebCore/editing/markup.cpp b/Source/WebCore/editing/markup.cpp
index b93a78e..5ef3d7d 100644
--- a/Source/WebCore/editing/markup.cpp
+++ b/Source/WebCore/editing/markup.cpp
@@ -465,7 +465,7 @@ static bool isElementPresentational(const Node* node)
RefPtr<CSSMutableStyleDeclaration> style = styleFromMatchedRulesAndInlineDecl(node);
if (!style)
return false;
- return !propertyMissingOrEqualToNone(style.get(), CSSPropertyTextDecoration) || !Editor::hasTransparentBackgroundColor(style.get());
+ return !propertyMissingOrEqualToNone(style.get(), CSSPropertyTextDecoration);
}
static bool shouldIncludeWrapperForFullySelectedRoot(Node* fullySelectedRoot, CSSMutableStyleDeclaration* style)