[BlackBerry] Syncing up left over bits in Api from our local branch to upstream
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 17:17:03 +0000 (17:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Mar 2012 17:17:03 +0000 (17:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81105

Patch by Nima Ghanavatian <nghanavatian@rim.com> on 2012-03-16
Reviewed by Rob Buis.

This patches fixes up a previous sync done in this directory and adds some new bits
as well.  This is accurate as of ddea1528b37b29925638fe1183318b3c3994f1f8 in our
local repo.

* Api/BackingStore.cpp:
(BlackBerry::WebKit::BackingStorePrivate::drawAndBlendLayersForDirectRendering):
(WebKit):
(BlackBerry::WebKit::BackingStorePrivate::drawLayersOnCommitIfNeeded):
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::webContext):
(BlackBerry::WebKit::WebPage::webContext):
(BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
* Api/WebPage.h:
* Api/WebPage_p.h:
(WebPagePrivate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111024 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/blackberry/Api/BackingStore.cpp
Source/WebKit/blackberry/Api/WebPage.cpp
Source/WebKit/blackberry/Api/WebPage.h
Source/WebKit/blackberry/Api/WebPage_p.h
Source/WebKit/blackberry/ChangeLog

index e5806b3aa7302d568d87c90aa2d1800a281d3d29..b4a4addf1141b4eb0e3bf62a7226c7510e913dd0 100644 (file)
@@ -2541,6 +2541,46 @@ bool BackingStorePrivate::drawLayersOnCommitIfNeeded()
     return true;
 }
 
+void BackingStorePrivate::drawAndBlendLayersForDirectRendering(const Platform::IntRect& dirtyRect)
+{
+    ASSERT(BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread());
+    if (!BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread())
+        return;
+
+    // Because we're being called sync from the WebKit thread, we can use
+    // regular WebPage size and transformation functions without concerns.
+    WebCore::IntRect contentsRect = visibleContentsRect();
+    WebCore::FloatRect untransformedContentsRect = m_webPage->d->mapFromTransformedFloatRect(WebCore::FloatRect(contentsRect));
+    WebCore::IntRect contentsScreenRect = m_client->mapFromTransformedContentsToTransformedViewport(contentsRect);
+    WebCore::IntRect dstRect = intersection(contentsScreenRect,
+        WebCore::IntRect(WebCore::IntPoint(0, 0), m_webPage->d->transformedViewportSize()));
+
+    // Check if rendering caused a commit and we need to redraw the layers.
+    m_needsDrawLayersOnCommit = false;
+    m_webPage->d->drawSubLayers(dstRect, untransformedContentsRect);
+
+#if ENABLE_COMPOSITING_SURFACE
+    // See above comment about sync calling, visibleContentsRect() is safe here.
+    Platform::IntRect visibleDirtyRect = dirtyRect;
+    visibleDirtyRect.intersect(visibleContentsRect());
+    visibleDirtyRect = m_client->mapFromTransformedContentsToTransformedViewport(visibleDirtyRect);
+
+    blendCompositingSurface(visibleDirtyRect);
+#endif
+}
+
+bool BackingStorePrivate::drawLayersOnCommitIfNeeded()
+{
+    // Check if rendering caused a commit and we need to redraw the layers
+    if (!m_needsDrawLayersOnCommit)
+        return false;
+
+    m_needsDrawLayersOnCommit = false;
+    m_webPage->d->drawLayersOnCommit();
+
+    return true;
+}
+
 void BackingStorePrivate::drawAndBlendLayersForDirectRendering(const Platform::IntRect& dirtyRect)
 {
     ASSERT(BlackBerry::Platform::userInterfaceThreadMessageClient()->isCurrentThread());
index d0d52b4782c6f69517b46d9e46daf8d8d66a5e34..a5bc3e46acd2e0877764a1635bc63d3044717315 100644 (file)
@@ -55,6 +55,7 @@
 #include "HTMLFrameOwnerElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
+#include "HTMLMediaElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
 #include "HTTPParsers.h"
@@ -2008,9 +2009,9 @@ bool WebPagePrivate::useFixedLayout() const
     return true;
 }
 
-ActiveNodeContext WebPagePrivate::activeNodeContext(TargetDetectionStrategy strategy)
+Platform::WebContext WebPagePrivate::webContext(TargetDetectionStrategy strategy)
 {
-    ActiveNodeContext context;
+    Platform::WebContext context;
 
     RefPtr<Node> node = contextNode(strategy);
     m_currentContextNode = node;
@@ -2029,10 +2030,10 @@ ActiveNodeContext WebPagePrivate::activeNodeContext(TargetDetectionStrategy stra
 
         String pattern = findPatternStringForUrl(href);
         if (!pattern.isEmpty())
-            context.setPattern(pattern);
+            context.setPattern(pattern.utf8().data());
 
         if (!href.string().isEmpty()) {
-            context.setUrl(href.string());
+            context.setUrl(href.string().utf8().data());
 
             // Links are non-selectable by default, but selection should be allowed
             // providing the page is selectable, use the parent to determine it.
@@ -2042,58 +2043,75 @@ ActiveNodeContext WebPagePrivate::activeNodeContext(TargetDetectionStrategy stra
     }
 
     if (!nodeAllowSelectionOverride && !node->canStartSelection())
-        context.resetFlag(ActiveNodeContext::IsSelectable);
+        context.resetFlag(Platform::WebContext::IsSelectable);
 
     if (node->isHTMLElement()) {
         HTMLImageElement* imageElement = 0;
+        HTMLMediaElement* mediaElement = 0;
+
         if (node->hasTagName(HTMLNames::imgTag))
             imageElement = static_cast<HTMLImageElement*>(node.get());
         else if (node->hasTagName(HTMLNames::areaTag))
             imageElement = static_cast<HTMLAreaElement*>(node.get())->imageElement();
+
+        if (static_cast<HTMLElement*>(node.get())->isMediaElement())
+            mediaElement = static_cast<HTMLMediaElement*>(node.get());
+
         if (imageElement && imageElement->renderer()) {
+            context.setFlag(Platform::WebContext::IsImage);
             // FIXME: At the mean time, we only show "Save Image" when the image data is available.
             if (CachedResource* cachedResource = imageElement->cachedImage()) {
                 if (cachedResource->isLoaded() && cachedResource->data()) {
                     String url = stripLeadingAndTrailingHTMLSpaces(imageElement->getAttribute(HTMLNames::srcAttr).string());
-                    context.setImageSrc(node->document()->completeURL(url).string());
+                    context.setSrc(node->document()->completeURL(url).string().utf8().data());
                 }
             }
             String alt = imageElement->altText();
             if (!alt.isNull())
-                context.setImageAlt(alt);
+                context.setAlt(alt.utf8().data());
+        }
+
+        if (mediaElement) {
+            if (mediaElement->hasAudio())
+                context.setFlag(Platform::WebContext::IsAudio);
+            if (mediaElement->hasVideo())
+                context.setFlag(Platform::WebContext::IsVideo);
+
+            String src = stripLeadingAndTrailingHTMLSpaces(mediaElement->getAttribute(HTMLNames::srcAttr).string());
+            context.setSrc(node->document()->completeURL(src).string().utf8().data());
         }
     }
 
     if (node->isTextNode()) {
         Text* curText = static_cast<Text*>(node.get());
         if (!curText->wholeText().isEmpty())
-            context.setText(curText->wholeText());
+            context.setText(curText->wholeText().utf8().data());
     }
 
     if (node->isElementNode()) {
         Element* element = static_cast<Element*>(node->shadowAncestorNode());
         if (DOMSupport::isTextBasedContentEditableElement(element)) {
-            context.setFlag(ActiveNodeContext::IsInput);
+            context.setFlag(Platform::WebContext::IsInput);
             if (element->hasTagName(HTMLNames::inputTag))
-                context.setFlag(ActiveNodeContext::IsSingleLine);
+                context.setFlag(Platform::WebContext::IsSingleLine);
             if (DOMSupport::isPasswordElement(element))
-                context.setFlag(ActiveNodeContext::IsPassword);
+                context.setFlag(Platform::WebContext::IsPassword);
 
             String elementText(DOMSupport::inputElementText(element));
             if (!elementText.stripWhiteSpace().isEmpty())
-                context.setText(elementText);
+                context.setText(elementText.utf8().data());
         }
     }
 
     if (node->isFocusable())
-        context.setFlag(ActiveNodeContext::IsFocusable);
+        context.setFlag(Platform::WebContext::IsFocusable);
 
     return context;
 }
 
-ActiveNodeContext WebPage::activeNodeContext(TargetDetectionStrategy strategy) const
+Platform::WebContext WebPage::webContext(TargetDetectionStrategy strategy) const
 {
-    return d->activeNodeContext(strategy);
+    return d->webContext(strategy);
 }
 
 void WebPagePrivate::updateCursor()
@@ -3549,6 +3567,7 @@ bool WebPagePrivate::handleMouseEvent(PlatformMouseEvent& mouseEvent)
     }
 
     if (mouseEvent.type() == WebCore::PlatformEvent::MousePressed) {
+        m_inputHandler->enableInputMode();
         if (m_inputHandler->willOpenPopupForNode(node)) {
             // Do not allow any human generated mouse or keyboard events to select <option>s in the list box
             // because we use a pop up dialog to handle the actual selections. This prevents options from
index 3a883ce6605de532422758bd0226984328b318cf..e9eed2304c067c37d3f63ca10c79ec822a3b982a 100644 (file)
 #ifndef WebPage_h
 #define WebPage_h
 
-#include "ActiveNodeContext.h"
 #include "BlackBerryGlobal.h"
+#include "WebString.h"
+
 #include <BlackBerryPlatformGuardedPointer.h>
 #include <BlackBerryPlatformInputEvents.h>
+#include <BlackBerryPlatformWebContext.h>
 #include <imf/input_data.h>
 #include <network/NetworkRequest.h>
 
@@ -257,7 +259,7 @@ public:
 
     WebString textHasAttribute(const WebString& query) const;
 
-    ActiveNodeContext activeNodeContext(TargetDetectionStrategy) const;
+    Platform::WebContext webContext(TargetDetectionStrategy) const;
 
     typedef intptr_t BackForwardId;
     struct BackForwardEntry {
index bb4df5d9fda414139157b8d8c00c745fbc6491fd..4047a6138b04183283007fb19af972e6da2c4091 100644 (file)
@@ -266,7 +266,7 @@ public:
     void notifyPluginRectChanged(int id, const WebCore::IntRect& rectChanged);
 
     // Context Methods.
-    ActiveNodeContext activeNodeContext(TargetDetectionStrategy);
+    Platform::WebContext webContext(TargetDetectionStrategy);
     PassRefPtr<WebCore::Node> contextNode(TargetDetectionStrategy);
 
 #if ENABLE(VIEWPORT_REFLOW)
index d90a4be6137fc780b3742b75efd07318364d9231..d4db13c5fc314277bffd481a3034575103db745a 100644 (file)
@@ -1,3 +1,26 @@
+2012-03-16  Nima Ghanavatian  <nghanavatian@rim.com>
+
+        [BlackBerry] Syncing up left over bits in Api from our local branch to upstream
+        https://bugs.webkit.org/show_bug.cgi?id=81105
+
+        Reviewed by Rob Buis.
+
+        This patches fixes up a previous sync done in this directory and adds some new bits
+        as well.  This is accurate as of ddea1528b37b29925638fe1183318b3c3994f1f8 in our
+        local repo.
+
+        * Api/BackingStore.cpp:
+        (BlackBerry::WebKit::BackingStorePrivate::drawAndBlendLayersForDirectRendering):
+        (WebKit):
+        (BlackBerry::WebKit::BackingStorePrivate::drawLayersOnCommitIfNeeded):
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::webContext):
+        (BlackBerry::WebKit::WebPage::webContext):
+        (BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
+        * Api/WebPage.h:
+        * Api/WebPage_p.h:
+        (WebPagePrivate):
+
 2012-03-16  Mike Fenton  <mifenton@rim.com>
 
         [BlackBerry] Input processing mode should be cancelled when processing hot keys