2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
4 * Copyright (C) 2011 Igalia S.L.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 * THE POSSIBILITY OF SUCH DAMAGE.
31 #include "NamedNodeMap.h"
32 #include "NotImplemented.h"
34 #include "WindowsKeyboardCodes.h"
35 #include <WebCore/EflKeyboardUtilities.h>
36 #include <WebCore/FocusController.h>
37 #include <WebCore/Frame.h>
38 #include <WebCore/KeyboardEvent.h>
39 #include <WebCore/Page.h>
40 #include <WebCore/PlatformKeyboardEvent.h>
41 #include <WebCore/Settings.h>
44 #include "Arguments.h"
45 #include "PlatformContextCairo.h"
46 #include "WebCoreArgumentCoders.h"
49 #include "WebPageProxyMessages.h"
50 #include <WebCore/FrameView.h>
52 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
53 #include <WebCore/HTMLInputElement.h>
54 #include <WebCore/HTMLNames.h>
57 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
58 #include <WebCore/PlatformContextCairo.h>
61 #if ENABLE(TIZEN_SUPPORT_RSS_LINK_PARSING)
62 #include "HTMLLinkElement.h"
63 #include <WebCore/html/HTMLAllCollection.h>
64 #include <efl/RssItemEfl.h>
67 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
68 #include <WebCore/Pasteboard.h>
71 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
72 #include "WebInspectorServerEfl.h"
75 #if ENABLE(TIZEN_WEB_STORAGE)
76 #include <WebCore/GroupSettings.h>
77 #include <WebCore/PageGroup.h>
80 #if ENABLE(TIZEN_NPAPI)
81 #include "PluginView.h"
84 #if ENABLE(TIZEN_PREFERENCE)
85 #include "WebPreferencesStore.h"
86 #include <WebCore/Settings.h>
89 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
90 #include <WebCore/HTMLFrameOwnerElement.h>
91 #include <WebCore/HTMLImageElement.h>
94 #if ENABLE(TIZEN_DEVICE_ORIENTATION)
95 #include "DeviceMotionClientEfl.h"
96 #include "DeviceOrientationClientEfl.h"
99 #if ENABLE(TIZEN_WEBKIT2_THEME_SET)
100 #include <WebCore/RenderThemeEfl.h>
103 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
104 #include "RenderLayer.h"
105 #include "WebGraphicsLayer.h"
107 #endif // #if OS(TIZEN)
109 using namespace WebCore;
113 void WebPage::platformInitialize()
115 #if ENABLE(TIZEN_DEVICE_ORIENTATION)
116 WebCore::provideDeviceMotionTo(m_page.get(), new DeviceMotionClientEfl);
117 WebCore::provideDeviceOrientationTo(m_page.get(), new DeviceOrientationClientEfl);
121 #if ENABLE(TIZEN_PREFERENCE)
122 void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store)
124 Settings* settings = m_page->settings();
125 settings->setInteractiveFormValidationEnabled(store.getBoolValueForKey(WebPreferencesKey::interactiveFormValidationEnabledKey()));
126 settings->setViewWidth(store.getUInt32ValueForKey(WebPreferencesKey::viewWidthKey()));
127 settings->setViewHeight(store.getUInt32ValueForKey(WebPreferencesKey::viewHeightKey()));
128 settings->setUsesEncodingDetector(store.getBoolValueForKey(WebPreferencesKey::usesEncodingDetectorKey()));
129 #if ENABLE(TIZEN_LOAD_REMOTE_IMAGES)
130 settings->setLoadRemoteImages(store.getBoolValueForKey(WebPreferencesKey::loadRemoteImagesKey()));
132 #if ENABLE(TIZEN_ISF_PORT)
133 settings->setShowImeOnAutofocus(store.getBoolValueForKey(WebPreferencesKey::showImeOnAutofocusKey()));
134 settings->setEnableDefaultKeypad(store.getBoolValueForKey(WebPreferencesKey::defaultKeypadEnabledKey()));
136 #if ENABLE(TIZEN_WAC_DISABLE_GEOLOCATION)
137 settings->setGeolocationEnabled(store.getBoolValueForKey(WebPreferencesKey::geolocationEnabledKey()));
141 void WebPage::platformPreferencesDidChange(const WebPreferencesStore&)
145 #endif // #if ENABLE(TIZEN_PREFERENCE)
147 static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
149 page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
152 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
158 bool WebPage::platformHasLocalDataForURL(const KURL&)
164 String WebPage::cachedResponseMIMETypeForURL(const KURL&)
170 bool WebPage::platformCanHandleRequest(const ResourceRequest&)
176 String WebPage::cachedSuggestedFilenameForURL(const KURL&)
182 PassRefPtr<SharedBuffer> WebPage::cachedResponseDataForURL(const KURL&)
188 const char* WebPage::interpretKeyEvent(const KeyboardEvent* event)
190 ASSERT(event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent);
192 if (event->type() == eventNames().keydownEvent)
193 return getKeyDownCommandName(event);
195 return getKeyPressCommandName(event);
200 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
201 IntSize WebPage::contentsSize() const
203 FrameView* frameView = m_page->mainFrame()->view();
205 return IntSize(0, 0);
207 return frameView->contentsSize();
211 void WebPage::scrollMainFrameBy(const IntSize& scrollOffset)
213 m_page->mainFrame()->view()->scrollBy(scrollOffset);
216 void WebPage::scrollMainFrameTo(const IntPoint& scrollPosition)
218 m_page->mainFrame()->view()->setScrollPosition(scrollPosition);
221 void WebPage::createSnapshot(const IntRect rect, float scaleFactor, ShareableBitmap::Handle& snapshotHandle)
223 FrameView* frameView = m_mainFrame->coreFrame()->view();
227 RefPtr<WebImage> snapshotImage = scaledSnapshotInViewCoordinates(rect, scaleFactor, ImageOptionsShareable);
228 if (!snapshotImage || !snapshotImage->bitmap())
231 snapshotImage->bitmap()->createHandle(snapshotHandle);
234 void WebPage::requestUpdateFormNavigation()
236 Frame* frame = m_page->focusController()->focusedOrMainFrame();
240 Document* document = frame->document();
244 Node* focusedNode = document->focusedNode();
246 Vector<RefPtr<Node> > focusableNodes;
247 document->getFocusableNodes(focusableNodes);
249 int formElementCount = 0;
250 int currentNodeIndex = -1;
251 const Vector<RefPtr<Node> >::iterator end = focusableNodes.end();
252 for (Vector<RefPtr<Node> >::iterator it = focusableNodes.begin(); it != end; ++it) {
253 AtomicString nodeName = (*it).get()->nodeName();
254 if (equalIgnoringCase(nodeName, "SELECT")
255 || (equalIgnoringCase(nodeName, "INPUT")
256 && !equalIgnoringCase((*it).get()->toInputElement()->type(), "CHECKBOX")
257 && !equalIgnoringCase((*it).get()->toInputElement()->type(), "RADIO")
258 && !equalIgnoringCase((*it).get()->toInputElement()->type(), "SUBMIT")
261 if ((*it).get() == focusedNode)
262 currentNodeIndex = formElementCount;
267 if (currentNodeIndex == -1)
270 send(Messages::WebPageProxy::UpdateFormNavigation(formElementCount, currentNodeIndex));
273 void WebPage::moveFocus(int newIndex)
275 Frame* frame = m_page->focusController()->focusedOrMainFrame();
279 Document* document = frame->document();
283 Vector<RefPtr<Node> > focusableNodes;
284 document->getFocusableNodes(focusableNodes);
287 const Vector<RefPtr<Node> >::iterator end = focusableNodes.end();
288 for (Vector<RefPtr<Node> >::iterator it = focusableNodes.begin(); it != end; ++it) {
289 AtomicString nodeName = (*it).get()->nodeName();
290 if (equalIgnoringCase(nodeName, "SELECT")) {
291 if (index == newIndex) {
292 (*it).get()->setFocus();
293 LayoutPoint position = LayoutPoint(0, 0);
294 PlatformMouseEvent event(flooredIntPoint(position), flooredIntPoint(position), LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0);
295 (*it).get()->dispatchMouseEvent(event, "mousedown", 0, 0);
298 } else if (equalIgnoringCase(nodeName, "INPUT")
299 && !equalIgnoringCase((*it).get()->toInputElement()->type(), "CHECKBOX")
300 && !equalIgnoringCase((*it).get()->toInputElement()->type(), "RADIO")
302 if (index == newIndex) {
303 HTMLInputElement* elem = (*it).get()->toInputElement();
311 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
313 #define A4_HEIGHT 297
314 #define INCH_TO_MM 25.4
315 #define INCH_TO_POINTS 72.0
317 void WebPage::createPagesToPDF(const IntSize& size, const String& fileName)
319 FrameView* frameView = m_mainFrame->coreFrame()->view();
323 RefPtr<WebImage> pageshotImage = WebImage::create(size, ImageOptionsShareable);
324 if (!pageshotImage->bitmap())
327 double pdfWidth = A4_WIDTH / INCH_TO_MM * INCH_TO_POINTS;
328 double pdfHeight = A4_HEIGHT / INCH_TO_MM * INCH_TO_POINTS;
329 double scaleFactorPdf = pdfWidth / (double)size.width();
331 OwnPtr<WebCore::GraphicsContext> graphicsContext = pageshotImage->bitmap()->createGraphicsContextForPdfSurface(fileName, pdfWidth, pdfHeight);
332 graphicsContext->scale(FloatSize(scaleFactorPdf, scaleFactorPdf));
334 frameView->updateLayoutAndStyleIfNeededRecursive();
336 int pageNumber = ((size.height() * scaleFactorPdf) / pdfHeight) + 1;
337 IntRect paintRect(0, 0, size.width(), size.height());
339 PaintBehavior oldBehavior = frameView->paintBehavior();
340 frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
341 for (int i = 0; i < pageNumber; i++) {
342 frameView->paint(graphicsContext.get(), paintRect);
343 cairo_show_page(graphicsContext->platformContext()->cr());
344 graphicsContext->translate(0, -ceil(pdfHeight / scaleFactorPdf));
346 frameView->setPaintBehavior(oldBehavior);
348 pageshotImage.release();
352 void WebPage::confirmComposition(const String& compositionString)
354 Frame* frame = m_page->focusController()->focusedOrMainFrame();
355 if (!frame || !frame->editor()->canEdit())
357 frame->editor()->confirmComposition(compositionString);
360 void WebPage::setComposition(const String& compositionString, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition)
362 Frame* frame = m_page->focusController()->focusedOrMainFrame();
363 if (!frame || !frame->editor()->canEdit())
365 frame->editor()->setComposition(compositionString, underlines, cursorPosition, 0);
368 #if ENABLE(TIZEN_TEXT_CARET_HANDLING_WK2)
369 bool WebPage::setCaretPosition(const WebCore::IntPoint& pos)
371 Frame* frame = m_page->focusController()->focusedOrMainFrame();
375 WebCore::FrameSelection* controller = frame->selection();
379 FrameView* frameView = frame->view();
383 WebCore::IntPoint point = pos;
384 WebCore::HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frameView->windowToContents(point), /*allowShadowContent*/ true, /*ignoreClipping*/ true);
385 if (result.scrollbar())
388 WebCore::Node* innerNode = result.innerNode();
390 if (!innerNode || !innerNode->renderer())
393 WebCore::VisiblePosition visiblePos;
395 const int boundariesWidth = 2;
397 // we check if content is richly editable - because those input field behave other than plain text ones
398 // sometimes they may consists a node structure and they need special approach
399 if (innerNode->rendererIsRichlyEditable()) {
400 // point gets inner node local coordinates
401 point = flooredIntPoint(result.localPoint());
402 WebCore::IntRect rect = innerNode->renderer()->absoluteBoundingBoxRect(true);
404 // it is not the best way to do this, but it is not as slow and it works - so maybe in the future someone
405 // will have a better idea how to solve it
406 // here we are getting innerNode from HitTestResult - unfortunately this is a kind of high level node
407 // in the code below I am trying to obtain low level node - #text - to get its coordinates and size
409 // all those getting nodes rects are needed to bypass WebCore's methods of positioning caret when user
410 // is clicking outside a node - and cheat WebCore telling it that actually we clicked into input field
411 // node, not outside of it
412 WebCore::Node* deepInnerNode = innerNode->renderer()->positionForPoint(point).deepEquivalent().deprecatedNode();
414 if (!deepInnerNode || !deepInnerNode->renderer())
417 // so we get a base node rectange
418 WebCore::IntRect deepNodeRect = deepInnerNode->renderer()->absoluteBoundingBoxRect(true);
420 // we modify our local point to adjust it to base node local coordinates
421 point.move(rect.x() - deepNodeRect.x(), rect.y() - deepNodeRect.y());
423 // if we are outside the rect we cheat, that we are just inside of it
426 else if (point.y() >= deepNodeRect.height())
427 point.setY(deepNodeRect.height() - 1);
429 // visible position created - caret ready to set
430 visiblePos = deepInnerNode->renderer()->positionForPoint(point);
431 if (visiblePos.isNull())
434 // for plain text input fields we can get only a caret bounding box
435 if (!controller->isCaret() || !controller->caretRenderer())
438 const WebCore::Node* node = controller->start().deprecatedNode();
439 if (!node || !node->renderer())
442 WebCore::IntRect rect = controller->caretRenderer()->absoluteBoundingBoxRect(true);
444 // here we also cheat input field that we actually are just inside of if
445 if (point.x() < rect.x())
446 point.setX(rect.x());
447 else if (point.x() > rect.maxX())
448 point.setX(rect.maxX());
449 if (point.y() < rect.y() + boundariesWidth)
450 point.setY(rect.y() + boundariesWidth);
451 else if (point.y() >= rect.maxY() - boundariesWidth)
452 point.setY(rect.maxY() - boundariesWidth - 1);
454 // hit test with fake (adjusted) coordinates
455 WebCore::HitTestResult newResult = frame->eventHandler()->hitTestResultAtPoint
456 (point, /*allowShadowContent*/ true, /*ignoreClipping*/ true);
458 if (!newResult.isContentEditable())
461 WebCore::Node* newInnerNode = newResult.innerNode();
463 if (!newInnerNode || !newInnerNode->renderer())
466 // visible position created
467 visiblePos = newInnerNode->renderer()->positionForPoint(newResult.localPoint());
468 if (visiblePos.isNull())
472 // create visible selection from visible position
473 WebCore::VisibleSelection newSelection = WebCore::VisibleSelection(visiblePos);
474 controller->setSelection(newSelection, WebCore::CharacterGranularity);
475 // after setting selection caret blinking is suspended by default so we are unsuspedning it
476 controller->setCaretBlinkingSuspended(false);
481 void WebPage::getCaretPosition(WebCore::IntRect& rect)
483 Frame* frame = m_page->focusController()->focusedOrMainFrame();
487 WebCore::FrameSelection* controller = frame->selection();
491 WebCore::Node* node = controller->start().deprecatedNode();
492 if (!node || !node->renderer() || !node->isContentEditable())
495 if (controller->isCaret()) {
496 FrameView* frameView = frame->view();
500 rect = frameView->contentsToWindow(controller->absoluteCaretBounds());
505 #if ENABLE(TIZEN_ISF_PORT)
506 void WebPage::getCursorOffsetPosition(int& offset)
509 Frame* frame = m_page->focusController()->focusedOrMainFrame();
510 if (!frame || !frame->editor()->canEdit())
513 Position base = frame->selection()->base();
514 Node* baseNode = base.containerNode();
516 offset = baseNode->isTextNode() ? base.offsetInContainerNode() : 0;
519 void WebPage::getContentOfPosition(String& content)
521 Frame* frame = m_page->focusController()->focusedOrMainFrame();
522 if (!frame || !frame->editor()->canEdit())
525 Position base = frame->selection()->base();
526 Node* baseNode = base.containerNode();
527 if (baseNode && baseNode->isTextNode())
528 content = baseNode->textContent();
533 void WebPage::deleteSurroundingPosition(bool& result)
535 Frame* frame = m_page->focusController()->focusedOrMainFrame();
536 if (!frame || !frame->editor()->canEdit())
539 frame->editor()->deleteWithDirection(DirectionBackward, CharacterGranularity, false, true);
543 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
544 void WebPage::setFocusedInputElementValue(const String& inputValue)
546 Frame* frame = m_page->focusController()->focusedOrMainFrame();
549 && frame->document()->focusedNode()) {
550 Node* node = frame->document()->focusedNode();
551 if (node->nodeType() == Node::ELEMENT_NODE) {
552 if (node->hasTagName(HTMLNames::inputTag)) {
553 static_cast<HTMLInputElement*>(node)->setValue(inputValue, DispatchChangeEvent);
554 static_cast<HTMLInputElement*>(node)->blur(); // unfocus input element after set the value
560 void WebPage::getFocusedInputElementValue(String& inputValue)
562 inputValue = String();
564 Frame* frame = m_page->focusController()->focusedOrMainFrame();
567 && frame->document()->focusedNode()) {
568 Node* node = frame->document()->focusedNode();
569 if (node->nodeType() == WebCore::Node::ELEMENT_NODE)
570 if (node->hasTagName(WebCore::HTMLNames::inputTag))
571 inputValue = (static_cast<WebCore::HTMLInputElement*>(node))->value();
576 #if ENABLE(TIZEN_READER)
577 void WebPage::checkPageForReader(uint64_t callbackID)
582 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
583 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
584 static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page)
586 IntRect focusedRect = IntRect(0, 0, 0, 0);
587 Node* node = hitTestResult.innerNode();
588 bool isFocusRingDrawable = false;
589 Node* focusableNode = node;
590 while (focusableNode) {
591 RenderObject* renderer = focusableNode->renderer();
592 if (renderer && renderer->isRoot())
595 if (focusableNode->isFocusable()) {
596 if (focusableNode->isLink() || focusableNode->hasTagName(HTMLNames::inputTag))
597 isFocusRingDrawable = true;
601 focusableNode = focusableNode->parentNode();
604 if (!isFocusRingDrawable)
607 if (!hitTestResult.absoluteImageURL().isEmpty()) {
609 IntRect imageNodeRect = pixelSnappedIntRect(node->getRect());
610 if (!focusableNode->renderRect(&isReplaced).isEmpty() && imageNodeRect.contains(pixelSnappedIntRect(focusableNode->getRect()))) {
611 // If render rect of focusableNode is empty and rect of imageNode include rect of focusableNode,
612 // we have to get rect of focusableNode.
613 // for example - The rect of google logo image in www.google.com pc site's search result page is bigger than rect of focusableNode.
614 // for example - The rect of category menu image in www.gmarket.co.kr pc site is bigger than rect of focusableNode.
615 focusedRect = pixelSnappedIntRect(focusableNode->getRect());
618 // otherwise we have to get rect of imageNode.
619 // for example - The render rect of images in www.pudelek.pl is empty.
620 // for example - The rect of focusableNode of 'Test your browser GO' image in peacekeeper.futuremark.com is bigger than rect of 'Test your browser GO' image.
621 focusedRect = imageNodeRect;
622 focusableNode = node;
625 // If focusedNode have multiple child nodes, we have to unite rect of child nodes.
626 // for example - links in www.google.com's search result page.
627 IntRect tempRect = IntRect(0, 0, 0, 0);
628 for (Node* childNode = focusableNode->firstChild(); childNode; childNode = childNode->traverseNextNode(focusableNode)) {
630 if (focusableNode->renderRect(&isReplaced).contains(childNode->getRect()))
631 tempRect.unite(pixelSnappedIntRect(childNode->getRect()));
634 // If tempRect is empty or rect of focusableNode include tempRect,
635 // we have to get rect of focusableNode.
636 // for example - list menu item in m.naver.com.
637 // otherwise we have to get rect of tempRect.
638 if (tempRect.isEmpty() || focusableNode->getRect().contains(tempRect))
639 focusedRect = pixelSnappedIntRect(focusableNode->getRect());
641 focusedRect = tempRect;
644 // We have to get render rect from ancestor node if current focusedRect is empty.
645 // for example - The rect of naver logo image in www.naver.com pc site is empty.
647 for (Node* loopNode = focusableNode; loopNode && focusedRect.isEmpty(); loopNode = loopNode->parentNode()) {
648 RenderObject* renderer = loopNode->renderer();
649 if (renderer && renderer->isRoot())
652 focusedRect = pixelSnappedIntRect(loopNode->renderRect(&isReplaced));
655 Frame* mainFrame = page->mainFrame();
656 Frame* nodeFrame = focusableNode->document()->frame();
658 while (nodeFrame && nodeFrame != mainFrame) {
659 owner = nodeFrame->ownerElement();
663 focusedRect.setX(focusedRect.x() + owner->getRect().x());
664 focusedRect.setY(focusedRect.y() + owner->getRect().y());
665 nodeFrame = owner->document()->frame();
668 // The y position of tab menu item in www.google.com is negative value,
669 // so we do not want to draw focus ring in that case.
670 if ((focusedRect.x() < 0) || (focusedRect.y() < 0))
671 focusedRect = IntRect(0, 0, 0, 0);
677 void WebPage::hitTestResultAtPoint(const IntPoint& point, int hitTestMode, WebHitTestResult::Data& hitTestResultData)
679 Frame* frame = m_page->focusController()->focusedOrMainFrame();
680 FrameView* frameView = frame->view();
684 HitTestResult hitTestResult = frame->eventHandler()->hitTestResultAtPoint(frameView->windowToContents(point), false);
685 hitTestResultData.absoluteImageURL = hitTestResult.absoluteImageURL().string();
686 hitTestResultData.absoluteLinkURL = hitTestResult.absoluteLinkURL().string();
687 hitTestResultData.absoluteMediaURL = hitTestResult.absoluteMediaURL().string();
688 hitTestResultData.linkLabel = hitTestResult.textContent();
689 hitTestResultData.linkTitle = hitTestResult.titleDisplayString();
691 int context = WebHitTestResult::HitTestResultContextDocument;
693 if (!hitTestResult.absoluteLinkURL().isEmpty())
694 context |= WebHitTestResult::HitTestResultContextLink;
695 if (!hitTestResult.absoluteImageURL().isEmpty())
696 context |= WebHitTestResult::HitTestResultContextImage;
697 if (!hitTestResult.absoluteMediaURL().isEmpty())
698 context |= WebHitTestResult::HitTestResultContextMedia;
699 if (hitTestResult.isSelected())
700 context |= WebHitTestResult::HitTestResultContextSelection;
701 if (hitTestResult.isContentEditable())
702 context |= WebHitTestResult::HitTestResultContextEditable;
703 if (hitTestResult.innerNonSharedNode() && hitTestResult.innerNonSharedNode()->isTextNode())
704 context |= WebHitTestResult::HitTestResultContextText;
706 hitTestResultData.context = context;
707 hitTestResultData.hitTestMode = hitTestMode;
709 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
710 hitTestResultData.focusedRect = getFocusedRect(hitTestResult, m_page.get());
713 if (hitTestResultData.hitTestMode & WebHitTestResult::HitTestModeNodeData) {
714 WebCore::Node* hitNode = hitTestResult.innerNonSharedNode();
716 hitTestResultData.nodeData.nodeValue = hitNode->nodeValue();
718 if ((hitTestResultData.context & WebHitTestResult::HitTestResultContextText) && hitNode->parentNode())
719 hitNode = hitNode->parentNode(); // if hittest inner node is Text node, fill tagName with parent node's info and fill attributeMap with parent node's attributes.
721 if (hitNode->isElementNode()) {
722 WebCore::Element* hitElement = static_cast<WebCore::Element*>(hitNode);
724 hitTestResultData.nodeData.tagName = hitElement->tagName();
728 WebCore::NamedNodeMap* namedNodeMap = hitNode->attributes();
730 for (size_t i = 0; i < namedNodeMap->length(); i++) {
731 WebCore::Attribute* attribute = namedNodeMap->element()->attributeItem(i);
732 String key = attribute->name().toString();
733 String value = attribute->value();
734 hitTestResultData.nodeData.attributeMap.add(key, value);
739 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
740 hitTestResultData.nodeData.isScrollableNodeFocused = false;
741 hitTestResultData.nodeData.enclosingWebLayerID = 0;
742 WebCore::RenderObject* renderer = hitTestResult.innerNode() ? hitTestResult.innerNode()->renderer() : 0;
744 if (renderer->isBoxModelObject() && renderer->hasLayer() && toRenderBoxModelObject(renderer)->layer()->hasAcceleratedTouchScrolling()) {
745 hitTestResultData.nodeData.isScrollableNodeFocused = true;
746 WebCore::GraphicsLayer* scrollingContentsLayer = renderer->enclosingLayer()->layerForScrollingContents();
747 hitTestResultData.nodeData.enclosingWebLayerID = scrollingContentsLayer ? toWebGraphicsLayer(scrollingContentsLayer)->id() : 0;
749 frame->eventHandler()->setMousePressNode(hitTestResult.innerNode());
752 renderer = renderer->parent();
757 if ((hitTestResultData.hitTestMode & WebHitTestResult::HitTestModeImageData) && (hitTestResultData.context & WebHitTestResult::HitTestResultContextImage)) {
758 WebCore::Image* hitImage = hitTestResult.image();
759 if (hitImage && hitImage->data() && hitImage->data()->data()) {
760 hitTestResultData.imageData.dataReference = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>(hitImage->data()->data()), hitImage->data()->size());
761 hitTestResultData.imageData.fileNameExtension = hitImage->filenameExtension();
767 #if ENABLE(TIZEN_SUPPORT_RSS_LINK_PARSING)
768 void WebPage::getRssItems(uint64_t callbackID)
770 if (!m_page->mainFrame())
772 Document* document = m_page->mainFrame()->document();
775 RefPtr<HTMLAllCollection>collection = document->all();
777 WTF::String Rss("application/rss+xml");
778 WTF::String Atom("application/atom+xml");
779 WTF::String Alternate("alternate");
781 Vector<RssItemEfl> rssItems;
783 for (Node* node = collection->firstItem(); node; node = collection->nextItem()) {
784 HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(node);
785 if (linkElement->rel() == Alternate) {
786 RssItemEfl::LinkTypeEfl type;
787 if (linkElement->type() == Rss)
788 type = RssItemEfl::LINK_TYPE_EFL_RSS;
789 else if (linkElement->type() == Atom)
790 type = RssItemEfl::LINK_TYPE_EFL_ATOM;
794 RssItemEfl rssItem(linkElement->href(), linkElement->title(), type);
795 rssItems.append(rssItem);
798 send(Messages::WebPageProxy::GetRssItemsCallback(rssItems, callbackID));
802 #endif // #if ENABLE(TIZEN_SUPPORT_RSS_LINK_PARSING)
804 #if ENABLE(TIZEN_WEB_STORAGE)
805 void WebPage::getStorageQuotaBytes(uint64_t callbackID)
807 uint32_t quota = m_page->group().groupSettings()->localStorageQuotaBytes();
808 send(Messages::WebPageProxy::DidGetWebStorageQuotaBytes(quota, callbackID));
811 void WebPage::setStorageQuotaBytes(uint32_t quota)
813 m_page->group().groupSettings()->setLocalStorageQuotaBytes(quota);
817 #if ENABLE(TIZEN_WEBKIT2_THEME_SET)
818 void WebPage::setThemePath(const String& path)
820 Frame* mainFrame = m_page->mainFrame();
824 WebCore::FrameView* view = mainFrame->view();
826 view->setEdjeTheme(path);
827 WebCore::RenderThemeEfl* theme = static_cast<RenderThemeEfl*>(m_page->theme());
828 theme->themeChanged();
833 #if ENABLE(TIZEN_RECORDING_SURFACE_SET)
834 void WebPage::recordingSurfaceSetEnableSet(bool enable)
836 m_recordingSurfaceSetSettings = enable;
840 #if ENABLE(TIZEN_WEBKIT_PASTEBOARD)
841 void WebPage::setDataToPasteboardWithType(const String& data, uint64_t type)
843 Pasteboard::generalPasteboard()->setDataWithType(data, static_cast<Pasteboard::PasteboardDataType>(type));
847 void WebPage::suspendJavaScriptAndResources()
849 Frame* mainFrame = m_page->mainFrame();
853 for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
854 frame->document()->suspendScheduledTasks(WebCore::ActiveDOMObject::PageWillBeSuspended);
855 mainFrame->loader()->suspendAllLoaders();
858 void WebPage::resumeJavaScriptAndResources()
860 Frame* mainFrame = m_page->mainFrame();
864 for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
865 frame->document()->resumeScheduledTasks();
866 mainFrame->loader()->resumeAllLoaders();
869 #if ENABLE(TIZEN_WEBKIT2_REMOTE_WEB_INSPECTOR)
870 void WebPage::startInspectorServer(uint32_t port, uint32_t& allocatedPort)
872 bool ret = WebInspectorServerEfl::server()->startServer(port);
874 allocatedPort = WebInspectorServerEfl::server()->getServerPort();
879 void WebPage::stopInspectorServer(bool& result)
881 result = WebInspectorServerEfl::server()->stopServer();
885 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
886 void WebPage::scrollOverflowWithTrajectoryVector(const WebCore::FloatPoint& trajectoryVector)
888 Frame* frame = m_page->focusController()->focusedOrMainFrame();
891 frame->eventHandler()->scrollOverflow(trajectoryVector);
895 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL)
896 void WebPage::scrollOverflow(const WebCore::FloatPoint& delta, bool& scrolled)
898 scrolled = m_page->focusController()->focusedOrMainFrame()->eventHandler()->scrollOverflow(delta);
901 void WebPage::setPressedNodeAtPoint(const IntPoint& point, bool& pressed)
903 pressed = m_page->focusController()->focusedOrMainFrame()->eventHandler()->setMousePressNodeAtPoint(point);
907 void WebPage::executeEditCommandWithArgument(const String& commandName, const String& argument)
909 executeEditingCommand(commandName, argument);
912 #if ENABLE(TIZEN_FIX_PLUGIN_DOWNLOAD)
913 void WebPage::arePluginsEnabled(bool& enabled)
915 enabled = m_page->settings()->arePluginsEnabled();
917 #endif // ENABLE(TIZEN_FIX_PLUGIN_DOWNLOAD)
919 #if ENABLE(TIZEN_NPAPI)
920 void WebPage::suspendPlugin()
922 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
923 FrameView* view = frame->view();
927 const HashSet<RefPtr<Widget> >* children = view->children();
930 HashSet<RefPtr<Widget> >::const_iterator end = children->end();
931 for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
932 Widget* widget = (*it).get();
933 if (widget->isPluginViewBase()) {
934 PluginView* pluginView = static_cast<PluginView*>(widget);
936 pluginView->suspendPlugin();
942 void WebPage::resumePlugin()
944 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
945 FrameView* view = frame->view();
949 const HashSet<RefPtr<Widget> >* children = view->children();
952 HashSet<RefPtr<Widget> >::const_iterator end = children->end();
953 for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
954 Widget* widget = (*it).get();
955 if (widget->isPluginViewBase()) {
956 PluginView* pluginView = static_cast<PluginView*>(widget);
958 pluginView->resumePlugin();
965 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
966 void WebPage::getTextStyleStateForSelection()
968 Frame* frame = m_page->focusController()->focusedOrMainFrame();
970 int underlineState = frame->editor()->selectionHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "underline");
971 int italicState = frame->editor()->selectionHasStyle(CSSPropertyFontStyle, "italic");
972 int boldState = frame->editor()->selectionHasStyle(CSSPropertyFontWeight, "bold");
974 send(Messages::WebPageProxy::DidGetTextStyleStateForSelection(underlineState, italicState, boldState));
978 #endif // #if OS(TIZEN)
980 } // namespace WebKit