Get rid of Chrome, use Page.

This hides ChromeClient inside Page and gets rid of Chrome object.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/878673005
This commit is contained in:
Elliott Sprehn 2015-01-26 18:06:24 -08:00
parent dddf8f294f
commit eb3e7d4b8b
37 changed files with 152 additions and 453 deletions

View File

@ -980,8 +980,6 @@ sky_core_files = [
"loader/UniqueIdentifier.h",
"page/AutoscrollController.cpp",
"page/AutoscrollController.h",
"page/Chrome.cpp",
"page/Chrome.h",
"page/ChromeClient.h",
"page/EditorClient.h",
"page/EventHandler.cpp",

View File

@ -112,7 +112,6 @@
#include "sky/engine/core/inspector/InspectorTraceEvents.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/loader/ImageLoader.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/FocusController.h"
@ -1683,7 +1682,7 @@ bool Document::setFocusedElement(PassRefPtr<Element> prpNewFocusedElement, Focus
}
if (!focusChangeBlocked && frameHost())
frameHost()->chrome().focusedNodeChanged(m_focusedElement.get());
page()->focusedNodeChanged(m_focusedElement.get());
SetFocusedElementDone:
updateRenderTreeIfNeeded();

View File

@ -74,7 +74,6 @@
#include "sky/engine/core/html/HTMLTemplateElement.h"
#include "sky/engine/core/html/parser/HTMLDocumentParser.h"
#include "sky/engine/core/html/parser/HTMLParserIdioms.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/FocusController.h"
#include "sky/engine/core/page/Page.h"

View File

@ -46,7 +46,6 @@
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/frame/Settings.h"
#include "sky/engine/core/html/HTMLImageElement.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/EditorClient.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/rendering/RenderBox.h"

View File

@ -35,7 +35,6 @@
#include "sky/engine/core/editing/TypingCommand.h"
#include "sky/engine/core/events/CompositionEvent.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/rendering/RenderObject.h"
@ -140,11 +139,7 @@ bool InputMethodController::confirmCompositionOrInsertText(const String& text, C
void InputMethodController::confirmCompositionAndResetState()
{
if (!hasComposition())
return;
// ChromeClient::willSetInputMethodState() resets input method and the composition string is committed.
m_frame.chromeClient().willSetInputMethodState();
// TODO(esprehn): Remove this.
}
void InputMethodController::cancelComposition()

View File

@ -30,16 +30,17 @@
#include "sky/engine/core/frame/Console.h"
#include "sky/engine/bindings/core/v8/ScriptCallStackFactory.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/frame/ConsoleTypes.h"
#include "sky/engine/core/frame/FrameConsole.h"
#include "sky/engine/core/frame/FrameHost.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/inspector/ConsoleAPITypes.h"
#include "sky/engine/core/inspector/ConsoleMessage.h"
#include "sky/engine/core/inspector/ScriptArguments.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/inspector/ScriptCallStack.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/platform/TraceEvent.h"
#include "sky/engine/core/inspector/ScriptCallStack.h"
#include "sky/engine/wtf/text/CString.h"
#include "sky/engine/wtf/text/WTFString.h"

View File

@ -36,7 +36,6 @@
#include "sky/engine/core/frame/Settings.h"
#include "sky/engine/core/loader/EmptyClients.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/FocusController.h"
@ -103,17 +102,4 @@ void Frame::setDOMWindow(PassRefPtr<LocalDOMWindow> domWindow)
m_domWindow = domWindow;
}
static ChromeClient& emptyChromeClient()
{
DEFINE_STATIC_LOCAL(EmptyChromeClient, client, ());
return client;
}
ChromeClient& Frame::chromeClient() const
{
if (Page* page = this->page())
return page->chrome().client();
return emptyChromeClient();
}
} // namespace blink

View File

@ -66,8 +66,6 @@ public:
virtual void setDOMWindow(PassRefPtr<LocalDOMWindow>);
LocalDOMWindow* domWindow() const;
ChromeClient& chromeClient() const;
Settings* settings() const; // can be null
protected:

View File

