зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1463327 - part 3: Change scope of some methods of HTMLEditor which won't be called by non-helper classes of editing to protected r=m_kato
HTMLEditor has 2 type of public methods. One is rue-public methods. I.e., they should be able to be called by anybody. E.g., command handlers, event listeners, or JS via nsIEditor interface. The other is semi-public methods. They are not called by the above examples but called by other classes which are helper classes to handle edit actions. E.g., TextEditRules, HTMLEditRules, HTMLEditUtils, CSSEditUtils and Transaction classes. When we will implement InputEvent.inputType, we need to create new stack class and create its instance at every true-public methods to manage current inputType (like TextEditRules::AutoSafeEditorData). Therefore, it should not happen that new code starts to call semi-public methods without the new stack class instance. For preventing this issue, we should make HTMLEditor have only the true-public methods as public. The other public methods should be protected and their users should be friend classes. Then, we can protect such method from external classes. Note that this patch just moves the methods without any changes in HTMLEditor.h (except removes BlockTransformationType since it's unused and replaces ResizingRequestID with new enum class ResizeAt since normal enum isn't hit by searchfox.org). MozReview-Commit-ID: 7PC8E8vD7w2 --HG-- extra : rebase_source : 13f51565f2b89ab816ba529af18ee88193a9c932
This commit is contained in:
Родитель
f615160008
Коммит
d40825b1e4
|
@ -83,16 +83,6 @@ enum
|
|||
* first some helpful functors we will use
|
||||
********************************************************/
|
||||
|
||||
static bool IsBlockNode(const nsINode& node)
|
||||
{
|
||||
return HTMLEditor::NodeIsBlockStatic(&node);
|
||||
}
|
||||
|
||||
static bool IsInlineNode(const nsINode& node)
|
||||
{
|
||||
return !IsBlockNode(node);
|
||||
}
|
||||
|
||||
static bool
|
||||
IsStyleCachePreservingAction(EditAction action)
|
||||
{
|
||||
|
|
|
@ -156,6 +156,15 @@ protected:
|
|||
return mData->HTMLEditorRef();
|
||||
}
|
||||
|
||||
static bool IsBlockNode(const nsINode& aNode)
|
||||
{
|
||||
return HTMLEditor::NodeIsBlockStatic(&aNode);
|
||||
}
|
||||
static bool IsInlineNode(const nsINode& aNode)
|
||||
{
|
||||
return !IsBlockNode(aNode);
|
||||
}
|
||||
|
||||
enum RulesEndpoint
|
||||
{
|
||||
kStart,
|
||||
|
|
|
@ -75,6 +75,8 @@ namespace mozilla {
|
|||
using namespace dom;
|
||||
using namespace widget;
|
||||
|
||||
const char16_t kNBSP = 160;
|
||||
|
||||
// Some utilities to handle overloading of "A" tag for link and named anchor.
|
||||
static bool
|
||||
IsLinkTag(const nsString& s)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -691,19 +691,21 @@ HTMLEditor::SetShadowPosition(Element* aShadow,
|
|||
int32_t
|
||||
HTMLEditor::GetNewResizingIncrement(int32_t aX,
|
||||
int32_t aY,
|
||||
int32_t aID)
|
||||
ResizeAt aResizeAt)
|
||||
{
|
||||
int32_t result = 0;
|
||||
if (!mPreserveRatio) {
|
||||
switch (aID) {
|
||||
case kX:
|
||||
case kWidth:
|
||||
switch (aResizeAt) {
|
||||
case ResizeAt::eX:
|
||||
case ResizeAt::eWidth:
|
||||
result = aX - mOriginalX;
|
||||
break;
|
||||
case kY:
|
||||
case kHeight:
|
||||
case ResizeAt::eY:
|
||||
case ResizeAt::eHeight:
|
||||
result = aY - mOriginalY;
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Invalid resizing request");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -713,15 +715,15 @@ HTMLEditor::GetNewResizingIncrement(int32_t aX,
|
|||
float objectSizeRatio =
|
||||
((float)mResizedObjectWidth) / ((float)mResizedObjectHeight);
|
||||
result = (xi > yi) ? xi : yi;
|
||||
switch (aID) {
|
||||
case kX:
|
||||
case kWidth:
|
||||
switch (aResizeAt) {
|
||||
case ResizeAt::eX:
|
||||
case ResizeAt::eWidth:
|
||||
if (result == yi)
|
||||
result = (int32_t) (((float) result) * objectSizeRatio);
|
||||
result = (int32_t) (((float) result) * mWidthIncrementFactor);
|
||||
break;
|
||||
case kY:
|
||||
case kHeight:
|
||||
case ResizeAt::eY:
|
||||
case ResizeAt::eHeight:
|
||||
if (result == xi)
|
||||
result = (int32_t) (((float) result) / objectSizeRatio);
|
||||
result = (int32_t) (((float) result) * mHeightIncrementFactor);
|
||||
|
@ -734,9 +736,10 @@ int32_t
|
|||
HTMLEditor::GetNewResizingX(int32_t aX,
|
||||
int32_t aY)
|
||||
{
|
||||
int32_t resized = mResizedObjectX +
|
||||
GetNewResizingIncrement(aX, aY, kX) * mXIncrementFactor;
|
||||
int32_t max = mResizedObjectX + mResizedObjectWidth;
|
||||
int32_t resized =
|
||||
mResizedObjectX +
|
||||
GetNewResizingIncrement(aX, aY, ResizeAt::eX) * mXIncrementFactor;
|
||||
int32_t max = mResizedObjectX + mResizedObjectWidth;
|
||||
return std::min(resized, max);
|
||||
}
|
||||
|
||||
|
@ -744,8 +747,9 @@ int32_t
|
|||
HTMLEditor::GetNewResizingY(int32_t aX,
|
||||
int32_t aY)
|
||||
{
|
||||
int32_t resized = mResizedObjectY +
|
||||
GetNewResizingIncrement(aX, aY, kY) * mYIncrementFactor;
|
||||
int32_t resized =
|
||||
mResizedObjectY +
|
||||
GetNewResizingIncrement(aX, aY, ResizeAt::eY) * mYIncrementFactor;
|
||||
int32_t max = mResizedObjectY + mResizedObjectHeight;
|
||||
return std::min(resized, max);
|
||||
}
|
||||
|
@ -754,9 +758,10 @@ int32_t
|
|||
HTMLEditor::GetNewResizingWidth(int32_t aX,
|
||||
int32_t aY)
|
||||
{
|
||||
int32_t resized = mResizedObjectWidth +
|
||||
GetNewResizingIncrement(aX, aY, kWidth) *
|
||||
mWidthIncrementFactor;
|
||||
int32_t resized =
|
||||
mResizedObjectWidth +
|
||||
GetNewResizingIncrement(aX, aY,
|
||||
ResizeAt::eWidth) * mWidthIncrementFactor;
|
||||
return std::max(resized, 1);
|
||||
}
|
||||
|
||||
|
@ -764,9 +769,10 @@ int32_t
|
|||
HTMLEditor::GetNewResizingHeight(int32_t aX,
|
||||
int32_t aY)
|
||||
{
|
||||
int32_t resized = mResizedObjectHeight +
|
||||
GetNewResizingIncrement(aX, aY, kHeight) *
|
||||
mHeightIncrementFactor;
|
||||
int32_t resized =
|
||||
mResizedObjectHeight +
|
||||
GetNewResizingIncrement(aX, aY,
|
||||
ResizeAt::eHeight) * mHeightIncrementFactor;
|
||||
return std::max(resized, 1);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче