Changeset 96566 in webkit
- Timestamp:
- Oct 3, 2011 7:26:10 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96561 r96566 1 2011-10-03 Darin Adler <darin@apple.com> 2 3 Change cursor to hand over missing plug-in message 4 https://bugs.webkit.org/show_bug.cgi?id=69312 5 6 Reviewed by Sam Weinig. 7 8 No tests because we currently don't have any test machinery for cursors. 9 10 * page/EventHandler.cpp: 11 (WebCore::OptionalCursor::OptionalCursor): Added. Construct an object 12 to represent either a cursor, or no cursor change. 13 (WebCore::OptionalCursor::isCursorChange): Added. 14 (WebCore::OptionalCursor::cursor): Added. 15 (WebCore::EventHandler::selectCursor): Changed return type to OptionalCursor, 16 moved some special cases from handleMouseMoveEvent in here. Moved the logic 17 for plug-ins and framesets into the specific renderer classes for those. 18 Added a call to the new getCursor virtual function. 19 (WebCore::EventHandler::handleMouseMoveEvent): Changed cursor setting code to 20 just be a call to selectCursor and then setCursor. Plug-in-specific code is now 21 in RenderWidget. 22 23 * page/EventHandler.h: Changed return type of selectCursor. 24 25 * page/MouseEventWithHitTestResults.cpp: Made some functions be inline. 26 * page/MouseEventWithHitTestResults.h: 27 (WebCore::MouseEventWithHitTestResults::localPoint): Made this inline. 28 (WebCore::MouseEventWithHitTestResults::scrollbar): Made this inline. 29 Yes, this has nothing to do with the rest of the patch, but it's good. 30 31 * rendering/RenderEmbeddedObject.cpp: 32 (WebCore::RenderEmbeddedObject::getReplacementTextGeometry): Made const. 33 (WebCore::RenderEmbeddedObject::isInMissingPluginIndicator): Made const. 34 Overloaded so it can be called with a point rather than an event. 35 (WebCore::shouldMissingPluginMessageBeButton): Added. Helps streamline 36 the logic below. 37 (WebCore::RenderEmbeddedObject::handleMissingPluginIndicatorEvent): 38 Changed to use shouldMissingPluginMessageBeButton. 39 (WebCore::RenderEmbeddedObject::getCursor): Added. Sets the cursor to 40 a hand when over the missing plug-in message. 41 * rendering/RenderEmbeddedObject.h: Added getCursor override. Also updated 42 for other changes above. 43 44 * rendering/RenderFrameSet.cpp: 45 (WebCore::RenderFrameSet::getCursor): Added. Contains the logic that used 46 to be hardcoded in EventHandler::selectCursor about cursors when over 47 resizable frame borders. 48 * rendering/RenderFrameSet.h: Added getCursor. 49 50 * rendering/RenderObject.cpp: 51 (WebCore::RenderObject::getCursor): Added. Returns SetCursorBasedOnStyle. 52 * rendering/RenderObject.h: Added getCursor. 53 54 * rendering/RenderWidget.cpp: 55 (WebCore::RenderWidget::getCursor): Added. Contains the logic that used 56 to be hardcoded in EventHandler::handleMouseMoveEvent to prevent setting 57 the cursor when the pointer is over a plug-in. This new code is much better, 58 because it only kicks in when there is actually a plug-in present. The old 59 was based on the HTML tag! 60 * rendering/RenderWidget.h: Added getCursor. 61 1 62 2011-10-03 Anders Carlsson <andersca@apple.com> 2 63 -
trunk/Source/WebCore/page/EventHandler.cpp
r95964 r96566 128 128 const double fakeMouseMoveInterval = 0.1; 129 129 130 enum NoCursorChangeType { NoCursorChange }; 131 132 class OptionalCursor { 133 public: 134 OptionalCursor(NoCursorChangeType) : m_isCursorChange(false) { } 135 OptionalCursor(const Cursor& cursor) : m_isCursorChange(true), m_cursor(cursor) { } 136 137 bool isCursorChange() const { return m_isCursorChange; } 138 const Cursor& cursor() const { return m_cursor; } 139 140 private: 141 bool m_isCursorChange; 142 Cursor m_cursor; 143 }; 144 130 145 static inline bool scrollNode(float delta, WheelEvent::Granularity granularity, ScrollDirection positiveDirection, ScrollDirection negativeDirection, Node* node, Node** stopNode) 131 146 { … … 1151 1166 } 1152 1167 1153 Cursor EventHandler::selectCursor(const MouseEventWithHitTestResults& event, Scrollbar* scrollbar) 1154 { 1168 OptionalCursor EventHandler::selectCursor(const MouseEventWithHitTestResults& event, Scrollbar* scrollbar) 1169 { 1170 if (m_resizeLayer && m_resizeLayer->inResizeMode()) 1171 return NoCursorChange; 1172 1173 Page* page = m_frame->page(); 1174 if (!page) 1175 return NoCursorChange; 1176 if (page->mainFrame()->eventHandler()->m_panScrollInProgress) 1177 return NoCursorChange; 1178 1155 1179 Node* node = targetNode(event); 1156 1180 RenderObject* renderer = node ? node->renderer() : 0; 1157 1181 RenderStyle* style = renderer ? renderer->style() : 0; 1158 1159 1182 bool horizontalText = !style || style->isHorizontalWritingMode(); 1160 1183 const Cursor& iBeam = horizontalText ? iBeamCursor() : verticalTextCursor(); … … 1165 1188 return iBeam; 1166 1189 1167 if (renderer && renderer->isFrameSet()) { 1168 RenderFrameSet* frameSetRenderer = toRenderFrameSet(renderer); 1169 if (frameSetRenderer->canResizeRow(event.localPoint())) 1170 return rowResizeCursor(); 1171 if (frameSetRenderer->canResizeColumn(event.localPoint())) 1172 return columnResizeCursor(); 1190 if (renderer) { 1191 Cursor overrideCursor; 1192 switch (renderer->getCursor(event.localPoint(), overrideCursor)) { 1193 case SetCursorBasedOnStyle: 1194 break; 1195 case SetCursor: 1196 return overrideCursor; 1197 case DoNotSetCursor: 1198 return NoCursorChange; 1199 } 1173 1200 } 1174 1201 … … 1630 1657 if (scrollbar && !m_mousePressed) 1631 1658 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platforms that support visual feedback on scrollbar hovering. 1632 if (Page* page = m_frame->page()) { 1633 if ((!m_resizeLayer || !m_resizeLayer->inResizeMode()) && !page->mainFrame()->eventHandler()->m_panScrollInProgress) { 1634 // Plugins set cursor on their own. The only case WebKit intervenes is resetting cursor to arrow on mouse enter, 1635 // in case the particular plugin doesn't manipulate cursor at all. Thus, even a CSS cursor set on body has no 1636 // effect on plugins (which matches Firefox). 1637 bool overPluginElement = false; 1638 if (targetNode(mev) && targetNode(mev)->isHTMLElement()) { 1639 HTMLElement* el = toHTMLElement(targetNode(mev)); 1640 overPluginElement = el->hasTagName(appletTag) || el->hasTagName(objectTag) || el->hasTagName(embedTag); 1641 } 1642 if (!overPluginElement) { 1643 if (FrameView* view = m_frame->view()) 1644 view->setCursor(selectCursor(mev, scrollbar)); 1645 } 1646 } 1659 if (FrameView* view = m_frame->view()) { 1660 OptionalCursor optionalCursor = selectCursor(mev, scrollbar); 1661 if (optionalCursor.isCursorChange()) 1662 view->setCursor(optionalCursor.cursor()); 1647 1663 } 1648 1664 } -
trunk/Source/WebCore/page/EventHandler.h
r93053 r96566 51 51 52 52 class Clipboard; 53 class Cursor;54 53 class Event; 55 54 class EventTarget; … … 63 62 class MouseEventWithHitTestResults; 64 63 class Node; 64 class OptionalCursor; 65 65 class PlatformKeyboardEvent; 66 66 class PlatformTouchEvent; … … 239 239 bool handleMouseReleaseEvent(const MouseEventWithHitTestResults&); 240 240 241 Cursor selectCursor(const MouseEventWithHitTestResults&, Scrollbar*);241 OptionalCursor selectCursor(const MouseEventWithHitTestResults&, Scrollbar*); 242 242 #if ENABLE(PAN_SCROLLING) 243 243 void updatePanScrollState(); -
trunk/Source/WebCore/page/MouseEventWithHitTestResults.cpp
r90603 r96566 34 34 } 35 35 36 const LayoutPoint MouseEventWithHitTestResults::localPoint() const37 {38 return m_hitTestResult.localPoint();39 }40 41 Scrollbar* MouseEventWithHitTestResults::scrollbar() const42 {43 return m_hitTestResult.scrollbar();44 }45 46 36 bool MouseEventWithHitTestResults::isOverLink() const 47 37 { -
trunk/Source/WebCore/page/MouseEventWithHitTestResults.h
r90603 r96566 35 35 const PlatformMouseEvent& event() const { return m_event; } 36 36 const HitTestResult& hitTestResult() const { return m_hitTestResult; } 37 const LayoutPoint localPoint() const;38 Scrollbar* scrollbar() const ;37 LayoutPoint localPoint() const { return m_hitTestResult.localPoint(); } 38 Scrollbar* scrollbar() const { return m_hitTestResult.scrollbar(); } 39 39 bool isOverLink() const; 40 40 bool isOverWidget() const { return m_hitTestResult.isOverWidget(); } -
trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp
r94912 r96566 27 27 #include "Chrome.h" 28 28 #include "ChromeClient.h" 29 #include "Cursor.h" 29 30 #include "CSSValueKeywords.h" 30 31 #include "Font.h" … … 181 182 } 182 183 183 bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, Path& path, FloatRect& replacementTextRect, Font& font, TextRun& run, float& textWidth) 184 bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, Path& path, FloatRect& replacementTextRect, Font& font, TextRun& run, float& textWidth) const 184 185 { 185 186 contentRect = contentBoxRect(); … … 250 251 } 251 252 252 bool RenderEmbeddedObject::isInMissingPluginIndicator( MouseEvent* event)253 bool RenderEmbeddedObject::isInMissingPluginIndicator(const LayoutPoint& point) const 253 254 { 254 255 FloatRect contentRect; … … 258 259 TextRun run(""); 259 260 float textWidth; 260 if (!getReplacementTextGeometry(IntPoint(), contentRect, path, replacementTextRect, font, run, textWidth)) 261 return false; 262 263 return path.contains(absoluteToLocal(event->absoluteLocation(), false, true)); 261 return getReplacementTextGeometry(IntPoint(), contentRect, path, replacementTextRect, font, run, textWidth) 262 && path.contains(point); 263 } 264 265 bool RenderEmbeddedObject::isInMissingPluginIndicator(MouseEvent* event) const 266 { 267 return isInMissingPluginIndicator(roundedLayoutPoint(absoluteToLocal(event->absoluteLocation(), false, true))); 268 } 269 270 static bool shouldMissingPluginMessageBeButton(Document* document) 271 { 272 Page* page = document->page(); 273 return page && page->chrome()->client()->shouldMissingPluginMessageBeButton(); 264 274 } 265 275 266 276 void RenderEmbeddedObject::handleMissingPluginIndicatorEvent(Event* event) 267 277 { 268 if (Page* page = document()->page()) { 269 if (!page->chrome()->client()->shouldMissingPluginMessageBeButton()) 270 return; 271 } 278 if (!shouldMissingPluginMessageBeButton(document())) 279 return; 272 280 273 281 if (!event->isMouseEvent()) … … 308 316 } 309 317 310 } 318 CursorDirective RenderEmbeddedObject::getCursor(const LayoutPoint& point, Cursor& cursor) const 319 { 320 if (m_showsMissingPluginIndicator && shouldMissingPluginMessageBeButton(document()) && isInMissingPluginIndicator(point)) { 321 cursor = handCursor(); 322 return SetCursor; 323 } 324 return RenderPart::getCursor(point, cursor); 325 } 326 327 } -
trunk/Source/WebCore/rendering/RenderEmbeddedObject.h
r90667 r96566 59 59 virtual void paintReplaced(PaintInfo&, const LayoutPoint&); 60 60 virtual void paint(PaintInfo&, const LayoutPoint&); 61 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const; 61 62 62 63 #if USE(ACCELERATED_COMPOSITING) … … 68 69 69 70 void setMissingPluginIndicatorIsPressed(bool); 70 bool isInMissingPluginIndicator(MouseEvent*); 71 bool getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, Path&, FloatRect& replacementTextRect, Font&, TextRun&, float& textWidth); 71 bool isInMissingPluginIndicator(MouseEvent*) const; 72 bool isInMissingPluginIndicator(const LayoutPoint&) const; 73 bool getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, Path&, FloatRect& replacementTextRect, Font&, TextRun&, float& textWidth) const; 72 74 73 75 String m_replacementText; -
trunk/Source/WebCore/rendering/RenderFrameSet.cpp
r96385 r96566 25 25 #include "RenderFrameSet.h" 26 26 27 #include "Cursor.h" 27 28 #include "Document.h" 28 29 #include "EventHandler.h" … … 800 801 } 801 802 803 CursorDirective RenderFrameSet::getCursor(const LayoutPoint& point, Cursor& cursor) const 804 { 805 if (canResizeRow(point)) { 806 cursor = rowResizeCursor(); 807 return SetCursor; 808 } 809 if (canResizeColumn(point)) { 810 cursor = columnResizeCursor(); 811 return SetCursor; 812 } 813 return RenderBox::getCursor(point, cursor); 814 } 815 802 816 } // namespace WebCore -
trunk/Source/WebCore/rendering/RenderFrameSet.h
r90515 r96566 69 69 bool isResizingColumn() const; 70 70 71 bool canResizeRow(const IntPoint&) const;72 bool canResizeColumn(const IntPoint&) const;71 bool canResizeRow(const LayoutPoint&) const; 72 bool canResizeColumn(const LayoutPoint&) const; 73 73 74 74 void notifyFrameEdgeInfoChanged(); … … 100 100 virtual void paint(PaintInfo&, const LayoutPoint&); 101 101 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const; 102 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const; 102 103 103 104 inline HTMLFrameSetElement* frameSet() const; -
trunk/Source/WebCore/rendering/RenderObject.cpp
r96408 r96566 2691 2691 } 2692 2692 2693 CursorDirective RenderObject::getCursor(const LayoutPoint&, Cursor&) const 2694 { 2695 return SetCursorBasedOnStyle; 2696 } 2697 2693 2698 #if ENABLE(SVG) 2699 2694 2700 RenderSVGResourceContainer* RenderObject::toRenderSVGResourceContainer() 2695 2701 { -
trunk/Source/WebCore/rendering/RenderObject.h
r96408 r96566 47 47 class AffineTransform; 48 48 class AnimationController; 49 class Cursor; 49 50 class HitTestResult; 50 51 class InlineBox; … … 66 67 67 68 struct PaintInfo; 69 70 enum CursorDirective { 71 SetCursorBasedOnStyle, 72 SetCursor, 73 DoNotSetCursor 74 }; 68 75 69 76 enum HitTestFilter { … … 659 666 virtual RenderStyle* outlineStyleForRepaint() const { return style(); } 660 667 661 void getTextDecorationColors(int decorations, Color& underline, Color& overline, 662 Color& linethrough, bool quirksMode = false); 668 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const; 669 670 void getTextDecorationColors(int decorations, Color& underline, Color& overline, Color& linethrough, bool quirksMode = false); 663 671 664 672 // Return the RenderBox in the container chain which is responsible for painting this object, or 0 -
trunk/Source/WebCore/rendering/RenderWidget.cpp
r95749 r96566 386 386 } 387 387 388 CursorDirective RenderWidget::getCursor(const LayoutPoint& point, Cursor& cursor) const 389 { 390 if (widget() && widget()->isPluginViewBase()) { 391 // A plug-in is responsible for setting the cursor when the pointer is over it. 392 return DoNotSetCursor; 393 } 394 return RenderReplaced::getCursor(point, cursor); 395 } 396 388 397 } // namespace WebCore -
trunk/Source/WebCore/rendering/RenderWidget.h
r95725 r96566 60 60 virtual void layout(); 61 61 virtual void paint(PaintInfo&, const LayoutPoint&); 62 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const; 62 63 63 64 private:
Note: See TracChangeset
for help on using the changeset viewer.