summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/WebViewImpl.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-25 15:09:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-25 15:09:11 +0200
commita89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd (patch)
treeb7abd9f49ae1d4d2e426a5883bfccd42b8e2ee12 /Source/WebKit/chromium/src/WebViewImpl.cpp
parent8d473cf9743f1d30a16a27114e93bd5af5648d23 (diff)
downloadqtwebkit-a89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd.tar.gz
Imported WebKit commit eb5c1b8fe4d4b1b90b5137433fc58a91da0e6878 (http://svn.webkit.org/repository/webkit/trunk@118516)
Diffstat (limited to 'Source/WebKit/chromium/src/WebViewImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/WebViewImpl.cpp188
1 files changed, 118 insertions, 70 deletions
diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp
index f74c802a9..a8931b120 100644
--- a/Source/WebKit/chromium/src/WebViewImpl.cpp
+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp
@@ -113,6 +113,7 @@
#include "SpeechInputClientImpl.h"
#include "SpeechRecognitionClientProxy.h"
#include "StyleResolver.h"
+#include "Text.h"
#include "TextFieldDecoratorImpl.h"
#include "TextIterator.h"
#include "Timer.h"
@@ -140,6 +141,7 @@
#include "WebRange.h"
#include "WebRuntimeFeatures.h"
#include "WebSettingsImpl.h"
+#include "WebTextInputInfo.h"
#include "WebViewClient.h"
#include "WheelEvent.h"
#include "cc/CCProxy.h"
@@ -202,7 +204,7 @@ const float WebView::minPageScaleFactor = 0.25;
const float WebView::maxPageScaleFactor = 4.0;
-// The group name identifies a namespace of pages. Page group is used on OSX
+// The group name identifies a namespace of pages. Page group is used on PLATFORM(MAC)
// for some programs that use HTML views to display things that don't seem like
// web pages to the user (so shouldn't have visited link coloring). We only use
// one page group.
@@ -1277,6 +1279,11 @@ WebViewImpl* WebViewImpl::fromPage(Page* page)
return static_cast<WebViewImpl*>(chromeClient->webView());
}
+PageGroup* WebViewImpl::defaultPageGroup()
+{
+ return PageGroup::pageGroup(pageGroupName);
+}
+
// WebWidget ------------------------------------------------------------------
void WebViewImpl::close()
@@ -1460,6 +1467,11 @@ void WebViewImpl::willBeginFrame()
m_client->willBeginCompositorFrame();
}
+void WebViewImpl::didBeginFrame()
+{
+ InspectorInstrumentation::didComposite(m_page.get());
+}
+
void WebViewImpl::updateAnimations(double monotonicFrameBeginTime)
{
#if ENABLE(REQUEST_ANIMATION_FRAME)
@@ -1880,60 +1892,113 @@ bool WebViewImpl::compositionRange(size_t* location, size_t* length)
return false;
}
+WebTextInputInfo WebViewImpl::textInputInfo()
+{
+ WebTextInputInfo info;
+
+ Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return info;
+
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return info;
+
+ FrameSelection* selection = focused->selection();
+ if (!selection)
+ return info;
+
+ Node* node = focusedWebCoreNode();
+ if (!node)
+ return info;
+
+ info.type = textInputType();
+ if (info.type == WebTextInputTypeNone)
+ return info;
+
+ if (node->hasTagName(HTMLNames::textareaTag))
+ info.value = static_cast<HTMLTextAreaElement*>(node)->value();
+ else if (node->hasTagName(HTMLNames::inputTag))
+ info.value = static_cast<HTMLInputElement*>(node)->value();
+ else if (node->shouldUseInputMethod())
+ info.value = node->nodeValue();
+ else
+ return info;
+
+ if (info.value.isEmpty())
+ return info;
+
+ if (node->hasTagName(HTMLNames::textareaTag) || node->hasTagName(HTMLNames::inputTag)) {
+ HTMLTextFormControlElement* formElement = static_cast<HTMLTextFormControlElement*>(node);
+ info.selectionStart = formElement->selectionStart();
+ info.selectionEnd = formElement->selectionEnd();
+ if (editor->hasComposition()) {
+ info.compositionStart = formElement->indexForVisiblePosition(Position(editor->compositionNode(), editor->compositionStart()));
+ info.compositionEnd = formElement->indexForVisiblePosition(Position(editor->compositionNode(), editor->compositionEnd()));
+ }
+ } else {
+ info.selectionStart = selection->start().computeOffsetInContainerNode();
+ info.selectionEnd = selection->end().computeOffsetInContainerNode();
+ if (editor->hasComposition()) {
+ info.compositionStart = static_cast<int>(editor->compositionStart());
+ info.compositionEnd = static_cast<int>(editor->compositionEnd());
+ }
+ }
+
+ return info;
+}
+
WebTextInputType WebViewImpl::textInputType()
{
Node* node = focusedWebCoreNode();
if (!node)
return WebTextInputTypeNone;
- if (node->nodeType() == Node::ELEMENT_NODE) {
- Element* element = static_cast<Element*>(node);
- if (element->hasLocalName(HTMLNames::inputTag)) {
- HTMLInputElement* input = static_cast<HTMLInputElement*>(element);
-
- if (input->readOnly() || input->disabled())
- return WebTextInputTypeNone;
-
- if (input->isPasswordField())
- return WebTextInputTypePassword;
- if (input->isSearchField())
- return WebTextInputTypeSearch;
- if (input->isEmailField())
- return WebTextInputTypeEmail;
- if (input->isNumberField())
- return WebTextInputTypeNumber;
- if (input->isTelephoneField())
- return WebTextInputTypeTelephone;
- if (input->isURLField())
- return WebTextInputTypeURL;
- if (input->isDateField())
- return WebTextInputTypeDate;
- if (input->isDateTimeField())
- return WebTextInputTypeDateTime;
- if (input->isDateTimeLocalField())
- return WebTextInputTypeDateTimeLocal;
- if (input->isMonthField())
- return WebTextInputTypeMonth;
- if (input->isTimeField())
- return WebTextInputTypeTime;
- if (input->isWeekField())
- return WebTextInputTypeWeek;
- if (input->isTextField())
- return WebTextInputTypeText;
+ if (node->hasTagName(HTMLNames::inputTag)) {
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
+ if (input->readOnly() || input->disabled())
return WebTextInputTypeNone;
- }
-
- if (element->hasLocalName(HTMLNames::textareaTag)) {
- HTMLTextAreaElement* textarea = static_cast<HTMLTextAreaElement*>(element);
- if (textarea->readOnly() || textarea->disabled())
- return WebTextInputTypeNone;
+ if (input->isPasswordField())
+ return WebTextInputTypePassword;
+ if (input->isSearchField())
+ return WebTextInputTypeSearch;
+ if (input->isEmailField())
+ return WebTextInputTypeEmail;
+ if (input->isNumberField())
+ return WebTextInputTypeNumber;
+ if (input->isTelephoneField())
+ return WebTextInputTypeTelephone;
+ if (input->isURLField())
+ return WebTextInputTypeURL;
+ if (input->isDateField())
+ return WebTextInputTypeDate;
+ if (input->isDateTimeField())
+ return WebTextInputTypeDateTime;
+ if (input->isDateTimeLocalField())
+ return WebTextInputTypeDateTimeLocal;
+ if (input->isMonthField())
+ return WebTextInputTypeMonth;
+ if (input->isTimeField())
+ return WebTextInputTypeTime;
+ if (input->isWeekField())
+ return WebTextInputTypeWeek;
+ if (input->isTextField())
return WebTextInputTypeText;
- }
+
+ return WebTextInputTypeNone;
+ }
+
+ if (node->hasTagName(HTMLNames::textareaTag)) {
+ HTMLTextAreaElement* textarea = static_cast<HTMLTextAreaElement*>(node);
+
+ if (textarea->readOnly() || textarea->disabled())
+ return WebTextInputTypeNone;
+
+ return WebTextInputTypeText;
}
- // For other situations.
if (node->shouldUseInputMethod())
return WebTextInputTypeText;
@@ -3042,7 +3107,7 @@ void WebViewImpl::didCommitLoad(bool* isNewNavigation, bool isNavigationWithinPa
m_newNavigationLoader = 0;
#endif
m_observedNewNavigation = false;
- if (!isNavigationWithinPage)
+ if (*isNewNavigation && !isNavigationWithinPage)
m_pageScaleFactorIsSet = false;
m_gestureAnimation.clear();
@@ -3244,22 +3309,6 @@ bool WebViewImpl::allowsAcceleratedCompositing()
return !m_compositorCreationFailed;
}
-bool WebViewImpl::pageHasRTLStyle() const
-{
- if (!page())
- return false;
- Document* document = page()->mainFrame()->document();
- if (!document)
- return false;
- RenderView* renderView = document->renderView();
- if (!renderView)
- return false;
- RenderStyle* style = renderView->style();
- if (!style)
- return false;
- return (style->direction() == RTL);
-}
-
void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer)
{
m_rootGraphicsLayer = layer;
@@ -3502,6 +3551,11 @@ void WebViewImpl::applyScrollAndScale(const WebSize& scrollDelta, float pageScal
}
}
+void WebViewImpl::willCommit()
+{
+ InspectorInstrumentation::willComposite(m_page.get());
+}
+
void WebViewImpl::didCommit()
{
if (m_client)
@@ -3554,14 +3608,10 @@ void WebViewImpl::updateLayerTreeViewport()
IntRect visibleRect = view->visibleContentRect(true /* include scrollbars */);
IntPoint scroll(view->scrollX(), view->scrollY());
- int layerAdjustX = 0;
- if (pageHasRTLStyle()) {
- // The origin of the initial containing block for RTL root layers is not
- // at the far left side of the layer bounds. Instead, it's one viewport
- // width (not including scrollbars) to the left of the right side of the
- // layer.
- layerAdjustX = -view->contentsSize().width() + view->visibleContentRect(false).width();
- }
+ // In RTL-style pages, the origin of the initial containing block for the
+ // root layer may be positive; translate the layer to avoid negative
+ // coordinates.
+ int layerAdjustX = -view->scrollOrigin().x();
// This part of the deviceScale will be used to scale the contents of
// the NCCH's GraphicsLayer.
@@ -3620,8 +3670,6 @@ void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState,
#if USE(ACCELERATED_COMPOSITING)
if (!m_layerTreeView.isNull()) {
bool visible = visibilityState == WebPageVisibilityStateVisible;
- if (!visible && isAcceleratedCompositingActive())
- m_nonCompositedContentHost->protectVisibleTileTextures();
m_layerTreeView.setVisible(visible);
}
#endif