Commit 8943635a authored by xji@chromium.org's avatar xji@chromium.org

2011-03-28 Xiaomei Ji <xji@chromium.org>

        Reviewed by Ryosuke Niwa.

        move directionOfEnclosingBlock() to be global so that it could be reused.
        https://bugs.webkit.org/show_bug.cgi?id=57233.

        Provide global function directionOfEnclosingBlock(Node*) so that it could be
        reused in SelectionController and other functionalities that need enclosing
        block's direcionality, such as moving caret by word in visual order.
      
        No new functionality, so no new tests.

        * editing/SelectionController.cpp:
        (WebCore::SelectionController::directionOfEnclosingBlock):
        * editing/htmlediting.cpp:
        (WebCore::directionOfEnclosingBlock):
        * editing/htmlediting.h:


git-svn-id: svn://svn.chromium.org/blink/trunk@82121 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 5bd251c0
2011-03-28 Xiaomei Ji <xji@chromium.org>
Reviewed by Ryosuke Niwa.
move directionOfEnclosingBlock() to be global so that it could be reused.
https://bugs.webkit.org/show_bug.cgi?id=57233.
Provide global function directionOfEnclosingBlock(Node*) so that it could be
reused in SelectionController and other functionalities that need enclosing
block's direcionality, such as moving caret by word in visual order.
No new functionality, so no new tests.
* editing/SelectionController.cpp:
(WebCore::SelectionController::directionOfEnclosingBlock):
* editing/htmlediting.cpp:
(WebCore::directionOfEnclosingBlock):
* editing/htmlediting.h:
2011-03-28 Jarkko Sakkinen <jarkko.j.sakkinen@gmail.com>
Reviewed by Benjamin Poulain.
......@@ -334,6 +334,11 @@ void SelectionController::setIsDirectional(bool isDirectional)
m_isDirectional = !m_frame || m_frame->editor()->behavior().shouldConsiderSelectionAsDirectional() || isDirectional;
}
TextDirection SelectionController::directionOfEnclosingBlock()
{
return WebCore::directionOfEnclosingBlock(m_selection.extent());
}
void SelectionController::willBeModified(EAlteration alter, SelectionDirection direction)
{
if (alter != AlterationExtend)
......@@ -383,17 +388,6 @@ void SelectionController::willBeModified(EAlteration alter, SelectionDirection d
}
}
TextDirection SelectionController::directionOfEnclosingBlock()
{
Node* enclosingBlockNode = enclosingBlock(m_selection.extent().containerNode());
if (!enclosingBlockNode)
return LTR;
RenderObject* renderer = enclosingBlockNode->renderer();
if (renderer)
return renderer->style()->direction();
return LTR;
}
VisiblePosition SelectionController::positionForPlatform(bool isGetStart) const
{
Settings* settings = m_frame ? m_frame->settings() : 0;
......
......@@ -332,6 +332,15 @@ Node* enclosingBlock(Node* node, EditingBoundaryCrossingRule rule)
return static_cast<Element*>(enclosingNodeOfType(firstPositionInOrBeforeNode(node), isBlock, rule));
}
TextDirection directionOfEnclosingBlock(const Position& position)
{
Node* enclosingBlockNode = enclosingBlock(position.containerNode());
if (!enclosingBlockNode)
return LTR;
RenderObject* renderer = enclosingBlockNode->renderer();
return renderer ? renderer->style()->direction() : LTR;
}
// This method is used to create positions in the DOM. It returns the maximum valid offset
// in a node. It returns 1 for some elements even though they do not have children, which
// creates technically invalid DOM Positions. Be sure to call parentAnchoredEquivalent
......
......@@ -30,6 +30,7 @@
#include "ExceptionCode.h"
#include "HTMLNames.h"
#include "Position.h"
#include "TextDirection.h"
#include <wtf/Forward.h>
#include <wtf/unicode/CharacterNames.h>
......@@ -96,6 +97,8 @@ bool isNodeVisiblyContainedWithin(Node*, const Range*);
bool isRenderedAsNonInlineTableImageOrHR(const Node*);
bool isNodeInTextFormControl(Node* node);
TextDirection directionOfEnclosingBlock(const Position&);
// -------------------------------------------------------------------------
// Position
// -------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment