Commit 6ba8ab79 authored by hyatt's avatar hyatt

Eliminate RenderLayer::gScrollBar in favor of caching the scrollbar hit

        in RenderObject::NodeInfo (and then propagating that Widget to
        MouseEventWithHitTestResults).

        This allows RenderListBox and RenderBlock to do the same thing when the
        mouse is over the scrollbar.

        Also land fix to support font-size: 0.

        Reviewed by mjs (scrollbar), eric (font-size)

        * dom/Document.cpp:
        (WebCore::Document::prepareMouseEvent):
        * page/Frame.cpp:
        (WebCore::Frame::passWidgetMouseDownEventToWidget):
        * page/FrameView.cpp:
        (WebCore::selectCursor):
        (WebCore::FrameView::handleMouseMoveEvent):
        (WebCore::FrameView::dispatchMouseEvent):
        * page/MouseEventWithHitTestResults.cpp:
        (WebCore::MouseEventWithHitTestResults::MouseEventWithHitTestResults):
        * page/MouseEventWithHitTestResults.h:
        (WebCore::MouseEventWithHitTestResults::scrollbar):
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::isPointInScrollbar):
        (WebCore::RenderBlock::nodeAtPoint):
        * rendering/RenderBlock.h:
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::hitTest):
        * rendering/RenderLayer.h:
        (WebCore::RenderLayer::getHiddenBehavior):
        * rendering/RenderListBox.cpp:
        (WebCore::RenderListBox::RenderListBox):
        (WebCore::RenderListBox::~RenderListBox):
        (WebCore::RenderListBox::isPointInScrollbar):
        * rendering/RenderListBox.h:
        * rendering/RenderObject.h:
        (WebCore::RenderObject::NodeInfo::NodeInfo):
        (WebCore::RenderObject::NodeInfo::scrollbar):
        (WebCore::RenderObject::NodeInfo::setScrollbar):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16678 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 12628dc4
