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

Side by Side Diff: Source/core/layout/LayoutView.cpp

Issue 1170153004: DevTools Timeline: expose HitTest event (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 10 matching lines...) Expand all
21 #include "config.h" 21 #include "config.h"
22 #include "core/layout/LayoutView.h" 22 #include "core/layout/LayoutView.h"
23 23
24 #include "core/dom/Document.h" 24 #include "core/dom/Document.h"
25 #include "core/dom/Element.h" 25 #include "core/dom/Element.h"
26 #include "core/editing/FrameSelection.h" 26 #include "core/editing/FrameSelection.h"
27 #include "core/frame/LocalFrame.h" 27 #include "core/frame/LocalFrame.h"
28 #include "core/frame/Settings.h" 28 #include "core/frame/Settings.h"
29 #include "core/html/HTMLFrameOwnerElement.h" 29 #include "core/html/HTMLFrameOwnerElement.h"
30 #include "core/html/HTMLIFrameElement.h" 30 #include "core/html/HTMLIFrameElement.h"
31 #include "core/inspector/InspectorTraceEvents.h"
31 #include "core/layout/HitTestResult.h" 32 #include "core/layout/HitTestResult.h"
32 #include "core/layout/LayoutFlowThread.h" 33 #include "core/layout/LayoutFlowThread.h"
33 #include "core/layout/LayoutGeometryMap.h" 34 #include "core/layout/LayoutGeometryMap.h"
34 #include "core/layout/LayoutPart.h" 35 #include "core/layout/LayoutPart.h"
35 #include "core/layout/LayoutQuote.h" 36 #include "core/layout/LayoutQuote.h"
36 #include "core/layout/LayoutScrollbarPart.h" 37 #include "core/layout/LayoutScrollbarPart.h"
37 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 38 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
38 #include "core/page/Page.h" 39 #include "core/page/Page.h"
39 #include "core/paint/DeprecatedPaintLayer.h" 40 #include "core/paint/DeprecatedPaintLayer.h"
40 #include "core/paint/ViewPainter.h" 41 #include "core/paint/ViewPainter.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 77
77 LayoutView::~LayoutView() 78 LayoutView::~LayoutView()
78 { 79 {
79 } 80 }
80 81
81 bool LayoutView::hitTest(HitTestResult& result) 82 bool LayoutView::hitTest(HitTestResult& result)
82 { 83 {
83 return hitTest(result.hitTestRequest(), result.hitTestLocation(), result); 84 return hitTest(result.hitTestRequest(), result.hitTestLocation(), result);
84 } 85 }
85 86
86 namespace {
87
88 PassRefPtr<TracedValue> hitTestInfo(const HitTestRequest& request, const HitTest Location& location, const HitTestResult& result)
89 {
90 RefPtr<TracedValue> value(TracedValue::create());
91 value->setInteger("x", location.roundedPoint().x());
92 value->setInteger("y", location.roundedPoint().y());
93 if (location.isRectBasedTest())
94 value->setBoolean("rect", true);
95 if (location.isRectilinear())
96 value->setBoolean("rectilinear", true);
97 if (request.touchEvent())
98 value->setBoolean("touch", true);
99 if (request.move())
100 value->setBoolean("move", true);
101 if (request.listBased()) {
102 value->setBoolean("listBased", true);
103 } else if (Node* node = result.innerNode()) {
104 value->setString("nodeAddress", String::format("%" PRIx64, static_cast<u int64>(reinterpret_cast<intptr_t>(node))));
105 value->setString("tag", node->nodeName());
106 Element* elem = result.innerElement();
107 if (elem && elem->hasID())
108 value->setString("htmlId", elem->getIdAttribute());
109 }
110 return value;
111 }
112
113 } // anonymous namespace
114
115 bool LayoutView::hitTest(const HitTestRequest& request, const HitTestLocation& l ocation, HitTestResult& result) 87 bool LayoutView::hitTest(const HitTestRequest& request, const HitTestLocation& l ocation, HitTestResult& result)
116 { 88 {
117 TRACE_EVENT_BEGIN0("blink", "LayoutView::hitTest"); 89 TRACE_EVENT_BEGIN0("blink,devtools.timeline", "HitTest");
118 m_hitTestCount++; 90 m_hitTestCount++;
119 91
120 ASSERT(!location.isRectBasedTest() || request.listBased()); 92 ASSERT(!location.isRectBasedTest() || request.listBased());
121 93
122 // We have to recursively update layout/style here because otherwise, when t he hit test recurses 94 // We have to recursively update layout/style here because otherwise, when t he hit test recurses
123 // into a child document, it could trigger a layout on the parent document, which can destroy DeprecatedPaintLayer 95 // into a child document, it could trigger a layout on the parent document, which can destroy DeprecatedPaintLayer
124 // that are higher up in the call stack, leading to crashes. 96 // that are higher up in the call stack, leading to crashes.
125 // Note that Document::updateLayout calls its parent's updateLayout. 97 // Note that Document::updateLayout calls its parent's updateLayout.
126 // FIXME: It should be the caller's responsibility to ensure an up-to-date l ayout. 98 // FIXME: It should be the caller's responsibility to ensure an up-to-date l ayout.
127 frameView()->updateLayoutAndStyleForPainting(); 99 frameView()->updateLayoutAndStyleForPainting();
128 commitPendingSelection(); 100 commitPendingSelection();
129 101
130 bool hitLayer = layer()->stackingNode()->hitTest(request, location, result); 102 bool hitLayer = layer()->stackingNode()->hitTest(request, location, result);
131 103
132 // FrameView scrollbars are not the same as Layer scrollbars tested by Layer ::hitTestOverflowControls, 104 // FrameView scrollbars are not the same as Layer scrollbars tested by Layer ::hitTestOverflowControls,
133 // so we need to test FrameView scrollbars separately here. Note that it's i mportant we do this after 105 // so we need to test FrameView scrollbars separately here. Note that it's i mportant we do this after
134 // the hit test above, because that may overwrite the entire HitTestResult w hen it finds a hit. 106 // the hit test above, because that may overwrite the entire HitTestResult w hen it finds a hit.
135 IntPoint framePoint = frameView()->contentsToFrame(location.roundedPoint()); 107 IntPoint framePoint = frameView()->contentsToFrame(location.roundedPoint());
136 if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(framePoin t)) 108 if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(framePoin t))
137 result.setScrollbar(frameScrollbar); 109 result.setScrollbar(frameScrollbar);
138 110
139 TRACE_EVENT_END1("blink", "LayoutView::hitTest", "info", hitTestInfo(request , location, result)); 111 TRACE_EVENT_END1("blink,devtools.timeline", "HitTest", "endData", InspectorH itTestEvent::endData(request, location, result));
yurys 2015/06/09 16:39:52 Is there a special handling of the info param that
140 return hitLayer; 112 return hitLayer;
141 } 113 }
142 114
143 void LayoutView::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit, Logi calExtentComputedValues& computedValues) const 115 void LayoutView::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit, Logi calExtentComputedValues& computedValues) const
144 { 116 {
145 computedValues.m_extent = (!shouldUsePrintingLayout() && m_frameView) ? Layo utUnit(viewLogicalHeightForBoxSizing()) : logicalHeight; 117 computedValues.m_extent = (!shouldUsePrintingLayout() && m_frameView) ? Layo utUnit(viewLogicalHeightForBoxSizing()) : logicalHeight;
146 } 118 }
147 119
148 void LayoutView::updateLogicalWidth() 120 void LayoutView::updateLogicalWidth()
149 { 121 {
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 return viewHeight(IncludeScrollbars) / scale; 946 return viewHeight(IncludeScrollbars) / scale;
975 } 947 }
976 948
977 void LayoutView::willBeDestroyed() 949 void LayoutView::willBeDestroyed()
978 { 950 {
979 LayoutBlockFlow::willBeDestroyed(); 951 LayoutBlockFlow::willBeDestroyed();
980 m_compositor.clear(); 952 m_compositor.clear();
981 } 953 }
982 954
983 } // namespace blink 955 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorTraceEvents.cpp ('k') | Source/devtools/front_end/timeline/TimelineModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698