| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 RenderBlock* DragCaretController::caretRenderer() const | 183 RenderBlock* DragCaretController::caretRenderer() const |
| 184 { | 184 { |
| 185 return CaretBase::caretRenderer(m_position.deepEquivalent().deprecatedNode()
); | 185 return CaretBase::caretRenderer(m_position.deepEquivalent().deprecatedNode()
); |
| 186 } | 186 } |
| 187 | 187 |
| 188 IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect
) const | 188 IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect
) const |
| 189 { | 189 { |
| 190 RenderBlock* caretPainter = caretRenderer(node); | 190 RenderBlock* caretPainter = caretRenderer(node); |
| 191 if (!caretPainter) | 191 if (!caretPainter) |
| 192 return IntRect(); | 192 return IntRect(); |
| 193 | 193 return caretPainter->localToAbsoluteQuad(FloatRect(rect)).enclosingBoundingB
ox(); |
| 194 LayoutRect localRect(rect); | |
| 195 caretPainter->flipForWritingMode(localRect); | |
| 196 return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoun
dingBox(); | |
| 197 } | 194 } |
| 198 | 195 |
| 199 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) | 196 void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect) |
| 200 { | 197 { |
| 201 RenderBlock* caretPainter = caretRenderer(node); | 198 RenderBlock* caretPainter = caretRenderer(node); |
| 202 if (!caretPainter) | 199 if (!caretPainter) |
| 203 return; | 200 return; |
| 204 | 201 |
| 205 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. | 202 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. |
| 206 // https://bugs.webkit.org/show_bug.cgi?id=108283 | 203 // https://bugs.webkit.org/show_bug.cgi?id=108283 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 231 if (node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)) | 228 if (node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)) |
| 232 invalidateLocalCaretRect(node, localCaretRectWithoutUpdate()); | 229 invalidateLocalCaretRect(node, localCaretRectWithoutUpdate()); |
| 233 } | 230 } |
| 234 | 231 |
| 235 void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi
nt& paintOffset, const LayoutRect& clipRect) const | 232 void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi
nt& paintOffset, const LayoutRect& clipRect) const |
| 236 { | 233 { |
| 237 if (m_caretVisibility == Hidden) | 234 if (m_caretVisibility == Hidden) |
| 238 return; | 235 return; |
| 239 | 236 |
| 240 LayoutRect drawingRect = localCaretRectWithoutUpdate(); | 237 LayoutRect drawingRect = localCaretRectWithoutUpdate(); |
| 241 if (RenderBlock* renderer = caretRenderer(node)) | |
| 242 renderer->flipForWritingMode(drawingRect); | |
| 243 drawingRect.moveBy(roundedIntPoint(paintOffset)); | 238 drawingRect.moveBy(roundedIntPoint(paintOffset)); |
| 244 LayoutRect caret = intersection(drawingRect, clipRect); | 239 LayoutRect caret = intersection(drawingRect, clipRect); |
| 245 if (caret.isEmpty()) | 240 if (caret.isEmpty()) |
| 246 return; | 241 return; |
| 247 | 242 |
| 248 Color caretColor = Color::black; | 243 Color caretColor = Color::black; |
| 249 | 244 |
| 250 Element* element; | 245 Element* element; |
| 251 if (node->isElementNode()) | 246 if (node->isElementNode()) |
| 252 element = toElement(node); | 247 element = toElement(node); |
| 253 else | 248 else |
| 254 element = node->parentElement(); | 249 element = node->parentElement(); |
| 255 | 250 |
| 256 if (element && element->renderer()) | 251 if (element && element->renderer()) |
| 257 caretColor = element->renderer()->resolveColor(CSSPropertyColor); | 252 caretColor = element->renderer()->resolveColor(CSSPropertyColor); |
| 258 | 253 |
| 259 context->fillRect(caret, caretColor); | 254 context->fillRect(caret, caretColor); |
| 260 } | 255 } |
| 261 | 256 |
| 262 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p,
const LayoutPoint& paintOffset, const LayoutRect& clipRect) const | 257 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p,
const LayoutPoint& paintOffset, const LayoutRect& clipRect) const |
| 263 { | 258 { |
| 264 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) | 259 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) |
| 265 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); | 260 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); |
| 266 } | 261 } |
| 267 | 262 |
| 268 } | 263 } |
| OLD | NEW |