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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutPart.cpp

Issue 2810873007: Replace LayoutPart::GetFrameViewBase with GetNodeFrameView (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutPart.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutPart.cpp b/third_party/WebKit/Source/core/layout/LayoutPart.cpp
index 97212dd02c9387c312db5285b7c524b777d7b0db..17f3a5ee511e8718de53d256c3ef928143692414 100644
--- a/third_party/WebKit/Source/core/layout/LayoutPart.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutPart.cpp
@@ -89,25 +89,30 @@ LayoutPart::~LayoutPart() {
DCHECK_LE(ref_count_, 0);
}
-FrameViewBase* LayoutPart::GetFrameViewBase() const {
- // Plugin FrameViewBases are stored in their DOM node.
- Element* element = ToElement(GetNode());
-
- if (element && element->IsFrameOwnerElement())
- return ToHTMLFrameOwnerElement(element)->OwnedWidget();
-
+FrameView* LayoutPart::GetNodeFrameView() const {
+ // FrameViews are stored in HTMLFrameOwnerElement node.
+ Node* node = GetNode();
+ if (node && node->IsFrameOwnerElement()) {
+ FrameViewBase* frame_view_base =
+ ToHTMLFrameOwnerElement(node)->OwnedWidget();
+ if (frame_view_base && frame_view_base->IsFrameView())
+ return ToFrameView(frame_view_base);
+ }
return nullptr;
}
PluginView* LayoutPart::Plugin() const {
- // Plugins are stored in their DOM node.
- return GetNode() && IsHTMLPlugInElement(GetNode())
- ? ToHTMLPlugInElement(GetNode())->Plugin()
- : nullptr;
+ // Plugins are stored in HTMLPlugInElement node.
+ Node* node = GetNode();
+ return node && IsHTMLPlugInElement(node) ? ToHTMLPlugInElement(node)->Plugin()
+ : nullptr;
}
FrameViewBase* LayoutPart::PluginOrFrame() const {
- FrameViewBase* result = GetFrameViewBase();
+ FrameViewBase* result = nullptr;
+ Node* node = GetNode();
+ if (node && node->IsFrameOwnerElement())
+ result = ToHTMLFrameOwnerElement(node)->OwnedWidget();
if (!result)
result = Plugin();
return result;
@@ -174,15 +179,15 @@ bool LayoutPart::NodeAtPoint(HitTestResult& result,
const HitTestLocation& location_in_container,
const LayoutPoint& accumulated_offset,
HitTestAction action) {
- if (!GetFrameViewBase() || !GetFrameViewBase()->IsFrameView() ||
- !result.GetHitTestRequest().AllowsChildFrameContent()) {
+ FrameView* frame_view = GetNodeFrameView();
+ if (!frame_view || !result.GetHitTestRequest().AllowsChildFrameContent()) {
return NodeAtPointOverFrameViewBase(result, location_in_container,
accumulated_offset, action);
}
// A hit test can never hit an off-screen element; only off-screen iframes are
// throttled; therefore, hit tests can skip descending into throttled iframes.
- if (ToFrameView(GetFrameViewBase())->ShouldThrottleRendering()) {
+ if (frame_view->ShouldThrottleRendering()) {
return NodeAtPointOverFrameViewBase(result, location_in_container,
accumulated_offset, action);
}
@@ -191,7 +196,7 @@ bool LayoutPart::NodeAtPoint(HitTestResult& result,
DocumentLifecycle::kCompositingClean);
if (action == kHitTestForeground) {
- FrameView* child_frame_view = ToFrameView(GetFrameViewBase());
+ FrameView* child_frame_view = GetNodeFrameView();
dcheng 2017/04/12 23:44:37 Can we just use frame_view directly here? It seems
joelhockey 2017/04/13 00:37:01 Yes, I can't see how this value could change, so n
LayoutViewItem child_root_item = child_frame_view->GetLayoutViewItem();
if (VisibleToHitTestRequest(result.GetHitTestRequest()) &&
@@ -393,9 +398,8 @@ void LayoutPart::UpdateGeometryInternal(FrameViewBase& frame_view_base) {
void LayoutPart::InvalidatePaintOfSubtreesIfNeeded(
const PaintInvalidationState& paint_invalidation_state) {
- if (GetFrameViewBase() && GetFrameViewBase()->IsFrameView() &&
- !IsThrottledFrameView()) {
- FrameView* child_frame_view = ToFrameView(GetFrameViewBase());
+ FrameView* child_frame_view = GetNodeFrameView();
+ if (child_frame_view && !IsThrottledFrameView()) {
// |childFrameView| is in another document, which could be
// missing its LayoutView. TODO(jchaffraix): Ideally we should
// not need this code.
@@ -413,10 +417,9 @@ void LayoutPart::InvalidatePaintOfSubtreesIfNeeded(
}
bool LayoutPart::IsThrottledFrameView() const {
- if (!GetFrameViewBase() || !GetFrameViewBase()->IsFrameView())
- return false;
- const FrameView* frame_view = ToFrameView(GetFrameViewBase());
- return frame_view->ShouldThrottleRendering();
+ if (FrameView* frame_view = GetNodeFrameView())
+ return frame_view->ShouldThrottleRendering();
+ return false;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698