Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / WebViewImpl.h
blob59820aec5deba76425fe157acb12acc75252b497
1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
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.
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.
31 #ifndef WebViewImpl_h
32 #define WebViewImpl_h
34 #include "core/page/ContextMenuProvider.h"
35 #include "core/page/EventWithHitTestResults.h"
36 #include "platform/geometry/IntPoint.h"
37 #include "platform/geometry/IntRect.h"
38 #include "platform/graphics/CompositedDisplayList.h"
39 #include "platform/graphics/GraphicsLayer.h"
40 #include "platform/heap/Handle.h"
41 #include "public/platform/WebCompositedDisplayList.h"
42 #include "public/platform/WebCompositorAnimationTimeline.h"
43 #include "public/platform/WebDisplayMode.h"
44 #include "public/platform/WebFloatSize.h"
45 #include "public/platform/WebGestureCurveTarget.h"
46 #include "public/platform/WebLayer.h"
47 #include "public/platform/WebPoint.h"
48 #include "public/platform/WebRect.h"
49 #include "public/platform/WebSize.h"
50 #include "public/platform/WebString.h"
51 #include "public/platform/WebVector.h"
52 #include "public/web/WebInputEvent.h"
53 #include "public/web/WebNavigationPolicy.h"
54 #include "public/web/WebPageImportanceSignals.h"
55 #include "public/web/WebView.h"
56 #include "web/ChromeClientImpl.h"
57 #include "web/ContextMenuClientImpl.h"
58 #include "web/DragClientImpl.h"
59 #include "web/EditorClientImpl.h"
60 #include "web/MediaKeysClientImpl.h"
61 #include "web/PageWidgetDelegate.h"
62 #include "web/SpellCheckerClientImpl.h"
63 #include "web/StorageClientImpl.h"
64 #include "wtf/HashSet.h"
65 #include "wtf/OwnPtr.h"
66 #include "wtf/RefCounted.h"
67 #include "wtf/Vector.h"
69 namespace blink {
71 class DataObject;
72 class DevToolsEmulator;
73 class Frame;
74 class FullscreenController;
75 class InspectorOverlayImpl;
76 class LinkHighlightImpl;
77 class PageOverlay;
78 class PageScaleConstraintsSet;
79 class DeprecatedPaintLayerCompositor;
80 class TopControls;
81 class UserGestureToken;
82 class WebActiveGestureAnimation;
83 class WebDevToolsAgentImpl;
84 class WebElement;
85 class WebLayerTreeView;
86 class WebLocalFrameImpl;
87 class WebImage;
88 class WebPagePopupImpl;
89 class WebPlugin;
90 class WebSelection;
91 class WebSettingsImpl;
93 class WebViewImpl final : public WebView
94 , public RefCounted<WebViewImpl>
95 , public WebGestureCurveTarget
96 , public PageWidgetEventHandler {
97 public:
98 static WebViewImpl* create(WebViewClient*);
99 static HashSet<WebViewImpl*>& allInstances();
101 // WebWidget methods:
102 void close() override;
103 WebSize size() override;
104 void willStartLiveResize() override;
105 void resize(const WebSize&) override;
106 void resizeVisualViewport(const WebSize&) override;
107 void resizePinchViewport(const WebSize&) override;
108 void willEndLiveResize() override;
109 void didEnterFullScreen() override;
110 void didExitFullScreen() override;
112 void beginFrame(const WebBeginFrameArgs&) override;
114 void layout() override;
115 void paint(WebCanvas*, const WebRect&) override;
116 #if OS(ANDROID)
117 void paintCompositedDeprecated(WebCanvas*, const WebRect&) override;
118 #endif
119 void layoutAndPaintAsync(WebLayoutAndPaintAsyncCallback*) override;
120 void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) override;
121 void themeChanged() override;
122 bool handleInputEvent(const WebInputEvent&) override;
123 void setCursorVisibilityState(bool isVisible) override;
124 bool hasTouchEventHandlersAt(const WebPoint&) override;
126 void applyViewportDeltas(
127 const WebFloatSize& visualViewportDelta,
128 const WebFloatSize& layoutViewportDelta,
129 const WebFloatSize& elasticOverscrollDelta,
130 float pageScaleDelta,
131 float topControlsShownRatioDelta) override;
132 void recordFrameTimingEvent(enum FrameTimingEventType, int64_t, const WebVector<WebFrameTimingEvent>&) override;
133 void mouseCaptureLost() override;
134 void setFocus(bool enable) override;
135 bool setComposition(
136 const WebString& text,
137 const WebVector<WebCompositionUnderline>& underlines,
138 int selectionStart,
139 int selectionEnd) override;
140 bool confirmComposition() override;
141 bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) override;
142 bool confirmComposition(const WebString& text) override;
143 bool compositionRange(size_t* location, size_t* length) override;
144 WebTextInputInfo textInputInfo() override;
145 WebColor backgroundColor() const override;
146 WebPagePopup* pagePopup() const override;
147 bool selectionBounds(WebRect& anchor, WebRect& focus) const override;
148 bool selectionTextDirection(WebTextDirection& start, WebTextDirection& end) const override;
149 bool isSelectionAnchorFirst() const override;
150 bool caretOrSelectionRange(size_t* location, size_t* length) override;
151 void setTextDirection(WebTextDirection) override;
152 bool isAcceleratedCompositingActive() const override;
153 void willCloseLayerTreeView() override;
154 void didAcquirePointerLock() override;
155 void didNotAcquirePointerLock() override;
156 void didLosePointerLock() override;
157 void didChangeWindowResizerRect() override;
159 // WebView methods:
160 virtual bool isWebView() const { return true; }
161 void setMainFrame(WebFrame*) override;
162 void setCredentialManagerClient(WebCredentialManagerClient*) override;
163 void setPrerendererClient(WebPrerendererClient*) override;
164 void setSpellCheckClient(WebSpellCheckClient*) override;
165 WebSettings* settings() override;
166 WebString pageEncoding() const override;
167 void setPageEncoding(const WebString&) override;
168 bool isTransparent() const override;
169 void setIsTransparent(bool value) override;
170 void setBaseBackgroundColor(WebColor) override;
171 bool tabsToLinks() const override;
172 void setTabsToLinks(bool value) override;
173 bool tabKeyCyclesThroughElements() const override;
174 void setTabKeyCyclesThroughElements(bool value) override;
175 bool isActive() const override;
176 void setIsActive(bool value) override;
177 void setDomainRelaxationForbidden(bool, const WebString& scheme) override;
178 void setWindowFeatures(const WebWindowFeatures&) override;
179 void setOpenedByDOM() override;
180 WebFrame* mainFrame() override;
181 WebFrame* findFrameByName(
182 const WebString& name, WebFrame* relativeToFrame) override;
183 WebFrame* focusedFrame() override;
184 void setFocusedFrame(WebFrame*) override;
185 void setInitialFocus(bool reverse) override;
186 void clearFocusedElement() override;
187 bool scrollFocusedNodeIntoRect(const WebRect&) override;
188 void smoothScroll(int targetX, int targetY, long durationMs) override;
189 void zoomToFindInPageRect(const WebRect&);
190 void advanceFocus(bool reverse) override;
191 double zoomLevel() override;
192 double setZoomLevel(double) override;
193 void zoomLimitsChanged(double minimumZoomLevel, double maximumZoomLevel) override;
194 float textZoomFactor() override;
195 float setTextZoomFactor(float) override;
196 bool zoomToMultipleTargetsRect(const WebRect&) override;
197 float pageScaleFactor() const override;
198 void setDefaultPageScaleLimits(float minScale, float maxScale) override;
199 void setInitialPageScaleOverride(float) override;
200 void setMaximumLegibleScale(float) override;
201 void setPageScaleFactor(float) override;
202 void setVisualViewportOffset(const WebFloatPoint&) override;
203 void setPinchViewportOffset(const WebFloatPoint&) override;
204 WebFloatPoint visualViewportOffset() const override;
205 WebFloatPoint pinchViewportOffset() const override;
206 void resetScrollAndScaleState() override;
207 void setIgnoreViewportTagScaleLimits(bool) override;
208 WebSize contentsPreferredMinimumSize() override;
209 void setDisplayMode(WebDisplayMode) override;
211 float deviceScaleFactor() const override;
212 void setDeviceScaleFactor(float) override;
213 void setDeviceColorProfile(const WebVector<char>&) override;
214 void resetDeviceColorProfile() override;
216 void enableAutoResizeMode(
217 const WebSize& minSize,
218 const WebSize& maxSize) override;
219 void disableAutoResizeMode() override;
220 void performMediaPlayerAction(
221 const WebMediaPlayerAction& action,
222 const WebPoint& location) override;
223 void performPluginAction(
224 const WebPluginAction&,
225 const WebPoint&) override;
226 WebHitTestResult hitTestResultAt(const WebPoint&) override;
227 WebHitTestResult hitTestResultForTap(const WebPoint&, const WebSize&) override;
228 void copyImageAt(const WebPoint&) override;
229 void saveImageAt(const WebPoint&) override;
230 void dragSourceEndedAt(
231 const WebPoint& clientPoint,
232 const WebPoint& screenPoint,
233 WebDragOperation) override;
234 void dragSourceSystemDragEnded() override;
235 WebDragOperation dragTargetDragEnter(
236 const WebDragData&,
237 const WebPoint& clientPoint,
238 const WebPoint& screenPoint,
239 WebDragOperationsMask operationsAllowed,
240 int modifiers) override;
241 WebDragOperation dragTargetDragOver(
242 const WebPoint& clientPoint,
243 const WebPoint& screenPoint,
244 WebDragOperationsMask operationsAllowed,
245 int modifiers) override;
246 void dragTargetDragLeave() override;
247 void dragTargetDrop(
248 const WebPoint& clientPoint,
249 const WebPoint& screenPoint,
250 int modifiers) override;
251 void spellingMarkers(WebVector<uint32_t>* markers) override;
252 void removeSpellingMarkersUnderWords(const WebVector<WebString>& words) override;
253 unsigned long createUniqueIdentifierForRequest() override;
254 void enableDeviceEmulation(const WebDeviceEmulationParams&) override;
255 void disableDeviceEmulation() override;
256 WebAXObject accessibilityObject() override;
257 void setSelectionColors(unsigned activeBackgroundColor,
258 unsigned activeForegroundColor,
259 unsigned inactiveBackgroundColor,
260 unsigned inactiveForegroundColor) override;
261 void performCustomContextMenuAction(unsigned action) override;
262 void showContextMenu() override;
263 void extractSmartClipData(WebRect, WebString&, WebString&, WebRect&) override;
264 void hidePopups() override;
265 void setPageOverlayColor(WebColor) override;
266 WebPageImportanceSignals* pageImportanceSignals() override;
267 void transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters&) override;
268 bool endActiveFlingAnimation() override;
269 void setShowPaintRects(bool) override;
270 void setShowDebugBorders(bool);
271 void setShowFPSCounter(bool) override;
272 void setShowScrollBottleneckRects(bool) override;
273 void acceptLanguagesChanged() override;
275 void setCompositedDisplayList(PassOwnPtr<CompositedDisplayList>);
276 WebCompositedDisplayList* compositedDisplayList() override;
278 // WebViewImpl
279 void enableViewport();
280 void disableViewport();
282 float defaultMinimumPageScaleFactor() const;
283 float defaultMaximumPageScaleFactor() const;
284 float minimumPageScaleFactor() const;
285 float maximumPageScaleFactor() const;
286 float clampPageScaleFactorToLimits(float) const;
287 void resetScrollAndScaleStateImmediately();
289 HitTestResult coreHitTestResultAt(const WebPoint&);
290 void invalidateRect(const IntRect&);
292 void setIgnoreInputEvents(bool newValue);
293 void setBackgroundColorOverride(WebColor);
294 void setZoomFactorOverride(float);
295 void updateShowFPSCounter();
296 void setCompositorDeviceScaleFactorOverride(float);
297 void setRootLayerTransform(const WebSize& offset, float scale);
299 Color baseBackgroundColor() const { return m_baseBackgroundColor; }
301 WebColor backgroundColorOverride() const { return m_backgroundColorOverride; }
303 const WebPoint& lastMouseDownPoint() const
305 return m_lastMouseDownPoint;
308 Frame* focusedCoreFrame() const;
310 // Returns the currently focused Element or null if no element has focus.
311 Element* focusedElement() const;
313 static WebViewImpl* fromPage(Page*);
315 WebViewClient* client()
317 return m_client;
320 WebSpellCheckClient* spellCheckClient()
322 return m_spellCheckClient;
325 // Returns the page object associated with this view. This may be null when
326 // the page is shutting down, but will be valid at all other times.
327 Page* page() const
329 return m_page.get();
332 WebDevToolsAgentImpl* mainFrameDevToolsAgentImpl();
334 DevToolsEmulator* devToolsEmulator() const
336 return m_devToolsEmulator.get();
339 // Returns the main frame associated with this view. This may be null when
340 // the page is shutting down, but will be valid at all other times.
341 WebLocalFrameImpl* mainFrameImpl();
343 // FIXME: Temporary method to accommodate out-of-process frame ancestors;
344 // will be removed when there can be multiple WebWidgets for a single page.
345 WebLocalFrameImpl* localFrameRootTemporary() const;
347 // Event related methods:
348 void mouseContextMenu(const WebMouseEvent&);
349 void mouseDoubleClick(const WebMouseEvent&);
351 bool detectContentOnTouch(const GestureEventWithHitTestResults& targetedEvent);
352 bool startPageScaleAnimation(const IntPoint& targetPosition, bool useAnchor, float newScale, double durationInSeconds);
354 void hasTouchEventHandlers(bool);
356 // WebGestureCurveTarget implementation for fling.
357 bool scrollBy(const WebFloatSize& delta, const WebFloatSize& velocity) override;
359 // Handles context menu events orignated via the the keyboard. These
360 // include the VK_APPS virtual key and the Shift+F10 combine. Code is
361 // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
362 // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
363 // significant change in this function is the code to convert from a
364 // Keyboard event to the Right Mouse button down event.
365 bool sendContextMenuEvent(const WebKeyboardEvent&);
367 void showContextMenuAtPoint(float x, float y, PassRefPtrWillBeRawPtr<ContextMenuProvider>);
369 void showContextMenuForElement(WebElement);
371 // Notifies the WebView that a load has been committed. isNewNavigation
372 // will be true if a new session history item should be created for that
373 // load. isNavigationWithinPage will be true if the navigation does
374 // not take the user away from the current page.
375 void didCommitLoad(bool isNewNavigation, bool isNavigationWithinPage);
377 void postLayoutResize(WebLocalFrameImpl* webframe);
379 // Indicates two things:
380 // 1) This view may have a new layout now.
381 // 2) Calling layout() is a no-op.
382 // After calling WebWidget::layout(), expect to get this notification
383 // unless the view did not need a layout.
384 void layoutUpdated(WebLocalFrameImpl*);
386 void documentElementAvailable(WebLocalFrameImpl*);
387 void willInsertBody(WebLocalFrameImpl*);
388 void didRemoveAllPendingStylesheet(WebLocalFrameImpl*);
389 void didFinishDocumentLoad(WebLocalFrameImpl*);
390 void didChangeContentsSize();
391 void pageScaleFactorChanged();
393 // Returns true if popup menus should be rendered by the browser, false if
394 // they should be rendered by WebKit (which is the default).
395 static bool useExternalPopupMenus();
397 bool shouldAutoResize() const
399 return m_shouldAutoResize;
402 IntSize minAutoSize() const
404 return m_minAutoSize;
407 IntSize maxAutoSize() const
409 return m_maxAutoSize;
412 void updateMainFrameLayoutSize();
413 void updatePageDefinedViewportConstraints(const ViewportDescription&);
415 // Start a system drag and drop operation.
416 void startDragging(
417 LocalFrame*,
418 const WebDragData& dragData,
419 WebDragOperationsMask mask,
420 const WebImage& dragImage,
421 const WebPoint& dragImageOffset);
423 PagePopup* openPagePopup(PagePopupClient*);
424 void closePagePopup(PagePopup*);
425 LocalDOMWindow* pagePopupWindow() const;
427 // Returns the input event we're currently processing. This is used in some
428 // cases where the WebCore DOM event doesn't have the information we need.
429 static const WebInputEvent* currentInputEvent()
431 return m_currentInputEvent;
434 GraphicsLayer* rootGraphicsLayer();
435 void setRootGraphicsLayer(GraphicsLayer*);
436 GraphicsLayerFactory* graphicsLayerFactory() const;
437 DeprecatedPaintLayerCompositor* compositor() const;
438 void registerForAnimations(WebLayer*);
439 void scheduleAnimation();
440 void attachCompositorAnimationTimeline(WebCompositorAnimationTimeline*);
441 void detachCompositorAnimationTimeline(WebCompositorAnimationTimeline*);
442 WebCompositorAnimationTimeline* linkHighlightsTimeline() const { return m_linkHighlightsTimeline.get(); }
444 void setVisibilityState(WebPageVisibilityState, bool) override;
446 bool hasOpenedPopup() const { return m_pagePopup; }
448 // Returns true if the event leads to scrolling.
449 static bool mapKeyCodeForScroll(
450 int keyCode,
451 ScrollDirectionPhysical*,
452 ScrollGranularity*);
454 // Called by a full frame plugin inside this view to inform it that its
455 // zoom level has been updated. The plugin should only call this function
456 // if the zoom change was triggered by the browser, it's only needed in case
457 // a plugin can update its own zoom, say because of its own UI.
458 void fullFramePluginZoomLevelChanged(double zoomLevel);
460 void computeScaleAndScrollForBlockRect(const WebPoint& hitPoint, const WebRect& blockRect, float padding, float defaultScaleWhenAlreadyLegible, float& scale, WebPoint& scroll);
461 Node* bestTapNode(const GestureEventWithHitTestResults& targetedTapEvent);
462 void enableTapHighlightAtPoint(const GestureEventWithHitTestResults& targetedTapEvent);
463 void enableTapHighlights(WillBeHeapVector<RawPtrWillBeMember<Node>>&);
464 void computeScaleAndScrollForFocusedNode(Node* focusedNode, bool zoomInToLegibleScale, float& scale, IntPoint& scroll, bool& needAnimation);
466 void animateDoubleTapZoom(const IntPoint&);
468 void enableFakePageScaleAnimationForTesting(bool);
469 bool fakeDoubleTapAnimationPendingForTesting() const { return m_doubleTapZoomPending; }
470 IntPoint fakePageScaleAnimationTargetPositionForTesting() const { return m_fakePageScaleAnimationTargetPosition; }
471 float fakePageScaleAnimationPageScaleForTesting() const { return m_fakePageScaleAnimationPageScaleFactor; }
472 bool fakePageScaleAnimationUseAnchorForTesting() const { return m_fakePageScaleAnimationUseAnchor; }
474 void enterFullScreenForElement(Element*);
475 void exitFullScreenForElement(Element*);
477 void clearCompositedSelection();
478 void updateCompositedSelection(const WebSelection&);
480 // Exposed for the purpose of overriding device metrics.
481 void sendResizeEventAndRepaint();
483 // Exposed for testing purposes.
484 bool hasHorizontalScrollbar();
485 bool hasVerticalScrollbar();
487 // Pointer Lock calls allow a page to capture all mouse events and
488 // disable the system cursor.
489 bool requestPointerLock();
490 void requestPointerUnlock();
491 bool isPointerLocked();
493 // Heuristic-based function for determining if we should disable workarounds
494 // for viewing websites that are not optimized for mobile devices.
495 bool shouldDisableDesktopWorkarounds();
497 // Exposed for tests.
498 unsigned numLinkHighlights() { return m_linkHighlights.size(); }
499 LinkHighlightImpl* linkHighlight(int i) { return m_linkHighlights[i].get(); }
501 WebSettingsImpl* settingsImpl();
503 // Returns the bounding box of the block type node touched by the WebPoint.
504 WebRect computeBlockBound(const WebPoint&, bool ignoreClipping);
506 WebLayerTreeView* layerTreeView() const { return m_layerTreeView; }
508 bool matchesHeuristicsForGpuRasterizationForTesting() const { return m_matchesHeuristicsForGpuRasterization; }
510 void setTopControlsHeight(float height, bool topControlsShrinkLayoutSize) override;
511 void updateTopControlsState(WebTopControlsState constraint, WebTopControlsState current, bool animate) override;
513 TopControls& topControls();
514 // Called anytime top controls layout height or content offset have changed.
515 void didUpdateTopControls();
517 void forceNextWebGLContextCreationToFail() override;
518 void forceNextDrawingBufferCreationToFail() override;
520 IntSize mainFrameSize();
521 WebDisplayMode displayMode() const { return m_displayMode; }
523 PageScaleConstraintsSet& pageScaleConstraintsSet() const;
525 FloatSize elasticOverscroll() const { return m_elasticOverscroll; }
527 private:
528 InspectorOverlayImpl* inspectorOverlay();
530 void setPageScaleFactorAndLocation(float, const FloatPoint&);
532 void scrollAndRescaleViewports(float scaleFactor, const IntPoint& mainFrameOrigin, const FloatPoint& visualViewportOrigin);
534 float maximumLegiblePageScale() const;
535 void refreshPageScaleFactorAfterLayout();
536 void resetScrollAndScaleState(bool immediately);
537 void resumeTreeViewCommitsIfRenderingReady();
538 IntSize contentsSize() const;
540 void performResize();
541 void resizeViewWhileAnchored(FrameView*);
543 friend class WebView; // So WebView::Create can call our constructor
544 friend class WTF::RefCounted<WebViewImpl>;
545 friend void setCurrentInputEventForTest(const WebInputEvent*);
547 enum DragAction {
548 DragEnter,
549 DragOver
552 explicit WebViewImpl(WebViewClient*);
553 ~WebViewImpl() override;
555 WebTextInputType textInputType();
556 int textInputFlags();
558 WebString inputModeOfFocusedElement();
560 // Returns true if the event was actually processed.
561 bool keyEventDefault(const WebKeyboardEvent&);
563 bool confirmComposition(const WebString& text, ConfirmCompositionBehavior);
565 // Returns true if the view was scrolled.
566 bool scrollViewWithKeyboard(int keyCode, int modifiers);
568 void hideSelectPopup();
570 HitTestResult hitTestResultForRootFramePos(const IntPoint&);
571 HitTestResult hitTestResultForViewportPos(const IntPoint&);
573 // Consolidate some common code between starting a drag over a target and
574 // updating a drag over a target. If we're starting a drag, |isEntering|
575 // should be true.
576 WebDragOperation dragTargetDragEnterOrOver(const WebPoint& clientPoint,
577 const WebPoint& screenPoint,
578 DragAction,
579 int modifiers);
581 void configureAutoResizeMode();
583 void initializeLayerTreeView();
585 void setIsAcceleratedCompositingActive(bool);
586 void doComposite();
587 void reallocateRenderer();
588 void updateLayerTreeViewport();
589 void updateLayerTreeBackgroundColor();
590 void updateRootLayerTransform();
591 void updateLayerTreeDeviceScaleFactor();
593 // Helper function: Widens the width of |source| by the specified margins
594 // while keeping it smaller than page width.
595 WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin);
597 void pointerLockMouseEvent(const WebInputEvent&);
599 // PageWidgetEventHandler functions
600 void handleMouseLeave(LocalFrame&, const WebMouseEvent&) override;
601 void handleMouseDown(LocalFrame&, const WebMouseEvent&) override;
602 void handleMouseUp(LocalFrame&, const WebMouseEvent&) override;
603 bool handleMouseWheel(LocalFrame&, const WebMouseWheelEvent&) override;
604 bool handleGestureEvent(const WebGestureEvent&) override;
605 bool handleKeyEvent(const WebKeyboardEvent&) override;
606 bool handleCharEvent(const WebKeyboardEvent&) override;
608 bool handleSyntheticWheelFromTouchpadPinchEvent(const WebGestureEvent&);
610 WebPlugin* focusedPluginIfInputMethodSupported(LocalFrame*);
612 void enablePopupMouseWheelEventListener();
613 void disablePopupMouseWheelEventListener();
615 void cancelPagePopup();
616 void updatePageOverlays();
618 WebViewClient* m_client; // Can be 0 (e.g. unittests, shared workers, etc.)
619 WebSpellCheckClient* m_spellCheckClient;
621 OwnPtrWillBePersistent<ChromeClientImpl> m_chromeClientImpl;
622 ContextMenuClientImpl m_contextMenuClientImpl;
623 DragClientImpl m_dragClientImpl;
624 EditorClientImpl m_editorClientImpl;
625 SpellCheckerClientImpl m_spellCheckerClientImpl;
626 StorageClientImpl m_storageClientImpl;
628 WebSize m_size;
629 // If true, automatically resize the layout view around its content.
630 bool m_shouldAutoResize;
631 // The lower bound on the size when auto-resizing.
632 IntSize m_minAutoSize;
633 // The upper bound on the size when auto-resizing.
634 IntSize m_maxAutoSize;
636 OwnPtrWillBePersistent<Page> m_page;
638 // An object that can be used to manipulate m_page->settings() without linking
639 // against WebCore. This is lazily allocated the first time GetWebSettings()
640 // is called.
641 OwnPtr<WebSettingsImpl> m_webSettings;
643 // A copy of the web drop data object we received from the browser.
644 Persistent<DataObject> m_currentDragData;
646 // The point relative to the client area where the mouse was last pressed
647 // down. This is used by the drag client to determine what was under the
648 // mouse when the drag was initiated. We need to track this here in
649 // WebViewImpl since DragClient::startDrag does not pass the position the
650 // mouse was at when the drag was initiated, only the current point, which
651 // can be misleading as it is usually not over the element the user actually
652 // dragged by the time a drag is initiated.
653 WebPoint m_lastMouseDownPoint;
655 // Keeps track of the current zoom level. 0 means no zoom, positive numbers
656 // mean zoom in, negative numbers mean zoom out.
657 double m_zoomLevel;
659 double m_minimumZoomLevel;
661 double m_maximumZoomLevel;
663 // This value, when multiplied by the font scale factor, gives the maximum
664 // page scale that can result from automatic zooms.
665 float m_maximumLegibleScale;
667 // The scale moved to by the latest double tap zoom, if any.
668 float m_doubleTapZoomPageScaleFactor;
669 // Have we sent a double-tap zoom and not yet heard back the scale?
670 bool m_doubleTapZoomPending;
672 // Used for testing purposes.
673 bool m_enableFakePageScaleAnimationForTesting;
674 IntPoint m_fakePageScaleAnimationTargetPosition;
675 float m_fakePageScaleAnimationPageScaleFactor;
676 bool m_fakePageScaleAnimationUseAnchor;
678 bool m_doingDragAndDrop;
680 bool m_ignoreInputEvents;
682 float m_compositorDeviceScaleFactorOverride;
683 WebSize m_rootLayerOffset;
684 float m_rootLayerScale;
686 // Webkit expects keyPress events to be suppressed if the associated keyDown
687 // event was handled. Safari implements this behavior by peeking out the
688 // associated WM_CHAR event if the keydown was handled. We emulate
689 // this behavior by setting this flag if the keyDown was handled.
690 bool m_suppressNextKeypressEvent;
692 // Represents whether or not this object should process incoming IME events.
693 bool m_imeAcceptEvents;
695 // The available drag operations (copy, move link...) allowed by the source.
696 WebDragOperation m_operationsAllowed;
698 // The current drag operation as negotiated by the source and destination.
699 // When not equal to DragOperationNone, the drag data can be dropped onto the
700 // current drop target in this WebView (the drop target can accept the drop).
701 WebDragOperation m_dragOperation;
703 // The popup associated with an input/select element.
704 RefPtr<WebPagePopupImpl> m_pagePopup;
706 OwnPtrWillBePersistent<InspectorOverlayImpl> m_inspectorOverlay;
707 OwnPtrWillBePersistent<DevToolsEmulator> m_devToolsEmulator;
708 OwnPtr<PageOverlay> m_pageColorOverlay;
710 // Whether the webview is rendering transparently.
711 bool m_isTransparent;
713 // Whether the user can press tab to focus links.
714 bool m_tabsToLinks;
716 // If set, the (plugin) node which has mouse capture.
717 RefPtrWillBePersistent<Node> m_mouseCaptureNode;
718 RefPtr<UserGestureToken> m_mouseCaptureGestureToken;
720 RefPtr<UserGestureToken> m_pointerLockGestureToken;
722 IntRect m_rootLayerScrollDamage;
723 WebLayerTreeView* m_layerTreeView;
724 WebLayer* m_rootLayer;
725 GraphicsLayer* m_rootGraphicsLayer;
726 GraphicsLayer* m_rootTransformLayer;
727 OwnPtr<GraphicsLayerFactory> m_graphicsLayerFactory;
728 bool m_matchesHeuristicsForGpuRasterization;
729 // If true, the graphics context is being restored.
730 bool m_recreatingGraphicsContext;
731 static const WebInputEvent* m_currentInputEvent;
733 WebCompositedDisplayList m_compositedDisplayList;
735 MediaKeysClientImpl m_mediaKeysClientImpl;
736 OwnPtr<WebActiveGestureAnimation> m_gestureAnimation;
737 WebPoint m_positionOnFlingStart;
738 WebPoint m_globalPositionOnFlingStart;
739 int m_flingModifier;
740 bool m_flingSourceDevice;
741 Vector<OwnPtr<LinkHighlightImpl>> m_linkHighlights;
742 OwnPtr<WebCompositorAnimationTimeline> m_linkHighlightsTimeline;
743 OwnPtrWillBePersistent<FullscreenController> m_fullscreenController;
745 bool m_showFPSCounter;
746 WebColor m_baseBackgroundColor;
747 WebColor m_backgroundColorOverride;
748 float m_zoomFactorOverride;
750 bool m_userGestureObserved;
751 bool m_shouldDispatchFirstVisuallyNonEmptyLayout;
752 bool m_shouldDispatchFirstLayoutAfterFinishedParsing;
753 WebDisplayMode m_displayMode;
755 FloatSize m_elasticOverscroll;
757 RefPtrWillBePersistent<EventListener> m_popupMouseWheelEventListener;
759 WebPageImportanceSignals m_pageImportanceSignals;
762 DEFINE_TYPE_CASTS(WebViewImpl, WebWidget, widget, widget->isWebView(), widget.isWebView());
763 // We have no ways to check if the specified WebView is an instance of
764 // WebViewImpl because WebViewImpl is the only implementation of WebView.
765 DEFINE_TYPE_CASTS(WebViewImpl, WebView, webView, true, true);
767 } // namespace blink
769 #endif