Commit d79c6851 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Always route intrinsic size info changes through FrameOwner.

This simplifies the process of passing intrinsic sizing info around by
reusing the existing virtual on FrameOwner. Since the sizing info is only
needed by the RemoteFrameOwner implementation, RemoteFrameOwner now uses
LocalFrameView::GetIntrinsicSizingInfo() to calculate it on demand,
rather than relying on LayoutSVGRoot to pass it down.

However, this leads to some issues when building the layout tree; if
LayoutSVGRoot notifies RemoteFrameOwner to recalculate the intrinsic
sizing info, the call to GetIntrinsicSizingInfo() will fail, since the
LayoutSVGRoot is not yet in the actual layout tree.

To fix that, SVGSVGRoot now also overrides AttachLayoutTree() so that
RemoteFrameOwner no longer has to rely on LayoutSVGRoot::StyleDidChange
for the intrinsic sizing info changed notification when building the
layout tree.

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I2f459e6dcaceae287a2c97bf56da67ddc8a4f8c8
Reviewed-on: https://chromium-review.googlesource.com/958287
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#542678}
parent bd3098c6
......@@ -48,8 +48,4 @@ specific_include_rules = {
"+core/frame/WebRemoteFrameImpl.h",
"+gin"
],
# Allow LocalFrame.cpp to use WebLocalFrameImpl.h
"LocalFrame.cpp" : [
"+core/frame/WebLocalFrameImpl.h",
]
}
......@@ -45,8 +45,8 @@ class CORE_EXPORT FrameOwner : public GarbageCollectedMixin {
virtual bool CanRenderFallbackContent() const = 0;
virtual void RenderFallbackContent() = 0;
// The intrinsic dimensions of the embedded object changed. This is relevant
// for SVG documents that are embedded via <object> or <embed>.
// The intrinsic dimensions of the embedded object changed. This is only
// relevant for SVG documents that are embedded via <object> or <embed>.
virtual void IntrinsicSizingInfoChanged() = 0;
// Returns the 'name' content attribute value of the browsing context
......
......@@ -56,8 +56,6 @@
#include "core/frame/LocalFrameView.h"
#include "core/frame/PerformanceMonitor.h"
#include "core/frame/Settings.h"
#include "core/frame/WebFrameWidgetBase.h"
#include "core/frame/WebLocalFrameImpl.h"
#include "core/html/HTMLFrameElementBase.h"
#include "core/html/HTMLPlugInElement.h"
#include "core/html/PluginDocument.h"
......@@ -460,22 +458,6 @@ LayoutView* LocalFrame::ContentLayoutObject() const {
return GetDocument() ? GetDocument()->GetLayoutView() : nullptr;
}
void LocalFrame::IntrinsicSizingInfoChanged(
const IntrinsicSizingInfo& sizing_info) {
if (!Owner())
return;
// Notify the owner. For remote frame owners, notify via
// an IPC to the parent renderer; otherwise notify directly.
// TODO(dcheng): Move this into a virtual on FrameOwner.
if (Owner()->IsRemote()) {
WebLocalFrameImpl::FromFrame(this)
->FrameWidgetImpl()
->IntrinsicSizingInfoChanged(sizing_info);
} else {
Owner()->IntrinsicSizingInfoChanged();
}
}
void LocalFrame::DidChangeVisibilityState() {
if (GetDocument())
GetDocument()->DidChangeVisibilityState();
......
......@@ -161,8 +161,6 @@ class CORE_EXPORT LocalFrame final : public Frame,
SpellChecker& GetSpellChecker() const;
FrameConsole& Console() const;
void IntrinsicSizingInfoChanged(const IntrinsicSizingInfo&);
// A local root is the root of a connected subtree that contains only
// LocalFrames. The local root is responsible for coordinating input, layout,
// et cetera for that subtree of frames.
......
......@@ -6,6 +6,7 @@
#include "core/frame/LocalFrame.h"
#include "core/frame/LocalFrameClient.h"
#include "core/frame/WebFrameWidgetBase.h"
#include "core/frame/WebLocalFrameImpl.h"
#include "core/timing/Performance.h"
#include "public/platform/WebResourceTimingInfo.h"
......@@ -63,4 +64,17 @@ void RemoteFrameOwner::DispatchLoad() {
web_frame->Client()->DispatchLoad();
}
void RemoteFrameOwner::IntrinsicSizingInfoChanged() {
LocalFrame& local_frame = ToLocalFrame(*frame_);
IntrinsicSizingInfo intrinsic_sizing_info;
bool result =
local_frame.View()->GetIntrinsicSizingInfo(intrinsic_sizing_info);
// By virtue of having been invoked, GetIntrinsicSizingInfo() should always
// succeed here.
DCHECK(result);
WebLocalFrameImpl::FromFrame(local_frame)
->FrameWidgetImpl()
->IntrinsicSizingInfoChanged(intrinsic_sizing_info);
}
} // namespace blink
......@@ -42,7 +42,7 @@ class CORE_EXPORT RemoteFrameOwner final
// TODO(dcheng): Implement.
bool CanRenderFallbackContent() const override { return false; }
void RenderFallbackContent() override {}
void IntrinsicSizingInfoChanged() override {}
void IntrinsicSizingInfoChanged() override;
AtomicString BrowsingContextContainerName() const override {
return browsing_context_container_name_;
......
......@@ -283,9 +283,8 @@ void LayoutSVGRoot::IntrinsicSizingInfoChanged() const {
// document, or not embedded in a way that supports/allows size negotiation.
if (!IsEmbeddedThroughFrameContainingSVGDocument())
return;
IntrinsicSizingInfo sizing_info;
ComputeIntrinsicSizingInfo(sizing_info);
GetFrame()->IntrinsicSizingInfoChanged(sizing_info);
DCHECK(GetFrame()->Owner());
GetFrame()->Owner()->IntrinsicSizingInfoChanged();
}
void LayoutSVGRoot::StyleDidChange(StyleDifference diff,
......@@ -297,10 +296,7 @@ void LayoutSVGRoot::StyleDidChange(StyleDifference diff,
has_box_decoration_background_ = StyleRef().HasBoxDecorationBackground();
}
// If we previously didn't have any computed style, we wouldn't have been
// able to determine our intrinsic dimensions, so in that case always
// initiate a size negotiation.
if (!old_style || StyleChangeAffectsIntrinsicSize(*old_style))
if (old_style && StyleChangeAffectsIntrinsicSize(*old_style))
IntrinsicSizingInfoChanged();
LayoutReplaced::StyleDidChange(diff, old_style);
......
......@@ -518,6 +518,13 @@ bool SVGSVGElement::LayoutObjectIsNeeded(const ComputedStyle& style) {
return IsValid() && Element::LayoutObjectIsNeeded(style);
}
void SVGSVGElement::AttachLayoutTree(AttachContext& context) {
SVGGraphicsElement::AttachLayoutTree(context);
if (GetLayoutObject() && GetLayoutObject()->IsSVGRoot())
ToLayoutSVGRoot(GetLayoutObject())->IntrinsicSizingInfoChanged();
}
LayoutObject* SVGSVGElement::CreateLayoutObject(const ComputedStyle&) {
if (IsOutermostSVGSVGElement())
return new LayoutSVGRoot(this);
......
......@@ -128,6 +128,7 @@ class SVGSVGElement final : public SVGGraphicsElement,
const AtomicString&,
MutableCSSPropertyValueSet*) override;
void AttachLayoutTree(AttachContext&) override;
bool LayoutObjectIsNeeded(const ComputedStyle&) override;
LayoutObject* CreateLayoutObject(const ComputedStyle&) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment