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

Side by Side Diff: public/webpage/WebView.h

Issue 17186002: Move public/webpage to public/web (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | « public/webpage/WebValidationMessageClient.h ('k') | public/webpage/WebViewBenchmarkSupport.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009, 2010, 2011, 2012 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 WebView_h
32 #define WebView_h
33
34 #include "../platform/WebString.h"
35 #include "../platform/WebVector.h"
36 #include "WebDragOperation.h"
37 #include "WebPageVisibilityState.h"
38 #include "WebWidget.h"
39
40 namespace WebKit {
41
42 class WebAccessibilityObject;
43 class WebAutofillClient;
44 class WebDevToolsAgent;
45 class WebDevToolsAgentClient;
46 class WebDragData;
47 class WebFrame;
48 class WebFrameClient;
49 class WebGraphicsContext3D;
50 class WebHitTestResult;
51 class WebNode;
52 class WebPageOverlay;
53 class WebPermissionClient;
54 class WebPrerendererClient;
55 class WebRange;
56 class WebSettings;
57 class WebSpellCheckClient;
58 class WebString;
59 class WebTextFieldDecoratorClient;
60 class WebValidationMessageClient;
61 class WebViewBenchmarkSupport;
62 class WebViewClient;
63 struct WebActiveWheelFlingParameters;
64 struct WebMediaPlayerAction;
65 struct WebPluginAction;
66 struct WebPoint;
67
68 class WebView : public WebWidget {
69 public:
70 WEBKIT_EXPORT static const double textSizeMultiplierRatio;
71 WEBKIT_EXPORT static const double minTextSizeMultiplier;
72 WEBKIT_EXPORT static const double maxTextSizeMultiplier;
73 WEBKIT_EXPORT static const float minPageScaleFactor;
74 WEBKIT_EXPORT static const float maxPageScaleFactor;
75
76 // Controls which frames user content is injected into.
77 enum UserContentInjectIn {
78 UserContentInjectInAllFrames,
79 UserContentInjectInTopFrameOnly
80 };
81
82 // Controls which documents user styles are injected into.
83 enum UserStyleInjectionTime {
84 UserStyleInjectInExistingDocuments,
85 UserStyleInjectInSubsequentDocuments
86 };
87
88
89 // Initialization ------------------------------------------------------
90
91 // Creates a WebView that is NOT yet initialized. You will need to
92 // call initializeMainFrame to finish the initialization. It is valid
93 // to pass null client pointers.
94 WEBKIT_EXPORT static WebView* create(WebViewClient*);
95
96 // After creating a WebView, you should immediately call this method.
97 // You can optionally modify the settings before calling this method.
98 // The WebFrameClient will receive events for the main frame and any
99 // child frames. It is valid to pass a null WebFrameClient pointer.
100 virtual void initializeMainFrame(WebFrameClient*) = 0;
101
102 virtual void initializeHelperPluginFrame(WebFrameClient*) = 0;
103
104 // Initializes the various client interfaces.
105 virtual void setAutofillClient(WebAutofillClient*) = 0;
106 virtual void setDevToolsAgentClient(WebDevToolsAgentClient*) = 0;
107 virtual void setPermissionClient(WebPermissionClient*) = 0;
108 virtual void setPrerendererClient(WebPrerendererClient*) = 0;
109 virtual void setSpellCheckClient(WebSpellCheckClient*) = 0;
110 virtual void setValidationMessageClient(WebValidationMessageClient*) = 0;
111 virtual void addTextFieldDecoratorClient(WebTextFieldDecoratorClient*) = 0;
112
113
114 // Options -------------------------------------------------------------
115
116 // The returned pointer is valid for the lifetime of the WebView.
117 virtual WebSettings* settings() = 0;
118
119 // Corresponds to the encoding of the main frame. Setting the page
120 // encoding may cause the main frame to reload.
121 virtual WebString pageEncoding() const = 0;
122 virtual void setPageEncoding(const WebString&) = 0;
123
124 // Makes the WebView transparent. This is useful if you want to have
125 // some custom background rendered behind it.
126 virtual bool isTransparent() const = 0;
127 virtual void setIsTransparent(bool) = 0;
128
129 // Controls whether pressing Tab key advances focus to links.
130 virtual bool tabsToLinks() const = 0;
131 virtual void setTabsToLinks(bool) = 0;
132
133 // Method that controls whether pressing Tab key cycles through page
134 // elements or inserts a '\t' char in the focused text area.
135 virtual bool tabKeyCyclesThroughElements() const = 0;
136 virtual void setTabKeyCyclesThroughElements(bool) = 0;
137
138 // Controls the WebView's active state, which may affect the rendering
139 // of elements on the page (i.e., tinting of input elements).
140 virtual bool isActive() const = 0;
141 virtual void setIsActive(bool) = 0;
142
143 // Allows disabling domain relaxation.
144 virtual void setDomainRelaxationForbidden(bool, const WebString& scheme) = 0 ;
145
146
147 // Closing -------------------------------------------------------------
148
149 // Runs beforeunload handlers for the current page, returning false if
150 // any handler suppressed unloading.
151 virtual bool dispatchBeforeUnloadEvent() = 0;
152
153 // Runs unload handlers for the current page.
154 virtual void dispatchUnloadEvent() = 0;
155
156
157 // Frames --------------------------------------------------------------
158
159 virtual WebFrame* mainFrame() = 0;
160
161 // Returns the frame identified by the given name. This method
162 // supports pseudo-names like _self, _top, and _blank. It traverses
163 // the entire frame tree containing this tree looking for a frame that
164 // matches the given name. If the optional relativeToFrame parameter
165 // is specified, then the search begins with the given frame and its
166 // children.
167 virtual WebFrame* findFrameByName(
168 const WebString& name, WebFrame* relativeToFrame = 0) = 0;
169
170
171 // Focus ---------------------------------------------------------------
172
173 virtual WebFrame* focusedFrame() = 0;
174 virtual void setFocusedFrame(WebFrame*) = 0;
175
176 // Focus the first (last if reverse is true) focusable node.
177 virtual void setInitialFocus(bool reverse) = 0;
178
179 // Clears the focused node (and selection if a text field is focused)
180 // to ensure that a text field on the page is not eating keystrokes we
181 // send it.
182 virtual void clearFocusedNode() = 0;
183
184 // Scrolls the node currently in focus into view.
185 virtual void scrollFocusedNodeIntoView() = 0;
186
187 // Scrolls the node currently in focus into |rect|, where |rect| is in
188 // window space.
189 virtual void scrollFocusedNodeIntoRect(const WebRect&) { }
190
191 // Advance the focus of the WebView forward to the next element or to the
192 // previous element in the tab sequence (if reverse is true).
193 virtual void advanceFocus(bool reverse) { }
194
195 // Animate a scale into the specified find-in-page rect.
196 virtual void zoomToFindInPageRect(const WebRect&) = 0;
197
198
199 // Zoom ----------------------------------------------------------------
200
201 // Returns the current zoom level. 0 is "original size", and each increment
202 // above or below represents zooming 20% larger or smaller to default limits
203 // of 300% and 50% of original size, respectively. Only plugins use
204 // non whole-numbers, since they might choose to have specific zoom level so
205 // that fixed-width content is fit-to-page-width, for example.
206 virtual double zoomLevel() = 0;
207
208 // Changes the zoom level to the specified level, clamping at the limits
209 // noted above, and returns the current zoom level after applying the
210 // change.
211 //
212 // If |textOnly| is set, only the text will be zoomed; otherwise the entire
213 // page will be zoomed. You can only have either text zoom or full page zoom
214 // at one time. Changing the mode while the page is zoomed will have odd
215 // effects.
216 virtual double setZoomLevel(bool textOnly, double zoomLevel) = 0;
217
218 // Updates the zoom limits for this view.
219 virtual void zoomLimitsChanged(double minimumZoomLevel,
220 double maximumZoomLevel) = 0;
221
222 // Helper functions to convert between zoom level and zoom factor. zoom
223 // factor is zoom percent / 100, so 300% = 3.0.
224 WEBKIT_EXPORT static double zoomLevelToZoomFactor(double zoomLevel);
225 WEBKIT_EXPORT static double zoomFactorToZoomLevel(double factor);
226
227 // Sets the initial page scale to the given factor. This scale setting overr ides
228 // page scale set in the page's viewport meta tag.
229 virtual void setInitialPageScaleOverride(float) = 0;
230
231 // Gets the scale factor of the page, where 1.0 is the normal size, > 1.0
232 // is scaled up, < 1.0 is scaled down.
233 virtual float pageScaleFactor() const = 0;
234
235 // Scales the page and the scroll offset by a given factor, while ensuring
236 // that the new scroll position does not go beyond the edge of the page.
237 virtual void setPageScaleFactorPreservingScrollOffset(float) = 0;
238
239 // Scales a page by a factor of scaleFactor and then sets a scroll position to (x, y).
240 // setPageScaleFactor() magnifies and shrinks a page without affecting layou t.
241 // On the other hand, zooming affects layout of the page.
242 virtual void setPageScaleFactor(float scaleFactor, const WebPoint& origin) = 0;
243
244 // PageScaleFactor will be force-clamped between minPageScale and maxPageSca le
245 // (and these values will persist until setPageScaleFactorLimits is called
246 // again).
247 virtual void setPageScaleFactorLimits(float minPageScale, float maxPageScale ) = 0;
248
249 virtual float minimumPageScaleFactor() const = 0;
250 virtual float maximumPageScaleFactor() const = 0;
251
252 // Save the WebView's current scroll and scale state. Each call to this func tion
253 // overwrites the previously saved scroll and scale state.
254 virtual void saveScrollAndScaleState() = 0;
255
256 // Restore the previously saved scroll and scale state. After restoring the
257 // state, this function deletes any saved scroll and scale state.
258 virtual void restoreScrollAndScaleState() = 0;
259
260 // Reset any saved values for the scroll and scale state.
261 virtual void resetScrollAndScaleState() = 0;
262
263 // Prevent the web page from setting min/max scale via the viewport meta
264 // tag. This is an accessibility feature that lets folks zoom in to web
265 // pages even if the web page tries to block scaling.
266 virtual void setIgnoreViewportTagScaleLimits(bool) = 0;
267
268 // Returns the "preferred" contents size, defined as the preferred minimum w idth of the main document's contents
269 // and the minimum height required to display the main document without scro llbars.
270 // The returned size has the page zoom factor applied.
271 virtual WebSize contentsPreferredMinimumSize() = 0;
272
273 // FIXME(aelias): Delete this after Chromium switches to the other name.
274 void setIgnoreViewportTagMaximumScale(bool ignore) { setIgnoreViewportTagSca leLimits(ignore); }
275
276 // The ratio of the current device's screen DPI to the target device's scree n DPI.
277 virtual float deviceScaleFactor() const = 0;
278
279 // Sets the ratio as computed by computePageScaleConstraints.
280 virtual void setDeviceScaleFactor(float) = 0;
281
282
283 // Fixed Layout --------------------------------------------------------
284
285 // In fixed layout mode, the layout of the page is independent of the
286 // view port size, given by WebWidget::size().
287
288 virtual bool isFixedLayoutModeEnabled() const = 0;
289 virtual void enableFixedLayoutMode(bool enable) = 0;
290
291 virtual WebSize fixedLayoutSize() const = 0;
292 virtual void setFixedLayoutSize(const WebSize&) = 0;
293
294
295 // Auto-Resize -----------------------------------------------------------
296
297 // In auto-resize mode, the view is automatically adjusted to fit the html
298 // content within the given bounds.
299 virtual void enableAutoResizeMode(
300 const WebSize& minSize,
301 const WebSize& maxSize) = 0;
302
303 // Turn off auto-resize.
304 virtual void disableAutoResizeMode() = 0;
305
306 // Media ---------------------------------------------------------------
307
308 // Performs the specified media player action on the node at the given locat ion.
309 virtual void performMediaPlayerAction(
310 const WebMediaPlayerAction&, const WebPoint& location) = 0;
311
312 // Performs the specified plugin action on the node at the given location.
313 virtual void performPluginAction(
314 const WebPluginAction&, const WebPoint& location) = 0;
315
316
317 // Data exchange -------------------------------------------------------
318
319 // Do a hit test at given point and return the HitTestResult.
320 virtual WebHitTestResult hitTestResultAt(const WebPoint&) = 0;
321
322 // Copy to the clipboard the image located at a particular point in the
323 // WebView (if there is such an image)
324 virtual void copyImageAt(const WebPoint&) = 0;
325
326 // Notifies the WebView that a drag has terminated.
327 virtual void dragSourceEndedAt(
328 const WebPoint& clientPoint, const WebPoint& screenPoint,
329 WebDragOperation operation) = 0;
330
331 // Notifies the WebView that a drag is going on.
332 virtual void dragSourceMovedTo(
333 const WebPoint& clientPoint, const WebPoint& screenPoint,
334 WebDragOperation operation) = 0;
335
336 // Notfies the WebView that the system drag and drop operation has ended.
337 virtual void dragSourceSystemDragEnded() = 0;
338
339 // Callback methods when a drag-and-drop operation is trying to drop
340 // something on the WebView.
341 virtual WebDragOperation dragTargetDragEnter(
342 const WebDragData&,
343 const WebPoint& clientPoint, const WebPoint& screenPoint,
344 WebDragOperationsMask operationsAllowed,
345 int keyModifiers) = 0;
346 virtual WebDragOperation dragTargetDragOver(
347 const WebPoint& clientPoint, const WebPoint& screenPoint,
348 WebDragOperationsMask operationsAllowed,
349 int keyModifiers) = 0;
350 virtual void dragTargetDragLeave() = 0;
351 virtual void dragTargetDrop(
352 const WebPoint& clientPoint, const WebPoint& screenPoint,
353 int keyModifiers) = 0;
354
355 // Retrieves a list of spelling markers.
356 virtual void spellingMarkers(WebVector<uint32_t>* markers) = 0;
357
358
359 // Support for resource loading initiated by plugins -------------------
360
361 // Returns next unused request identifier which is unique within the
362 // parent Page.
363 virtual unsigned long createUniqueIdentifierForRequest() = 0;
364
365
366 // Developer tools -----------------------------------------------------
367
368 // Inspect a particular point in the WebView. (x = -1 || y = -1) is a
369 // special case, meaning inspect the current page and not a specific
370 // point.
371 virtual void inspectElementAt(const WebPoint&) = 0;
372
373 // Settings used by the inspector.
374 virtual WebString inspectorSettings() const = 0;
375 virtual void setInspectorSettings(const WebString&) = 0;
376 virtual bool inspectorSetting(const WebString& key,
377 WebString* value) const = 0;
378 virtual void setInspectorSetting(const WebString& key,
379 const WebString& value) = 0;
380
381 // The embedder may optionally engage a WebDevToolsAgent. This may only
382 // be set once per WebView.
383 virtual WebDevToolsAgent* devToolsAgent() = 0;
384
385
386 // Accessibility -------------------------------------------------------
387
388 // Returns the accessibility object for this view.
389 virtual WebAccessibilityObject accessibilityObject() = 0;
390
391
392 // Autofill -----------------------------------------------------------
393
394 // Notifies the WebView that Autofill suggestions are available for a node.
395 // |itemIDs| is a vector of IDs for the menu items. A positive itemID is a
396 // unique ID for the Autofill entries. Other MenuItemIDs are defined in
397 // WebAutofillClient.h
398 virtual void applyAutofillSuggestions(
399 const WebNode&,
400 const WebVector<WebString>& names,
401 const WebVector<WebString>& labels,
402 const WebVector<WebString>& icons,
403 const WebVector<int>& itemIDs,
404 int separatorIndex = -1) = 0;
405
406 // Hides any popup (suggestions, selects...) that might be showing.
407 virtual void hidePopups() = 0;
408
409 virtual void selectAutofillSuggestionAtIndex(unsigned listIndex) = 0;
410
411
412 // Context menu --------------------------------------------------------
413
414 virtual void performCustomContextMenuAction(unsigned action) = 0;
415
416 // Shows a context menu for the currently focused element.
417 virtual void showContextMenu() = 0;
418
419
420 // Popup menu ----------------------------------------------------------
421
422 // Sets whether select popup menus should be rendered by the browser.
423 WEBKIT_EXPORT static void setUseExternalPopupMenus(bool);
424
425
426 // Visited link state --------------------------------------------------
427
428 // Tells all WebView instances to update the visited link state for the
429 // specified hash.
430 WEBKIT_EXPORT static void updateVisitedLinkState(unsigned long long hash);
431
432 // Tells all WebView instances to update the visited state for all
433 // their links.
434 WEBKIT_EXPORT static void resetVisitedLinkState();
435
436
437 // Custom colors -------------------------------------------------------
438
439 virtual void setScrollbarColors(unsigned inactiveColor,
440 unsigned activeColor,
441 unsigned trackColor) = 0;
442
443 virtual void setSelectionColors(unsigned activeBackgroundColor,
444 unsigned activeForegroundColor,
445 unsigned inactiveBackgroundColor,
446 unsigned inactiveForegroundColor) = 0;
447
448 // User scripts --------------------------------------------------------
449 WEBKIT_EXPORT static void addUserStyleSheet(const WebString& sourceCode,
450 const WebVector<WebString>& patt erns,
451 UserContentInjectIn injectIn,
452 UserStyleInjectionTime injection Time = UserStyleInjectInSubsequentDocuments);
453 WEBKIT_EXPORT static void removeAllUserContent();
454
455 // Modal dialog support ------------------------------------------------
456
457 // Call these methods before and after running a nested, modal event loop
458 // to suspend script callbacks and resource loads.
459 WEBKIT_EXPORT static void willEnterModalLoop();
460 WEBKIT_EXPORT static void didExitModalLoop();
461
462 // Called to inform the WebView that a wheel fling animation was started ext ernally (for instance
463 // by the compositor) but must be completed by the WebView.
464 virtual void transferActiveWheelFlingAnimation(const WebActiveWheelFlingPara meters&) = 0;
465
466 virtual bool setEditableSelectionOffsets(int start, int end) = 0;
467 virtual bool setCompositionFromExistingText(int compositionStart, int compos itionEnd, const WebVector<WebCompositionUnderline>& underlines) = 0;
468 virtual void extendSelectionAndDelete(int before, int after) = 0;
469
470 virtual bool isSelectionEditable() const = 0;
471
472 virtual void setShowPaintRects(bool) = 0;
473 virtual void setShowFPSCounter(bool) = 0;
474 virtual void setContinuousPaintingEnabled(bool) = 0;
475
476 // Benchmarking support -------------------------------------------------
477
478 virtual WebViewBenchmarkSupport* benchmarkSupport() { return 0; }
479
480 // Visibility -----------------------------------------------------------
481
482 // Sets the visibility of the WebView.
483 virtual void setVisibilityState(WebPageVisibilityState visibilityState,
484 bool isInitialState) { }
485
486 // PageOverlay ----------------------------------------------------------
487
488 // Adds/removes page overlay to this WebView. These functions change the
489 // graphical appearance of the WebView. WebPageOverlay paints the
490 // contents of the page overlay. It also provides an z-order number for
491 // the page overlay. The z-order number defines the paint order the page
492 // overlays. Page overlays with larger z-order number will be painted after
493 // page overlays with smaller z-order number. That is, they appear above
494 // the page overlays with smaller z-order number. If two page overlays have
495 // the same z-order number, the later added one will be on top.
496 virtual void addPageOverlay(WebPageOverlay*, int /*z-order*/) = 0;
497 virtual void removePageOverlay(WebPageOverlay*) = 0;
498
499 // Testing functionality for TestRunner ---------------------------------
500
501 protected:
502 ~WebView() {}
503 };
504
505 } // namespace WebKit
506
507 #endif
OLDNEW
« no previous file with comments | « public/webpage/WebValidationMessageClient.h ('k') | public/webpage/WebViewBenchmarkSupport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698