Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: sky/engine/core/painting/LayoutRoot.cpp

Issue 1148253003: Add LayoutRoot (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Updated Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sky/engine/config.h"
6 #include "sky/engine/core/painting/LayoutRoot.h"
7
8 #include "sky/engine/core/dom/Document.h"
9 #include "sky/engine/core/dom/Element.h"
10 #include "sky/engine/core/frame/FrameView.h"
11 #include "sky/engine/core/frame/LocalFrame.h"
12 #include "sky/engine/core/frame/Settings.h"
13 #include "sky/engine/core/painting/PaintingTasks.h"
14 #include "sky/engine/platform/geometry/IntRect.h"
15 #include "third_party/skia/include/core/SkCanvas.h"
16
17 namespace blink {
18
19 PassRefPtr<LayoutRoot> LayoutRoot::create()
20 {
21 return adoptRef(new LayoutRoot);
22 }
23
24 LayoutRoot::LayoutRoot()
25 : m_minWidth(0)
26 , m_maxWidth(0)
27 , m_minHeight(0)
28 , m_maxHeight(0)
29 {
30 m_settings = Settings::create();
31 m_settings->setDefaultFixedFontSize(13);
32 m_settings->setDefaultFontSize(16);
33 m_frameHost = FrameHost::createDummy(m_settings.get());
34 m_frame = LocalFrame::create(nullptr, m_frameHost.get());
35 m_frame->createView(IntSize(), Color::white, false);
36 }
37
38 LayoutRoot::~LayoutRoot()
39 {
40 }
41
42 Element* LayoutRoot::rootElement() const
43 {
44 if (!m_document)
45 return nullptr;
46 return m_document->firstElementChild();
47 }
48
49 void LayoutRoot::setRootElement(Element* root)
50 {
51 m_document = &root->document();
52 m_frame->setDocument(m_document.get());
53 m_document->setFrame(m_frame.get());
54
55 m_document->attach();
56 m_document->setChild(root, ASSERT_NO_EXCEPTION);
57
58 m_document->setFrame(nullptr);
59 m_frame->setDocument(nullptr);
60 }
61
62 void LayoutRoot::layout()
63 {
64 m_frame->setDocument(m_document.get());
65 m_document->setFrame(m_frame.get());
66
67 LayoutUnit maxWidth = std::max(m_minWidth, m_maxWidth);
68 LayoutUnit maxHeight = std::max(m_minHeight, m_maxHeight);
69 IntSize maxSize(maxWidth, maxHeight);
70
71 m_frame->view()->setFrameRect(IntRect(IntPoint(), maxSize));
72 m_frame->view()->setLayoutSize(maxSize);
73
74 m_document->updateLayout();
75
76 m_document->setFrame(nullptr);
77 m_frame->setDocument(nullptr);
78 }
79
80 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698