@ -30,16 +30,16 @@
#include "sky/engine/core/frame/FrameConsole.h"
#include "sky/engine/bindings/core/v8/ScriptCallStackFactory.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/frame/FrameHost.h"
#include "sky/engine/core/inspector/ConsoleAPITypes.h"
#include "sky/engine/core/inspector/ConsoleMessage.h"
#include "sky/engine/core/inspector/ConsoleMessageStorage.h"
#include "sky/engine/core/inspector/ScriptArguments.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/inspector/ScriptCallStack.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/Page.h"
#include "sky/engine/platform/network/ResourceResponse.h"
#include "sky/engine/core/inspector/ScriptCallStack.h"
#include "sky/engine/wtf/text/StringBuilder.h"
namespace blink {
@ -98,7 +98,7 @@ void FrameConsole::addMessage(PassRefPtr<ConsoleMessage> prpConsoleMessage)
RefPtr<ScriptCallStack> reportedCallStack = nullptr;
if (consoleMessage->source() != ConsoleAPIMessageSource) {
if (consoleMessage->callStack() && m_frame.chromeClient().shouldReportDetailedMessageForSource(messageURL))
if (consoleMessage->callStack() && m_frame.page()->shouldReportDetailedMessageForSource(messageURL))
reportedCallStack = consoleMessage->callStack();
} else {
if (!m_frame.host() || (consoleMessage->scriptArguments() && consoleMessage->scriptArguments()->argumentCount() == 0))
@ -107,14 +107,14 @@ void FrameConsole::addMessage(PassRefPtr<ConsoleMessage> prpConsoleMessage)
if (!allClientReportingMessageTypes().contains(consoleMessage->type()))
return;
if (m_frame.chromeClient().shouldReportDetailedMessageForSource(messageURL))
if (m_frame.page()->shouldReportDetailedMessageForSource(messageURL))
reportedCallStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture);
}
String stackTrace;
if (reportedCallStack)
stackTrace = FrameConsole::formatStackTraceString(consoleMessage->message(), reportedCallStack);
m_frame.chromeClient().addMessageToConsole(&m_frame, consoleMessage->source(), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, stackTrace);
m_frame.page()->addMessageToConsole(&m_frame, consoleMessage->source(), consoleMessage->level(), consoleMessage->message(), lineNumber, messageURL, stackTrace);
}
void FrameConsole::reportResourceResponseReceived(Document* document, unsigned long requestIdentifier, const ResourceResponse& response)

View File

@ -31,8 +31,6 @@
#include "sky/engine/config.h"
#include "sky/engine/core/frame/FrameHost.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/Page.h"
namespace blink {
@ -58,11 +56,6 @@ Settings& FrameHost::settings() const
return m_page->settings();
}
Chrome& FrameHost::chrome() const
{
return m_page->chrome();
}
float FrameHost::deviceScaleFactor() const
{
return m_page->deviceScaleFactor();

View File

@ -39,7 +39,6 @@
namespace blink {
class Chrome;
class Page;
class ServiceProvider;
class Settings;
@ -62,7 +61,6 @@ public:
// Careful: This function will eventually be removed.
Page& page() const { return *m_page; }
Settings& settings() const;
Chrome& chrome() const;
ServiceProvider& services() const { return m_services; }

View File

@ -40,7 +40,6 @@
#include "sky/engine/core/html/parser/TextResourceDecoder.h"
#include "sky/engine/core/inspector/InspectorTraceEvents.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/FocusController.h"
@ -361,15 +360,6 @@ void FrameView::layout(bool allowSubtree)
// Post-layout assert that nobody was re-marked as needing layout during layout.
document->renderView()->assertSubtreeIsLaidOut();
#endif
// FIXME: It should be not possible to remove the FrameView from the frame/page during layout
// however m_inPerformLayout is not set for most of this function, so none of our RELEASE_ASSERTS
// in LocalFrame/Page will fire. One of the post-layout tasks is disconnecting the LocalFrame from
// the page in fast/frames/crash-remove-iframe-during-object-beforeload-2.html
// necessitating this check here.
// ASSERT(frame()->page());
if (frame().page())
frame().page()->chrome().client().layoutUpdated(m_frame.get());
}
DocumentLifecycle& FrameView::lifecycle() const
@ -414,10 +404,7 @@ void FrameView::setLayoutSize(const IntSize& size)
HostWindow* FrameView::hostWindow() const
{
Page* page = frame().page();
if (!page)
return 0;
return &page->chrome();
return frame().page();
}
void FrameView::contentsResized()
@ -855,7 +842,7 @@ void FrameView::setCursor(const Cursor& cursor)
Page* page = frame().page();
if (!page || !page->settings().deviceSupportsMouse())
return;
page->chrome().setCursor(cursor);
page->setCursor(cursor);
}
void FrameView::setLayoutSizeInternal(const IntSize& size)

View File

@ -65,7 +65,6 @@
#include "sky/engine/core/inspector/ConsoleMessageStorage.h"
#include "sky/engine/core/inspector/InspectorTraceEvents.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/Page.h"
@ -151,7 +150,7 @@ FloatRect LocalDOMWindow::adjustWindowRect(LocalFrame& frame, const FloatRect& p
ASSERT(host);
FloatRect screen = screenAvailableRect(frame.view());
FloatRect window = host->chrome().windowRect();
FloatRect window = host->page().windowRect();
// Make sure we're in a valid state before adjusting dimensions.
ASSERT(std::isfinite(screen.x()));
@ -173,7 +172,8 @@ FloatRect LocalDOMWindow::adjustWindowRect(LocalFrame& frame, const FloatRect& p
if (!std::isnan(pendingChanges.height()))
window.setHeight(pendingChanges.height());
FloatSize minimumSize = host->chrome().client().minimumWindowSize();
// TODO(esprehn): What?
FloatSize minimumSize = FloatSize(100, 100);
// Let size 0 pass through, since that indicates default size, not minimum size.
if (window.width())
window.setWidth(min(max(minimumSize.width(), window.width()), screen.width()));
@ -439,7 +439,7 @@ void LocalDOMWindow::focus(ExecutionContext* context)
if (!host)
return;
host->chrome().focus();
host->page().focus();
if (!m_frame)
return;
@ -456,7 +456,7 @@ int LocalDOMWindow::outerHeight() const
if (!host)
return 0;
return static_cast<int>(host->chrome().windowRect().height());
return static_cast<int>(host->page().windowRect().height());
}
int LocalDOMWindow::outerWidth() const
@ -468,7 +468,7 @@ int LocalDOMWindow::outerWidth() const
if (!host)
return 0;
return static_cast<int>(host->chrome().windowRect().width());
return static_cast<int>(host->page().windowRect().width());
}
int LocalDOMWindow::innerHeight() const
@ -504,7 +504,7 @@ int LocalDOMWindow::screenX() const
if (!host)
return 0;
return static_cast<int>(host->chrome().windowRect().x());
return static_cast<int>(host->page().windowRect().x());
}
int LocalDOMWindow::screenY() const
@ -516,7 +516,7 @@ int LocalDOMWindow::screenY() const
if (!host)
return 0;
return static_cast<int>(host->chrome().windowRect().y());
return static_cast<int>(host->page().windowRect().y());
}
LocalDOMWindow* LocalDOMWindow::window() const
@ -557,10 +557,10 @@ void LocalDOMWindow::moveBy(float x, float y) const
if (!host)
return;
FloatRect windowRect = host->chrome().windowRect();
FloatRect windowRect = host->page().windowRect();
windowRect.move(x, y);
// Security check (the spec talks about UniversalBrowserWrite to disable this check...)
host->chrome().setWindowRect(adjustWindowRect(*m_frame, windowRect));
host->page().setWindowRect(adjustWindowRect(*m_frame, windowRect));
}
void LocalDOMWindow::moveTo(float x, float y) const
@ -572,10 +572,10 @@ void LocalDOMWindow::moveTo(float x, float y) const
if (!host)
return;
FloatRect windowRect = host->chrome().windowRect();
FloatRect windowRect = host->page().windowRect();
windowRect.setLocation(FloatPoint(x, y));
// Security check (the spec talks about UniversalBrowserWrite to disable this check...)
host->chrome().setWindowRect(adjustWindowRect(*m_frame, windowRect));
host->page().setWindowRect(adjustWindowRect(*m_frame, windowRect));
}
void LocalDOMWindow::resizeBy(float x, float y) const
@ -587,10 +587,10 @@ void LocalDOMWindow::resizeBy(float x, float y) const
if (!host)
return;
FloatRect fr = host->chrome().windowRect();
FloatRect fr = host->page().windowRect();
FloatSize dest = fr.size() + FloatSize(x, y);
FloatRect update(fr.location(), dest);
host->chrome().setWindowRect(adjustWindowRect(*m_frame, update));
host->page().setWindowRect(adjustWindowRect(*m_frame, update));
}
void LocalDOMWindow::resizeTo(float width, float height) const
@ -602,10 +602,10 @@ void LocalDOMWindow::resizeTo(float width, float height) const
if (!host)
return;
FloatRect fr = host->chrome().windowRect();
FloatRect fr = host->page().windowRect();
FloatSize dest = FloatSize(width, height);
FloatRect update(fr.location(), dest);
host->chrome().setWindowRect(adjustWindowRect(*m_frame, update));
host->page().setWindowRect(adjustWindowRect(*m_frame, update));
}
int LocalDOMWindow::requestAnimationFrame(PassOwnPtr<RequestAnimationFrameCallback> callback)

View File

@ -49,7 +49,6 @@
#include "sky/engine/core/inspector/ConsoleMessageStorage.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/loader/MojoLoader.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/FocusController.h"
#include "sky/engine/core/page/Page.h"

View File

@ -35,7 +35,6 @@
#include "sky/engine/core/html/parser/HTMLParserIdioms.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/loader/FrameLoaderTypes.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/rendering/RenderImage.h"
#include "sky/engine/platform/network/ResourceRequest.h"

View File

