2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Corporation. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
30 #include "Arguments.h"
31 #include "DataReference.h"
32 #include "DecoderAdapter.h"
33 #include "DrawingArea.h"
34 #include "InjectedBundle.h"
35 #include "InjectedBundleBackForwardList.h"
36 #include "LayerTreeHost.h"
37 #include "MessageID.h"
38 #include "NetscapePlugin.h"
39 #include "NotificationPermissionRequestManager.h"
40 #include "PageOverlay.h"
41 #include "PluginProxy.h"
42 #include "PluginView.h"
43 #include "PrintInfo.h"
44 #include "SessionState.h"
45 #include "ShareableBitmap.h"
46 #include "WebAlternativeTextClient.h"
47 #include "WebBackForwardList.h"
48 #include "WebBackForwardListItem.h"
49 #include "WebBackForwardListProxy.h"
50 #include "WebChromeClient.h"
51 #include "WebColorChooser.h"
52 #include "WebContextMenu.h"
53 #include "WebContextMenuClient.h"
54 #include "WebContextMessages.h"
55 #include "WebCoreArgumentCoders.h"
56 #include "WebDragClient.h"
57 #include "WebEditorClient.h"
59 #include "WebEventConversion.h"
61 #include "WebFullScreenManager.h"
62 #include "WebGeolocationClient.h"
63 #include "WebGeometry.h"
65 #include "WebInspector.h"
66 #include "WebInspectorClient.h"
67 #include "WebNotificationClient.h"
68 #include "WebOpenPanelResultListener.h"
69 #include "WebPageCreationParameters.h"
70 #include "WebPageGroupProxy.h"
71 #include "WebPageProxyMessages.h"
72 #include "WebPopupMenu.h"
73 #include "WebPreferencesStore.h"
74 #include "WebProcess.h"
75 #include "WebProcessProxyMessages.h"
76 #include <JavaScriptCore/APICast.h>
77 #include <WebCore/AbstractDatabase.h>
78 #include <WebCore/ArchiveResource.h>
79 #include <WebCore/Chrome.h>
80 #include <WebCore/ContextMenuController.h>
81 #include <WebCore/DocumentFragment.h>
82 #include <WebCore/DocumentLoader.h>
83 #include <WebCore/DocumentMarkerController.h>
84 #include <WebCore/DragController.h>
85 #include <WebCore/DragData.h>
86 #include <WebCore/DragSession.h>
87 #include <WebCore/EventHandler.h>
88 #include <WebCore/FocusController.h>
89 #include <WebCore/FormState.h>
90 #include <WebCore/Frame.h>
91 #include <WebCore/FrameLoadRequest.h>
92 #include <WebCore/FrameLoaderTypes.h>
93 #include <WebCore/FrameView.h>
94 #include <WebCore/HTMLFormElement.h>
95 #include <WebCore/HTMLInputElement.h>
96 #include <WebCore/HTMLPlugInElement.h>
97 #include <WebCore/HistoryItem.h>
98 #include <WebCore/KeyboardEvent.h>
99 #include <WebCore/MouseEvent.h>
100 #include <WebCore/Page.h>
101 #include <WebCore/PlatformKeyboardEvent.h>
102 #include <WebCore/PluginDocument.h>
103 #include <WebCore/PrintContext.h>
104 #include <WebCore/RenderLayer.h>
105 #include <WebCore/RenderTreeAsText.h>
106 #include <WebCore/RenderView.h>
107 #include <WebCore/ResourceRequest.h>
108 #include <WebCore/RunLoop.h>
109 #include <WebCore/SchemeRegistry.h>
110 #include <WebCore/ScriptValue.h>
111 #include <WebCore/SerializedScriptValue.h>
112 #include <WebCore/Settings.h>
113 #include <WebCore/SharedBuffer.h>
114 #include <WebCore/SubstituteData.h>
115 #include <WebCore/TextIterator.h>
116 #include <WebCore/markup.h>
117 #include <runtime/JSLock.h>
118 #include <runtime/JSValue.h>
120 #include <WebCore/Range.h>
121 #include <WebCore/VisiblePosition.h>
124 #include <WebCore/MHTMLArchive.h>
127 #if ENABLE(PLUGIN_PROCESS)
129 #include "MachPort.h"
133 #if ENABLE(BATTERY_STATUS)
134 #include "WebBatteryClient.h"
137 #if ENABLE(NETWORK_INFO)
138 #include "WebNetworkInfoClient.h"
141 #if ENABLE(WEB_INTENTS)
142 #include "IntentData.h"
145 #if ENABLE(VIBRATION)
146 #include "WebVibrationClient.h"
149 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER) || ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
150 #include "WebRegisterProtocolHandlerClient.h"
153 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
154 #include "WebRegisterContentHandlerClient.h"
158 #include "BuiltInPDFView.h"
162 #if ENABLE(DEVICE_ORIENTATION)
163 #include "DeviceMotionClientQt.h"
164 #include "DeviceOrientationClientQt.h"
166 #include "HitTestResult.h"
172 #include "DataObjectGtk.h"
173 #include "WebPrintOperationGtk.h"
176 #if ENABLE(TIZEN_MEDIA_STREAM)
177 #include "WebUserMediaClient.h"
178 #include "UserMediaPermissionRequestManager.h"
181 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
182 #include <WebCore/NodeList.h>
183 #include "HTMLLinkElement.h"
184 #include "HTMLMetaElement.h"
187 #if ENABLE(TIZEN_GEOLOCATION)
188 #include <WebCore/GeolocationClientMock.h>
189 #include <WebCore/GeolocationController.h>
193 #include <wtf/RefCountedLeakCounter.h>
196 #if ENABLE(TIZEN_INDEXED_DATABASE)
197 #include <WebCore/PageGroup.h>
198 #include <WebCore/GroupSettings.h>
201 #if ENABLE(TIZEN_ISF_PORT)
202 #include "NativeWebKeyboardEvent.h"
205 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
206 #include "AboutDataTizen.h"
209 #if ENABLE(TIZEN_DRAG_SUPPORT)
210 #include "DataObjectTizen.h"
213 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_TEXT_SELECTION_MODE)
214 #include "HTMLImageElement.h"
218 using namespace WebCore;
223 class SendStopResponsivenessTimer {
225 SendStopResponsivenessTimer(WebPage* page)
230 ~SendStopResponsivenessTimer()
232 m_page->send(Messages::WebPageProxy::StopResponsivenessTimer());
239 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageCounter, ("WebPage"));
241 PassRefPtr<WebPage> WebPage::create(uint64_t pageID, const WebPageCreationParameters& parameters)
243 RefPtr<WebPage> page = adoptRef(new WebPage(pageID, parameters));
245 if (page->pageGroup()->isVisibleToInjectedBundle() && WebProcess::shared().injectedBundle())
246 WebProcess::shared().injectedBundle()->didCreatePage(page.get());
248 return page.release();
251 WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
252 : m_viewSize(parameters.viewSize)
253 , m_useFixedLayout(false)
254 , m_drawsBackground(true)
255 , m_drawsTransparentBackground(false)
258 , m_tabToLinks(false)
260 , m_windowIsVisible(false)
261 , m_isSmartInsertDeleteEnabled(parameters.isSmartInsertDeleteEnabled)
262 , m_layerHostingMode(parameters.layerHostingMode)
263 , m_keyboardEventBeingInterpreted(0)
265 , m_nativeWindow(parameters.nativeWindow)
267 , m_accessibilityObject(0)
269 , m_setCanStartMediaTimer(WebProcess::shared().runLoop(), this, &WebPage::setCanStartMediaTimerFired)
270 , m_findController(this)
271 #if ENABLE(TOUCH_EVENTS)
273 , m_tapHighlightController(this)
276 #if ENABLE(INPUT_TYPE_COLOR)
277 , m_activeColorChooser(0)
279 #if ENABLE(GEOLOCATION)
280 , m_geolocationPermissionRequestManager(this)
283 , m_canRunBeforeUnloadConfirmPanel(parameters.canRunBeforeUnloadConfirmPanel)
284 , m_canRunModal(parameters.canRunModal)
285 , m_isRunningModal(false)
286 , m_cachedMainFrameIsPinnedToLeftSide(false)
287 , m_cachedMainFrameIsPinnedToRightSide(false)
288 , m_canShortCircuitHorizontalWheelEvents(false)
289 , m_numWheelEventHandlers(0)
290 , m_cachedPageCount(0)
291 #if ENABLE(CONTEXT_MENUS)
292 , m_isShowingContextMenu(false)
294 , m_willGoToBackForwardItemCallbackEnabled(true)
296 , m_gestureReachedScrollingLimit(false)
298 #if ENABLE(PAGE_VISIBILITY_API)
299 , m_visibilityState(WebCore::PageVisibilityStateVisible)
301 #if ENABLE(TIZEN_SYNC_REQUEST_ANIMATION_FRAME)
302 , m_suspendedAnimationController(false)
304 , m_inspectorClient(0)
305 #if ENABLE(TIZEN_ISF_PORT)
306 , m_prepareKeyDownEvent(false)
310 // FIXME: This is a non-ideal location for this Setting and
311 // 4ms should be adopted project-wide now, https://bugs.webkit.org/show_bug.cgi?id=61214
312 #if ENABLE(TIZEN_DOM_TIMER_MIN_INTERVAL_SET)
313 Settings::setDefaultMinDOMTimerInterval(0.001);
315 Settings::setDefaultMinDOMTimerInterval(0.004);
318 Page::PageClients pageClients;
319 pageClients.chromeClient = new WebChromeClient(this);
320 #if ENABLE(CONTEXT_MENUS)
321 pageClients.contextMenuClient = new WebContextMenuClient(this);
323 pageClients.editorClient = new WebEditorClient(this);
324 #if ENABLE(DRAG_SUPPORT)
325 pageClients.dragClient = new WebDragClient(this);
327 pageClients.backForwardClient = WebBackForwardListProxy::create(this);
328 #if ENABLE(INSPECTOR)
329 m_inspectorClient = new WebInspectorClient(this);
330 pageClients.inspectorClient = m_inspectorClient;
332 #if USE(AUTOCORRECTION_PANEL)
333 pageClients.alternativeTextClient = new WebAlternativeTextClient(this);
336 m_page = adoptPtr(new Page(pageClients));
338 #if ENABLE(BATTERY_STATUS)
339 WebCore::provideBatteryTo(m_page.get(), new WebBatteryClient(this));
341 #if ENABLE(GEOLOCATION)
342 #if ENABLE(TIZEN_GEOLOCATION) && ENABLE(TIZEN_WEBKIT2_EFL_WTR)
343 if (WebProcess::shared().injectedBundle() && WebProcess::shared().injectedBundle()->testRunnerModeEnabled()) {
344 GeolocationClientMock* mock = new GeolocationClientMock();
345 WebCore::provideGeolocationTo(m_page.get(), mock);
346 mock->setController(WebCore::GeolocationController::from(m_page.get()));
348 #endif // ENABLE(TIZEN_GEOLOCATION) && ENABLE(TIZEN_WEBKIT2_EFL_WTR)
349 WebCore::provideGeolocationTo(m_page.get(), new WebGeolocationClient(this));
351 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(QT)
352 WebCore::provideDeviceMotionTo(m_page.get(), new DeviceMotionClientQt);
353 WebCore::provideDeviceOrientationTo(m_page.get(), new DeviceOrientationClientQt);
355 #if ENABLE(NETWORK_INFO)
356 WebCore::provideNetworkInfoTo(m_page.get(), new WebNetworkInfoClient(this));
358 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
359 WebCore::provideNotification(m_page.get(), new WebNotificationClient(this));
361 #if ENABLE(VIBRATION)
362 WebCore::provideVibrationTo(m_page.get(), new WebVibrationClient(this));
365 #if ENABLE(VIBRATION)
366 WebCore::provideVibrationTo(m_page.get(), new WebVibrationClient(this));
369 #if ENABLE(TIZEN_MEDIA_STREAM)
370 WebCore::provideUserMediaTo(m_page.get(), new WebUserMediaClient(this));
373 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER) || ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
374 WebCore::provideRegisterProtocolHandlerTo(m_page.get(), new WebRegisterProtocolHandlerClient(this));
377 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
378 WebCore::provideRegisterContentHandlerTo(m_page.get(), new WebRegisterContentHandlerClient(this));
381 // Qt does not yet call setIsInWindow. Until it does, just leave
382 // this line out so plug-ins and video will work. Eventually all platforms
383 // should call setIsInWindow and this comment and #if should be removed,
384 // leaving behind the setCanStartMedia call.
386 m_page->setCanStartMedia(false);
389 updatePreferences(parameters.store);
391 m_pageGroup = WebProcess::shared().webPageGroup(parameters.pageGroupData);
392 m_page->setGroupName(m_pageGroup->identifier());
393 m_page->setDeviceScaleFactor(parameters.deviceScaleFactor);
395 platformInitialize();
397 m_drawingArea = DrawingArea::create(this, parameters);
398 m_drawingArea->setPaintingEnabled(false);
400 m_mainFrame = WebFrame::createMainFrame(this);
402 setUseFixedLayout(parameters.useFixedLayout);
404 setDrawsBackground(parameters.drawsBackground);
405 setDrawsTransparentBackground(parameters.drawsTransparentBackground);
407 setPaginationMode(parameters.paginationMode);
408 setPaginationBehavesLikeColumns(parameters.paginationBehavesLikeColumns);
409 setPageLength(parameters.pageLength);
410 setGapBetweenPages(parameters.gapBetweenPages);
412 setMemoryCacheMessagesEnabled(parameters.areMemoryCacheClientCallsEnabled);
414 setActive(parameters.isActive);
415 setFocused(parameters.isFocused);
416 setIsInWindow(parameters.isInWindow);
418 m_userAgent = parameters.userAgent;
420 WebBackForwardListProxy::setHighestItemIDFromUIProcess(parameters.highestUsedBackForwardItemID);
422 if (!parameters.sessionState.isEmpty())
423 restoreSession(parameters.sessionState);
425 m_drawingArea->setPaintingEnabled(true);
427 setMediaVolume(parameters.mediaVolume);
430 webPageCounter.increment();
436 if (m_backForwardList)
437 m_backForwardList->detach();
441 m_sandboxExtensionTracker.invalidate();
443 for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
444 (*it)->webPageDestroyed();
447 webPageCounter.decrement();
451 void WebPage::dummy(bool&)
455 CoreIPC::Connection* WebPage::connection() const
457 return WebProcess::shared().connection();
460 #if ENABLE(CONTEXT_MENUS)
461 void WebPage::initializeInjectedBundleContextMenuClient(WKBundlePageContextMenuClient* client)
463 m_contextMenuClient.initialize(client);
467 void WebPage::initializeInjectedBundleEditorClient(WKBundlePageEditorClient* client)
469 m_editorClient.initialize(client);
472 void WebPage::initializeInjectedBundleFormClient(WKBundlePageFormClient* client)
474 m_formClient.initialize(client);
477 void WebPage::initializeInjectedBundleLoaderClient(WKBundlePageLoaderClient* client)
479 m_loaderClient.initialize(client);
482 void WebPage::initializeInjectedBundlePolicyClient(WKBundlePagePolicyClient* client)
484 m_policyClient.initialize(client);
487 void WebPage::initializeInjectedBundleResourceLoadClient(WKBundlePageResourceLoadClient* client)
489 m_resourceLoadClient.initialize(client);
492 void WebPage::initializeInjectedBundleUIClient(WKBundlePageUIClient* client)
494 m_uiClient.initialize(client);
497 #if ENABLE(FULLSCREEN_API)
498 void WebPage::initializeInjectedBundleFullScreenClient(WKBundlePageFullScreenClient* client)
500 m_fullScreenClient.initialize(client);
504 void WebPage::initializeInjectedBundleDiagnosticLoggingClient(WKBundlePageDiagnosticLoggingClient* client)
506 m_logDiagnosticMessageClient.initialize(client);
509 PassRefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* pluginElement, const Plugin::Parameters& parameters)
512 bool blocked = false;
514 if (!WebProcess::shared().connection()->sendSync(
515 Messages::WebContext::GetPluginPath(parameters.mimeType, parameters.url.string()),
516 Messages::WebContext::GetPluginPath::Reply(pluginPath, blocked), 0)) {
521 if (pluginElement->renderer()->isEmbeddedObject())
522 toRenderEmbeddedObject(pluginElement->renderer())->setPluginUnavailabilityReason(RenderEmbeddedObject::InsecurePluginVersion);
524 send(Messages::WebPageProxy::DidBlockInsecurePluginVersion(parameters.mimeType, parameters.url.string()));
528 if (pluginPath.isNull()) {
530 if (parameters.mimeType == "application/pdf"
531 || (parameters.mimeType.isEmpty() && parameters.url.path().lower().endsWith(".pdf")))
532 return BuiltInPDFView::create(frame);
539 #if ENABLE(PLUGIN_PROCESS)
540 return PluginProxy::create(pluginPath);
541 #elif ENABLE(NETSCAPE_PLUGIN_API)
542 NetscapePlugin::setSetExceptionFunction(NPRuntimeObjectMap::setGlobalException);
543 return NetscapePlugin::create(NetscapePluginModule::getOrCreate(pluginPath));
549 EditorState WebPage::editorState() const
551 Frame* frame = m_page->focusController()->focusedOrMainFrame();
555 result.selectionIsNone = frame->selection()->isNone();
556 result.selectionIsRange = frame->selection()->isRange();
557 result.isContentEditable = frame->selection()->isContentEditable();
558 result.isContentRichlyEditable = frame->selection()->isContentRichlyEditable();
559 result.isInPasswordField = frame->selection()->isInPasswordField();
560 result.hasComposition = frame->editor()->hasComposition();
561 result.shouldIgnoreCompositionSelectionChange = frame->editor()->ignoreCompositionSelectionChange();
563 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
564 if (!result.shouldIgnoreCompositionSelectionChange) {
565 result.underlineState = frame->editor()->selectionHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "underline");
566 result.italicState = frame->editor()->selectionHasStyle(CSSPropertyFontStyle, "italic");
567 result.boldState = frame->editor()->selectionHasStyle(CSSPropertyFontWeight, "bold");
568 result.bgColor = frame->editor()->selectionStartCSSPropertyValue(CSSPropertyBackgroundColor);
569 result.color = frame->editor()->selectionStartCSSPropertyValue(CSSPropertyColor);
570 result.fontSize = frame->editor()->selectionStartCSSPropertyValue(CSSPropertyFontSize);
574 #if ENABLE(TIZEN_ISF_PORT) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
575 Element* rootEditableElement = frame->selection()->rootEditableElement();
576 if (!rootEditableElement)
579 result.editorRect = nodeRect(rootEditableElement);
582 #if ENABLE(TIZEN_ISF_PORT)
583 result.isTapEventHandling = (currentEvent() && currentEvent()->type() == WebEvent::GestureSingleTap);
585 if (!result.shouldIgnoreCompositionSelectionChange && result.isContentEditable) {
586 result.inputMethodContextID = reinterpret_cast<uintptr_t>(rootEditableElement);
588 Node* hostNode = rootEditableElement->shadowHost();
590 hostNode = rootEditableElement;
592 HTMLTextFormControlElement* formControl = toTextFormControl(hostNode);
594 const AtomicString& type = formControl->type();
596 if (type == "number" && formControl->hasTagName(HTMLNames::inputTag)) {
597 StepRange stepRange = static_cast<HTMLInputElement*>(formControl)->createStepRange(RejectAny);
598 bool needsSigned = stepRange.minimum().isNegative();
599 bool needsDecimal = (stepRange.step().floor() != stepRange.step());
601 if (needsSigned && needsDecimal)
602 result.inputMethodHints = "signedDecimalNumber";
603 else if (needsSigned)
604 result.inputMethodHints = "signedNumber";
605 else if (needsDecimal)
606 result.inputMethodHints = "decimalNumber";
608 result.inputMethodHints = "number";
609 } else if (type == "text" && formControl->form() && equalIgnoringCase(formControl->form()->fastGetAttribute(HTMLNames::roleAttr), "search"))
610 result.inputMethodHints = "search";
612 result.inputMethodHints = type;
614 result.surroundingText = formControl->value();
617 Position base = frame->selection()->base();
618 Node* baseNode = base.containerNode();
620 result.cursorPosition = baseNode->isTextNode() ? base.offsetInContainerNode() : 0;
628 Element* selectionRoot = frame->selection()->rootEditableElement();
629 Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
634 if (scope->hasTagName(HTMLNames::inputTag)) {
635 HTMLInputElement* input = static_cast<HTMLInputElement*>(scope);
636 if (input->isTelephoneField())
637 result.inputMethodHints |= Qt::ImhDialableCharactersOnly;
638 else if (input->isNumberField())
639 result.inputMethodHints |= Qt::ImhDigitsOnly;
640 else if (input->isEmailField()) {
641 result.inputMethodHints |= Qt::ImhEmailCharactersOnly;
642 result.inputMethodHints |= Qt::ImhNoAutoUppercase;
643 } else if (input->isURLField()) {
644 result.inputMethodHints |= Qt::ImhUrlCharactersOnly;
645 result.inputMethodHints |= Qt::ImhNoAutoUppercase;
646 } else if (input->isPasswordField()) {
647 // Set ImhHiddenText flag for password fields. The Qt platform
648 // is responsible for determining which widget will receive input
649 // method events for password fields.
650 result.inputMethodHints |= Qt::ImhHiddenText;
651 result.inputMethodHints |= Qt::ImhNoAutoUppercase;
652 result.inputMethodHints |= Qt::ImhNoPredictiveText;
653 result.inputMethodHints |= Qt::ImhSensitiveData;
658 result.editorRect = frame->view()->contentsToWindow(selectionRoot->getPixelSnappedRect());
661 if (result.hasComposition && (range = frame->editor()->compositionRange())) {
662 frame->editor()->getCompositionSelection(result.anchorPosition, result.cursorPosition);
664 result.compositionRect = frame->view()->contentsToWindow(range->boundingBox());
667 if (!result.hasComposition && !result.selectionIsNone && (range = frame->selection()->selection().firstRange())) {
668 TextIterator::getLocationAndLengthFromRange(scope, range.get(), location, length);
669 bool baseIsFirst = frame->selection()->selection().isBaseFirst();
671 result.cursorPosition = (baseIsFirst) ? location + length : location;
672 result.anchorPosition = (baseIsFirst) ? location : location + length;
673 result.selectedText = range->text();
677 result.cursorRect = frame->view()->contentsToWindow(frame->editor()->firstRectForRange(range.get()));
679 // FIXME: We should only transfer innerText when it changes and do this on the UI side.
680 if (result.isContentEditable && !result.isInPasswordField) {
681 result.surroundingText = scope->innerText();
682 if (result.hasComposition) {
683 // The anchor is always the left position when they represent a composition.
684 result.surroundingText.remove(result.anchorPosition, result.cursorPosition - result.anchorPosition);
692 String WebPage::renderTreeExternalRepresentation() const
694 return externalRepresentation(m_mainFrame->coreFrame(), RenderAsTextBehaviorNormal);
697 uint64_t WebPage::renderTreeSize() const
701 return m_page->renderTreeSize().treeSize;
704 void WebPage::setPaintedObjectsCounterThreshold(uint64_t threshold)
708 m_page->setRelevantRepaintedObjectsCounterThreshold(threshold);
711 void WebPage::setTracksRepaints(bool trackRepaints)
713 if (FrameView* view = mainFrameView())
714 view->setTracksRepaints(trackRepaints);
717 bool WebPage::isTrackingRepaints() const
719 if (FrameView* view = mainFrameView())
720 return view->isTrackingRepaints();
725 void WebPage::resetTrackedRepaints()
727 if (FrameView* view = mainFrameView())
728 view->resetTrackedRepaints();
731 PassRefPtr<ImmutableArray> WebPage::trackedRepaintRects()
733 FrameView* view = mainFrameView();
735 return ImmutableArray::create();
737 const Vector<IntRect>& rects = view->trackedRepaintRects();
738 size_t size = rects.size();
740 return ImmutableArray::create();
742 Vector<RefPtr<APIObject> > vector;
743 vector.reserveInitialCapacity(size);
745 for (size_t i = 0; i < size; ++i)
746 vector.uncheckedAppend(WebRect::create(toAPI(rects[i])));
748 return ImmutableArray::adopt(vector);
751 void WebPage::executeEditingCommand(const String& commandName, const String& argument)
753 Frame* frame = m_page->focusController()->focusedOrMainFrame();
756 frame->editor()->command(commandName).execute(argument);
759 bool WebPage::isEditingCommandEnabled(const String& commandName)
761 Frame* frame = m_page->focusController()->focusedOrMainFrame();
765 Editor::Command command = frame->editor()->command(commandName);
766 return command.isSupported() && command.isEnabled();
769 void WebPage::clearMainFrameName()
771 if (Frame* frame = mainFrame())
772 frame->tree()->clearName();
775 #if USE(ACCELERATED_COMPOSITING)
776 void WebPage::enterAcceleratedCompositingMode(GraphicsLayer* layer)
778 m_drawingArea->setRootCompositingLayer(layer);
781 void WebPage::exitAcceleratedCompositingMode()
783 m_drawingArea->setRootCompositingLayer(0);
787 void WebPage::close()
794 if (pageGroup()->isVisibleToInjectedBundle() && WebProcess::shared().injectedBundle())
795 WebProcess::shared().injectedBundle()->willDestroyPage(this);
797 #if ENABLE(INSPECTOR)
800 #if ENABLE(FULLSCREEN_API)
801 m_fullScreenManager = 0;
804 if (m_activePopupMenu) {
805 m_activePopupMenu->disconnectFromPage();
806 m_activePopupMenu = 0;
809 if (m_activeOpenPanelResultListener) {
810 m_activeOpenPanelResultListener->disconnectFromPage();
811 m_activeOpenPanelResultListener = 0;
814 #if ENABLE(INPUT_TYPE_COLOR)
815 if (m_activeColorChooser) {
816 m_activeColorChooser->disconnectFromPage();
817 m_activeColorChooser = 0;
821 m_sandboxExtensionTracker.invalidate();
823 m_underlayPage = nullptr;
824 m_printContext = nullptr;
825 m_mainFrame->coreFrame()->loader()->detachFromParent();
827 m_drawingArea = nullptr;
829 bool isRunningModal = m_isRunningModal;
830 m_isRunningModal = false;
832 // The WebPage can be destroyed by this call.
833 WebProcess::shared().removeWebPage(m_pageID);
836 WebProcess::shared().runLoop()->stop();
839 void WebPage::tryClose()
841 SendStopResponsivenessTimer stopper(this);
843 if (!m_mainFrame->coreFrame()->loader()->shouldClose()) {
844 send(Messages::WebPageProxy::StopResponsivenessTimer());
848 send(Messages::WebPageProxy::ClosePage(true));
851 void WebPage::sendClose()
853 send(Messages::WebPageProxy::ClosePage(false));
856 void WebPage::loadURL(const String& url, const SandboxExtension::Handle& sandboxExtensionHandle)
858 loadURLRequest(ResourceRequest(KURL(KURL(), url)), sandboxExtensionHandle);
861 void WebPage::loadURLRequest(const ResourceRequest& request, const SandboxExtension::Handle& sandboxExtensionHandle)
863 SendStopResponsivenessTimer stopper(this);
865 m_sandboxExtensionTracker.beginLoad(m_mainFrame.get(), sandboxExtensionHandle);
866 m_mainFrame->coreFrame()->loader()->load(request, false);
869 void WebPage::loadData(PassRefPtr<SharedBuffer> sharedBuffer, const String& MIMEType, const String& encodingName, const KURL& baseURL, const KURL& unreachableURL)
871 SendStopResponsivenessTimer stopper(this);
873 ResourceRequest request(baseURL);
874 SubstituteData substituteData(sharedBuffer, MIMEType, encodingName, unreachableURL);
875 m_mainFrame->coreFrame()->loader()->load(request, substituteData, false);
878 void WebPage::loadHTMLString(const String& htmlString, const String& baseURLString)
880 #if ENABLE(TIZEN_LOAD_HTML_STRING_AS_UTF8)
881 CString html = htmlString.utf8();
882 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(html.data()), html.length());
883 KURL baseURL = baseURLString.isEmpty() ? blankURL() : KURL(KURL(), baseURLString);
884 loadData(sharedBuffer, "text/html", "utf-8", baseURL, KURL());
886 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar));
887 KURL baseURL = baseURLString.isEmpty() ? blankURL() : KURL(KURL(), baseURLString);
888 loadData(sharedBuffer, "text/html", "utf-16", baseURL, KURL());
892 void WebPage::loadAlternateHTMLString(const String& htmlString, const String& baseURLString, const String& unreachableURLString)
894 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar));
895 KURL baseURL = baseURLString.isEmpty() ? blankURL() : KURL(KURL(), baseURLString);
896 KURL unreachableURL = unreachableURLString.isEmpty() ? KURL() : KURL(KURL(), unreachableURLString);
897 loadData(sharedBuffer, "text/html", "utf-16", baseURL, unreachableURL);
900 void WebPage::loadPlainTextString(const String& string)
902 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(string.characters()), string.length() * sizeof(UChar));
903 loadData(sharedBuffer, "text/plain", "utf-16", blankURL(), KURL());
906 void WebPage::loadWebArchiveData(const CoreIPC::DataReference& webArchiveData)
908 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(webArchiveData.data()), webArchiveData.size() * sizeof(uint8_t));
909 loadData(sharedBuffer, "application/x-webarchive", "utf-16", blankURL(), KURL());
913 void WebPage::loadContentsbyMimeType(const CoreIPC::DataReference& contents, const String& mimeType, const String& encoding, const String& baseURL)
915 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(contents.data()), contents.size() * sizeof(uint8_t));
916 KURL baseKURL(WebCore::KURL(), baseURL);
917 loadData(sharedBuffer, mimeType, encoding, baseKURL, KURL());
921 void WebPage::linkClicked(const String& url, const WebMouseEvent& event)
923 Frame* frame = m_page->mainFrame();
927 RefPtr<Event> coreEvent;
928 if (event.type() != WebEvent::NoType)
929 coreEvent = MouseEvent::create(eventNames().clickEvent, frame->document()->defaultView(), platform(event), 0, 0);
931 frame->loader()->loadFrameRequest(FrameLoadRequest(frame->document()->securityOrigin(), ResourceRequest(url)),
932 false, false, coreEvent.get(), 0, MaybeSendReferrer);
935 void WebPage::stopLoadingFrame(uint64_t frameID)
937 WebFrame* frame = WebProcess::shared().webFrame(frameID);
941 frame->coreFrame()->loader()->stopForUserCancel();
944 void WebPage::stopLoading()
946 SendStopResponsivenessTimer stopper(this);
948 m_mainFrame->coreFrame()->loader()->stopForUserCancel();
951 void WebPage::setDefersLoading(bool defersLoading)
953 m_page->setDefersLoading(defersLoading);
956 void WebPage::reload(bool reloadFromOrigin, const SandboxExtension::Handle& sandboxExtensionHandle)
958 SendStopResponsivenessTimer stopper(this);
960 m_sandboxExtensionTracker.beginLoad(m_mainFrame.get(), sandboxExtensionHandle);
961 m_mainFrame->coreFrame()->loader()->reload(reloadFromOrigin);
964 void WebPage::goForward(uint64_t backForwardItemID)
966 SendStopResponsivenessTimer stopper(this);
968 HistoryItem* item = WebBackForwardListProxy::itemForID(backForwardItemID);
973 m_page->goToItem(item, FrameLoadTypeForward);
976 void WebPage::goBack(uint64_t backForwardItemID)
978 SendStopResponsivenessTimer stopper(this);
980 HistoryItem* item = WebBackForwardListProxy::itemForID(backForwardItemID);
985 m_page->goToItem(item, FrameLoadTypeBack);
988 void WebPage::goToBackForwardItem(uint64_t backForwardItemID)
990 SendStopResponsivenessTimer stopper(this);
992 HistoryItem* item = WebBackForwardListProxy::itemForID(backForwardItemID);
997 m_page->goToItem(item, FrameLoadTypeIndexedBackForward);
1000 void WebPage::tryRestoreScrollPosition()
1002 m_page->mainFrame()->loader()->history()->restoreScrollPositionAndViewState();
1005 void WebPage::layoutIfNeeded()
1007 if (m_mainFrame->coreFrame()->view())
1008 m_mainFrame->coreFrame()->view()->updateLayoutAndStyleIfNeededRecursive();
1010 if (m_underlayPage) {
1011 if (FrameView *frameView = m_underlayPage->mainFrameView())
1012 frameView->updateLayoutAndStyleIfNeededRecursive();
1016 void WebPage::setSize(const WebCore::IntSize& viewSize)
1018 FrameView* view = m_page->mainFrame()->view();
1020 #if USE(TILED_BACKING_STORE)
1021 // If we are resizing to content ignore external attempts.
1022 if (view->useFixedLayout())
1026 if (m_viewSize == viewSize)
1029 view->resize(viewSize);
1030 view->setNeedsLayout();
1031 m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), viewSize));
1033 m_viewSize = viewSize;
1036 #if USE(TILED_BACKING_STORE)
1037 void WebPage::setFixedVisibleContentRect(const IntRect& rect)
1039 ASSERT(m_useFixedLayout);
1041 m_page->mainFrame()->view()->setFixedVisibleContentRect(rect);
1044 void WebPage::setResizesToContentsUsingLayoutSize(const IntSize& targetLayoutSize)
1046 ASSERT(m_useFixedLayout);
1047 ASSERT(!targetLayoutSize.isEmpty());
1049 FrameView* view = m_page->mainFrame()->view();
1051 view->setDelegatesScrolling(true);
1052 view->setUseFixedLayout(true);
1053 view->setPaintsEntireContents(true);
1055 if (view->fixedLayoutSize() == targetLayoutSize)
1058 m_page->settings()->setAcceleratedCompositingForFixedPositionEnabled(true);
1059 m_page->settings()->setFixedElementsLayoutRelativeToFrame(true);
1060 m_page->settings()->setFixedPositionCreatesStackingContext(true);
1062 // Always reset even when empty. This also takes care of the relayout.
1063 setFixedLayoutSize(targetLayoutSize);
1066 void WebPage::resizeToContentsIfNeeded()
1068 ASSERT(m_useFixedLayout);
1070 FrameView* view = m_page->mainFrame()->view();
1072 if (!view->useFixedLayout())
1075 IntSize newSize = view->contentsSize().expandedTo(view->fixedLayoutSize());
1077 if (newSize == m_viewSize)
1080 m_viewSize = newSize;
1081 view->resize(newSize);
1082 view->setNeedsLayout();
1085 void WebPage::sendViewportAttributesChanged()
1087 ASSERT(m_useFixedLayout);
1089 // Viewport properties have no impact on zero sized fixed viewports.
1090 if (m_viewportSize.isEmpty())
1093 // Recalculate the recommended layout size, when the available size (device pixel) changes.
1094 Settings* settings = m_page->settings();
1097 #if ENABLE(TIZEN_DLOG_SUPPORT)
1098 TIZEN_LOGI(" args type: [%d], scale: [%.1f, %.1f, %.1f], layout: [%.1f, %.1f], userScalable: [%.1f]"
1099 , static_cast<int>(m_page->viewportArguments().type), m_page->viewportArguments().initialScale
1100 , m_page->viewportArguments().minimumScale, m_page->viewportArguments().maximumScale
1101 , m_page->viewportArguments().width, m_page->viewportArguments().height, m_page->viewportArguments().userScalable);
1104 // As android and iphone does, we set layout width to 980 for desktop content
1105 int minimumLayoutFallbackWidth = settings->layoutFallbackWidth();
1107 int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_viewportSize.width());
1110 // If unset we use the viewport dimensions. This fits with the behavior of desktop browsers.
1111 int deviceWidth = (settings->deviceWidth() > 0) ? settings->deviceWidth() : m_viewportSize.width();
1112 int deviceHeight = (settings->deviceHeight() > 0) ? settings->deviceHeight() : m_viewportSize.height();
1114 ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, deviceWidth, deviceHeight, m_page->deviceScaleFactor(), m_viewportSize);
1115 WebCore::restrictMinimumScaleFactorToViewportSize(attr, m_viewportSize);
1116 WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr);
1118 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1119 // On WebProcess, JS runs before visible content rect is updated by UIProcess
1120 // In this case, JS returns incorrect inner size value because scale factor is not updated yet
1121 // So, we update fixed visible content rect at here.
1122 // FIXME: scale factor needs to be calculated and set fixed visible content rect
1124 // if constrainsScrollingToContentEdge is true, scroll position will be adjusted with contents size.
1125 // disable this to avoid adjust scroll position on setFixedVisibleContentRect() because contents size is not fixed yet.
1126 bool constrainsScrollingToContentEdge = mainFrameView()->constrainsScrollingToContentEdge();
1127 mainFrameView()->setConstrainsScrollingToContentEdge(false);
1129 FloatSize contentFixedSize = m_viewportSize;
1130 contentFixedSize.scale(1 / (attr.initialScale * attr.devicePixelRatio));
1131 mainFrameView()->setFixedVisibleContentRect(IntRect(mainFrameView()->scrollPosition(), roundedIntSize(contentFixedSize)));
1133 // If viewport meta tag is not defined or initial scale factor is not defined,
1134 // initial scale factor can be defined by "Default View" setting of UIProcess.
1135 // Therefore we set initialScale as ValueAuto as WebKit opensource does, to handle it with setting on UIProcess.
1136 // You can find this implementation on WebKit bug.
1137 // https://bugs.webkit.org/show_bug.cgi?id=102392
1138 if (m_page->viewportArguments().type == ViewportArguments::Implicit
1139 || m_page->viewportArguments().initialScale == ViewportArguments::ValueAuto)
1140 attr.initialScale = ViewportArguments::ValueAuto;
1143 setResizesToContentsUsingLayoutSize(IntSize(static_cast<int>(attr.layoutSize.width()), static_cast<int>(attr.layoutSize.height())));
1145 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
1146 // recover constrainsScrollingToContentEdge
1147 mainFrameView()->setConstrainsScrollingToContentEdge(constrainsScrollingToContentEdge);
1150 send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
1153 void WebPage::setViewportSize(const IntSize& size)
1155 ASSERT(m_useFixedLayout);
1157 if (m_viewportSize == size)
1160 #if ENABLE(TIZEN_DLOG_SUPPORT)
1161 TIZEN_LOGI(" viewportSize: [%d, %d]", size.width(), size.height());
1164 m_viewportSize = size;
1166 sendViewportAttributesChanged();
1171 void WebPage::scrollMainFrameIfNotAtMaxScrollPosition(const IntSize& scrollOffset)
1173 Frame* frame = m_page->mainFrame();
1175 IntPoint scrollPosition = frame->view()->scrollPosition();
1176 IntPoint maximumScrollPosition = frame->view()->maximumScrollPosition();
1178 // If the current scroll position in a direction is the max scroll position
1179 // we don't want to scroll at all.
1180 IntSize newScrollOffset;
1181 if (scrollPosition.x() < maximumScrollPosition.x())
1182 newScrollOffset.setWidth(scrollOffset.width());
1183 if (scrollPosition.y() < maximumScrollPosition.y())
1184 newScrollOffset.setHeight(scrollOffset.height());
1186 if (newScrollOffset.isZero())
1189 frame->view()->setScrollPosition(frame->view()->scrollPosition() + newScrollOffset);
1192 void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
1194 GraphicsContextStateSaver stateSaver(graphicsContext);
1195 graphicsContext.clip(rect);
1197 if (m_underlayPage) {
1198 m_underlayPage->drawRect(graphicsContext, rect);
1200 graphicsContext.beginTransparencyLayer(1);
1201 m_mainFrame->coreFrame()->view()->paint(&graphicsContext, rect);
1202 graphicsContext.endTransparencyLayer();
1206 m_mainFrame->coreFrame()->view()->paint(&graphicsContext, rect);
1209 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_TEXT_SELECTION_MODE)
1210 void WebPage::selectLink(WebCore::IntPoint positionForSelection, bool& result)
1213 Frame* frame = m_page->focusController()->focusedOrMainFrame();
1217 FrameView* frameView = frame->view();
1221 HitTestResult hitTestResult = frame->eventHandler()->hitTestResultAtPoint(frameView->windowToContents(positionForSelection), false);
1223 RefPtr<Range> range;
1224 Element* URLElement = hitTestResult.URLElement();
1226 for (Node* childNode = URLElement->firstChild(); childNode; childNode = childNode->traverseNextNode(URLElement)) {
1227 RenderObject* r = childNode->renderer();
1228 if (r && (r->isText() || r->isImage())) {
1230 range = VisibleSelection::selectionFromContentsOfNode(childNode).toNormalizedRange();
1231 else if (!hitTestResult.image()) {
1232 RefPtr<Range> extendedRange = VisibleSelection::selectionFromContentsOfNode(childNode).toNormalizedRange();
1233 range->setEnd(childNode, extendedRange->endOffset());
1238 range = VisibleSelection::selectionFromContentsOfNode(URLElement).toNormalizedRange();
1240 range = VisibleSelection::selectionFromContentsOfNode(hitTestResult.innerNonSharedNode()).toNormalizedRange();
1242 WebCore::FrameSelection* frameSelection = frame->selection();
1243 if (!frameSelection)
1246 EAffinity affinity = frameSelection->affinity();
1247 frameSelection->setSelectedRange(range.get(), affinity, true);
1249 if (frameSelection->isRange())
1256 #if ENABLE(TIZEN_ORIENTATION_EVENTS)
1257 void WebPage::sendOrientationChangeEvent(int newOrientation)
1259 Frame* frame = m_mainFrame->coreFrame();
1260 if (!frame || frame->orientation() == newOrientation)
1263 frame->sendOrientationChangeEvent(newOrientation);
1264 for (WebCore::Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
1265 child->sendOrientationChangeEvent(newOrientation);
1269 void WebPage::drawPageOverlay(GraphicsContext& graphicsContext, const IntRect& rect)
1271 ASSERT(m_pageOverlay);
1273 GraphicsContextStateSaver stateSaver(graphicsContext);
1274 graphicsContext.clip(rect);
1275 m_pageOverlay->drawRect(graphicsContext, rect);
1278 double WebPage::textZoomFactor() const
1280 Frame* frame = m_mainFrame->coreFrame();
1283 return frame->textZoomFactor();
1286 void WebPage::setTextZoomFactor(double zoomFactor)
1288 Frame* frame = m_mainFrame->coreFrame();
1291 frame->setTextZoomFactor(static_cast<float>(zoomFactor));
1294 double WebPage::pageZoomFactor() const
1296 Frame* frame = m_mainFrame->coreFrame();
1299 return frame->pageZoomFactor();
1302 void WebPage::setPageZoomFactor(double zoomFactor)
1304 Frame* frame = m_mainFrame->coreFrame();
1307 frame->setPageZoomFactor(static_cast<float>(zoomFactor));
1310 void WebPage::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
1312 Frame* frame = m_mainFrame->coreFrame();
1315 return frame->setPageAndTextZoomFactors(static_cast<float>(pageZoomFactor), static_cast<float>(textZoomFactor));
1318 void WebPage::windowScreenDidChange(uint64_t displayID)
1320 m_page->windowScreenDidChange(static_cast<PlatformDisplayID>(displayID));
1323 void WebPage::setViewMode(Page::ViewMode mode)
1325 m_page->setViewMode(mode);
1328 void WebPage::scalePage(double scale, const IntPoint& origin)
1330 m_page->setPageScaleFactor(scale, origin);
1332 for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
1333 (*it)->pageScaleFactorDidChange();
1335 send(Messages::WebPageProxy::PageScaleFactorDidChange(scale));
1338 double WebPage::pageScaleFactor() const
1340 return m_page->pageScaleFactor();
1343 void WebPage::setDeviceScaleFactor(float scaleFactor)
1345 if (scaleFactor == m_page->deviceScaleFactor())
1348 m_page->setDeviceScaleFactor(scaleFactor);
1350 // Tell all our plug-in views that the device scale factor changed.
1352 for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
1353 (*it)->setDeviceScaleFactor(scaleFactor);
1356 if (m_findController.isShowingOverlay()) {
1357 // We must have updated layout to get the selection rects right.
1359 m_findController.deviceScaleFactorDidChange();
1363 float WebPage::deviceScaleFactor() const
1365 return m_page->deviceScaleFactor();
1368 void WebPage::setUseFixedLayout(bool fixed)
1370 m_useFixedLayout = fixed;
1372 FrameView* view = mainFrameView();
1376 view->setUseFixedLayout(fixed);
1378 setFixedLayoutSize(IntSize());
1381 void WebPage::setFixedLayoutSize(const IntSize& size)
1383 FrameView* view = mainFrameView();
1384 if (!view || view->fixedLayoutSize() == size)
1387 view->setFixedLayoutSize(size);
1388 // Do not force it until the first layout, this would then become our first layout prematurely.
1389 if (view->didFirstLayout())
1390 view->forceLayout();
1393 void WebPage::setPaginationMode(uint32_t mode)
1395 Page::Pagination pagination = m_page->pagination();
1396 pagination.mode = static_cast<Page::Pagination::Mode>(mode);
1397 m_page->setPagination(pagination);
1400 void WebPage::setPaginationBehavesLikeColumns(bool behavesLikeColumns)
1402 Page::Pagination pagination = m_page->pagination();
1403 pagination.behavesLikeColumns = behavesLikeColumns;
1404 m_page->setPagination(pagination);
1407 void WebPage::setPageLength(double pageLength)
1409 Page::Pagination pagination = m_page->pagination();
1410 pagination.pageLength = pageLength;
1411 m_page->setPagination(pagination);
1414 void WebPage::setGapBetweenPages(double gap)
1416 Page::Pagination pagination = m_page->pagination();
1417 pagination.gap = gap;
1418 m_page->setPagination(pagination);
1421 void WebPage::installPageOverlay(PassRefPtr<PageOverlay> pageOverlay)
1423 bool shouldFadeIn = true;
1425 if (m_pageOverlay) {
1426 m_pageOverlay->setPage(0);
1429 // We're installing a page overlay when a page overlay is already active.
1430 // In this case we don't want to fade in the new overlay.
1431 shouldFadeIn = false;
1435 m_pageOverlay = pageOverlay;
1436 m_pageOverlay->setPage(this);
1439 m_pageOverlay->startFadeInAnimation();
1441 m_drawingArea->didInstallPageOverlay();
1443 send(Messages::WebPageProxy::DidInstallOrUninstallPageOverlay(true));
1446 m_pageOverlay->setNeedsDisplay();
1449 void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay, bool fadeOut)
1451 if (pageOverlay != m_pageOverlay)
1455 m_pageOverlay->startFadeOutAnimation();
1459 m_pageOverlay->setPage(0);
1460 m_pageOverlay = nullptr;
1462 m_drawingArea->didUninstallPageOverlay();
1464 send(Messages::WebPageProxy::DidInstallOrUninstallPageOverlay(false));
1468 #if PLATFORM(EFL) && OS(TIZEN)
1469 PassRefPtr<WebImage> WebPage::scaledSnapshotInViewCoordinates(const IntRect& rect, double scaleFactor, ImageOptions options)
1471 FrameView* frameView = m_mainFrame->coreFrame()->view();
1475 IntSize size(ceil(rect.width() * scaleFactor), ceil(rect.height() * scaleFactor));
1476 RefPtr<WebImage> snapshot = WebImage::create(size, options);
1477 if (!snapshot->bitmap())
1480 OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
1481 graphicsContext->scale(FloatSize(scaleFactor, scaleFactor));
1482 graphicsContext->translate(-rect.x(), -rect.y());
1484 frameView->updateLayoutAndStyleIfNeededRecursive();
1486 PaintBehavior oldBehavior = frameView->paintBehavior();
1487 frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
1488 frameView->paint(graphicsContext.get(), rect);
1489 frameView->setPaintBehavior(oldBehavior);
1491 return snapshot.release();
1494 PassRefPtr<WebImage> WebPage::snapshotInViewCoordinates(const IntRect& rect, ImageOptions options)
1496 return scaledSnapshotInViewCoordinates(rect, 1, options);
1499 PassRefPtr<WebImage> WebPage::snapshotInViewCoordinates(const IntRect& rect, ImageOptions options)
1501 FrameView* frameView = m_mainFrame->coreFrame()->view();
1505 IntSize bitmapSize = rect.size();
1506 float deviceScaleFactor = corePage()->deviceScaleFactor();
1507 bitmapSize.scale(deviceScaleFactor);
1509 RefPtr<WebImage> snapshot = WebImage::create(bitmapSize, options);
1510 if (!snapshot->bitmap())
1513 OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
1514 graphicsContext->applyDeviceScaleFactor(deviceScaleFactor);
1515 graphicsContext->translate(-rect.x(), -rect.y());
1517 frameView->updateLayoutAndStyleIfNeededRecursive();
1519 PaintBehavior oldBehavior = frameView->paintBehavior();
1520 frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
1521 frameView->paint(graphicsContext.get(), rect);
1522 frameView->setPaintBehavior(oldBehavior);
1524 return snapshot.release();
1528 PassRefPtr<WebImage> WebPage::scaledSnapshotInDocumentCoordinates(const IntRect& rect, double scaleFactor, ImageOptions options)
1530 FrameView* frameView = m_mainFrame->coreFrame()->view();
1534 float combinedScaleFactor = scaleFactor * corePage()->deviceScaleFactor();
1535 IntSize size(ceil(rect.width() * combinedScaleFactor), ceil(rect.height() * combinedScaleFactor));
1536 RefPtr<WebImage> snapshot = WebImage::create(size, options);
1537 if (!snapshot->bitmap())
1540 OwnPtr<WebCore::GraphicsContext> graphicsContext = snapshot->bitmap()->createGraphicsContext();
1541 graphicsContext->applyDeviceScaleFactor(combinedScaleFactor);
1542 graphicsContext->translate(-rect.x(), -rect.y());
1544 frameView->updateLayoutAndStyleIfNeededRecursive();
1546 PaintBehavior oldBehavior = frameView->paintBehavior();
1547 frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
1548 frameView->paintContents(graphicsContext.get(), rect);
1549 frameView->setPaintBehavior(oldBehavior);
1551 return snapshot.release();
1554 PassRefPtr<WebImage> WebPage::snapshotInDocumentCoordinates(const IntRect& rect, ImageOptions options)
1556 return scaledSnapshotInDocumentCoordinates(rect, 1, options);
1559 void WebPage::pageDidScroll()
1561 m_uiClient.pageDidScroll(this);
1563 send(Messages::WebPageProxy::PageDidScroll());
1566 #if USE(TILED_BACKING_STORE)
1567 void WebPage::pageDidRequestScroll(const IntPoint& point)
1569 #if ENABLE(TIZEN_DLOG_SUPPORT)
1570 TIZEN_LOGI(" scroll position: [%d, %d]", point.x(), point.y());
1572 send(Messages::WebPageProxy::PageDidRequestScroll(point));
1576 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
1577 void WebPage::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
1579 #if ENABLE(TIZEN_DLOG_SUPPORT)
1580 TIZEN_LOGI(" scale factor: [%.2f], scroll position: [%d, %d]", scale, point.x(), point.y());
1582 send(Messages::WebPageProxy::pageDidRequestRestoreVisibleContentRect(point, scale));
1586 #if ENABLE(CONTEXT_MENUS)
1587 WebContextMenu* WebPage::contextMenu()
1590 m_contextMenu = WebContextMenu::create(this);
1591 return m_contextMenu.get();
1597 static const WebEvent* g_currentEvent = 0;
1599 // FIXME: WebPage::currentEvent is used by the plug-in code to avoid having to convert from DOM events back to
1600 // WebEvents. When we get the event handling sorted out, this should go away and the Widgets should get the correct
1601 // platform events passed to the event handler code.
1602 const WebEvent* WebPage::currentEvent()
1604 return g_currentEvent;
1607 class CurrentEvent {
1609 explicit CurrentEvent(const WebEvent& event)
1610 : m_previousCurrentEvent(g_currentEvent)
1612 g_currentEvent = &event;
1617 g_currentEvent = m_previousCurrentEvent;
1621 const WebEvent* m_previousCurrentEvent;
1624 #if ENABLE(CONTEXT_MENUS)
1625 static bool isContextClick(const PlatformMouseEvent& event)
1627 if (event.button() == WebCore::RightButton)
1631 // FIXME: this really should be about OSX-style UI, not about the Mac port
1632 if (event.button() == WebCore::LeftButton && event.ctrlKey())
1639 static bool handleContextMenuEvent(const PlatformMouseEvent& platformMouseEvent, WebPage* page)
1641 IntPoint point = page->corePage()->mainFrame()->view()->windowToContents(platformMouseEvent.position());
1642 HitTestResult result = page->corePage()->mainFrame()->eventHandler()->hitTestResultAtPoint(point, false);
1644 Frame* frame = page->corePage()->mainFrame();
1645 #if !ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
1646 if (result.innerNonSharedNode())
1647 frame = result.innerNonSharedNode()->document()->frame();
1650 bool handled = frame->eventHandler()->sendContextMenuEvent(platformMouseEvent);
1652 page->contextMenu()->show();
1654 #if ENABLE(TIZEN_DRAG_SUPPORT)
1655 if(result.isDragSupport()) {
1656 if (result.innerNonSharedNode())
1657 frame = result.innerNonSharedNode()->document()->frame();
1659 PlatformMouseEvent event(frame->view()->windowToContents(platformMouseEvent.position()), platformMouseEvent.globalPosition(), LeftButton, PlatformEvent::MousePressed, 1, false, false, false, false, currentTime());
1660 frame->page()->dragController()->setPosition(event);
1668 static bool handleMouseEvent(const WebMouseEvent& mouseEvent, WebPage* page, bool onlyUpdateScrollbars)
1670 Frame* frame = page->corePage()->mainFrame();
1674 PlatformMouseEvent platformMouseEvent = platform(mouseEvent);
1676 switch (platformMouseEvent.type()) {
1677 case PlatformEvent::MousePressed: {
1678 #if ENABLE(CONTEXT_MENUS)
1679 if (isContextClick(platformMouseEvent))
1680 page->corePage()->contextMenuController()->clearContextMenu();
1683 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
1685 if (!isContextClick(platformMouseEvent))
1686 handled = frame->eventHandler()->handleMousePressEvent(platformMouseEvent);
1688 bool handled = frame->eventHandler()->handleMousePressEvent(platformMouseEvent);
1690 #if ENABLE(CONTEXT_MENUS)
1691 if (isContextClick(platformMouseEvent))
1692 handled = handleContextMenuEvent(platformMouseEvent, page);
1695 bool gtkMouseButtonPressHandled = page->handleMousePressedEvent(platformMouseEvent);
1696 handled = handled || gtkMouseButtonPressHandled;
1701 case PlatformEvent::MouseReleased:
1702 return frame->eventHandler()->handleMouseReleaseEvent(platformMouseEvent);
1703 case PlatformEvent::MouseMoved:
1704 if (onlyUpdateScrollbars)
1705 return frame->eventHandler()->passMouseMovedEventToScrollbars(platformMouseEvent);
1706 return frame->eventHandler()->mouseMoved(platformMouseEvent);
1708 ASSERT_NOT_REACHED();
1713 void WebPage::mouseEvent(const WebMouseEvent& mouseEvent)
1715 #if ENABLE(CONTEXT_MENUS)
1716 // Don't try to handle any pending mouse events if a context menu is showing.
1717 if (m_isShowingContextMenu) {
1718 send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(mouseEvent.type()), false));
1723 bool handled = false;
1725 if (m_pageOverlay) {
1726 // Let the page overlay handle the event.
1727 handled = m_pageOverlay->mouseEvent(mouseEvent);
1731 CurrentEvent currentEvent(mouseEvent);
1733 // We need to do a full, normal hit test during this mouse event if the page is active or if a mouse
1734 // button is currently pressed. It is possible that neither of those things will be true since on
1735 // Lion when legacy scrollbars are enabled, WebKit receives mouse events all the time. If it is one
1736 // of those cases where the page is not active and the mouse is not pressed, then we can fire a more
1737 // efficient scrollbars-only version of the event.
1738 bool onlyUpdateScrollbars = !(m_page->focusController()->isActive() || (mouseEvent.button() != WebMouseEvent::NoButton));
1739 handled = handleMouseEvent(mouseEvent, this, onlyUpdateScrollbars);
1742 send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(mouseEvent.type()), handled));
1745 void WebPage::mouseEventSyncForTesting(const WebMouseEvent& mouseEvent, bool& handled)
1747 handled = m_pageOverlay && m_pageOverlay->mouseEvent(mouseEvent);
1750 CurrentEvent currentEvent(mouseEvent);
1752 // We need to do a full, normal hit test during this mouse event if the page is active or if a mouse
1753 // button is currently pressed. It is possible that neither of those things will be true since on
1754 // Lion when legacy scrollbars are enabled, WebKit receives mouse events all the time. If it is one
1755 // of those cases where the page is not active and the mouse is not pressed, then we can fire a more
1756 // efficient scrollbars-only version of the event.
1757 bool onlyUpdateScrollbars = !(m_page->focusController()->isActive() || (mouseEvent.button() != WebMouseEvent::NoButton));
1758 handled = handleMouseEvent(mouseEvent, this, onlyUpdateScrollbars);
1762 static bool handleWheelEvent(const WebWheelEvent& wheelEvent, Page* page)
1764 Frame* frame = page->mainFrame();
1768 PlatformWheelEvent platformWheelEvent = platform(wheelEvent);
1769 return frame->eventHandler()->handleWheelEvent(platformWheelEvent);
1772 void WebPage::wheelEvent(const WebWheelEvent& wheelEvent)
1774 CurrentEvent currentEvent(wheelEvent);
1776 bool handled = handleWheelEvent(wheelEvent, m_page.get());
1777 send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(wheelEvent.type()), handled));
1780 void WebPage::wheelEventSyncForTesting(const WebWheelEvent& wheelEvent, bool& handled)
1782 CurrentEvent currentEvent(wheelEvent);
1784 handled = handleWheelEvent(wheelEvent, m_page.get());
1787 static bool handleKeyEvent(const WebKeyboardEvent& keyboardEvent, Page* page)
1789 if (!page->mainFrame()->view())
1792 if (keyboardEvent.type() == WebEvent::Char && keyboardEvent.isSystemKey())
1793 return page->focusController()->focusedOrMainFrame()->eventHandler()->handleAccessKey(platform(keyboardEvent));
1794 return page->focusController()->focusedOrMainFrame()->eventHandler()->keyEvent(platform(keyboardEvent));
1797 #if ENABLE(TIZEN_ISF_PORT)
1798 void WebPage::keyEvent(const NativeWebKeyboardEvent& keyboardEvent)
1800 void WebPage::keyEvent(const WebKeyboardEvent& keyboardEvent)
1803 CurrentEvent currentEvent(keyboardEvent);
1805 #if ENABLE(TIZEN_ISF_PORT)
1806 m_prepareKeyDownEvent = false;
1809 bool handled = handleKeyEvent(keyboardEvent, m_page.get());
1810 // FIXME: Platform default behaviors should be performed during normal DOM event dispatch (in most cases, in default keydown event handler).
1812 handled = performDefaultBehaviorForKeyEvent(keyboardEvent);
1814 send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(keyboardEvent.type()), handled));
1817 void WebPage::keyEventSyncForTesting(const WebKeyboardEvent& keyboardEvent, bool& handled)
1819 CurrentEvent currentEvent(keyboardEvent);
1821 handled = handleKeyEvent(keyboardEvent, m_page.get());
1823 handled = performDefaultBehaviorForKeyEvent(keyboardEvent);
1826 #if ENABLE(GESTURE_EVENTS)
1827 static bool handleGestureEvent(const WebGestureEvent& gestureEvent, Page* page)
1829 Frame* frame = page->mainFrame();
1833 PlatformGestureEvent platformGestureEvent = platform(gestureEvent);
1834 return frame->eventHandler()->handleGestureEvent(platformGestureEvent);
1837 void WebPage::gestureEvent(const WebGestureEvent& gestureEvent)
1839 CurrentEvent currentEvent(gestureEvent);
1841 bool handled = handleGestureEvent(gestureEvent, m_page.get());
1842 send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(gestureEvent.type()), handled));
1846 void WebPage::validateCommand(const String& commandName, uint64_t callbackID)
1848 bool isEnabled = false;
1850 Frame* frame = m_page->focusController()->focusedOrMainFrame();
1852 Editor::Command command = frame->editor()->command(commandName);
1853 state = command.state();
1854 isEnabled = command.isSupported() && command.isEnabled();
1857 send(Messages::WebPageProxy::ValidateCommandCallback(commandName, isEnabled, state, callbackID));
1860 void WebPage::executeEditCommand(const String& commandName)
1862 executeEditingCommand(commandName, String());
1865 uint64_t WebPage::restoreSession(const SessionState& sessionState)
1867 const BackForwardListItemVector& list = sessionState.list();
1868 size_t size = list.size();
1869 uint64_t currentItemID = 0;
1870 for (size_t i = 0; i < size; ++i) {
1871 WebBackForwardListItem* webItem = list[i].get();
1872 DecoderAdapter decoder(webItem->backForwardData().data(), webItem->backForwardData().size());
1874 RefPtr<HistoryItem> item = HistoryItem::decodeBackForwardTree(webItem->url(), webItem->title(), webItem->originalURL(), decoder);
1876 LOG_ERROR("Failed to decode a HistoryItem from session state data.");
1880 if (i == sessionState.currentIndex())
1881 currentItemID = webItem->itemID();
1883 WebBackForwardListProxy::addItemFromUIProcess(list[i]->itemID(), item.release());
1885 ASSERT(currentItemID);
1886 return currentItemID;
1889 void WebPage::restoreSessionAndNavigateToCurrentItem(const SessionState& sessionState)
1891 if (uint64_t currentItemID = restoreSession(sessionState))
1892 goToBackForwardItem(currentItemID);
1895 #if ENABLE(TOUCH_EVENTS)
1897 void WebPage::highlightPotentialActivation(const IntPoint& point, const IntSize& area)
1899 if (point == IntPoint::zero()) {
1900 // An empty point deactivates the highlighting.
1901 tapHighlightController().hideHighlight();
1903 Frame* mainframe = m_page->mainFrame();
1904 Node* activationNode = 0;
1905 Node* adjustedNode = 0;
1906 IntPoint adjustedPoint;
1908 #if ENABLE(TOUCH_ADJUSTMENT)
1909 if (!mainframe->eventHandler()->bestClickableNodeForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), adjustedPoint, adjustedNode))
1913 HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), /*allowShadowContent*/ false, /*ignoreClipping*/ true);
1914 adjustedNode = result.innerNode();
1916 // Find the node to highlight. This is not the same as the node responding the tap gesture, because many
1917 // pages has a global click handler and we do not want to highlight the body.
1918 // Instead find the enclosing link or focusable element, or the last enclosing inline element.
1919 for (Node* node = adjustedNode; node; node = node->parentOrHostNode()) {
1920 if (node->isMouseFocusable() || node->isLink()) {
1921 activationNode = node;
1924 if (node->renderer() && node->renderer()->isInline())
1925 activationNode = node;
1926 else if (activationNode)
1931 tapHighlightController().highlight(activationNode);
1936 static bool handleTouchEvent(const WebTouchEvent& touchEvent, Page* page)
1938 Frame* frame = page->mainFrame();
1942 return frame->eventHandler()->handleTouchEvent(platform(touchEvent));
1945 void WebPage::touchEvent(const WebTouchEvent& touchEvent)
1947 CurrentEvent currentEvent(touchEvent);
1949 bool handled = handleTouchEvent(touchEvent, m_page.get());
1951 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1952 static bool checkOverflow = false;
1953 if (touchEvent.type() == WebEvent::TouchStart && touchEvent.touchPoints().size() == 1) {
1954 checkOverflow = true;
1955 } else if (checkOverflow && touchEvent.type() == WebEvent::TouchMove && touchEvent.touchPoints().size() == 1) {
1956 bool pressed = false;
1958 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1959 setPressedNodeAtPoint(touchEvent.touchPoints()[0].position(), true, pressed, id);
1961 setPressedNodeAtPoint(touchEvent.touchPoints()[0].position(), false, pressed, id);
1963 send(Messages::WebPageProxy::SetOverflowResult(pressed, id));
1964 checkOverflow = false;
1967 send(Messages::WebPageProxy::DidReceiveEvent(static_cast<uint32_t>(touchEvent.type()), handled));
1970 void WebPage::touchEventSyncForTesting(const WebTouchEvent& touchEvent, bool& handled)
1972 CurrentEvent currentEvent(touchEvent);
1973 handled = handleTouchEvent(touchEvent, m_page.get());
1977 void WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
1979 page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
1982 void WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
1984 page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
1987 void WebPage::scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
1989 scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity));
1992 void WebPage::centerSelectionInVisibleArea()
1994 Frame* frame = m_page->focusController()->focusedOrMainFrame();
1998 frame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
1999 m_findController.showFindIndicatorInSelection();
2002 void WebPage::setActive(bool isActive)
2004 m_page->focusController()->setActive(isActive);
2007 // Tell all our plug-in views that the window focus changed.
2008 for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
2009 (*it)->setWindowIsFocused(isActive);
2013 void WebPage::setDrawsBackground(bool drawsBackground)
2015 if (m_drawsBackground == drawsBackground)
2018 m_drawsBackground = drawsBackground;
2020 for (Frame* coreFrame = m_mainFrame->coreFrame(); coreFrame; coreFrame = coreFrame->tree()->traverseNext()) {
2021 if (FrameView* view = coreFrame->view())
2022 view->setTransparent(!drawsBackground);
2025 m_drawingArea->pageBackgroundTransparencyChanged();
2026 m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize));
2029 void WebPage::setDrawsTransparentBackground(bool drawsTransparentBackground)
2031 if (m_drawsTransparentBackground == drawsTransparentBackground)
2034 m_drawsTransparentBackground = drawsTransparentBackground;
2036 Color backgroundColor = drawsTransparentBackground ? Color::transparent : Color::white;
2037 for (Frame* coreFrame = m_mainFrame->coreFrame(); coreFrame; coreFrame = coreFrame->tree()->traverseNext()) {
2038 if (FrameView* view = coreFrame->view())
2039 view->setBaseBackgroundColor(backgroundColor);
2042 m_drawingArea->pageBackgroundTransparencyChanged();
2043 m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize));
2046 void WebPage::viewWillStartLiveResize()
2051 // FIXME: This should propagate to all ScrollableAreas.
2052 if (Frame* frame = m_page->focusController()->focusedOrMainFrame()) {
2053 if (FrameView* view = frame->view())
2054 view->willStartLiveResize();
2058 void WebPage::viewWillEndLiveResize()
2063 // FIXME: This should propagate to all ScrollableAreas.
2064 if (Frame* frame = m_page->focusController()->focusedOrMainFrame()) {
2065 if (FrameView* view = frame->view())
2066 view->willEndLiveResize();
2070 void WebPage::setFocused(bool isFocused)
2072 m_page->focusController()->setFocused(isFocused);
2075 void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event)
2077 if (!m_page || !m_page->focusController())
2080 Frame* frame = m_page->focusController()->focusedOrMainFrame();
2081 frame->document()->setFocusedNode(0);
2083 if (isKeyboardEventValid && event.type() == WebEvent::KeyDown) {
2084 PlatformKeyboardEvent platformEvent(platform(event));
2085 platformEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
2086 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, KeyboardEvent::create(platformEvent, frame->document()->defaultView()).get());
2090 m_page->focusController()->setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, 0);
2093 void WebPage::setWindowResizerSize(const IntSize& windowResizerSize)
2095 if (m_windowResizerSize == windowResizerSize)
2098 m_windowResizerSize = windowResizerSize;
2100 for (Frame* coreFrame = m_mainFrame->coreFrame(); coreFrame; coreFrame = coreFrame->tree()->traverseNext()) {
2101 FrameView* view = coreFrame->view();
2103 view->windowResizerRectChanged();
2107 void WebPage::setCanStartMediaTimerFired()
2110 m_page->setCanStartMedia(true);
2113 void WebPage::setIsInWindow(bool isInWindow)
2116 m_setCanStartMediaTimer.stop();
2117 m_page->setCanStartMedia(false);
2118 m_page->willMoveOffscreen();
2120 // Defer the call to Page::setCanStartMedia() since it ends up sending a syncrhonous messages to the UI process
2121 // in order to get plug-in connections, and the UI process will be waiting for the Web process to update the backing
2122 // store after moving the view into a window, until it times out and paints white. See <rdar://problem/9242771>.
2123 m_setCanStartMediaTimer.startOneShot(0);
2124 m_page->didMoveOnscreen();
2128 void WebPage::didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID)
2130 WebFrame* frame = WebProcess::shared().webFrame(frameID);
2133 frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID);
2136 void WebPage::show()
2138 send(Messages::WebPageProxy::ShowPage());
2141 void WebPage::setUserAgent(const String& userAgent)
2143 m_userAgent = userAgent;
2145 #if ENABLE(TIZEN_CUSTOM_HEADERS)
2146 void WebPage::addCustomHeader(const String& name, const String& value)
2148 m_customHeaders.add(name, value);
2151 void WebPage::removeCustomHeader(const String& name)
2153 m_customHeaders.remove(name);
2156 void WebPage::clearCustomHeaders()
2158 m_customHeaders.clear();
2161 WebCore::HTTPHeaderMap WebPage::customHeaders()
2163 return m_customHeaders;
2167 void WebPage::suspendActiveDOMObjectsAndAnimations()
2169 m_page->suspendActiveDOMObjectsAndAnimations();
2172 void WebPage::resumeActiveDOMObjectsAndAnimations()
2174 m_page->resumeActiveDOMObjectsAndAnimations();
2176 // We need to repaint on resume to kickstart animated painting again.
2177 m_drawingArea->setNeedsDisplay(IntRect(IntPoint(0, 0), m_viewSize));
2180 IntPoint WebPage::screenToWindow(const IntPoint& point)
2182 IntPoint windowPoint;
2183 sendSync(Messages::WebPageProxy::ScreenToWindow(point), Messages::WebPageProxy::ScreenToWindow::Reply(windowPoint));
2187 IntRect WebPage::windowToScreen(const IntRect& rect)
2190 sendSync(Messages::WebPageProxy::WindowToScreen(rect), Messages::WebPageProxy::WindowToScreen::Reply(screenRect));
2194 IntRect WebPage::windowResizerRect() const
2196 if (m_windowResizerSize.isEmpty())
2199 IntSize frameViewSize;
2200 if (Frame* coreFrame = m_mainFrame->coreFrame()) {
2201 if (FrameView* view = coreFrame->view())
2202 frameViewSize = view->size();
2205 return IntRect(frameViewSize.width() - m_windowResizerSize.width(), frameViewSize.height() - m_windowResizerSize.height(),
2206 m_windowResizerSize.width(), m_windowResizerSize.height());
2209 KeyboardUIMode WebPage::keyboardUIMode()
2211 bool fullKeyboardAccessEnabled = WebProcess::shared().fullKeyboardAccessEnabled();
2212 return static_cast<KeyboardUIMode>((fullKeyboardAccessEnabled ? KeyboardAccessFull : KeyboardAccessDefault) | (m_tabToLinks ? KeyboardAccessTabsToLinks : 0));
2215 void WebPage::runJavaScriptInMainFrame(const String& script, uint64_t callbackID)
2217 // NOTE: We need to be careful when running scripts that the objects we depend on don't
2218 // disappear during script execution.
2220 // Retain the SerializedScriptValue at this level so it (and the internal data) lives
2221 // long enough for the DataReference to be encoded by the sent message.
2222 RefPtr<SerializedScriptValue> serializedResultValue;
2223 CoreIPC::DataReference dataReference;
2225 JSLockHolder lock(JSDOMWindow::commonJSGlobalData());
2226 if (JSValue resultValue = m_mainFrame->coreFrame()->script()->executeScript(script, true).jsValue()) {
2227 if ((serializedResultValue = SerializedScriptValue::create(m_mainFrame->jsContext(), toRef(m_mainFrame->coreFrame()->script()->globalObject(mainThreadNormalWorld())->globalExec(), resultValue), 0)))
2228 dataReference = serializedResultValue->data();
2231 send(Messages::WebPageProxy::ScriptValueCallback(dataReference, callbackID));
2234 void WebPage::getContentsAsString(uint64_t callbackID)
2236 String resultString = m_mainFrame->contentsAsString();
2237 send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
2241 void WebPage::getContentsAsMHTMLData(uint64_t callbackID, bool useBinaryEncoding)
2243 CoreIPC::DataReference dataReference;
2245 RefPtr<SharedBuffer> buffer = useBinaryEncoding
2246 ? MHTMLArchive::generateMHTMLDataUsingBinaryEncoding(m_page.get())
2247 : MHTMLArchive::generateMHTMLData(m_page.get());
2250 dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
2252 send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
2256 void WebPage::getRenderTreeExternalRepresentation(uint64_t callbackID)
2258 String resultString = renderTreeExternalRepresentation();
2259 send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
2262 void WebPage::getSelectionOrContentsAsString(uint64_t callbackID)
2264 String resultString = m_mainFrame->selectionAsString();
2265 if (resultString.isEmpty())
2266 resultString = m_mainFrame->contentsAsString();
2267 send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
2270 void WebPage::getSourceForFrame(uint64_t frameID, uint64_t callbackID)
2272 String resultString;
2273 if (WebFrame* frame = WebProcess::shared().webFrame(frameID))
2274 resultString = frame->source();
2276 send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
2279 void WebPage::getMainResourceDataOfFrame(uint64_t frameID, uint64_t callbackID)
2281 CoreIPC::DataReference dataReference;
2283 RefPtr<SharedBuffer> buffer;
2284 if (WebFrame* frame = WebProcess::shared().webFrame(frameID)) {
2285 if (DocumentLoader* loader = frame->coreFrame()->loader()->documentLoader()) {
2286 if ((buffer = loader->mainResourceData()))
2287 dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
2291 send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
2294 static PassRefPtr<SharedBuffer> resourceDataForFrame(Frame* frame, const KURL& resourceURL)
2296 DocumentLoader* loader = frame->loader()->documentLoader();
2300 RefPtr<ArchiveResource> subresource = loader->subresource(resourceURL);
2304 return subresource->data();
2307 void WebPage::getResourceDataFromFrame(uint64_t frameID, const String& resourceURLString, uint64_t callbackID)
2309 CoreIPC::DataReference dataReference;
2310 KURL resourceURL(KURL(), resourceURLString);
2312 RefPtr<SharedBuffer> buffer;
2313 if (WebFrame* frame = WebProcess::shared().webFrame(frameID)) {
2314 buffer = resourceDataForFrame(frame->coreFrame(), resourceURL);
2316 // Try to get the resource data from the cache.
2317 buffer = cachedResponseDataForURL(resourceURL);
2321 dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
2324 send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
2327 void WebPage::getWebArchiveOfFrame(uint64_t frameID, uint64_t callbackID)
2329 CoreIPC::DataReference dataReference;
2331 #if PLATFORM(MAC) || PLATFORM(WIN)
2332 RetainPtr<CFDataRef> data;
2333 if (WebFrame* frame = WebProcess::shared().webFrame(frameID)) {
2334 if ((data = frame->webArchiveData(0, 0)))
2335 dataReference = CoreIPC::DataReference(CFDataGetBytePtr(data.get()), CFDataGetLength(data.get()));
2339 send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
2342 void WebPage::forceRepaintWithoutCallback()
2344 m_drawingArea->forceRepaint();
2347 void WebPage::forceRepaint(uint64_t callbackID)
2349 if (m_drawingArea->forceRepaintAsync(callbackID))
2352 forceRepaintWithoutCallback();
2353 send(Messages::WebPageProxy::VoidCallback(callbackID));
2356 #if ENABLE(WEB_INTENTS)
2357 void WebPage::deliverIntentToFrame(uint64_t frameID, const IntentData& intentData)
2359 WebFrame* frame = WebProcess::shared().webFrame(frameID);
2363 frame->deliverIntent(intentData);
2367 void WebPage::preferencesDidChange(const WebPreferencesStore& store)
2369 WebPreferencesStore::removeTestRunnerOverrides();
2370 updatePreferences(store);
2373 void WebPage::updatePreferences(const WebPreferencesStore& store)
2375 Settings* settings = m_page->settings();
2377 m_tabToLinks = store.getBoolValueForKey(WebPreferencesKey::tabsToLinksKey());
2379 // FIXME: This should be generated from macro expansion for all preferences,
2380 // but we currently don't match the naming of WebCore exactly so we are
2381 // handrolling the boolean and integer preferences until that is fixed.
2383 #define INITIALIZE_SETTINGS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) settings->set##KeyUpper(store.get##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key()));
2385 FOR_EACH_WEBKIT_STRING_PREFERENCE(INITIALIZE_SETTINGS)
2387 #undef INITIALIZE_SETTINGS
2389 settings->setScriptEnabled(store.getBoolValueForKey(WebPreferencesKey::javaScriptEnabledKey()));
2390 settings->setLoadsImagesAutomatically(store.getBoolValueForKey(WebPreferencesKey::loadsImagesAutomaticallyKey()));
2391 settings->setLoadsSiteIconsIgnoringImageLoadingSetting(store.getBoolValueForKey(WebPreferencesKey::loadsSiteIconsIgnoringImageLoadingPreferenceKey()));
2392 settings->setPluginsEnabled(store.getBoolValueForKey(WebPreferencesKey::pluginsEnabledKey()));
2393 settings->setJavaEnabled(store.getBoolValueForKey(WebPreferencesKey::javaEnabledKey()));
2394 settings->setJavaEnabledForLocalFiles(store.getBoolValueForKey(WebPreferencesKey::javaEnabledForLocalFilesKey()));
2395 settings->setOfflineWebApplicationCacheEnabled(store.getBoolValueForKey(WebPreferencesKey::offlineWebApplicationCacheEnabledKey()));
2396 settings->setLocalStorageEnabled(store.getBoolValueForKey(WebPreferencesKey::localStorageEnabledKey()));
2397 settings->setXSSAuditorEnabled(store.getBoolValueForKey(WebPreferencesKey::xssAuditorEnabledKey()));
2398 settings->setFrameFlatteningEnabled(store.getBoolValueForKey(WebPreferencesKey::frameFlatteningEnabledKey()));
2399 settings->setPrivateBrowsingEnabled(store.getBoolValueForKey(WebPreferencesKey::privateBrowsingEnabledKey()));
2400 settings->setDeveloperExtrasEnabled(store.getBoolValueForKey(WebPreferencesKey::developerExtrasEnabledKey()));
2401 settings->setJavaScriptExperimentsEnabled(store.getBoolValueForKey(WebPreferencesKey::javaScriptExperimentsEnabledKey()));
2402 settings->setTextAreasAreResizable(store.getBoolValueForKey(WebPreferencesKey::textAreasAreResizableKey()));
2403 settings->setNeedsSiteSpecificQuirks(store.getBoolValueForKey(WebPreferencesKey::needsSiteSpecificQuirksKey()));
2404 settings->setJavaScriptCanOpenWindowsAutomatically(store.getBoolValueForKey(WebPreferencesKey::javaScriptCanOpenWindowsAutomaticallyKey()));
2405 settings->setForceFTPDirectoryListings(store.getBoolValueForKey(WebPreferencesKey::forceFTPDirectoryListingsKey()));
2406 settings->setDNSPrefetchingEnabled(store.getBoolValueForKey(WebPreferencesKey::dnsPrefetchingEnabledKey()));
2407 #if ENABLE(WEB_ARCHIVE)
2408 settings->setWebArchiveDebugModeEnabled(store.getBoolValueForKey(WebPreferencesKey::webArchiveDebugModeEnabledKey()));
2410 settings->setLocalFileContentSniffingEnabled(store.getBoolValueForKey(WebPreferencesKey::localFileContentSniffingEnabledKey()));
2411 settings->setUsesPageCache(store.getBoolValueForKey(WebPreferencesKey::usesPageCacheKey()));
2412 settings->setPageCacheSupportsPlugins(store.getBoolValueForKey(WebPreferencesKey::pageCacheSupportsPluginsKey()));
2413 settings->setAuthorAndUserStylesEnabled(store.getBoolValueForKey(WebPreferencesKey::authorAndUserStylesEnabledKey()));
2414 settings->setPaginateDuringLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::paginateDuringLayoutEnabledKey()));
2415 settings->setDOMPasteAllowed(store.getBoolValueForKey(WebPreferencesKey::domPasteAllowedKey()));
2416 settings->setJavaScriptCanAccessClipboard(store.getBoolValueForKey(WebPreferencesKey::javaScriptCanAccessClipboardKey()));
2417 settings->setShouldPrintBackgrounds(store.getBoolValueForKey(WebPreferencesKey::shouldPrintBackgroundsKey()));
2418 settings->setWebSecurityEnabled(store.getBoolValueForKey(WebPreferencesKey::webSecurityEnabledKey()));
2419 settings->setAllowUniversalAccessFromFileURLs(store.getBoolValueForKey(WebPreferencesKey::allowUniversalAccessFromFileURLsKey()));
2420 settings->setAllowFileAccessFromFileURLs(store.getBoolValueForKey(WebPreferencesKey::allowFileAccessFromFileURLsKey()));
2422 settings->setMinimumFontSize(store.getUInt32ValueForKey(WebPreferencesKey::minimumFontSizeKey()));
2423 settings->setMinimumLogicalFontSize(store.getUInt32ValueForKey(WebPreferencesKey::minimumLogicalFontSizeKey()));
2424 settings->setDefaultFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFontSizeKey()));
2425 settings->setDefaultFixedFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFixedFontSizeKey()));
2426 settings->setLayoutFallbackWidth(store.getUInt32ValueForKey(WebPreferencesKey::layoutFallbackWidthKey()));
2427 settings->setDeviceWidth(store.getUInt32ValueForKey(WebPreferencesKey::deviceWidthKey()));
2428 settings->setDeviceHeight(store.getUInt32ValueForKey(WebPreferencesKey::deviceHeightKey()));
2429 settings->setEditableLinkBehavior(static_cast<WebCore::EditableLinkBehavior>(store.getUInt32ValueForKey(WebPreferencesKey::editableLinkBehaviorKey())));
2430 settings->setShowsToolTipOverTruncatedText(store.getBoolValueForKey(WebPreferencesKey::showsToolTipOverTruncatedTextKey()));
2432 settings->setAcceleratedCompositingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedCompositingEnabledKey()) && LayerTreeHost::supportsAcceleratedCompositing());
2433 settings->setAcceleratedDrawingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedDrawingEnabledKey()) && LayerTreeHost::supportsAcceleratedCompositing());
2434 settings->setCanvasUsesAcceleratedDrawing(store.getBoolValueForKey(WebPreferencesKey::canvasUsesAcceleratedDrawingKey()) && LayerTreeHost::supportsAcceleratedCompositing());
2435 settings->setShowDebugBorders(store.getBoolValueForKey(WebPreferencesKey::compositingBordersVisibleKey()));
2436 settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey()));
2437 settings->setCSSCustomFilterEnabled(store.getBoolValueForKey(WebPreferencesKey::cssCustomFilterEnabledKey()));
2438 settings->setCSSRegionsEnabled(store.getBoolValueForKey(WebPreferencesKey::cssRegionsEnabledKey()));
2439 settings->setCSSGridLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::cssGridLayoutEnabledKey()));
2440 settings->setRegionBasedColumnsEnabled(store.getBoolValueForKey(WebPreferencesKey::regionBasedColumnsEnabledKey()));
2441 settings->setWebGLEnabled(store.getBoolValueForKey(WebPreferencesKey::webGLEnabledKey()));
2442 settings->setMediaPlaybackRequiresUserGesture(store.getBoolValueForKey(WebPreferencesKey::mediaPlaybackRequiresUserGestureKey()));
2443 settings->setMediaPlaybackAllowsInline(store.getBoolValueForKey(WebPreferencesKey::mediaPlaybackAllowsInlineKey()));
2444 settings->setMockScrollbarsEnabled(store.getBoolValueForKey(WebPreferencesKey::mockScrollbarsEnabledKey()));
2445 settings->setHyperlinkAuditingEnabled(store.getBoolValueForKey(WebPreferencesKey::hyperlinkAuditingEnabledKey()));
2446 settings->setRequestAnimationFrameEnabled(store.getBoolValueForKey(WebPreferencesKey::requestAnimationFrameEnabledKey()));
2448 // <rdar://problem/10697417>: It is necessary to force compositing when accelerate drawing
2449 // is enabled on Mac so that scrollbars are always in their own layers.
2451 if (settings->acceleratedDrawingEnabled())
2452 settings->setForceCompositingMode(LayerTreeHost::supportsAcceleratedCompositing());
2455 settings->setForceCompositingMode(store.getBoolValueForKey(WebPreferencesKey::forceCompositingModeKey()) && LayerTreeHost::supportsAcceleratedCompositing());
2457 #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
2458 if (!settings->acceleratedCompositingEnabled()) {
2459 settings->setAcceleratedCompositingFor3DTransformsEnabled(false);
2460 settings->setAcceleratedCompositingForVideoEnabled(false);
2461 settings->setAcceleratedCompositingForPluginsEnabled(false);
2462 settings->setAcceleratedCompositingForCanvasEnabled(false);
2463 settings->setAcceleratedCompositingForAnimationEnabled(false);
2466 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
2467 settings->setMemorySavingMode(WebProcess::shared().memorySavingModeEnabled());
2470 #if ENABLE(SQL_DATABASE)
2471 AbstractDatabase::setIsAvailable(store.getBoolValueForKey(WebPreferencesKey::databasesEnabledKey()));
2474 #if ENABLE(FULLSCREEN_API)
2475 settings->setFullScreenEnabled(store.getBoolValueForKey(WebPreferencesKey::fullScreenEnabledKey()));
2478 #if ENABLE(TIZEN_WEBKIT2_ASYNCHRONOUS_SPELLCHECKING)
2479 settings->setAsynchronousSpellCheckingEnabled(store.getBoolValueForKey(WebPreferencesKey::asynchronousSpellCheckingEnabledKey()));
2481 settings->setLocalStorageDatabasePath(WebProcess::shared().localStorageDirectory());
2483 #if USE(AVFOUNDATION)
2484 settings->setAVFoundationEnabled(store.getBoolValueForKey(WebPreferencesKey::isAVFoundationEnabledKey()));
2487 #if ENABLE(WEB_AUDIO)
2488 settings->setWebAudioEnabled(store.getBoolValueForKey(WebPreferencesKey::webAudioEnabledKey()));
2491 settings->setApplicationChromeMode(store.getBoolValueForKey(WebPreferencesKey::applicationChromeModeKey()));
2492 settings->setSuppressesIncrementalRendering(store.getBoolValueForKey(WebPreferencesKey::suppressesIncrementalRenderingKey()));
2493 settings->setBackspaceKeyNavigationEnabled(store.getBoolValueForKey(WebPreferencesKey::backspaceKeyNavigationEnabledKey()));
2494 settings->setWantsBalancedSetDefersLoadingBehavior(store.getBoolValueForKey(WebPreferencesKey::wantsBalancedSetDefersLoadingBehaviorKey()));
2495 settings->setCaretBrowsingEnabled(store.getBoolValueForKey(WebPreferencesKey::caretBrowsingEnabledKey()));
2497 #if ENABLE(VIDEO_TRACK)
2498 settings->setShouldDisplaySubtitles(store.getBoolValueForKey(WebPreferencesKey::shouldDisplaySubtitlesKey()));
2499 settings->setShouldDisplayCaptions(store.getBoolValueForKey(WebPreferencesKey::shouldDisplayCaptionsKey()));
2500 settings->setShouldDisplayTextDescriptions(store.getBoolValueForKey(WebPreferencesKey::shouldDisplayTextDescriptionsKey()));
2503 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
2504 settings->setNotificationsEnabled(store.getBoolValueForKey(WebPreferencesKey::notificationsEnabledKey()));
2507 settings->setShouldRespectImageOrientation(store.getBoolValueForKey(WebPreferencesKey::shouldRespectImageOrientationKey()));
2509 #if ENABLE(TIZEN_INDEXED_DATABASE)
2510 m_page->group().groupSettings()->setIndexedDBDatabasePath(WebProcess::shared().indexedDatabaseDirectory());
2511 m_page->group().groupSettings()->setIndexedDBQuotaBytes(0x6400000); //100M
2514 settings->setDiagnosticLoggingEnabled(store.getBoolValueForKey(WebPreferencesKey::diagnosticLoggingEnabledKey()));
2516 #if ENABLE(TEXT_AUTOSIZING)
2517 settings->setTextAutosizingEnabled(store.getBoolValueForKey(WebPreferencesKey::textAutosizingEnabledKey()));
2520 #if ENABLE(TIZEN_FILE_SYSTEM)
2521 m_page->group().groupSettings()->setLocalFileSystemQuotaBytes(0x6400000); //100M
2524 #if ENABLE(TIZEN_WORKERS)
2525 m_page->group().groupSettings()->setAllowUniversalAccessFromFileURLs(settings->allowUniversalAccessFromFileURLs());
2528 platformPreferencesDidChange(store);
2531 m_drawingArea->updatePreferences();
2534 #if ENABLE(INSPECTOR)
2535 WebInspector* WebPage::inspector()
2540 m_inspector = WebInspector::create(this, m_inspectorClient);
2541 return m_inspector.get();
2545 #if ENABLE(FULLSCREEN_API)
2546 WebFullScreenManager* WebPage::fullScreenManager()
2548 if (!m_fullScreenManager)
2549 m_fullScreenManager = WebFullScreenManager::create(this);
2550 return m_fullScreenManager.get();
2554 NotificationPermissionRequestManager* WebPage::notificationPermissionRequestManager()
2556 if (m_notificationPermissionRequestManager)
2557 return m_notificationPermissionRequestManager.get();
2559 m_notificationPermissionRequestManager = NotificationPermissionRequestManager::create(this);
2560 return m_notificationPermissionRequestManager.get();
2563 #if ENABLE(TIZEN_MEDIA_STREAM)
2564 UserMediaPermissionRequestManager* WebPage::userMediaPermissionRequestManager()
2566 if (m_userMediaPermissionRequestManager)
2567 return m_userMediaPermissionRequestManager.get();
2569 m_userMediaPermissionRequestManager = UserMediaPermissionRequestManager::create(this);
2570 return m_userMediaPermissionRequestManager.get();
2574 #if !PLATFORM(GTK) && !PLATFORM(MAC)
2575 bool WebPage::handleEditingKeyboardEvent(KeyboardEvent* evt)
2577 Node* node = evt->target()->toNode();
2579 Frame* frame = node->document()->frame();
2582 const PlatformKeyboardEvent* keyEvent = evt->keyEvent();
2586 Editor::Command command = frame->editor()->command(interpretKeyEvent(evt));
2588 if (keyEvent->type() == PlatformEvent::RawKeyDown) {
2589 // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated,
2590 // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
2591 // (e.g. Tab that inserts a Tab character, or Enter).
2592 return !command.isTextInsertion() && command.execute(evt);
2595 if (command.execute(evt))
2598 // Don't allow text insertion for nodes that cannot edit.
2599 if (!frame->editor()->canEdit())
2602 // Don't insert null or control characters as they can result in unexpected behaviour
2603 if (evt->charCode() < ' ')
2606 return frame->editor()->insertText(evt->keyEvent()->text(), evt);
2610 #if ENABLE(DRAG_SUPPORT)
2613 void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WebCore::DragDataMap& dataMap, uint32_t flags)
2616 send(Messages::WebPageProxy::DidPerformDragControllerAction(WebCore::DragSession()));
2620 DragData dragData(dataMap, clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
2622 case DragControllerActionEntered:
2623 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController()->dragEntered(&dragData)));
2626 case DragControllerActionUpdated:
2627 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController()->dragUpdated(&dragData)));
2630 case DragControllerActionExited:
2631 m_page->dragController()->dragExited(&dragData);
2634 case DragControllerActionPerformDrag:
2635 m_page->dragController()->performDrag(&dragData);
2639 ASSERT_NOT_REACHED();
2643 #elif PLATFORM(QT) || PLATFORM(GTK) || ENABLE(TIZEN_DRAG_SUPPORT)
2644 void WebPage::performDragControllerAction(uint64_t action, WebCore::DragData dragData)
2647 send(Messages::WebPageProxy::DidPerformDragControllerAction(WebCore::DragSession()));
2649 QMimeData* data = const_cast<QMimeData*>(dragData.platformData());
2652 DataObjectGtk* data = const_cast<DataObjectGtk*>(dragData.platformData());
2655 #if ENABLE(TIZEN_DRAG_SUPPORT)
2656 DataObjectTizen* data = const_cast<DataObjectTizen*>(dragData.platformData());
2663 case DragControllerActionEntered:
2664 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController()->dragEntered(&dragData)));
2667 case DragControllerActionUpdated:
2668 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController()->dragUpdated(&dragData)));
2671 case DragControllerActionExited:
2672 m_page->dragController()->dragExited(&dragData);
2675 case DragControllerActionPerformDrag: {
2676 m_page->dragController()->performDrag(&dragData);
2681 ASSERT_NOT_REACHED();
2683 // DragData does not delete its platformData so we need to do that here.
2685 QMimeData* data = const_cast<QMimeData*>(dragData.platformData());
2688 DataObjectGtk* data = const_cast<DataObjectGtk*>(dragData.platformData());
2691 #if ENABLE(TIZEN_DRAG_SUPPORT)
2692 DataObjectTizen* data = const_cast<DataObjectTizen*>(dragData.platformData());
2698 void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsHandleArray)
2701 send(Messages::WebPageProxy::DidPerformDragControllerAction(WebCore::DragSession()));
2705 DragData dragData(dragStorageName, clientPosition, globalPosition, static_cast<DragOperation>(draggingSourceOperationMask), static_cast<DragApplicationFlags>(flags));
2707 case DragControllerActionEntered:
2708 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController()->dragEntered(&dragData)));
2711 case DragControllerActionUpdated:
2712 send(Messages::WebPageProxy::DidPerformDragControllerAction(m_page->dragController()->dragUpdated(&dragData)));
2715 case DragControllerActionExited:
2716 m_page->dragController()->dragExited(&dragData);
2719 case DragControllerActionPerformDrag: {
2720 ASSERT(!m_pendingDropSandboxExtension);
2722 m_pendingDropSandboxExtension = SandboxExtension::create(sandboxExtensionHandle);
2723 for (size_t i = 0; i < sandboxExtensionsHandleArray.size(); i++) {
2724 if (RefPtr<SandboxExtension> extension = SandboxExtension::create(sandboxExtensionsHandleArray[i]))
2725 m_pendingDropExtensionsForFileUpload.append(extension);
2728 m_page->dragController()->performDrag(&dragData);
2730 // If we started loading a local file, the sandbox extension tracker would have adopted this
2731 // pending drop sandbox extension. If not, we'll play it safe and invalidate it.
2732 if (m_pendingDropSandboxExtension) {
2733 m_pendingDropSandboxExtension->invalidate();
2734 m_pendingDropSandboxExtension = nullptr;
2736 for (size_t i = 0; i < m_pendingDropExtensionsForFileUpload.size(); i++)
2737 m_pendingDropExtensionsForFileUpload[i]->invalidate();
2739 m_pendingDropExtensionsForFileUpload.clear();
2744 ASSERT_NOT_REACHED();
2749 void WebPage::dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation)
2751 IntPoint adjustedClientPosition(clientPosition.x() + m_page->dragController()->dragOffset().x(), clientPosition.y() + m_page->dragController()->dragOffset().y());
2752 IntPoint adjustedGlobalPosition(globalPosition.x() + m_page->dragController()->dragOffset().x(), globalPosition.y() + m_page->dragController()->dragOffset().y());
2754 m_page->dragController()->dragEnded();
2755 FrameView* view = m_page->mainFrame()->view();
2758 // FIXME: These are fake modifier keys here, but they should be real ones instead.
2759 PlatformMouseEvent event(adjustedClientPosition, adjustedGlobalPosition, LeftButton, PlatformEvent::MouseMoved, 0, false, false, false, false, currentTime());
2760 m_page->mainFrame()->eventHandler()->dragSourceEndedAt(event, (DragOperation)operation);
2763 void WebPage::willPerformLoadDragDestinationAction()
2765 m_sandboxExtensionTracker.willPerformLoadDragDestinationAction(m_pendingDropSandboxExtension.release());
2768 void WebPage::mayPerformUploadDragDestinationAction()
2770 for (size_t i = 0; i < m_pendingDropExtensionsForFileUpload.size(); i++)
2771 m_pendingDropExtensionsForFileUpload[i]->consumePermanently();
2772 m_pendingDropExtensionsForFileUpload.clear();
2775 #endif // ENABLE(DRAG_SUPPORT)
2777 WebUndoStep* WebPage::webUndoStep(uint64_t stepID)
2779 return m_undoStepMap.get(stepID).get();
2782 void WebPage::addWebUndoStep(uint64_t stepID, WebUndoStep* entry)
2784 m_undoStepMap.set(stepID, entry);
2787 void WebPage::removeWebEditCommand(uint64_t stepID)
2789 m_undoStepMap.remove(stepID);
2792 void WebPage::unapplyEditCommand(uint64_t stepID)
2794 WebUndoStep* step = webUndoStep(stepID);
2798 step->step()->unapply();
2801 void WebPage::reapplyEditCommand(uint64_t stepID)
2803 WebUndoStep* step = webUndoStep(stepID);
2808 step->step()->reapply();
2812 void WebPage::didRemoveEditCommand(uint64_t commandID)
2814 removeWebEditCommand(commandID);
2817 void WebPage::setActivePopupMenu(WebPopupMenu* menu)
2819 m_activePopupMenu = menu;
2822 #if ENABLE(INPUT_TYPE_COLOR)
2823 void WebPage::setActiveColorChooser(WebColorChooser* colorChooser)
2825 m_activeColorChooser = colorChooser;
2828 void WebPage::didEndColorChooser()
2830 m_activeColorChooser->didEndChooser();
2833 void WebPage::didChooseColor(const WebCore::Color& color)
2835 m_activeColorChooser->didChooseColor(color);
2839 void WebPage::setActiveOpenPanelResultListener(PassRefPtr<WebOpenPanelResultListener> openPanelResultListener)
2841 m_activeOpenPanelResultListener = openPanelResultListener;
2844 bool WebPage::findStringFromInjectedBundle(const String& target, FindOptions options)
2846 return m_page->findString(target, options);
2849 void WebPage::findString(const String& string, uint32_t options, uint32_t maxMatchCount)
2851 m_findController.findString(string, static_cast<FindOptions>(options), maxMatchCount);
2854 void WebPage::findStringMatches(const String& string, uint32_t options, uint32_t maxMatchCount)
2856 m_findController.findStringMatches(string, static_cast<FindOptions>(options), maxMatchCount);
2859 void WebPage::getImageForFindMatch(uint32_t matchIndex)
2861 m_findController.getImageForFindMatch(matchIndex);
2864 void WebPage::selectFindMatch(uint32_t matchIndex)
2866 m_findController.selectFindMatch(matchIndex);
2869 void WebPage::hideFindUI()
2871 m_findController.hideFindUI();
2874 void WebPage::countStringMatches(const String& string, uint32_t options, uint32_t maxMatchCount)
2876 m_findController.countStringMatches(string, static_cast<FindOptions>(options), maxMatchCount);
2879 void WebPage::didChangeSelectedIndexForActivePopupMenu(int32_t newIndex)
2881 changeSelectedIndex(newIndex);
2883 // Since applictions on tizen may provide a way to select item more than one time,
2884 // we need to keep the active popup menu to allow repetitive selection.
2886 m_activePopupMenu = 0;
2890 void WebPage::changeSelectedIndex(int32_t index)
2892 if (!m_activePopupMenu)
2895 m_activePopupMenu->didChangeSelectedIndex(index);
2898 void WebPage::didChooseFilesForOpenPanel(const Vector<String>& files)
2900 if (!m_activeOpenPanelResultListener)
2903 m_activeOpenPanelResultListener->didChooseFiles(files);
2904 m_activeOpenPanelResultListener = 0;
2907 void WebPage::didCancelForOpenPanel()
2909 m_activeOpenPanelResultListener = 0;
2913 void WebPage::cancelForOpenPanel()
2915 if (m_activeOpenPanelResultListener) {
2916 m_activeOpenPanelResultListener->disconnectFromPage();
2917 m_activeOpenPanelResultListener = 0;
2922 #if ENABLE(WEB_PROCESS_SANDBOX)
2923 void WebPage::extendSandboxForFileFromOpenPanel(const SandboxExtension::Handle& handle)
2925 SandboxExtension::create(handle)->consumePermanently();
2929 #if ENABLE(GEOLOCATION)
2930 void WebPage::didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed)
2932 m_geolocationPermissionRequestManager.didReceiveGeolocationPermissionDecision(geolocationID, allowed);
2936 void WebPage::didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed)
2938 notificationPermissionRequestManager()->didReceiveNotificationPermissionDecision(notificationID, allowed);
2941 #if ENABLE(TIZEN_MEDIA_STREAM)
2942 void WebPage::didReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed)
2944 userMediaPermissionRequestManager()->didReceiveUserMediaPermissionDecision(userMediaID, allowed);
2948 void WebPage::advanceToNextMisspelling(bool startBeforeSelection)
2950 Frame* frame = m_page->focusController()->focusedOrMainFrame();
2951 frame->editor()->advanceToNextMisspelling(startBeforeSelection);
2954 void WebPage::changeSpellingToWord(const String& word)
2956 replaceSelectionWithText(m_page->focusController()->focusedOrMainFrame(), word);
2959 void WebPage::unmarkAllMisspellings()
2961 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
2962 if (Document* document = frame->document())
2963 document->markers()->removeMarkers(DocumentMarker::Spelling);
2967 void WebPage::unmarkAllBadGrammar()
2969 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
2970 if (Document* document = frame->document())
2971 document->markers()->removeMarkers(DocumentMarker::Grammar);
2976 void WebPage::uppercaseWord()
2978 m_page->focusController()->focusedOrMainFrame()->editor()->uppercaseWord();
2981 void WebPage::lowercaseWord()
2983 m_page->focusController()->focusedOrMainFrame()->editor()->lowercaseWord();
2986 void WebPage::capitalizeWord()
2988 m_page->focusController()->focusedOrMainFrame()->editor()->capitalizeWord();
2992 void WebPage::setTextForActivePopupMenu(int32_t index)
2994 if (!m_activePopupMenu)
2997 m_activePopupMenu->setTextForIndex(index);
3001 void WebPage::failedToShowPopupMenu()
3003 if (!m_activePopupMenu)
3006 m_activePopupMenu->client()->popupDidHide();
3010 #if ENABLE(CONTEXT_MENUS)
3011 void WebPage::didSelectItemFromActiveContextMenu(const WebContextMenuItemData& item)
3016 m_contextMenu->itemSelected(item);
3021 void WebPage::replaceSelectionWithText(Frame* frame, const String& text)
3023 bool selectReplacement = true;
3024 bool smartReplace = false;
3025 return frame->editor()->replaceSelectionWithText(text, selectReplacement, smartReplace);
3028 void WebPage::clearSelection()
3030 m_page->focusController()->focusedOrMainFrame()->selection()->clear();
3033 bool WebPage::mainFrameHasCustomRepresentation() const
3035 if (Frame* frame = mainFrame())
3036 return static_cast<WebFrameLoaderClient*>(frame->loader()->client())->frameHasCustomRepresentation();
3041 void WebPage::didChangeScrollOffsetForMainFrame()
3043 Frame* frame = m_page->mainFrame();
3044 IntPoint scrollPosition = frame->view()->scrollPosition();
3045 IntPoint maximumScrollPosition = frame->view()->maximumScrollPosition();
3046 IntPoint minimumScrollPosition = frame->view()->minimumScrollPosition();
3048 #if PLATFORM(EFL) && OS(TIZEN)
3049 send(Messages::WebPageProxy::DidChangeScrollPositionForMainFrame(scrollPosition));
3052 bool isPinnedToLeftSide = (scrollPosition.x() <= minimumScrollPosition.x());
3053 bool isPinnedToRightSide = (scrollPosition.x() >= maximumScrollPosition.x());
3055 if (isPinnedToLeftSide != m_cachedMainFrameIsPinnedToLeftSide || isPinnedToRightSide != m_cachedMainFrameIsPinnedToRightSide) {
3056 send(Messages::WebPageProxy::DidChangeScrollOffsetPinningForMainFrame(isPinnedToLeftSide, isPinnedToRightSide));
3058 m_cachedMainFrameIsPinnedToLeftSide = isPinnedToLeftSide;
3059 m_cachedMainFrameIsPinnedToRightSide = isPinnedToRightSide;
3063 void WebPage::mainFrameDidLayout()
3065 unsigned pageCount = m_page->pageCount();
3066 if (pageCount != m_cachedPageCount) {
3067 send(Messages::WebPageProxy::DidChangePageCount(pageCount));
3068 m_cachedPageCount = pageCount;
3071 double red, green, blue, alpha;
3072 m_mainFrame->getDocumentBackgroundColor(&red, &green, &blue, &alpha);
3073 send(Messages::WebPageProxy::SetBackgroundColor(red, green, blue, alpha));
3076 void WebPage::addPluginView(PluginView* pluginView)
3078 ASSERT(!m_pluginViews.contains(pluginView));
3080 m_pluginViews.add(pluginView);
3083 void WebPage::removePluginView(PluginView* pluginView)
3085 ASSERT(m_pluginViews.contains(pluginView));
3087 m_pluginViews.remove(pluginView);
3091 void WebPage::setWindowIsVisible(bool windowIsVisible)
3093 m_windowIsVisible = windowIsVisible;
3095 corePage()->focusController()->setContainingWindowIsVisible(windowIsVisible);
3097 // Tell all our plug-in views that the window visibility changed.
3098 for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
3099 (*it)->setWindowIsVisible(windowIsVisible);
3102 void WebPage::windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates)
3104 m_windowFrameInScreenCoordinates = windowFrameInScreenCoordinates;
3105 m_viewFrameInWindowCoordinates = viewFrameInWindowCoordinates;
3106 m_accessibilityPosition = accessibilityViewCoordinates;
3108 // Tell all our plug-in views that the window and view frames have changed.
3109 for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
3110 (*it)->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates);
3114 bool WebPage::windowIsFocused() const
3116 return m_page->focusController()->isActive();
3119 bool WebPage::windowAndWebPageAreFocused() const
3122 if (!m_windowIsVisible)
3125 return m_page->focusController()->isFocused() && m_page->focusController()->isActive();
3128 void WebPage::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
3130 if (messageID.is<CoreIPC::MessageClassDrawingArea>()) {
3132 m_drawingArea->didReceiveDrawingAreaMessage(connection, messageID, arguments);
3136 #if USE(TILED_BACKING_STORE) && USE(ACCELERATED_COMPOSITING)
3137 if (messageID.is<CoreIPC::MessageClassLayerTreeCoordinator>()) {
3139 m_drawingArea->didReceiveLayerTreeCoordinatorMessage(connection, messageID, arguments);
3144 #if ENABLE(INSPECTOR)
3145 if (messageID.is<CoreIPC::MessageClassWebInspector>()) {
3146 if (WebInspector* inspector = this->inspector())
3147 inspector->didReceiveWebInspectorMessage(connection, messageID, arguments);
3152 #if ENABLE(FULLSCREEN_API)
3153 if (messageID.is<CoreIPC::MessageClassWebFullScreenManager>()) {
3154 fullScreenManager()->didReceiveMessage(connection, messageID, arguments);
3159 didReceiveWebPageMessage(connection, messageID, arguments);
3162 void WebPage::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
3164 didReceiveSyncWebPageMessage(connection, messageID, arguments, reply);
3167 InjectedBundleBackForwardList* WebPage::backForwardList()
3169 if (!m_backForwardList)
3170 m_backForwardList = InjectedBundleBackForwardList::create(this);
3171 return m_backForwardList.get();
3174 #if PLATFORM(QT) || OS(TIZEN)
3175 #if ENABLE(TOUCH_ADJUSTMENT)
3176 void WebPage::findZoomableAreaForPoint(const WebCore::IntPoint& point, const WebCore::IntSize& area)
3179 IntRect zoomableArea;
3180 bool foundAreaForTouchPoint = m_mainFrame->coreFrame()->eventHandler()->bestZoomableAreaForTouchPoint(point, IntSize(area.width() / 2, area.height() / 2), zoomableArea, node);
3183 if (!foundAreaForTouchPoint)
3186 send(Messages::WebPageProxy::DidFindZoomableArea(point, zoomableArea));
3190 void WebPage::findZoomableAreaForPoint(const WebCore::IntPoint& point, const WebCore::IntSize& area)
3193 Frame* mainframe = m_mainFrame->coreFrame();
3194 HitTestResult result = mainframe->eventHandler()->hitTestResultAtPoint(mainframe->view()->windowToContents(point), /*allowShadowContent*/ false, /*ignoreClipping*/ true);
3196 Node* node = result.innerNode();
3201 #if OS(TIZEN) // FIXME: This is to fix wrong codes of open source.
3202 IntRect zoomableArea = enclosingIntRect(node->getRect());
3204 IntRect zoomableArea = node->getRect();
3208 bool found = !node->isTextNode() && !node->isShadowRoot();
3210 // No candidate found, bail out.
3211 if (!found && !node->parentNode())
3214 // Candidate found, and it is a better candidate than its parent.
3215 // NB: A parent is considered a better candidate iff the node is
3216 // contained by it and it is the only child.
3217 if (found && (!node->parentNode() || node->parentNode()->childNodeCount() != 1))
3220 node = node->parentNode();
3221 #if OS(TIZEN) // FIXME: This is to fix wrong codes of open source.
3222 zoomableArea.unite(enclosingIntRect(node->getRect()));
3224 zoomableArea.unite(node->getRect());
3228 if (node->document() && node->document()->frame() && node->document()->frame()->view()) {
3229 const ScrollView* view = node->document()->frame()->view();
3230 zoomableArea = view->contentsToWindow(zoomableArea);
3233 send(Messages::WebPageProxy::DidFindZoomableArea(point, zoomableArea));
3238 WebPage::SandboxExtensionTracker::~SandboxExtensionTracker()
3243 void WebPage::SandboxExtensionTracker::invalidate()
3245 if (m_pendingProvisionalSandboxExtension) {
3246 m_pendingProvisionalSandboxExtension->invalidate();
3247 m_pendingProvisionalSandboxExtension = 0;
3250 if (m_provisionalSandboxExtension) {
3251 m_provisionalSandboxExtension->invalidate();
3252 m_provisionalSandboxExtension = 0;
3255 if (m_committedSandboxExtension) {
3256 m_committedSandboxExtension->invalidate();
3257 m_committedSandboxExtension = 0;
3261 void WebPage::SandboxExtensionTracker::willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension)
3263 setPendingProvisionalSandboxExtension(pendingDropSandboxExtension);
3266 void WebPage::SandboxExtensionTracker::beginLoad(WebFrame* frame, const SandboxExtension::Handle& handle)
3268 ASSERT(frame->isMainFrame());
3270 setPendingProvisionalSandboxExtension(SandboxExtension::create(handle));
3273 void WebPage::SandboxExtensionTracker::setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension> pendingProvisionalSandboxExtension)
3275 // If we get two beginLoad calls in succession, without a provisional load starting, then
3276 // m_pendingProvisionalSandboxExtension will be non-null. Invalidate and null out the extension if that is the case.
3277 if (m_pendingProvisionalSandboxExtension) {
3278 m_pendingProvisionalSandboxExtension->invalidate();
3279 m_pendingProvisionalSandboxExtension = nullptr;
3282 m_pendingProvisionalSandboxExtension = pendingProvisionalSandboxExtension;
3285 static bool shouldReuseCommittedSandboxExtension(WebFrame* frame)
3287 ASSERT(frame->isMainFrame());
3289 FrameLoader* frameLoader = frame->coreFrame()->loader();
3290 FrameLoadType frameLoadType = frameLoader->loadType();
3292 // If the page is being reloaded, it should reuse whatever extension is committed.
3293 if (frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTypeReloadFromOrigin)
3296 DocumentLoader* documentLoader = frameLoader->documentLoader();
3297 DocumentLoader* provisionalDocumentLoader = frameLoader->provisionalDocumentLoader();
3298 if (!documentLoader || !provisionalDocumentLoader)
3301 if (documentLoader->url().isLocalFile() && provisionalDocumentLoader->url().isLocalFile())
3307 void WebPage::SandboxExtensionTracker::didStartProvisionalLoad(WebFrame* frame)
3309 if (!frame->isMainFrame())
3312 // We should only reuse the commited sandbox extension if it is not null. It can be
3313 // null if the last load was for an error page.
3314 if (m_committedSandboxExtension && shouldReuseCommittedSandboxExtension(frame)) {
3315 m_pendingProvisionalSandboxExtension = m_committedSandboxExtension.release();
3316 ASSERT(!m_committedSandboxExtension);
3319 ASSERT(!m_provisionalSandboxExtension);
3321 m_provisionalSandboxExtension = m_pendingProvisionalSandboxExtension.release();
3322 if (!m_provisionalSandboxExtension)
3325 m_provisionalSandboxExtension->consume();
3328 void WebPage::SandboxExtensionTracker::didCommitProvisionalLoad(WebFrame* frame)
3330 if (!frame->isMainFrame())
3333 // Generally, there should be no pending extension at this stage, but we can have one if UI process
3334 // has an out of date idea of WebProcess state, and initiates a load or reload without stopping an existing one.
3335 if (m_pendingProvisionalSandboxExtension) {
3336 m_pendingProvisionalSandboxExtension->invalidate();
3337 m_pendingProvisionalSandboxExtension = nullptr;
3340 // The provisional load has been committed. Invalidate the currently committed sandbox
3341 // extension and make the provisional sandbox extension the committed sandbox extension.
3342 if (m_committedSandboxExtension)
3343 m_committedSandboxExtension->invalidate();
3345 m_committedSandboxExtension = m_provisionalSandboxExtension.release();
3348 void WebPage::SandboxExtensionTracker::didFailProvisionalLoad(WebFrame* frame)
3350 if (!frame->isMainFrame())
3353 // Generally, there should be no pending extension at this stage, but we can have one if UI process
3354 // has an out of date idea of WebProcess state, and initiates a load or reload without stopping an existing one.
3355 if (m_pendingProvisionalSandboxExtension) {
3356 m_pendingProvisionalSandboxExtension->invalidate();
3357 m_pendingProvisionalSandboxExtension = nullptr;
3360 if (!m_provisionalSandboxExtension)
3363 m_provisionalSandboxExtension->invalidate();
3364 m_provisionalSandboxExtension = nullptr;
3367 bool WebPage::hasLocalDataForURL(const KURL& url)
3369 if (url.isLocalFile())
3372 FrameLoader* frameLoader = m_page->mainFrame()->loader();
3373 DocumentLoader* documentLoader = frameLoader ? frameLoader->documentLoader() : 0;
3374 if (documentLoader && documentLoader->subresource(url))
3377 return platformHasLocalDataForURL(url);
3380 void WebPage::setCustomTextEncodingName(const String& encoding)
3382 m_page->mainFrame()->loader()->reloadWithOverrideEncoding(encoding);
3385 void WebPage::didRemoveBackForwardItem(uint64_t itemID)
3387 WebBackForwardListProxy::removeItem(itemID);
3392 bool WebPage::isSpeaking()
3395 return sendSync(Messages::WebPageProxy::GetIsSpeaking(), Messages::WebPageProxy::GetIsSpeaking::Reply(result)) && result;
3398 void WebPage::speak(const String& string)
3400 send(Messages::WebPageProxy::Speak(string));
3403 void WebPage::stopSpeaking()
3405 send(Messages::WebPageProxy::StopSpeaking());
3411 RetainPtr<PDFDocument> WebPage::pdfDocumentForPrintingFrame(Frame* coreFrame)
3413 Document* document = coreFrame->document();
3417 if (!document->isPluginDocument())
3420 PluginView* pluginView = static_cast<PluginView*>(toPluginDocument(document)->pluginWidget());
3424 return pluginView->pdfDocumentForPrinting();
3426 #endif // PLATFORM(MAC)
3428 void WebPage::beginPrinting(uint64_t frameID, const PrintInfo& printInfo)
3430 WebFrame* frame = WebProcess::shared().webFrame(frameID);
3434 Frame* coreFrame = frame->coreFrame();
3439 if (pdfDocumentForPrintingFrame(coreFrame))
3441 #endif // PLATFORM(MAC)
3443 if (!m_printContext)
3444 m_printContext = adoptPtr(new PrintContext(coreFrame));
3446 drawingArea()->setLayerTreeStateIsFrozen(true);
3447 m_printContext->begin(printInfo.availablePaperWidth, printInfo.availablePaperHeight);
3449 float fullPageHeight;
3450 m_printContext->computePageRects(FloatRect(0, 0, printInfo.availablePaperWidth, printInfo.availablePaperHeight), 0, 0, printInfo.pageSetupScaleFactor, fullPageHeight, true);
3453 if (!m_printOperation)
3454 m_printOperation = WebPrintOperationGtk::create(this, printInfo);
3458 void WebPage::endPrinting()
3460 drawingArea()->setLayerTreeStateIsFrozen(false);
3462 m_printOperation = 0;
3464 m_printContext = nullptr;
3467 void WebPage::computePagesForPrinting(uint64_t frameID, const PrintInfo& printInfo, uint64_t callbackID)
3469 Vector<IntRect> resultPageRects;
3470 double resultTotalScaleFactorForPrinting = 1;
3472 beginPrinting(frameID, printInfo);
3474 if (m_printContext) {
3475 resultPageRects = m_printContext->pageRects();
3476 resultTotalScaleFactorForPrinting = m_printContext->computeAutomaticScaleFactor(FloatSize(printInfo.availablePaperWidth, printInfo.availablePaperHeight)) * printInfo.pageSetupScaleFactor;
3480 computePagesForPrintingPDFDocument(frameID, printInfo, resultPageRects);
3481 #endif // PLATFORM(MAC)
3483 // If we're asked to print, we should actually print at least a blank page.
3484 if (resultPageRects.isEmpty())
3485 resultPageRects.append(IntRect(0, 0, 1, 1));
3487 send(Messages::WebPageProxy::ComputedPagesCallback(resultPageRects, resultTotalScaleFactorForPrinting, callbackID));
3490 #if PLATFORM(MAC) || PLATFORM(WIN)
3491 void WebPage::drawRectToPDF(uint64_t frameID, const PrintInfo& printInfo, const WebCore::IntRect& rect, uint64_t callbackID)
3493 WebFrame* frame = WebProcess::shared().webFrame(frameID);
3494 Frame* coreFrame = frame ? frame->coreFrame() : 0;
3496 RetainPtr<CFMutableDataRef> pdfPageData(AdoptCF, CFDataCreateMutable(0, 0));
3501 ASSERT(coreFrame->document()->printing() || pdfDocumentForPrintingFrame(coreFrame));
3503 ASSERT(coreFrame->document()->printing());
3506 // FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data.
3507 RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get()));
3509 CGRect mediaBox = CGRectMake(0, 0, rect.width(), rect.height());
3510 RetainPtr<CGContextRef> context(AdoptCF, CGPDFContextCreate(pdfDataConsumer.get(), &mediaBox, 0));
3511 RetainPtr<CFDictionaryRef> pageInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
3512 CGPDFContextBeginPage(context.get(), pageInfo.get());
3515 if (RetainPtr<PDFDocument> pdfDocument = pdfDocumentForPrintingFrame(coreFrame)) {
3516 ASSERT(!m_printContext);
3517 drawRectToPDFFromPDFDocument(context.get(), pdfDocument.get(), printInfo, rect);
3521 GraphicsContext ctx(context.get());
3522 ctx.scale(FloatSize(1, -1));
3523 ctx.translate(0, -rect.height());
3524 m_printContext->spoolRect(ctx, rect);
3527 CGPDFContextEndPage(context.get());
3528 CGPDFContextClose(context.get());
3532 send(Messages::WebPageProxy::DataCallback(CoreIPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get())), callbackID));
3535 void WebPage::drawPagesToPDF(uint64_t frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, uint64_t callbackID)
3537 WebFrame* frame = WebProcess::shared().webFrame(frameID);
3538 Frame* coreFrame = frame ? frame->coreFrame() : 0;
3540 RetainPtr<CFMutableDataRef> pdfPageData(AdoptCF, CFDataCreateMutable(0, 0));
3546 ASSERT(coreFrame->document()->printing() || pdfDocumentForPrintingFrame(coreFrame));
3548 ASSERT(coreFrame->document()->printing());
3551 // FIXME: Use CGDataConsumerCreate with callbacks to avoid copying the data.
3552 RetainPtr<CGDataConsumerRef> pdfDataConsumer(AdoptCF, CGDataConsumerCreateWithCFData(pdfPageData.get()));
3554 CGRect mediaBox = (m_printContext && m_printContext->pageCount()) ? m_printContext->pageRect(0) : CGRectMake(0, 0, printInfo.availablePaperWidth, printInfo.availablePaperHeight);
3555 RetainPtr<CGContextRef> context(AdoptCF, CGPDFContextCreate(pdfDataConsumer.get(), &mediaBox, 0));
3558 if (RetainPtr<PDFDocument> pdfDocument = pdfDocumentForPrintingFrame(coreFrame)) {
3559 ASSERT(!m_printContext);
3560 drawPagesToPDFFromPDFDocument(context.get(), pdfDocument.get(), printInfo, first, count);
3564 size_t pageCount = m_printContext->pageCount();
3565 for (uint32_t page = first; page < first + count; ++page) {
3566 if (page >= pageCount)
3569 RetainPtr<CFDictionaryRef> pageInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
3570 CGPDFContextBeginPage(context.get(), pageInfo.get());
3572 GraphicsContext ctx(context.get());
3573 ctx.scale(FloatSize(1, -1));
3574 ctx.translate(0, -m_printContext->pageRect(page).height());
3575 m_printContext->spoolPage(ctx, page, m_printContext->pageRect(page).width());
3577 CGPDFContextEndPage(context.get());
3580 CGPDFContextClose(context.get());
3584 send(Messages::WebPageProxy::DataCallback(CoreIPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get())), callbackID));
3589 void WebPage::drawPagesForPrinting(uint64_t frameID, const PrintInfo& printInfo, uint64_t callbackID)
3591 beginPrinting(frameID, printInfo);
3592 if (m_printContext && m_printOperation) {
3593 m_printOperation->startPrint(m_printContext.get(), callbackID);
3597 send(Messages::WebPageProxy::VoidCallback(callbackID));
3601 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
3602 void WebPage::getWebAppCapable(uint64_t callbackID)
3604 RefPtr<WebCore::NodeList> nodeList = mainFrame()->document()->getElementsByTagName("meta");
3605 bool capable = false;
3607 for (unsigned i = 0; i < nodeList->length(); i++) {
3608 WebCore::HTMLMetaElement* metaElement = static_cast<WebCore::HTMLMetaElement*>(nodeList->item(i));
3609 if (metaElement->name() == "apple-mobile-web-app-capable") {
3610 capable = metaElement->content() == "yes" ? true : false;
3615 send(Messages::WebPageProxy::DidGetWebAppCapable(capable, callbackID));
3618 void WebPage::getWebAppIconURL(uint64_t callbackID)
3620 RefPtr<WebCore::NodeList> nodeList = mainFrame()->document()->getElementsByTagName("link");
3623 for (unsigned i = 0; i < nodeList->length(); i++) {
3624 WebCore::HTMLLinkElement* linkElement = static_cast<WebCore::HTMLLinkElement*>(nodeList->item(i));
3625 if (linkElement->rel() == "apple-touch-icon" || linkElement->rel() == "apple-touch-icon-precomposed")
3626 iconURL = linkElement->href().string();
3629 send(Messages::WebPageProxy::DidGetWebAppIconURL(iconURL, callbackID));
3632 void WebPage::getWebAppIconURLs(uint64_t callbackID)
3634 RefPtr<WebCore::NodeList> nodeList = mainFrame()->document()->getElementsByTagName("link");
3635 Vector<std::pair<String, String> > iconURLs;
3637 for (unsigned i = 0; i < nodeList->length(); i++) {
3638 WebCore::HTMLLinkElement* linkElement = static_cast<WebCore::HTMLLinkElement*>(nodeList->item(i));
3639 if (linkElement->rel() == "apple-touch-icon" || linkElement->rel() == "apple-touch-icon-precomposed")
3640 iconURLs.append(pair<String, String>(linkElement->href().string(), linkElement->iconSizes()));
3643 send(Messages::WebPageProxy::DidGetWebAppIconURLs(iconURLs, callbackID));
3647 void WebPage::setMediaVolume(float volume)
3649 m_page->setMediaVolume(volume);
3652 void WebPage::runModal()
3656 if (m_isRunningModal)
3659 m_isRunningModal = true;
3660 send(Messages::WebPageProxy::RunModal());
3662 ASSERT(!m_isRunningModal);
3665 void WebPage::setMemoryCacheMessagesEnabled(bool memoryCacheMessagesEnabled)
3667 m_page->setMemoryCacheClientCallsEnabled(memoryCacheMessagesEnabled);
3670 bool WebPage::canHandleRequest(const WebCore::ResourceRequest& request)
3672 if (SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(request.url().protocol()))
3674 return platformCanHandleRequest(request);
3677 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
3678 void WebPage::handleAlternativeTextUIResult(const String& result)
3680 Frame* frame = m_page->focusController()->focusedOrMainFrame();
3683 frame->editor()->handleAlternativeTextUIResult(result);
3687 void WebPage::simulateMouseDown(int button, WebCore::IntPoint position, int clickCount, WKEventModifiers modifiers, double time)
3689 mouseEvent(WebMouseEvent(WebMouseEvent::MouseDown, static_cast<WebMouseEvent::Button>(button), position, position, 0, 0, 0, clickCount, static_cast<WebMouseEvent::Modifiers>(modifiers), time));
3692 void WebPage::simulateMouseUp(int button, WebCore::IntPoint position, int clickCount, WKEventModifiers modifiers, double time)
3694 mouseEvent(WebMouseEvent(WebMouseEvent::MouseUp, static_cast<WebMouseEvent::Button>(button), position, position, 0, 0, 0, clickCount, static_cast<WebMouseEvent::Modifiers>(modifiers), time));
3697 void WebPage::simulateMouseMotion(WebCore::IntPoint position, double time)
3699 mouseEvent(WebMouseEvent(WebMouseEvent::MouseMove, WebMouseEvent::NoButton, position, position, 0, 0, 0, 0, WebMouseEvent::Modifiers(), time));
3702 void WebPage::setCompositionForTesting(const String& compositionString, uint64_t from, uint64_t length)
3704 Frame* frame = m_page->focusController()->focusedOrMainFrame();
3705 if (!frame || !frame->editor()->canEdit())
3708 Vector<CompositionUnderline> underlines;
3709 underlines.append(CompositionUnderline(0, compositionString.length(), Color(Color::black), false));
3710 frame->editor()->setComposition(compositionString, underlines, from, from + length);
3713 bool WebPage::hasCompositionForTesting()
3715 Frame* frame = m_page->focusController()->focusedOrMainFrame();
3716 return frame && frame->editor()->hasComposition();
3719 void WebPage::confirmCompositionForTesting(const String& compositionString)
3721 Frame* frame = m_page->focusController()->focusedOrMainFrame();
3722 if (!frame || !frame->editor()->canEdit())
3725 if (compositionString.isNull())
3726 frame->editor()->confirmComposition();
3727 frame->editor()->confirmComposition(compositionString);
3730 void WebPage::numWheelEventHandlersChanged(unsigned numWheelEventHandlers)
3732 if (m_numWheelEventHandlers == numWheelEventHandlers)
3735 m_numWheelEventHandlers = numWheelEventHandlers;
3736 recomputeShortCircuitHorizontalWheelEventsState();
3739 static bool hasEnabledHorizontalScrollbar(ScrollableArea* scrollableArea)
3741 if (Scrollbar* scrollbar = scrollableArea->horizontalScrollbar())
3742 return scrollbar->enabled();
3747 static bool pageContainsAnyHorizontalScrollbars(Frame* mainFrame)
3749 if (FrameView* frameView = mainFrame->view()) {
3750 if (hasEnabledHorizontalScrollbar(frameView))
3754 for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext()) {
3755 FrameView* frameView = frame->view();
3759 const HashSet<ScrollableArea*>* scrollableAreas = frameView->scrollableAreas();
3760 if (!scrollableAreas)
3763 for (HashSet<ScrollableArea*>::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
3764 ScrollableArea* scrollableArea = *it;
3765 if (!scrollableArea->isOnActivePage())
3768 if (hasEnabledHorizontalScrollbar(scrollableArea))
3776 void WebPage::recomputeShortCircuitHorizontalWheelEventsState()
3778 bool canShortCircuitHorizontalWheelEvents = !m_numWheelEventHandlers;
3780 if (canShortCircuitHorizontalWheelEvents) {
3781 // Check if we have any horizontal scroll bars on the page.
3782 if (pageContainsAnyHorizontalScrollbars(mainFrame()))
3783 canShortCircuitHorizontalWheelEvents = false;
3786 if (m_canShortCircuitHorizontalWheelEvents == canShortCircuitHorizontalWheelEvents)
3789 m_canShortCircuitHorizontalWheelEvents = canShortCircuitHorizontalWheelEvents;
3790 send(Messages::WebPageProxy::SetCanShortCircuitHorizontalWheelEvents(m_canShortCircuitHorizontalWheelEvents));
3793 Frame* WebPage::mainFrame() const
3795 return m_page ? m_page->mainFrame() : 0;
3798 FrameView* WebPage::mainFrameView() const
3800 if (Frame* frame = mainFrame())
3801 return frame->view();
3806 #if ENABLE(PAGE_VISIBILITY_API)
3807 void WebPage::setVisibilityState(int visibilityState, bool isInitialState)
3812 WebCore::PageVisibilityState state = static_cast<WebCore::PageVisibilityState>(visibilityState);
3814 if (m_visibilityState == state)
3817 FrameView* view = m_page->mainFrame() ? m_page->mainFrame()->view() : 0;
3819 if (state == WebCore::PageVisibilityStateVisible) {
3820 m_page->didMoveOnscreen();
3825 m_page->setVisibilityState(state, isInitialState);
3826 m_visibilityState = state;
3828 if (state == WebCore::PageVisibilityStateHidden) {
3829 m_page->willMoveOffscreen();
3836 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
3837 const char* dumpFileName = "/tmp/webkit_memory";
3840 void dumpMemorySnapshotForUrl(char* url)
3842 PrintFormat format = PRINT_FORMAT_JSON;
3844 fp = fopen(dumpFileName, "a");
3846 if (format == PRINT_FORMAT_JSON)
3849 fprintf(fp, "URL:%s\n", url);
3850 fprintf(fp, "%s", memoryPage(format).utf8().data());
3851 if (format == PRINT_FORMAT_JSON)
3852 fprintf(fp, "\"URL\":\"%s\"}\n", url);
3858 void dumpMemorySnapshot()
3860 dumpMemorySnapshotForUrl(lastUrl);
3863 void WebPage::dumpMemorySnapshot()
3865 char* url = strdup(mainWebFrame()->url().utf8().data());
3872 } // namespace WebKit