OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 // consistent since this is given to the plugin, so force everything to 0 | 738 // consistent since this is given to the plugin, so force everything to 0 |
739 // in the "everything is clipped" case. | 739 // in the "everything is clipped" case. |
740 gfx::Rect new_clip; | 740 gfx::Rect new_clip; |
741 if (!clip.IsEmpty()) | 741 if (!clip.IsEmpty()) |
742 new_clip = clip; | 742 new_clip = clip; |
743 | 743 |
744 // Don't notify the plugin if we've already sent these same params before. | 744 // Don't notify the plugin if we've already sent these same params before. |
745 if (sent_did_change_view_ && position == position_ && new_clip == clip_) | 745 if (sent_did_change_view_ && position == position_ && new_clip == clip_) |
746 return; | 746 return; |
747 | 747 |
748 // TODO(polina): fullscreen transition might take multiple ViewChanged, | 748 if (desired_fullscreen_state_ || fullscreen_) { |
749 // so this will update the state too early. Also, when F11 is used to | 749 WebElement element = container_->element(); |
750 // exit fullscreen mode, desired_fullscreen_state_ is not properly set | 750 WebDocument document = element.document(); |
751 // and cannot be relied on. | 751 // TODO(polina): temporary hack to ease WebKit/Chromium commit sequence. |
752 // Pending fix: http://codereview.chromium.org/8273029/ | 752 #ifdef WEBKIT_WEBDOCUMENT_HAS_FULLSCREENELEMENT |
753 // WebKit: https://bugs.webkit.org/show_bug.cgi?id=70076. | 753 bool is_fullscreen_element = (element == document.fullScreenElement()); |
754 if (desired_fullscreen_state_ && !fullscreen_) { | 754 #else |
755 // Entered fullscreen. Only possible via SetFullscreen. | 755 bool is_fullscreen_element = desired_fullscreen_state_; |
756 fullscreen_ = true; | 756 #endif |
757 } else if (!desired_fullscreen_state_ && fullscreen_) { | 757 if (!fullscreen_ && desired_fullscreen_state_ && |
758 // Exited fullscreen. Possible via SetFullscreen or F11/link. | 758 delegate()->IsInFullscreenMode() && is_fullscreen_element) { |
759 fullscreen_ = false; | 759 // Entered fullscreen. Only possible via SetFullscreen(). |
760 // Reset the size attributes that we hacked to fill in the screen and | 760 fullscreen_ = true; |
761 // retrigger ViewChanged. Make sure we don't forward duplicates of | 761 } else if (fullscreen_ && !is_fullscreen_element) { |
762 // this view to the plugin. | 762 // Exited fullscreen. Possible via SetFullscreen() or F11/link, |
763 ResetSizeAttributesAfterFullscreen(); | 763 // so desired_fullscreen_state might be out-of-date. |
764 SetSentDidChangeView(position, new_clip); | 764 desired_fullscreen_state_ = false; |
765 MessageLoop::current()->PostTask( | 765 fullscreen_ = false; |
766 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this)); | 766 // Reset the size attributes that we hacked to fill in the screen and |
767 return; | 767 // retrigger ViewChanged. Make sure we don't forward duplicates of |
| 768 // this view to the plugin. |
| 769 ResetSizeAttributesAfterFullscreen(); |
| 770 SetSentDidChangeView(position, new_clip); |
| 771 MessageLoop::current()->PostTask( |
| 772 FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this)); |
| 773 return; |
| 774 } |
768 } | 775 } |
769 | 776 |
770 SetSentDidChangeView(position, new_clip); | 777 SetSentDidChangeView(position, new_clip); |
771 flash_fullscreen_ = (fullscreen_container_ != NULL); | 778 flash_fullscreen_ = (fullscreen_container_ != NULL); |
772 | 779 |
773 PP_Rect pp_position, pp_clip; | 780 PP_Rect pp_position, pp_clip; |
774 RectToPPRect(position_, &pp_position); | 781 RectToPPRect(position_, &pp_position); |
775 RectToPPRect(clip_, &pp_clip); | 782 RectToPPRect(clip_, &pp_clip); |
776 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip); | 783 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip); |
777 } | 784 } |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 screen_size_for_fullscreen_ = gfx::Size(); | 2063 screen_size_for_fullscreen_ = gfx::Size(); |
2057 WebElement element = container_->element(); | 2064 WebElement element = container_->element(); |
2058 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2065 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2059 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2066 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2060 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2067 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2061 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2068 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2062 } | 2069 } |
2063 | 2070 |
2064 } // namespace ppapi | 2071 } // namespace ppapi |
2065 } // namespace webkit | 2072 } // namespace webkit |
OLD | NEW |