@ -35,9 +35,6 @@ namespace blink {
void fillWithEmptyClients(Page::PageClients& pageClients)
{
static ChromeClient* dummyChromeClient = adoptPtr(new EmptyChromeClient).leakPtr();
pageClients.chromeClient = dummyChromeClient;
static EditorClient* dummyEditorClient = adoptPtr(new EmptyEditorClient).leakPtr();
pageClients.editorClient = dummyEditorClient;
@ -45,11 +42,6 @@ void fillWithEmptyClients(Page::PageClients& pageClients)
pageClients.spellCheckerClient = dummySpellCheckerClient;
}
String EmptyChromeClient::acceptLanguages()
{
return String();
}
NavigationPolicy EmptyFrameLoaderClient::decidePolicyForNavigation(const ResourceRequest&, Document*, NavigationPolicy, bool isTransitionNavigation)
{
return NavigationPolicyIgnore;

View File

@ -58,40 +58,6 @@
namespace blink {
class EmptyChromeClient : public ChromeClient {
WTF_MAKE_FAST_ALLOCATED;
public:
virtual ~EmptyChromeClient() { }
virtual void chromeDestroyed() override { }
virtual void* webView() const override { return 0; }
virtual void setWindowRect(const FloatRect&) override { }
virtual FloatRect windowRect() override { return FloatRect(); }
virtual FloatRect pageRect() override { return FloatRect(); }
virtual void focus() override { }
virtual bool canTakeFocus(FocusType) override { return false; }
virtual void takeFocus(FocusType) override { }
virtual void focusedNodeChanged(Node*) override { }
virtual void focusedFrameChanged(LocalFrame*) override { }
virtual void show(NavigationPolicy) override { }
virtual bool shouldReportDetailedMessageForSource(const String&) override { return false; }
virtual void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const String&, unsigned, const String&, const String&) override { }
virtual void scheduleVisualUpdate() override { }
virtual IntRect rootViewToScreen(const IntRect& r) const override { return r; }
virtual blink::WebScreenInfo screenInfo() const override { return blink::WebScreenInfo(); }
virtual void setCursor(const Cursor&) override { }
virtual String acceptLanguages() override;
};
class EmptyFrameLoaderClient : public FrameLoaderClient {
WTF_MAKE_NONCOPYABLE(EmptyFrameLoaderClient); WTF_MAKE_FAST_ALLOCATED;
public:

View File

@ -58,7 +58,6 @@
#include "sky/engine/core/loader/FrameFetchContext.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/loader/UniqueIdentifier.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/Page.h"

View File

@ -31,7 +31,6 @@
#include "sky/engine/core/frame/FrameView.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/Page.h"
#include "sky/engine/core/rendering/HitTestResult.h"

View File

@ -1,117 +0,0 @@
/*
* Copyright (C) 2006, 2007, 2009, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2012, Samsung Electronics. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "sky/engine/config.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/rendering/HitTestResult.h"
#include "sky/engine/platform/Logging.h"
#include "sky/engine/platform/geometry/FloatRect.h"
#include "sky/engine/public/platform/WebScreenInfo.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/Vector.h"
namespace blink {
Chrome::Chrome(ChromeClient* client)
: m_client(client)
{
ASSERT(m_client);
}
Chrome::~Chrome()
{
}
PassOwnPtr<Chrome> Chrome::create(ChromeClient* client)
{
return adoptPtr(new Chrome(client));
}
IntRect Chrome::rootViewToScreen(const IntRect& rect) const
{
return m_client->rootViewToScreen(rect);
}
blink::WebScreenInfo Chrome::screenInfo() const
{
return m_client->screenInfo();
}
void Chrome::setWindowRect(const FloatRect& rect) const
{
m_client->setWindowRect(rect);
}
FloatRect Chrome::windowRect() const
{
return m_client->windowRect();
}
FloatRect Chrome::pageRect() const
{
return m_client->pageRect();
}
void Chrome::focus() const
{
m_client->focus();
}
bool Chrome::canTakeFocus(FocusType type) const
{
return m_client->canTakeFocus(type);
}
void Chrome::takeFocus(FocusType type) const
{
m_client->takeFocus(type);
}
void Chrome::focusedNodeChanged(Node* node) const
{
m_client->focusedNodeChanged(node);
}
void Chrome::show(NavigationPolicy policy) const
{
m_client->show(policy);
}
void Chrome::setCursor(const Cursor& cursor)
{
m_client->setCursor(cursor);
}
void Chrome::scheduleVisualUpdate()
{
m_client->scheduleVisualUpdate();
}
void Chrome::willBeDestroyed()
{
m_client->chromeDestroyed();
}
} // namespace blink

View File

@ -1,87 +0,0 @@
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2012, Samsung Electronics. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SKY_ENGINE_CORE_PAGE_CHROME_H_
#define SKY_ENGINE_CORE_PAGE_CHROME_H_
#include "sky/engine/core/loader/NavigationPolicy.h"
#include "sky/engine/core/page/FocusType.h"
#include "sky/engine/platform/Cursor.h"
#include "sky/engine/platform/HostWindow.h"
#include "sky/engine/wtf/Forward.h"
namespace blink {
class ChromeClient;
class ColorChooser;
class ColorChooserClient;
class DateTimeChooser;
class DateTimeChooserClient;
class FloatRect;
class LocalFrame;
class HitTestResult;
class IntRect;
class Node;
class Page;
struct DateTimeChooserParameters;
class Chrome final : public HostWindow {
public:
virtual ~Chrome();
static PassOwnPtr<Chrome> create(ChromeClient*);
ChromeClient& client() { return *m_client; }
// HostWindow methods.
virtual IntRect rootViewToScreen(const IntRect&) const override;
virtual blink::WebScreenInfo screenInfo() const override;
virtual void scheduleVisualUpdate() override;
void setCursor(const Cursor&);
void setWindowRect(const FloatRect&) const;
FloatRect windowRect() const;
FloatRect pageRect() const;
void focus() const;
bool canTakeFocus(FocusType) const;
void takeFocus(FocusType) const;
void focusedNodeChanged(Node*) const;
void show(NavigationPolicy = NavigationPolicyIgnore) const;
void willBeDestroyed();
private:
Chrome(ChromeClient*);
ChromeClient* m_client;
};
}
#endif // SKY_ENGINE_CORE_PAGE_CHROME_H_

View File

@ -22,59 +22,35 @@
#ifndef SKY_ENGINE_CORE_PAGE_CHROMECLIENT_H_
#define SKY_ENGINE_CORE_PAGE_CHROMECLIENT_H_
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/frame/ConsoleTypes.h"
#include "sky/engine/core/inspector/ConsoleAPITypes.h"
#include "sky/engine/core/loader/NavigationPolicy.h"
#include "sky/engine/core/page/FocusType.h"
#include "sky/engine/core/rendering/style/RenderStyleConstants.h"
#include "sky/engine/platform/Cursor.h"
#include "sky/engine/platform/HostWindow.h"
#include "sky/engine/platform/scroll/ScrollTypes.h"
#include "sky/engine/public/platform/WebScreenInfo.h"
#include "sky/engine/wtf/Forward.h"
#include "sky/engine/wtf/PassOwnPtr.h"
#include "sky/engine/wtf/Vector.h"
namespace blink {
class ColorChooser;
class ColorChooserClient;
class DateTimeChooser;
class DateTimeChooserClient;
class Element;
class FloatRect;
class Frame;
class GraphicsContext;
class HitTestResult;
class IntRect;
class LocalFrame;
class Node;
class Page;
class Widget;
struct DateTimeChooserParameters;
struct GraphicsDeviceAdapter;
class ChromeClient {
public:
virtual void chromeDestroyed() = 0;
virtual void setWindowRect(const FloatRect&) = 0;
virtual FloatRect windowRect() = 0;
virtual FloatRect pageRect() = 0;
virtual void focus() = 0;
virtual bool canTakeFocus(FocusType) = 0;
virtual void takeFocus(FocusType) = 0;
virtual void focusedNodeChanged(Node*) = 0;
virtual void focusedFrameChanged(LocalFrame*) = 0;
virtual void show(NavigationPolicy) = 0;
virtual bool shouldReportDetailedMessageForSource(const String& source) = 0;
virtual void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace) = 0;
@ -83,28 +59,13 @@ public:
// Methods used by HostWindow.
virtual IntRect rootViewToScreen(const IntRect&) const = 0;
virtual blink::WebScreenInfo screenInfo() const = 0;
virtual void setCursor(const Cursor&) = 0;
virtual void scheduleVisualUpdate() = 0;
// End methods used by HostWindow.
virtual void layoutUpdated(LocalFrame*) const { }
virtual void setCursor(const Cursor&) = 0;
virtual String acceptLanguages() = 0;
enum DialogType {
AlertDialog = 0,
ConfirmDialog = 1,
PromptDialog = 2,
HTMLDialog = 3
};
virtual FloatSize minimumWindowSize() const { return FloatSize(100, 100); };
virtual bool isChromeClientImpl() const { return false; }
// Input mehtod editor related functions.
virtual void willSetInputMethodState() { }
protected:
virtual ~ChromeClient() { }
};

View File

@ -49,7 +49,6 @@
#include "sky/engine/core/frame/Settings.h"
#include "sky/engine/core/loader/FrameLoaderClient.h"
#include "sky/engine/core/page/AutoscrollController.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/EditorClient.h"
#include "sky/engine/core/page/FocusController.h"

View File

@ -44,7 +44,6 @@
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/frame/Settings.h"
#include "sky/engine/core/html/HTMLImageElement.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/Page.h"
@ -216,7 +215,7 @@ void FocusController::setFocusedFrame(PassRefPtr<LocalFrame> frame)
m_isChangingFocusedFrame = false;
m_page->chrome().client().focusedFrameChanged(newFrame.get());
m_page->focusedFrameChanged(newFrame.get());
}
void FocusController::focusDocumentView(PassRefPtr<LocalFrame> frame)
@ -326,10 +325,10 @@ bool FocusController::advanceFocusInDocumentOrder(FocusType type, bool initialFo
if (!node) {
// We didn't find a node to focus, so we should try to pass focus to Chrome.
if (!initialFocus && m_page->chrome().canTakeFocus(type)) {
if (!initialFocus && m_page->canTakeFocus(type)) {
document->setFocusedElement(nullptr);
setFocusedFrame(nullptr);
m_page->chrome().takeFocus(type);
m_page->takeFocus(type);
return true;
}
@ -554,8 +553,6 @@ bool FocusController::setFocusedElement(Element* element, PassRefPtr<LocalFrame>
if (oldFocusedElement && oldFocusedElement->isRootEditableElement() && !relinquishesEditingFocus(oldFocusedElement))
return false;
m_page->chrome().client().willSetInputMethodState();
RefPtr<Document> newDocument = nullptr;
if (element)
newDocument = &element->document();

View File

@ -21,6 +21,7 @@
#include "sky/engine/core/page/Page.h"
#include "sky/engine/core/dom/ClientRectList.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/dom/DocumentMarkerController.h"
#include "sky/engine/core/dom/StyleEngine.h"
#include "sky/engine/core/editing/Caret.h"
@ -35,14 +36,17 @@
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/frame/Settings.h"
#include "sky/engine/core/page/AutoscrollController.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/FocusController.h"
#include "sky/engine/core/page/PageLifecycleNotifier.h"
#include "sky/engine/core/rendering/RenderView.h"
#include "sky/engine/platform/geometry/FloatRect.h"
#include "sky/engine/public/platform/WebScreenInfo.h"
#include "sky/engine/wtf/HashMap.h"
#include "sky/engine/wtf/PassRefPtr.h"
#include "sky/engine/wtf/RefCountedLeakCounter.h"
#include "sky/engine/wtf/StdLibExtras.h"
#include "sky/engine/wtf/Vector.h"
#include "sky/engine/wtf/text/Base64.h"
namespace blink {
@ -63,7 +67,7 @@ Page::Page(PageClients& pageClients, ServiceProvider& services)
: SettingsDelegate(Settings::create())
, m_animator(this)
, m_autoscrollController(AutoscrollController::create(*this))
, m_chrome(Chrome::create(pageClients.chromeClient))
, m_chromeClient(pageClients.chromeClient)
, m_dragCaretController(DragCaretController::create())
, m_focusController(FocusController::create(this))
, m_undoStack(UndoStack::create())
@ -270,10 +274,79 @@ void Page::willBeDestroyed()
pageCounter.decrement();
#endif
m_chrome->willBeDestroyed();
m_mainFrame = 0;
}
IntRect Page::rootViewToScreen(const IntRect& rect) const
{
return m_chromeClient->rootViewToScreen(rect);
}
blink::WebScreenInfo Page::screenInfo() const
{
return m_chromeClient->screenInfo();
}
void Page::setWindowRect(const FloatRect& rect) const
{
m_chromeClient->setWindowRect(rect);
}
FloatRect Page::windowRect() const
{
return m_chromeClient->windowRect();
}
void Page::focus() const
{
m_chromeClient->focus();
}
bool Page::canTakeFocus(FocusType type) const
{
return m_chromeClient->canTakeFocus(type);
}
void Page::takeFocus(FocusType type) const
{
m_chromeClient->takeFocus(type);
}
void Page::focusedNodeChanged(Node* node) const
{
m_chromeClient->focusedNodeChanged(node);
}
void Page::focusedFrameChanged(LocalFrame* frame) const
{
m_chromeClient->focusedFrameChanged(frame);
}
void Page::scheduleVisualUpdate()
{
m_chromeClient->scheduleVisualUpdate();
}
void Page::setCursor(const Cursor& cursor)
{
m_chromeClient->setCursor(cursor);
}
bool Page::shouldReportDetailedMessageForSource(const String& source)
{
return m_chromeClient->shouldReportDetailedMessageForSource(source);
}
void Page::addMessageToConsole(LocalFrame* localFrame, MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace)
{
m_chromeClient->addMessageToConsole(localFrame, source, level, message, lineNumber, sourceID, stackTrace);
}
void* Page::webView() const
{
return m_chromeClient->webView();
}
Page::PageClients::PageClients()
: chromeClient(0)
, editorClient(0)

View File

@ -21,10 +21,15 @@
#ifndef SKY_ENGINE_CORE_PAGE_PAGE_H_
#define SKY_ENGINE_CORE_PAGE_PAGE_H_
#include "sky/engine/core/frame/ConsoleTypes.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/frame/SettingsDelegate.h"
#include "sky/engine/core/inspector/ConsoleAPITypes.h"
#include "sky/engine/core/page/FocusType.h"
#include "sky/engine/core/page/PageAnimator.h"
#include "sky/engine/core/page/PageVisibilityState.h"
#include "sky/engine/platform/Cursor.h"
#include "sky/engine/platform/HostWindow.h"
#include "sky/engine/platform/LifecycleContext.h"
#include "sky/engine/platform/Supplementable.h"
#include "sky/engine/platform/geometry/LayoutRect.h"
@ -38,15 +43,18 @@
namespace blink {
class AutoscrollController;
class Chrome;
class ChromeClient;
class ClientRectList;
class Document;
class DragCaretController;
class EditorClient;
class FloatRect;
class FocusController;
class Frame;
class FrameHost;
class IntRect;
class LocalFrame;
class Node;
class PageLifecycleNotifier;
class Range;
class RenderBox;
@ -62,7 +70,7 @@ typedef uint64_t LinkHash;
float deviceScaleFactor(LocalFrame*);
class Page final : public Supplementable<Page>, public LifecycleContext<Page>, public SettingsDelegate {
class Page final : public Supplementable<Page>, public LifecycleContext<Page>, public SettingsDelegate, public HostWindow {
WTF_MAKE_NONCOPYABLE(Page);
friend class Settings;
public:
@ -95,7 +103,6 @@ public:
void documentDetached(Document*);
PageAnimator& animator() { return m_animator; }
Chrome& chrome() const { return *m_chrome; }
AutoscrollController& autoscrollController() const { return *m_autoscrollController; }
DragCaretController& dragCaretController() const { return *m_dragCaretController; }
FocusController& focusController() const { return *m_focusController; }
@ -136,10 +143,32 @@ public:
void willBeDestroyed();
protected:
PageLifecycleNotifier& lifecycleNotifier();
// HostWindow methods.
virtual IntRect rootViewToScreen(const IntRect&) const override;
virtual blink::WebScreenInfo screenInfo() const override;
virtual void scheduleVisualUpdate() override;
void setWindowRect(const FloatRect&) const;
FloatRect windowRect() const;
void focus() const;
bool canTakeFocus(FocusType) const;
void takeFocus(FocusType) const;
void focusedNodeChanged(Node*) const;
void focusedFrameChanged(LocalFrame*) const;
bool shouldReportDetailedMessageForSource(const String& source);
void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace);
void setCursor(const Cursor&);
void* webView() const;
private:
PageLifecycleNotifier& lifecycleNotifier();
void initGroup();
void setTimerAlignmentInterval(double);
@ -151,7 +180,7 @@ private:
PageAnimator m_animator;
const OwnPtr<AutoscrollController> m_autoscrollController;
const OwnPtr<Chrome> m_chrome;
ChromeClient* m_chromeClient;
const OwnPtr<DragCaretController> m_dragCaretController;
const OwnPtr<FocusController> m_focusController;
const OwnPtr<UndoStack> m_undoStack;

View File

@ -6,9 +6,9 @@
#include "sky/engine/core/page/PageAnimator.h"
#include "sky/engine/core/animation/DocumentAnimations.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/frame/FrameView.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/ChromeClient.h"
#include "sky/engine/core/page/Page.h"
#include "sky/engine/platform/Logging.h"
@ -43,7 +43,7 @@ void PageAnimator::scheduleVisualUpdate()
{
if (m_servicingAnimations || m_updatingLayoutAndStyleForPainting)
return;
m_page->chrome().scheduleVisualUpdate();
m_page->scheduleVisualUpdate();
}
void PageAnimator::updateLayoutAndStyleForPainting(LocalFrame* rootFrame)

View File

@ -24,7 +24,6 @@
#include "sky/engine/core/rendering/RenderInline.h"
#include "sky/engine/core/dom/StyleEngine.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/Page.h"
#include "sky/engine/core/rendering/HitTestResult.h"
#include "sky/engine/core/rendering/InlineTextBox.h"

View File

@ -50,7 +50,6 @@
#include "sky/engine/core/frame/FrameView.h"
#include "sky/engine/core/frame/LocalFrame.h"
#include "sky/engine/core/inspector/InspectorTraceEvents.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/FocusController.h"
#include "sky/engine/core/page/Page.h"
@ -99,9 +98,7 @@ RenderLayerScrollableArea::~RenderLayerScrollableArea()
HostWindow* RenderLayerScrollableArea::hostWindow() const
{
if (Page* page = box().frame()->page())
return &page->chrome();
return nullptr;
return box().frame()->page();
}
bool RenderLayerScrollableArea::isActive() const

View File

@ -118,13 +118,6 @@ public:
// Called when a new node gets focused.
virtual void focusedNodeChanged(const WebNode&) { }
// Indicates two things:
// 1) This view may have a new layout now.
// 2) Calling layout() is a no-op.
// After calling WebWidget::layout(), expect to get this notification
// unless the view did not need a layout.
virtual void didUpdateLayout() { }
// Returns comma separated list of accept languages.
virtual WebString acceptLanguages() { return WebString(); }

View File

@ -86,11 +86,6 @@ void* ChromeClientImpl::webView() const
return static_cast<void*>(m_webView);
}
void ChromeClientImpl::chromeDestroyed()
{
// Our lifetime is bound to the WebViewImpl.
}
void ChromeClientImpl::setWindowRect(const FloatRect& r)
{
if (m_webView->client())
@ -112,14 +107,6 @@ FloatRect ChromeClientImpl::windowRect()
return FloatRect(rect);
}
FloatRect ChromeClientImpl::pageRect()
{
// We hide the details of the window's border thickness from the web page by
// simple re-using the window position here. So, from the point-of-view of
// the web page, the window has no border.
return windowRect();
}
void ChromeClientImpl::focus()
{
}
@ -163,10 +150,6 @@ WebNavigationPolicy ChromeClientImpl::getNavigationPolicy()
return WebNavigationPolicyCurrentTab;
}
void ChromeClientImpl::show(NavigationPolicy navigationPolicy)
{
}
bool ChromeClientImpl::shouldReportDetailedMessageForSource(const String& url)
{
WebLocalFrameImpl* webframe = m_webView->mainFrameImpl();
@ -238,11 +221,6 @@ WebScreenInfo ChromeClientImpl::screenInfo() const
return m_webView->client() ? m_webView->client()->screenInfo() : WebScreenInfo();
}
void ChromeClientImpl::layoutUpdated(LocalFrame* frame) const
{
m_webView->layoutUpdated(WebLocalFrameImpl::fromFrame(frame));
}
void ChromeClientImpl::setCursor(const Cursor& cursor)
{
setCursor(WebCursorInfo(cursor));
@ -257,8 +235,4 @@ String ChromeClientImpl::acceptLanguages()
return m_webView->client()->acceptLanguages();
}
void ChromeClientImpl::willSetInputMethodState()
{
}
} // namespace blink

View File

@ -59,16 +59,14 @@ public:
virtual void* webView() const override;
// ChromeClient methods:
virtual void chromeDestroyed() override;
virtual void setWindowRect(const FloatRect&) override;
virtual FloatRect windowRect() override;
virtual FloatRect pageRect() override;
virtual void focus() override;
virtual bool canTakeFocus(FocusType) override;
virtual void takeFocus(FocusType) override;
virtual void focusedNodeChanged(Node*) override;
virtual void focusedFrameChanged(LocalFrame*) override;
virtual void show(NavigationPolicy) override;
virtual bool shouldReportDetailedMessageForSource(const WTF::String&) override;
virtual void addMessageToConsole(
LocalFrame*, MessageSource, MessageLevel,
@ -77,28 +75,18 @@ public:
virtual void scheduleVisualUpdate() override;
virtual IntRect rootViewToScreen(const IntRect&) const override;
virtual WebScreenInfo screenInfo() const override;
virtual void layoutUpdated(LocalFrame*) const override;
virtual void setCursor(const Cursor&) override;
// ChromeClient methods:
virtual String acceptLanguages() override;
// ChromeClientImpl:
void setNewWindowNavigationPolicy(WebNavigationPolicy);
virtual void willSetInputMethodState() override;
private:
virtual bool isChromeClientImpl() const override { return true; }
WebNavigationPolicy getNavigationPolicy();
void setCursor(const WebCursorInfo&);
WebViewImpl* m_webView; // weak pointer
};
DEFINE_TYPE_CASTS(ChromeClientImpl, ChromeClient, client, client->isChromeClientImpl(), client.isChromeClientImpl());
} // namespace blink
#endif // SKY_ENGINE_WEB_CHROMECLIENTIMPL_H_

View File

@ -38,7 +38,6 @@
#include "sky/engine/core/frame/FrameView.h"
#include "sky/engine/core/frame/Settings.h"
#include "sky/engine/core/html/HTMLIFrameElement.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/Page.h"
#include "sky/engine/core/rendering/HitTestResult.h"

View File

@ -27,6 +27,7 @@
#include "sky/engine/config.h"
#include "sky/engine/web/SpellCheckerClientImpl.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/dom/DocumentMarkerController.h"
#include "sky/engine/core/dom/Element.h"
#include "sky/engine/core/editing/Editor.h"

View File

@ -102,7 +102,6 @@
#include "sky/engine/core/html/HTMLAnchorElement.h"
#include "sky/engine/core/inspector/ConsoleMessage.h"
#include "sky/engine/core/loader/MojoLoader.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/FocusController.h"
#include "sky/engine/core/page/Page.h"

View File

@ -53,7 +53,6 @@
#include "sky/engine/core/loader/FrameLoader.h"
#include "sky/engine/core/loader/UniqueIdentifier.h"
#include "sky/engine/core/page/AutoscrollController.h"
#include "sky/engine/core/page/Chrome.h"
#include "sky/engine/core/page/EventHandler.h"
#include "sky/engine/core/page/FocusController.h"
#include "sky/engine/core/page/Page.h"
@ -196,7 +195,7 @@ WebViewImpl* WebViewImpl::fromPage(Page* page)
{
if (!page)
return 0;
return static_cast<WebViewImpl*>(page->chrome().client().webView());
return static_cast<WebViewImpl*>(page->webView());
}
// WebWidget ------------------------------------------------------------------
@ -823,13 +822,6 @@ void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag
{
}
void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe)
{
if (!m_client)
return;
m_client->didUpdateLayout();
}
void WebViewImpl::setBackgroundColorOverride(WebColor color)
{
m_backgroundColorOverride = color;

View File

@ -31,6 +31,7 @@
#ifndef SKY_ENGINE_WEB_WEBVIEWIMPL_H_
#define SKY_ENGINE_WEB_WEBVIEWIMPL_H_
#include "sky/engine/core/rendering/HitTestResult.h"
#include "sky/engine/platform/geometry/IntPoint.h"
#include "sky/engine/platform/geometry/IntRect.h"
#include "sky/engine/public/platform/WebInputEvent.h"
@ -54,6 +55,7 @@ class Frame;
class WebLocalFrameImpl;
class WebImage;
class WebSettingsImpl;
class Page;
class WebViewImpl final : public WebView, public RefCounted<WebViewImpl> {
public:
@ -154,13 +156,6 @@ public:
// not take the user away from the current page.
void didCommitLoad(bool isNewNavigation, bool isNavigationWithinPage);
// Indicates two things:
// 1) This view may have a new layout now.
// 2) Calling layout() is a no-op.
// After calling WebWidget::layout(), expect to get this notification
// unless the view did not need a layout.
void layoutUpdated(WebLocalFrameImpl*);
void updateMainFrameLayoutSize();
void scheduleVisualUpdate();