| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 m_previousCaretRect); | 202 m_previousCaretRect); |
| 203 } | 203 } |
| 204 if (newAnchorNode && shouldRepaintCaret(*newAnchorNode)) | 204 if (newAnchorNode && shouldRepaintCaret(*newAnchorNode)) |
| 205 invalidateLocalCaretRect(newAnchorNode, newRect); | 205 invalidateLocalCaretRect(newAnchorNode, newRect); |
| 206 m_previousCaretNode = newNode; | 206 m_previousCaretNode = newNode; |
| 207 m_previousCaretAnchorNode = newAnchorNode; | 207 m_previousCaretAnchorNode = newAnchorNode; |
| 208 m_previousCaretRect = newRect; | 208 m_previousCaretRect = newRect; |
| 209 m_previousCaretVisibility = m_caretVisibility; | 209 m_previousCaretVisibility = m_caretVisibility; |
| 210 } | 210 } |
| 211 | 211 |
| 212 // TDOO(yosin): We should mark |FrameCaret::absoluteCaretBounds()| to |const|. |
| 212 IntRect FrameCaret::absoluteCaretBounds() { | 213 IntRect FrameCaret::absoluteCaretBounds() { |
| 213 DCHECK_NE(m_frame->document()->lifecycle().state(), | 214 DCHECK_NE(m_frame->document()->lifecycle().state(), |
| 214 DocumentLifecycle::InPaintInvalidation); | 215 DocumentLifecycle::InPaintInvalidation); |
| 215 DCHECK(!m_frame->document()->needsLayoutTreeUpdate()); | 216 DCHECK(!m_frame->document()->needsLayoutTreeUpdate()); |
| 216 DocumentLifecycle::DisallowTransitionScope disallowTransition( | 217 DocumentLifecycle::DisallowTransitionScope disallowTransition( |
| 217 m_frame->document()->lifecycle()); | 218 m_frame->document()->lifecycle()); |
| 218 | 219 |
| 219 if (!isActive()) { | 220 Node* const caretNode = caretPosition().anchorNode(); |
| 220 clearCaretRect(); | 221 if (!isActive()) |
| 221 } else { | 222 return absoluteBoundsForLocalRect(caretNode, LayoutRect()); |
| 222 if (enclosingTextControl(caretPosition().position())) { | 223 // TODO(yosin): We should get rid of text control short path since layout |
| 223 if (isVisuallyEquivalentCandidate(caretPosition().position())) | 224 // tree is clean. |
| 224 updateCaretRect(caretPosition()); | 225 if (enclosingTextControl(caretPosition().position()) && |
| 225 else | 226 isVisuallyEquivalentCandidate(caretPosition().position())) { |
| 226 updateCaretRect(createVisiblePosition(caretPosition())); | 227 return absoluteBoundsForLocalRect(caretNode, |
| 227 } else { | 228 computeCaretRect(caretPosition())); |
| 228 updateCaretRect(createVisiblePosition(caretPosition())); | |
| 229 } | |
| 230 } | 229 } |
| 231 return absoluteBoundsForLocalRect(caretPosition().anchorNode(), | 230 return absoluteBoundsForLocalRect( |
| 232 localCaretRectWithoutUpdate()); | 231 caretNode, computeCaretRect(createVisiblePosition(caretPosition()))); |
| 233 } | 232 } |
| 234 | 233 |
| 235 void FrameCaret::setShouldShowBlockCursor(bool shouldShowBlockCursor) { | 234 void FrameCaret::setShouldShowBlockCursor(bool shouldShowBlockCursor) { |
| 236 m_shouldShowBlockCursor = shouldShowBlockCursor; | 235 m_shouldShowBlockCursor = shouldShowBlockCursor; |
| 237 | 236 |
| 238 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 237 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 239 | 238 |
| 240 updateAppearance(); | 239 updateAppearance(); |
| 241 } | 240 } |
| 242 | 241 |
| 243 void FrameCaret::paintCaret(GraphicsContext& context, | 242 void FrameCaret::paintCaret(GraphicsContext& context, |
| 244 const LayoutPoint& paintOffset) { | 243 const LayoutPoint& paintOffset) { |
| 245 if (m_caretVisibility == CaretVisibility::Hidden) | 244 if (m_caretVisibility == CaretVisibility::Hidden) |
| 246 return; | 245 return; |
| 247 | 246 |
| 248 if (!(isActive() && m_shouldPaintCaret)) | 247 if (!(isActive() && m_shouldPaintCaret)) |
| 249 return; | 248 return; |
| 250 | 249 |
| 251 updateCaretRect(caretPosition()); | 250 const LayoutRect caretLocalRect = computeCaretRect(caretPosition()); |
| 252 CaretBase::paintCaret(caretPosition().anchorNode(), context, paintOffset, | 251 CaretBase::paintCaret(caretPosition().anchorNode(), context, *this, |
| 253 DisplayItem::kCaret); | 252 caretLocalRect, paintOffset, DisplayItem::kCaret); |
| 254 } | 253 } |
| 255 | 254 |
| 256 void FrameCaret::dataWillChange(const CharacterData& node) { | 255 void FrameCaret::dataWillChange(const CharacterData& node) { |
| 257 if (node == m_previousCaretNode) { | 256 if (node == m_previousCaretNode) { |
| 258 // This invalidation is eager, and intentionally uses stale state. | 257 // This invalidation is eager, and intentionally uses stale state. |
| 259 DisableCompositingQueryAsserts disabler; | 258 DisableCompositingQueryAsserts disabler; |
| 260 invalidateLocalCaretRect(m_previousCaretAnchorNode.get(), | 259 invalidateLocalCaretRect(m_previousCaretAnchorNode.get(), |
| 261 m_previousCaretRect); | 260 m_previousCaretRect); |
| 262 } | 261 } |
| 263 } | 262 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 298 |
| 300 void FrameCaret::caretBlinkTimerFired(TimerBase*) { | 299 void FrameCaret::caretBlinkTimerFired(TimerBase*) { |
| 301 DCHECK_EQ(m_caretVisibility, CaretVisibility::Visible); | 300 DCHECK_EQ(m_caretVisibility, CaretVisibility::Visible); |
| 302 if (isCaretBlinkingSuspended() && m_shouldPaintCaret) | 301 if (isCaretBlinkingSuspended() && m_shouldPaintCaret) |
| 303 return; | 302 return; |
| 304 m_shouldPaintCaret = !m_shouldPaintCaret; | 303 m_shouldPaintCaret = !m_shouldPaintCaret; |
| 305 setCaretRectNeedsUpdate(); | 304 setCaretRectNeedsUpdate(); |
| 306 } | 305 } |
| 307 | 306 |
| 308 } // namespace blink | 307 } // namespace blink |
| OLD | NEW |