FloatQuad LayoutGeometryMap::mapToAncestor(const FloatRect& rect, const LayoutBoxModelObject* ancestor) const { FloatQuad result; if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() && (!ancestor || (m_mapping.size() && ancestor == m_mapping[0].m_layoutObject))) { result = rect; result.move(m_accumulatedOffset); } else { TransformState transformState(TransformState::ApplyTransformDirection, rect.center(), rect); mapToAncestor(transformState, ancestor); result = transformState.lastPlanarQuad(); } #if ENABLE(ASSERT) if (m_mapping.size() > 0) { const LayoutObject* lastLayoutObject = m_mapping.last().m_layoutObject; FloatRect layoutObjectMappedResult = lastLayoutObject->localToAncestorQuad(rect, ancestor, m_mapCoordinatesFlags).boundingBox(); // Inspector creates layoutObjects with negative width <https://bugs.webkit.org/show_bug.cgi?id=87194>. // Taking FloatQuad bounds avoids spurious assertions because of that. ASSERT(enclosingIntRect(layoutObjectMappedResult) == enclosingIntRect(result.boundingBox()) || layoutObjectMappedResult.mayNotHaveExactIntRectRepresentation() || result.boundingBox().mayNotHaveExactIntRectRepresentation()); } #endif return result; }
bool DockTabMotherWidget::getInsertionDirection(const QPoint &pos, QWidget *widget, Direction dockDir, InsertionDirection &insertDir) { auto insertionFromAbsoluteDir = [dockDir](Direction absDir)->InsertionDirection { switch (dockDir) { default: case Left: switch (absDir) { default: case Left: return PreviousSplitter; case Right: return NextSplitter; case Top: return Previous; case Bottom: return Next; } case Right: switch (absDir) { default: case Left: return NextSplitter; case Right: return PreviousSplitter; case Top: return Previous; case Bottom: return Next; } case Top: switch (absDir) { default: case Left: return Previous; case Right: return Next; case Top: return PreviousSplitter; case Bottom: return NextSplitter; } case Bottom: switch (absDir) { default: case Left: return Previous; case Right: return Next; case Top: return NextSplitter; case Bottom: return PreviousSplitter; } } }; auto isInInsertDist = [this](int x, int border)->bool { return border - insertDistance() <= x && x < border + insertDistance(); }; QRect rect = widget->rect(); rect.moveTopLeft(mapToAncestor(this, widget, rect.topLeft())); int left = rect.left(); int rightEnd = rect.left() + rect.width(); int top = rect.top(); int bottomEnd = rect.top() + rect.height(); int x = pos.x(); int y = pos.y(); if (left <= x && x < rightEnd) { if (isInInsertDist(top, y)) { insertDir = insertionFromAbsoluteDir(Top); return true; } if (isInInsertDist(bottomEnd, y)) { insertDir = insertionFromAbsoluteDir(Bottom); return true; } } if (top <= y && y < bottomEnd) { if (isInInsertDist(left, x)) { insertDir = insertionFromAbsoluteDir(Left); return true; } if (isInInsertDist(rightEnd, x)) { insertDir = insertionFromAbsoluteDir(Right); return true; } } return false; }