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

Side by Side Diff: Source/core/dom/WheelController.cpp

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google, Inc. All rights reserved. 2 * Copyright (C) 2013 Google, 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 * * Redistributions of source code must retain the above copyright 7 * * 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 * * Redistributions in binary form must reproduce the above copyright 9 * * 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 17 matching lines...) Expand all
28 28
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/events/ThreadLocalEventNames.h" 30 #include "core/events/ThreadLocalEventNames.h"
31 #include "core/events/WheelEvent.h" 31 #include "core/events/WheelEvent.h"
32 #include "core/frame/Frame.h" 32 #include "core/frame/Frame.h"
33 #include "core/page/Page.h" 33 #include "core/page/Page.h"
34 #include "core/page/scrolling/ScrollingCoordinator.h" 34 #include "core/page/scrolling/ScrollingCoordinator.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 WheelController::WheelController(Document* document) 38 WheelController::WheelController(Document& document)
39 : DOMWindowLifecycleObserver(document->domWindow()) 39 : DOMWindowLifecycleObserver(document.domWindow())
40 , m_wheelEventHandlerCount(0) 40 , m_wheelEventHandlerCount(0)
41 { 41 {
42 } 42 }
43 43
44 WheelController::~WheelController() 44 WheelController::~WheelController()
45 { 45 {
46 } 46 }
47 47
48 const char* WheelController::supplementName() 48 const char* WheelController::supplementName()
49 { 49 {
50 return "WheelController"; 50 return "WheelController";
51 } 51 }
52 52
53 WheelController* WheelController::from(Document* document) 53 WheelController* WheelController::from(Document& document)
54 { 54 {
55 WheelController* controller = static_cast<WheelController*>(DocumentSuppleme nt::from(document, supplementName())); 55 WheelController* controller = static_cast<WheelController*>(DocumentSuppleme nt::from(document, supplementName()));
56 if (!controller) { 56 if (!controller) {
57 controller = new WheelController(document); 57 controller = new WheelController(document);
58 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(contr oller)); 58 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(contr oller));
59 } 59 }
60 return controller; 60 return controller;
61 } 61 }
62 62
63 static void wheelEventHandlerCountChanged(Document* document) 63 static void wheelEventHandlerCountChanged(Document& document)
64 { 64 {
65 Page* page = document->page(); 65 Page* page = document.page();
66 if (!page) 66 if (!page)
67 return; 67 return;
68 68
69 ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator(); 69 ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator();
70 if (!scrollingCoordinator) 70 if (!scrollingCoordinator)
71 return; 71 return;
72 72
73 FrameView* frameView = document->view(); 73 FrameView* frameView = document.view();
74 if (!frameView) 74 if (!frameView)
75 return; 75 return;
76 76
77 scrollingCoordinator->frameViewWheelEventHandlerCountChanged(frameView); 77 scrollingCoordinator->frameViewWheelEventHandlerCountChanged(frameView);
78 } 78 }
79 79
80 void WheelController::didAddWheelEventHandler(Document* document) 80 void WheelController::didAddWheelEventHandler(Document& document)
81 { 81 {
82 ++m_wheelEventHandlerCount; 82 ++m_wheelEventHandlerCount;
83 Page* page = document->page(); 83 Page* page = document.page();
84 Frame* mainFrame = page ? page->mainFrame() : 0; 84 Frame* mainFrame = page ? page->mainFrame() : 0;
85 if (mainFrame) 85 if (mainFrame)
86 mainFrame->notifyChromeClientWheelEventHandlerCountChanged(); 86 mainFrame->notifyChromeClientWheelEventHandlerCountChanged();
87 87
88 wheelEventHandlerCountChanged(document); 88 wheelEventHandlerCountChanged(document);
89 } 89 }
90 90
91 void WheelController::didRemoveWheelEventHandler(Document* document) 91 void WheelController::didRemoveWheelEventHandler(Document& document)
92 { 92 {
93 ASSERT(m_wheelEventHandlerCount > 0); 93 ASSERT(m_wheelEventHandlerCount > 0);
94 --m_wheelEventHandlerCount; 94 --m_wheelEventHandlerCount;
95 Page* page = document->page(); 95 Page* page = document.page();
96 Frame* mainFrame = page ? page->mainFrame() : 0; 96 Frame* mainFrame = page ? page->mainFrame() : 0;
97 if (mainFrame) 97 if (mainFrame)
98 mainFrame->notifyChromeClientWheelEventHandlerCountChanged(); 98 mainFrame->notifyChromeClientWheelEventHandlerCountChanged();
99 99
100 wheelEventHandlerCountChanged(document); 100 wheelEventHandlerCountChanged(document);
101 } 101 }
102 102
103 void WheelController::didAddEventListener(DOMWindow* window, const AtomicString& eventType) 103 void WheelController::didAddEventListener(DOMWindow* window, const AtomicString& eventType)
104 { 104 {
105 if (eventType != EventTypeNames::wheel && eventType != EventTypeNames::mouse wheel) 105 if (eventType != EventTypeNames::wheel && eventType != EventTypeNames::mouse wheel)
106 return; 106 return;
107 107
108 Document* document = window->document(); 108 Document* document = window->document();
109 didAddWheelEventHandler(document); 109 ASSERT(document);
110 didAddWheelEventHandler(*document);
110 } 111 }
111 112
112 void WheelController::didRemoveEventListener(DOMWindow* window, const AtomicStri ng& eventType) 113 void WheelController::didRemoveEventListener(DOMWindow* window, const AtomicStri ng& eventType)
113 { 114 {
114 if (eventType != EventTypeNames::wheel && eventType != EventTypeNames::mouse wheel) 115 if (eventType != EventTypeNames::wheel && eventType != EventTypeNames::mouse wheel)
115 return; 116 return;
116 117
117 Document* document = window->document(); 118 Document* document = window->document();
118 didRemoveWheelEventHandler(document); 119 ASSERT(document);
120 didRemoveWheelEventHandler(*document);
119 } 121 }
120 122
121 } // namespace WebCore 123 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698