Changeset 69150 in webkit
- Timestamp:
- Oct 5, 2010 2:42:35 PM (14 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r69116 r69150 1 2010-10-05 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Start sending Carbon plug-in events in th Carbon event model 6 https://bugs.webkit.org/show_bug.cgi?id=47209 7 <rdar://problem/8515677> 8 9 * WebProcess/Plugins/Netscape/NetscapePlugin.cpp: 10 (WebKit::NetscapePlugin::NetscapePlugin): 11 Initialize the NP_CGContext struct. 12 13 * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm: 14 (WebKit::NetscapePlugin::platformPostInitialize): 15 Create a fake Carbon window. 16 17 (WebKit::NetscapePlugin::platformDestroy): 18 Destroy the Carbon window. 19 20 (WebKit::modifiersForEvent): 21 Given a WebEvent, return the EventRecord modifiers. 22 23 (WebKit::NetscapePlugin::platformPaint): 24 (WebKit::NetscapePlugin::platformHandleMouseEvent): 25 (WebKit::NetscapePlugin::platformHandleWheelEvent): 26 (WebKit::NetscapePlugin::platformHandleMouseEnterEvent): 27 (WebKit::NetscapePlugin::platformHandleMouseLeaveEvent): 28 (WebKit::NetscapePlugin::platformSetFocus): 29 (WebKit::NetscapePlugin::windowFocusChanged): 30 Create Carbon EventRecords and call NPP_HandleEvent. 31 1 32 2010-10-05 Sam Weinig <sam@webkit.org> 2 33 -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
r68988 r69150 57 57 , m_drawingModel(static_cast<NPDrawingModel>(-1)) 58 58 , m_eventModel(static_cast<NPEventModel>(-1)) 59 #ifndef NP_NO_CARBON 60 , m_npCGContext() 61 #endif 59 62 #endif 60 63 { -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
r68988 r69150 56 56 NPError setDrawingModel(NPDrawingModel); 57 57 NPError setEventModel(NPEventModel); 58 #ifndef NP_NO_CARBON 59 WindowRef windowRef() const; 60 #endif 58 61 #elif PLATFORM(WIN) 59 62 HWND containingWindow() const; … … 187 190 NPEventModel m_eventModel; 188 191 RetainPtr<PlatformLayer> m_pluginLayer; 192 #ifndef NP_NO_CARBON 193 NP_CGContext m_npCGContext; 194 #endif 189 195 #elif PLATFORM(WIN) 190 196 HWND m_window; -
trunk/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
r68988 r69150 26 26 #include "NetscapePlugin.h" 27 27 28 #include <AppKit/AppKit.h>28 #include "NotImplemented.h" 29 29 #include "WebEvent.h" 30 30 #include <WebCore/GraphicsContext.h> … … 123 123 } 124 124 125 #ifndef NP_NO_CARBON 126 if (m_eventModel == NPEventModelCarbon) { 127 // Initialize the fake Carbon window. 128 Rect bounds = { 0, 0, 0, 0 }; 129 CreateNewWindow(kDocumentWindowClass, 0, &bounds, reinterpret_cast<WindowRef*>(&m_npCGContext.window)); 130 131 // FIXME: Disable the backing store. 132 133 m_npWindow.window = &m_npCGContext; 134 } 135 #endif 136 125 137 return true; 126 138 } … … 128 140 void NetscapePlugin::platformDestroy() 129 141 { 142 #ifndef NP_NO_CARBON 143 if (m_eventModel == NPEventModelCarbon) { 144 // Destroy the fake Carbon window. 145 ASSERT(m_npCGContext.window); 146 DisposeWindow(static_cast<WindowRef>(m_npCGContext.window)); 147 } 148 #endif 130 149 } 131 150 … … 144 163 } 145 164 165 #ifndef NP_NO_CARBON 166 WindowRef NetscapePlugin::windowRef() const 167 { 168 ASSERT(m_eventModel == NPEventModelCarbon); 169 170 return reinterpret_cast<WindowRef>(m_npCGContext.window); 171 } 172 173 static inline EventRecord initializeEventRecord(EventKind eventKind) 174 { 175 EventRecord eventRecord; 176 177 eventRecord.what = eventKind; 178 eventRecord.message = 0; 179 eventRecord.when = TickCount(); 180 eventRecord.where = Point(); 181 eventRecord.modifiers = 0; 182 183 return eventRecord; 184 } 185 186 static bool anyMouseButtonIsDown(const WebEvent& event) 187 { 188 if (event.type() == WebEvent::MouseDown) 189 return true; 190 191 if (event.type() == WebEvent::MouseMove && static_cast<const WebMouseEvent&>(event).button() != WebMouseEvent::NoButton) 192 return true; 193 194 return false; 195 } 196 197 static bool rightMouseButtonIsDown(const WebEvent& event) 198 { 199 if (event.type() == WebEvent::MouseDown && static_cast<const WebMouseEvent&>(event).button() == WebMouseEvent::RightButton) 200 return true; 201 202 if (event.type() == WebEvent::MouseMove && static_cast<const WebMouseEvent&>(event).button() == WebMouseEvent::RightButton) 203 return true; 204 205 return false; 206 } 207 208 209 static EventModifiers modifiersForEvent(const WebEvent& event) 210 { 211 EventModifiers modifiers = 0; 212 213 // We only want to set the btnState if a mouse button is _not_ down. 214 if (!anyMouseButtonIsDown(event)) 215 modifiers |= btnState; 216 217 if (event.metaKey()) 218 modifiers |= cmdKey; 219 220 if (event.shiftKey()) 221 modifiers |= shiftKey; 222 223 if (event.altKey()) 224 modifiers |= optionKey; 225 226 // Set controlKey if the control key is down or the right mouse button is down. 227 if (event.controlKey() || rightMouseButtonIsDown(event)) 228 modifiers |= controlKey; 229 230 return modifiers; 231 } 232 233 #endif 234 146 235 void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect) 147 236 { 237 CGContextRef platformContext = context->platformContext(); 238 148 239 // Translate the context so that the origin is at the top left corner of the plug-in view. 149 240 context->translate(m_frameRect.x(), m_frameRect.y()); … … 157 248 NPCocoaEvent event = initializeEvent(NPCocoaEventDrawRect); 158 249 159 event.data.draw.context = context->platformContext();250 event.data.draw.context = platformContext; 160 251 event.data.draw.x = dirtyRect.x() - m_frameRect.x(); 161 252 event.data.draw.y = dirtyRect.y() - m_frameRect.y(); … … 166 257 break; 167 258 } 168 259 260 #ifndef NP_NO_CARBON 261 case NPEventModelCarbon: { 262 if (platformContext != m_npCGContext.context) { 263 m_npCGContext.context = platformContext; 264 callSetWindow(); 265 } 266 267 EventRecord event = initializeEventRecord(updateEvt); 268 event.message = reinterpret_cast<unsigned long>(windowRef()); 269 270 NPP_HandleEvent(&event); 271 break; 272 } 273 #endif 274 169 275 default: 170 276 ASSERT_NOT_REACHED(); … … 252 358 } 253 359 360 #ifndef NP_NO_CARBON 361 case NPEventModelCarbon: { 362 notImplemented(); 363 return false; 364 } 365 #endif 366 254 367 default: 255 368 ASSERT_NOT_REACHED(); … … 276 389 } 277 390 391 #ifndef NP_NO_CARBON 392 case NPEventModelCarbon: 393 // Carbon doesn't have wheel events. 394 break; 395 #endif 396 278 397 default: 279 398 ASSERT_NOT_REACHED(); … … 293 412 } 294 413 414 #ifndef NP_NO_CARBON 415 case NPEventModelCarbon: { 416 EventRecord eventRecord = initializeEventRecord(adjustCursorEvent); 417 eventRecord.modifiers = modifiersForEvent(mouseEvent); 418 419 return NPP_HandleEvent(&eventRecord); 420 } 421 #endif 422 295 423 default: 296 424 ASSERT_NOT_REACHED(); … … 309 437 return NPP_HandleEvent(&event); 310 438 } 439 440 #ifndef NP_NO_CARBON 441 case NPEventModelCarbon: { 442 EventRecord eventRecord = initializeEventRecord(adjustCursorEvent); 443 eventRecord.modifiers = modifiersForEvent(mouseEvent); 444 445 return NPP_HandleEvent(&eventRecord); 446 } 447 #endif 311 448 312 449 default: … … 385 522 } 386 523 524 #ifndef NP_NO_CARBON 525 case NPEventModelCarbon: { 526 EventRecord event = initializeEventRecord(hasFocus ? getFocusEvent : loseFocusEvent); 527 528 NPP_HandleEvent(&event); 529 break; 530 } 531 #endif 532 387 533 default: 388 534 ASSERT_NOT_REACHED(); … … 401 547 break; 402 548 } 549 550 #ifndef NP_NO_CARBON 551 case NPEventModelCarbon: { 552 HiliteWindow(windowRef(), hasFocus); 553 if (hasFocus) 554 SetUserFocusWindow(windowRef()); 555 556 EventRecord event = initializeEventRecord(activateEvt); 557 event.message = reinterpret_cast<unsigned long>(windowRef()); 558 if (hasFocus) 559 event.modifiers |= activeFlag; 560 561 NPP_HandleEvent(&event); 562 break; 563 } 564 #endif 403 565 404 566 default:
Note: See TracChangeset
for help on using the changeset viewer.