2006-09-29 David Hyatt <hyatt@apple.com>
Eliminate RenderLayer::gScrollBar in favor of caching the scrollbar hit
in RenderObject::NodeInfo (and then propagating that Widget to
MouseEventWithHitTestResults).
This allows RenderListBox and RenderBlock to do the same thing when the
mouse is over the scrollbar.
Also land fix to support font-size: 0.
Reviewed by mjs (scrollbar), eric (font-size)
* dom/Document.cpp:
(WebCore::Document::prepareMouseEvent):
* page/Frame.cpp:
(WebCore::Frame::passWidgetMouseDownEventToWidget):
* page/FrameView.cpp:
(WebCore::selectCursor):
(WebCore::FrameView::handleMouseMoveEvent):
(WebCore::FrameView::dispatchMouseEvent):
* page/MouseEventWithHitTestResults.cpp:
(WebCore::MouseEventWithHitTestResults::MouseEventWithHitTestResults):
* page/MouseEventWithHitTestResults.h:
(WebCore::MouseEventWithHitTestResults::scrollbar):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::isPointInScrollbar):
(WebCore::RenderBlock::nodeAtPoint):
* rendering/RenderBlock.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::hitTest):
* rendering/RenderLayer.h:
(WebCore::RenderLayer::getHiddenBehavior):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::RenderListBox):
(WebCore::RenderListBox::~RenderListBox):
(WebCore::RenderListBox::isPointInScrollbar):
* rendering/RenderListBox.h:
* rendering/RenderObject.h:
(WebCore::RenderObject::NodeInfo::NodeInfo):
(WebCore::RenderObject::NodeInfo::scrollbar):
(WebCore::RenderObject::NodeInfo::setScrollbar):
2006-09-29 MorganL <morganl.webkit@yahoo.com>
Reviewed by Adele.
......@@ -2335,6 +2335,23 @@
FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
/* End PBXBuildFile section */
/* Begin PBXBuildStyle section */
BCCA09250ACCF95C00E0C915 /* Development */ = {
isa = PBXBuildStyle;
buildSettings = {
COPY_PHASE_STRIP = NO;
};
name = Development;
};
BCCA09260ACCF95C00E0C915 /* Deployment */ = {
isa = PBXBuildStyle;
buildSettings = {
COPY_PHASE_STRIP = YES;
};
name = Deployment;
};
/* End PBXBuildStyle section */
/* Begin PBXContainerItemProxy section */
DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
......@@ -9176,6 +9193,12 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
buildSettings = {
};
buildStyles = (
BCCA09250ACCF95C00E0C915 /* Development */,
BCCA09260ACCF95C00E0C915 /* Deployment */,
);
hasScannedForEncodings = 1;
knownRegions = (
English,
......@@ -3026,7 +3026,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
return;
}
if (size <= 0)
if (size < 0)
return;
setFontSize(fontDescription, size);
......
......@@ -1686,7 +1686,7 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(bool readonly, bool act
const IntPoint& point, const PlatformMouseEvent& event)
{
if (!renderer())
return MouseEventWithHitTestResults(event, 0, false);
return MouseEventWithHitTestResults(event, 0, 0, false);
assert(renderer()->isRenderView());
RenderObject::NodeInfo renderInfo(readonly, active, mouseMove);
......@@ -1696,7 +1696,7 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(bool readonly, bool act
updateRendering();
bool isOverLink = renderInfo.URLElement() && !renderInfo.URLElement()->getAttribute(hrefAttr).isNull();
return MouseEventWithHitTestResults(event, renderInfo.innerNode(), isOverLink);
return MouseEventWithHitTestResults(event, renderInfo.innerNode(), renderInfo.scrollbar(), isOverLink);
}
// DOM Section 1.1.1
......
......@@ -3262,12 +3262,7 @@ bool Frame::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&
if (!target)
return false;
Widget* widget;
if (target->isListBox())
widget = static_cast<RenderListBox*>(target)->scrollBarTarget();
else
widget = RenderLayer::gScrollBar;
Widget* widget = event.scrollbar();
if (!widget) {
if (!target->isWidget())
return false;
......
......@@ -703,7 +703,7 @@ static Cursor selectCursor(const MouseEventWithHitTestResults& event, Frame* fra
bool inResizer = false;
if (frame->view() && layer && layer->isPointInResizeControl(frame->view()->convertFromContainingWindow(event.event().pos())))
inResizer = true;
if ((editable || (renderer && renderer->isText() && renderer->canSelect())) && !inResizer && !RenderLayer::gScrollBar)
if ((editable || (renderer && renderer->isText() && renderer->canSelect())) && !inResizer && !event.scrollbar())
return iBeamCursor();
// FIXME: If the point is in a layer's overflow scrollbars, we should use the pointer cursor
return pointerCursor();
......@@ -787,6 +787,13 @@ void FrameView::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent)
bool swallowEvent = dispatchMouseEvent(mousemoveEvent, mev.targetNode(), false, 0, mouseEvent, true);
if (d->oldScrollBar != mev.scrollbar()) {
// Send mouse exited to the old scrollbar.
if (d->oldScrollBar)
d->oldScrollBar->mouseExited();
d->oldScrollBar = mev.scrollbar();
}
if (d->m_resizeLayer && d->m_resizeLayer->inResizeMode())
d->m_resizeLayer->resize(mouseEvent, d->offsetFromResizeCorner);
......@@ -798,8 +805,8 @@ void FrameView::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent)
if (newSubframe && d->oldSubframe != newSubframe)
m_frame->passSubframeEventToSubframe(mev, newSubframe.get());
else {
if (RenderLayer::gScrollBar && !d->mousePressed)
RenderLayer::gScrollBar->mouseMoved(mouseEvent); // Handle hover effects on platforms that support visual feedback on scrollbar hovering.
if (mev.scrollbar() && !d->mousePressed)
mev.scrollbar()->mouseMoved(mouseEvent); // Handle hover effects on platforms that support visual feedback on scrollbar hovering.
setCursor(selectCursor(mev, m_frame.get(), d->mousePressed));
}
......@@ -1180,13 +1187,6 @@ bool FrameView::dispatchMouseEvent(const AtomicString& eventType, Node* targetNo
EventTargetNodeCast(targetNode)->dispatchMouseEvent(mouseEvent, mouseoverEvent, 0, d->oldUnder.get());
}
d->oldUnder = targetNode;
if (d->oldScrollBar != RenderLayer::gScrollBar) {
// Send mouse exited to the old scrollbar.
if (d->oldScrollBar)
d->oldScrollBar->mouseExited();
d->oldScrollBar = RenderLayer::gScrollBar;
}
}
bool swallowEvent = false;
......
......@@ -35,10 +35,11 @@ static inline Element* targetElement(Node* node)
}
MouseEventWithHitTestResults::MouseEventWithHitTestResults(const PlatformMouseEvent& event,
PassRefPtr<Node> node, bool isOverLink)
PassRefPtr<Node> node, PlatformScrollBar* scrollbar, bool isOverLink)
: m_event(event)
, m_targetNode(node)
, m_targetElement(targetElement(m_targetNode.get()))
, m_scrollbar(scrollbar)
, m_isOverLink(isOverLink)
{
}
......
......@@ -26,18 +26,22 @@
namespace WebCore {
class PlatformScrollBar;
class MouseEventWithHitTestResults {
public:
MouseEventWithHitTestResults(const PlatformMouseEvent&, PassRefPtr<Node>, bool isOverLink);
MouseEventWithHitTestResults(const PlatformMouseEvent&, PassRefPtr<Node>, PlatformScrollBar*, bool isOverLink);
const PlatformMouseEvent& event() const { return m_event; }
Node* targetNode() const;
PlatformScrollBar* scrollbar() const { return m_scrollbar; }
bool isOverLink() const { return m_isOverLink; }
private:
PlatformMouseEvent m_event;
RefPtr<Node> m_targetNode;
RefPtr<Element> m_targetElement;
PlatformScrollBar* m_scrollbar;
bool m_isOverLink;
};
......
......@@ -2486,7 +2486,7 @@ int RenderBlock::getClearDelta(RenderObject *child)
return result;
}
bool RenderBlock::isPointInScrollbar(int _x, int _y, int _tx, int _ty)
bool RenderBlock::isPointInScrollbar(NodeInfo& info, int _x, int _y, int _tx, int _ty)
{
if (!scrollsOverflow())
return false;
......@@ -2497,7 +2497,7 @@ bool RenderBlock::isPointInScrollbar(int _x, int _y, int _tx, int _ty)
m_layer->verticalScrollbarWidth(),
height() + borderTopExtra() + borderBottomExtra() - borderTop() - borderBottom() - m_layer->horizontalScrollbarHeight());
if (vertRect.contains(_x, _y)) {
RenderLayer::gScrollBar = m_layer->verticalScrollbarWidget();
info.setScrollbar(m_layer->verticalScrollbarWidget());
return true;
}
}
......@@ -2508,7 +2508,7 @@ bool RenderBlock::isPointInScrollbar(int _x, int _y, int _tx, int _ty)
width() - borderLeft() - borderRight() - m_layer->verticalScrollbarWidth(),
m_layer->horizontalScrollbarHeight());
if (horizRect.contains(_x, _y)) {
RenderLayer::gScrollBar = m_layer->horizontalScrollbarWidget();
info.setScrollbar(m_layer->horizontalScrollbarWidget());
return true;
}
}
......@@ -2539,7 +2539,7 @@ bool RenderBlock::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
}
}
if (isPointInScrollbar(_x, _y, tx, ty)) {
if (isPointInScrollbar(info, _x, _y, tx, ty)) {
if (hitTestAction == HitTestBlockBackground) {
setInnerNode(info);
return true;
......
......@@ -201,7 +201,7 @@ public:
virtual bool nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty,
HitTestAction hitTestAction);
virtual bool isPointInScrollbar(int x, int y, int tx, int ty);
virtual bool isPointInScrollbar(NodeInfo& info, int x, int y, int tx, int ty);
virtual VisiblePosition positionForCoordinates(int x, int y);
......
......@@ -75,8 +75,6 @@ namespace WebCore {
using namespace EventNames;
using namespace HTMLNames;
PlatformScrollBar* RenderLayer::gScrollBar = 0;
#ifndef NDEBUG
static bool inRenderLayerDestroy;
#endif
......@@ -1388,8 +1386,6 @@ static inline IntRect frameVisibleRect(RenderObject* renderer)
bool
RenderLayer::hitTest(RenderObject::NodeInfo& info, const IntPoint& point)
{
gScrollBar = 0;
renderer()->document()->updateLayout();
IntRect boundsRect(m_x, m_y, width(), height());
......
......@@ -167,8 +167,6 @@ public:
static ScrollBehavior getVisibleBehavior(const ScrollAlignment& s) { return s.m_rectVisible; }
static ScrollBehavior getPartialBehavior(const ScrollAlignment& s) { return s.m_rectPartial; }
static ScrollBehavior getHiddenBehavior(const ScrollAlignment& s) { return s.m_rectHidden; }
static PlatformScrollBar* gScrollBar;
RenderLayer(RenderObject*);
~RenderLayer();
......
......@@ -55,7 +55,6 @@ RenderListBox::RenderListBox(HTMLSelectElement* element)
, m_optionsWidth(0)
, m_indexOffset(0)
, m_selectionChanged(true)
, m_scrollBarHit(false)
, m_vBar(0)
{
}
......@@ -65,7 +64,6 @@ RenderListBox::~RenderListBox()
if (m_vBar && m_vBar->isWidget()) {
element()->document()->view()->removeChild(static_cast<PlatformScrollBar*>(m_vBar));
m_vBar->deref();
delete m_vBar;
}
}
......@@ -325,12 +323,7 @@ void RenderListBox::paintItemBackground(PaintInfo& i, int tx, int ty, int listIn
i.p->fillRect(itemBoundingBoxRect(tx, ty, listIndex), backColor);
}
PlatformScrollBar* RenderListBox::scrollBarTarget()
{
return m_scrollBarHit ? static_cast<PlatformScrollBar*>(m_vBar) : 0;
}
bool RenderListBox::isPointInScrollbar(int _x, int _y, int _tx, int _ty)
bool RenderListBox::isPointInScrollbar(NodeInfo& info, int _x, int _y, int _tx, int _ty)
{
if (!m_vBar)
return false;
......@@ -340,8 +333,11 @@ bool RenderListBox::isPointInScrollbar(int _x, int _y, int _tx, int _ty)
m_vBar->width(),
height() + borderTopExtra() + borderBottomExtra() - borderTop() - borderBottom());
m_scrollBarHit = vertRect.contains(_x, _y);
return m_scrollBarHit;
if (vertRect.contains(_x, _y)) {
info.setScrollbar(m_vBar->isWidget() ? static_cast<PlatformScrollBar*>(m_vBar) : 0);
return true;
}
return false;
}
HTMLOptionElement* RenderListBox::optionAtPoint(int x, int y)
......
......@@ -44,7 +44,7 @@ public:
virtual bool canHaveChildren() const { return false; }
virtual const char* renderName() const { return "RenderListBox"; }
virtual void paintObject(PaintInfo&, int tx, int ty);
virtual bool isPointInScrollbar(int x, int y, int tx, int ty);
virtual bool isPointInScrollbar(NodeInfo&, int x, int y, int tx, int ty);
virtual bool scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier=1.0);
......@@ -57,8 +57,6 @@ public:
HTMLOptionElement* optionAtPoint(int x, int y);
PlatformScrollBar* scrollBarTarget();
bool scrollToRevealElementAtListIndex(int index);
virtual bool shouldAutoscroll() const { return numItems() > size(); }
......@@ -71,7 +69,6 @@ private:
int m_optionsTotalHeight;
int m_indexOffset;
bool m_selectionChanged;
bool m_scrollBarHit;
int size() const;
int numItems() const;
......
......@@ -54,6 +54,7 @@ class FrameView;
class HTMLAreaElement;
class InlineBox;
class InlineFlowBox;
class PlatformScrollBar;
class Position;
class RenderArena;
class RenderBlock;
......@@ -484,12 +485,14 @@ public:
class NodeInfo {
public:
NodeInfo(bool readonly, bool active, bool mouseMove = false)
: m_innerNode(0), m_innerNonSharedNode(0), m_innerURLElement(0), m_readonly(readonly), m_active(active), m_mouseMove(mouseMove)
: m_innerNode(0), m_innerNonSharedNode(0), m_innerURLElement(0),
m_scrollbar(0), m_readonly(readonly), m_active(active), m_mouseMove(mouseMove)
{ }
Node* innerNode() const { return m_innerNode; }
Node* innerNonSharedNode() const { return m_innerNonSharedNode; }
Element* URLElement() const { return m_innerURLElement; }
PlatformScrollBar* scrollbar() const { return m_scrollbar; }
bool readonly() const { return m_readonly; }
bool active() const { return m_active; }
bool mouseMove() const { return m_mouseMove; }
......@@ -497,11 +500,13 @@ public:
void setInnerNode(Node* n) { m_innerNode = n; }
void setInnerNonSharedNode(Node* n) { m_innerNonSharedNode = n; }
void setURLElement(Element* n) { m_innerURLElement = n; }
void setScrollbar(PlatformScrollBar* s) { m_scrollbar = s; }
private:
Node* m_innerNode;
Node* m_innerNonSharedNode;
Element* m_innerURLElement;
PlatformScrollBar* m_scrollbar;
bool m_readonly;
bool m_active;
bool m_mouseMove;
......
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