OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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/frame/FrameletView.h" |
| 6 |
| 7 #include "core/events/Event.h" |
| 8 #include "core/frame/Framelet.h" |
| 9 #include "core/html/HTMLFrameOwnerElement.h" |
| 10 #include "core/layout/LayoutPart.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 FrameletView::FrameletView(Framelet* framelet) |
| 15 : m_framelet(framelet) |
| 16 { |
| 17 ASSERT(framelet); |
| 18 } |
| 19 |
| 20 FrameletView::~FrameletView() |
| 21 { |
| 22 } |
| 23 |
| 24 PassRefPtrWillBeRawPtr<FrameletView> FrameletView::create(Framelet* framelet) |
| 25 { |
| 26 RefPtrWillBeRawPtr<FrameletView> view = adoptRefWillBeNoop(new FrameletView(
framelet)); |
| 27 view->show(); |
| 28 return view.release(); |
| 29 } |
| 30 |
| 31 void FrameletView::dispose() |
| 32 { |
| 33 HTMLFrameOwnerElement* ownerElement = toHTMLFrameOwnerElement(m_framelet->ow
ner()); |
| 34 if (ownerElement && ownerElement->ownedWidget() == this) |
| 35 ownerElement->setWidget(nullptr); |
| 36 } |
| 37 |
| 38 void FrameletView::frameRectsChanged() |
| 39 { |
| 40 m_framelet->frameRectsChanged(frameRect()); |
| 41 } |
| 42 |
| 43 void FrameletView::hide() |
| 44 { |
| 45 setSelfVisible(false); |
| 46 m_framelet->updateVisibility(false); |
| 47 Widget::hide(); |
| 48 } |
| 49 |
| 50 void FrameletView::invalidateRect(const IntRect& rect) |
| 51 { |
| 52 LayoutPart* layoutObject = m_framelet->ownerLayoutObject(); |
| 53 if (!layoutObject) |
| 54 return; |
| 55 |
| 56 LayoutRect repaintRect(rect); |
| 57 repaintRect.move(layoutObject->borderLeft() + layoutObject->paddingLeft(), |
| 58 layoutObject->borderTop() + layoutObject->paddingTop()); |
| 59 layoutObject->invalidatePaintRectangle(repaintRect); |
| 60 } |
| 61 |
| 62 void FrameletView::setFocus(bool focused, WebFocusType focusType) |
| 63 { |
| 64 m_framelet->updateFocus(focused, focusType); |
| 65 } |
| 66 |
| 67 void FrameletView::setFrameRect(const IntRect& newRect) |
| 68 { |
| 69 IntRect oldRect = frameRect(); |
| 70 |
| 71 if (newRect == oldRect) |
| 72 return; |
| 73 |
| 74 Widget::setFrameRect(newRect); |
| 75 |
| 76 frameRectsChanged(); |
| 77 } |
| 78 |
| 79 void FrameletView::setParentVisible(bool parentVisible) |
| 80 { |
| 81 if (isParentVisible() == parentVisible) |
| 82 return; |
| 83 |
| 84 Widget::setParentVisible(parentVisible); |
| 85 if (!isSelfVisible()) |
| 86 return; |
| 87 |
| 88 m_framelet->updateVisibility(isVisible()); |
| 89 } |
| 90 |
| 91 void FrameletView::show() |
| 92 { |
| 93 setSelfVisible(true); |
| 94 m_framelet->updateVisibility(true); |
| 95 Widget::show(); |
| 96 } |
| 97 |
| 98 DEFINE_TRACE(FrameletView) |
| 99 { |
| 100 visitor->trace(m_framelet); |
| 101 Widget::trace(visitor); |
| 102 } |
| 103 |
| 104 } // namespace blink |
OLD | NEW |