Commit ef7cefa6 authored by akling@apple.com's avatar akling@apple.com

FocusController::focusedOrMainFrame() should return a reference.

<https://webkit.org/b/120339>

Reviewed by Antti Koivisto.

Now that Page::mainFrame() returns a reference, we can make this return a reference
too, since there's always either a focused or a main frame.

One hectogram of null checks removed as a result.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154678 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a5dea8b3
2013-08-26 Andreas Kling <akling@apple.com>
FocusController::focusedOrMainFrame() should return a reference.
<https://webkit.org/b/120339>
Reviewed by Antti Koivisto.
Now that Page::mainFrame() returns a reference, we can make this return a reference
too, since there's always either a focused or a main frame.
One hectogram of null checks removed as a result.
2013-08-26 Andreas Kling <akling@apple.com> 2013-08-26 Andreas Kling <akling@apple.com>
Document's renderer is always a RenderView. Document's renderer is always a RenderView.
...@@ -161,7 +161,7 @@ AccessibilityObject* AXObjectCache::focusedUIElementForPage(const Page* page) ...@@ -161,7 +161,7 @@ AccessibilityObject* AXObjectCache::focusedUIElementForPage(const Page* page)
return 0; return 0;
// get the focused node in the page // get the focused node in the page
Document* focusedDocument = page->focusController().focusedOrMainFrame()->document(); Document* focusedDocument = page->focusController().focusedOrMainFrame().document();
Element* focusedElement = focusedDocument->focusedElement(); Element* focusedElement = focusedDocument->focusedElement();
if (focusedElement && isHTMLAreaElement(focusedElement)) if (focusedElement && isHTMLAreaElement(focusedElement))
return focusedImageMapUIElement(toHTMLAreaElement(focusedElement)); return focusedImageMapUIElement(toHTMLAreaElement(focusedElement));
......
...@@ -984,7 +984,7 @@ bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectIn ...@@ -984,7 +984,7 @@ bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectIn
// Reveal the current selection // Reveal the current selection
if (Frame* editedFrame = document->frame()) if (Frame* editedFrame = document->frame())
if (Page* page = editedFrame->page()) if (Page* page = editedFrame->page())
page->focusController().focusedOrMainFrame()->selection().revealSelection(ScrollAlignment::alignCenterIfNeeded); page->focusController().focusedOrMainFrame().selection().revealSelection(ScrollAlignment::alignCenterIfNeeded);
} }
} }
......
...@@ -84,7 +84,7 @@ void CachedPage::restore(Page* page) ...@@ -84,7 +84,7 @@ void CachedPage::restore(Page* page)
// Restore the focus appearance for the focused element. // Restore the focus appearance for the focused element.
// FIXME: Right now we don't support pages w/ frames in the b/f cache. This may need to be tweaked when we add support for that. // FIXME: Right now we don't support pages w/ frames in the b/f cache. This may need to be tweaked when we add support for that.
Document* focusedDocument = page->focusController().focusedOrMainFrame()->document(); Document* focusedDocument = page->focusController().focusedOrMainFrame().document();
if (Element* element = focusedDocument->focusedElement()) if (Element* element = focusedDocument->focusedElement())
element->updateFocusAppearance(true); element->updateFocusAppearance(true);
......
...@@ -1965,9 +1965,9 @@ bool EventHandler::handlePasteGlobalSelection(const PlatformMouseEvent& mouseEve ...@@ -1965,9 +1965,9 @@ bool EventHandler::handlePasteGlobalSelection(const PlatformMouseEvent& mouseEve
if (!m_frame->page()) if (!m_frame->page())
return false; return false;
Frame* focusFrame = m_frame->page()->focusController().focusedOrMainFrame(); Frame& focusFrame = m_frame->page()->focusController().focusedOrMainFrame();
// Do not paste here if the focus was moved somewhere else. // Do not paste here if the focus was moved somewhere else.
if (m_frame == focusFrame && m_frame->editor().client()->supportsGlobalSelection()) if (m_frame == &focusFrame && m_frame->editor().client()->supportsGlobalSelection())
return m_frame->editor().command(ASCIILiteral("PasteGlobalSelection")).execute(); return m_frame->editor().command(ASCIILiteral("PasteGlobalSelection")).execute();
return false; return false;
...@@ -3336,7 +3336,7 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent) ...@@ -3336,7 +3336,7 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) {
node->dispatchEvent(keydown, IGNORE_EXCEPTION); node->dispatchEvent(keydown, IGNORE_EXCEPTION);
// If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame. // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame.
bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->focusController().focusedOrMainFrame(); bool changedFocusedFrame = m_frame->page() && m_frame != &m_frame->page()->focusController().focusedOrMainFrame();
return keydown->defaultHandled() || keydown->defaultPrevented() || changedFocusedFrame; return keydown->defaultHandled() || keydown->defaultPrevented() || changedFocusedFrame;
} }
...@@ -3358,7 +3358,7 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent) ...@@ -3358,7 +3358,7 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
node->dispatchEvent(keydown, IGNORE_EXCEPTION); node->dispatchEvent(keydown, IGNORE_EXCEPTION);
// If frame changed as a result of keydown dispatch, then return early to avoid sending a subsequent keypress message to the new frame. // If frame changed as a result of keydown dispatch, then return early to avoid sending a subsequent keypress message to the new frame.
bool changedFocusedFrame = m_frame->page() && m_frame != m_frame->page()->focusController().focusedOrMainFrame(); bool changedFocusedFrame = m_frame->page() && m_frame != &m_frame->page()->focusController().focusedOrMainFrame();
bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented() || changedFocusedFrame; bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented() || changedFocusedFrame;
if (handledByInputMethod || (keydownResult && !backwardCompatibilityMode)) if (handledByInputMethod || (keydownResult && !backwardCompatibilityMode))
return keydownResult; return keydownResult;
......
...@@ -204,11 +204,11 @@ void FocusController::setFocusedFrame(PassRefPtr<Frame> frame) ...@@ -204,11 +204,11 @@ void FocusController::setFocusedFrame(PassRefPtr<Frame> frame)
m_isChangingFocusedFrame = false; m_isChangingFocusedFrame = false;
} }
Frame* FocusController::focusedOrMainFrame() const Frame& FocusController::focusedOrMainFrame() const
{ {
if (Frame* frame = focusedFrame()) if (Frame* frame = focusedFrame())
return frame; return *frame;
return &m_page->mainFrame(); return m_page->mainFrame();
} }
void FocusController::setFocused(bool focused) void FocusController::setFocused(bool focused)
...@@ -219,7 +219,7 @@ void FocusController::setFocused(bool focused) ...@@ -219,7 +219,7 @@ void FocusController::setFocused(bool focused)
m_isFocused = focused; m_isFocused = focused;
if (!m_isFocused) if (!m_isFocused)
focusedOrMainFrame()->eventHandler().stopAutoscrollTimer(); focusedOrMainFrame().eventHandler().stopAutoscrollTimer();
if (!m_focusedFrame) if (!m_focusedFrame)
setFocusedFrame(&m_page->mainFrame()); setFocusedFrame(&m_page->mainFrame());
...@@ -255,8 +255,8 @@ bool FocusController::setInitialFocus(FocusDirection direction, KeyboardEvent* e ...@@ -255,8 +255,8 @@ bool FocusController::setInitialFocus(FocusDirection direction, KeyboardEvent* e
// If focus is being set initially, accessibility needs to be informed that system focus has moved // If focus is being set initially, accessibility needs to be informed that system focus has moved
// into the web area again, even if focus did not change within WebCore. PostNotification is called instead // into the web area again, even if focus did not change within WebCore. PostNotification is called instead
// of handleFocusedUIElementChanged, because this will send the notification even if the element is the same. // of handleFocusedUIElementChanged, because this will send the notification even if the element is the same.
if (AXObjectCache* cache = focusedOrMainFrame()->document()->existingAXObjectCache()) if (AXObjectCache* cache = focusedOrMainFrame().document()->existingAXObjectCache())
cache->postNotification(focusedOrMainFrame()->document(), AXObjectCache::AXFocusedUIElementChanged, true); cache->postNotification(focusedOrMainFrame().document(), AXObjectCache::AXFocusedUIElementChanged, true);
return didAdvanceFocus; return didAdvanceFocus;
} }
...@@ -281,16 +281,15 @@ bool FocusController::advanceFocus(FocusDirection direction, KeyboardEvent* even ...@@ -281,16 +281,15 @@ bool FocusController::advanceFocus(FocusDirection direction, KeyboardEvent* even
bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, KeyboardEvent* event, bool initialFocus) bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, KeyboardEvent* event, bool initialFocus)
{ {
Frame* frame = focusedOrMainFrame(); Frame& frame = focusedOrMainFrame();
ASSERT(frame); Document* document = frame.document();
Document* document = frame->document();
Node* currentNode = document->focusedElement(); Node* currentNode = document->focusedElement();
// FIXME: Not quite correct when it comes to focus transitions leaving/entering the WebView itself // FIXME: Not quite correct when it comes to focus transitions leaving/entering the WebView itself
bool caretBrowsing = frame->settings().caretBrowsingEnabled(); bool caretBrowsing = frame.settings().caretBrowsingEnabled();
if (caretBrowsing && !currentNode) if (caretBrowsing && !currentNode)
currentNode = frame->selection().start().deprecatedNode(); currentNode = frame.selection().start().deprecatedNode();
document->updateLayoutIgnorePendingStylesheets(); document->updateLayoutIgnorePendingStylesheets();
...@@ -349,8 +348,8 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb ...@@ -349,8 +348,8 @@ bool FocusController::advanceFocusInDocumentOrder(FocusDirection direction, Keyb
if (caretBrowsing) { if (caretBrowsing) {
Position position = firstPositionInOrBeforeNode(element.get()); Position position = firstPositionInOrBeforeNode(element.get());
VisibleSelection newSelection(position, position, DOWNSTREAM); VisibleSelection newSelection(position, position, DOWNSTREAM);
if (frame->selection().shouldChangeSelection(newSelection)) if (frame.selection().shouldChangeSelection(newSelection))
frame->selection().setSelection(newSelection); frame.selection().setSelection(newSelection);
} }
element->focus(false, direction); element->focus(false, direction);
...@@ -660,7 +659,7 @@ void FocusController::setActive(bool active) ...@@ -660,7 +659,7 @@ void FocusController::setActive(bool active)
} }
} }
focusedOrMainFrame()->selection().pageActivationChanged(); focusedOrMainFrame().selection().pageActivationChanged();
if (m_focusedFrame && isFocused()) if (m_focusedFrame && isFocused())
dispatchEventsOnWindowAndFocusedElement(m_focusedFrame->document(), active); dispatchEventsOnWindowAndFocusedElement(m_focusedFrame->document(), active);
...@@ -828,7 +827,7 @@ bool FocusController::advanceFocusDirectionallyInContainer(Node* container, cons ...@@ -828,7 +827,7 @@ bool FocusController::advanceFocusDirectionallyInContainer(Node* container, cons
} }
// Navigate into a new frame. // Navigate into a new frame.
LayoutRect rect; LayoutRect rect;
Element* focusedElement = focusedOrMainFrame()->document()->focusedElement(); Element* focusedElement = focusedOrMainFrame().document()->focusedElement();
if (focusedElement && !hasOffscreenRect(focusedElement)) if (focusedElement && !hasOffscreenRect(focusedElement))
rect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */); rect = nodeRectInAbsoluteCoordinates(focusedElement, true /* ignore border */);
frameElement->contentFrame()->document()->updateLayoutIgnorePendingStylesheets(); frameElement->contentFrame()->document()->updateLayoutIgnorePendingStylesheets();
...@@ -846,7 +845,7 @@ bool FocusController::advanceFocusDirectionallyInContainer(Node* container, cons ...@@ -846,7 +845,7 @@ bool FocusController::advanceFocusDirectionallyInContainer(Node* container, cons
} }
// Navigate into a new scrollable container. // Navigate into a new scrollable container.
LayoutRect startingRect; LayoutRect startingRect;
Element* focusedElement = focusedOrMainFrame()->document()->focusedElement(); Element* focusedElement = focusedOrMainFrame().document()->focusedElement();
if (focusedElement && !hasOffscreenRect(focusedElement)) if (focusedElement && !hasOffscreenRect(focusedElement))
startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true); startingRect = nodeRectInAbsoluteCoordinates(focusedElement, true);
return advanceFocusDirectionallyInContainer(focusCandidate.visibleNode, startingRect, direction, event); return advanceFocusDirectionallyInContainer(focusCandidate.visibleNode, startingRect, direction, event);
...@@ -867,10 +866,7 @@ bool FocusController::advanceFocusDirectionallyInContainer(Node* container, cons ...@@ -867,10 +866,7 @@ bool FocusController::advanceFocusDirectionallyInContainer(Node* container, cons
bool FocusController::advanceFocusDirectionally(FocusDirection direction, KeyboardEvent* event) bool FocusController::advanceFocusDirectionally(FocusDirection direction, KeyboardEvent* event)
{ {
Frame* curFrame = focusedOrMainFrame(); Document* focusedDocument = focusedOrMainFrame().document();
ASSERT(curFrame);
Document* focusedDocument = curFrame->document();
if (!focusedDocument) if (!focusedDocument)
return false; return false;
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
void setFocusedFrame(PassRefPtr<Frame>); void setFocusedFrame(PassRefPtr<Frame>);
Frame* focusedFrame() const { return m_focusedFrame.get(); } Frame* focusedFrame() const { return m_focusedFrame.get(); }
Frame* focusedOrMainFrame() const; Frame& focusedOrMainFrame() const;
bool setInitialFocus(FocusDirection, KeyboardEvent*); bool setInitialFocus(FocusDirection, KeyboardEvent*);
bool advanceFocus(FocusDirection, KeyboardEvent*, bool initialFocus = false); bool advanceFocus(FocusDirection, KeyboardEvent*, bool initialFocus = false);
......
...@@ -565,7 +565,7 @@ bool Page::findString(const String& target, FindOptions options) ...@@ -565,7 +565,7 @@ bool Page::findString(const String& target, FindOptions options)
return false; return false;
bool shouldWrap = options & WrapAround; bool shouldWrap = options & WrapAround;
Frame* frame = focusController().focusedOrMainFrame(); Frame* frame = &focusController().focusedOrMainFrame();
Frame* startFrame = frame; Frame* startFrame = frame;
do { do {
if (frame->editor().findString(target, (options & ~WrapAround) | StartInSelection)) { if (frame->editor().findString(target, (options & ~WrapAround) | StartInSelection)) {
...@@ -697,7 +697,7 @@ void Page::unmarkAllTextMatches() ...@@ -697,7 +697,7 @@ void Page::unmarkAllTextMatches()
const VisibleSelection& Page::selection() const const VisibleSelection& Page::selection() const
{ {
return focusController().focusedOrMainFrame()->selection().selection(); return focusController().focusedOrMainFrame().selection().selection();
} }
void Page::setDefersLoading(bool defers) void Page::setDefersLoading(bool defers)
......
...@@ -299,7 +299,7 @@ void DumpRenderTreeSupportEfl::executeCoreCommandByName(const Evas_Object* ewkVi ...@@ -299,7 +299,7 @@ void DumpRenderTreeSupportEfl::executeCoreCommandByName(const Evas_Object* ewkVi
{ {
DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page); DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page);
page->focusController().focusedOrMainFrame()->editor().command(name).execute(value); page->focusController().focusedOrMainFrame().editor().command(name).execute(value);
} }
bool DumpRenderTreeSupportEfl::findString(const Evas_Object* ewkView, const String& text, WebCore::FindOptions options) bool DumpRenderTreeSupportEfl::findString(const Evas_Object* ewkView, const String& text, WebCore::FindOptions options)
...@@ -348,7 +348,7 @@ bool DumpRenderTreeSupportEfl::isCommandEnabled(const Evas_Object* ewkView, cons ...@@ -348,7 +348,7 @@ bool DumpRenderTreeSupportEfl::isCommandEnabled(const Evas_Object* ewkView, cons
{ {
DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false); DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
return page->focusController().focusedOrMainFrame()->editor().command(name).isEnabled(); return page->focusController().focusedOrMainFrame().editor().command(name).isEnabled();
} }
void DumpRenderTreeSupportEfl::forceLayout(Evas_Object* ewkFrame) void DumpRenderTreeSupportEfl::forceLayout(Evas_Object* ewkFrame)
...@@ -565,10 +565,7 @@ void DumpRenderTreeSupportEfl::setComposition(Evas_Object* ewkView, const char* ...@@ -565,10 +565,7 @@ void DumpRenderTreeSupportEfl::setComposition(Evas_Object* ewkView, const char*
{ {
DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page); DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page);
if (!page->focusController().focusedOrMainFrame()) WebCore::Editor& editor = page->focusController().focusedOrMainFrame().editor();
return;
WebCore::Editor& editor = page->focusController().focusedOrMainFrame()->editor();
if (!editor.canEdit() && !editor.hasComposition()) if (!editor.canEdit() && !editor.hasComposition())
return; return;
...@@ -582,10 +579,7 @@ bool DumpRenderTreeSupportEfl::hasComposition(const Evas_Object* ewkView) ...@@ -582,10 +579,7 @@ bool DumpRenderTreeSupportEfl::hasComposition(const Evas_Object* ewkView)
{ {
DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false); DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
if (!page->focusController().focusedOrMainFrame()) return page->focusController().focusedOrMainFrame().editor().hasComposition();
return false;
return page->focusController().focusedOrMainFrame()->editor().hasComposition();
} }
bool DumpRenderTreeSupportEfl::compositionRange(Evas_Object* ewkView, int* start, int* length) bool DumpRenderTreeSupportEfl::compositionRange(Evas_Object* ewkView, int* start, int* length)
...@@ -594,10 +588,7 @@ bool DumpRenderTreeSupportEfl::compositionRange(Evas_Object* ewkView, int* start ...@@ -594,10 +588,7 @@ bool DumpRenderTreeSupportEfl::compositionRange(Evas_Object* ewkView, int* start
DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false); DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
if (!page->focusController().focusedOrMainFrame()) WebCore::Editor& editor = page->focusController().focusedOrMainFrame().editor();
return false;
WebCore::Editor& editor = page->focusController().focusedOrMainFrame()->editor();
if (!editor.hasComposition()) if (!editor.hasComposition())
return false; return false;
...@@ -610,10 +601,7 @@ void DumpRenderTreeSupportEfl::confirmComposition(Evas_Object* ewkView, const ch ...@@ -610,10 +601,7 @@ void DumpRenderTreeSupportEfl::confirmComposition(Evas_Object* ewkView, const ch
{ {
DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page); DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page);
if (!page->focusController().focusedOrMainFrame()) WebCore::Editor& editor = page->focusController().focusedOrMainFrame().editor();
return;
WebCore::Editor& editor = page->focusController().focusedOrMainFrame()->editor();
if (!editor.hasComposition()) { if (!editor.hasComposition()) {
editor.insertText(String::fromUTF8(text), 0); editor.insertText(String::fromUTF8(text), 0);
...@@ -631,19 +619,16 @@ WebCore::IntRect DumpRenderTreeSupportEfl::firstRectForCharacterRange(Evas_Objec ...@@ -631,19 +619,16 @@ WebCore::IntRect DumpRenderTreeSupportEfl::firstRectForCharacterRange(Evas_Objec
{ {
DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, WebCore::IntRect()); DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, WebCore::IntRect());
if (!page->focusController().focusedOrMainFrame())
return WebCore::IntRect();
if ((location + length < location) && (location + length)) if ((location + length < location) && (location + length))
length = 0; length = 0;
WebCore::Frame* frame = page->focusController().focusedOrMainFrame(); WebCore::Frame& frame = page->focusController().focusedOrMainFrame();
RefPtr<WebCore::Range> range = WebCore::TextIterator::rangeFromLocationAndLength(frame->selection().rootEditableElementOrDocumentElement(), location, length); RefPtr<WebCore::Range> range = WebCore::TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), location, length);
if (!range) if (!range)
return WebCore::IntRect(); return WebCore::IntRect();
return frame->editor().firstRectForRange(range.get()); return frame.editor().firstRectForRange(range.get());
} }
bool DumpRenderTreeSupportEfl::selectedRange(Evas_Object* ewkView, int* start, int* length) bool DumpRenderTreeSupportEfl::selectedRange(Evas_Object* ewkView, int* start, int* length)
...@@ -653,16 +638,13 @@ bool DumpRenderTreeSupportEfl::selectedRange(Evas_Object* ewkView, int* start, i ...@@ -653,16 +638,13 @@ bool DumpRenderTreeSupportEfl::selectedRange(Evas_Object* ewkView, int* start, i
DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false); DRT_SUPPRT_PAGE_GET_OR_RETURN(ewkView, page, false);
if (!page->focusController().focusedOrMainFrame()) WebCore::Frame& frame = page->focusController().focusedOrMainFrame();
return false; RefPtr<WebCore::Range> range = frame.selection().toNormalizedRange().get();
WebCore::Frame* frame = page->focusController().focusedOrMainFrame();
RefPtr<WebCore::Range> range = frame->selection().toNormalizedRange().get();
if (!range) if (!range)
return false; return false;
WebCore::Element* selectionRoot = frame->selection().rootEditableElement(); WebCore::Element* selectionRoot = frame.selection().rootEditableElement();
WebCore::Element* scope = selectionRoot ? selectionRoot : frame->document()->documentElement(); WebCore::Element* scope = selectionRoot ? selectionRoot : frame.document()->documentElement();
RefPtr<WebCore::Range> testRange = WebCore::Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset()); RefPtr<WebCore::Range> testRange = WebCore::Range::create(scope->document(), scope, 0, range->startContainer(), range->startOffset());
*start = WebCore::TextIterator::rangeLength(testRange.get()); *start = WebCore::TextIterator::rangeLength(testRange.get());
......
...@@ -1573,7 +1573,7 @@ const char* ewk_view_selection_get(const Evas_Object* ewkView) ...@@ -1573,7 +1573,7 @@ const char* ewk_view_selection_get(const Evas_Object* ewkView)
{ {
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
CString selectedString = priv->page->focusController().focusedOrMainFrame()->editor().selectedText().utf8(); CString selectedString = priv->page->focusController().focusedOrMainFrame().editor().selectedText().utf8();
if (selectedString.isNull()) if (selectedString.isNull())
return 0; return 0;
return eina_stringshare_add(selectedString.data()); return eina_stringshare_add(selectedString.data());
...@@ -1588,7 +1588,7 @@ Eina_Bool ewk_view_editor_command_execute(const Evas_Object* ewkView, const Ewk_ ...@@ -1588,7 +1588,7 @@ Eina_Bool ewk_view_editor_command_execute(const Evas_Object* ewkView, const Ewk_
if (!commandString) if (!commandString)
return false; return false;
return priv->page->focusController().focusedOrMainFrame()->editor().command(commandString).execute(WTF::String::fromUTF8(value)); return priv->page->focusController().focusedOrMainFrame().editor().command(commandString).execute(WTF::String::fromUTF8(value));
} }
Eina_Bool ewk_view_context_menu_forward_event(Evas_Object* ewkView, const Evas_Event_Mouse_Down* downEvent) Eina_Bool ewk_view_context_menu_forward_event(Evas_Object* ewkView, const Evas_Event_Mouse_Down* downEvent)
...@@ -2945,16 +2945,15 @@ void ewk_view_input_method_state_set(Evas_Object* ewkView, bool active) ...@@ -2945,16 +2945,15 @@ void ewk_view_input_method_state_set(Evas_Object* ewkView, bool active)
{ {
EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
EWK_VIEW_PRIV_GET(smartData, priv); EWK_VIEW_PRIV_GET(smartData, priv);
WebCore::Frame* focusedFrame = priv->page->focusController().focusedOrMainFrame(); WebCore::Frame& focusedFrame = priv->page->focusController().focusedOrMainFrame();
priv->imh = 0; priv->imh = 0;
if (focusedFrame if (focusedFrame.document()
&& focusedFrame->document() && focusedFrame.document()->focusedElement()
&& focusedFrame->document()->focusedElement() && isHTMLInputElement(focusedFrame.document()->focusedElement())) {
&& isHTMLInputElement(focusedFrame->document()->focusedElement())) {
WebCore::HTMLInputElement* inputElement; WebCore::HTMLInputElement* inputElement;
inputElement = static_cast<WebCore::HTMLInputElement*>(focusedFrame->document()->focusedElement()); inputElement = static_cast<WebCore::HTMLInputElement*>(focusedFrame.document()->focusedElement());
if (inputElement) { if (inputElement) {
// for password fields, active == false // for password fields, active == false
if (!active) { if (!active) {
...@@ -4011,11 +4010,9 @@ void ewk_view_text_direction_set(Evas_Object* ewkView, Ewk_Text_Direction direct ...@@ -4011,11 +4010,9 @@ void ewk_view_text_direction_set(Evas_Object* ewkView, Ewk_Text_Direction direct
// the text direction of the selected node and updates its DOM "dir" // the text direction of the selected node and updates its DOM "dir"
// attribute and its CSS "direction" property. // attribute and its CSS "direction" property.
// So, we just call the function as Safari does. // So, we just call the function as Safari does.
WebCore::Frame* focusedFrame = priv->page->focusController().focusedOrMainFrame(); WebCore::Frame& focusedFrame = priv->page->focusController().focusedOrMainFrame();
if (!focusedFrame)
return;
WebCore::Editor& editor = focusedFrame->editor(); WebCore::Editor& editor = focusedFrame.editor();
if (!editor.canEdit()) if (!editor.canEdit())
return; return;
......
...@@ -623,8 +623,8 @@ void ChromeClient::paint(WebCore::Timer<ChromeClient>*) ...@@ -623,8 +623,8 @@ void ChromeClient::paint(WebCore::Timer<ChromeClient>*)
// We update the IM context window location here, because we want it to be // We update the IM context window location here, because we want it to be
// synced with cursor movement. For instance, a text field can move without // synced with cursor movement. For instance, a text field can move without
// the selection changing. // the selection changing.
Frame* focusedFrame = core(m_webView)->focusController().focusedOrMainFrame(); Frame& focusedFrame = core(m_webView)->focusController().focusedOrMainFrame();
if (focusedFrame && focusedFrame->editor().canEdit()) if (focusedFrame.editor().canEdit())
m_webView->priv->imFilter.setCursorRect(frame.selection().absoluteCaretBounds()); m_webView->priv->imFilter.setCursorRect(frame.selection().absoluteCaretBounds());
} }
......
...@@ -276,7 +276,7 @@ void DumpRenderTreeSupportGtk::executeCoreCommandByName(WebKitWebView* webView, ...@@ -276,7 +276,7 @@ void DumpRenderTreeSupportGtk::executeCoreCommandByName(WebKitWebView* webView,
g_return_if_fail(name); g_return_if_fail(name);
g_return_if_fail(value); g_return_if_fail(value);
core(webView)->focusController().focusedOrMainFrame()->editor().command(name).execute(value); core(webView)->focusController().focusedOrMainFrame().editor().command(name).execute(value);
} }
bool DumpRenderTreeSupportGtk::isCommandEnabled(WebKitWebView* webView, const gchar* name) bool DumpRenderTreeSupportGtk::isCommandEnabled(WebKitWebView* webView, const gchar* name)
...@@ -284,7 +284,7 @@ bool DumpRenderTreeSupportGtk::isCommandEnabled(WebKitWebView* webView, const gc ...@@ -284,7 +284,7 @@ bool DumpRenderTreeSupportGtk::isCommandEnabled(WebKitWebView* webView, const gc
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
g_return_val_if_fail(name, FALSE); g_return_val_if_fail(name, FALSE);
return core(webView)->focusController().focusedOrMainFrame()->editor().command(name).isEnabled(); return core(webView)->focusController().focusedOrMainFrame().editor().command(name).isEnabled();
} }
void DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char* text, int start, int length) void DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char* text, int start, int length)
...@@ -292,11 +292,8 @@ void DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char ...@@ -292,11 +292,8 @@ void DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
g_return_if_fail(text); g_return_if_fail(text);
Frame* frame = core(webView)->focusController().focusedOrMainFrame(); Frame& frame = core(webView)->focusController().focusedOrMainFrame();
if (!frame) Editor& editor = frame.editor();
return;
Editor& editor = frame->editor();
if (!editor.canEdit() && !editor.hasComposition()) if (!editor.canEdit() && !editor.hasComposition())
return; return;
...@@ -309,11 +306,8 @@ void DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char ...@@ -309,11 +306,8 @@ void DumpRenderTreeSupportGtk::setComposition(WebKitWebView* webView, const char
bool DumpRenderTreeSupportGtk::hasComposition(WebKitWebView* webView) bool DumpRenderTreeSupportGtk::hasComposition(WebKitWebView* webView)
{ {
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false); g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
Frame* frame = core(webView)->focusController().focusedOrMainFrame(); Frame& frame = core(webView)->focusController().focusedOrMainFrame();
if (!frame) return frame.editor().hasComposition();
return false;
return frame->editor().hasComposition();
} }
bool DumpRenderTreeSupportGtk::compositionRange(WebKitWebView* webView, int* start, int* length) bool DumpRenderTreeSupportGtk::compositionRange(WebKitWebView* webView, int* start, int* length)
...@@ -322,11 +316,8 @@ bool DumpRenderTreeSupportGtk::compositionRange(WebKitWebView* webView, int* sta ...@@ -322,11 +316,8 @@ bool DumpRenderTreeSupportGtk::compositionRange(WebKitWebView* webView, int* sta
*start = *length = 0; *start = *length = 0;
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false); g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
Frame* frame = core(webView)->focusController().focusedOrMainFrame(); Frame& frame = core(webView)->focusController().focusedOrMainFrame();
if (!frame) Editor& editor = frame.editor();
return false;
Editor& editor = frame->editor();
if (!editor.hasComposition()) if (!editor.hasComposition())
return false; return false;
...@@ -339,11 +330,8 @@ void DumpRenderTreeSupportGtk::confirmComposition(WebKitWebView* webView, const ...@@ -339,11 +330,8 @@ void DumpRenderTreeSupportGtk::confirmComposition(WebKitWebView* webView, const
{ {
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
Frame* frame = core(webView)->focusController().focusedOrMainFrame(); Frame& frame = core(webView)->focusController().focusedOrMainFrame();
if (!frame) Editor& editor = frame.editor();
return;
Editor& editor = frame->editor();