https://bugs.webkit.org/show_bug.cgi?id=139557
Patch by Myles C. Maxfield <mmaxfield@apple.com> on 2014-12-15
Reviewed by Darin Adler.
Source/WebCore:
This patch deletes the helper functions rendererBoundingBox() and rendererAnchorRect() and
migrates callers to using renderers directly.
It also improves the comment in RenderElement.h regarding RenderElement::anchorRect().
No new tests because this is simply refactoring.
* WebCore.exp.in: Delete exported symbol for rendererBoundingBox()
* accessibility/AccessibilitySlider.cpp:
(WebCore::AccessibilitySliderThumb::elementRect): Migrate off rendererBoundingBox()
* dom/ContainerNode.cpp:
(WebCore::rendererAnchorRect): Deleted.
* dom/ContainerNode.h:
* dom/Node.cpp:
(WebCore::rendererBoundingBox): Deleted.
* dom/Node.h:
* html/ColorInputType.cpp:
(WebCore::ColorInputType::elementRectRelativeToRootView): Migrate off rendererBoundingBox().
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setupDateTimeChooserParameters): Ditto.
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::buildBubbleTree): Ditto.
* page/FrameView.cpp:
(WebCore::FrameView::scrollElementToRect): Migrate off rendererAnchorRect().
(WebCore::FrameView::scrollToAnchor): Ditto.
* page/SpatialNavigation.cpp:
(WebCore::nodeRectInAbsoluteCoordinates): Migrate off rendererBoundingBox().
* rendering/RenderElement.h:
Source/WebKit/mac:
* WebView/WebActionMenuController.mm:
(elementBoundingBoxInWindowCoordinatesFromNode): Migrate off rendererBoundingBox().
Source/WebKit2:
* Shared/WebHitTestResult.cpp:
(WebKit::WebHitTestResult::Data::elementBoundingBoxInWindowCoordinates): Migrate off rendererBoundingBox().
* WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp:
(WebKit::WebPage::findZoomableAreaForPoint): Ditto.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177301
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-12-15 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Addressing post-review comments in r177035
+ https://bugs.webkit.org/show_bug.cgi?id=139557
+
+ Reviewed by Darin Adler.
+
+ This patch deletes the helper functions rendererBoundingBox() and rendererAnchorRect() and
+ migrates callers to using renderers directly.
+
+ It also improves the comment in RenderElement.h regarding RenderElement::anchorRect().
+
+ No new tests because this is simply refactoring.
+
+ * WebCore.exp.in: Delete exported symbol for rendererBoundingBox()
+ * accessibility/AccessibilitySlider.cpp:
+ (WebCore::AccessibilitySliderThumb::elementRect): Migrate off rendererBoundingBox()
+ * dom/ContainerNode.cpp:
+ (WebCore::rendererAnchorRect): Deleted.
+ * dom/ContainerNode.h:
+ * dom/Node.cpp:
+ (WebCore::rendererBoundingBox): Deleted.
+ * dom/Node.h:
+ * html/ColorInputType.cpp:
+ (WebCore::ColorInputType::elementRectRelativeToRootView): Migrate off rendererBoundingBox().
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::setupDateTimeChooserParameters): Ditto.
+ * html/ValidationMessage.cpp:
+ (WebCore::ValidationMessage::buildBubbleTree): Ditto.
+ * page/FrameView.cpp:
+ (WebCore::FrameView::scrollElementToRect): Migrate off rendererAnchorRect().
+ (WebCore::FrameView::scrollToAnchor): Ditto.
+ * page/SpatialNavigation.cpp:
+ (WebCore::nodeRectInAbsoluteCoordinates): Migrate off rendererBoundingBox().
+ * rendering/RenderElement.h:
+
2014-12-15 Myles C. Maxfield <mmaxfield@apple.com>
Delete Notation because we don't use it
__ZN7WebCore19enclosingLayoutRectERKNS_9FloatRectE
__ZN7WebCore19floatValueForLengthERKNS_6LengthEf
__ZN7WebCore19getFileCreationTimeERKN3WTF6StringERl
-__ZN7WebCore19rendererBoundingBoxERKNS_4NodeE
__ZN7WebCore19toInt32EnforceRangeEPN3JSC9ExecStateENS0_7JSValueE
__ZN7WebCore20ApplicationCacheHost17maybeLoadResourceEPNS_14ResourceLoaderERKNS_15ResourceRequestERKNS_3URLE
__ZN7WebCore20ApplicationCacheHost25maybeLoadFallbackForErrorEPNS_14ResourceLoaderERKNS_13ResourceErrorE
RenderObject* sliderRenderer = m_parent->renderer();
if (!sliderRenderer || !sliderRenderer->isSlider())
return LayoutRect();
- return rendererBoundingBox(*downcast<HTMLInputElement>(sliderRenderer->node())->sliderThumbElement());
+ if (RenderElement* thumbRenderer = downcast<HTMLInputElement>(sliderRenderer->node())->sliderThumbElement()->renderer())
+ return thumbRenderer->absoluteBoundingBoxRect();
+ return LayoutRect();
}
bool AccessibilitySliderThumb::computeAccessibilityIsIgnored() const
return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, name);
}
-LayoutRect rendererAnchorRect(const ContainerNode& node)
-{
- if (RenderElement* renderer = node.renderer())
- return renderer->anchorRect();
- return LayoutRect();
-}
-
} // namespace WebCore
ChildNodesLazySnapshot* m_nextSnapshot;
};
-LayoutRect rendererAnchorRect(const ContainerNode&);
-
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ContainerNode)
return inDocument() && document().hasLivingRenderTree();
}
-IntRect rendererBoundingBox(const Node& node)
-{
- if (RenderObject* renderer = node.renderer())
- return renderer->absoluteBoundingBoxRect();
- return IntRect();
-}
-
} // namespace WebCore
#ifndef NDEBUG
return parentNode();
}
-WEBCORE_EXPORT IntRect rendererBoundingBox(const Node&);
-
} // namespace WebCore
#ifndef NDEBUG
IntRect ColorInputType::elementRectRelativeToRootView() const
{
- return element().document().view()->contentsToRootView(rendererBoundingBox(element()));
+ if (!element().renderer())
+ return IntRect();
+ element().document().view()->contentsToRootView(element().renderer()->absoluteBoundingBoxRect());
}
Color ColorInputType::currentColor()
parameters.stepBase = 0;
}
- parameters.anchorRectInRootView = document().view()->contentsToRootView(rendererBoundingBox(*this));
+ if (RenderObject* renderer = this->renderer())
+ parameters.anchorRectInRootView = document().view()->contentsToRootView(renderer->absoluteBoundingBoxRect());
+ else
+ parameters.anchorRectInRootView = IntRect();
parameters.currentValue = value();
parameters.isAnchorElementRTL = computedStyle()->direction() == RTL;
#if ENABLE(DATALIST_ELEMENT)
void ValidationMessage::buildBubbleTree()
{
ASSERT(!validationMessageClient());
+
+ if (!m_element->renderer())
+ return;
+
ShadowRoot& shadowRoot = m_element->ensureUserAgentShadowRoot();
Document& document = m_element->document();
m_bubble->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
shadowRoot.appendChild(m_bubble.get(), ASSERT_NO_EXCEPTION);
document.updateLayout();
- adjustBubblePosition(rendererBoundingBox(*m_element), m_bubble.get());
+ adjustBubblePosition(m_element->renderer()->absoluteBoundingBoxRect(), m_bubble.get());
RefPtr<HTMLDivElement> clipper = HTMLDivElement::create(document);
clipper->setPseudo(AtomicString("-webkit-validation-bubble-arrow-clipper", AtomicString::ConstructFromLiteral));
{
frame().document()->updateLayoutIgnorePendingStylesheets();
- LayoutRect bounds = rendererAnchorRect(*element);
+ LayoutRect bounds;
+ if (RenderElement* renderer = element->renderer())
+ bounds = renderer->anchorRect();
int centeringOffsetX = (rect.width() - bounds.width()) / 2;
int centeringOffsetY = (rect.height() - bounds.height()) / 2;
setScrollPosition(IntPoint(bounds.x() - centeringOffsetX - rect.x(), bounds.y() - centeringOffsetY - rect.y()));
return;
LayoutRect rect;
- if (anchorNode != frame().document())
- rect = rendererAnchorRect(*anchorNode.get());
+ if (anchorNode != frame().document() && anchorNode->renderer())
+ rect = anchorNode->renderer()->anchorRect();
// Scroll nested layers and frames to reveal the anchor.
// Align to the top and to the closest side (this matches other browsers).
if (is<Document>(*node))
return frameRectInAbsoluteCoordinates(downcast<Document>(*node).frame());
- LayoutRect rect = rectToAbsoluteCoordinates(node->document().frame(), rendererBoundingBox(*node));
+ LayoutRect rect;
+ if (RenderObject* renderer = node->renderer())
+ rect = rectToAbsoluteCoordinates(node->document().frame(), renderer->absoluteBoundingBoxRect());
// For authors that use border instead of outline in their CSS, we compensate by ignoring the border when calculating
// the rect of the focused element.
bool hasHiddenBackface() const { return style().backfaceVisibility() == BackfaceVisibilityHidden; }
// anchorRect() is conceptually similar to absoluteBoundingBoxRect(), but is intended for scrolling to an anchor.
- // It works differently than absoluteBoundingBoxRect() for inline renderers.
+ // For inline renderers, this gets the logical top left of the first leaf child and the logical bottom right of the
+ // last leaf child, converts them to absolute coordinates, and makes a box out of them.
LayoutRect anchorRect() const;
bool hasFilter() const { return style().hasFilter(); }
+2014-12-15 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Addressing post-review comments in r177035
+ https://bugs.webkit.org/show_bug.cgi?id=139557
+
+ Reviewed by Darin Adler.
+
+ * WebView/WebActionMenuController.mm:
+ (elementBoundingBoxInWindowCoordinatesFromNode): Migrate off rendererBoundingBox().
+
2014-12-15 Timothy Horton <timothy_horton@apple.com>
Implement Data Detectors immediate actions for Legacy WebKit
if (!view)
return IntRect();
- return view->contentsToWindow(rendererBoundingBox(*node));
+ RenderObject* renderer = node->renderer();
+ if (!renderer)
+ return IntRect();
+
+ return view->contentsToWindow(renderer->absoluteBoundingBoxRect());
}
- (NSArray *)_defaultMenuItemsForLink
+2014-12-15 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Addressing post-review comments in r177035
+ https://bugs.webkit.org/show_bug.cgi?id=139557
+
+ Reviewed by Darin Adler.
+
+ * Shared/WebHitTestResult.cpp:
+ (WebKit::WebHitTestResult::Data::elementBoundingBoxInWindowCoordinates): Migrate off rendererBoundingBox().
+ * WebProcess/WebPage/CoordinatedGraphics/WebPageCoordinatedGraphics.cpp:
+ (WebKit::WebPage::findZoomableAreaForPoint): Ditto.
+
2014-12-15 Timothy Horton <timothy_horton@apple.com>
Implement Data Detectors immediate actions for WebKit2
if (!view)
return IntRect();
- return view->contentsToWindow(rendererBoundingBox(*node));
+ RenderObject* renderer = node->renderer();
+ if (!renderer)
+ return IntRect();
+
+ return view->contentsToWindow(renderer->absoluteBoundingBoxRect());
}
} // WebKit
if (!node)
return;
- IntRect zoomableArea = rendererBoundingBox(*node);
+ IntRect zoomableArea;
+ if (RenderObject* renderer = node->renderer())
+ zoomableArea = renderer->absoluteBoundingBoxRect();
while (true) {
bool found = !node->isTextNode() && !node->isShadowRoot();
break;
node = node->parentNode();
- zoomableArea.unite(rendererBoundingBox(*node));
+ if (RenderObject* renderer = node.renderer())
+ zoomableArea.unite(renderer->absoluteBoundingBoxRect());
}
if (node->document().frame() && node->document().frame()->view()) {