Title: [110562] trunk/Source/WebKit/blackberry
Revision
110562
Author
[email protected]
Date
2012-03-13 08:02:49 -0700 (Tue, 13 Mar 2012)

Log Message

Remove ActiveNodeContext in favour of BlackBerry::Platform::WebContext
https://bugs.webkit.org/show_bug.cgi?id=80984

Remove ActiveNodeContext, and switch the implementation to
provide a BlackBerry::Platform::WebContext. The new object
adds an explicit IsImage flag, as well as IsAudio and IsVideo
for the HTML5 elements.

Note that for many videos both IsVideo and IsAudio will be true,
as videos typically have audio streams as well.

Patch by Mike Lattanzio <[email protected]> on 2012-03-13
Reviewed by George Staikos.

* Api/ActiveNodeContext.h: Removed.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::webContext):
(BlackBerry::WebKit::WebPage::webContext):
* Api/WebPage.h:
* Api/WebPage_p.h:

Modified Paths

Removed Paths

Diff

Deleted: trunk/Source/WebKit/blackberry/Api/ActiveNodeContext.h (110561 => 110562)


--- trunk/Source/WebKit/blackberry/Api/ActiveNodeContext.h	2012-03-13 14:57:53 UTC (rev 110561)
+++ trunk/Source/WebKit/blackberry/Api/ActiveNodeContext.h	2012-03-13 15:02:49 UTC (rev 110562)
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef ActiveNodeContext_h
-#define ActiveNodeContext_h
-
-#include "WebString.h"
-
-namespace BlackBerry {
-namespace WebKit {
-
-class ActiveNodeContext {
-public:
-    // We assume a default context should be selectable, but nothing else.
-    ActiveNodeContext()
-        : m_flags(IsSelectable)
-        {
-        }
-
-    enum ContextFlags { IsFocusable = 0x01,
-                        IsInput = 0x02,
-                        IsPassword = 0x04,
-                        IsSelectable = 0x08,
-                        IsSingleLine = 0x10, };
-
-    bool isFocusable() const { return m_flags & IsFocusable; }
-    bool isInput() const { return m_flags & IsInput; }
-    bool isPassword() const { return m_flags & IsPassword; }
-    bool isSelectable() const { return m_flags & IsSelectable; }
-    bool isSingleLine() const { return m_flags & IsSingleLine; }
-
-    void setFlag(ContextFlags flag) { m_flags |= flag; }
-    void resetFlag(ContextFlags flag) { m_flags &= ~flag; }
-
-    const WebString& imageAlt() const { return m_imageAlt; }
-    void setImageAlt(const WebString& string) { m_imageAlt = string; }
-
-    const WebString& imageSrc() const { return m_imageSrc; }
-    void setImageSrc(const WebString& string) { m_imageSrc = string; }
-
-    const WebString& pattern() const { return m_pattern; }
-    void setPattern(const WebString& string) { m_pattern = string; }
-
-    const WebString& text() const { return m_text; }
-    void setText(const WebString& string) { m_text = string; }
-
-    const WebString& url() const { return m_url; }
-    void setUrl(const WebString& string) { m_url = string; }
-
-private:
-    unsigned m_flags;
-    WebString m_imageAlt;
-    WebString m_imageSrc;
-    WebString m_pattern;
-    WebString m_text;
-    WebString m_url;
-};
-
-}
-}
-#endif // ActiveNodeContext_h

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (110561 => 110562)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-03-13 14:57:53 UTC (rev 110561)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2012-03-13 15:02:49 UTC (rev 110562)
@@ -57,6 +57,7 @@
 #include "HTMLFrameOwnerElement.h"
 #include "HTMLImageElement.h"
 #include "HTMLInputElement.h"
+#include "HTMLMediaElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
 #include "HTTPParsers.h"
@@ -1992,9 +1993,9 @@
     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;
@@ -2013,10 +2014,10 @@
 
         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.
@@ -2026,58 +2027,75 @@
     }
 
     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 = ""
-                    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 = ""
+            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()

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (110561 => 110562)


--- trunk/Source/WebKit/blackberry/Api/WebPage.h	2012-03-13 14:57:53 UTC (rev 110561)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h	2012-03-13 15:02:49 UTC (rev 110562)
@@ -19,10 +19,12 @@
 #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 @@
 
     WebString textHasAttribute(const WebString& query) const;
 
-    ActiveNodeContext activeNodeContext(TargetDetectionStrategy) const;
+    Platform::WebContext webContext(TargetDetectionStrategy) const;
 
     typedef intptr_t BackForwardId;
     struct BackForwardEntry {

Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (110561 => 110562)


--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-03-13 14:57:53 UTC (rev 110561)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h	2012-03-13 15:02:49 UTC (rev 110562)
@@ -266,7 +266,7 @@
     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)

Modified: trunk/Source/WebKit/blackberry/ChangeLog (110561 => 110562)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-03-13 14:57:53 UTC (rev 110561)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-03-13 15:02:49 UTC (rev 110562)
@@ -1,3 +1,25 @@
+2012-03-13  Mike Lattanzio  <[email protected]>
+
+        Remove ActiveNodeContext in favour of BlackBerry::Platform::WebContext
+        https://bugs.webkit.org/show_bug.cgi?id=80984
+
+        Remove ActiveNodeContext, and switch the implementation to
+        provide a BlackBerry::Platform::WebContext. The new object
+        adds an explicit IsImage flag, as well as IsAudio and IsVideo
+        for the HTML5 elements.
+
+        Note that for many videos both IsVideo and IsAudio will be true,
+        as videos typically have audio streams as well.
+
+        Reviewed by George Staikos.
+
+        * Api/ActiveNodeContext.h: Removed.
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::webContext):
+        (BlackBerry::WebKit::WebPage::webContext):
+        * Api/WebPage.h:
+        * Api/WebPage_p.h:
+
 2012-03-12  Andy Chen  <[email protected]>
 
         [Blackberry] Make the process of marking all matches interruptible and asynchronous for find-in-page
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to