Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "public/web/WebFrame.h" | 5 #include "public/web/WebFrame.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/WindowProxyManager.h" | 7 #include "bindings/core/v8/WindowProxyManager.h" |
| 8 #include "core/HTMLNames.h" | |
| 8 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
| 11 #include "core/frame/RemoteFrame.h" | 12 #include "core/frame/RemoteFrame.h" |
| 12 #include "core/html/HTMLFrameElementBase.h" | 13 #include "core/html/HTMLFrameElementBase.h" |
| 13 #include "core/html/HTMLFrameOwnerElement.h" | 14 #include "core/html/HTMLFrameOwnerElement.h" |
| 14 #include "core/page/Page.h" | 15 #include "core/page/Page.h" |
| 15 #include "platform/UserGestureIndicator.h" | 16 #include "platform/UserGestureIndicator.h" |
| 16 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
| 17 #include "public/web/WebElement.h" | 18 #include "public/web/WebElement.h" |
| 18 #include "public/web/WebFrameOwnerProperties.h" | 19 #include "public/web/WebFrameOwnerProperties.h" |
| 19 #include "public/web/WebSandboxFlags.h" | 20 #include "public/web/WebSandboxFlags.h" |
| 20 #include "web/OpenedFrameTracker.h" | 21 #include "web/OpenedFrameTracker.h" |
| 21 #include "web/RemoteFrameOwner.h" | 22 #include "web/RemoteFrameOwner.h" |
| 22 #include "web/WebLocalFrameImpl.h" | 23 #include "web/WebLocalFrameImpl.h" |
| 23 #include "web/WebRemoteFrameImpl.h" | 24 #include "web/WebRemoteFrameImpl.h" |
| 25 #include "wtf/Optional.h" | |
| 24 #include <algorithm> | 26 #include <algorithm> |
| 25 | 27 |
| 26 namespace blink { | 28 namespace blink { |
| 27 | 29 |
| 30 using namespace HTMLNames; | |
| 31 | |
| 28 bool WebFrame::swap(WebFrame* frame) { | 32 bool WebFrame::swap(WebFrame* frame) { |
| 29 using std::swap; | 33 using std::swap; |
| 30 Frame* oldFrame = toImplBase()->frame(); | 34 Frame* oldFrame = toImplBase()->frame(); |
| 31 if (oldFrame->isDetaching()) | 35 if (oldFrame->isDetaching()) |
| 32 return false; | 36 return false; |
| 33 | 37 |
| 34 // Unload the current Document in this frame: this calls unload handlers, | 38 // Unload the current Document in this frame: this calls unload handlers, |
| 35 // detaches child frames, etc. Since this runs script, make sure this frame | 39 // detaches child frames, etc. Since this runs script, make sure this frame |
| 36 // wasn't detached before continuing with the swap. | 40 // wasn't detached before continuing with the swap. |
| 37 // FIXME: There is no unit test for this condition, so one needs to be | 41 // FIXME: There is no unit test for this condition, so one needs to be |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 WebInsecureRequestPolicy WebFrame::getInsecureRequestPolicy() const { | 135 WebInsecureRequestPolicy WebFrame::getInsecureRequestPolicy() const { |
| 132 return toImplBase()->frame()->securityContext()->getInsecureRequestPolicy(); | 136 return toImplBase()->frame()->securityContext()->getInsecureRequestPolicy(); |
| 133 } | 137 } |
| 134 | 138 |
| 135 void WebFrame::setFrameOwnerProperties( | 139 void WebFrame::setFrameOwnerProperties( |
| 136 const WebFrameOwnerProperties& properties) { | 140 const WebFrameOwnerProperties& properties) { |
| 137 // At the moment, this is only used to replicate frame owner properties | 141 // At the moment, this is only used to replicate frame owner properties |
| 138 // for frames with a remote owner. | 142 // for frames with a remote owner. |
| 139 RemoteFrameOwner* owner = toRemoteFrameOwner(toImplBase()->frame()->owner()); | 143 RemoteFrameOwner* owner = toRemoteFrameOwner(toImplBase()->frame()->owner()); |
| 140 DCHECK(owner); | 144 DCHECK(owner); |
| 141 owner->setScrollingMode(properties.scrollingMode); | 145 |
| 142 owner->setMarginWidth(properties.marginWidth); | 146 Optional<int> marginWidth; |
| 143 owner->setMarginHeight(properties.marginHeight); | 147 Optional<int> marginHeight; |
| 148 bool scrollingModeChanged = false; | |
| 149 | |
| 150 if (owner->scrollingMode() != | |
| 151 static_cast<ScrollbarMode>(properties.scrollingMode)) { | |
| 152 owner->setScrollingMode(properties.scrollingMode); | |
|
bokan
2016/11/21 13:21:52
There's no need to check for changes when setting
| |
| 153 scrollingModeChanged = true; | |
| 154 } | |
| 155 if (owner->marginWidth() != properties.marginWidth) { | |
| 156 owner->setMarginWidth(properties.marginWidth); | |
| 157 marginWidth = properties.marginWidth; | |
| 158 } | |
| 159 if (owner->marginHeight() != properties.marginHeight) { | |
| 160 owner->setMarginHeight(properties.marginHeight); | |
| 161 marginHeight = properties.marginHeight; | |
| 162 } | |
| 144 owner->setAllowFullscreen(properties.allowFullscreen); | 163 owner->setAllowFullscreen(properties.allowFullscreen); |
| 145 owner->setCsp(properties.requiredCsp); | 164 owner->setCsp(properties.requiredCsp); |
| 146 owner->setDelegatedpermissions(properties.delegatedPermissions); | 165 owner->setDelegatedpermissions(properties.delegatedPermissions); |
| 166 | |
| 167 Frame* frame = toImplBase()->frame(); | |
| 168 DCHECK(frame); | |
| 169 | |
| 170 if (frame->isLocalFrame()) { | |
| 171 LocalFrame* localFrame = toLocalFrame(frame); | |
| 172 if (localFrame->document()) { | |
| 173 localFrame->document()->didChangeFrameOwnerProperties( | |
|
bokan
2016/11/21 13:21:52
If you move this up to before we set the values on
| |
| 174 marginWidth, marginHeight, scrollingModeChanged); | |
| 175 } | |
| 176 } | |
| 147 } | 177 } |
| 148 | 178 |
| 149 WebFrame* WebFrame::opener() const { | 179 WebFrame* WebFrame::opener() const { |
| 150 return m_opener; | 180 return m_opener; |
| 151 } | 181 } |
| 152 | 182 |
| 153 void WebFrame::setOpener(WebFrame* opener) { | 183 void WebFrame::setOpener(WebFrame* opener) { |
| 154 if (m_opener) | 184 if (m_opener) |
| 155 m_opener->m_openedFrameTracker->remove(this); | 185 m_opener->m_openedFrameTracker->remove(this); |
| 156 if (opener) | 186 if (opener) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { \ | 355 void WebFrame::clearWeakFrames(VisitorDispatcher visitor) { \ |
| 326 clearWeakFramesImpl(visitor); \ | 356 clearWeakFramesImpl(visitor); \ |
| 327 } | 357 } |
| 328 | 358 |
| 329 DEFINE_VISITOR_METHOD(Visitor*) | 359 DEFINE_VISITOR_METHOD(Visitor*) |
| 330 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor) | 360 DEFINE_VISITOR_METHOD(InlinedGlobalMarkingVisitor) |
| 331 | 361 |
| 332 #undef DEFINE_VISITOR_METHOD | 362 #undef DEFINE_VISITOR_METHOD |
| 333 | 363 |
| 334 } // namespace blink | 364 } // namespace blink |
| OLD | NEW |