Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Side by Side Diff: sky/engine/core/editing/FrameSelection.cpp

Issue 845093002: Delete an assortment of unneeded paint invalidation code. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/editing/FrameSelection.h ('k') | sky/engine/core/frame/FrameView.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 { 76 {
77 return !frame || frame->editor().behavior().shouldConsiderSelectionAsDirecti onal(); 77 return !frame || frame->editor().behavior().shouldConsiderSelectionAsDirecti onal();
78 } 78 }
79 79
80 FrameSelection::FrameSelection(LocalFrame* frame) 80 FrameSelection::FrameSelection(LocalFrame* frame)
81 : m_frame(frame) 81 : m_frame(frame)
82 , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation()) 82 , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation())
83 , m_observingVisibleSelection(false) 83 , m_observingVisibleSelection(false)
84 , m_granularity(CharacterGranularity) 84 , m_granularity(CharacterGranularity)
85 , m_caretBlinkTimer(this, &FrameSelection::caretBlinkTimerFired) 85 , m_caretBlinkTimer(this, &FrameSelection::caretBlinkTimerFired)
86 , m_caretRectDirty(true)
87 , m_shouldPaintCaret(true) 86 , m_shouldPaintCaret(true)
88 , m_isCaretBlinkingSuspended(false) 87 , m_isCaretBlinkingSuspended(false)
89 , m_focused(frame && frame->page() && frame->page()->focusController().focus edFrame() == frame) 88 , m_focused(frame && frame->page() && frame->page()->focusController().focus edFrame() == frame)
90 , m_shouldShowBlockCursor(false) 89 , m_shouldShowBlockCursor(false)
91 { 90 {
92 if (shouldAlwaysUseDirectionalSelection(m_frame)) 91 if (shouldAlwaysUseDirectionalSelection(m_frame))
93 m_selection.setIsDirectional(true); 92 m_selection.setIsDirectional(true);
94 } 93 }
95 94
96 FrameSelection::~FrameSelection() 95 FrameSelection::~FrameSelection()
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 { 1148 {
1150 m_granularity = CharacterGranularity; 1149 m_granularity = CharacterGranularity;
1151 1150
1152 m_caretBlinkTimer.stop(); 1151 m_caretBlinkTimer.stop();
1153 1152
1154 RenderView* view = m_frame->contentRenderer(); 1153 RenderView* view = m_frame->contentRenderer();
1155 if (view) 1154 if (view)
1156 view->clearSelection(); 1155 view->clearSelection();
1157 1156
1158 setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdat eAppearance); 1157 setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdat eAppearance);
1159 m_previousCaretNode.clear();
1160 } 1158 }
1161 1159
1162 void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger ) 1160 void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger )
1163 { 1161 {
1164 if (m_selection.isBaseFirst()) 1162 if (m_selection.isBaseFirst())
1165 setBase(pos, trigger); 1163 setBase(pos, trigger);
1166 else 1164 else
1167 setExtent(pos, trigger); 1165 setExtent(pos, trigger);
1168 } 1166 }
1169 1167
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 ASSERT(m_frame->document()->lifecycle().state() != DocumentLifecycle::InPain tInvalidation); 1200 ASSERT(m_frame->document()->lifecycle().state() != DocumentLifecycle::InPain tInvalidation);
1203 m_frame->document()->updateLayout(); 1201 m_frame->document()->updateLayout();
1204 if (!isNonOrphanedCaret(m_selection)) { 1202 if (!isNonOrphanedCaret(m_selection)) {
1205 clearCaretRect(); 1203 clearCaretRect();
1206 } else { 1204 } else {
1207 updateCaretRect(m_frame->document(), VisiblePosition(m_selection.start() , m_selection.affinity())); 1205 updateCaretRect(m_frame->document(), VisiblePosition(m_selection.start() , m_selection.affinity()));
1208 } 1206 }
1209 return absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), loca lCaretRectWithoutUpdate()); 1207 return absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), loca lCaretRectWithoutUpdate());
1210 } 1208 }
1211 1209
1212 static LayoutRect localCaretRect(const VisibleSelection& m_selection, const Posi tionWithAffinity& caretPosition, RenderObject*& renderer)
1213 {
1214 renderer = nullptr;
1215 if (!isNonOrphanedCaret(m_selection))
1216 return LayoutRect();
1217
1218 return localCaretRectOfPosition(caretPosition, renderer);
1219 }
1220
1221 void FrameSelection::invalidateCaretRect()
1222 {
1223 if (!m_caretRectDirty)
1224 return;
1225 m_caretRectDirty = false;
1226
1227 RenderObject* renderer = nullptr;
1228 LayoutRect newRect = localCaretRect(m_selection, PositionWithAffinity(m_sele ction.start(), m_selection.affinity()), renderer);
1229 Node* newNode = renderer ? renderer->node() : nullptr;
1230
1231 if (!m_caretBlinkTimer.isActive() && newNode == m_previousCaretNode && newRe ct == m_previousCaretRect)
1232 return;
1233
1234 if (m_previousCaretNode && m_previousCaretNode->isContentEditable())
1235 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect) ;
1236 if (newNode && newNode->isContentEditable())
1237 invalidateLocalCaretRect(newNode, newRect);
1238
1239 m_previousCaretNode = newNode;
1240 m_previousCaretRect = newRect;
1241 }
1242
1243 void FrameSelection::paintCaret(GraphicsContext* context, const LayoutPoint& pai ntOffset, const LayoutRect& clipRect) 1210 void FrameSelection::paintCaret(GraphicsContext* context, const LayoutPoint& pai ntOffset, const LayoutRect& clipRect)
1244 { 1211 {
1245 if (m_selection.isCaret() && m_shouldPaintCaret) { 1212 if (m_selection.isCaret() && m_shouldPaintCaret) {
1246 updateCaretRect(m_frame->document(), PositionWithAffinity(m_selection.st art(), m_selection.affinity())); 1213 updateCaretRect(m_frame->document(), PositionWithAffinity(m_selection.st art(), m_selection.affinity()));
1247 CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, pai ntOffset, clipRect); 1214 CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, pai ntOffset, clipRect);
1248 } 1215 }
1249 } 1216 }
1250 1217
1251 bool FrameSelection::contains(const LayoutPoint& point) 1218 bool FrameSelection::contains(const LayoutPoint& point)
1252 { 1219 {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 1648
1682 void FrameSelection::showTreeForThis() const 1649 void FrameSelection::showTreeForThis() const
1683 { 1650 {
1684 m_selection.showTreeForThis(); 1651 m_selection.showTreeForThis();
1685 } 1652 }
1686 1653
1687 #endif 1654 #endif
1688 1655
1689 void FrameSelection::setCaretRectNeedsUpdate() 1656 void FrameSelection::setCaretRectNeedsUpdate()
1690 { 1657 {
1691 m_caretRectDirty = true;
1692
1693 scheduleVisualUpdate(); 1658 scheduleVisualUpdate();
1694 } 1659 }
1695 1660
1696 void FrameSelection::scheduleVisualUpdate() const 1661 void FrameSelection::scheduleVisualUpdate() const
1697 { 1662 {
1698 if (!m_frame) 1663 if (!m_frame)
1699 return; 1664 return;
1700 if (Page* page = m_frame->page()) 1665 if (Page* page = m_frame->page())
1701 page->animator().scheduleVisualUpdate(); 1666 page->animator().scheduleVisualUpdate();
1702 } 1667 }
1703 1668
1704 } 1669 }
1705 1670
1706 #ifndef NDEBUG 1671 #ifndef NDEBUG
1707 1672
1708 void showTree(const blink::FrameSelection& sel) 1673 void showTree(const blink::FrameSelection& sel)
1709 { 1674 {
1710 sel.showTreeForThis(); 1675 sel.showTreeForThis();
1711 } 1676 }
1712 1677
1713 void showTree(const blink::FrameSelection* sel) 1678 void showTree(const blink::FrameSelection* sel)
1714 { 1679 {
1715 if (sel) 1680 if (sel)
1716 sel->showTreeForThis(); 1681 sel->showTreeForThis();
1717 } 1682 }
1718 1683
1719 #endif 1684 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/editing/FrameSelection.h ('k') | sky/engine/core/frame/FrameView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698