Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #ifndef WebFrameWidgetImpl_h | |
| 32 #define WebFrameWidgetImpl_h | |
| 33 | |
| 34 #include "platform/graphics/GraphicsLayer.h" | |
| 35 #include "platform/scroll/ScrollTypes.h" | |
| 36 #include "public/platform/WebPoint.h" | |
| 37 #include "public/platform/WebSize.h" | |
| 38 #include "public/web/WebFrameWidget.h" | |
| 39 #include "public/web/WebInputEvent.h" | |
| 40 #include "web/PageWidgetDelegate.h" | |
| 41 #include "wtf/OwnPtr.h" | |
| 42 #include "wtf/RefCounted.h" | |
| 43 | |
| 44 namespace blink { | |
| 45 class Frame; | |
| 46 class Element; | |
| 47 class LocalFrame; | |
| 48 class Page; | |
| 49 class RenderLayerCompositor; | |
| 50 class UserGestureToken; | |
| 51 class WebLayer; | |
| 52 class WebLayerTreeView; | |
| 53 class WebLocalFrameImpl; | |
| 54 class WebMouseEvent; | |
| 55 class WebMouseWheelEvent; | |
| 56 class WebViewImpl; | |
| 57 | |
| 58 class WebFrameWidgetImpl final : public WebFrameWidget | |
| 59 , public PageWidgetEventHandler | |
| 60 , public RefCounted<WebFrameWidgetImpl> { | |
| 61 public: | |
| 62 static WebFrameWidgetImpl* create(WebWidgetClient*, WebLocalFrame*); | |
| 63 | |
| 64 // WebWidget functions: | |
| 65 void close() override; | |
| 66 WebSize size() override; | |
| 67 void willStartLiveResize() override; | |
| 68 void resize(const WebSize&) override; | |
| 69 void resizePinchViewport(const WebSize&) override; | |
| 70 void willEndLiveResize() override; | |
| 71 void willEnterFullScreen() override; | |
| 72 void didEnterFullScreen() override; | |
| 73 void willExitFullScreen() override; | |
| 74 void didExitFullScreen() override; | |
| 75 void beginFrame(const WebBeginFrameArgs&) override; | |
| 76 void layout() override; | |
| 77 void paint(WebCanvas*, const WebRect&) override; | |
| 78 void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) overri de; | |
| 79 bool isTrackingRepaints() const override; | |
| 80 void themeChanged() override; | |
| 81 bool handleInputEvent(const WebInputEvent&) override; | |
| 82 void setCursorVisibilityState(bool isVisible) override; | |
| 83 bool hasTouchEventHandlersAt(const WebPoint&) override; | |
| 84 | |
| 85 // FIXME(bokan): Old pinch path only - This should be removed once old pinch | |
| 86 // is removed. | |
| 87 void applyViewportDeltas( | |
| 88 const WebSize& scrollDelta, | |
| 89 float pageScaleDelta, | |
| 90 float topControlsDelta) override; | |
| 91 void applyViewportDeltas( | |
| 92 const WebSize& pinchViewportDelta, | |
| 93 const WebSize& mainFrameDelta, | |
| 94 const WebFloatSize& elasticOverscrollDelta, | |
| 95 float pageScaleDelta, | |
| 96 float topControlsDelta) override; | |
| 97 void mouseCaptureLost() override; | |
| 98 void setFocus(bool enable) override; | |
| 99 bool setComposition( | |
| 100 const WebString& text, | |
| 101 const WebVector<WebCompositionUnderline>& underlines, | |
| 102 int selectionStart, int selectionEnd) override; | |
| 103 bool confirmComposition() override; | |
| 104 bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) overri de; | |
| 105 bool confirmComposition(const WebString& text) override; | |
| 106 bool compositionRange(size_t* location, size_t* length) override; | |
| 107 WebTextInputInfo textInputInfo() override; | |
| 108 WebColor backgroundColor() const override; | |
| 109 bool selectionBounds(WebRect& anchor, WebRect& focus) const override; | |
| 110 bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const override; | |
| 111 bool isSelectionAnchorFirst() const override; | |
| 112 bool caretOrSelectionRange(size_t* location, size_t* length) override; | |
| 113 void setTextDirection(WebTextDirection) override; | |
| 114 bool isAcceleratedCompositingActive() const override; | |
| 115 void willCloseLayerTreeView() override; | |
| 116 void didChangeWindowResizerRect() override; | |
| 117 | |
| 118 WebWidgetClient* client() const { return m_client; } | |
| 119 | |
| 120 Frame* focusedCoreFrame() const; | |
| 121 | |
| 122 // Returns the currently focused Element or null if no element has focus. | |
| 123 Element* focusedElement() const; | |
| 124 | |
| 125 void scheduleAnimation(); | |
| 126 | |
| 127 RenderLayerCompositor* compositor() const; | |
| 128 void suppressInvalidations(bool enable); | |
| 129 void setRootGraphicsLayer(GraphicsLayer*); | |
| 130 | |
| 131 // Exposed for the purpose of overriding device metrics. | |
| 132 void sendResizeEventAndRepaint(); | |
| 133 | |
| 134 void updateMainFrameLayoutSize(); | |
| 135 | |
| 136 // Returns the page object associated with this widget. This may be null whe n | |
| 137 // the page is shutting down, but will be valid at all other times. | |
| 138 Page* page() const { return m_page; } | |
| 139 | |
| 140 // Returns true if the event leads to scrolling. | |
| 141 static bool mapKeyCodeForScroll( | |
| 142 int keyCode, | |
| 143 ScrollDirection*, | |
| 144 ScrollGranularity*); | |
| 145 | |
| 146 private: | |
| 147 friend class WebFrameWidget; // For WebFrameWidget::create. | |
| 148 friend class WTF::RefCounted<WebFrameWidgetImpl>; | |
| 149 | |
| 150 explicit WebFrameWidgetImpl(WebWidgetClient*, WebLocalFrame*); | |
| 151 ~WebFrameWidgetImpl(); | |
| 152 | |
| 153 // Returns true if the event was actually processed. | |
| 154 bool keyEventDefault(const WebKeyboardEvent&); | |
| 155 | |
| 156 // Returns true if the view was scrolled. | |
| 157 bool scrollViewWithKeyboard(int keyCode, int modifiers); | |
| 158 | |
| 159 void initializeLayerTreeView(); | |
| 160 | |
| 161 void setIsAcceleratedCompositingActive(bool); | |
| 162 void updateLayerTreeViewport(); | |
| 163 void updateLayerTreeBackgroundColor(); | |
| 164 void updateLayerTreeDeviceScaleFactor(); | |
| 165 | |
| 166 bool isTransparent() const; | |
| 167 | |
| 168 // PageWidgetEventHandler functions | |
| 169 void handleMouseLeave(LocalFrame&, const WebMouseEvent&) override; | |
| 170 void handleMouseDown(LocalFrame&, const WebMouseEvent&) override; | |
| 171 void handleMouseUp(LocalFrame&, const WebMouseEvent&) override; | |
| 172 bool handleMouseWheel(LocalFrame&, const WebMouseWheelEvent&) override; | |
| 173 bool handleGestureEvent(const WebGestureEvent&) override; | |
| 174 bool handleKeyEvent(const WebKeyboardEvent&) override; | |
| 175 bool handleCharEvent(const WebKeyboardEvent&) override; | |
| 176 | |
| 177 WebWidgetClient* m_client; | |
| 178 | |
| 179 // WebFrameWidget is associated with a subtree of the frame tree, correspond ing to a maximal | |
| 180 // connected tree of LocalFrames. This member points to the root of that sub tree. | |
| 181 WebLocalFrameImpl* m_localRoot; | |
| 182 | |
| 183 WebSize m_size; | |
| 184 | |
| 185 // If set, the (plugin) node which has mouse capture. | |
| 186 RefPtrWillBePersistent<Node> m_mouseCaptureNode; | |
| 187 RefPtr<UserGestureToken> m_mouseCaptureGestureToken; | |
| 188 | |
| 189 WebLayerTreeView* m_layerTreeView; | |
| 190 WebLayer* m_rootLayer; | |
| 191 GraphicsLayer* m_rootGraphicsLayer; | |
| 192 bool m_isAcceleratedCompositingActive; | |
| 193 bool m_layerTreeViewClosed; | |
| 194 | |
| 195 // FIXME: The lifetimes of these objects relative to the WebFrameWidget are not clear, | |
| 196 // and it might be better to replace them with lookups based on the localRoo t. | |
| 197 WebViewImpl* m_webView; | |
| 198 Page* m_page; | |
| 199 | |
| 200 bool m_suppressNextKeypressEvent; | |
| 201 | |
| 202 bool m_ignoreInputEvents; | |
| 203 | |
| 204 static const WebInputEvent* m_currentInputEvent; | |
| 205 | |
| 206 WebColor m_baseBackgroundColor; | |
| 207 WebColor m_backgroundColorOverride; | |
|
dcheng
2014/12/18 19:52:43
I think these are unreferenced now, so let's remov
dcheng
2014/12/18 19:52:43
I think these are unreferenced now, so let's remov
kenrb
2015/01/05 17:09:38
Done.
| |
| 208 }; | |
| 209 | |
| 210 } // namespace blink | |
| 211 | |
| 212 #endif | |
| 213 | |
| OLD | NEW |