2
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
5
+ #include " mozilla/HTMLEditor.h"
6
+
5
7
#include < math.h>
6
8
7
9
#include " EditorUtils.h"
20
22
#include " nsEditor.h"
21
23
#include " nsError.h"
22
24
#include " nsGkAtoms.h"
23
- #include " nsHTMLEditor.h"
24
25
#include " nsHTMLObjectResizer.h"
25
26
#include " nsIContent.h"
26
27
#include " nsROCSSPrimitiveValue.h"
46
47
#include " nscore.h"
47
48
#include < algorithm>
48
49
49
- using namespace mozilla ;
50
- using namespace mozilla ::dom;
50
+ namespace mozilla {
51
+
52
+ using namespace dom ;
51
53
52
54
#define BLACK_BG_RGB_TRIGGER 0xd0
53
55
54
56
NS_IMETHODIMP
55
- nsHTMLEditor ::AbsolutePositionSelection (bool aEnabled)
57
+ HTMLEditor ::AbsolutePositionSelection (bool aEnabled)
56
58
{
57
59
AutoEditBatch beginBatching (this );
58
60
AutoRules beginRulesSniffing (this ,
@@ -78,7 +80,7 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
78
80
}
79
81
80
82
NS_IMETHODIMP
81
- nsHTMLEditor ::GetAbsolutelyPositionedSelectionContainer (nsIDOMElement ** _retval)
83
+ HTMLEditor ::GetAbsolutelyPositionedSelectionContainer (nsIDOMElement** _retval)
82
84
{
83
85
nsAutoString positionStr;
84
86
nsCOMPtr<nsINode> node = GetSelectionContainer ();
@@ -102,30 +104,31 @@ nsHTMLEditor::GetAbsolutelyPositionedSelectionContainer(nsIDOMElement **_retval)
102
104
}
103
105
104
106
NS_IMETHODIMP
105
- nsHTMLEditor::GetSelectionContainerAbsolutelyPositioned (bool *aIsSelectionContainerAbsolutelyPositioned)
107
+ HTMLEditor::GetSelectionContainerAbsolutelyPositioned (
108
+ bool * aIsSelectionContainerAbsolutelyPositioned)
106
109
{
107
110
*aIsSelectionContainerAbsolutelyPositioned = (mAbsolutelyPositionedObject != nullptr );
108
111
return NS_OK;
109
112
}
110
113
111
114
NS_IMETHODIMP
112
- nsHTMLEditor ::GetAbsolutePositioningEnabled (bool * aIsEnabled)
115
+ HTMLEditor ::GetAbsolutePositioningEnabled (bool * aIsEnabled)
113
116
{
114
117
*aIsEnabled = mIsAbsolutelyPositioningEnabled ;
115
118
return NS_OK;
116
119
}
117
120
118
121
NS_IMETHODIMP
119
- nsHTMLEditor ::SetAbsolutePositioningEnabled (bool aIsEnabled)
122
+ HTMLEditor ::SetAbsolutePositioningEnabled (bool aIsEnabled)
120
123
{
121
124
mIsAbsolutelyPositioningEnabled = aIsEnabled;
122
125
return NS_OK;
123
126
}
124
127
125
128
NS_IMETHODIMP
126
- nsHTMLEditor ::RelativeChangeElementZIndex (nsIDOMElement * aElement,
129
+ HTMLEditor ::RelativeChangeElementZIndex (nsIDOMElement* aElement,
127
130
int32_t aChange,
128
- int32_t * aReturn)
131
+ int32_t * aReturn)
129
132
{
130
133
NS_ENSURE_ARG_POINTER (aElement);
131
134
NS_ENSURE_ARG_POINTER (aReturn);
@@ -144,7 +147,8 @@ nsHTMLEditor::RelativeChangeElementZIndex(nsIDOMElement * aElement,
144
147
}
145
148
146
149
NS_IMETHODIMP
147
- nsHTMLEditor::SetElementZIndex (nsIDOMElement* aElement, int32_t aZindex)
150
+ HTMLEditor::SetElementZIndex (nsIDOMElement* aElement,
151
+ int32_t aZindex)
148
152
{
149
153
nsCOMPtr<Element> element = do_QueryInterface (aElement);
150
154
NS_ENSURE_ARG_POINTER (element);
@@ -157,7 +161,7 @@ nsHTMLEditor::SetElementZIndex(nsIDOMElement* aElement, int32_t aZindex)
157
161
}
158
162
159
163
NS_IMETHODIMP
160
- nsHTMLEditor ::RelativeChangeZIndex (int32_t aChange)
164
+ HTMLEditor ::RelativeChangeZIndex (int32_t aChange)
161
165
{
162
166
AutoEditBatch beginBatching (this );
163
167
AutoRules beginRulesSniffing (this ,
@@ -182,8 +186,8 @@ nsHTMLEditor::RelativeChangeZIndex(int32_t aChange)
182
186
}
183
187
184
188
NS_IMETHODIMP
185
- nsHTMLEditor ::GetElementZIndex (nsIDOMElement * aElement,
186
- int32_t * aZindex)
189
+ HTMLEditor ::GetElementZIndex (nsIDOMElement* aElement,
190
+ int32_t * aZindex)
187
191
{
188
192
nsCOMPtr<Element> element = do_QueryInterface (aElement);
189
193
NS_ENSURE_STATE (element || !aElement);
@@ -227,7 +231,7 @@ nsHTMLEditor::GetElementZIndex(nsIDOMElement * aElement,
227
231
}
228
232
229
233
already_AddRefed<Element>
230
- nsHTMLEditor ::CreateGrabber (nsINode* aParentNode)
234
+ HTMLEditor ::CreateGrabber (nsINode* aParentNode)
231
235
{
232
236
// let's create a grabber through the element factory
233
237
nsCOMPtr<nsIDOMElement> retDOM;
@@ -247,7 +251,7 @@ nsHTMLEditor::CreateGrabber(nsINode* aParentNode)
247
251
}
248
252
249
253
NS_IMETHODIMP
250
- nsHTMLEditor ::RefreshGrabber ()
254
+ HTMLEditor ::RefreshGrabber ()
251
255
{
252
256
NS_ENSURE_TRUE (mAbsolutelyPositionedObject , NS_ERROR_NULL_POINTER);
253
257
@@ -270,7 +274,7 @@ nsHTMLEditor::RefreshGrabber()
270
274
}
271
275
272
276
NS_IMETHODIMP
273
- nsHTMLEditor ::HideGrabber ()
277
+ HTMLEditor ::HideGrabber ()
274
278
{
275
279
nsresult res = mAbsolutelyPositionedObject ->UnsetAttr (kNameSpaceID_None ,
276
280
nsGkAtoms::_moz_abspos,
@@ -298,7 +302,7 @@ nsHTMLEditor::HideGrabber()
298
302
}
299
303
300
304
NS_IMETHODIMP
301
- nsHTMLEditor ::ShowGrabberOnElement (nsIDOMElement * aElement)
305
+ HTMLEditor ::ShowGrabberOnElement (nsIDOMElement* aElement)
302
306
{
303
307
nsCOMPtr<Element> element = do_QueryInterface (aElement);
304
308
NS_ENSURE_ARG_POINTER (element);
@@ -327,7 +331,7 @@ nsHTMLEditor::ShowGrabberOnElement(nsIDOMElement * aElement)
327
331
}
328
332
329
333
nsresult
330
- nsHTMLEditor ::StartMoving (nsIDOMElement * aHandle)
334
+ HTMLEditor ::StartMoving (nsIDOMElement* aHandle)
331
335
{
332
336
nsCOMPtr<nsINode> parentNode = mGrabber ->GetParentNode ();
333
337
@@ -354,7 +358,7 @@ nsHTMLEditor::StartMoving(nsIDOMElement *aHandle)
354
358
}
355
359
356
360
void
357
- nsHTMLEditor ::SnapToGrid (int32_t & newX, int32_t & newY)
361
+ HTMLEditor ::SnapToGrid (int32_t & newX, int32_t & newY)
358
362
{
359
363
if (mSnapToGridEnabled && mGridSize ) {
360
364
newX = (int32_t ) floor ( ((float )newX / (float )mGridSize ) + 0 .5f ) * mGridSize ;
@@ -363,7 +367,7 @@ nsHTMLEditor::SnapToGrid(int32_t & newX, int32_t & newY)
363
367
}
364
368
365
369
nsresult
366
- nsHTMLEditor ::GrabberClicked ()
370
+ HTMLEditor ::GrabberClicked ()
367
371
{
368
372
// add a mouse move listener to the editor
369
373
nsresult res = NS_OK;
@@ -385,7 +389,7 @@ nsHTMLEditor::GrabberClicked()
385
389
}
386
390
387
391
nsresult
388
- nsHTMLEditor ::EndMoving ()
392
+ HTMLEditor ::EndMoving ()
389
393
{
390
394
if (mPositioningShadow ) {
391
395
nsCOMPtr<nsIPresShell> ps = GetPresShell ();
@@ -421,7 +425,8 @@ nsHTMLEditor::EndMoving()
421
425
return CheckSelectionStateForAnonymousButtons (selection);
422
426
}
423
427
nsresult
424
- nsHTMLEditor::SetFinalPosition (int32_t aX, int32_t aY)
428
+ HTMLEditor::SetFinalPosition (int32_t aX,
429
+ int32_t aY)
425
430
{
426
431
nsresult res = EndMoving ();
427
432
NS_ENSURE_SUCCESS (res, res);
@@ -456,7 +461,8 @@ nsHTMLEditor::SetFinalPosition(int32_t aX, int32_t aY)
456
461
}
457
462
458
463
void
459
- nsHTMLEditor::AddPositioningOffset (int32_t & aX, int32_t & aY)
464
+ HTMLEditor::AddPositioningOffset (int32_t & aX,
465
+ int32_t & aY)
460
466
{
461
467
// Get the positioning offset
462
468
int32_t positioningOffset =
@@ -467,8 +473,8 @@ nsHTMLEditor::AddPositioningOffset(int32_t & aX, int32_t & aY)
467
473
}
468
474
469
475
NS_IMETHODIMP
470
- nsHTMLEditor ::AbsolutelyPositionElement (nsIDOMElement* aElement,
471
- bool aEnabled)
476
+ HTMLEditor ::AbsolutelyPositionElement (nsIDOMElement* aElement,
477
+ bool aEnabled)
472
478
{
473
479
nsCOMPtr<Element> element = do_QueryInterface (aElement);
474
480
NS_ENSURE_ARG_POINTER (element);
@@ -540,36 +546,38 @@ nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement* aElement,
540
546
}
541
547
542
548
NS_IMETHODIMP
543
- nsHTMLEditor ::SetSnapToGridEnabled (bool aEnabled)
549
+ HTMLEditor ::SetSnapToGridEnabled (bool aEnabled)
544
550
{
545
551
mSnapToGridEnabled = aEnabled;
546
552
return NS_OK;
547
553
}
548
554
549
555
NS_IMETHODIMP
550
- nsHTMLEditor ::GetSnapToGridEnabled (bool * aIsEnabled)
556
+ HTMLEditor ::GetSnapToGridEnabled (bool * aIsEnabled)
551
557
{
552
558
*aIsEnabled = mSnapToGridEnabled ;
553
559
return NS_OK;
554
560
}
555
561
556
562
NS_IMETHODIMP
557
- nsHTMLEditor ::SetGridSize (uint32_t aSize)
563
+ HTMLEditor ::SetGridSize (uint32_t aSize)
558
564
{
559
565
mGridSize = aSize;
560
566
return NS_OK;
561
567
}
562
568
563
569
NS_IMETHODIMP
564
- nsHTMLEditor ::GetGridSize (uint32_t * aSize)
570
+ HTMLEditor ::GetGridSize (uint32_t * aSize)
565
571
{
566
572
*aSize = mGridSize ;
567
573
return NS_OK;
568
574
}
569
575
570
576
// self-explanatory
571
577
NS_IMETHODIMP
572
- nsHTMLEditor::SetElementPosition (nsIDOMElement *aElement, int32_t aX, int32_t aY)
578
+ HTMLEditor::SetElementPosition (nsIDOMElement* aElement,
579
+ int32_t aX,
580
+ int32_t aY)
573
581
{
574
582
nsCOMPtr<Element> element = do_QueryInterface (aElement);
575
583
NS_ENSURE_STATE (element);
@@ -579,7 +587,9 @@ nsHTMLEditor::SetElementPosition(nsIDOMElement *aElement, int32_t aX, int32_t aY
579
587
}
580
588
581
589
void
582
- nsHTMLEditor::SetElementPosition (dom::Element& aElement, int32_t aX, int32_t aY)
590
+ HTMLEditor::SetElementPosition (Element& aElement,
591
+ int32_t aX,
592
+ int32_t aY)
583
593
{
584
594
AutoEditBatch batchIt (this );
585
595
mCSSEditUtils ->SetCSSPropertyPixels (aElement, *nsGkAtoms::left, aX);
@@ -588,7 +598,7 @@ nsHTMLEditor::SetElementPosition(dom::Element& aElement, int32_t aX, int32_t aY)
588
598
589
599
// self-explanatory
590
600
NS_IMETHODIMP
591
- nsHTMLEditor ::GetPositionedElement (nsIDOMElement ** aReturn)
601
+ HTMLEditor ::GetPositionedElement (nsIDOMElement** aReturn)
592
602
{
593
603
nsCOMPtr<nsIDOMElement> ret =
594
604
static_cast <nsIDOMElement*>(GetAsDOMNode (mAbsolutelyPositionedObject ));
@@ -597,8 +607,8 @@ nsHTMLEditor::GetPositionedElement(nsIDOMElement ** aReturn)
597
607
}
598
608
599
609
nsresult
600
- nsHTMLEditor ::CheckPositionedElementBGandFG (nsIDOMElement * aElement,
601
- nsAString & aReturn)
610
+ HTMLEditor ::CheckPositionedElementBGandFG (nsIDOMElement* aElement,
611
+ nsAString& aReturn)
602
612
{
603
613
// we are going to outline the positioned element and bring it to the
604
614
// front to overlap any other element intersecting with it. But
@@ -664,3 +674,5 @@ nsHTMLEditor::CheckPositionedElementBGandFG(nsIDOMElement * aElement,
664
674
665
675
return NS_OK;
666
676
}
677
+
678
+ } // namespace mozilla
0 commit comments