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

Side by Side Diff: Source/web/WebPluginContainerImpl.cpp

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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
« no previous file with comments | « Source/web/WebPasswordFormData.cpp ('k') | Source/web/WebSearchableFormData.cpp » ('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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 void WebPluginContainerImpl::setPlugin(WebPlugin* plugin) 260 void WebPluginContainerImpl::setPlugin(WebPlugin* plugin)
261 { 261 {
262 if (plugin != m_webPlugin) { 262 if (plugin != m_webPlugin) {
263 m_element->resetInstance(); 263 m_element->resetInstance();
264 m_webPlugin = plugin; 264 m_webPlugin = plugin;
265 } 265 }
266 } 266 }
267 267
268 float WebPluginContainerImpl::deviceScaleFactor() 268 float WebPluginContainerImpl::deviceScaleFactor()
269 { 269 {
270 Page* page = m_element->document()->page(); 270 Page* page = m_element->document().page();
271 if (!page) 271 if (!page)
272 return 1.0; 272 return 1.0;
273 return page->deviceScaleFactor(); 273 return page->deviceScaleFactor();
274 } 274 }
275 275
276 float WebPluginContainerImpl::pageScaleFactor() 276 float WebPluginContainerImpl::pageScaleFactor()
277 { 277 {
278 Page* page = m_element->document()->page(); 278 Page* page = m_element->document().page();
279 if (!page) 279 if (!page)
280 return 1.0; 280 return 1.0;
281 return page->pageScaleFactor(); 281 return page->pageScaleFactor();
282 } 282 }
283 283
284 float WebPluginContainerImpl::pageZoomFactor() 284 float WebPluginContainerImpl::pageZoomFactor()
285 { 285 {
286 Frame* frame = m_element->document()->frame(); 286 Frame* frame = m_element->document().frame();
287 if (!frame) 287 if (!frame)
288 return 1.0; 288 return 1.0;
289 return frame->pageZoomFactor(); 289 return frame->pageZoomFactor();
290 } 290 }
291 291
292 void WebPluginContainerImpl::setWebLayer(WebLayer* layer) 292 void WebPluginContainerImpl::setWebLayer(WebLayer* layer)
293 { 293 {
294 if (m_webLayer == layer) 294 if (m_webLayer == layer)
295 return; 295 return;
296 296
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 m_scrollbarGroup->setFrameRect(frameRect()); 410 m_scrollbarGroup->setFrameRect(frameRect());
411 } 411 }
412 } 412 }
413 413
414 void WebPluginContainerImpl::allowScriptObjects() 414 void WebPluginContainerImpl::allowScriptObjects()
415 { 415 {
416 } 416 }
417 417
418 void WebPluginContainerImpl::clearScriptObjects() 418 void WebPluginContainerImpl::clearScriptObjects()
419 { 419 {
420 Frame* frame = m_element->document()->frame(); 420 Frame* frame = m_element->document().frame();
421 if (!frame) 421 if (!frame)
422 return; 422 return;
423 frame->script()->cleanupScriptObjectsForPlugin(this); 423 frame->script()->cleanupScriptObjectsForPlugin(this);
424 } 424 }
425 425
426 NPObject* WebPluginContainerImpl::scriptableObjectForElement() 426 NPObject* WebPluginContainerImpl::scriptableObjectForElement()
427 { 427 {
428 return m_element->getNPObject(); 428 return m_element->getNPObject();
429 } 429 }
430 430
431 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed) 431 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed)
432 { 432 {
433 Frame* frame = m_element->document()->frame(); 433 Frame* frame = m_element->document().frame();
434 if (!frame) 434 if (!frame)
435 return WebString(); 435 return WebString();
436 436
437 const KURL& kurl = url; 437 const KURL& kurl = url;
438 ASSERT(kurl.protocolIs("javascript")); 438 ASSERT(kurl.protocolIs("javascript"));
439 439
440 String script = decodeURLEscapeSequences( 440 String script = decodeURLEscapeSequences(
441 kurl.string().substring(strlen("javascript:"))); 441 kurl.string().substring(strlen("javascript:")));
442 442
443 ScriptValue result = frame->script()->executeScript(script, popupsAllowed); 443 ScriptValue result = frame->script()->executeScript(script, popupsAllowed);
444 444
445 // Failure is reported as a null string. 445 // Failure is reported as a null string.
446 String resultStr; 446 String resultStr;
447 result.getString(resultStr); 447 result.getString(resultStr);
448 return resultStr; 448 return resultStr;
449 } 449 }
450 450
451 void WebPluginContainerImpl::loadFrameRequest(const WebURLRequest& request, cons t WebString& target, bool notifyNeeded, void* notifyData) 451 void WebPluginContainerImpl::loadFrameRequest(const WebURLRequest& request, cons t WebString& target, bool notifyNeeded, void* notifyData)
452 { 452 {
453 Frame* frame = m_element->document()->frame(); 453 Frame* frame = m_element->document().frame();
454 if (!frame || !frame->loader()->documentLoader()) 454 if (!frame || !frame->loader()->documentLoader())
455 return; // FIXME: send a notification in this case? 455 return; // FIXME: send a notification in this case?
456 456
457 if (notifyNeeded) { 457 if (notifyNeeded) {
458 // FIXME: This is a bit of hack to allow us to observe completion of 458 // FIXME: This is a bit of hack to allow us to observe completion of
459 // our frame request. It would be better to evolve FrameLoader to 459 // our frame request. It would be better to evolve FrameLoader to
460 // support a completion callback instead. 460 // support a completion callback instead.
461 OwnPtr<WebPluginLoadObserver> observer = adoptPtr(new WebPluginLoadObser ver(this, request.url(), notifyData)); 461 OwnPtr<WebPluginLoadObserver> observer = adoptPtr(new WebPluginLoadObser ver(this, request.url(), notifyData));
462 // FIXME: Calling get here is dangerous! What if observer is freed? 462 // FIXME: Calling get here is dangerous! What if observer is freed?
463 m_pluginLoadObservers.append(observer.get()); 463 m_pluginLoadObservers.append(observer.get());
464 WebDataSourceImpl::setNextPluginLoadObserver(observer.release()); 464 WebDataSourceImpl::setNextPluginLoadObserver(observer.release());
465 } 465 }
466 466
467 FrameLoadRequest frameRequest(frame->document()->securityOrigin(), request.t oResourceRequest(), target); 467 FrameLoadRequest frameRequest(frame->document()->securityOrigin(), request.t oResourceRequest(), target);
468 UserGestureIndicator gestureIndicator(request.hasUserGesture() ? DefinitelyP rocessingNewUserGesture : PossiblyProcessingUserGesture); 468 UserGestureIndicator gestureIndicator(request.hasUserGesture() ? DefinitelyP rocessingNewUserGesture : PossiblyProcessingUserGesture);
469 frame->loader()->load(frameRequest); 469 frame->loader()->load(frameRequest);
470 } 470 }
471 471
472 void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel) 472 void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel)
473 { 473 {
474 WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->pa ge()); 474 WebViewImpl* view = WebViewImpl::fromPage(m_element->document().frame()->pag e());
475 view->fullFramePluginZoomLevelChanged(zoomLevel); 475 view->fullFramePluginZoomLevelChanged(zoomLevel);
476 } 476 }
477 477
478 bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect) 478 bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect)
479 { 479 {
480 Frame* frame = m_element->document()->frame(); 480 Frame* frame = m_element->document().frame();
481 if (!frame) 481 if (!frame)
482 return false; 482 return false;
483 483
484 // hitTestResultAtPoint() takes a padding rectangle. 484 // hitTestResultAtPoint() takes a padding rectangle.
485 // FIXME: We'll be off by 1 when the width or height is even. 485 // FIXME: We'll be off by 1 when the width or height is even.
486 IntRect documentRect(x() + rect.x, y() + rect.y, rect.width, rect.height); 486 IntRect documentRect(x() + rect.x, y() + rect.y, rect.width, rect.height);
487 LayoutPoint center = documentRect.center(); 487 LayoutPoint center = documentRect.center();
488 // Make the rect we're checking (the point surrounded by padding rects) cont ained inside the requested rect. (Note that -1/2 is 0.) 488 // Make the rect we're checking (the point surrounded by padding rects) cont ained inside the requested rect. (Note that -1/2 is 0.)
489 LayoutSize padding((documentRect.width() - 1) / 2, (documentRect.height() - 1) / 2); 489 LayoutSize padding((documentRect.width() - 1) / 2, (documentRect.height() - 1) / 2);
490 HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(center, H itTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShado wContent, padding); 490 HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(center, H itTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShado wContent, padding);
491 const HitTestResult::NodeSet& nodes = result.rectBasedTestResult(); 491 const HitTestResult::NodeSet& nodes = result.rectBasedTestResult();
492 if (nodes.size() != 1) 492 if (nodes.size() != 1)
493 return false; 493 return false;
494 return nodes.first().get() == m_element; 494 return nodes.first().get() == m_element;
495 } 495 }
496 496
497 void WebPluginContainerImpl::requestTouchEventType(TouchEventRequestType request Type) 497 void WebPluginContainerImpl::requestTouchEventType(TouchEventRequestType request Type)
498 { 498 {
499 if (m_touchEventRequestType == requestType) 499 if (m_touchEventRequestType == requestType)
500 return; 500 return;
501 501
502 if (requestType != TouchEventRequestTypeNone && m_touchEventRequestType == T ouchEventRequestTypeNone) 502 if (requestType != TouchEventRequestTypeNone && m_touchEventRequestType == T ouchEventRequestTypeNone)
503 m_element->document()->didAddTouchEventHandler(m_element); 503 m_element->document().didAddTouchEventHandler(m_element);
504 else if (requestType == TouchEventRequestTypeNone && m_touchEventRequestType != TouchEventRequestTypeNone) 504 else if (requestType == TouchEventRequestTypeNone && m_touchEventRequestType != TouchEventRequestTypeNone)
505 m_element->document()->didRemoveTouchEventHandler(m_element); 505 m_element->document().didRemoveTouchEventHandler(m_element);
506 m_touchEventRequestType = requestType; 506 m_touchEventRequestType = requestType;
507 } 507 }
508 508
509 void WebPluginContainerImpl::setWantsWheelEvents(bool wantsWheelEvents) 509 void WebPluginContainerImpl::setWantsWheelEvents(bool wantsWheelEvents)
510 { 510 {
511 if (m_wantsWheelEvents == wantsWheelEvents) 511 if (m_wantsWheelEvents == wantsWheelEvents)
512 return; 512 return;
513 m_wantsWheelEvents = wantsWheelEvents; 513 m_wantsWheelEvents = wantsWheelEvents;
514 if (Page* page = m_element->document()->page()) { 514 if (Page* page = m_element->document().page()) {
515 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina tor()) { 515 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordina tor()) {
516 if (parent() && parent()->isFrameView()) 516 if (parent() && parent()->isFrameView())
517 scrollingCoordinator->frameViewLayoutUpdated(toFrameView(parent( ))); 517 scrollingCoordinator->frameViewLayoutUpdated(toFrameView(parent( )));
518 } 518 }
519 } 519 }
520 } 520 }
521 521
522 WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point) 522 WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point)
523 { 523 {
524 ScrollView* view = parent(); 524 ScrollView* view = parent();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 { 601 {
602 size_t pos = m_pluginLoadObservers.find(observer); 602 size_t pos = m_pluginLoadObservers.find(observer);
603 if (pos == notFound) 603 if (pos == notFound)
604 return; 604 return;
605 m_pluginLoadObservers.remove(pos); 605 m_pluginLoadObservers.remove(pos);
606 } 606 }
607 607
608 ScrollbarGroup* WebPluginContainerImpl::scrollbarGroup() 608 ScrollbarGroup* WebPluginContainerImpl::scrollbarGroup()
609 { 609 {
610 if (!m_scrollbarGroup) 610 if (!m_scrollbarGroup)
611 m_scrollbarGroup = adoptPtr(new ScrollbarGroup(m_element->document()->fr ame()->view(), frameRect())); 611 m_scrollbarGroup = adoptPtr(new ScrollbarGroup(m_element->document().fra me()->view(), frameRect()));
612 return m_scrollbarGroup.get(); 612 return m_scrollbarGroup.get();
613 } 613 }
614 614
615 void WebPluginContainerImpl::willStartLiveResize() 615 void WebPluginContainerImpl::willStartLiveResize()
616 { 616 {
617 if (m_scrollbarGroup) 617 if (m_scrollbarGroup)
618 m_scrollbarGroup->willStartLiveResize(); 618 m_scrollbarGroup->willStartLiveResize();
619 } 619 }
620 620
621 void WebPluginContainerImpl::willEndLiveResize() 621 void WebPluginContainerImpl::willEndLiveResize()
(...skipping 19 matching lines...) Expand all
641 , m_webPlugin(webPlugin) 641 , m_webPlugin(webPlugin)
642 , m_webLayer(0) 642 , m_webLayer(0)
643 , m_touchEventRequestType(TouchEventRequestTypeNone) 643 , m_touchEventRequestType(TouchEventRequestTypeNone)
644 , m_wantsWheelEvents(false) 644 , m_wantsWheelEvents(false)
645 { 645 {
646 } 646 }
647 647
648 WebPluginContainerImpl::~WebPluginContainerImpl() 648 WebPluginContainerImpl::~WebPluginContainerImpl()
649 { 649 {
650 if (m_touchEventRequestType != TouchEventRequestTypeNone) 650 if (m_touchEventRequestType != TouchEventRequestTypeNone)
651 m_element->document()->didRemoveTouchEventHandler(m_element); 651 m_element->document().didRemoveTouchEventHandler(m_element);
652 652
653 for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i) 653 for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
654 m_pluginLoadObservers[i]->clearPluginContainer(); 654 m_pluginLoadObservers[i]->clearPluginContainer();
655 m_webPlugin->destroy(); 655 m_webPlugin->destroy();
656 if (m_webLayer) 656 if (m_webLayer)
657 GraphicsLayer::unregisterContentsLayer(m_webLayer); 657 GraphicsLayer::unregisterContentsLayer(m_webLayer);
658 } 658 }
659 659
660 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) 660 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
661 { 661 {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 768
769 // Copy stashed info over, and only copy here in order not to interfere 769 // Copy stashed info over, and only copy here in order not to interfere
770 // the ctrl-c logic above. 770 // the ctrl-c logic above.
771 if (currentInputEvent 771 if (currentInputEvent
772 && WebInputEvent::isKeyboardEventType(currentInputEvent->type)) { 772 && WebInputEvent::isKeyboardEventType(currentInputEvent->type)) {
773 webEvent.modifiers |= currentInputEvent->modifiers & 773 webEvent.modifiers |= currentInputEvent->modifiers &
774 (WebInputEvent::CapsLockOn | WebInputEvent::NumLockOn); 774 (WebInputEvent::CapsLockOn | WebInputEvent::NumLockOn);
775 } 775 }
776 776
777 // Give the client a chance to issue edit comamnds. 777 // Give the client a chance to issue edit comamnds.
778 WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->pa ge()); 778 WebViewImpl* view = WebViewImpl::fromPage(m_element->document().frame()->pag e());
779 if (m_webPlugin->supportsEditCommands() && view->client()) 779 if (m_webPlugin->supportsEditCommands() && view->client())
780 view->client()->handleCurrentKeyboardEvent(); 780 view->client()->handleCurrentKeyboardEvent();
781 781
782 WebCursorInfo cursorInfo; 782 WebCursorInfo cursorInfo;
783 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo)) 783 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
784 event->setDefaultHandled(); 784 event->setDefaultHandled();
785 } 785 }
786 786
787 void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event) 787 void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event)
788 { 788 {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 for (size_t i = 0; i < cutOutRects.size(); i++) 875 for (size_t i = 0; i < cutOutRects.size(); i++)
876 cutOutRects[i].move(-frameRect.x(), -frameRect.y()); 876 cutOutRects[i].move(-frameRect.x(), -frameRect.y());
877 } 877 }
878 878
879 WebCore::IntRect WebPluginContainerImpl::windowClipRect() const 879 WebCore::IntRect WebPluginContainerImpl::windowClipRect() const
880 { 880 {
881 // Start by clipping to our bounds. 881 // Start by clipping to our bounds.
882 IntRect clipRect = 882 IntRect clipRect =
883 convertToContainingWindow(IntRect(0, 0, width(), height())); 883 convertToContainingWindow(IntRect(0, 0, width(), height()));
884 884
885 // document()->renderer() can be 0 when we receive messages from the 885 // document().renderer() can be 0 when we receive messages from the
886 // plugins while we are destroying a frame. 886 // plugins while we are destroying a frame.
887 if (m_element->renderer()->document()->renderer()) { 887 if (m_element->renderer()->document().renderer()) {
888 // Take our element and get the clip rect from the enclosing layer and 888 // Take our element and get the clip rect from the enclosing layer and
889 // frame view. 889 // frame view.
890 clipRect.intersect( 890 clipRect.intersect(
891 m_element->document()->view()->windowClipRectForFrameOwner(m_element , true)); 891 m_element->document().view()->windowClipRectForFrameOwner(m_element, true));
892 } 892 }
893 893
894 return clipRect; 894 return clipRect;
895 } 895 }
896 896
897 } // namespace WebKit 897 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/web/WebPasswordFormData.cpp ('k') | Source/web/WebSearchableFormData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698