OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 #include "core/layout/LayoutScrollbarPart.h" | 36 #include "core/layout/LayoutScrollbarPart.h" |
37 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" | 37 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
38 #include "core/page/Page.h" | 38 #include "core/page/Page.h" |
39 #include "core/paint/DeprecatedPaintLayer.h" | 39 #include "core/paint/DeprecatedPaintLayer.h" |
40 #include "core/paint/ViewPainter.h" | 40 #include "core/paint/ViewPainter.h" |
41 #include "core/svg/SVGDocumentExtensions.h" | 41 #include "core/svg/SVGDocumentExtensions.h" |
42 #include "platform/TraceEvent.h" | 42 #include "platform/TraceEvent.h" |
43 #include "platform/TracedValue.h" | 43 #include "platform/TracedValue.h" |
44 #include "platform/geometry/FloatQuad.h" | 44 #include "platform/geometry/FloatQuad.h" |
45 #include "platform/geometry/TransformState.h" | 45 #include "platform/geometry/TransformState.h" |
| 46 #include "platform/graphics/GraphicsLayer.h" |
46 #include "platform/graphics/paint/DisplayItemList.h" | 47 #include "platform/graphics/paint/DisplayItemList.h" |
47 #include <inttypes.h> | 48 #include <inttypes.h> |
48 | 49 |
49 namespace blink { | 50 namespace blink { |
50 | 51 |
51 LayoutView::LayoutView(Document* document) | 52 LayoutView::LayoutView(Document* document) |
52 : LayoutBlockFlow(document) | 53 : LayoutBlockFlow(document) |
53 , m_frameView(document->view()) | 54 , m_frameView(document->view()) |
54 , m_selectionStart(nullptr) | 55 , m_selectionStart(nullptr) |
55 , m_selectionEnd(nullptr) | 56 , m_selectionEnd(nullptr) |
56 , m_selectionStartPos(-1) | 57 , m_selectionStartPos(-1) |
57 , m_selectionEndPos(-1) | 58 , m_selectionEndPos(-1) |
58 , m_pageLogicalHeight(0) | 59 , m_pageLogicalHeight(0) |
59 , m_pageLogicalHeightChanged(false) | 60 , m_pageLogicalHeightChanged(false) |
60 , m_layoutState(nullptr) | 61 , m_layoutState(nullptr) |
61 , m_layoutQuoteHead(nullptr) | 62 , m_layoutQuoteHead(nullptr) |
62 , m_layoutCounterCount(0) | 63 , m_layoutCounterCount(0) |
63 , m_hitTestCount(0) | 64 , m_hitTestCount(0) |
| 65 , m_hitTestCacheHits(0) |
64 , m_pendingSelection(PendingSelection::create()) | 66 , m_pendingSelection(PendingSelection::create()) |
65 { | 67 { |
66 // init LayoutObject attributes | 68 // init LayoutObject attributes |
67 setInline(false); | 69 setInline(false); |
68 | 70 |
69 m_minPreferredLogicalWidth = 0; | 71 m_minPreferredLogicalWidth = 0; |
70 m_maxPreferredLogicalWidth = 0; | 72 m_maxPreferredLogicalWidth = 0; |
71 | 73 |
72 setPreferredLogicalWidthsDirty(MarkOnlyThis); | 74 setPreferredLogicalWidthsDirty(MarkOnlyThis); |
73 | 75 |
74 setPositionState(AbsolutePosition); // to 0,0 :) | 76 setPositionState(AbsolutePosition); // to 0,0 :) |
75 } | 77 } |
76 | 78 |
77 LayoutView::~LayoutView() | 79 LayoutView::~LayoutView() |
78 { | 80 { |
79 } | 81 } |
80 | 82 |
81 bool LayoutView::hitTest(HitTestResult& result) | |
82 { | |
83 return hitTest(result.hitTestRequest(), result.hitTestLocation(), result); | |
84 } | |
85 | |
86 namespace { | 83 namespace { |
87 | 84 |
88 PassRefPtr<TracedValue> hitTestInfo(const HitTestRequest& request, const HitTest
Location& location, const HitTestResult& result) | 85 PassRefPtr<TracedValue> hitTestInfo(const HitTestResult& result) |
89 { | 86 { |
| 87 const HitTestRequest& request = result.hitTestRequest(); |
| 88 const HitTestLocation& location = result.hitTestLocation(); |
90 RefPtr<TracedValue> value(TracedValue::create()); | 89 RefPtr<TracedValue> value(TracedValue::create()); |
91 value->setInteger("x", location.roundedPoint().x()); | 90 value->setInteger("x", location.roundedPoint().x()); |
92 value->setInteger("y", location.roundedPoint().y()); | 91 value->setInteger("y", location.roundedPoint().y()); |
93 if (location.isRectBasedTest()) | 92 if (location.isRectBasedTest()) |
94 value->setBoolean("rect", true); | 93 value->setBoolean("rect", true); |
95 if (location.isRectilinear()) | 94 if (location.isRectilinear()) |
96 value->setBoolean("rectilinear", true); | 95 value->setBoolean("rectilinear", true); |
97 if (request.touchEvent()) | 96 if (request.touchEvent()) |
98 value->setBoolean("touch", true); | 97 value->setBoolean("touch", true); |
99 if (request.move()) | 98 if (request.move()) |
100 value->setBoolean("move", true); | 99 value->setBoolean("move", true); |
101 if (request.listBased()) { | 100 if (request.listBased()) { |
102 value->setBoolean("listBased", true); | 101 value->setBoolean("listBased", true); |
103 } else if (Node* node = result.innerNode()) { | 102 } else if (Node* node = result.innerNode()) { |
104 value->setString("nodeAddress", String::format("%" PRIx64, static_cast<u
int64>(reinterpret_cast<intptr_t>(node)))); | 103 value->setString("nodeAddress", String::format("%" PRIx64, static_cast<u
int64>(reinterpret_cast<intptr_t>(node)))); |
105 value->setString("tag", node->nodeName()); | 104 value->setString("tag", node->nodeName()); |
106 Element* elem = result.innerElement(); | 105 Element* elem = result.innerElement(); |
107 if (elem && elem->hasID()) | 106 if (elem && elem->hasID()) |
108 value->setString("htmlId", elem->getIdAttribute()); | 107 value->setString("htmlId", elem->getIdAttribute()); |
109 } | 108 } |
110 return value; | 109 return value; |
111 } | 110 } |
112 | 111 |
113 } // anonymous namespace | 112 } // anonymous namespace |
114 | 113 |
115 bool LayoutView::hitTest(const HitTestRequest& request, const HitTestLocation& l
ocation, HitTestResult& result) | 114 bool LayoutView::hitTest(HitTestResult& result) |
116 { | 115 { |
117 TRACE_EVENT_BEGIN0("blink", "LayoutView::hitTest"); | 116 TRACE_EVENT_BEGIN0("blink", "LayoutView::hitTest"); |
118 m_hitTestCount++; | 117 m_hitTestCount++; |
119 | 118 |
120 ASSERT(!location.isRectBasedTest() || request.listBased()); | 119 ASSERT(!result.hitTestLocation().isRectBasedTest() || result.hitTestRequest(
).listBased()); |
121 | 120 |
122 // We have to recursively update layout/style here because otherwise, when t
he hit test recurses | 121 // 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 | 122 // 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. | 123 // that are higher up in the call stack, leading to crashes. |
125 // Note that Document::updateLayout calls its parent's updateLayout. | 124 // 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. | 125 // FIXME: It should be the caller's responsibility to ensure an up-to-date l
ayout. |
127 frameView()->updateLayoutAndStyleForPainting(); | 126 frameView()->updateLayoutAndStyleForPainting(); |
128 commitPendingSelection(); | 127 commitPendingSelection(); |
129 | 128 |
130 bool hitLayer = layer()->stackingNode()->hitTest(request, location, result); | 129 uint64_t domTreeVersion = document().domTreeVersion(); |
| 130 HitTestResult cacheResult = result; |
| 131 bool cacheHit = m_hitTestCache.lookupCachedResult(cacheResult, domTreeVersio
n); |
| 132 bool hitLayer = layer()->stackingNode()->hitTest(result); |
131 | 133 |
132 // FrameView scrollbars are not the same as Layer scrollbars tested by Layer
::hitTestOverflowControls, | 134 // 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 | 135 // 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. | 136 // the hit test above, because that may overwrite the entire HitTestResult w
hen it finds a hit. |
135 IntPoint framePoint = frameView()->contentsToFrame(location.roundedPoint()); | 137 IntPoint framePoint = frameView()->contentsToFrame(result.hitTestLocation().
roundedPoint()); |
136 if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(framePoin
t)) | 138 if (Scrollbar* frameScrollbar = frameView()->scrollbarAtFramePoint(framePoin
t)) |
137 result.setScrollbar(frameScrollbar); | 139 result.setScrollbar(frameScrollbar); |
138 | 140 |
139 TRACE_EVENT_END1("blink", "LayoutView::hitTest", "info", hitTestInfo(request
, location, result)); | 141 if (cacheHit) { |
| 142 m_hitTestCacheHits++; |
| 143 m_hitTestCache.verify(result, cacheResult); |
| 144 } |
| 145 |
| 146 if (hitLayer) { |
| 147 m_hitTestCache.addCachedResult(result, domTreeVersion); |
| 148 |
| 149 if (layer()->graphicsLayerBacking()) { |
| 150 layer()->graphicsLayerBacking()->platformLayer()->setHitCacheRect(en
closingIntRect(result.validityRect())); |
| 151 } |
| 152 } |
| 153 |
| 154 TRACE_EVENT_END1("blink", "LayoutView::hitTest", "info", hitTestInfo(result)
); |
140 return hitLayer; | 155 return hitLayer; |
141 } | 156 } |
142 | 157 |
143 void LayoutView::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit, Logi
calExtentComputedValues& computedValues) const | 158 void LayoutView::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit, Logi
calExtentComputedValues& computedValues) const |
144 { | 159 { |
145 computedValues.m_extent = (!shouldUsePrintingLayout() && m_frameView) ? Layo
utUnit(viewLogicalHeightForBoxSizing()) : logicalHeight; | 160 computedValues.m_extent = (!shouldUsePrintingLayout() && m_frameView) ? Layo
utUnit(viewLogicalHeightForBoxSizing()) : logicalHeight; |
146 } | 161 } |
147 | 162 |
148 void LayoutView::updateLogicalWidth() | 163 void LayoutView::updateLogicalWidth() |
149 { | 164 { |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 return viewHeight(IncludeScrollbars) / scale; | 989 return viewHeight(IncludeScrollbars) / scale; |
975 } | 990 } |
976 | 991 |
977 void LayoutView::willBeDestroyed() | 992 void LayoutView::willBeDestroyed() |
978 { | 993 { |
979 LayoutBlockFlow::willBeDestroyed(); | 994 LayoutBlockFlow::willBeDestroyed(); |
980 m_compositor.clear(); | 995 m_compositor.clear(); |
981 } | 996 } |
982 | 997 |
983 } // namespace blink | 998 } // namespace blink |
OLD | NEW |