Commit 811b43c4 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2010-04-27 Jens Alfke <snej@chromium.org>

        Reviewed by Darin Fisher.

        [Chromium] Add some notifications and an accessor to WebKit API
        https://bugs.webkit.org/show_bug.cgi?id=37625

        * dom/Node.cpp:
        (WebCore::Node::hasNonEmptyBoundingBox): New method.
        * dom/Node.h:
        * html/HTMLAnchorElement.cpp:
        (WebCore::HTMLAnchorElement::isKeyboardFocusable): Moved part of method into new Node method
2010-04-27  Jens Alfke  <snej@chromium.org>

        Reviewed by Darin Fisher.

        [Chromium] Add some notifications and an accessor to WebKit API
        https://bugs.webkit.org/show_bug.cgi?id=37625

        * public/WebFrameClient.h:
        (WebKit::WebFrameClient::didFirstLayout):
        (WebKit::WebFrameClient::didFirstVisuallyNonEmptyLayout):
        * public/WebNode.h:
        * src/FrameLoaderClientImpl.cpp:
        (WebKit::FrameLoaderClientImpl::dispatchDidFirstLayout):
        (WebKit::FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout):
        * src/WebElement.cpp:
        * src/WebNode.cpp:
        (WebKit::WebNode::hasNonEmptyBoundingBox):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58362 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 854fd269
2010-04-27 Jens Alfke <snej@chromium.org>
Reviewed by Darin Fisher.
[Chromium] Add some notifications and an accessor to WebKit API
https://bugs.webkit.org/show_bug.cgi?id=37625
* dom/Node.cpp:
(WebCore::Node::hasNonEmptyBoundingBox): New method.
* dom/Node.h:
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::isKeyboardFocusable): Moved part of method into new Node method
2010-04-27 Jochen Eisinger <jochen@chromium.org>
 
Reviewed by Shinichiro Hamaji.
......@@ -762,6 +762,27 @@ IntRect Node::getRect() const
return IntRect();
}
bool Node::hasNonEmptyBoundingBox() const
{
// Before calling absoluteRects, check for the common case where the renderer
// is non-empty, since this is a faster check and almost always returns true.
RenderBoxModelObject* box = renderBoxModelObject();
if (!box)
return false;
if (!box->borderBoundingBox().isEmpty())
return true;
Vector<IntRect> rects;
FloatPoint absPos = renderer()->localToAbsolute();
renderer()->absoluteRects(rects, absPos.x(), absPos.y());
size_t n = rects.size();
for (size_t i = 0; i < n; ++i)
if (!rects[i].isEmpty())
return true;
return false;
}
void Node::setNeedsStyleRecalc(StyleChangeType changeType)
{
if ((changeType != NoStyleChange) && !attached()) // changed compared to what?
......
......@@ -311,6 +311,11 @@ public:
virtual bool shouldUseInputMethod() const;
virtual IntRect getRect() const;
// Returns true if the node has a non-empty bounding box in layout.
// This does not 100% guarantee the user can see it, but is pretty close.
// Note: This method only works properly after layout has occurred.
bool hasNonEmptyBoundingBox() const;
virtual void recalcStyle(StyleChange = NoChange) { }
unsigned nodeIndex() const;
......
......@@ -102,24 +102,7 @@ bool HTMLAnchorElement::isKeyboardFocusable(KeyboardEvent* event) const
if (!document()->frame()->eventHandler()->tabsToLinks(event))
return false;
if (!renderer() || !renderer()->isBoxModelObject())
return false;
// Before calling absoluteRects, check for the common case where the renderer
// is non-empty, since this is a faster check and almost always returns true.
RenderBoxModelObject* box = toRenderBoxModelObject(renderer());
if (!box->borderBoundingBox().isEmpty())
return true;
Vector<IntRect> rects;
FloatPoint absPos = renderer()->localToAbsolute();
renderer()->absoluteRects(rects, absPos.x(), absPos.y());
size_t n = rects.size();
for (size_t i = 0; i < n; ++i)
if (!rects[i].isEmpty())
return true;
return false;
return hasNonEmptyBoundingBox();
}
void HTMLAnchorElement::defaultEventHandler(Event* evt)
......
2010-04-27 Jens Alfke <snej@chromium.org>
Reviewed by Darin Fisher.
[Chromium] Add some notifications and an accessor to WebKit API
https://bugs.webkit.org/show_bug.cgi?id=37625
* public/WebFrameClient.h:
(WebKit::WebFrameClient::didFirstLayout):
(WebKit::WebFrameClient::didFirstVisuallyNonEmptyLayout):
* public/WebNode.h:
* src/FrameLoaderClientImpl.cpp:
(WebKit::FrameLoaderClientImpl::dispatchDidFirstLayout):
(WebKit::FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout):
* src/WebElement.cpp:
* src/WebNode.cpp:
(WebKit::WebNode::hasNonEmptyBoundingBox):
2010-04-27 Darin Fisher <darin@chromium.org>
Reviewed by Dimitri Glazkov.
......
......@@ -293,6 +293,12 @@ public:
// Geometry notifications ----------------------------------------------
// The frame's document finished the initial layout of a page.
virtual void didFirstLayout(WebFrame*) { }
// The frame's document finished the initial non-empty layout of a page.
virtual void didFirstVisuallyNonEmptyLayout(WebFrame*) { }
// The size of the content area changed.
virtual void didChangeContentsSize(WebFrame*, const WebSize&) { }
......
......@@ -101,6 +101,11 @@ public:
WEBKIT_API void simulateClick();
WEBKIT_API WebNodeList getElementsByTagName(const WebString&) const;
// Returns true if the node has a non-empty bounding box in layout.
// This does not 100% guarantee the user can see it, but is pretty close.
// Note: This method only works properly after layout has occurred.
WEBKIT_API bool hasNonEmptyBoundingBox() const;
// Deprecated. Use to() instead.
template<typename T> T toElement()
{
......
......@@ -789,12 +789,14 @@ void FrameLoaderClientImpl::dispatchDidFinishLoad()
void FrameLoaderClientImpl::dispatchDidFirstLayout()
{
if (m_webFrame->client())
m_webFrame->client()->didFirstLayout(m_webFrame);
}
void FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout()
{
// FIXME: called when webkit finished layout of a page that was visually non-empty.
// All resources have not necessarily finished loading.
if (m_webFrame->client())
m_webFrame->client()->didFirstVisuallyNonEmptyLayout(m_webFrame);
}
Frame* FrameLoaderClientImpl::dispatchCreatePage()
......
......@@ -32,6 +32,8 @@
#include "WebElement.h"
#include "Element.h"
#include "RenderBoxModelObject.h"
#include "RenderObject.h"
#include <wtf/PassRefPtr.h>
using namespace WebCore;
......
......@@ -178,6 +178,11 @@ WebNodeList WebNode::getElementsByTagName(const WebString& tag) const
return WebNodeList(m_private->getElementsByTagName(tag));
}
bool WebNode::hasNonEmptyBoundingBox() const
{
return m_private->hasNonEmptyBoundingBox();
}
WebNode::WebNode(const PassRefPtr<Node>& node)
: m_private(node)
{
......
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