e73fcd7110e2a4cb0c4d1b6c202daa26e32082f5
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebPage / efl / WebPageEfl.cpp
1 /*
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.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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.
14  *
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.
26  */
27
28 #include "config.h"
29 #include "WebPage.h"
30
31 #include "EditorState.h"
32 #include "NamedNodeMap.h"
33 #include "NotImplemented.h"
34 #include "WebEvent.h"
35 #include "WindowsKeyboardCodes.h"
36 #include <WebCore/EflKeyboardUtilities.h>
37 #include <WebCore/FocusController.h>
38 #include <WebCore/Frame.h>
39 #include <WebCore/FrameView.h>
40 #include <WebCore/KeyboardEvent.h>
41 #include <WebCore/Page.h>
42 #include <WebCore/PlatformKeyboardEvent.h>
43 #include <WebCore/RenderThemeEfl.h>
44 #include <WebCore/Settings.h>
45
46 #if OS(TIZEN)
47 #include "Arguments.h"
48 #include "GraphicsContext.h"
49 #include "WebCoreArgumentCoders.h"
50 #include "WebFrame.h"
51 #include "WebImage.h"
52 #include "WebPageProxyMessages.h"
53 #include <WebCore/FrameView.h>
54
55 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
56 #include <WebCore/HTMLInputElement.h>
57 #include <WebCore/HTMLNames.h>
58 #endif
59
60 #if ENABLE(TIZEN_MULTIPLE_SELECT)
61 #include "WebPopupMenu.h"
62 #include <WebCore/PopupMenuClient.h>
63 #endif
64
65 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
66 #include <WebCore/PlatformContextCairo.h>
67 #endif
68
69 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
70 #include <WebCore/ClipboardTizen.h>
71 #endif
72
73 #if ENABLE(TIZEN_PASTEBOARD)
74 #include <WebCore/Pasteboard.h>
75 #endif
76
77 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
78 #include "WebInspectorServerTizen.h"
79 #endif
80
81 #if ENABLE(TIZEN_WEB_STORAGE)
82 #include <WebCore/GroupSettings.h>
83 #include <WebCore/PageGroup.h>
84 #endif
85
86 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
87 #include "PluginView.h"
88 #endif
89
90 #if ENABLE(TIZEN_PREFERENCE)
91 #include "WebPreferencesStore.h"
92 #include <WebCore/Settings.h>
93 #endif
94
95 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
96 #include <WebCore/HTMLFrameOwnerElement.h>
97 #include <WebCore/HTMLImageElement.h>
98 #endif
99
100 #if ENABLE(TIZEN_DEVICE_ORIENTATION)
101 #include "DeviceMotionClientTizen.h"
102 #include "DeviceOrientationClientTizen.h"
103 #endif
104
105 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
106 #include "RenderLayer.h"
107 #include "WebGraphicsLayer.h"
108 #include <WebCore/RenderView.h>
109 #endif
110
111 #if ENABLE(TIZEN_ISF_PORT)
112 #include <WebCore/Text.h>
113 #include <WebCore/EditorClient.h>
114 #endif
115
116 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION) || ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
117 #include "EditorClient.h"
118 #endif
119
120 #if ENABLE(TIZEN_DATALIST_ELEMENT)
121 #include "HTMLCollection.h"
122 #include "HTMLDataListElement.h"
123 #include "HTMLOptionElement.h"
124 #endif
125
126 #if ENABLE(TIZEN_STYLE_SCOPED)
127 #include <WebCore/RuntimeEnabledFeatures.h>
128 #endif
129
130 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
131 #include "htmlediting.h"
132 #endif
133
134 #if ENABLE(TIZEN_LINK_MAGNIFIER)
135 #include "LinkMagnifier.h"
136 #endif
137
138 #if ENABLE(TIZEN_SCREEN_READER)
139 #include "WebEventConversion.h"
140 #endif
141
142 #if ENABLE(TIZEN_SCREEN_READER) || ENABLE(TIZEN_FOCUS_UI) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
143 #include <WebCore/HTMLAreaElement.h>
144 #endif
145
146 #if ENABLE(TIZEN_CSP)
147 #include <WebCore/ContentSecurityPolicy.h>
148 #endif
149
150 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
151 #include "WebPageSerializerTizen.h"
152 #endif
153
154 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
155 #include "fontconfig/fontconfig.h"
156 #include <WebCore/FontCache.h>
157 #endif
158
159 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
160 #include "visible_units.h"
161 #endif
162 #endif // #if OS(TIZEN)
163
164 using namespace WebCore;
165
166 namespace WebKit {
167
168 void WebPage::platformInitialize()
169 {
170 #if ENABLE(TIZEN_DEVICE_ORIENTATION)
171     WebCore::provideDeviceMotionTo(m_page.get(), new DeviceMotionClientTizen);
172     WebCore::provideDeviceOrientationTo(m_page.get(), new DeviceOrientationClientTizen);
173 #endif
174 }
175
176 #if ENABLE(TIZEN_PREFERENCE)
177 void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store)
178 {
179     Settings* settings = m_page->settings();
180     settings->setInteractiveFormValidationEnabled(store.getBoolValueForKey(WebPreferencesKey::interactiveFormValidationEnabledKey()));
181     settings->setUsesEncodingDetector(store.getBoolValueForKey(WebPreferencesKey::usesEncodingDetectorKey()));
182 #if ENABLE(TIZEN_LOAD_REMOTE_IMAGES)
183     settings->setLoadRemoteImages(store.getBoolValueForKey(WebPreferencesKey::loadRemoteImagesKey()));
184 #endif
185 #if ENABLE(TIZEN_LINK_EFFECT)
186     settings->setLinkEffectEnabled(store.getBoolValueForKey(WebPreferencesKey::linkEffectEnabledKey()));
187 #endif
188 #if ENABLE(TIZEN_ISF_PORT)
189     settings->setEnableDefaultKeypad(store.getBoolValueForKey(WebPreferencesKey::defaultKeypadEnabledKey()));
190 #endif
191 #if ENABLE(TIZEN_STYLE_SCOPED)
192     WebCore::RuntimeEnabledFeatures::setStyleScopedEnabled(store.getBoolValueForKey(WebPreferencesKey::styleScopedEnabledKey()));
193 #endif
194 #if ENABLE(TIZEN_WEB_AUDIO)
195     settings->setWebAudioEnabled(true);
196 #endif
197 }
198 #else
199 void WebPage::platformPreferencesDidChange(const WebPreferencesStore&)
200 {
201     notImplemented();
202 }
203 #endif // #if ENABLE(TIZEN_PREFERENCE)
204
205 static inline void scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
206 {
207     page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
208 }
209
210 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboardEvent)
211 {
212     notImplemented();
213     return false;
214 }
215
216 bool WebPage::platformHasLocalDataForURL(const KURL&)
217 {
218     notImplemented();
219     return false;
220 }
221
222 String WebPage::cachedResponseMIMETypeForURL(const KURL&)
223 {
224     notImplemented();
225     return String();
226 }
227
228 bool WebPage::platformCanHandleRequest(const ResourceRequest&)
229 {
230     notImplemented();
231     return true;
232 }
233
234 String WebPage::cachedSuggestedFilenameForURL(const KURL&)
235 {
236     notImplemented();
237     return String();
238 }
239
240 PassRefPtr<SharedBuffer> WebPage::cachedResponseDataForURL(const KURL&)
241 {
242     notImplemented();
243     return 0;
244 }
245
246 const char* WebPage::interpretKeyEvent(const KeyboardEvent* event)
247 {
248     ASSERT(event->type() == eventNames().keydownEvent || event->type() == eventNames().keypressEvent);
249
250     if (event->type() == eventNames().keydownEvent)
251         return getKeyDownCommandName(event);
252
253     return getKeyPressCommandName(event);
254 }
255
256 void WebPage::setThemePath(const String& themePath)
257 {
258     WebCore::RenderThemeEfl* theme = static_cast<WebCore::RenderThemeEfl*>(m_page->theme());
259     theme->setThemePath(themePath);
260 }
261
262 static Frame* targetFrameForEditing(WebPage* page)
263 {
264     Frame* frame = page->corePage()->focusController()->focusedOrMainFrame();
265     if (!frame)
266         return 0;
267
268     Editor* editor = frame->editor();
269     if (!editor->canEdit())
270         return 0;
271
272     if (editor->hasComposition()) {
273         // We should verify the parent node of this IME composition node are
274         // editable because JavaScript may delete a parent node of the composition
275         // node. In this case, WebKit crashes while deleting texts from the parent
276         // node, which doesn't exist any longer.
277         if (PassRefPtr<Range> range = editor->compositionRange()) {
278             Node* node = range->startContainer();
279             if (!node || !node->isContentEditable())
280                 return 0;
281         }
282     }
283
284     return frame;
285 }
286
287 void WebPage::confirmComposition(const String& compositionString)
288 {
289     Frame* targetFrame = targetFrameForEditing(this);
290     if (!targetFrame)
291         return;
292
293     targetFrame->editor()->confirmComposition(compositionString);
294
295 #if ENABLE(TIZEN_ISF_PORT)
296     m_page->editorClient()->respondToChangedSelection(targetFrame);
297 #endif
298 }
299
300 void WebPage::setComposition(const String& compositionString, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t cursorPosition)
301 {
302     Frame* targetFrame = targetFrameForEditing(this);
303     if (!targetFrame)
304         return;
305
306 #if ENABLE(TIZEN_ISF_PORT)
307     if (targetFrame->selection()->rootEditableElement()) {
308         HTMLTextFormControlElement* textFormControl = toTextFormControl(targetFrame->selection()->rootEditableElement()->shadowAncestorNode());
309         if (textFormControl && textFormControl->maxLength() >= 0) {
310             unsigned availableLength = textFormControl->maxLength() - textFormControl->value().length();
311             if (targetFrame->editor()->hasComposition())
312                 availableLength += (targetFrame->editor()->compositionEnd() - targetFrame->editor()->compositionStart());
313             if (!availableLength)
314                 return;
315
316             if (availableLength < compositionString.length()) {
317                 String newCompositionString = compositionString.substring(0, availableLength);
318                 Vector<CompositionUnderline> newUnderlines;
319                 size_t numUnderlines = underlines.size();
320                 for (size_t index = 0; index < numUnderlines; ++index) {
321                     if (underlines[index].startOffset < availableLength) {
322                         newUnderlines.append(underlines[index]);
323                         if (newUnderlines.last().endOffset > availableLength)
324                             newUnderlines.last().endOffset = availableLength;
325                     }
326                 }
327                 targetFrame->editor()->setComposition(newCompositionString, newUnderlines, cursorPosition, 0);
328                 return;
329             }
330         }
331     }
332 #endif
333
334     targetFrame->editor()->setComposition(compositionString, underlines, cursorPosition, 0);
335
336 #if ENABLE(TIZEN_ISF_PORT)
337     m_page->editorClient()->respondToChangedSelection(targetFrame);
338 #endif
339 }
340
341 void WebPage::cancelComposition()
342 {
343     Frame* frame = m_page->focusController()->focusedOrMainFrame();
344     if (!frame)
345         return;
346
347     frame->editor()->cancelComposition();
348 }
349
350 #if OS(TIZEN)
351
352 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
353 IntSize WebPage::contentsSize() const
354 {
355     FrameView* frameView = m_page->mainFrame()->view();
356     if (!frameView)
357         return IntSize(0, 0);
358
359     return frameView->contentsSize();
360 }
361 #endif
362
363 void WebPage::scrollMainFrameBy(const IntSize& scrollOffset)
364 {
365     m_page->mainFrame()->view()->scrollBy(scrollOffset);
366 }
367
368 void WebPage::scrollMainFrameTo(const IntPoint& scrollPosition)
369 {
370     m_page->mainFrame()->view()->setScrollPosition(scrollPosition);
371 }
372
373 void WebPage::createSnapshot(const IntRect rect, float scaleFactor, ShareableBitmap::Handle& snapshotHandle)
374 {
375     FrameView* frameView = m_mainFrame->coreFrame()->view();
376     if (!frameView)
377         return;
378
379     RefPtr<WebImage> snapshotImage = scaledSnapshotInViewCoordinates(rect, scaleFactor, ImageOptionsShareable);
380     if (!snapshotImage || !snapshotImage->bitmap())
381         return;
382
383     snapshotImage->bitmap()->createHandle(snapshotHandle);
384 }
385
386 void WebPage::requestUpdateFormNavigation()
387 {
388     Frame* frame = m_page->focusController()->focusedOrMainFrame();
389     if (!frame)
390         return;
391
392     Document* document = frame->document();
393     if (!document)
394         return;
395
396     Node* focusedNode = document->focusedNode();
397
398     Vector<RefPtr<Node> > focusableNodes;
399     document->getFocusableNodes(focusableNodes);
400
401     int formElementCount = 0;
402     int currentNodeIndex = -1;
403     const Vector<RefPtr<Node> >::iterator end = focusableNodes.end();
404     for (Vector<RefPtr<Node> >::iterator it = focusableNodes.begin(); it != end; ++it) {
405         AtomicString nodeName = (*it).get()->nodeName();
406         if (equalIgnoringCase(nodeName, "SELECT")
407             || (equalIgnoringCase(nodeName, "INPUT")
408                 && !equalIgnoringCase((*it).get()->toInputElement()->type(), "CHECKBOX")
409                 && !equalIgnoringCase((*it).get()->toInputElement()->type(), "RADIO")
410                 && !equalIgnoringCase((*it).get()->toInputElement()->type(), "SUBMIT")
411                 )
412             ) {
413             if ((*it).get() == focusedNode)
414                 currentNodeIndex = formElementCount;
415             formElementCount++;
416         }
417     }
418
419     if (currentNodeIndex == -1)
420         return;
421
422     send(Messages::WebPageProxy::UpdateFormNavigation(formElementCount, currentNodeIndex));
423 }
424
425 void WebPage::moveFocus(int newIndex)
426 {
427     Frame* frame = m_page->focusController()->focusedOrMainFrame();
428     if (!frame)
429         return;
430
431     Document* document = frame->document();
432     if (!document)
433         return;
434
435     Vector<RefPtr<Node> > focusableNodes;
436     document->getFocusableNodes(focusableNodes);
437
438     int index = 0;
439     const Vector<RefPtr<Node> >::iterator end = focusableNodes.end();
440     for (Vector<RefPtr<Node> >::iterator it = focusableNodes.begin(); it != end; ++it) {
441         AtomicString nodeName = (*it).get()->nodeName();
442         if (equalIgnoringCase(nodeName, "SELECT")) {
443             if (index == newIndex) {
444                 (*it).get()->setFocus();
445                 LayoutPoint position = LayoutPoint(0, 0);
446                 PlatformMouseEvent event(flooredIntPoint(position), flooredIntPoint(position), LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0);
447                 (*it).get()->dispatchMouseEvent(event, "mousedown", 0, 0);
448             }
449             index++;
450         } else if (equalIgnoringCase(nodeName, "INPUT")
451             && !equalIgnoringCase((*it).get()->toInputElement()->type(), "CHECKBOX")
452             && !equalIgnoringCase((*it).get()->toInputElement()->type(), "RADIO")
453             ) {
454             if (index == newIndex) {
455                 HTMLInputElement* elem = (*it).get()->toInputElement();
456                 elem->focus();
457             }
458             index++;
459         }
460     }
461 }
462
463 #if ENABLE(TIZEN_MOBILE_WEB_PRINT)
464 #define INCH_TO_MM 25.4
465 #define INCH_TO_POINTS 72.0
466
467 void WebPage::createPagesToPDF(const IntSize& surfaceSize, const IntSize& contentsSize, const String& fileName)
468 {
469     FrameView* frameView = m_mainFrame->coreFrame()->view();
470     if (!frameView)
471         return;
472
473     RefPtr<WebImage> pageshotImage = WebImage::create(contentsSize, ImageOptionsShareable);
474     if (!pageshotImage->bitmap())
475         return;
476
477     double pdfWidth = (double)surfaceSize.width() / INCH_TO_MM * INCH_TO_POINTS;
478     double pdfHeight = (double)surfaceSize.height() / INCH_TO_MM * INCH_TO_POINTS;
479     double scaleFactorPdf = 1.0;
480     if (contentsSize.width() > pdfWidth)
481         scaleFactorPdf = pdfWidth / (double)contentsSize.width();
482
483     OwnPtr<WebCore::GraphicsContext> graphicsContext = pageshotImage->bitmap()->createGraphicsContextForPdfSurface(fileName, pdfWidth, pdfHeight);
484     graphicsContext->scale(FloatSize(scaleFactorPdf, scaleFactorPdf));
485
486     frameView->updateLayoutAndStyleIfNeededRecursive();
487
488     int pageNumber = ((contentsSize.height() * scaleFactorPdf) / pdfHeight) + 1;
489     float paintY = 0.0;
490
491     PaintBehavior oldBehavior = frameView->paintBehavior();
492     frameView->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
493     for (int i = 0; i < pageNumber; i++) {
494         IntRect paintRect(0, (int)paintY, contentsSize.width(), (int)(pdfHeight / scaleFactorPdf));
495
496         frameView->paint(graphicsContext.get(), paintRect);
497         cairo_show_page(graphicsContext->platformContext()->cr());
498         graphicsContext->translate(0, -ceil(pdfHeight / scaleFactorPdf));
499         paintY += (pdfHeight / scaleFactorPdf);
500     }
501     frameView->setPaintBehavior(oldBehavior);
502
503     pageshotImage.release();
504 }
505 #endif
506
507 #if ENABLE(TIZEN_TEXT_CARET_HANDLING_WK2)
508 bool WebPage::setCaretPosition(const IntPoint& pos)
509 {
510     Frame* frame = m_page->focusController()->focusedOrMainFrame();
511     if (!frame)
512         return false;
513
514     FrameSelection* controller = frame->selection();
515     if (!controller)
516         return false;
517
518     FrameView* frameView = frame->view();
519     if (!frameView)
520         return false;
521
522     IntPoint point = m_page->mainFrame()->view()->windowToContents(pos);
523     HitTestResult result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, /*allowShadowContent*/ true, /*ignoreClipping*/ true);
524     if (result.scrollbar())
525         return false;
526
527     Node* innerNode = result.innerNode();
528
529     if (!innerNode || !innerNode->renderer())
530         return false;
531
532     VisiblePosition visiblePos;
533
534     // we check if content is richly editable - because those input field behave other than plain text ones
535     // sometimes they may consists a node structure and they need special approach
536     if (innerNode->rendererIsRichlyEditable()) {
537         // point gets inner node local coordinates
538         point = flooredIntPoint(result.localPoint());
539         IntRect rect = innerNode->renderer()->absoluteBoundingBoxRect(true);
540
541         // it is not the best way to do this, but it is not as slow and it works - so maybe in the future someone
542         // will have a better idea how to solve it
543         // here we are getting innerNode from HitTestResult - unfortunately this is a kind of high level node
544         // in the code below I am trying to obtain low level node - #text - to get its coordinates and size
545
546         // all those getting nodes rects are needed to bypass WebCore's methods of positioning caret when user
547         // is clicking outside a node - and cheat WebCore telling it that actually we clicked into input field
548         // node, not outside of it
549         Node* deepInnerNode = innerNode->renderer()->positionForPoint(point).deepEquivalent().deprecatedNode();
550
551         if (!deepInnerNode || !deepInnerNode->renderer())
552             return false;
553
554         // so we get a base node rectange
555         IntRect deepNodeRect = deepInnerNode->renderer()->absoluteBoundingBoxRect(true);
556
557         // we modify our local point to adjust it to base node local coordinates
558         point.move(rect.x() - deepNodeRect.x(), rect.y() - deepNodeRect.y());
559
560         // if we are outside the rect we cheat, that we are just inside of it
561         if (point.y() < 0)
562             point.setY(0);
563         else if (point.y() >= deepNodeRect.height())
564             point.setY(deepNodeRect.height() - 1);
565
566         // visible position created - caret ready to set
567         visiblePos = deepInnerNode->renderer()->positionForPoint(point);
568         if (visiblePos.isNull())
569             return false;
570     } else {
571         // for plain text input fields we can get only a caret bounding box
572         if (!controller->isCaret() || !controller->caretRenderer())
573             return false;
574
575         const Node* node = controller->start().deprecatedNode();
576         if (!node || !node->renderer())
577             return false;
578
579         IntRect rect = controller->caretRenderer()->absoluteBoundingBoxRect(true);
580
581         // The below wirtten code is not correct way to implement. Presntly the is no
582         // other working way. To be replaced by better logic
583         // here we also cheat input field that we actually are just inside of if
584         IntPoint focusedFramePoint = frame->view()->windowToContents(pos);
585         IntPoint oldFocusedFramePoint = focusedFramePoint;
586
587         const int boundariesWidth = 2;
588         if (focusedFramePoint.x() < rect.x())
589             focusedFramePoint.setX(rect.x());
590         else if (focusedFramePoint.x() > rect.maxX())
591             focusedFramePoint.setX(rect.maxX());
592         if (focusedFramePoint.y() < rect.y() + boundariesWidth)
593             focusedFramePoint.setY(rect.y() + boundariesWidth);
594         else if (focusedFramePoint.y() >= rect.maxY() - boundariesWidth)
595             focusedFramePoint.setY(rect.maxY() - boundariesWidth - 1);
596
597         int diffX = focusedFramePoint.x() - oldFocusedFramePoint.x();
598         int diffY = focusedFramePoint.y() - oldFocusedFramePoint.y();
599         point.setX((point.x())+diffX);
600         point.setY((point.y())+diffY);
601
602         // hit test with fake (adjusted) coordinates
603         IntPoint hitTestPoint = m_page->mainFrame()->view()->windowToContents(point);
604         HitTestResult newResult = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(hitTestPoint, /*allowShadowContent*/ true, /*ignoreClipping*/ true);
605
606         if (!newResult.isContentEditable())
607             return false;
608
609         Node* newInnerNode = newResult.innerNode();
610
611         if (!newInnerNode || !newInnerNode->renderer())
612             return false;
613
614         // visible position created
615         visiblePos = newInnerNode->renderer()->positionForPoint(newResult.localPoint());
616         if (visiblePos.isNull())
617             return false;
618     }
619
620     // create visible selection from visible position
621     VisibleSelection newSelection = VisibleSelection(visiblePos);
622     controller->setSelection(newSelection, CharacterGranularity);
623     // after setting selection caret blinking is suspended by default so we are unsuspedning it
624     controller->setCaretBlinkingSuspended(false);
625
626     return true;
627 }
628
629 void WebPage::getCaretPosition(IntRect& rect)
630 {
631     Frame* frame = m_page->focusController()->focusedOrMainFrame();
632     if (!frame)
633         return;
634
635     FrameSelection* controller = frame->selection();
636     if (!controller)
637         return;
638
639     Node* node = controller->start().deprecatedNode();
640     if (!node || !node->renderer() || !node->isContentEditable())
641         return;
642
643     if (controller->isCaret()) {
644         FrameView* frameView = frame->view();
645         if (!frameView)
646             return;
647
648         rect = frameView->contentsToWindow(controller->absoluteCaretBounds());
649     }
650 }
651 #endif
652
653 #if ENABLE(TIZEN_ISF_PORT)
654 void WebPage::didCancelComposition(Node* valueChangedNode)
655 {
656     Frame* frame = m_page->focusController()->focusedOrMainFrame();
657     if (!frame || frame->editor()->ignoreCompositionSelectionChange() || !valueChangedNode->containsIncludingShadowDOM(frame->editor()->compositionNode()))
658         return;
659
660     frame->editor()->cancelComposition();
661     send(Messages::WebPageProxy::DidCancelComposition());
662 }
663
664 void WebPage::getCursorOffset(int& offset)
665 {
666     offset = 0;
667     Frame* frame = m_page->focusController()->focusedOrMainFrame();
668     if (!frame || !frame->editor()->canEdit())
669         return;
670
671     Position base = frame->selection()->base();
672     Node* baseNode = base.containerNode();
673     if (baseNode)
674         offset = baseNode->isTextNode() ? base.offsetInContainerNode() : 0;
675 }
676
677 void WebPage::getSurroundingTextAndCursorOffset(String& text, int& offset)
678 {
679     text = String();
680     offset = 0;
681
682     Frame* frame = m_page->focusController()->focusedOrMainFrame();
683     if (!frame || !frame->editor()->canEdit())
684         return;
685
686     Position base = frame->selection()->base();
687     Node* baseNode = base.containerNode();
688     if (baseNode && baseNode->isTextNode()) {
689         text = baseNode->textContent();
690         offset = base.offsetInContainerNode();
691     }
692 }
693
694 void WebPage::getSelectionRect(bool isOnlyEditable, IntRect& rect)
695 {
696     rect = IntRect();
697
698     Frame* frame = m_page->focusController()->focusedFrame();
699     if (!frame || !frame->view())
700         return;
701
702     FrameSelection* selection = frame->selection();
703     Node* node = selection->start().deprecatedNode();
704     if (!node || !node->renderer() || (isOnlyEditable && !node->isContentEditable()))
705         return;
706
707     if (selection->isCaret())
708         rect = frame->view()->contentsToWindow(selection->absoluteCaretBounds());
709     else if (selection->isRange())
710         rect = frame->view()->contentsToWindow(enclosingIntRect(selection->bounds(false)));
711 }
712
713 void WebPage::deleteSurroundingText(int offset, int count)
714 {
715     Frame* frame = m_page->focusController()->focusedOrMainFrame();
716     if (!frame || !frame->editor()->canEdit())
717         return;
718
719     Position base(frame->selection()->base());
720     offset += base.offsetInContainerNode();
721     base.moveToOffset(offset);
722     Position extent(base);
723     extent.moveToOffset(offset + count);
724     VisibleSelection selection(base, extent);
725     if (!selection.isRange())
726         return;
727
728     frame->selection()->setSelection(selection);
729     frame->editor()->deleteWithDirection(DirectionBackward, CharacterGranularity, false, true);
730 }
731 #endif
732
733 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION) || ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
734 void WebPage::setFocusedInputElementValue(const String& inputValue)
735 {
736     Frame* frame = m_page->focusController()->focusedOrMainFrame();
737     if (!frame || !frame->document() || !frame->document()->focusedNode())
738         return;
739
740     HTMLInputElement* inputElement = frame->document()->focusedNode()->toInputElement();
741     if (!inputElement)
742         return;
743
744     inputElement->toNode()->dispatchFocusEvent(0);
745     inputElement->setValue(inputValue, DispatchChangeEvent);
746 }
747
748 void  WebPage::getFocusedInputElementValue(String& inputValue)
749 {
750     inputValue = String();
751
752     Frame* frame = m_page->focusController()->focusedOrMainFrame();
753     if (!frame || !frame->document() || !frame->document()->focusedNode())
754         return;
755
756     HTMLInputElement* inputElement = frame->document()->focusedNode()->toInputElement();
757     if (!inputElement)
758         return;
759
760     inputValue = inputElement->value();
761 }
762 #endif
763
764 #if ENABLE(TIZEN_DATALIST_ELEMENT)
765 void WebPage::getFocusedInputElementDataList(Vector<String>& optionList)
766 {
767     Frame* frame = m_page->focusController()->focusedOrMainFrame();
768     if (!frame || !frame->document())
769         return;
770
771     Node* node = frame->document()->focusedNode();
772     if (!node)
773         return;
774
775     HTMLInputElement* input = node->toInputElement();
776     if (!input)
777         return;
778
779     HTMLDataListElement* dataList = static_cast<HTMLDataListElement*>(input->list());
780     if (!dataList)
781         return;
782
783     RefPtr<HTMLCollection> options = static_cast<HTMLDataListElement*>(dataList)->options();
784     for (unsigned i = 0; Node* node = options->item(i); i++) {
785         HTMLOptionElement* optionElement = static_cast<HTMLOptionElement*>(node);
786         String value = optionElement->value();
787         optionList.append(value);
788     }
789 }
790 #endif
791
792 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
793 static IntRect getNodeRect(Node* node, Node* focusableNode, bool isImage)
794 {
795     IntRect rect;
796
797     if (isImage) {
798         bool isReplaced;
799         IntRect imageNodeRect = pixelSnappedIntRect(node->getRect());
800         if (!focusableNode->renderRect(&isReplaced).isEmpty() && imageNodeRect.contains(pixelSnappedIntRect(focusableNode->getRect()))) {
801             // If render rect of focusableNode is empty and rect of imageNode include rect of focusableNode,
802             // we have to get rect of focusableNode.
803             // for example - The rect of google logo image in www.google.com pc site's search result page is bigger than rect of focusableNode.
804             // for example - The rect of category menu image in www.gmarket.co.kr pc site is bigger than rect of focusableNode.
805             rect = pixelSnappedIntRect(focusableNode->getRect());
806         }
807         else {
808             // otherwise we have to get rect of imageNode.
809             // for example - The render rect of images in www.pudelek.pl is empty.
810             // 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.
811             rect = imageNodeRect;
812             focusableNode = node;
813         }
814     } else {
815         // If focusedNode have multiple child nodes, we have to unite rect of child nodes.
816         // for example - links in www.google.com's search result page.
817         IntRect tempRect;
818         for (Node* childNode = focusableNode->firstChild(); childNode; childNode = childNode->traverseNextNode(focusableNode)) {
819             bool isReplaced;
820             if (focusableNode->renderRect(&isReplaced).contains(childNode->getRect()))
821                 tempRect.unite(pixelSnappedIntRect(childNode->getRect()));
822         }
823
824         // If tempRect is empty or rect of focusableNode include tempRect,
825         // we have to get rect of focusableNode.
826         // for example - list menu item in m.naver.com.
827         // otherwise we have to get rect of tempRect.
828         // getRect API do not return correct rect if the node is a container node,
829         // hence using absoluteBoundingBoxRect to get the correct bounding rect.
830         LayoutRect renderRect = focusableNode->renderer() ? focusableNode->renderer()->absoluteBoundingBoxRect() : focusableNode->getRect();
831         if (tempRect.isEmpty() || renderRect.contains(tempRect))
832             rect = pixelSnappedIntRect(renderRect);
833         else
834             rect = tempRect;
835     }
836
837     // We have to get render rect from ancestor node if current rect is empty.
838     // for example - The rect of naver logo image in www.naver.com pc site is empty.
839     bool isReplaced;
840     for (Node* loopNode = focusableNode; loopNode && rect.isEmpty(); loopNode = loopNode->parentNode()) {
841         RenderObject* renderer = loopNode->renderer();
842         if (renderer && renderer->isRoot())
843             break;
844
845         rect = pixelSnappedIntRect(loopNode->renderRect(&isReplaced));
846     }
847
848     Frame* nodeFrame = focusableNode->document()->frame();
849     Node* owner;
850     while (nodeFrame && (owner = nodeFrame->ownerElement())) {
851         rect.moveBy(owner->getRect().pixelSnappedLocation());
852         nodeFrame = owner->document()->frame();
853     }
854
855     // The y position of tab menu item in www.google.com is negative value,
856     // so we do not want to draw focus ring in that case.
857     if ((rect.maxX() < 0) || (rect.maxY() < 0))
858         rect = IntRect();
859
860     return rect;
861 }
862 #endif
863
864 #if ENABLE(TIZEN_WEBKIT2_HIT_TEST)
865 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
866 static IntRect getFocusedRect(HitTestResult hitTestResult, Page* page)
867 {
868     Node* node = hitTestResult.innerNode();
869     if (!node)
870         return IntRect();
871
872     bool isFocusRingDrawable = false;
873     Node* focusableNode = node;
874     while (focusableNode) {
875         RenderObject* renderer = focusableNode->renderer();
876         if (renderer && renderer->isRoot())
877             break;
878
879         if (focusableNode->isFocusable()) {
880             if (focusableNode->isLink()
881                 || focusableNode->hasTagName(HTMLNames::inputTag)
882                 || focusableNode->hasTagName(HTMLNames::selectTag)
883                 || focusableNode->hasTagName(HTMLNames::buttonTag))
884                 isFocusRingDrawable = true;
885             break;
886         }
887
888         focusableNode = focusableNode->parentNode();
889     }
890
891     if (!isFocusRingDrawable) {
892         if (node->hasTagName(HTMLNames::imgTag))
893             return getNodeRect(node, node, !hitTestResult.absoluteImageURL().isEmpty());
894
895         return IntRect();
896     }
897
898     return getNodeRect(node, focusableNode, !hitTestResult.absoluteImageURL().isEmpty());
899 }
900 #endif
901
902 void WebPage::hitTestResultAtPoint(const IntPoint& point, int hitTestMode, WebHitTestResult::Data& hitTestResultData)
903 {
904     Frame* frame = m_page->mainFrame();
905     FrameView* frameView = frame->view();
906     if (!frameView)
907         return;
908
909     HitTestResult hitTestResult = frame->eventHandler()->hitTestResultAtPoint(frameView->windowToContents(point), false);
910     hitTestResultData.absoluteImageURL = hitTestResult.absoluteImageURL().string();
911     hitTestResultData.absoluteLinkURL = hitTestResult.absoluteLinkURL().string();
912     hitTestResultData.absoluteMediaURL = hitTestResult.absoluteMediaURL().string();
913     hitTestResultData.linkLabel = hitTestResult.textContent();
914     hitTestResultData.linkTitle = hitTestResult.titleDisplayString();
915     hitTestResultData.isContentEditable = hitTestResult.isContentEditable();
916 #if ENABLE(TIZEN_DRAG_SUPPORT)
917     hitTestResultData.isDragSupport = hitTestResult.isDragSupport();
918 #endif
919
920     int context = WebHitTestResult::HitTestResultContextDocument;
921
922     if (!hitTestResult.absoluteLinkURL().isEmpty())
923         context |= WebHitTestResult::HitTestResultContextLink;
924     if (!hitTestResult.absoluteImageURL().isEmpty())
925         context |= WebHitTestResult::HitTestResultContextImage;
926     if (!hitTestResult.absoluteMediaURL().isEmpty())
927         context |= WebHitTestResult::HitTestResultContextMedia;
928     if (hitTestResult.isSelected())
929         context |= WebHitTestResult::HitTestResultContextSelection;
930     if (hitTestResult.isContentEditable())
931         context |= WebHitTestResult::HitTestResultContextEditable;
932     if (hitTestResult.innerNonSharedNode() && hitTestResult.innerNonSharedNode()->isTextNode())
933         context |= WebHitTestResult::HitTestResultContextText;
934
935     hitTestResultData.context = context;
936     hitTestResultData.hitTestMode = hitTestMode;
937
938 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
939     hitTestResultData.focusedRect = getFocusedRect(hitTestResult, m_page.get());
940     if (hitTestResult.innerNode() && hitTestResult.innerNode()->renderer() && hitTestResult.innerNode()->renderer()->style()) {
941         hitTestResultData.focusedColor = hitTestResult.innerNode()->renderer()->style()->tapHighlightColor();
942         if (!hitTestResultData.focusedColor.hasAlpha())
943             hitTestResultData.focusedColor = Color(hitTestResultData.focusedColor.red(), hitTestResultData.focusedColor.green(), hitTestResultData.focusedColor.blue(), RenderStyle::initialTapHighlightColor().alpha());
944     }
945 #endif
946
947     if (hitTestResultData.hitTestMode & WebHitTestResult::HitTestModeNodeData) {
948         WebCore::Node* hitNode = hitTestResult.innerNonSharedNode();
949         if (hitNode) {
950             hitTestResultData.nodeData.nodeValue = hitNode->nodeValue();
951
952             if ((hitTestResultData.context & WebHitTestResult::HitTestResultContextText) && hitNode->parentNode())
953                 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.
954
955             if (hitNode->isElementNode()) {
956                 WebCore::Element* hitElement = static_cast<WebCore::Element*>(hitNode);
957                 if (hitElement) {
958                     hitTestResultData.nodeData.tagName = hitElement->tagName();
959                 }
960             }
961
962             WebCore::NamedNodeMap* namedNodeMap = hitNode->attributes();
963             if (namedNodeMap) {
964                 for (size_t i = 0; i < namedNodeMap->length(); i++) {
965                     const WebCore::Attribute* attribute = namedNodeMap->element()->attributeItem(i);
966                     String key = attribute->name().toString();
967                     String value = attribute->value();
968                     hitTestResultData.nodeData.attributeMap.add(key, value);
969                 }
970             }
971         }
972     }
973
974     if ((hitTestResultData.hitTestMode & WebHitTestResult::HitTestModeImageData) && (hitTestResultData.context & WebHitTestResult::HitTestResultContextImage)) {
975         WebCore::Image* hitImage = hitTestResult.image();
976         if (hitImage && hitImage->data() && hitImage->data()->data()) {
977             hitTestResultData.imageData.data.append(hitImage->data()->data(), hitImage->data()->size());
978             hitTestResultData.imageData.fileNameExtension = hitImage->filenameExtension();
979         }
980     }
981 }
982 #endif
983
984 #if ENABLE(TIZEN_WEB_STORAGE)
985 void WebPage::getStorageQuotaBytes(uint64_t callbackID)
986 {
987     uint32_t quota = m_page->group().groupSettings()->localStorageQuotaBytes();
988     send(Messages::WebPageProxy::DidGetWebStorageQuotaBytes(quota, callbackID));
989 }
990
991 void WebPage::setStorageQuotaBytes(uint32_t quota)
992 {
993     m_page->group().groupSettings()->setLocalStorageQuotaBytes(quota);
994 }
995 #endif
996
997 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
998 void WebPage::setClipboardDataForPaste(const String& data, const String& type)
999 {
1000 #if ENABLE(TIZEN_PASTEBOARD)
1001     // FIXME: Should move to EditorClient like Clipboard
1002     Pasteboard::generalPasteboard()->setDataWithType(data, type);
1003 #else
1004     Frame* mainFrame = m_page->mainFrame();
1005     if (!mainFrame)
1006         return;
1007
1008     mainFrame->editor()->client()->setClipboardDataForPaste(data, type);
1009 #endif
1010 }
1011 #endif
1012
1013 void WebPage::suspendJavaScriptAndResources()
1014 {
1015     Frame* mainFrame = m_page->mainFrame();
1016     if (!mainFrame)
1017         return;
1018
1019     for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
1020         frame->document()->suspendScheduledTasks(WebCore::ActiveDOMObject::PageWillBeSuspended);
1021     mainFrame->loader()->suspendAllLoaders();
1022 }
1023
1024 void WebPage::resumeJavaScriptAndResources()
1025 {
1026     Frame* mainFrame = m_page->mainFrame();
1027     if (!mainFrame)
1028         return;
1029
1030     for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
1031         frame->document()->resumeScheduledTasks();
1032     mainFrame->loader()->resumeAllLoaders();
1033 }
1034
1035 void WebPage::suspendAnimations()
1036 {
1037     Frame* mainFrame = m_page->mainFrame();
1038     if (!mainFrame)
1039         return;
1040
1041     for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
1042         frame->animation()->suspendAnimationsForDocument(frame->document());
1043 }
1044
1045 void WebPage::resumeAnimations()
1046 {
1047     Frame* mainFrame = m_page->mainFrame();
1048     if (!mainFrame)
1049         return;
1050
1051     for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
1052         frame->animation()->resumeAnimationsForDocument(frame->document());
1053 }
1054
1055 #if ENABLE(TIZEN_SYNC_REQUEST_ANIMATION_FRAME)
1056 void WebPage::suspendAnimationController()
1057 {
1058     if (!m_suspendedAnimationController) {
1059         Frame* mainFrame = m_page->mainFrame();
1060         if (!mainFrame)
1061             return;
1062
1063         for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
1064             frame->document()->suspendScriptedAnimationControllerCallbacks();
1065
1066         m_suspendedAnimationController = true;
1067     }
1068 }
1069
1070 void WebPage::resumeAnimationController()
1071 {
1072     if (m_suspendedAnimationController) {
1073         Frame* mainFrame = m_page->mainFrame();
1074         if (!mainFrame)
1075             return;
1076
1077         for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext())
1078             frame->document()->resumeScriptedAnimationControllerCallbacks();
1079
1080         m_suspendedAnimationController = false;
1081     }
1082 }
1083 #endif
1084
1085 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
1086 void WebPage::startInspectorServer(uint32_t port,  uint32_t& allocatedPort)
1087 {
1088     bool ret = WebInspectorServerTizen::server()->startServer(port);
1089     if (ret)
1090         allocatedPort = WebInspectorServerTizen::server()->getServerPort();
1091     else
1092         allocatedPort = 0;
1093 }
1094
1095 void WebPage::stopInspectorServer(bool& result)
1096 {
1097     result = WebInspectorServerTizen::server()->stopServer();
1098 }
1099 #endif
1100
1101 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1102 void WebPage::scrollOverflowWithTrajectoryVector(const WebCore::FloatPoint& trajectoryVector)
1103 {
1104     Frame* frame = m_page->focusController()->focusedOrMainFrame();
1105     if (!frame)
1106         return;
1107     frame->eventHandler()->scrollOverflow(trajectoryVector);
1108 }
1109 #endif
1110
1111 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1112 void WebPage::scrollOverflow(const WebCore::FloatPoint& delta, bool& scrolled)
1113 {
1114     scrolled = m_page->focusController()->focusedOrMainFrame()->eventHandler()->scrollOverflow(delta);
1115 }
1116
1117 void WebPage::setPressedNodeAtPoint(const IntPoint& point, bool checkOverflowLayer, bool& pressed, uint32_t& id)
1118 {
1119     RenderObject* renderer = 0;
1120     id = 0;
1121     pressed = m_page->mainFrame()->eventHandler()->setMousePressNodeAtPoint(point, checkOverflowLayer, renderer);
1122 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1123     if (pressed && renderer)
1124         id = toWebGraphicsLayer(renderer->enclosingLayer()->layerForScrollingContents())->id();
1125 #endif
1126 }
1127 #endif
1128
1129 void WebPage::executeEditCommandWithArgument(const String& commandName, const String& argument)
1130 {
1131     executeEditingCommand(commandName, argument);
1132 }
1133
1134 #if ENABLE(TIZEN_PLUGIN_SUSPEND_RESUME)
1135 void WebPage::suspendPlugin()
1136 {
1137     for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1138         FrameView* view = frame->view();
1139         if (!view)
1140             continue;
1141
1142         const HashSet<RefPtr<Widget> >* children = view->children();
1143         ASSERT(children);
1144
1145         HashSet<RefPtr<Widget> >::const_iterator end = children->end();
1146         for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
1147             Widget* widget = (*it).get();
1148             if (widget->isPluginViewBase()) {
1149                 PluginView* pluginView = static_cast<PluginView*>(widget);
1150                 if (pluginView)
1151                     pluginView->suspendPlugin();
1152             }
1153         }
1154     }
1155 }
1156
1157 void WebPage::resumePlugin()
1158 {
1159     for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
1160         FrameView* view = frame->view();
1161         if (!view)
1162             continue;
1163
1164         const HashSet<RefPtr<Widget> >* children = view->children();
1165         ASSERT(children);
1166
1167         HashSet<RefPtr<Widget> >::const_iterator end = children->end();
1168         for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
1169             Widget* widget = (*it).get();
1170             if (widget->isPluginViewBase()) {
1171                 PluginView* pluginView = static_cast<PluginView*>(widget);
1172                 if (pluginView)
1173                     pluginView->resumePlugin();
1174             }
1175         }
1176     }
1177 }
1178 #endif
1179
1180 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1181 void WebPage::getTextStyleStateForSelection()
1182 {
1183     Frame* frame = m_page->focusController()->focusedOrMainFrame();
1184
1185     int underlineState = frame->editor()->selectionHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "underline");
1186     int italicState = frame->editor()->selectionHasStyle(CSSPropertyFontStyle, "italic");
1187     int boldState = frame->editor()->selectionHasStyle(CSSPropertyFontWeight, "bold");
1188
1189     send(Messages::WebPageProxy::DidGetTextStyleStateForSelection(underlineState, italicState, boldState));
1190 }
1191 #endif
1192
1193 #if ENABLE(TIZEN_MULTIPLE_SELECT)
1194 void WebPage::didChangeSelectedIndexForActivePopupMenuMultiple(Vector<int32_t> newIndex)
1195 {
1196     if (!m_activePopupMenu)
1197         return;
1198
1199     m_activePopupMenu->client()->popupDidHide();
1200
1201     size_t indexSize = newIndex.size();
1202     for (size_t i = 0; i < indexSize; i++)
1203         m_activePopupMenu->didChangeSelectedIndex(newIndex.at(i));
1204
1205 }
1206 #endif
1207
1208 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1209 void WebPage::startOfflinePageSave(String subresourceFolderName)
1210 {
1211     WebPageSerializerTizen::getSerializedPageContent(this, subresourceFolderName);
1212 }
1213 #endif
1214
1215 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1216 void WebPage::selectClosestWord(const IntPoint& point, bool isStartedTextSelectionFromOutside, bool& result)
1217 {
1218     result = false;
1219
1220     Frame* mainFrame = m_page->mainFrame();
1221     Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
1222
1223     HitTestResult hitTestResult = mainFrame->eventHandler()->hitTestResultAtPoint(m_page->mainFrame()->view()->windowToContents(point), false);
1224
1225     Node* node = hitTestResult.innerNonSharedNode();
1226     if (!node)
1227         return;
1228
1229      Frame* newFocusFrame = node->document()->frame();
1230      if (focusedFrame != newFocusFrame) {
1231          m_page->focusController()->setFocusedFrame(newFocusFrame);
1232          focusedFrame = newFocusFrame;
1233      }
1234
1235 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1236     HTMLInputElement* inputElement = node->toInputElement();
1237 #endif
1238
1239     if (hitTestResult.isContentEditable()) {
1240 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1241         if (!inputElement || (inputElement
1242             && !inputElement->isDateField() && !inputElement->isDateTimeField() && !inputElement->isDateTimeLocalField()
1243             && !inputElement->isMonthField() && !inputElement->isTimeField() && !inputElement->isWeekField())) {
1244             result = setCaretPosition(point);
1245             return;
1246         }
1247 #else
1248         result = setCaretPosition(point);
1249         return;
1250 #endif
1251     }
1252
1253 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1254     if (!node->isTextNode() && !inputElement)
1255 #else
1256     if (!node->isTextNode())
1257 #endif
1258         return;
1259
1260 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
1261     if (inputElement
1262         && (inputElement->isDateField() || inputElement->isDateTimeField() || inputElement->isDateTimeLocalField()
1263         || inputElement->isMonthField() || inputElement->isTimeField() || inputElement->isWeekField())) {
1264         if (inputElement->value().isEmpty())
1265             return;
1266     }
1267 #endif
1268
1269     if (!isStartedTextSelectionFromOutside) {
1270         for (Node* node = hitTestResult.innerNonSharedNode(); node; node = node->parentNode()) {
1271             if (node->isFocusable()) {
1272                 // Text selection shoud not be started when text of <button> tag is selected.
1273                 if (node->hasTagName(HTMLNames::buttonTag))
1274                     return;
1275                 break;
1276             }
1277         }
1278     }
1279
1280     FrameSelection* frameSelection = focusedFrame->selection();
1281
1282     VisiblePosition position = mainFrame->visiblePositionForPoint(point);
1283     VisibleSelection selection(position);
1284
1285     // This changes just the 'start' and 'end' positions of the VisibleSelection
1286     selection.expandUsingGranularity(WordGranularity);
1287
1288     FrameSelection::SetSelectionOptions options = FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle | FrameSelection::DoNotSetFocus;
1289     frameSelection->setSelection(VisibleSelection(selection.start(), selection.end()), options);
1290
1291     if (!frameSelection->isRange())
1292         return;
1293
1294     // This changes just the 'start' and 'end' positions of the VisibleSelection
1295     // Find handlers positions
1296     IntRect leftRect, rightRect;
1297     getSelectionHandlers(leftRect, rightRect);
1298     if (leftRect.size().isZero() && rightRect.size().isZero()) {
1299         // Sometimes there is no selected text, but isNone() returns TRUE
1300         // in this case ewk_frame_selection_handlers_get() returns FALSE and handlers are invalid
1301         // Workaround - clear the selection.
1302         // Better solution would be to modify the ewk_frame_select_closest_word()
1303         // to not select anything in the first place (for example - don't call setSelection()
1304         // if there is nothing under the cursor).
1305         selectionClearAllSelection(m_page->mainFrame());
1306         return;
1307     }
1308
1309     result = true;
1310 }
1311
1312 void WebPage::setLeftSelection(const IntPoint& point, bool& result)
1313 {
1314     result = false;
1315
1316     Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
1317     FrameSelection* frameSelection = focusedFrame->selection();
1318     if (!frameSelection->isRange())
1319         return;
1320
1321     Node* selectionEndNode = frameSelection->end().deprecatedNode();
1322     if (!selectionEndNode || !selectionEndNode->renderer())
1323         return;
1324
1325     FrameView* frameView = focusedFrame->view();
1326     if (!frameView)
1327         return;
1328
1329     IntPoint pos = frameView->windowToContents(point);
1330     IntRect leftRect, rightRect;
1331     getSelectionHandlers(leftRect, rightRect);
1332     if ((rightRect.y() + rightRect.height()) < pos.y())
1333         pos.setY(rightRect.y() + (rightRect.height()/2));
1334
1335     if (selectionEndNode->rendererIsEditable() && !selectionEndNode->rendererIsRichlyEditable()) {
1336         const int boundariesWidth = 2;
1337
1338         IntRect rect = frameSelection->caretRenderer()->absoluteBoundingBoxRect(true);
1339         // here we cheat input field that we actually are just inside of if
1340         if (pos.y() < rect.y() + boundariesWidth)
1341             pos.setY(rect.y() + boundariesWidth);
1342         else if (pos.y() >= rect.maxY() - boundariesWidth)
1343             pos.setY(rect.maxY() - boundariesWidth - 1);
1344     }
1345
1346     OwnPtr<VisiblePosition> position = adoptPtr(new VisiblePosition(focusedFrame->visiblePositionForPoint(pos)));
1347     Position extent = frameSelection->extent();
1348
1349     Node* newSelectionStartNode = position->deepEquivalent().deprecatedNode();
1350
1351     // both start and end nodes should be in the same area type: both should be editable or both should be not editable
1352     // Check if the new position is before the extent's position
1353     if (newSelectionStartNode
1354         && selectionEndNode->isContentEditable() == newSelectionStartNode->isContentEditable()
1355         && comparePositions(position->deepEquivalent(), extent) < 0) {
1356         // Change the 'base' and 'extent' positions to 'start' and 'end' positions.
1357         // We do it, because without this, the other modification of the selection
1358         // would destroy the 'start' and/or 'end' positions and set them to
1359         // the 'base'/'extent' positions accordingly
1360         VisibleSelection sel(frameSelection->start(), frameSelection->end());
1361         frameSelection->setSelection(sel);
1362
1363         bool oldProhibitsScrolling = focusedFrame->view()->prohibitsScrolling();
1364         focusedFrame->view()->setProhibitsScrolling(true);
1365
1366         frameSelection->setBase(*position);
1367
1368         focusedFrame->view()->setProhibitsScrolling(oldProhibitsScrolling);
1369         // This forces webkit to show selection
1370         // m_coreFrame->invalidateSelection();
1371
1372         result = true;
1373     }
1374 }
1375
1376
1377 void WebPage::setRightSelection(const IntPoint& point, bool& result)
1378 {
1379     result = false;
1380
1381     Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
1382     FrameSelection* frameSelection = focusedFrame->selection();
1383
1384     if (!frameSelection->isRange())
1385         return;
1386
1387     Node* selectionStartNode = frameSelection->start().deprecatedNode();
1388     if (!selectionStartNode || !selectionStartNode->renderer())
1389         return;
1390
1391     FrameView* frameView = focusedFrame->view();
1392     if (!frameView)
1393         return;
1394
1395     IntPoint pos = frameView->windowToContents(point);
1396     if (selectionStartNode->rendererIsEditable() && !selectionStartNode->rendererIsRichlyEditable()) {
1397         const int boundariesWidth = 2;
1398
1399         IntRect rect = frameSelection->caretRenderer()->absoluteBoundingBoxRect(true);
1400         // here we cheat input field that we actually are just inside of if
1401         if (pos.y() < rect.y() + boundariesWidth)
1402             pos.setY(rect.y() + boundariesWidth);
1403         else if (pos.y() >= rect.maxY() - boundariesWidth)
1404             pos.setY(rect.maxY() - boundariesWidth - 1);
1405     }
1406
1407     OwnPtr<VisiblePosition> position = adoptPtr(new VisiblePosition(focusedFrame->visiblePositionForPoint(pos)));
1408     Position base = frameSelection->base();
1409
1410     Node* newSelectionEndNode = position->deepEquivalent().deprecatedNode();
1411
1412     // both start and end nodes should be in the same area type: both should be editable or both should be not editable
1413     // Check if the new position is after the base's position
1414     if (newSelectionEndNode
1415         && selectionStartNode->isContentEditable() == newSelectionEndNode->isContentEditable()
1416         && comparePositions(position->deepEquivalent(), base) > 0) {
1417         // Change the 'base' and 'extent' positions to 'start' and 'end' positions.
1418         // We do it, because without this, the other modifications of the selection
1419         // would destroy the 'start' and/or 'end' positions and set them to
1420         // the 'base'/'extent' positions accordingly
1421
1422         VisibleSelection sel(frameSelection->start(), frameSelection->end());
1423         frameSelection->setSelection(sel);
1424
1425         bool oldProhibitsScrolling = focusedFrame->view()->prohibitsScrolling();
1426         focusedFrame->view()->setProhibitsScrolling(true);
1427
1428         frameSelection->setExtent(*position);
1429
1430         focusedFrame->view()->setProhibitsScrolling(oldProhibitsScrolling);
1431
1432         result = true;
1433     }
1434 }
1435
1436 void WebPage::getSelectionHandlers(IntRect& leftRect, IntRect& rightRect)
1437 {
1438     Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
1439     if (!focusedFrame->selection()->isRange())
1440         return;
1441
1442     // Is this check necessary? Leaving it for safety.
1443     RenderView* root = focusedFrame->contentRenderer();
1444     if (!root)
1445         return;
1446
1447     RefPtr<Range> selectedRange = focusedFrame->selection()->toNormalizedRange();
1448
1449     Vector<IntRect> rects;
1450     selectedRange->boundingBoxEx(rects, true);
1451
1452     unsigned size = rects.size();
1453     if (size > 0) {
1454         leftRect = rects[0];
1455         rightRect = rects[size-1];
1456
1457         // If selection rect size is greater than editor rect size because of round operation,
1458         // selection rect size should be changed to editor rect size.
1459         if (size == 1) {
1460             Element* selectionRoot = focusedFrame->selection()->rootEditableElement();
1461             if (selectionRoot) {
1462                 IntRect editorRect = focusedFrame->view()->contentsToWindow(selectionRoot->getPixelSnappedRect());
1463
1464 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1465                 if (m_editorState.editorRect != editorRect) {
1466                     EditorState state = editorState();
1467                     state.updateEditorRectOnly = true;
1468                     setEditorState(state);
1469                     send(Messages::WebPageProxy::EditorStateChanged(state));
1470                 }
1471 #endif
1472
1473                 if (leftRect.maxY() > editorRect.maxY()) {
1474                     leftRect.setY(editorRect.y());
1475                     leftRect.setHeight(editorRect.height());
1476                 }
1477
1478                 if (rightRect.maxY() > editorRect.maxY()) {
1479                     rightRect.setY(editorRect.y());
1480                     rightRect.setHeight(editorRect.height());
1481                 }
1482             }
1483         }
1484
1485         // prevent from selecting zero-length selection
1486         if (leftRect.x() == rightRect.x() + rightRect.width()
1487             && leftRect.y() == rightRect.y())
1488             return;
1489
1490         FrameView* frameView = focusedFrame->view();
1491         if (!frameView)
1492             return;
1493
1494         leftRect = frameView->contentsToWindow(leftRect);
1495         rightRect = frameView->contentsToWindow(rightRect);
1496      }
1497 }
1498
1499 void WebPage::getSelectionText(String& result)
1500 {
1501     Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
1502     result = focusedFrame->editor()->selectedText();
1503 }
1504
1505 void WebPage::selectionRangeClear(bool& result)
1506 {
1507     result = false;
1508
1509     Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
1510     FrameSelection* frameSelection = focusedFrame->selection();
1511     if (frameSelection && frameSelection->isRange() && frameSelection->isContentEditable()) {
1512         VisiblePosition visiblePos(frameSelection->extent());
1513         if (visiblePos.isNull())
1514             return;
1515
1516         focusedFrame->editor()->setIgnoreCompositionSelectionChange(true);
1517         frameSelection->setSelection(VisibleSelection(visiblePos), CharacterGranularity);
1518         focusedFrame->editor()->setIgnoreCompositionSelectionChange(false);
1519
1520         frameSelection->setCaretBlinkingSuspended(false);
1521     } else
1522         selectionClearAllSelection(m_page->mainFrame());
1523
1524     result = true;
1525 }
1526
1527 void WebPage::selectionClearAllSelection(Frame* frame)
1528 {
1529     if (!frame)
1530         return;
1531
1532     FrameSelection* frameSelection = frame->selection();
1533     if (frameSelection)
1534         frameSelection->clear();
1535
1536     if (!frame->tree())
1537         return;
1538
1539     if (frame->tree()->childCount() > 0) {
1540         if (frame->tree()->firstChild())
1541             selectionClearAllSelection(frame->tree()->firstChild());
1542     } else if (frame->tree()->nextSibling())
1543         selectionClearAllSelection(frame->tree()->nextSibling());
1544 }
1545
1546 void WebPage::scrollContentByCharacter(const IntPoint&, int direction, bool& result)
1547 {
1548     result = false;
1549
1550     Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
1551     if (!focusedFrame)
1552         return;
1553
1554     FrameSelection* frameSelection = focusedFrame->selection();
1555     if (!frameSelection)
1556         return;
1557
1558     VisiblePosition currentPosition = frameSelection->selection().visibleStart();
1559     if (direction) {
1560         if (isStartOfLine(currentPosition))
1561             return;
1562
1563         focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, CharacterGranularity, UserTriggered);
1564     } else {
1565         if (isEndOfLine(currentPosition))
1566             return;
1567
1568         focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, CharacterGranularity, UserTriggered);
1569     }
1570 }
1571
1572 void WebPage::scrollContentByLine(const IntPoint&, int direction, bool& result)
1573 {
1574     result = false;
1575
1576     Frame* focusedFrame = m_page->focusController()->focusedOrMainFrame();
1577     if (!focusedFrame)
1578         return;
1579
1580     FrameSelection* frameSelection = focusedFrame->selection();
1581     if (!frameSelection)
1582         return;
1583
1584     VisiblePosition currentPosition = frameSelection->selection().visibleStart();
1585     if (direction) {
1586         if (inSameLine(currentPosition, previousLinePosition(currentPosition, 0)))
1587             return;
1588
1589         focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionBackward, LineGranularity, UserTriggered);
1590     } else {
1591         if (inSameLine(currentPosition, nextLinePosition(currentPosition, 0)))
1592             return;
1593
1594         focusedFrame->selection()->modify(FrameSelection::AlterationMove, DirectionForward, LineGranularity, UserTriggered);
1595     }
1596 }
1597 #endif
1598
1599 #if ENABLE(TIZEN_LINK_MAGNIFIER)
1600 void WebPage::getLinkMagnifierRect(const IntPoint& position, const IntSize& size)
1601 {
1602     send(Messages::WebPageProxy::DidGetLinkMagnifierRect(position, LinkMagnifier::rect(this, position, size)));
1603 }
1604 #endif
1605
1606 #if ENABLE(TIZEN_SCREEN_READER)
1607 void WebPage::raiseTapEvent(const IntPoint& position, const IntPoint& globalPosition)
1608 {
1609     Frame* frame = m_page->mainFrame();
1610     if (!frame->view())
1611         return;
1612
1613     Vector<WebPlatformTouchPoint> touchPoints;
1614     touchPoints.append(WebPlatformTouchPoint(0, WebPlatformTouchPoint::TouchPressed, globalPosition, position));
1615
1616     WebTouchEvent touchStartEvent(WebEvent::TouchStart, touchPoints, WebEvent::Modifiers(0), ecore_time_get());
1617     if (!frame->eventHandler()->handleTouchEvent(platform(touchStartEvent))) {
1618         WebGestureEvent gestureEvent(WebEvent::GestureSingleTap, position, globalPosition, WebEvent::Modifiers(0), ecore_time_get());
1619         frame->eventHandler()->handleGestureEvent(platform(gestureEvent));
1620     }
1621
1622     touchPoints.at(0).setState(WebPlatformTouchPoint::TouchReleased);
1623     WebTouchEvent touchEndEvent(WebEvent::TouchEnd, touchPoints, WebEvent::Modifiers(0), ecore_time_get());
1624     frame->eventHandler()->handleTouchEvent(platform(touchEndEvent));
1625 }
1626
1627 static void sendScreenReaderFocusRect(WebPage* page, Node* node)
1628 {
1629     bool isImage = false;
1630     if (node->isElementNode()) {
1631         Element* element = static_cast<Element*>(node);
1632         isImage = !element->getAttribute(element->imageSourceAttributeName()).isEmpty();
1633     }
1634
1635     page->send(Messages::WebPageProxy::DidScreenReaderFocusRectChanged(getNodeRect(node, node, isImage)));
1636 }
1637
1638 void WebPage::moveScreenReaderFocus(bool forward, bool& result)
1639 {
1640     if (!m_screenReader)
1641         m_screenReader = ScreenReader::create(this);
1642
1643     if (!m_screenReader->moveFocus(forward)) {
1644         result = false;
1645         send(Messages::WebPageProxy::DidScreenReaderFocusRectChanged(IntRect()));
1646         return;
1647     } else {
1648         result = true;
1649         sendScreenReaderFocusRect(this, m_screenReader->getFocusedNode());
1650     }
1651 }
1652
1653 void WebPage::moveScreenReaderFocusByPoint(const IntPoint& point)
1654 {
1655     if (!m_screenReader)
1656         m_screenReader = ScreenReader::create(this);
1657
1658     if (!m_screenReader->moveFocus(point))
1659         return;
1660
1661     sendScreenReaderFocusRect(this, m_screenReader->getFocusedNode());
1662 }
1663
1664 void WebPage::recalcScreenReaderFocusRect()
1665 {
1666     if (!m_screenReader || !m_screenReader->getFocusedNode())
1667         return;
1668
1669     sendScreenReaderFocusRect(this, m_screenReader->getFocusedNode());
1670 }
1671
1672 void WebPage::updateScreenReaderFocus(RenderObject* object)
1673 {
1674     if (!m_screenReader)
1675         return;
1676
1677     if (!object)
1678         m_screenReader->clearFocus();
1679     else if (!m_screenReader->rendererWillBeDestroyed(object))
1680         return;
1681
1682     send(Messages::WebPageProxy::DidScreenReaderFocusRectChanged(IntRect()));
1683 }
1684
1685 void WebPage::clearScreenReader()
1686 {
1687     m_screenReader.clear();
1688 }
1689 #endif
1690
1691 #if ENABLE(TIZEN_SCREEN_READER) || ENABLE(TIZEN_FOCUS_UI) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1692 static LayoutRect rectToAbsoluteCoordinates(Frame* initialFrame, const LayoutRect& initialRect)
1693 {
1694     LayoutRect rect = initialRect;
1695     for (Frame* frame = initialFrame; frame; frame = frame->tree()->parent()) {
1696         RenderBoxModelObject* renderer;
1697         if (frame->ownerElement() && (renderer = frame->ownerElement()->renderBoxModelObject())) {
1698             do {
1699                 rect.move(renderer->offsetLeft(), renderer->offsetTop());
1700             } while ((renderer = renderer->offsetParent()));
1701             rect.move(-frame->view()->scrollOffset());
1702         }
1703     }
1704     return rect;
1705 }
1706
1707 IntRect WebPage::nodeRect(Node* node) const
1708 {
1709     if (!node)
1710         return IntRect();
1711
1712     LayoutRect rect;
1713     if (node->hasTagName(HTMLNames::areaTag)) {
1714         HTMLAreaElement* area = static_cast<HTMLAreaElement*>(node);
1715         HTMLImageElement* image = area->imageElement();
1716         if (!image || !image->renderer())
1717             return IntRect();
1718
1719         rect = rectToAbsoluteCoordinates(area->document()->frame(), area->computeRect(area->imageElement()->renderer()));
1720     } else if (node->renderer()) {
1721         if (node->isDocumentNode())
1722             rect = rectToAbsoluteCoordinates(static_cast<Document*>(node)->frame(), static_cast<Document*>(node)->frame()->view()->visibleContentRect());
1723         else {
1724             rect = node->getRect();
1725             rect.intersect(node->renderer()->absoluteClippedOverflowRect());
1726             rect = rectToAbsoluteCoordinates(node->document()->frame(), rect);
1727
1728             rect.move(node->renderer()->style()->borderLeftWidth(), node->renderer()->style()->borderTopWidth());
1729             rect.setWidth(rect.width() - node->renderer()->style()->borderLeftWidth() - node->renderer()->style()->borderRightWidth());
1730             rect.setHeight(rect.height() - node->renderer()->style()->borderTopWidth() - node->renderer()->style()->borderBottomWidth());
1731         }
1732     }
1733
1734     return pixelSnappedIntRect(rect);
1735 }
1736 #endif
1737
1738 #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL)
1739 // FIXME: Currently with cached pages, hiding Popup list menu is not working correctly.
1740 // This patch is a fix allowing any popup list menu to get close for any page navigation.
1741 void WebPage::notifyTransitionToCommitted(bool forNewPage)
1742 {
1743     if (m_activePopupMenu) {
1744         TIZEN_LOGI("");
1745         m_activePopupMenu->hide();
1746         m_activePopupMenu = 0;
1747     }
1748 }
1749 #endif
1750
1751 #if ENABLE(TIZEN_CSP)
1752 void WebPage::setContentSecurityPolicy(const String& policy, uint32_t headerType)
1753 {
1754     Frame* frame = m_page->focusController()->focusedOrMainFrame();
1755     if (!frame)
1756         return;
1757
1758     Document* document = frame->document();
1759     if (!document)
1760         return;
1761
1762     document->contentSecurityPolicy()->didReceiveHeader(policy, static_cast<WebCore::ContentSecurityPolicy::HeaderType>(headerType));
1763 }
1764 #endif
1765
1766 #if ENABLE(TIZEN_INDEXED_DATABASE)
1767 void WebPage::setIndexedDatabaseDirectory(const String& path)
1768 {
1769     m_page->group().groupSettings()->setIndexedDBDatabasePath(path);
1770 }
1771 #endif
1772
1773 #if ENABLE(TIZEN_WEB_STORAGE)
1774 void WebPage::setLocalStorageDirectory(const String& path)
1775 {
1776     m_page->settings()->setLocalStorageDatabasePath(path);
1777 }
1778 #endif
1779
1780 #if ENABLE(TIZEN_USE_SETTINGS_FONT)
1781 void WebPage::useSettingsFont()
1782 {
1783     if (!WebCore::fontCache()->isFontFamliyTizen())
1784         return;
1785
1786     FcInitReinitialize();
1787     WebCore::fontCache()->invalidate();
1788
1789     FrameView* frameView = m_mainFrame->coreFrame()->view();
1790     if (!frameView)
1791         return;
1792
1793     frameView->forceLayout();
1794 }
1795 #endif
1796
1797 void WebPage::didChangeContents(const IntRect& rect)
1798 {
1799     Frame* frame = m_page->focusController()->focusedOrMainFrame();
1800     if (!frame || !frame->view() || frame->view()->needsLayout())
1801         return;
1802
1803 #if ENABLE(TIZEN_ISF_PORT) || ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1804     if (m_editorState.isContentEditable && rect.intersects(m_editorState.editorRect) && frame->selection()->rootEditableElement()) {
1805         IntRect currentEditorRect = nodeRect(frame->selection()->rootEditableElement());
1806         if (m_editorState.editorRect != currentEditorRect) {
1807             m_editorState.editorRect = currentEditorRect;
1808             m_editorState.updateEditorRectOnly = true;
1809             send(Messages::WebPageProxy::EditorStateChanged(m_editorState));
1810         }
1811     }
1812 #endif
1813 }
1814 #endif // #if OS(TIZEN)
1815
1816 } // namespace WebKit