OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 "core/observer/ResizeObservation.h" | |
6 | |
7 #include "core/layout/LayoutBox.h" | |
8 #include "core/observer/ResizeObserver.h" | |
9 | |
10 namespace blink { | |
11 | |
12 ResizeObservation::ResizeObservation(Element* target, ResizeObserver* observer) | |
13 : m_target(target) | |
14 , m_observer(observer) | |
15 { | |
16 DCHECK(target); | |
17 LayoutBox* layout = m_target->layoutBox(); | |
18 if (layout) | |
19 setBroadcastSize(layout->contentSize()); | |
20 | |
21 m_target->ensureResizeObserverData().set(observer, this); | |
22 } | |
23 | |
24 bool ResizeObservation::hasResized() const | |
25 { | |
26 if (!m_target) | |
27 return false; | |
28 LayoutBox* layout = m_target->layoutBox(); | |
29 if (layout) | |
30 return layout->contentSize() != m_broadcastSize; | |
31 // else treat no layout as an empty rect. | |
szager1
2016/06/02 20:52:41
Please make sure this behavior is discussed in the
atotic1
2016/06/08 18:59:21
Will do.
| |
32 return !m_broadcastSize.isEmpty(); | |
33 } | |
34 | |
35 DEFINE_TRACE(ResizeObservation) | |
36 { | |
37 visitor->trace(m_target); | |
38 visitor->trace(m_observer); | |
39 } | |
40 | |
41 | |
42 } // namespace blink | |
OLD | NEW |