Commit ced9a57d authored by rniwa@webkit.org's avatar rniwa@webkit.org

Change the order of conditions to avoid computing rendererIsEditable()

https://bugs.webkit.org/show_bug.cgi?id=123868

Reviewed by Andreas Kling.

Merge https://chromium.googlesource.com/chromium/blink/+/c89b413ff0fc4aafa0c71d180b0b1e131bb37707

When we need both Node::renderer() and Node::rendererIsEditable() conditions to be true to perform
some operation, it is more effective to check for renderer() first, so that if this condition fails
we can avoid unnecessary computation of rendererIsEditable().

* dom/Position.cpp:
(WebCore::nextRenderedEditable):
(WebCore::previousRenderedEditable):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseReleaseEvent):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158723 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8985b147
2013-11-05 Ryosuke Niwa <rniwa@webkit.org>
Change the order of conditions to avoid computing rendererIsEditable()
https://bugs.webkit.org/show_bug.cgi?id=123868
Reviewed by Andreas Kling.
Merge https://chromium.googlesource.com/chromium/blink/+/c89b413ff0fc4aafa0c71d180b0b1e131bb37707
When we need both Node::renderer() and Node::rendererIsEditable() conditions to be true to perform
some operation, it is more effective to check for renderer() first, so that if this condition fails
we can avoid unnecessary computation of rendererIsEditable().
* dom/Position.cpp:
(WebCore::nextRenderedEditable):
(WebCore::previousRenderedEditable):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseReleaseEvent):
2013-11-05 Ryosuke Niwa <rniwa@webkit.org>
simpleUserAgentStyleSheet doesn't have focus ring on anchor element
......
......@@ -65,10 +65,8 @@ static bool hasInlineBoxWrapper(RenderObject& renderer)
static Node* nextRenderedEditable(Node* node)
{
while ((node = nextLeafNode(node))) {
if (!node->rendererIsEditable())
continue;
RenderObject* renderer = node->renderer();
if (!renderer)
if (!renderer || !node->rendererIsEditable())
continue;
if (hasInlineBoxWrapper(*renderer))
return node;
......@@ -79,10 +77,8 @@ static Node* nextRenderedEditable(Node* node)
static Node* previousRenderedEditable(Node* node)
{
while ((node = previousLeafNode(node))) {
if (!node->rendererIsEditable())
continue;
RenderObject* renderer = node->renderer();
if (!renderer)
if (!renderer || !node->rendererIsEditable())
continue;
if (hasInlineBoxWrapper(*renderer))
return node;
......
......@@ -937,7 +937,7 @@ bool EventHandler::handleMouseReleaseEvent(const MouseEventWithHitTestResults& e
VisibleSelection newSelection;
Node* node = event.targetNode();
bool caretBrowsing = m_frame.settings().caretBrowsingEnabled();
if (node && (caretBrowsing || node->rendererIsEditable()) && node->renderer()) {
if (node && node->renderer() && (caretBrowsing || node->rendererIsEditable())) {
VisiblePosition pos = node->renderer()->positionForPoint(event.localPoint());
newSelection = VisibleSelection(pos);
}
......
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