[BlackBerry] Ensure document is attached before accessing its FrameSelection
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 May 2013 19:38:10 +0000 (19:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 May 2013 19:38:10 +0000 (19:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=115565

Patch by Nima Ghanavatian <nghanavatian@blackberry.com> on 2013-05-06
Reviewed by Rob Buis.

Internally reviewed by Mike Fenton.

PR 312101
We need to make sure that the node and document
are attached before accessing the FrameSelection. This was
handled earlier but not all call paths were covered.

* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::setElementUnfocused):
(BlackBerry::WebKit::InputHandler::isActiveTextEdit):
(WebKit):
* WebKitSupport/InputHandler.h:

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

Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
Source/WebKit/blackberry/WebKitSupport/DOMSupport.h
Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp

index b3c4591c4daa2d98f80bb23510caebd37500a19b..e074dc644ac7acb93c9d665df954244a5768e430 100644 (file)
@@ -1,3 +1,23 @@
+2013-05-06  Nima Ghanavatian  <nghanavatian@blackberry.com>
+
+        [BlackBerry] Ensure document is attached before accessing its FrameSelection
+        https://bugs.webkit.org/show_bug.cgi?id=115565
+
+        Reviewed by Rob Buis.
+
+        Internally reviewed by Mike Fenton.
+
+        PR 312101
+        We need to make sure that the node and document
+        are attached before accessing the FrameSelection. This was
+        handled earlier but not all call paths were covered.
+
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::setElementUnfocused):
+        (BlackBerry::WebKit::InputHandler::isActiveTextEdit):
+        (WebKit):
+        * WebKitSupport/InputHandler.h:
+
 2013-05-06  Nima Ghanavatian  <nghanavatian@blackberry.com>
 
         [BlackBerry] Do not spellcheck when composition is active.
index efd95cb540e585a23c022f14f1b34a93e1de6a8b..b60771dd56d2b84ef2442b978c479766ef53277b 100644 (file)
@@ -662,6 +662,11 @@ BlackBerry::Platform::RequestedHandlePosition elementHandlePositionAttribute(con
     return position;
 }
 
+bool isElementAndDocumentAttached(const WebCore::Element* element)
+{
+    return element && element->attached() && element->document() && element->document()->attached();
+}
+
 } // DOMSupport
 } // WebKit
 } // BlackBerry
index 1e2fb1bcebdf5ebc719dda669bd95821f0218385..96ce59be124fe1c10d7f4fc3c85937ad67f38a8d 100644 (file)
@@ -106,6 +106,8 @@ bool isFixedPositionOrHasFixedPositionAncestor(WebCore::RenderObject*);
 WebCore::Element* selectionContainerElement(const WebCore::VisibleSelection&);
 BlackBerry::Platform::RequestedHandlePosition elementHandlePositionAttribute(const WebCore::Element*);
 
+bool isElementAndDocumentAttached(const WebCore::Element*);
+
 } // DOMSupport
 } // WebKit
 } // BlackBerry
index 561b6b931b2e4a3afb33866a0a0214343c0d32e1..940cc1084f439cf192ab72dfd085e2a1f752b109 100644 (file)
@@ -857,7 +857,7 @@ void InputHandler::requestSpellingCheckingOptions(imf_sp_text_t& spellCheckingOp
 
 void InputHandler::setElementUnfocused(bool refocusOccuring)
 {
-    if (isActiveTextEdit() && m_currentFocusElement->attached() && m_currentFocusElement->document()->attached()) {
+    if (isActiveTextEdit() && DOMSupport::isElementAndDocumentAttached(m_currentFocusElement.get())) {
         FocusLog(Platform::LogLevelInfo, "InputHandler::setElementUnfocused");
 
         // Pass any text into the field to IMF to learn.
@@ -918,7 +918,10 @@ void InputHandler::setInputModeEnabled(bool active)
     m_inputModeEnabled = active;
 
     // If the frame selection isn't focused, focus it.
-    if (isInputModeEnabled() && isActiveTextEdit() && !m_currentFocusElement->document()->frame()->selection()->isFocused())
+    if (isInputModeEnabled()
+        && isActiveTextEdit()
+        && DOMSupport::isElementAndDocumentAttached(m_currentFocusElement.get())
+        && !m_currentFocusElement->document()->frame()->selection()->isFocused())
         m_currentFocusElement->document()->frame()->selection()->setFocused(true);
 }