Index: Source/core/editing/Caret.cpp |
diff --git a/Source/core/editing/Caret.cpp b/Source/core/editing/Caret.cpp |
index 2b3c1d6ccf2ebb25d5d785e3293dcadc09b02066..ae7fb54dea8cffdd2b13bac75559919816df7849 100644 |
--- a/Source/core/editing/Caret.cpp |
+++ b/Source/core/editing/Caret.cpp |
@@ -179,6 +179,15 @@ IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect |
return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoundingBox(); |
} |
+void CaretBase::updateDirectionPointer(const RenderBoxModelObject* renderBoxModelObject, LayoutRect& rect) |
+{ |
+ // Extra rect are drawn, need to refresh more area. |
+ TextDirection containerDirection = renderBoxModelObject->style()->direction(); |
Inactive
2014/05/27 13:10:45
Ok, so I looked this up a bit more. Why do you nee
h.joshi
2014/05/28 03:02:53
Yes, RenderObject will be enough here to get style
|
+ rect.setWidth(rect.width() + LayoutUnit(2)); |
+ if (containerDirection == RTL) |
+ rect.setX(rect.x() - LayoutUnit(2)); |
+} |
+ |
void CaretBase::repaintCaretForLocalRect(Node* node, const LayoutRect& rect) |
{ |
RenderObject* caretPainter = caretRenderer(node); |
@@ -190,6 +199,7 @@ void CaretBase::repaintCaretForLocalRect(Node* node, const LayoutRect& rect) |
LayoutRect inflatedRect = rect; |
inflatedRect.inflate(1); |
+ updateDirectionPointer(toRenderBoxModelObject(caretPainter), inflatedRect); |
Inactive
2014/05/27 13:10:45
This cast should not be needed. Also, I am still n
h.joshi
2014/05/28 03:02:53
Yes, will remove after changing method usage.
|
caretPainter->repaintRectangle(inflatedRect); |
} |
@@ -223,8 +233,11 @@ void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged) |
return; |
if (RenderView* view = node->document().renderView()) { |
- if (shouldRepaintCaret(view, node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable))) |
- repaintCaretForLocalRect(node, localCaretRectWithoutUpdate()); |
+ if (shouldRepaintCaret(view, node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable))) { |
+ LayoutRect drawingRect = localCaretRectWithoutUpdate(); |
+ updateDirectionPointer(toRenderBoxModelObject(caretRenderer(node)), drawingRect); |
Inactive
2014/05/27 13:10:45
Ditto. Cast should not be needed.
Also, what if ca
h.joshi
2014/05/28 03:02:53
Ditto
|
+ repaintCaretForLocalRect(node, drawingRect); |
+ } |
} |
} |
@@ -242,6 +255,18 @@ void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi |
if (caret.isEmpty()) |
return; |
+ TextDirection containerDirection = toRenderBoxModelObject(renderer)->style()->direction(); |
Inactive
2014/05/27 13:10:45
Cast should not be needed.
h.joshi
2014/05/28 03:02:53
Yes, will make changes
|
+ LayoutRect directionPointerCaret = caret; |
+ |
+ // Drawing different Caret which shows editing style similar to IE |
Inactive
2014/05/27 13:10:45
nit: needs to end with a '.'
h.joshi
2014/05/28 03:02:53
Will make changes.
|
+ if (containerDirection == LTR) |
+ directionPointerCaret.setX(directionPointerCaret.x() + 1); |
+ else |
+ directionPointerCaret.setX(directionPointerCaret.x() - 2); |
+ |
+ directionPointerCaret.setWidth(LayoutUnit(2)); |
+ directionPointerCaret.setHeight(LayoutUnit(1)); |
+ |
Color caretColor = Color::black; |
Element* element; |
@@ -254,6 +279,14 @@ void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi |
caretColor = element->renderer()->resolveColor(CSSPropertyColor); |
context->fillRect(caret, caretColor); |
+ context->fillRect(directionPointerCaret, caretColor); |
+ |
+ // Update directionPointerCaret points and lets draw one more small rect to match IE. |
+ directionPointerCaret.setY(caret.y() + LayoutUnit(1)); |
+ directionPointerCaret.setWidth(LayoutUnit(1)); |
+ if (containerDirection == RTL) |
+ directionPointerCaret.setX(directionPointerCaret.x() + 1); |
+ context->fillRect(directionPointerCaret, caretColor); |
} |
void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p, const LayoutPoint& paintOffset, const LayoutRect& clipRect) const |