Changeset 86039 in webkit
- Timestamp:
- May 8, 2011 5:40:11 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86028 r86039 1 2011-05-08 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Extract a DragCaretController from FrameSelection 6 https://bugs.webkit.org/show_bug.cgi?id=60273 7 8 Extracted CaretBase and DragCaretController from FrameSelection. CaretBase is a base class for 9 DragCaretController and FrameSelection and provides functions to paint caret. 10 11 Since DragCaretController doesn't need to store selection, it only holds one VisiblePosition. 12 13 * WebCore.exp.in: 14 * editing/FrameSelection.cpp: 15 (WebCore::CaretBase::CaretBase): Added. 16 (WebCore::DragCaretController::DragCaretController): Added; Set m_caretVisible true. 17 (WebCore::DragCaretController::isContentRichlyEditable): Added. 18 (WebCore::FrameSelection::FrameSelection): Several member variables are move to CaretBase. 19 (WebCore::DragCaretController::setCaretPosition): Extracted from FrameSelection::setSelection. 20 (WebCore::FrameSelection::setSelection): Removed an early exit for DragCaretController. 21 (WebCore::clearRenderViewSelection): Extracted from FrameSelection::respondToNodeModification. 22 (WebCore::DragCaretController::nodeWillBeRemoved): Extracted from FrameSelection::nodeWillBeRemoved 23 and respondToNodeModification. Note that the position DragCaretController holds is equivalent to 24 FrameSelection's base or start so when removingNodeRemovesPosition returns true for m_position, 25 we used to execute the first if clause and cleared render tree selection and DOM tree selection. 26 This is exactly what new DragCaretController::nodeWillBeRemoved does. 27 (WebCore::FrameSelection::nodeWillBeRemoved): Simplified early exist conditions. 28 (WebCore::FrameSelection::respondToNodeModification): Calls clearRenderViewSelection. 29 (WebCore::CaretBase::updateCaretRect): Takes document, caretPosition, selection type, and boolean isOrphaned. 30 Note that we can't obtain the document from caretPosition because VisiblePosition can be null even if 31 FrameSelection's start was not null. 32 (WebCore::caretRendersInsideNode): Moved; Made static local. 33 (WebCore::CaretBase::caretRenderer): Extracted from FrameSelection::caretRenderer. 34 (WebCore::FrameSelection::caretRenderer): Calls CaretBase::caretRenderer. 35 (WebCore::DragCaretController::caretRenderer): Ditto. 36 (WebCore::FrameSelection::localCaretRect): Calls updateCaretRect with extra arguments. 37 (WebCore::CaretBase::absoluteBoundsForLocalRect): Moved from FrameSelection; Takes Node*. 38 (WebCore::CaretBase::caretRepaintRect): Ditto. 39 (WebCore::FrameSelection::recomputeCaretRect): Calls absoluteBoundsForLocalRect, caretRepaintRect, 40 and shouldRepaintCaret with extra arguments. 41 (WebCore::CaretBase::shouldRepaintCaret): Takes a boolean isContentEditable. 42 (WebCore::FrameSelection::invalidateCaretRect): Calls CaretBase::invalidateCaretRect. 43 (WebCore::CaretBase::invalidateCaretRect): Extracted from FrameSelection::invalidateCaretRect. 44 (WebCore::FrameSelection::paintCaret): Calls CaretBase::paintCaret. 45 (WebCore::CaretBase::paintCaret): Extracted from FrameSelection::paintCaret. 46 (WebCore::FrameSelection::updateAppearance): Removed an assertion that this function is never called for 47 DragCaretController. 48 (WebCore::DragCaretController::paintDragCaret): Moved from FrameSelection::paintDragCaret. 49 * editing/FrameSelection.h: 50 (WebCore::CaretBase::localCaretRectForPainting): Added. 51 (WebCore::DragCaretController::isContentEditable): Added. 52 (WebCore::DragCaretController::hasCaret): Added. 53 (WebCore::DragCaretController::caretPosition): Added. 54 (WebCore::DragCaretController::clear): Added. 55 * page/DragController.cpp: 56 (WebCore::DragController::tryDocumentDrag): Uses DragCaretController. 57 (WebCore::DragController::dispatchTextInputEventFor): Ditto. 58 (WebCore::DragController::concludeEditDrag): Ditto. 59 (WebCore::DragController::placeDragCaret): Ditto. 60 * page/Page.cpp: 61 (WebCore::Page::Page): Instantiates DragCaretController instead of FrameSelection. 62 * page/Page.h: 63 (WebCore::Page::dragCaretController): Returns DragCaretController* instead of FrameSelection*. 64 * rendering/RenderBlock.cpp: 65 (WebCore::RenderBlock::paintCaret): Uses FrameSelection and DragCaretController. 66 1 67 2011-05-08 Dan Bernstein <mitz@apple.com> 2 68 -
trunk/Source/WebCore/WebCore.exp.in
r85998 r86039 357 357 __ZN7WebCore14FrameSelection5clearEv 358 358 __ZN7WebCore14FrameSelection9selectAllEv 359 __ZN7WebCore14FrameSelectionC1EPNS_5FrameE b359 __ZN7WebCore14FrameSelectionC1EPNS_5FrameE 360 360 __ZN7WebCore14ResourceHandle12releaseProxyEv 361 361 __ZN7WebCore14ResourceHandle20forceContentSniffingEv -
trunk/Source/WebCore/editing/FrameSelection.cpp
r85864 r86039 71 71 const int NoXPosForVerticalArrowNavigation = INT_MIN; 72 72 73 FrameSelection::FrameSelection(Frame* frame, bool isDragCaretController) 73 CaretBase::CaretBase() 74 : m_caretRectNeedsUpdate(true) 75 , m_absCaretBoundsDirty(true) 76 , m_caretVisible(false) 77 , m_caretPaint(true) 78 { 79 } 80 81 DragCaretController::DragCaretController() 82 { 83 m_caretVisible = true; 84 } 85 86 bool DragCaretController::isContentRichlyEditable() const 87 { 88 return isRichlyEditablePosition(m_position.deepEquivalent()); 89 } 90 91 FrameSelection::FrameSelection(Frame* frame) 74 92 : m_frame(frame) 75 93 , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation) 76 94 , m_granularity(CharacterGranularity) 77 95 , m_caretBlinkTimer(this, &FrameSelection::caretBlinkTimerFired) 78 , m_caretRectNeedsUpdate(true)79 , m_absCaretBoundsDirty(true)80 , m_isDragCaretController(isDragCaretController)81 96 , m_isCaretBlinkingSuspended(false) 82 97 , m_focused(frame && frame->page() && frame->page()->focusController()->focusedFrame() == frame) 83 , m_caretVisible(isDragCaretController)84 , m_caretPaint(true)85 98 { 86 99 setIsDirectional(false); … … 128 141 } 129 142 143 void DragCaretController::setCaretPosition(const VisiblePosition& position) 144 { 145 if (m_position == position) 146 return; 147 148 if (Node* node = m_position.deepEquivalent().containerNode()) 149 invalidateCaretRect(node); 150 m_position = position; 151 m_caretRectNeedsUpdate = true; 152 Document* document = 0; 153 if (Node* node = m_position.deepEquivalent().containerNode()) { 154 invalidateCaretRect(node); 155 document = node->document(); 156 } 157 updateCaretRect(document, m_position, m_position.isNotNull() ? VisibleSelection::CaretSelection : VisibleSelection::NoSelection, m_position.isOrphan()); 158 } 159 130 160 void FrameSelection::setSelection(const VisibleSelection& s, SetSelectionOptions options, CursorAlignOnScroll align, TextGranularity granularity, DirectionalityPolicy directionalityPolicy) 131 161 { … … 138 168 setIsDirectional(directionalityPolicy == MakeDirectionalSelection); 139 169 140 if (m_isDragCaretController) {141 invalidateCaretRect();142 m_selection = s;143 m_caretRectNeedsUpdate = true;144 invalidateCaretRect();145 updateCaretRect();146 return;147 }148 170 if (!m_frame) { 149 171 m_selection = s; … … 220 242 } 221 243 222 void FrameSelection::nodeWillBeRemoved(Node *node) 223 { 224 if (isNone()) 225 return; 226 244 static void clearRenderViewSelection(const Position& position) 245 { 246 RefPtr<Document> document = position.anchorNode()->document(); 247 document->updateStyleIfNeeded(); 248 if (RenderView* view = toRenderView(document->renderer())) 249 view->clearSelection(); 250 } 251 252 void DragCaretController::nodeWillBeRemoved(Node* node) 253 { 254 if (!hasCaret() || (node && !node->inDocument())) 255 return; 256 257 if (!removingNodeRemovesPosition(node, m_position.deepEquivalent())) 258 return; 259 260 clearRenderViewSelection(m_position.deepEquivalent()); 261 clear(); 262 } 263 264 void FrameSelection::nodeWillBeRemoved(Node* node) 265 { 227 266 // There can't be a selection inside a fragment, so if a fragment's node is being removed, 228 267 // the selection in the document that created the fragment needs no adjustment. 229 if ( node && highestAncestor(node)->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)268 if (isNone() || (node && !node->inDocument())) 230 269 return; 231 270 … … 264 303 } 265 304 266 if (clearRenderTreeSelection) { 267 RefPtr<Document> document = m_selection.start().anchorNode()->document(); 268 document->updateStyleIfNeeded(); 269 if (RenderView* view = toRenderView(document->renderer())) 270 view->clearSelection(); 271 } 305 if (clearRenderTreeSelection) 306 clearRenderViewSelection(m_selection.start()); 272 307 273 308 if (clearDOMTreeSelection) … … 1032 1067 } 1033 1068 1034 void FrameSelection::updateCaretRect()1035 { 1036 if ( isNone() || !m_selection.start().anchorNode()->inDocument() || !m_selection.end().anchorNode()->inDocument()) {1069 void CaretBase::updateCaretRect(Document* document, const VisiblePosition& caretPosition, VisibleSelection::SelectionType type, bool isOrphaned) 1070 { 1071 if (type == VisibleSelection::NoSelection || isOrphaned) { 1037 1072 m_caretRect = IntRect(); 1038 1073 return; 1039 1074 } 1040 1075 1041 m_selection.start().anchorNode()->document()->updateStyleIfNeeded(); 1076 document->updateStyleIfNeeded(); 1077 1078 m_caretRect = IntRect(); 1042 1079 1043 m_caretRect = IntRect(); 1044 1045 if (isCaret()) { 1046 VisiblePosition pos(m_selection.start(), m_selection.affinity()); 1047 if (pos.isNotNull()) { 1048 ASSERT(pos.deepEquivalent().deprecatedNode()->renderer()); 1049 1080 if (type == VisibleSelection::CaretSelection) { 1081 if (caretPosition.isNotNull()) { 1082 ASSERT(caretPosition.deepEquivalent().deprecatedNode()->renderer()); 1083 1050 1084 // First compute a rect local to the renderer at the selection start 1051 1085 RenderObject* renderer; 1052 IntRect localRect = pos.localCaretRect(renderer);1086 IntRect localRect = caretPosition.localCaretRect(renderer); 1053 1087 1054 1088 // Get the renderer that will be responsible for painting the caret (which 1055 1089 // is either the renderer we just found, or one of its containers) 1056 RenderObject* caretPainter = caretRenderer( );1090 RenderObject* caretPainter = caretRenderer(caretPosition.deepEquivalent().deprecatedNode()); 1057 1091 1058 1092 // Compute an offset between the renderer and the caretPainter … … 1078 1112 } 1079 1113 1080 RenderObject* FrameSelection::caretRenderer() const 1081 { 1082 Node* node = m_selection.start().deprecatedNode(); 1114 static inline bool caretRendersInsideNode(Node* node) 1115 { 1116 return node && !isTableElement(node) && !editingIgnoresContent(node); 1117 } 1118 1119 RenderObject* CaretBase::caretRenderer(Node* node) const 1120 { 1083 1121 if (!node) 1084 1122 return 0; … … 1093 1131 } 1094 1132 1133 RenderObject* FrameSelection::caretRenderer() const 1134 { 1135 return CaretBase::caretRenderer(m_selection.start().deprecatedNode()); 1136 } 1137 1138 RenderObject* DragCaretController::caretRenderer() const 1139 { 1140 return CaretBase::caretRenderer(m_position.deepEquivalent().deprecatedNode()); 1141 } 1142 1095 1143 IntRect FrameSelection::localCaretRect() 1096 1144 { 1097 if (m_caretRectNeedsUpdate) 1098 updateCaretRect(); 1099 1145 if (m_caretRectNeedsUpdate) { 1146 bool isOrphaned = !isNone() && (!m_selection.start().anchorNode()->inDocument() || !m_selection.end().anchorNode()->inDocument()); 1147 updateCaretRect(m_frame->document(), VisiblePosition(m_selection.start(), m_selection.affinity()), m_selection.selectionType(), isOrphaned); 1148 } 1149 1100 1150 return m_caretRect; 1101 1151 } 1102 1152 1103 IntRect FrameSelection::absoluteBoundsForLocalRect(const IntRect& rect) const1104 { 1105 RenderObject* caretPainter = caretRenderer( );1153 IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const IntRect& rect) const 1154 { 1155 RenderObject* caretPainter = caretRenderer(node); 1106 1156 if (!caretPainter) 1107 1157 return IntRect(); … … 1129 1179 } 1130 1180 1131 IntRect FrameSelection::caretRepaintRect() const1132 { 1133 return absoluteBoundsForLocalRect( repaintRectForCaret(localCaretRectForPainting()));1181 IntRect CaretBase::caretRepaintRect(Node* node) const 1182 { 1183 return absoluteBoundsForLocalRect(node, repaintRectForCaret(localCaretRectForPainting())); 1134 1184 } 1135 1185 … … 1141 1191 if (!m_frame) 1142 1192 return false; 1143 1193 1144 1194 FrameView* v = m_frame->document()->view(); 1145 1195 if (!v) … … 1153 1203 IntRect oldAbsCaretBounds = m_absCaretBounds; 1154 1204 // FIXME: Rename m_caretRect to m_localCaretRect. 1155 m_absCaretBounds = absoluteBoundsForLocalRect(m_ caretRect);1205 m_absCaretBounds = absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), m_caretRect); 1156 1206 m_absCaretBoundsDirty = false; 1157 1207 … … 1161 1211 IntRect oldAbsoluteCaretRepaintBounds = m_absoluteCaretRepaintBounds; 1162 1212 // We believe that we need to inflate the local rect before transforming it to obtain the repaint bounds. 1163 m_absoluteCaretRepaintBounds = caretRepaintRect( );1213 m_absoluteCaretRepaintBounds = caretRepaintRect(m_selection.start().deprecatedNode()); 1164 1214 1165 1215 #if ENABLE(TEXT_CARET) … … 1167 1217 // FIXME: make caret repainting container-aware. 1168 1218 view->repaintRectangleInViewAndCompositedLayers(oldAbsoluteCaretRepaintBounds, false); 1169 if (shouldRepaintCaret(view ))1219 if (shouldRepaintCaret(view, isContentEditable())) 1170 1220 view->repaintRectangleInViewAndCompositedLayers(m_absoluteCaretRepaintBounds, false); 1171 1221 } … … 1174 1224 } 1175 1225 1176 bool FrameSelection::shouldRepaintCaret(const RenderView* view) const1226 bool CaretBase::shouldRepaintCaret(const RenderView* view, bool isContentEditable) const 1177 1227 { 1178 1228 ASSERT(view); 1179 1229 Frame* frame = view->frameView() ? view->frameView()->frame() : 0; // The frame where the selection started. 1180 1230 bool caretBrowsing = frame && frame->settings() && frame->settings()->caretBrowsingEnabled(); 1181 return (caretBrowsing || isContentEditable ());1231 return (caretBrowsing || isContentEditable); 1182 1232 } 1183 1233 … … 1187 1237 return; 1188 1238 1189 Document* d = m_selection.start().anchorNode()->document(); 1190 1191 // recomputeCaretRect will always return false for the drag caret, 1192 // because its m_frame is always 0. 1193 bool caretRectChanged = recomputeCaretRect(); 1194 1239 CaretBase::invalidateCaretRect(m_selection.start().deprecatedNode(), recomputeCaretRect()); 1240 } 1241 1242 void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged) 1243 { 1195 1244 // EDIT FIXME: This is an unfortunate hack. 1196 1245 // Basically, we can't trust this layout position since we … … 1207 1256 1208 1257 if (!caretRectChanged) { 1209 RenderView* view = toRenderView( d->renderer());1210 if (view && shouldRepaintCaret(view ))1211 view->repaintRectangleInViewAndCompositedLayers(caretRepaintRect( ), false);1258 RenderView* view = toRenderView(node->document()->renderer()); 1259 if (view && shouldRepaintCaret(view, node->isContentEditable())) 1260 view->repaintRectangleInViewAndCompositedLayers(caretRepaintRect(node), false); 1212 1261 } 1213 1262 } 1214 1263 1215 1264 void FrameSelection::paintCaret(GraphicsContext* context, int tx, int ty, const IntRect& clipRect) 1265 { 1266 if (!m_selection.isCaret()) 1267 return; 1268 1269 CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, tx, ty, clipRect); 1270 } 1271 1272 void CaretBase::paintCaret(Node* node, GraphicsContext* context, int tx, int ty, const IntRect& clipRect) const 1216 1273 { 1217 1274 #if ENABLE(TEXT_CARET) … … 1220 1277 if (!m_caretPaint) 1221 1278 return; 1222 if (!m_selection.isCaret())1223 return;1224 1279 1225 1280 IntRect drawingRect = localCaretRectForPainting(); 1226 if (caretRenderer() && caretRenderer()->isBox()) 1227 toRenderBox(caretRenderer())->flipForWritingMode(drawingRect); 1281 RenderObject* renderer = caretRenderer(node); 1282 if (renderer && renderer->isBox()) 1283 toRenderBox(renderer)->flipForWritingMode(drawingRect); 1228 1284 drawingRect.move(tx, ty); 1229 1285 IntRect caret = intersection(drawingRect, clipRect); … … 1233 1289 Color caretColor = Color::black; 1234 1290 ColorSpace colorSpace = ColorSpaceDeviceRGB; 1235 Element* element = rootEditableElement();1291 Element* element = node->rootEditableElement(); 1236 1292 if (element && element->renderer()) { 1237 1293 caretColor = element->renderer()->style()->visitedDependentColor(CSSPropertyColor); … … 1241 1297 context->fillRect(caret, caretColor, colorSpace); 1242 1298 #else 1299 UNUSED_PARAM(node); 1243 1300 UNUSED_PARAM(context); 1244 1301 UNUSED_PARAM(tx); … … 1481 1538 } 1482 1539 1483 bool FrameSelection::caretRendersInsideNode(Node* node) const1484 {1485 if (!node)1486 return false;1487 return !isTableElement(node) && !editingIgnoresContent(node);1488 }1489 1490 1540 void FrameSelection::focusedOrActiveStateChanged() 1491 1541 { … … 1556 1606 void FrameSelection::updateAppearance() 1557 1607 { 1558 ASSERT(!m_isDragCaretController);1559 1560 1608 #if ENABLE(TEXT_CARET) 1561 1609 bool caretRectChanged = recomputeCaretRect(); … … 1710 1758 } 1711 1759 1712 void FrameSelection::paintDragCaret(GraphicsContext* p, int tx, int ty, const IntRect& clipRect) const1760 void DragCaretController::paintDragCaret(Frame* frame, GraphicsContext* p, int tx, int ty, const IntRect& clipRect) const 1713 1761 { 1714 1762 #if ENABLE(TEXT_CARET) 1715 FrameSelection* dragCaretController = m_frame->page()->dragCaretController(); 1716 ASSERT(dragCaretController->selection().isCaret()); 1717 if (dragCaretController->selection().start().anchorNode()->document()->frame() == m_frame) 1718 dragCaretController->paintCaret(p, tx, ty, clipRect); 1763 if (m_position.deepEquivalent().deprecatedNode()->document()->frame() == frame) 1764 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, tx, ty, clipRect); 1719 1765 #else 1720 1766 UNUSED_PARAM(p); -
trunk/Source/WebCore/editing/FrameSelection.h
r85864 r86039 49 49 enum DirectionalityPolicy { MakeNonDirectionalSelection, MakeDirectionalSelection }; 50 50 51 class FrameSelection { 51 class CaretBase { 52 WTF_MAKE_NONCOPYABLE(CaretBase); 53 WTF_MAKE_FAST_ALLOCATED; 54 protected: 55 CaretBase(); 56 57 void invalidateCaretRect(Node*, bool caretRectChanged = false); 58 void updateCaretRect(Document*, const VisiblePosition& caretPosition, VisibleSelection::SelectionType, bool isOrphaned); 59 IntRect absoluteBoundsForLocalRect(Node*, const IntRect&) const; 60 IntRect absoluteCaretBounds(bool isContentEditable); 61 IntRect caretRepaintRect(Node*) const; 62 bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const; 63 64 IntRect localCaretRectForPainting() const { return m_caretRect; } 65 void paintCaret(Node*, GraphicsContext*, int tx, int ty, const IntRect& clipRect) const; 66 67 RenderObject* caretRenderer(Node*) const; 68 69 IntRect m_caretRect; // caret rect in coords local to the renderer responsible for painting the caret 70 IntRect m_absCaretBounds; // absolute bounding rect for the caret 71 IntRect m_absoluteCaretRepaintBounds; 72 73 bool m_caretRectNeedsUpdate; // true if m_caretRect and m_absCaretBounds need to be calculated 74 bool m_absCaretBoundsDirty; 75 bool m_caretVisible; 76 bool m_caretPaint; 77 }; 78 79 class DragCaretController : private CaretBase { 80 WTF_MAKE_NONCOPYABLE(DragCaretController); 81 WTF_MAKE_FAST_ALLOCATED; 82 public: 83 DragCaretController(); 84 85 RenderObject* caretRenderer() const; 86 void paintDragCaret(Frame*, GraphicsContext*, int tx, int ty, const IntRect& clipRect) const; 87 88 bool isContentEditable() const { return m_position.rootEditableElement(); } 89 bool isContentRichlyEditable() const; 90 91 bool hasCaret() const { return m_position.isNotNull(); } 92 const VisiblePosition& caretPosition() { return m_position; } 93 void setCaretPosition(const VisiblePosition&); 94 void clear() { setCaretPosition(VisiblePosition()); } 95 96 void nodeWillBeRemoved(Node*); 97 98 private: 99 VisiblePosition m_position; 100 }; 101 102 class FrameSelection : private CaretBase { 52 103 WTF_MAKE_NONCOPYABLE(FrameSelection); 53 104 WTF_MAKE_FAST_ALLOCATED; … … 64 115 typedef unsigned SetSelectionOptions; 65 116 66 FrameSelection(Frame* = 0 , bool isDragCaretController = false);117 FrameSelection(Frame* = 0); 67 118 68 119 Element* rootEditableElement() const { return m_selection.rootEditableElement(); } … … 115 166 // Caret rect local to the caret's renderer 116 167 IntRect localCaretRect(); 117 IntRect localCaretRectForPainting() const { return m_caretRect; }118 168 119 169 // Bounds of (possibly transformed) caret in absolute coords … … 140 190 void setCaretVisible(bool = true); 141 191 void clearCaretRectIfNeeded(); 142 bool recomputeCaretRect(); // returns true if caret rect moved192 bool recomputeCaretRect(); 143 193 void invalidateCaretRect(); 144 194 void paintCaret(GraphicsContext*, int tx, int ty, const IntRect& clipRect); … … 204 254 VisiblePosition modifyMovingBackward(TextGranularity); 205 255 206 void updateCaretRect();207 IntRect caretRepaintRect() const;208 bool shouldRepaintCaret(const RenderView* view) const;209 210 256 int xPosForVerticalArrowNavigation(EPositionType); 211 257 … … 213 259 214 260 void focusedOrActiveStateChanged(); 215 bool caretRendersInsideNode(Node*) const;216 217 IntRect absoluteBoundsForLocalRect(const IntRect&) const;218 261 219 262 void caretBlinkTimerFired(Timer<FrameSelection>*); … … 232 275 Timer<FrameSelection> m_caretBlinkTimer; 233 276 234 IntRect m_caretRect; // caret rect in coords local to the renderer responsible for painting the caret235 IntRect m_absCaretBounds; // absolute bounding rect for the caret236 IntRect m_absoluteCaretRepaintBounds;237 238 bool m_caretRectNeedsUpdate; // true if m_caretRect and m_absCaretBounds need to be calculated239 bool m_absCaretBoundsDirty;240 277 bool m_isDirectional; 241 bool m_isDragCaretController;242 278 bool m_isCaretBlinkingSuspended; 243 279 bool m_focused; 244 bool m_caretVisible;245 bool m_caretPaint;246 280 }; 247 281 -
trunk/Source/WebCore/page/DragController.cpp
r85864 r86039 331 331 if (!element) 332 332 return false; 333 if (!asFileInput(element)) { 334 VisibleSelection dragCaret = m_documentUnderMouse->frame()->visiblePositionForPoint(point); 335 m_page->dragCaretController()->setSelection(dragCaret); 336 } 333 if (!asFileInput(element)) 334 m_page->dragCaretController()->setCaretPosition(m_documentUnderMouse->frame()->visiblePositionForPoint(point)); 337 335 338 336 Frame* innerFrame = element->document()->frame(); … … 373 371 bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData* dragData) 374 372 { 375 ASSERT(!m_page->dragCaretController()->isNone()); 376 VisibleSelection dragCaret(m_page->dragCaretController()->selection()); 377 String text = dragCaret.isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame); 378 Node* target = innerFrame->editor()->findEventTargetFrom(dragCaret); 373 ASSERT(m_page->dragCaretController()->hasCaret()); 374 String text = m_page->dragCaretController()->isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame); 375 Node* target = innerFrame->editor()->findEventTargetFrom(m_page->dragCaretController()->caretPosition()); 379 376 ExceptionCode ec = 0; 380 377 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(), text), ec); … … 396 393 ASSERT(innerFrame); 397 394 398 if ( !m_page->dragCaretController()->isNone() && !dispatchTextInputEventFor(innerFrame, dragData))395 if (m_page->dragCaretController()->hasCaret() && !dispatchTextInputEventFor(innerFrame, dragData)) 399 396 return true; 400 397 … … 442 439 } 443 440 444 VisibleSelection dragCaret (m_page->dragCaretController()->selection());441 VisibleSelection dragCaret = m_page->dragCaretController()->caretPosition(); 445 442 m_page->dragCaretController()->clear(); 446 443 RefPtr<Range> range = dragCaret.toNormalizedRange(); … … 852 849 return; 853 850 IntPoint framePoint = frameView->windowToContents(windowPoint); 854 VisibleSelection dragCaret(frame->visiblePositionForPoint(framePoint)); 855 m_page->dragCaretController()->set Selection(dragCaret);851 852 m_page->dragCaretController()->setCaretPosition(frame->visiblePositionForPoint(framePoint)); 856 853 } 857 854 -
trunk/Source/WebCore/page/Page.cpp
r85895 r86039 116 116 Page::Page(const PageClients& pageClients) 117 117 : m_chrome(adoptPtr(new Chrome(this, pageClients.chromeClient))) 118 , m_dragCaretController(adoptPtr(new FrameSelection(0, true)))118 , m_dragCaretController(adoptPtr(new DragCaretController)) 119 119 #if ENABLE(DRAG_SUPPORT) 120 120 , m_dragController(adoptPtr(new DragController(this, pageClients.dragClient))) -
trunk/Source/WebCore/page/Page.h
r85864 r86039 55 55 class DeviceOrientationController; 56 56 class Document; 57 class DragCaretController; 57 58 class DragClient; 58 59 class DragController; … … 166 167 167 168 Chrome* chrome() const { return m_chrome.get(); } 168 FrameSelection* dragCaretController() const { return m_dragCaretController.get(); }169 DragCaretController* dragCaretController() const { return m_dragCaretController.get(); } 169 170 #if ENABLE(DRAG_SUPPORT) 170 171 DragController* dragController() const { return m_dragController.get(); } … … 316 317 317 318 OwnPtr<Chrome> m_chrome; 318 OwnPtr< FrameSelection> m_dragCaretController;319 OwnPtr<DragCaretController> m_dragCaretController; 319 320 320 321 #if ENABLE(ACCELERATED_2D_CANVAS) -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r85876 r86039 2430 2430 void RenderBlock::paintCaret(PaintInfo& paintInfo, int tx, int ty, CaretType type) 2431 2431 { 2432 FrameSelection* selection = type == CursorCaret ? frame()->selection() : frame()->page()->dragCaretController();2433 2434 2432 // Paint the caret if the FrameSelection says so or if caret browsing is enabled 2435 2433 bool caretBrowsing = frame()->settings() && frame()->settings()->caretBrowsingEnabled(); 2436 RenderObject* caretPainter = selection->caretRenderer(); 2437 if (caretPainter == this && (selection->isContentEditable() || caretBrowsing)) { 2434 RenderObject* caretPainter; 2435 bool isContentEditable; 2436 if (type == CursorCaret) { 2437 caretPainter = frame()->selection()->caretRenderer(); 2438 isContentEditable = frame()->selection()->isContentEditable(); 2439 } else { 2440 caretPainter = frame()->page()->dragCaretController()->caretRenderer(); 2441 isContentEditable = frame()->page()->dragCaretController()->isContentEditable(); 2442 } 2443 2444 if (caretPainter == this && (isContentEditable || caretBrowsing)) { 2438 2445 // Convert the painting offset into the local coordinate system of this renderer, 2439 2446 // to match the localCaretRect computed by the FrameSelection … … 2443 2450 frame()->selection()->paintCaret(paintInfo.context, tx, ty, paintInfo.rect); 2444 2451 else 2445 frame()-> selection()->paintDragCaret(paintInfo.context, tx, ty, paintInfo.rect);2452 frame()->page()->dragCaretController()->paintDragCaret(frame(), paintInfo.context, tx, ty, paintInfo.rect); 2446 2453 } 2447 2454 }
Note: See TracChangeset
for help on using the changeset viewer.