|
68 | 68 | #include "nsIFrameInlines.h"
|
69 | 69 | #include "mozilla/intl/WordBreaker.h"
|
70 | 70 | #include "mozilla/ServoStyleSet.h"
|
71 |
| -#include "mozilla/layers/LayersMessages.h" |
72 |
| -#include "mozilla/layers/RenderRootStateManager.h" |
73 |
| -#include "mozilla/layers/WebRenderBridgeChild.h" |
74 |
| -#include "mozilla/webrender/WebRenderAPI.h" |
75 |
| -#include "mozilla/layers/StackingContextHelper.h" |
76 | 71 |
|
77 | 72 | #include <algorithm>
|
78 | 73 | #include <limits>
|
|
105 | 100 | using namespace mozilla;
|
106 | 101 | using namespace mozilla::dom;
|
107 | 102 | using namespace mozilla::gfx;
|
108 |
| -using namespace mozilla::layers; |
109 | 103 |
|
110 | 104 | typedef mozilla::layout::TextDrawTarget TextDrawTarget;
|
111 | 105 |
|
@@ -4849,274 +4843,13 @@ nsresult nsTextFrame::CharacterDataChanged(
|
4849 | 4843 | return NS_OK;
|
4850 | 4844 | }
|
4851 | 4845 |
|
4852 |
| -class nsDisplayText final : public nsCharClipDisplayItem { |
4853 |
| - public: |
4854 |
| - nsDisplayText(nsDisplayListBuilder* aBuilder, nsTextFrame* aFrame, |
4855 |
| - const Maybe<bool>& aIsSelected); |
4856 |
| -#ifdef NS_BUILD_REFCNT_LOGGING |
4857 |
| - virtual ~nsDisplayText() { MOZ_COUNT_DTOR(nsDisplayText); } |
4858 |
| -#endif |
4859 |
| - |
4860 |
| - void RestoreState() final { |
4861 |
| - nsCharClipDisplayItem::RestoreState(); |
4862 |
| - mOpacity = 1.0f; |
4863 |
| - } |
4864 |
| - |
4865 |
| - nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const final { |
4866 |
| - *aSnap = false; |
4867 |
| - return mBounds; |
4868 |
| - } |
4869 |
| - void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, |
4870 |
| - HitTestState* aState, nsTArray<nsIFrame*>* aOutFrames) final { |
4871 |
| - if (nsRect(ToReferenceFrame(), mFrame->GetSize()).Intersects(aRect)) { |
4872 |
| - aOutFrames->AppendElement(mFrame); |
4873 |
| - } |
4874 |
| - } |
4875 |
| - bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder, |
4876 |
| - mozilla::wr::IpcResourceUpdateQueue& aResources, |
4877 |
| - const StackingContextHelper& aSc, |
4878 |
| - RenderRootStateManager* aManager, |
4879 |
| - nsDisplayListBuilder* aDisplayListBuilder) final; |
4880 |
| - void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) final; |
4881 |
| - NS_DISPLAY_DECL_NAME("Text", TYPE_TEXT) |
4882 |
| - |
4883 |
| - nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder) const final { |
4884 |
| - if (gfxPlatform::GetPlatform()->RespectsFontStyleSmoothing()) { |
4885 |
| - // On OS X, web authors can turn off subpixel text rendering using the |
4886 |
| - // CSS property -moz-osx-font-smoothing. If they do that, we don't need |
4887 |
| - // to use component alpha layers for the affected text. |
4888 |
| - if (mFrame->StyleFont()->mFont.smoothing == NS_FONT_SMOOTHING_GRAYSCALE) { |
4889 |
| - return nsRect(); |
4890 |
| - } |
4891 |
| - } |
4892 |
| - bool snap; |
4893 |
| - return GetBounds(aBuilder, &snap); |
4894 |
| - } |
4895 |
| - |
4896 |
| - nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) final; |
4897 |
| - |
4898 |
| - void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder, |
4899 |
| - const nsDisplayItemGeometry* aGeometry, |
4900 |
| - nsRegion* aInvalidRegion) const final; |
4901 |
| - |
4902 |
| - void RenderToContext(gfxContext* aCtx, nsDisplayListBuilder* aBuilder, |
4903 |
| - bool aIsRecording = false); |
4904 |
| - |
4905 |
| - bool CanApplyOpacity() const final { |
4906 |
| - if (IsSelected()) { |
4907 |
| - return false; |
4908 |
| - } |
4909 |
| - |
4910 |
| - nsTextFrame* f = static_cast<nsTextFrame*>(mFrame); |
4911 |
| - const nsStyleText* textStyle = f->StyleText(); |
4912 |
| - if (textStyle->mTextShadow) { |
4913 |
| - return false; |
4914 |
| - } |
4915 |
| - |
4916 |
| - nsTextFrame::TextDecorations decorations; |
4917 |
| - f->GetTextDecorations(f->PresContext(), nsTextFrame::eResolvedColors, |
4918 |
| - decorations); |
4919 |
| - if (decorations.HasDecorationLines()) { |
4920 |
| - return false; |
4921 |
| - } |
4922 |
| - |
4923 |
| - return true; |
4924 |
| - } |
4925 |
| - |
4926 |
| - void ApplyOpacity(nsDisplayListBuilder* aBuilder, float aOpacity, |
4927 |
| - const DisplayItemClipChain* aClip) final { |
4928 |
| - NS_ASSERTION(CanApplyOpacity(), "ApplyOpacity should be allowed"); |
4929 |
| - mOpacity = aOpacity; |
4930 |
| - IntersectClip(aBuilder, aClip, false); |
4931 |
| - } |
4932 |
| - |
4933 |
| - void WriteDebugInfo(std::stringstream& aStream) final { |
4934 |
| -#ifdef DEBUG |
4935 |
| - aStream << " (\""; |
4936 |
| - |
4937 |
| - nsTextFrame* f = static_cast<nsTextFrame*>(mFrame); |
4938 |
| - nsCString buf; |
4939 |
| - int32_t totalContentLength; |
4940 |
| - f->ToCString(buf, &totalContentLength); |
4941 |
| - |
4942 |
| - aStream << buf.get() << "\")"; |
4943 |
| -#endif |
4944 |
| - } |
4945 |
| - |
4946 |
| - nsRect mBounds; |
4947 |
| - float mOpacity; |
4948 |
| -}; |
4949 |
| - |
4950 |
| -class nsDisplayTextGeometry : public nsCharClipGeometry { |
4951 |
| - public: |
4952 |
| - nsDisplayTextGeometry(nsDisplayText* aItem, nsDisplayListBuilder* aBuilder) |
4953 |
| - : nsCharClipGeometry(aItem, aBuilder), mOpacity(aItem->mOpacity) { |
4954 |
| - nsTextFrame* f = static_cast<nsTextFrame*>(aItem->Frame()); |
4955 |
| - f->GetTextDecorations(f->PresContext(), nsTextFrame::eResolvedColors, |
4956 |
| - mDecorations); |
4957 |
| - } |
4958 |
| - |
4959 |
| - /** |
4960 |
| - * We store the computed text decorations here since they are |
4961 |
| - * computed using style data from parent frames. Any changes to these |
4962 |
| - * styles will only invalidate the parent frame and not this frame. |
4963 |
| - */ |
4964 |
| - nsTextFrame::TextDecorations mDecorations; |
4965 |
| - float mOpacity; |
4966 |
| -}; |
4967 |
| - |
4968 |
| -nsDisplayItemGeometry* nsDisplayText::AllocateGeometry( |
4969 |
| - nsDisplayListBuilder* aBuilder) { |
4970 |
| - return new nsDisplayTextGeometry(this, aBuilder); |
4971 |
| -} |
4972 |
| - |
4973 |
| -void nsDisplayText::ComputeInvalidationRegion( |
4974 |
| - nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry, |
4975 |
| - nsRegion* aInvalidRegion) const { |
4976 |
| - const nsDisplayTextGeometry* geometry = |
4977 |
| - static_cast<const nsDisplayTextGeometry*>(aGeometry); |
4978 |
| - nsTextFrame* f = static_cast<nsTextFrame*>(mFrame); |
4979 |
| - |
4980 |
| - nsTextFrame::TextDecorations decorations; |
4981 |
| - f->GetTextDecorations(f->PresContext(), nsTextFrame::eResolvedColors, |
4982 |
| - decorations); |
4983 |
| - |
4984 |
| - bool snap; |
4985 |
| - nsRect newRect = geometry->mBounds; |
4986 |
| - nsRect oldRect = GetBounds(aBuilder, &snap); |
4987 |
| - if (decorations != geometry->mDecorations || |
4988 |
| - mVisIStartEdge != geometry->mVisIStartEdge || |
4989 |
| - mVisIEndEdge != geometry->mVisIEndEdge || |
4990 |
| - !oldRect.IsEqualInterior(newRect) || |
4991 |
| - !geometry->mBorderRect.IsEqualInterior(GetBorderRect()) || |
4992 |
| - mOpacity != geometry->mOpacity) { |
4993 |
| - aInvalidRegion->Or(oldRect, newRect); |
4994 |
| - } |
4995 |
| -} |
4996 |
| - |
4997 | 4846 | NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(TextCombineScaleFactorProperty, float)
|
4998 | 4847 |
|
4999 |
| -static float GetTextCombineScaleFactor(nsTextFrame* aFrame) { |
| 4848 | +float nsTextFrame::GetTextCombineScaleFactor(nsTextFrame* aFrame) { |
5000 | 4849 | float factor = aFrame->GetProperty(TextCombineScaleFactorProperty());
|
5001 | 4850 | return factor ? factor : 1.0f;
|
5002 | 4851 | }
|
5003 | 4852 |
|
5004 |
| -nsDisplayText::nsDisplayText(nsDisplayListBuilder* aBuilder, |
5005 |
| - nsTextFrame* aFrame, |
5006 |
| - const Maybe<bool>& aIsSelected) |
5007 |
| - : nsCharClipDisplayItem(aBuilder, aFrame), mOpacity(1.0f) { |
5008 |
| - MOZ_COUNT_CTOR(nsDisplayText); |
5009 |
| - mIsFrameSelected = aIsSelected; |
5010 |
| - mBounds = mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame(); |
5011 |
| - // Bug 748228 |
5012 |
| - mBounds.Inflate(mFrame->PresContext()->AppUnitsPerDevPixel()); |
5013 |
| -} |
5014 |
| - |
5015 |
| -void nsDisplayText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { |
5016 |
| - AUTO_PROFILER_LABEL("nsDisplayText::Paint", GRAPHICS); |
5017 |
| - |
5018 |
| - DrawTargetAutoDisableSubpixelAntialiasing disable(aCtx->GetDrawTarget(), |
5019 |
| - mDisableSubpixelAA); |
5020 |
| - RenderToContext(aCtx, aBuilder); |
5021 |
| -} |
5022 |
| - |
5023 |
| -bool nsDisplayText::CreateWebRenderCommands( |
5024 |
| - mozilla::wr::DisplayListBuilder& aBuilder, |
5025 |
| - mozilla::wr::IpcResourceUpdateQueue& aResources, |
5026 |
| - const StackingContextHelper& aSc, RenderRootStateManager* aManager, |
5027 |
| - nsDisplayListBuilder* aDisplayListBuilder) { |
5028 |
| - if (mBounds.IsEmpty()) { |
5029 |
| - return true; |
5030 |
| - } |
5031 |
| - |
5032 |
| - auto appUnitsPerDevPixel = Frame()->PresContext()->AppUnitsPerDevPixel(); |
5033 |
| - gfx::Point deviceOffset = |
5034 |
| - LayoutDevicePoint::FromAppUnits(mBounds.TopLeft(), appUnitsPerDevPixel) |
5035 |
| - .ToUnknownPoint(); |
5036 |
| - |
5037 |
| - nsRect visible = GetPaintRect(); |
5038 |
| - visible.Inflate(3 * appUnitsPerDevPixel); |
5039 |
| - |
5040 |
| - visible = visible.Intersect(mBounds); |
5041 |
| - |
5042 |
| - RefPtr<gfxContext> textDrawer = aBuilder.GetTextContext( |
5043 |
| - aResources, aSc, aManager, this, visible, deviceOffset); |
5044 |
| - |
5045 |
| - RenderToContext(textDrawer, aDisplayListBuilder, true); |
5046 |
| - |
5047 |
| - return textDrawer->GetTextDrawer()->Finish(); |
5048 |
| -} |
5049 |
| - |
5050 |
| -void nsDisplayText::RenderToContext(gfxContext* aCtx, |
5051 |
| - nsDisplayListBuilder* aBuilder, |
5052 |
| - bool aIsRecording) { |
5053 |
| - nsTextFrame* f = static_cast<nsTextFrame*>(mFrame); |
5054 |
| - |
5055 |
| - // Add 1 pixel of dirty area around mVisibleRect to allow us to paint |
5056 |
| - // antialiased pixels beyond the measured text extents. |
5057 |
| - // This is temporary until we do this in the actual calculation of text |
5058 |
| - // extents. |
5059 |
| - auto A2D = mFrame->PresContext()->AppUnitsPerDevPixel(); |
5060 |
| - LayoutDeviceRect extraVisible = |
5061 |
| - LayoutDeviceRect::FromAppUnits(GetPaintRect(), A2D); |
5062 |
| - extraVisible.Inflate(1); |
5063 |
| - |
5064 |
| - gfxRect pixelVisible(extraVisible.x, extraVisible.y, extraVisible.width, |
5065 |
| - extraVisible.height); |
5066 |
| - pixelVisible.Inflate(2); |
5067 |
| - pixelVisible.RoundOut(); |
5068 |
| - |
5069 |
| - bool willClip = !aBuilder->IsForGenerateGlyphMask() && !aIsRecording; |
5070 |
| - if (willClip) { |
5071 |
| - aCtx->NewPath(); |
5072 |
| - aCtx->Rectangle(pixelVisible); |
5073 |
| - aCtx->Clip(); |
5074 |
| - } |
5075 |
| - |
5076 |
| - NS_ASSERTION(mVisIStartEdge >= 0, "illegal start edge"); |
5077 |
| - NS_ASSERTION(mVisIEndEdge >= 0, "illegal end edge"); |
5078 |
| - |
5079 |
| - gfxContextMatrixAutoSaveRestore matrixSR; |
5080 |
| - |
5081 |
| - nsPoint framePt = ToReferenceFrame(); |
5082 |
| - if (f->Style()->IsTextCombined()) { |
5083 |
| - float scaleFactor = GetTextCombineScaleFactor(f); |
5084 |
| - if (scaleFactor != 1.0f) { |
5085 |
| - if (auto* textDrawer = aCtx->GetTextDrawer()) { |
5086 |
| - // WebRender doesn't support scaling text like this yet |
5087 |
| - textDrawer->FoundUnsupportedFeature(); |
5088 |
| - return; |
5089 |
| - } |
5090 |
| - matrixSR.SetContext(aCtx); |
5091 |
| - // Setup matrix to compress text for text-combine-upright if |
5092 |
| - // necessary. This is done here because we want selection be |
5093 |
| - // compressed at the same time as text. |
5094 |
| - gfxPoint pt = nsLayoutUtils::PointToGfxPoint(framePt, A2D); |
5095 |
| - gfxMatrix mat = aCtx->CurrentMatrixDouble() |
5096 |
| - .PreTranslate(pt) |
5097 |
| - .PreScale(scaleFactor, 1.0) |
5098 |
| - .PreTranslate(-pt); |
5099 |
| - aCtx->SetMatrixDouble(mat); |
5100 |
| - } |
5101 |
| - } |
5102 |
| - nsTextFrame::PaintTextParams params(aCtx); |
5103 |
| - params.framePt = gfx::Point(framePt.x, framePt.y); |
5104 |
| - params.dirtyRect = extraVisible; |
5105 |
| - |
5106 |
| - if (aBuilder->IsForGenerateGlyphMask()) { |
5107 |
| - params.state = nsTextFrame::PaintTextParams::GenerateTextMask; |
5108 |
| - } else { |
5109 |
| - params.state = nsTextFrame::PaintTextParams::PaintText; |
5110 |
| - } |
5111 |
| - |
5112 |
| - f->PaintText(params, mVisIStartEdge, mVisIEndEdge, ToReferenceFrame(), |
5113 |
| - IsSelected(), mOpacity); |
5114 |
| - |
5115 |
| - if (willClip) { |
5116 |
| - aCtx->PopClip(); |
5117 |
| - } |
5118 |
| -} |
5119 |
| - |
5120 | 4853 | void nsTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
5121 | 4854 | const nsDisplayListSet& aLists) {
|
5122 | 4855 | if (!IsVisibleForPainting()) return;
|
@@ -6207,7 +5940,7 @@ bool nsTextFrame::PaintTextWithSelectionColors(
|
6207 | 5940 | const PaintTextSelectionParams& aParams,
|
6208 | 5941 | const UniquePtr<SelectionDetails>& aDetails,
|
6209 | 5942 | SelectionTypeMask* aAllSelectionTypeMask,
|
6210 |
| - const nsCharClipDisplayItem::ClipEdges& aClipEdges) { |
| 5943 | + const nsDisplayText::ClipEdges& aClipEdges) { |
6211 | 5944 | const gfxTextRun::Range& contentRange = aParams.contentRange;
|
6212 | 5945 |
|
6213 | 5946 | // Figure out which selections control the colors to use for each character.
|
@@ -6472,7 +6205,7 @@ void nsTextFrame::PaintTextSelectionDecorations(
|
6472 | 6205 |
|
6473 | 6206 | bool nsTextFrame::PaintTextWithSelection(
|
6474 | 6207 | const PaintTextSelectionParams& aParams,
|
6475 |
| - const nsCharClipDisplayItem::ClipEdges& aClipEdges) { |
| 6208 | + const nsDisplayText::ClipEdges& aClipEdges) { |
6476 | 6209 | NS_ASSERTION(GetContent()->IsSelectionDescendant(), "wrong paint path");
|
6477 | 6210 |
|
6478 | 6211 | UniquePtr<SelectionDetails> details = GetSelectionDetails();
|
@@ -6827,8 +6560,8 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
|
6827 | 6560 | } else {
|
6828 | 6561 | textBaselinePt.x += reversed ? -snappedEndEdge : snappedStartEdge;
|
6829 | 6562 | }
|
6830 |
| - nsCharClipDisplayItem::ClipEdges clipEdges(this, aToReferenceFrame, |
6831 |
| - snappedStartEdge, snappedEndEdge); |
| 6563 | + nsDisplayText::ClipEdges clipEdges(this, aToReferenceFrame, snappedStartEdge, |
| 6564 | + snappedEndEdge); |
6832 | 6565 | nsTextPaintStyle textPaintStyle(this);
|
6833 | 6566 | textPaintStyle.SetResolveColors(!aParams.callbacks);
|
6834 | 6567 |
|
|
0 commit comments