Chromium Code Reviews| 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 { | 183 { |
| 184 RenderObject* caretPainter = caretRenderer(node); | 184 RenderObject* caretPainter = caretRenderer(node); |
| 185 if (!caretPainter) | 185 if (!caretPainter) |
| 186 return; | 186 return; |
| 187 | 187 |
| 188 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. | 188 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. |
| 189 // https://bugs.webkit.org/show_bug.cgi?id=108283 | 189 // https://bugs.webkit.org/show_bug.cgi?id=108283 |
| 190 LayoutRect inflatedRect = rect; | 190 LayoutRect inflatedRect = rect; |
| 191 inflatedRect.inflate(1); | 191 inflatedRect.inflate(1); |
| 192 | 192 |
| 193 // as extra rect are draw so need to refresh more area | |
|
Inactive
2014/05/22 14:15:05
Comments should start with a capital letter and en
h.joshi
2014/05/23 13:26:31
Okey, will fix this
| |
| 194 TextDirection containerDirection = toRenderBoxModelObject(caretRenderer(node ))->style()->direction(); | |
|
Inactive
2014/05/22 14:15:05
You likely want to use caretPainter variable here.
h.joshi
2014/05/23 13:26:31
Okey, will fix this
| |
| 195 inflatedRect.setWidth(inflatedRect.width() + LayoutUnit(2)); | |
| 196 if (containerDirection == RTL) | |
| 197 inflatedRect.setX(inflatedRect.x() - LayoutUnit(2)); | |
| 198 | |
| 193 caretPainter->repaintRectangle(inflatedRect); | 199 caretPainter->repaintRectangle(inflatedRect); |
| 194 } | 200 } |
| 195 | 201 |
| 196 bool CaretBase::shouldRepaintCaret(const RenderView* view, bool isContentEditabl e) const | 202 bool CaretBase::shouldRepaintCaret(const RenderView* view, bool isContentEditabl e) const |
| 197 { | 203 { |
| 198 ASSERT(view); | 204 ASSERT(view); |
| 199 bool caretBrowsing = false; | 205 bool caretBrowsing = false; |
| 200 if (FrameView* frameView = view->frameView()) { | 206 if (FrameView* frameView = view->frameView()) { |
| 201 LocalFrame& frame = frameView->frame(); // The frame where the selection started | 207 LocalFrame& frame = frameView->frame(); // The frame where the selection started |
| 202 caretBrowsing = frame.settings() && frame.settings()->caretBrowsingEnabl ed(); | 208 caretBrowsing = frame.settings() && frame.settings()->caretBrowsingEnabl ed(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 216 // it happens after the document has accounted for any editing | 222 // it happens after the document has accounted for any editing |
| 217 // changes which may have been done. | 223 // changes which may have been done. |
| 218 // And, we need to leave this layout here so the caret moves right | 224 // And, we need to leave this layout here so the caret moves right |
| 219 // away after clicking. | 225 // away after clicking. |
| 220 m_caretRectNeedsUpdate = true; | 226 m_caretRectNeedsUpdate = true; |
| 221 | 227 |
| 222 if (caretRectChanged) | 228 if (caretRectChanged) |
| 223 return; | 229 return; |
| 224 | 230 |
| 225 if (RenderView* view = node->document().renderView()) { | 231 if (RenderView* view = node->document().renderView()) { |
| 226 if (shouldRepaintCaret(view, node->isContentEditable(Node::UserSelectAll IsAlwaysNonEditable))) | 232 if (shouldRepaintCaret(view, node->isContentEditable(Node::UserSelectAll IsAlwaysNonEditable))) { |
| 227 repaintCaretForLocalRect(node, localCaretRectWithoutUpdate()); | 233 // as extra rect are draw so need to refresh more area |
|
Inactive
2014/05/22 14:15:05
Ditto.
| |
| 234 LayoutRect drawingRect = localCaretRectWithoutUpdate(); | |
| 235 TextDirection containerDirection = toRenderBoxModelObject(caretRende rer(node))->style()->direction(); | |
|
Inactive
2014/05/22 14:15:05
Code duplication, you should probably move the cod
h.joshi
2014/05/23 13:26:31
Okey, will make new utility method
| |
| 236 drawingRect.setWidth(drawingRect.width() + LayoutUnit(2)); | |
| 237 | |
| 238 if (containerDirection == RTL) | |
| 239 drawingRect.setX(drawingRect.x() - LayoutUnit(2)); | |
| 240 repaintCaretForLocalRect(node, drawingRect); | |
| 241 } | |
| 228 } | 242 } |
| 229 } | 243 } |
| 230 | 244 |
| 231 void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi nt& paintOffset, const LayoutRect& clipRect) const | 245 void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoi nt& paintOffset, const LayoutRect& clipRect) const |
| 232 { | 246 { |
| 233 if (m_caretVisibility == Hidden) | 247 if (m_caretVisibility == Hidden) |
| 234 return; | 248 return; |
| 235 | 249 |
| 236 LayoutRect drawingRect = localCaretRectWithoutUpdate(); | 250 LayoutRect drawingRect = localCaretRectWithoutUpdate(); |
| 237 RenderObject* renderer = caretRenderer(node); | 251 RenderObject* renderer = caretRenderer(node); |
| 238 if (renderer && renderer->isBox()) | 252 if (renderer && renderer->isBox()) |
| 239 toRenderBox(renderer)->flipForWritingMode(drawingRect); | 253 toRenderBox(renderer)->flipForWritingMode(drawingRect); |
| 240 drawingRect.moveBy(roundedIntPoint(paintOffset)); | 254 drawingRect.moveBy(roundedIntPoint(paintOffset)); |
| 241 LayoutRect caret = intersection(drawingRect, clipRect); | 255 LayoutRect caret = intersection(drawingRect, clipRect); |
| 242 if (caret.isEmpty()) | 256 if (caret.isEmpty()) |
| 243 return; | 257 return; |
| 244 | 258 |
| 259 TextDirection containerDirection = toRenderBoxModelObject(renderer)->style() ->direction(); | |
| 260 LayoutRect ptrCaret = caret; | |
|
Inactive
2014/05/22 14:15:05
please no not use abbreviations in variable names.
| |
| 261 | |
| 262 // drawing different Caret which shows editing style similar to IE | |
| 263 if (containerDirection == LTR) { | |
|
Inactive
2014/05/22 14:15:05
No {} for one-liners.
h.joshi
2014/05/23 13:26:31
Okey, will update condition
| |
| 264 ptrCaret.setX(ptrCaret.x() + 1); | |
|
Inactive
2014/05/22 14:15:05
identation problem
| |
| 265 } else { | |
|
Inactive
2014/05/22 14:15:05
ditto
| |
| 266 ptrCaret.setX(ptrCaret.x() - 2); | |
|
Inactive
2014/05/22 14:15:05
ditto.
| |
| 267 } | |
| 268 ptrCaret.setWidth(LayoutUnit(2)); | |
| 269 ptrCaret.setHeight(LayoutUnit(1)); | |
| 270 | |
| 245 Color caretColor = Color::black; | 271 Color caretColor = Color::black; |
| 246 | 272 |
| 247 Element* element; | 273 Element* element; |
| 248 if (node->isElementNode()) | 274 if (node->isElementNode()) |
| 249 element = toElement(node); | 275 element = toElement(node); |
| 250 else | 276 else |
| 251 element = node->parentElement(); | 277 element = node->parentElement(); |
| 252 | 278 |
| 253 if (element && element->renderer()) | 279 if (element && element->renderer()) |
| 254 caretColor = element->renderer()->resolveColor(CSSPropertyColor); | 280 caretColor = element->renderer()->resolveColor(CSSPropertyColor); |
| 255 | 281 |
| 256 context->fillRect(caret, caretColor); | 282 context->fillRect(caret, caretColor); |
| 283 context->fillRect(ptrCaret, caretColor); | |
| 284 | |
| 285 // Update ptrCaret points and lets draw one more small rect to match IE | |
|
Inactive
2014/05/22 14:15:05
end with a '.'
h.joshi
2014/05/23 13:26:31
Okey, will update comment
| |
| 286 ptrCaret.setY(caret.y() + LayoutUnit(1)); | |
| 287 ptrCaret.setWidth(LayoutUnit(1)); | |
| 288 if (containerDirection == RTL) | |
| 289 ptrCaret.setX(ptrCaret.x() + 1); | |
| 290 context->fillRect(ptrCaret, caretColor); | |
| 257 } | 291 } |
| 258 | 292 |
| 259 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p, const LayoutPoint& paintOffset, const LayoutRect& clipRect) const | 293 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p, const LayoutPoint& paintOffset, const LayoutRect& clipRect) const |
| 260 { | 294 { |
| 261 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram e) | 295 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram e) |
| 262 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset, clipRect); | 296 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset, clipRect); |
| 263 } | 297 } |
| 264 | 298 |
| 265 } | 299 } |
| OLD | NEW |